@dcl/explore-site 0.0.1-24138829632.commit-0946e16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/HomePage-CbNrtXMa.js +3 -0
- package/assets/QueryClientProvider-DUSjZ_J_.js +2 -0
- package/assets/RoobertPRO-Bold-DDyOqNrI.woff2 +0 -0
- package/assets/RoobertPRO-Bold-zQ2qeH97.ttf +0 -0
- package/assets/SensorsRounded-Ci-z6t1A.js +15 -0
- package/assets/___vite-browser-external_commonjs-proxy-BqV5D26a.js +1 -0
- package/assets/__federation_expose_App-BckrSixU.js +1 -0
- package/assets/__federation_fn_import-WDa0gv1I.js +1 -0
- package/assets/__federation_shared_@dcl/hooks-BmGk-LAU.js +535 -0
- package/assets/__federation_shared_@dcl/schemas-FcJQcJ28.js +1 -0
- package/assets/__federation_shared_@emotion/react-oi_M7gMJ.js +1 -0
- package/assets/__federation_shared_@emotion/styled-YrTPT9q1.js +1 -0
- package/assets/__federation_shared_@reduxjs/toolkit-R1Ell7gI.js +1 -0
- package/assets/__federation_shared_decentraland-ui2-D5N7yacO.js +357 -0
- package/assets/__federation_shared_react-B3tlNTLg.js +1 -0
- package/assets/__federation_shared_react-dom-Dsn5WX9N.js +1 -0
- package/assets/__federation_shared_react-redux-DMak3BVq.js +13 -0
- package/assets/__federation_shared_react-router-dom-CSW28ZSI.js +49 -0
- package/assets/__federation_shared_viem-DsDw7lUr.js +2 -0
- package/assets/__federation_shared_wagmi-h3zhLZbR.js +17 -0
- package/assets/__vite-optional-peer-dep_lottie-react_decentraland-ui2-BIHI7g3E.js +1 -0
- package/assets/_commonjsHelpers-C4iS2aBk.js +1 -0
- package/assets/add-Ccyt7YRh.js +15 -0
- package/assets/all-wallets-BIOtzF11.js +6 -0
- package/assets/app-store-BqACXnTM.js +17 -0
- package/assets/apple-zIEkvR7h.js +18 -0
- package/assets/arrow-bottom-CxQ54WH1.js +8 -0
- package/assets/arrow-bottom-circle-BjCA11Rn.js +11 -0
- package/assets/arrow-left-CsFQBdFD.js +8 -0
- package/assets/arrow-right-jT5LSgqq.js +8 -0
- package/assets/arrow-top-CA_1oaHw.js +8 -0
- package/assets/auto-track-UOggKKzv.js +1 -0
- package/assets/bank-81NjtLlm.js +14 -0
- package/assets/basic-CvR9b359.js +2128 -0
- package/assets/brotli_wasm_bg-NfWIZley.wasm +0 -0
- package/assets/browser-BjIqaPVu.js +14 -0
- package/assets/card-BJomEEgV.js +14 -0
- package/assets/ccip-DotuofV0.js +1 -0
- package/assets/checkmark-Cz0VZAkr.js +11 -0
- package/assets/checkmark-bold-blkVLUov.js +8 -0
- package/assets/chevron-bottom-ClawczSo.js +8 -0
- package/assets/chevron-left-DfJ9r4mv.js +8 -0
- package/assets/chevron-right-CrxmyW0K.js +8 -0
- package/assets/chevron-top-BVIfb-H3.js +8 -0
- package/assets/chrome-store-Cb5xVI0B.js +61 -0
- package/assets/clock-Bx-Kyhh-.js +8 -0
- package/assets/close-DOjpWTZi.js +8 -0
- package/assets/coinPlaceholder-BqONZM6Q.js +8 -0
- package/assets/compass-ByyIpxD6.js +8 -0
- package/assets/copy-BOu2-Xgv.js +15 -0
- package/assets/core-BGxUaCGc.js +907 -0
- package/assets/create-submenu-Bu20F8-Z.webp +0 -0
- package/assets/createClient-CSnZgvsb.js +1 -0
- package/assets/cursor-BqYz2L6D.js +3 -0
- package/assets/cursor-transparent-CWCRGDtx.js +12 -0
- package/assets/custom-welcome-background-BxlFQma9.webp +0 -0
- package/assets/defineChain-7I0Ce1VT.js +1 -0
- package/assets/desktop-Cd_vx0kT.js +9 -0
- package/assets/disconnect-D5AICJhj.js +8 -0
- package/assets/discord-26Vqbq7c.js +17 -0
- package/assets/emotion-react.browser.esm-5OnyV0Sh.js +8 -0
- package/assets/emotion-use-insertion-effect-with-fallbacks.browser.esm-B75LdcJS.js +1 -0
- package/assets/etherscan--DKVcYrP.js +6 -0
- package/assets/exclamation-triangle-DOsYf3fQ.js +4 -0
- package/assets/explore-submenu-BFVuYMi9.webp +0 -0
- package/assets/extension-DEaO3Zvk.js +8 -0
- package/assets/external-link-DcpG6wpM.js +8 -0
- package/assets/facebook-ByV0OclL.js +26 -0
- package/assets/farcaster-DI6fsEyh.js +12 -0
- package/assets/filters-Djn1aDVs.js +8 -0
- package/assets/github-B3p0LLP5.js +18 -0
- package/assets/google-ae7qga4R.js +18 -0
- package/assets/governance-submenu-VTIKvCIL.webp +0 -0
- package/assets/help-circle-BmzUA_Be.js +12 -0
- package/assets/hooks.module-Dz_XB4AG.js +1 -0
- package/assets/id-2hYEZqNH.js +12 -0
- package/assets/image-mDqi4ffo.js +4 -0
- package/assets/index-9zCVakoE.js +1 -0
- package/assets/index-BKLT1eit.js +2 -0
- package/assets/index-Biwg5bHN.js +1 -0
- package/assets/index-BzXoRVC1.js +1 -0
- package/assets/index-C05H8NDX.js +1 -0
- package/assets/index-CGCGB-at.js +1 -0
- package/assets/index-CNMKbeE1.js +5 -0
- package/assets/index-CVdhIPEJ.js +1 -0
- package/assets/index-CdOcIHYV.js +395 -0
- package/assets/index-CdrMQoR6.js +1 -0
- package/assets/index-Ctl4brHr.js +2 -0
- package/assets/index-D6O4pjzC.js +12 -0
- package/assets/index-D6ZMQedT.js +1 -0
- package/assets/index-DGVKdsht.js +1 -0
- package/assets/index-D_fJMF1A.js +1 -0
- package/assets/index-Dy0yjznp.js +1 -0
- package/assets/index-Dy0yjznp__bundled.js +9 -0
- package/assets/index-JFBsW0Hp.js +1 -0
- package/assets/index-OQ3TYt4p.js +7 -0
- package/assets/index-VfkM29PH.js +1 -0
- package/assets/index-VfkM29PH__bundled.js +24 -0
- package/assets/index-nibyPLVP.js +1 -0
- package/assets/index-pEp_vRda.js +8 -0
- package/assets/index.es-D_4_VpXc.js +38 -0
- package/assets/index.umd-6zndRFhB.js +1 -0
- package/assets/info-Bhf5PLdi.js +3 -0
- package/assets/info-circle-CZ5iih32.js +12 -0
- package/assets/inherits_browser-BlmhoU4v.js +1 -0
- package/assets/is-plan-event-enabled-DeNtQvA5.js +1 -0
- package/assets/jsx-runtime-B1l0k91v.js +1 -0
- package/assets/jsx-runtime-B1l0k91v__bundled.js +9 -0
- package/assets/learn-submenu-sfxVP5Db.webp +0 -0
- package/assets/lightbulb-CA3e26a0.js +3 -0
- package/assets/localBatchGatewayRequest-vExM5jac.js +1 -0
- package/assets/logo-pattern-D4X-bvlg.webp +0 -0
- package/assets/mail-BktjMbEk.js +8 -0
- package/assets/man-default1-BEO13leF.png +0 -0
- package/assets/marketplace-submenu-CixWTv8_.webp +0 -0
- package/assets/mobile-zfEM0JzU.js +9 -0
- package/assets/more-Dg45xuT9.js +11 -0
- package/assets/native-CJ5et6AR.js +1 -0
- package/assets/network-placeholder-duQhExzj.js +14 -0
- package/assets/nftPlaceholder-C3kMYu-p.js +8 -0
- package/assets/off-Cz636L92.js +8 -0
- package/assets/play-store-Cch0eiCp.js +32 -0
- package/assets/plus-orAhHwVf.js +13 -0
- package/assets/preload-helper-BrYcp76J.js +1 -0
- package/assets/qr-code-7plug-hj.js +6 -0
- package/assets/recycle-horizontal-B6ivY9Sz.js +9 -0
- package/assets/refresh-CqfvjhXq.js +8 -0
- package/assets/remoteEntry.js +1 -0
- package/assets/reown-logo-DGoAljI9.js +12 -0
- package/assets/reselect-BfUrOuXx.js +1 -0
- package/assets/rich-text-react-renderer_decentraland-ui2-BIHI7g3E.js +1 -0
- package/assets/search-nNK2K8mD.js +8 -0
- package/assets/secp256k1-D6s48BOl.js +1 -0
- package/assets/send-BPz2SBvc.js +15 -0
- package/assets/swapHorizontal-TvVHlgjl.js +8 -0
- package/assets/swapHorizontalBold-BTw_LG1-.js +8 -0
- package/assets/swapHorizontalMedium-C3jJnFs_.js +16 -0
- package/assets/swapHorizontalRoundedBold-nTFwdVeT.js +8 -0
- package/assets/swapVertical-CHKvPR_7.js +8 -0
- package/assets/telegram-C552IoSr.js +16 -0
- package/assets/three-dots-Nyfa4nYF.js +5 -0
- package/assets/top_background-Bnd2vX_F.webp +0 -0
- package/assets/tslib.es6-DbvBTznf.js +1 -0
- package/assets/twitch-7SJKGXSa.js +18 -0
- package/assets/twitterIcon-BBg9ypIU.js +6 -0
- package/assets/uid-CX4a_w4r.js +44 -0
- package/assets/verify-BwQ9FKM1.js +8 -0
- package/assets/verify-filled-BAdDAZxZ.js +8 -0
- package/assets/w3m-modal-BqXXR9rX.js +642 -0
- package/assets/wallet-DJsa1d3M.js +8 -0
- package/assets/wallet-placeholder-DPIkQ5vM.js +14 -0
- package/assets/walletconnect-osdnzzVU.js +30 -0
- package/assets/warning-circle-BQ9uHGTL.js +12 -0
- package/assets/webSocket-CIn5Ftst.js +3 -0
- package/assets/x-5oycQ-0v.js +12 -0
- package/dcl-logo.svg +1 -0
- package/index.html +41 -0
- package/package.json +21 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const __vite__fileDeps=["assets/core-BGxUaCGc.js","assets/preload-helper-BrYcp76J.js","assets/_commonjsHelpers-C4iS2aBk.js","assets/index-nibyPLVP.js","assets/__federation_fn_import-WDa0gv1I.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
+
import{_ as _p}from"./preload-helper-BrYcp76J.js";import{g as pl,a as Ro,c as It}from"./_commonjsHelpers-C4iS2aBk.js";import{importShared as Ip}from"./__federation_fn_import-WDa0gv1I.js";import{c as $p,g as ga,s as Op,d as Dp,k as Sp,a as Pp}from"./index-nibyPLVP.js";var To={exports:{}},Vr=typeof Reflect=="object"?Reflect:null,ya=Vr&&typeof Vr.apply=="function"?Vr.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},hn;Vr&&typeof Vr.ownKeys=="function"?hn=Vr.ownKeys:Object.getOwnPropertySymbols?hn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:hn=function(e){return Object.getOwnPropertyNames(e)};function Ap(t){console&&console.warn&&console.warn(t)}var fl=Number.isNaN||function(e){return e!==e};function re(){re.init.call(this)}To.exports=re;To.exports.once=Tp;re.EventEmitter=re;re.prototype._events=void 0;re.prototype._eventsCount=0;re.prototype._maxListeners=void 0;var ma=10;function Ln(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(re,"defaultMaxListeners",{enumerable:!0,get:function(){return ma},set:function(t){if(typeof t!="number"||t<0||fl(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ma=t}});re.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};re.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||fl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function gl(t){return t._maxListeners===void 0?re.defaultMaxListeners:t._maxListeners}re.prototype.getMaxListeners=function(){return gl(this)};re.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")ya(c,this,r);else for(var u=c.length,l=vl(c,u),i=0;i<u;++i)ya(l[i],this,r);return!0};function yl(t,e,r,i){var n,s,o;if(Ln(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=gl(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,Ap(a)}return t}re.prototype.addListener=function(e,r){return yl(this,e,r,!1)};re.prototype.on=re.prototype.addListener;re.prototype.prependListener=function(e,r){return yl(this,e,r,!0)};function xp(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ml(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=xp.bind(i);return n.listener=r,i.wrapFn=n,n}re.prototype.once=function(e,r){return Ln(r),this.on(e,ml(this,e,r)),this};re.prototype.prependOnceListener=function(e,r){return Ln(r),this.prependListener(e,ml(this,e,r)),this};re.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Ln(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Cp(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};re.prototype.off=re.prototype.removeListener;re.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function wl(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?Rp(n):vl(n,n.length)}re.prototype.listeners=function(e){return wl(this,e,!0)};re.prototype.rawListeners=function(e){return wl(this,e,!1)};re.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):bl.call(t,e)};re.prototype.listenerCount=bl;function bl(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}re.prototype.eventNames=function(){return this._eventsCount>0?hn(this._events):[]};function vl(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Cp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Rp(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Tp(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}El(t,e,s,{once:!0}),e!=="error"&&Np(t,n,{once:!0})})}function Np(t,e,r){typeof t.on=="function"&&El(t,"error",e,r)}function El(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Lp=To.exports,N={};/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */var zs=function(t,e){return zs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},zs(t,e)};function jp(t,e){zs(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Hs=function(){return Hs=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Hs.apply(this,arguments)};function Bp(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Mp(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Fp(t,e){return function(r,i){e(r,i,t)}}function Up(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function qp(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{u(i.next(l))}catch(h){o(h)}}function c(l){try{u(i.throw(l))}catch(h){o(h)}}function u(l){l.done?s(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})}function kp(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function zp(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Hp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Ks(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _l(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function Kp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(_l(arguments[e]));return t}function Vp(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function Pi(t){return this instanceof Pi?(this.v=t,this):new Pi(t)}function Wp(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(d){i[d]&&(n[d]=function(f){return new Promise(function(p,y){s.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(i[d](f))}catch(p){h(s[0][3],p)}}function c(d){d.value instanceof Pi?Promise.resolve(d.value.v).then(u,l):h(s[0][2],d)}function u(d){a("next",d)}function l(d){a("throw",d)}function h(d,f){d(f),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Gp(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:Pi(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function Yp(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Ks=="function"?Ks(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}function Jp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Zp(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Qp(t){return t&&t.__esModule?t:{default:t}}function Xp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function ef(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const tf=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Hs},__asyncDelegator:Gp,__asyncGenerator:Wp,__asyncValues:Yp,__await:Pi,__awaiter:qp,__classPrivateFieldGet:Xp,__classPrivateFieldSet:ef,__createBinding:zp,__decorate:Mp,__exportStar:Hp,__extends:jp,__generator:kp,__importDefault:Qp,__importStar:Zp,__makeTemplateObject:Jp,__metadata:Up,__param:Fp,__read:_l,__rest:Bp,__spread:Kp,__spreadArrays:Vp,__values:Ks},Symbol.toStringTag,{value:"Module"})),jn=pl(tf);var os={},hi={},wa;function rf(){if(wa)return hi;wa=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return hi.delay=t,hi}var Qt={},as={},Xt={},ba;function nf(){return ba||(ba=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.ONE_THOUSAND=Xt.ONE_HUNDRED=void 0,Xt.ONE_HUNDRED=100,Xt.ONE_THOUSAND=1e3),Xt}var cs={},va;function sf(){return va||(va=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(cs)),cs}var Ea;function Il(){return Ea||(Ea=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=jn;e.__exportStar(nf(),t),e.__exportStar(sf(),t)}(as)),as}var _a;function of(){if(_a)return Qt;_a=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.fromMiliseconds=Qt.toMiliseconds=void 0;const t=Il();function e(i){return i*t.ONE_THOUSAND}Qt.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Qt.fromMiliseconds=r,Qt}var Ia;function af(){return Ia||(Ia=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=jn;e.__exportStar(rf(),t),e.__exportStar(of(),t)}(os)),os}var _r={},$a;function cf(){if($a)return _r;$a=1,Object.defineProperty(_r,"__esModule",{value:!0}),_r.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return _r.Watch=t,_r.default=t,_r}var us={},di={},Oa;function uf(){if(Oa)return di;Oa=1,Object.defineProperty(di,"__esModule",{value:!0}),di.IWatch=void 0;class t{}return di.IWatch=t,di}var Da;function lf(){return Da||(Da=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),jn.__exportStar(uf(),t)}(us)),us}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=jn;e.__exportStar(af(),t),e.__exportStar(cf(),t),e.__exportStar(lf(),t),e.__exportStar(Il(),t)})(N);class yr{}let hf=class extends yr{constructor(e){super()}};const Sa=N.FIVE_SECONDS,mr={pulse:"heartbeat_pulse"};let df=class $l extends hf{constructor(e){super(e),this.events=new Lp.EventEmitter,this.interval=Sa,this.interval=e?.interval||Sa}static async init(e){const r=new $l(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),N.toMiliseconds(this.interval))}pulse(){this.events.emit(mr.pulse)}};const pf=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,ff=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,gf=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function yf(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){mf(t);return}return e}function mf(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Gi(t,e={}){if(typeof t!="string")return t;if(t[0]==='"'&&t[t.length-1]==='"'&&t.indexOf("\\")===-1)return t.slice(1,-1);const r=t.trim();if(r.length<=9)switch(r.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!gf.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(pf.test(t)||ff.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,yf)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}const wf=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),bf=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function hr(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return bf(t)}catch{return t}}function Ft(t){return typeof t=="string"?t:wf(t)||""}function vf(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Ef=_f;function _f(t,e,r){var i=r&&r.stringify||vf,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var u="",l=1-n,h=-1,d=t&&t.length||0,f=0;f<d;){if(t.charCodeAt(f)===37&&f+1<d){switch(h=h>-1?h:0,t.charCodeAt(f+1)){case 100:case 102:if(l>=c||e[l]==null)break;h<f&&(u+=t.slice(h,f)),u+=Number(e[l]),h=f+2,f++;break;case 105:if(l>=c||e[l]==null)break;h<f&&(u+=t.slice(h,f)),u+=Math.floor(Number(e[l])),h=f+2,f++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;h<f&&(u+=t.slice(h,f));var p=typeof e[l];if(p==="string"){u+="'"+e[l]+"'",h=f+2,f++;break}if(p==="function"){u+=e[l].name||"<anonymous>",h=f+2,f++;break}u+=i(e[l]),h=f+2,f++;break;case 115:if(l>=c)break;h<f&&(u+=t.slice(h,f)),u+=String(e[l]),h=f+2,f++;break;case 37:h<f&&(u+=t.slice(h,f)),u+="%",h=f+2,f++,l--;break}++l}++f}return h===-1?t:(h<d&&(u+=t.slice(h)),u)}const Pa=Ef;var qr=Ot;const Ai=Rf().console||{},If={mapHttpRequest:Yi,mapHttpResponse:Yi,wrapRequestSerializer:ls,wrapResponseSerializer:ls,wrapErrorSerializer:ls,req:Yi,res:Yi,err:Pf};function $f(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Ot(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||Ai;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=$f(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=xi),Object.defineProperty(c,"levelVal",{get:l}),Object.defineProperty(c,"level",{get:h,set:d});const u={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:Af(t)};c.levels=Ot.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=xi,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=f,e&&(c._logEvent=Vs());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function h(){return this._level}function d(p){if(p!=="silent"&&!this.levels.values[p])throw Error("unknown level "+p);this._level=p,Ir(u,c,"error","log"),Ir(u,c,"fatal","error"),Ir(u,c,"warn","error"),Ir(u,c,"info","log"),Ir(u,c,"debug","log"),Ir(u,c,"trace","log")}function f(p,y){if(!p)throw new Error("missing bindings for child Pino");y=y||{},n&&p.serializers&&(y.serializers=p.serializers);const w=y.serializers;if(n&&w){var v=Object.assign({},i,w),b=t.browser.serialize===!0?Object.keys(v):n;delete p.serializers,Bn([p],b,v,this._stdErrSerialize)}function E($){this._childLevel=($._childLevel|0)+1,this.error=$r($,p,"error"),this.fatal=$r($,p,"fatal"),this.warn=$r($,p,"warn"),this.info=$r($,p,"info"),this.debug=$r($,p,"debug"),this.trace=$r($,p,"trace"),v&&(this.serializers=v,this._serialize=b),e&&(this._logEvent=Vs([].concat($._logEvent.bindings,p)))}return E.prototype=this,new E(this)}return c}Ot.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"}};Ot.stdSerializers=If;Ot.stdTimeFunctions=Object.assign({},{nullTime:Ol,epochTime:Dl,unixTime:xf,isoTime:Cf});function Ir(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?xi:n[r]?n[r]:Ai[r]||Ai[i]||xi,Of(t,e,r)}function Of(t,e,r){!t.transmit&&e[r]===xi||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ai?Ai:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&Bn(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,Df(this,r,o,s)):i.apply(a,o),t.transmit){const u=t.transmit.level||e.level,l=Ot.levels.values[u],h=Ot.levels.values[r];if(h<l)return;Sf(this,{ts:s,methodLevel:r,methodValue:h,transmitLevel:u,transmitValue:Ot.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function Df(t,e,r,i){t._serialize&&Bn(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Ot.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Pa(n.shift(),n):void 0}else typeof s=="string"&&(s=Pa(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Bn(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Ot.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function $r(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function Sf(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;Bn(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(u){return c.indexOf(u)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=Vs(c)}function Vs(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Pf(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function Af(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ol:Dl}function Yi(){return{}}function ls(t){return t}function xi(){}function Ol(){return!1}function Dl(){return Date.now()}function xf(){return Math.round(Date.now()/1e3)}function Cf(){return new Date(Date.now()).toISOString()}function Rf(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const Bi=Ro(qr),Tf={level:"info"},Mi="custom_context",No=1e3*1024;let Nf=class{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}},Aa=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new Nf(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.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 r=e.value;return e=e.next,{done:!1,value:r}}}}},Sl=class{constructor(e,r=No){this.level=e??"error",this.levelValue=qr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Aa(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===qr.levels.values.error?console.error(e):r===qr.levels.values.warn?console.warn(e):r===qr.levels.values.debug?console.debug(e):r===qr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Ft({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Aa(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Ft({extraMetadata:e})),new Blob(r,{type:"application/json"})}},Lf=class{constructor(e,r=No){this.baseChunkLogger=new Sl(e,r)}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 r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}},jf=class{constructor(e,r=No){this.baseChunkLogger=new Sl(e,r)}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 Bf=Object.defineProperty,Mf=Object.defineProperties,Ff=Object.getOwnPropertyDescriptors,xa=Object.getOwnPropertySymbols,Uf=Object.prototype.hasOwnProperty,qf=Object.prototype.propertyIsEnumerable,Ca=(t,e,r)=>e in t?Bf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,In=(t,e)=>{for(var r in e||(e={}))Uf.call(e,r)&&Ca(t,r,e[r]);if(xa)for(var r of xa(e))qf.call(e,r)&&Ca(t,r,e[r]);return t},$n=(t,e)=>Mf(t,Ff(e));function Mn(t){return $n(In({},t),{level:t?.level||Tf.level})}function kf(t,e=Mi){return t[e]||""}function zf(t,e,r=Mi){return t[r]=e,t}function Ve(t,e=Mi){let r="";return typeof t.bindings>"u"?r=kf(t,e):r=t.bindings().context||"",r}function Hf(t,e,r=Mi){const i=Ve(t,r);return i.trim()?`${i}/${e}`:e}function Fe(t,e,r=Mi){const i=Hf(t,e,r),n=t.child({context:i});return zf(n,i,r)}function Kf(t){var e,r;const i=new Lf((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Bi($n(In({},t.opts),{level:"trace",browser:$n(In({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function Vf(t){var e;const r=new jf((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Bi($n(In({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function Wf(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Kf(t):Vf(t)}function Gf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pl(t,...e){if(!Gf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ra(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Yf(t,e){Pl(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Or=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Jf(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Al(t){return typeof t=="string"&&(t=Jf(t)),Pl(t),t}let Zf=class{clone(){return this._cloneInto()}};function Qf(t){const e=i=>t().update(Al(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function xl(t=32){if(Or&&typeof Or.getRandomValues=="function")return Or.getRandomValues(new Uint8Array(t));if(Or&&typeof Or.randomBytes=="function")return Or.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Xf(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,u=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+u,a,i)}let eg=class extends Zf{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=hs(this.buffer)}update(e){Ra(this);const{view:r,buffer:i,blockLen:n}=this;e=Al(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=hs(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ra(this),Yf(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)r[h]=0;Xf(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=hs(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}};const Ji=BigInt(2**32-1),Ws=BigInt(32);function Cl(t,e=!1){return e?{h:Number(t&Ji),l:Number(t>>Ws&Ji)}:{h:Number(t>>Ws&Ji)|0,l:Number(t&Ji)|0}}function tg(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=Cl(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const rg=(t,e)=>BigInt(t>>>0)<<Ws|BigInt(e>>>0),ig=(t,e,r)=>t>>>r,ng=(t,e,r)=>t<<32-r|e>>>r,sg=(t,e,r)=>t>>>r|e<<32-r,og=(t,e,r)=>t<<32-r|e>>>r,ag=(t,e,r)=>t<<64-r|e>>>r-32,cg=(t,e,r)=>t>>>r-32|e<<64-r,ug=(t,e)=>e,lg=(t,e)=>t,hg=(t,e,r)=>t<<r|e>>>32-r,dg=(t,e,r)=>e<<r|t>>>32-r,pg=(t,e,r)=>e<<r-32|t>>>64-r,fg=(t,e,r)=>t<<r-32|e>>>64-r;function gg(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const yg=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),mg=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,wg=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),bg=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,vg=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),Eg=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,K={fromBig:Cl,split:tg,toBig:rg,shrSH:ig,shrSL:ng,rotrSH:sg,rotrSL:og,rotrBH:ag,rotrBL:cg,rotr32H:ug,rotr32L:lg,rotlSH:hg,rotlSL:dg,rotlBH:pg,rotlBL:fg,add:gg,add3L:yg,add3H:mg,add4L:wg,add4H:bg,add5H:Eg,add5L:vg},[_g,Ig]=K.split(["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","0xf40e35855771202a","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(t=>BigInt(t))),qt=new Uint32Array(80),kt=new Uint32Array(80);let $g=class extends eg{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:u,El:l,Fh:h,Fl:d,Gh:f,Gl:p,Hh:y,Hl:w}=this;return[e,r,i,n,s,o,a,c,u,l,h,d,f,p,y,w]}set(e,r,i,n,s,o,a,c,u,l,h,d,f,p,y,w){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=w|0}process(e,r){for(let E=0;E<16;E++,r+=4)qt[E]=e.getUint32(r),kt[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){const $=qt[E-15]|0,A=kt[E-15]|0,P=K.rotrSH($,A,1)^K.rotrSH($,A,8)^K.shrSH($,A,7),S=K.rotrSL($,A,1)^K.rotrSL($,A,8)^K.shrSL($,A,7),C=qt[E-2]|0,O=kt[E-2]|0,q=K.rotrSH(C,O,19)^K.rotrBH(C,O,61)^K.shrSH(C,O,6),B=K.rotrSL(C,O,19)^K.rotrBL(C,O,61)^K.shrSL(C,O,6),j=K.add4L(S,B,kt[E-7],kt[E-16]),k=K.add4H(j,P,q,qt[E-7],qt[E-16]);qt[E]=k|0,kt[E]=j|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:u,Dl:l,Eh:h,El:d,Fh:f,Fl:p,Gh:y,Gl:w,Hh:v,Hl:b}=this;for(let E=0;E<80;E++){const $=K.rotrSH(h,d,14)^K.rotrSH(h,d,18)^K.rotrBH(h,d,41),A=K.rotrSL(h,d,14)^K.rotrSL(h,d,18)^K.rotrBL(h,d,41),P=h&f^~h&y,S=d&p^~d&w,C=K.add5L(b,A,S,Ig[E],kt[E]),O=K.add5H(C,v,$,P,_g[E],qt[E]),q=C|0,B=K.rotrSH(i,n,28)^K.rotrBH(i,n,34)^K.rotrBH(i,n,39),j=K.rotrSL(i,n,28)^K.rotrBL(i,n,34)^K.rotrBL(i,n,39),k=i&s^i&a^s&a,R=n&o^n&c^o&c;v=y|0,b=w|0,y=f|0,w=p|0,f=h|0,p=d|0,{h,l:d}=K.add(u|0,l|0,O|0,q|0),u=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const g=K.add3L(q,j,R);i=K.add3H(g,O,B,k),n=g|0}({h:i,l:n}=K.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=K.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=K.add(this.Dh|0,this.Dl|0,u|0,l|0),{h,l:d}=K.add(this.Eh|0,this.El|0,h|0,d|0),{h:f,l:p}=K.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:w}=K.add(this.Gh|0,this.Gl|0,y|0,w|0),{h:v,l:b}=K.add(this.Hh|0,this.Hl|0,v|0,b|0),this.set(i,n,s,o,a,c,u,l,h,d,f,p,y,w,v,b)}roundClean(){qt.fill(0),kt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const Og=Qf(()=>new $g);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Lo=BigInt(0),Rl=BigInt(1),Dg=BigInt(2);function jo(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Bo(t){if(!jo(t))throw new Error("Uint8Array expected")}function ds(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Sg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Mo(t){Bo(t);let e="";for(let r=0;r<t.length;r++)e+=Sg[t[r]];return e}function Tl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Lo:BigInt("0x"+t)}const At={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ta(t){if(t>=At._0&&t<=At._9)return t-At._0;if(t>=At.A&&t<=At.F)return t-(At.A-10);if(t>=At.a&&t<=At.f)return t-(At.a-10)}function Nl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Ta(t.charCodeAt(s)),a=Ta(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Pg(t){return Tl(Mo(t))}function dn(t){return Bo(t),Tl(Mo(Uint8Array.from(t).reverse()))}function Ll(t,e){return Nl(t.toString(16).padStart(e*2,"0"))}function Gs(t,e){return Ll(t,e).reverse()}function xt(t,e,r){let i;if(typeof e=="string")try{i=Nl(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(jo(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function Na(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Bo(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const ps=t=>typeof t=="bigint"&&Lo<=t;function Ag(t,e,r){return ps(t)&&ps(e)&&ps(r)&&e<=t&&t<r}function pi(t,e,r,i){if(!Ag(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function xg(t){let e;for(e=0;t>Lo;t>>=Rl,e+=1);return e}const Cg=t=>(Dg<<BigInt(t-1))-Rl,Rg={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||jo(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Fo(t,e,r={}){const i=(n,s,o)=>{const a=Rg[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function La(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const $e=BigInt(0),pe=BigInt(1),nr=BigInt(2),Tg=BigInt(3),Ys=BigInt(4),ja=BigInt(5),Ba=BigInt(8);function we(t,e){const r=t%e;return r>=$e?r:e+r}function Ng(t,e,r){if(e<$e)throw new Error("invalid exponent, negatives unsupported");if(r<=$e)throw new Error("invalid modulus");if(r===pe)return $e;let i=pe;for(;e>$e;)e&pe&&(i=i*t%r),t=t*t%r,e>>=pe;return i}function yt(t,e,r){let i=t;for(;e-- >$e;)i*=i,i%=r;return i}function Ma(t,e){if(t===$e)throw new Error("invert: expected non-zero number");if(e<=$e)throw new Error("invert: expected positive modulus, got "+e);let r=we(t,e),i=e,n=$e,s=pe;for(;r!==$e;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==pe)throw new Error("invert: does not exist");return we(n,e)}function Lg(t){const e=(t-pe)/nr;let r,i,n;for(r=t-pe,i=0;r%nr===$e;r/=nr,i++);for(n=nr;n<t&&Ng(n,e,t)!==t-pe;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+pe)/Ys;return function(a,c){const u=a.pow(c,o);if(!a.eql(a.sqr(u),c))throw new Error("Cannot find square root");return u}}const s=(r+pe)/nr;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,u=o.pow(o.mul(o.ONE,n),r),l=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(h);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(u,pe<<BigInt(c-d-1));u=o.sqr(f),l=o.mul(l,f),h=o.mul(h,u),c=d}return l}}function jg(t){if(t%Ys===Tg){const e=(t+pe)/Ys;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%Ba===ja){const e=(t-ja)/Ba;return function(r,i){const n=r.mul(i,nr),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,nr),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return Lg(t)}const Bg=(t,e)=>(we(t,e)&pe)===pe,Mg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Fg(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Mg.reduce((i,n)=>(i[n]="function",i),e);return Fo(t,r)}function Ug(t,e,r){if(r<$e)throw new Error("invalid exponent, negatives unsupported");if(r===$e)return t.ONE;if(r===pe)return e;let i=t.ONE,n=e;for(;r>$e;)r&pe&&(i=t.mul(i,n)),n=t.sqr(n),r>>=pe;return i}function qg(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function jl(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Bl(t,e,r=!1,i={}){if(t<=$e)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=jl(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:Cg(n),ZERO:$e,ONE:pe,create:c=>we(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return $e<=c&&c<t},is0:c=>c===$e,isOdd:c=>(c&pe)===pe,neg:c=>we(-c,t),eql:(c,u)=>c===u,sqr:c=>we(c*c,t),add:(c,u)=>we(c+u,t),sub:(c,u)=>we(c-u,t),mul:(c,u)=>we(c*u,t),pow:(c,u)=>Ug(a,c,u),div:(c,u)=>we(c*Ma(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ma(c,t),sqrt:i.sqrt||(c=>(o||(o=jg(t)),o(a,c))),invertBatch:c=>qg(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>r?Gs(c,s):Ll(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?dn(c):Pg(c)}});return Object.freeze(a)}const Fa=BigInt(0),Zi=BigInt(1);function fs(t,e){const r=e.negate();return t?r:e}function Ml(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function gs(t,e){Ml(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function kg(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function zg(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const ys=new WeakMap,Fl=new WeakMap;function ms(t){return Fl.get(t)||1}function Hg(t,e){return{constTimeNegate:fs,hasPrecomputes(r){return ms(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Fa;)i&Zi&&(n=n.add(s)),s=s.double(),i>>=Zi;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=gs(i,e),o=[];let a=r,c=a;for(let u=0;u<n;u++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=gs(r,e);let a=t.ZERO,c=t.BASE;const u=BigInt(2**r-1),l=2**r,h=BigInt(r);for(let d=0;d<s;d++){const f=d*o;let p=Number(n&u);n>>=h,p>o&&(p-=l,n+=Zi);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(fs(v,i[y])):a=a.add(fs(b,i[w]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=gs(r,e),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<o;h++){const d=h*a;if(n===Fa)break;let f=Number(n&c);if(n>>=l,f>a&&(f-=u,n+=Zi),f===0)continue;let p=i[d+Math.abs(f)-1];f<0&&(p=p.negate()),s=s.add(p)}return s},getPrecomputes(r,i,n){let s=ys.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&ys.set(i,n(s))),s},wNAFCached(r,i,n){const s=ms(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=ms(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Ml(i,e),Fl.set(r,i),ys.delete(r)}}}function Kg(t,e,r,i){if(kg(r,t),zg(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=xg(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),u=Math.floor((e.BITS-1)/o)*o;let l=n;for(let h=u;h>=0;h-=o){c.fill(n);for(let f=0;f<i.length;f++){const p=i[f],y=Number(p>>BigInt(h)&BigInt(a));c[y]=c[y].add(r[f])}let d=n;for(let f=c.length-1,p=n;f>0;f--)p=p.add(c[f]),d=d.add(p);if(l=l.add(d),h!==0)for(let f=0;f<o;f++)l=l.double()}return l}function Vg(t){return Fg(t.Fp),Fo(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...jl(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const ct=BigInt(0),Ue=BigInt(1),Qi=BigInt(2),Wg=BigInt(8),Gg={zip215:!0};function Yg(t){const e=Vg(t);return Fo(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Jg(t){const e=Yg(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,u=Qi<<BigInt(a*8)-Ue,l=r.create,h=Bl(e.n,e.nBitLength),d=e.uvRatio||((g,m)=>{try{return{isValid:!0,value:r.sqrt(g*r.inv(m))}}catch{return{isValid:!1,value:ct}}}),f=e.adjustScalarBytes||(g=>g),p=e.domain||((g,m,_)=>{if(ds("phflag",_),m.length||_)throw new Error("Contexts/pre-hash are not supported");return g});function y(g,m){pi("coordinate "+g,m,ct,u)}function w(g){if(!(g instanceof E))throw new Error("ExtendedPoint expected")}const v=La((g,m)=>{const{ex:_,ey:D,ez:I}=g,x=g.is0();m==null&&(m=x?Wg:r.inv(I));const M=l(_*m),U=l(D*m),z=l(I*m);if(x)return{x:ct,y:Ue};if(z!==Ue)throw new Error("invZ was invalid");return{x:M,y:U}}),b=La(g=>{const{a:m,d:_}=e;if(g.is0())throw new Error("bad point: ZERO");const{ex:D,ey:I,ez:x,et:M}=g,U=l(D*D),z=l(I*I),F=l(x*x),H=l(F*F),G=l(U*m),ue=l(F*l(G+z)),ee=l(H+l(_*l(U*z)));if(ue!==ee)throw new Error("bad point: equation left != right (1)");const Y=l(D*I),Te=l(x*M);if(Y!==Te)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(m,_,D,I){this.ex=m,this.ey=_,this.ez=D,this.et=I,y("x",m),y("y",_),y("z",D),y("t",I),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof E)throw new Error("extended point not allowed");const{x:_,y:D}=m||{};return y("x",_),y("y",D),new E(_,D,Ue,l(_*D))}static normalizeZ(m){const _=r.invertBatch(m.map(D=>D.ez));return m.map((D,I)=>D.toAffine(_[I])).map(E.fromAffine)}static msm(m,_){return Kg(E,h,m,_)}_setWindowSize(m){P.setWindowSize(this,m)}assertValidity(){b(this)}equals(m){w(m);const{ex:_,ey:D,ez:I}=this,{ex:x,ey:M,ez:U}=m,z=l(_*U),F=l(x*I),H=l(D*U),G=l(M*I);return z===F&&H===G}is0(){return this.equals(E.ZERO)}negate(){return new E(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:m}=e,{ex:_,ey:D,ez:I}=this,x=l(_*_),M=l(D*D),U=l(Qi*l(I*I)),z=l(m*x),F=_+D,H=l(l(F*F)-x-M),G=z+M,ue=G-U,ee=z-M,Y=l(H*ue),Te=l(G*ee),De=l(H*ee),je=l(ue*G);return new E(Y,Te,je,De)}add(m){w(m);const{a:_,d:D}=e,{ex:I,ey:x,ez:M,et:U}=this,{ex:z,ey:F,ez:H,et:G}=m;if(_===BigInt(-1)){const ca=l((x-I)*(F+z)),ua=l((x+I)*(F-z)),ss=l(ua-ca);if(ss===ct)return this.double();const la=l(M*Qi*G),ha=l(U*Qi*H),da=ha+la,pa=ua+ca,fa=ha-la,wp=l(da*ss),bp=l(pa*fa),vp=l(da*fa),Ep=l(ss*pa);return new E(wp,bp,Ep,vp)}const ue=l(I*z),ee=l(x*F),Y=l(U*D*G),Te=l(M*H),De=l((I+x)*(z+F)-ue-ee),je=Te-Y,et=Te+Y,Pt=l(ee-_*ue),Er=l(De*je),gp=l(et*Pt),yp=l(De*Pt),mp=l(je*et);return new E(Er,gp,mp,yp)}subtract(m){return this.add(m.negate())}wNAF(m){return P.wNAFCached(this,m,E.normalizeZ)}multiply(m){const _=m;pi("scalar",_,Ue,i);const{p:D,f:I}=this.wNAF(_);return E.normalizeZ([D,I])[0]}multiplyUnsafe(m,_=E.ZERO){const D=m;return pi("scalar",D,ct,i),D===ct?A:this.is0()||D===Ue?this:P.wNAFCachedUnsafe(this,D,E.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return P.unsafeLadder(this,i).is0()}toAffine(m){return v(this,m)}clearCofactor(){const{h:m}=e;return m===Ue?this:this.multiplyUnsafe(m)}static fromHex(m,_=!1){const{d:D,a:I}=e,x=r.BYTES;m=xt("pointHex",m,x),ds("zip215",_);const M=m.slice(),U=m[x-1];M[x-1]=U&-129;const z=dn(M),F=_?u:r.ORDER;pi("pointHex.y",z,ct,F);const H=l(z*z),G=l(H-Ue),ue=l(D*H-I);let{isValid:ee,value:Y}=d(G,ue);if(!ee)throw new Error("Point.fromHex: invalid y coordinate");const Te=(Y&Ue)===Ue,De=(U&128)!==0;if(!_&&Y===ct&&De)throw new Error("Point.fromHex: x=0 and x_0=1");return De!==Te&&(Y=l(-Y)),E.fromAffine({x:Y,y:z})}static fromPrivateKey(m){return O(m).point}toRawBytes(){const{x:m,y:_}=this.toAffine(),D=Gs(_,r.BYTES);return D[D.length-1]|=m&Ue?128:0,D}toHex(){return Mo(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Ue,l(e.Gx*e.Gy)),E.ZERO=new E(ct,Ue,Ue,ct);const{BASE:$,ZERO:A}=E,P=Hg(E,a*8);function S(g){return we(g,i)}function C(g){return S(dn(g))}function O(g){const m=r.BYTES;g=xt("private key",g,m);const _=xt("hashed private key",s(g),2*m),D=f(_.slice(0,m)),I=_.slice(m,2*m),x=C(D),M=$.multiply(x),U=M.toRawBytes();return{head:D,prefix:I,scalar:x,point:M,pointBytes:U}}function q(g){return O(g).pointBytes}function B(g=new Uint8Array,...m){const _=Na(...m);return C(s(p(_,xt("context",g),!!n)))}function j(g,m,_={}){g=xt("message",g),n&&(g=n(g));const{prefix:D,scalar:I,pointBytes:x}=O(m),M=B(_.context,D,g),U=$.multiply(M).toRawBytes(),z=B(_.context,U,x,g),F=S(M+z*I);pi("signature.s",F,ct,i);const H=Na(U,Gs(F,r.BYTES));return xt("result",H,r.BYTES*2)}const k=Gg;function R(g,m,_,D=k){const{context:I,zip215:x}=D,M=r.BYTES;g=xt("signature",g,2*M),m=xt("message",m),_=xt("publicKey",_,M),x!==void 0&&ds("zip215",x),n&&(m=n(m));const U=dn(g.slice(M,2*M));let z,F,H;try{z=E.fromHex(_,x),F=E.fromHex(g.slice(0,M),x),H=$.multiplyUnsafe(U)}catch{return!1}if(!x&&z.isSmallOrder())return!1;const G=B(I,F.toRawBytes(),z.toRawBytes(),m);return F.add(z.multiplyUnsafe(G)).subtract(H).clearCofactor().equals(E.ZERO)}return $._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:j,verify:R,ExtendedPoint:E,utils:{getExtendedPublicKey:O,randomPrivateKey:()=>o(r.BYTES),precompute(g=8,m=E.BASE){return m._setWindowSize(g),m.multiply(BigInt(3)),m}}}}BigInt(0),BigInt(1);const Uo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ua=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Zg=BigInt(1),qa=BigInt(2);BigInt(3);const Qg=BigInt(5),Xg=BigInt(8);function ey(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Uo,o=t*t%s*t%s,a=yt(o,qa,s)*o%s,c=yt(a,Zg,s)*t%s,u=yt(c,Qg,s)*c%s,l=yt(u,e,s)*u%s,h=yt(l,r,s)*l%s,d=yt(h,i,s)*h%s,f=yt(d,n,s)*d%s,p=yt(f,n,s)*d%s,y=yt(p,e,s)*u%s;return{pow_p_5_8:yt(y,qa,s)*t%s,b2:o}}function ty(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ry(t,e){const r=Uo,i=we(e*e*e,r),n=we(i*i*e,r),s=ey(t*n).pow_p_5_8;let o=we(t*i*s,r);const a=we(e*o*o,r),c=o,u=we(o*Ua,r),l=a===t,h=a===we(-t,r),d=a===we(-t*Ua,r);return l&&(o=c),(h||d)&&(o=u),Bg(o,r)&&(o=we(-o,r)),{isValid:l||h,value:o}}const iy=Bl(Uo,void 0,!0),ny={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:iy,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Xg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Og,randomBytes:xl,adjustScalarBytes:ty,uvRatio:ry},Ul=Jg(ny),sy="EdDSA",oy="JWT",On=".",Fn="base64url",ql="utf8",kl="utf8",ay=":",cy="did",uy="key",ka="base58btc",ly="z",hy="K36",dy=32;function qo(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function zl(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?qo(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Hl(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=zl(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return qo(r)}function py(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*l+1>>>0,$=new Uint8Array(E);v!==b;){for(var A=p[v],P=0,S=E-1;(A!==0||P<w)&&S!==-1;S--,P++)A+=256*$[S]>>>0,$[S]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=P,v++}for(var C=E-w;C!==E&&$[C]===0;)C++;for(var O=c.repeat(y);C<E;++C)O+=t.charAt($[C]);return O}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var $=r[p.charCodeAt(y)];if($===255)return;for(var A=0,P=b-1;($!==0||A<v)&&P!==-1;P--,A++)$+=a*E[P]>>>0,E[P]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");v=A,y++}if(p[y]!==" "){for(var S=b-v;S!==b&&E[S]===0;)S++;for(var C=new Uint8Array(w+(b-S)),O=w;S!==b;)C[O++]=E[S++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var fy=py,gy=fy;const Kl=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},yy=t=>new TextEncoder().encode(t),my=t=>new TextDecoder().decode(t);let wy=class{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},by=class{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Vl(this,e)}},vy=class{constructor(e){this.decoders=e}or(e){return Vl(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Vl=(t,e)=>new vy({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let Ey=class{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new wy(e,r,i),this.decoder=new by(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Un=({name:t,prefix:e,encode:r,decode:i})=>new Ey(t,e,r,i),Fi=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=gy(r,e);return Un({prefix:t,name:e,encode:i,decode:s=>Kl(n(s))})},_y=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Iy=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},xe=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Un({prefix:e,name:t,encode(n){return Iy(n,i,r)},decode(n){return _y(n,i,r,t)}}),$y=Un({prefix:"\0",name:"identity",encode:t=>my(t),decode:t=>yy(t)});var Oy=Object.freeze({__proto__:null,identity:$y});const Dy=xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Sy=Object.freeze({__proto__:null,base2:Dy});const Py=xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ay=Object.freeze({__proto__:null,base8:Py});const xy=Fi({prefix:"9",name:"base10",alphabet:"0123456789"});var Cy=Object.freeze({__proto__:null,base10:xy});const Ry=xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ty=xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ny=Object.freeze({__proto__:null,base16:Ry,base16upper:Ty});const Ly=xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jy=xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),By=xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),My=xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Fy=xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uy=xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qy=xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ky=xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zy=xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hy=Object.freeze({__proto__:null,base32:Ly,base32upper:jy,base32pad:By,base32padupper:My,base32hex:Fy,base32hexupper:Uy,base32hexpad:qy,base32hexpadupper:ky,base32z:zy});const Ky=Fi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Vy=Fi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Wy=Object.freeze({__proto__:null,base36:Ky,base36upper:Vy});const Gy=Fi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yy=Fi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Jy=Object.freeze({__proto__:null,base58btc:Gy,base58flickr:Yy});const Zy=xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qy=xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xy=xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),em=xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tm=Object.freeze({__proto__:null,base64:Zy,base64pad:Qy,base64url:Xy,base64urlpad:em});const Wl=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),rm=Wl.reduce((t,e,r)=>(t[r]=e,t),[]),im=Wl.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function nm(t){return t.reduce((e,r)=>(e+=rm[r],e),"")}function sm(t){const e=[];for(const r of t){const i=im[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const om=Un({prefix:"🚀",name:"base256emoji",encode:nm,decode:sm});var am=Object.freeze({__proto__:null,base256emoji:om}),cm=Gl,za=128,um=127,lm=~um,hm=Math.pow(2,31);function Gl(t,e,r){e=e||[],r=r||0;for(var i=r;t>=hm;)e[r++]=t&255|za,t/=128;for(;t&lm;)e[r++]=t&255|za,t>>>=7;return e[r]=t|0,Gl.bytes=r-i+1,e}var dm=Js,pm=128,Ha=127;function Js(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Js.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Ha)<<n:(o&Ha)*Math.pow(2,n),n+=7}while(o>=pm);return Js.bytes=s-i,r}var fm=Math.pow(2,7),gm=Math.pow(2,14),ym=Math.pow(2,21),mm=Math.pow(2,28),wm=Math.pow(2,35),bm=Math.pow(2,42),vm=Math.pow(2,49),Em=Math.pow(2,56),_m=Math.pow(2,63),Im=function(t){return t<fm?1:t<gm?2:t<ym?3:t<mm?4:t<wm?5:t<bm?6:t<vm?7:t<Em?8:t<_m?9:10},$m={encode:cm,decode:dm,encodingLength:Im},Yl=$m;const Ka=(t,e,r=0)=>(Yl.encode(t,e,r),e),Va=t=>Yl.encodingLength(t),Zs=(t,e)=>{const r=e.byteLength,i=Va(t),n=i+Va(r),s=new Uint8Array(n+r);return Ka(t,s,0),Ka(r,s,i),s.set(e,n),new Om(t,r,e,s)};let Om=class{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}};const Jl=({name:t,code:e,encode:r})=>new Dm(t,e,r);let Dm=class{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Zs(this.code,r):r.then(i=>Zs(this.code,i))}else throw Error("Unknown type, must be binary type")}};const Zl=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Sm=Jl({name:"sha2-256",code:18,encode:Zl("SHA-256")}),Pm=Jl({name:"sha2-512",code:19,encode:Zl("SHA-512")});var Am=Object.freeze({__proto__:null,sha256:Sm,sha512:Pm});const Ql=0,xm="identity",Xl=Kl,Cm=t=>Zs(Ql,Xl(t)),Rm={code:Ql,name:xm,encode:Xl,digest:Cm};var Tm=Object.freeze({__proto__:null,identity:Rm});new TextEncoder,new TextDecoder;const Wa={...Oy,...Sy,...Ay,...Cy,...Ny,...Hy,...Wy,...Jy,...tm,...am};({...Am,...Tm});function eh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Ga=eh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ws=eh("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=zl(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),th={utf8:Ga,"utf-8":Ga,hex:Wa.base16,latin1:ws,ascii:ws,binary:ws,...Wa};function qn(t,e="utf8"){const r=th[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function si(t,e="utf8"){const r=th[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?qo(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Ya(t){return hr(qn(si(t,Fn),ql))}function Dn(t){return qn(si(Ft(t),ql),Fn)}function rh(t){const e=si(hy,ka),r=ly+qn(Hl([e,t]),ka);return[cy,uy,r].join(ay)}function Nm(t){return qn(t,Fn)}function Lm(t){return si(t,Fn)}function jm(t){return si([Dn(t.header),Dn(t.payload)].join(On),kl)}function Bm(t){return[Dn(t.header),Dn(t.payload),Nm(t.signature)].join(On)}function Qs(t){const e=t.split(On),r=Ya(e[0]),i=Ya(e[1]),n=Lm(e[2]),s=si(e.slice(0,2).join(On),kl);return{header:r,payload:i,signature:n,data:s}}function Ja(t=xl(dy)){const e=Ul.getPublicKey(t);return{secretKey:Hl([t,e]),publicKey:e}}async function Mm(t,e,r,i,n=N.fromMiliseconds(Date.now())){const s={alg:sy,typ:oy},o=rh(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},u=jm({header:s,payload:c}),l=Ul.sign(u,i.secretKey.slice(0,32));return Bm({header:s,payload:c,signature:l})}var Za=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},Fm=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Um=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),qm=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),km=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),zm=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Hm=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Km=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Qa=3,Vm=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Hm]],Xa=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Wm(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new zm:typeof navigator<"u"?Ym(navigator.userAgent):Zm()}function Gm(t){return t!==""&&Vm.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function Ym(t){var e=Gm(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new km;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Qa&&(n=Za(Za([],n,!0),Qm(Qa-n.length),!0)):n=[];var s=n.join("."),o=Jm(t),a=Km.exec(t);return a&&a[1]?new qm(r,s,o,a[1]):new Fm(r,s,o)}function Jm(t){for(var e=0,r=Xa.length;e<r;e++){var i=Xa[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Zm(){var t=typeof process<"u"&&process.version;return t?new Um(process.version.slice(1)):null}function Qm(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var he={};Object.defineProperty(he,"__esModule",{value:!0});he.getLocalStorage=he.getLocalStorageOrThrow=he.getCrypto=he.getCryptoOrThrow=ih=he.getLocation=he.getLocationOrThrow=ko=he.getNavigator=he.getNavigatorOrThrow=dr=he.getDocument=he.getDocumentOrThrow=he.getFromWindowOrThrow=he.getFromWindow=void 0;function wr(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}he.getFromWindow=wr;function oi(t){const e=wr(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}he.getFromWindowOrThrow=oi;function Xm(){return oi("document")}he.getDocumentOrThrow=Xm;function ew(){return wr("document")}var dr=he.getDocument=ew;function tw(){return oi("navigator")}he.getNavigatorOrThrow=tw;function rw(){return wr("navigator")}var ko=he.getNavigator=rw;function iw(){return oi("location")}he.getLocationOrThrow=iw;function nw(){return wr("location")}var ih=he.getLocation=nw;function sw(){return oi("crypto")}he.getCryptoOrThrow=sw;function ow(){return wr("crypto")}he.getCrypto=ow;function aw(){return oi("localStorage")}he.getLocalStorageOrThrow=aw;function cw(){return wr("localStorage")}he.getLocalStorage=cw;var zo={};Object.defineProperty(zo,"__esModule",{value:!0});var nh=zo.getWindowMetadata=void 0;const ec=he;function uw(){let t,e;try{t=ec.getDocumentOrThrow(),e=ec.getLocationOrThrow()}catch{return null}function r(){const h=t.getElementsByTagName("link"),d=[];for(let f=0;f<h.length;f++){const p=h[f],y=p.getAttribute("rel");if(y&&y.toLowerCase().indexOf("icon")>-1){const w=p.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(w.indexOf("/")===0)v+=w;else{const b=e.pathname.split("/");b.pop();const E=b.join("/");v+=E+"/"+w}d.push(v)}else if(w.indexOf("//")===0){const v=e.protocol+w;d.push(v)}else d.push(w)}}return d}function i(...h){const d=t.getElementsByTagName("meta");for(let f=0;f<d.length;f++){const p=d[f],y=["itemprop","property","name"].map(w=>p.getAttribute(w)).filter(w=>w?h.includes(w):!1);if(y.length&&y){const w=p.getAttribute("content");if(w)return w}}return""}function n(){let h=i("name","og:site_name","og:title","twitter:title");return h||(h=t.title),h}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,u=r();return{description:a,url:c,icons:u,name:o}}nh=zo.getWindowMetadata=uw;function lw(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*l+1>>>0,$=new Uint8Array(E);v!==b;){for(var A=p[v],P=0,S=E-1;(A!==0||P<w)&&S!==-1;S--,P++)A+=256*$[S]>>>0,$[S]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=P,v++}for(var C=E-w;C!==E&&$[C]===0;)C++;for(var O=c.repeat(y);C<E;++C)O+=t.charAt($[C]);return O}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var $=r[p.charCodeAt(y)];if($===255)return;for(var A=0,P=b-1;($!==0||A<v)&&P!==-1;P--,A++)$+=a*E[P]>>>0,E[P]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");v=A,y++}if(p[y]!==" "){for(var S=b-v;S!==b&&E[S]===0;)S++;for(var C=new Uint8Array(w+(b-S)),O=w;S!==b;)C[O++]=E[S++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var hw=lw,dw=hw;const pw=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},fw=t=>new TextEncoder().encode(t),gw=t=>new TextDecoder().decode(t);class yw{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class mw{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return sh(this,e)}}class ww{constructor(e){this.decoders=e}or(e){return sh(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const sh=(t,e)=>new ww({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class bw{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new yw(e,r,i),this.decoder=new mw(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const kn=({name:t,prefix:e,encode:r,decode:i})=>new bw(t,e,r,i),Ui=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=dw(r,e);return kn({prefix:t,name:e,encode:i,decode:s=>pw(n(s))})},vw=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Ew=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Ce=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>kn({prefix:e,name:t,encode(n){return Ew(n,i,r)},decode(n){return vw(n,i,r,t)}}),_w=kn({prefix:"\0",name:"identity",encode:t=>gw(t),decode:t=>fw(t)}),Iw=Object.freeze(Object.defineProperty({__proto__:null,identity:_w},Symbol.toStringTag,{value:"Module"})),$w=Ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Ow=Object.freeze(Object.defineProperty({__proto__:null,base2:$w},Symbol.toStringTag,{value:"Module"})),Dw=Ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Sw=Object.freeze(Object.defineProperty({__proto__:null,base8:Dw},Symbol.toStringTag,{value:"Module"})),Pw=Ui({prefix:"9",name:"base10",alphabet:"0123456789"}),Aw=Object.freeze(Object.defineProperty({__proto__:null,base10:Pw},Symbol.toStringTag,{value:"Module"})),xw=Ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cw=Ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Rw=Object.freeze(Object.defineProperty({__proto__:null,base16:xw,base16upper:Cw},Symbol.toStringTag,{value:"Module"})),Tw=Ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Nw=Ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lw=Ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jw=Ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bw=Ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Mw=Ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fw=Ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Uw=Ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qw=Ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),kw=Object.freeze(Object.defineProperty({__proto__:null,base32:Tw,base32hex:Bw,base32hexpad:Fw,base32hexpadupper:Uw,base32hexupper:Mw,base32pad:Lw,base32padupper:jw,base32upper:Nw,base32z:qw},Symbol.toStringTag,{value:"Module"})),zw=Ui({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hw=Ui({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Kw=Object.freeze(Object.defineProperty({__proto__:null,base36:zw,base36upper:Hw},Symbol.toStringTag,{value:"Module"})),Vw=Ui({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ww=Ui({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Gw=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Vw,base58flickr:Ww},Symbol.toStringTag,{value:"Module"})),Yw=Ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Jw=Ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zw=Ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qw=Ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Xw=Object.freeze(Object.defineProperty({__proto__:null,base64:Yw,base64pad:Jw,base64url:Zw,base64urlpad:Qw},Symbol.toStringTag,{value:"Module"})),oh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),eb=oh.reduce((t,e,r)=>(t[r]=e,t),[]),tb=oh.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function rb(t){return t.reduce((e,r)=>(e+=eb[r],e),"")}function ib(t){const e=[];for(const r of t){const i=tb[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const nb=kn({prefix:"🚀",name:"base256emoji",encode:rb,decode:ib}),sb=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:nb},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const tc={...Iw,...Ow,...Sw,...Aw,...Rw,...kw,...Kw,...Gw,...Xw,...sb},ob={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var Ho={exports:{}},Wr=typeof Reflect=="object"?Reflect:null,rc=Wr&&typeof Wr.apply=="function"?Wr.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},pn;Wr&&typeof Wr.ownKeys=="function"?pn=Wr.ownKeys:Object.getOwnPropertySymbols?pn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pn=function(e){return Object.getOwnPropertyNames(e)};function ab(t){console&&console.warn&&console.warn(t)}var ah=Number.isNaN||function(e){return e!==e};function ie(){ie.init.call(this)}Ho.exports=ie;Ho.exports.once=hb;ie.EventEmitter=ie;ie.prototype._events=void 0;ie.prototype._eventsCount=0;ie.prototype._maxListeners=void 0;var ic=10;function zn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ie,"defaultMaxListeners",{enumerable:!0,get:function(){return ic},set:function(t){if(typeof t!="number"||t<0||ah(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ic=t}});ie.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ie.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ah(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ch(t){return t._maxListeners===void 0?ie.defaultMaxListeners:t._maxListeners}ie.prototype.getMaxListeners=function(){return ch(this)};ie.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")rc(c,this,r);else for(var u=c.length,l=ph(c,u),i=0;i<u;++i)rc(l[i],this,r);return!0};function uh(t,e,r,i){var n,s,o;if(zn(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=ch(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,ab(a)}return t}ie.prototype.addListener=function(e,r){return uh(this,e,r,!1)};ie.prototype.on=ie.prototype.addListener;ie.prototype.prependListener=function(e,r){return uh(this,e,r,!0)};function cb(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function lh(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=cb.bind(i);return n.listener=r,i.wrapFn=n,n}ie.prototype.once=function(e,r){return zn(r),this.on(e,lh(this,e,r)),this};ie.prototype.prependOnceListener=function(e,r){return zn(r),this.prependListener(e,lh(this,e,r)),this};ie.prototype.removeListener=function(e,r){var i,n,s,o,a;if(zn(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():ub(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};ie.prototype.off=ie.prototype.removeListener;ie.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function hh(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?lb(n):ph(n,n.length)}ie.prototype.listeners=function(e){return hh(this,e,!0)};ie.prototype.rawListeners=function(e){return hh(this,e,!1)};ie.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):dh.call(t,e)};ie.prototype.listenerCount=dh;function dh(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ie.prototype.eventNames=function(){return this._eventsCount>0?pn(this._events):[]};function ph(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function ub(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function lb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function hb(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}fh(t,e,s,{once:!0}),e!=="error"&&db(t,n,{once:!0})})}function db(t,e,r){typeof t.on=="function"&&fh(t,"error",e,r)}function fh(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var pb=Ho.exports;const fb="PARSE_ERROR",gb="INVALID_REQUEST",yb="METHOD_NOT_FOUND",mb="INVALID_PARAMS",gh="INTERNAL_ERROR",Ko="SERVER_ERROR",wb=[-32700,-32600,-32601,-32602,-32603],Ii={[fb]:{code:-32700,message:"Parse error"},[gb]:{code:-32600,message:"Invalid Request"},[yb]:{code:-32601,message:"Method not found"},[mb]:{code:-32602,message:"Invalid params"},[gh]:{code:-32603,message:"Internal error"},[Ko]:{code:-32e3,message:"Server error"}},yh=Ko;function bb(t){return wb.includes(t)}function nc(t){return Object.keys(Ii).includes(t)?Ii[t]:Ii[yh]}function vb(t){const e=Object.values(Ii).find(r=>r.code===t);return e||Ii[yh]}function mh(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var wh={};/*! *****************************************************************************
|
|
16
|
+
Copyright (c) Microsoft Corporation.
|
|
17
|
+
|
|
18
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
19
|
+
purpose with or without fee is hereby granted.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
22
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
23
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
24
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
25
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
26
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
27
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
28
|
+
***************************************************************************** */var Xs=function(t,e){return Xs=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Xs(t,e)};function Eb(t,e){Xs(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var eo=function(){return eo=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},eo.apply(this,arguments)};function _b(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Ib(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function $b(t,e){return function(r,i){e(r,i,t)}}function Ob(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Db(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{u(i.next(l))}catch(h){o(h)}}function c(l){try{u(i.throw(l))}catch(h){o(h)}}function u(l){l.done?s(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})}function Sb(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Pb(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Ab(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function to(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function bh(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function xb(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bh(arguments[e]));return t}function Cb(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function Ci(t){return this instanceof Ci?(this.v=t,this):new Ci(t)}function Rb(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(d){i[d]&&(n[d]=function(f){return new Promise(function(p,y){s.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(i[d](f))}catch(p){h(s[0][3],p)}}function c(d){d.value instanceof Ci?Promise.resolve(d.value.v).then(u,l):h(s[0][2],d)}function u(d){a("next",d)}function l(d){a("throw",d)}function h(d,f){d(f),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Tb(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:Ci(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function Nb(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof to=="function"?to(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}function Lb(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function jb(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Bb(t){return t&&t.__esModule?t:{default:t}}function Mb(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Fb(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const Ub=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return eo},__asyncDelegator:Tb,__asyncGenerator:Rb,__asyncValues:Nb,__await:Ci,__awaiter:Db,__classPrivateFieldGet:Mb,__classPrivateFieldSet:Fb,__createBinding:Pb,__decorate:Ib,__exportStar:Ab,__extends:Eb,__generator:Sb,__importDefault:Bb,__importStar:jb,__makeTemplateObject:Lb,__metadata:Ob,__param:$b,__read:bh,__rest:_b,__spread:xb,__spreadArrays:Cb,__values:to},Symbol.toStringTag,{value:"Module"})),qb=pl(Ub);var Ct={},sc;function kb(){if(sc)return Ct;sc=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.isBrowserCryptoAvailable=Ct.getSubtleCrypto=Ct.getBrowerCrypto=void 0;function t(){return(It===null||It===void 0?void 0:It.crypto)||(It===null||It===void 0?void 0:It.msCrypto)||{}}Ct.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}Ct.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Ct.isBrowserCryptoAvailable=r,Ct}var Rt={},oc;function zb(){if(oc)return Rt;oc=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.isBrowser=Rt.isNode=Rt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Rt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Rt.isNode=e;function r(){return!t()&&!e()}return Rt.isBrowser=r,Rt}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=qb;e.__exportStar(kb(),t),e.__exportStar(zb(),t)})(wh);function Et(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function cr(t=6){return BigInt(Et(t))}function Wt(t,e,r){return{id:r||Et(),jsonrpc:"2.0",method:t,params:e}}function Hn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Kn(t,e,r){return{id:t,jsonrpc:"2.0",error:Hb(e)}}function Hb(t,e){return typeof t>"u"?nc(gh):(typeof t=="string"&&(t=Object.assign(Object.assign({},nc(Ko)),{message:t})),bb(t.code)&&(t=vb(t.code)),t)}class Kb{}class Vb extends Kb{constructor(){super()}}class Wb extends Vb{constructor(e){super()}}const Gb="^https?:",Yb="^wss?:";function Jb(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function vh(t,e){const r=Jb(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function ac(t){return vh(t,Gb)}function cc(t){return vh(t,Yb)}function Zb(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Eh(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Vo(t){return Eh(t)&&"method"in t}function Vn(t){return Eh(t)&&(_t(t)||nt(t))}function _t(t){return"result"in t}function nt(t){return"error"in t}let ot=class extends Wb{constructor(e){super(e),this.events=new pb.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(Wt(e.method,e.params||[],e.id||cr().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{nt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Vn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Wo={exports:{}},Gr=typeof Reflect=="object"?Reflect:null,uc=Gr&&typeof Gr.apply=="function"?Gr.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},fn;Gr&&typeof Gr.ownKeys=="function"?fn=Gr.ownKeys:Object.getOwnPropertySymbols?fn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fn=function(e){return Object.getOwnPropertyNames(e)};function Qb(t){console&&console.warn&&console.warn(t)}var _h=Number.isNaN||function(e){return e!==e};function ne(){ne.init.call(this)}Wo.exports=ne;Wo.exports.once=rv;ne.EventEmitter=ne;ne.prototype._events=void 0;ne.prototype._eventsCount=0;ne.prototype._maxListeners=void 0;var lc=10;function Wn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ne,"defaultMaxListeners",{enumerable:!0,get:function(){return lc},set:function(t){if(typeof t!="number"||t<0||_h(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");lc=t}});ne.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ne.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||_h(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ih(t){return t._maxListeners===void 0?ne.defaultMaxListeners:t._maxListeners}ne.prototype.getMaxListeners=function(){return Ih(this)};ne.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")uc(c,this,r);else for(var u=c.length,l=Ph(c,u),i=0;i<u;++i)uc(l[i],this,r);return!0};function $h(t,e,r,i){var n,s,o;if(Wn(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Ih(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,Qb(a)}return t}ne.prototype.addListener=function(e,r){return $h(this,e,r,!1)};ne.prototype.on=ne.prototype.addListener;ne.prototype.prependListener=function(e,r){return $h(this,e,r,!0)};function Xb(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Oh(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Xb.bind(i);return n.listener=r,i.wrapFn=n,n}ne.prototype.once=function(e,r){return Wn(r),this.on(e,Oh(this,e,r)),this};ne.prototype.prependOnceListener=function(e,r){return Wn(r),this.prependListener(e,Oh(this,e,r)),this};ne.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Wn(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():ev(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};ne.prototype.off=ne.prototype.removeListener;ne.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Dh(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?tv(n):Ph(n,n.length)}ne.prototype.listeners=function(e){return Dh(this,e,!0)};ne.prototype.rawListeners=function(e){return Dh(this,e,!1)};ne.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Sh.call(t,e)};ne.prototype.listenerCount=Sh;function Sh(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ne.prototype.eventNames=function(){return this._eventsCount>0?fn(this._events):[]};function Ph(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function ev(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function tv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function rv(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Ah(t,e,s,{once:!0}),e!=="error"&&iv(t,n,{once:!0})})}function iv(t,e,r){typeof t.on=="function"&&Ah(t,"error",e,r)}function Ah(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var nv=Wo.exports;const sv=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),ov=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",hc=t=>t.split("?")[0],dc=10,av=sv();let cv=class{constructor(e){if(this.url=e,this.events=new nv.EventEmitter,this.registering=!1,!cc(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ft(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!cc(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=wh.isReactNative()?void 0:{rejectUnauthorized:!Zb(e)},s=new av(e,[],n);ov()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?hr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Kn(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return mh(e,hc(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>dc&&this.events.setMaxListeners(dc)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${hc(this.url)}`));return this.events.emit("register_error",r),r}};var Go={exports:{}},Yr=typeof Reflect=="object"?Reflect:null,pc=Yr&&typeof Yr.apply=="function"?Yr.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},gn;Yr&&typeof Yr.ownKeys=="function"?gn=Yr.ownKeys:Object.getOwnPropertySymbols?gn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:gn=function(e){return Object.getOwnPropertyNames(e)};function uv(t){console&&console.warn&&console.warn(t)}var xh=Number.isNaN||function(e){return e!==e};function se(){se.init.call(this)}Go.exports=se;Go.exports.once=pv;se.EventEmitter=se;se.prototype._events=void 0;se.prototype._eventsCount=0;se.prototype._maxListeners=void 0;var fc=10;function Gn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(se,"defaultMaxListeners",{enumerable:!0,get:function(){return fc},set:function(t){if(typeof t!="number"||t<0||xh(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");fc=t}});se.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};se.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||xh(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ch(t){return t._maxListeners===void 0?se.defaultMaxListeners:t._maxListeners}se.prototype.getMaxListeners=function(){return Ch(this)};se.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")pc(c,this,r);else for(var u=c.length,l=jh(c,u),i=0;i<u;++i)pc(l[i],this,r);return!0};function Rh(t,e,r,i){var n,s,o;if(Gn(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Ch(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,uv(a)}return t}se.prototype.addListener=function(e,r){return Rh(this,e,r,!1)};se.prototype.on=se.prototype.addListener;se.prototype.prependListener=function(e,r){return Rh(this,e,r,!0)};function lv(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Th(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=lv.bind(i);return n.listener=r,i.wrapFn=n,n}se.prototype.once=function(e,r){return Gn(r),this.on(e,Th(this,e,r)),this};se.prototype.prependOnceListener=function(e,r){return Gn(r),this.prependListener(e,Th(this,e,r)),this};se.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Gn(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():hv(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};se.prototype.off=se.prototype.removeListener;se.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Nh(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?dv(n):jh(n,n.length)}se.prototype.listeners=function(e){return Nh(this,e,!0)};se.prototype.rawListeners=function(e){return Nh(this,e,!1)};se.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Lh.call(t,e)};se.prototype.listenerCount=Lh;function Lh(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}se.prototype.eventNames=function(){return this._eventsCount>0?gn(this._events):[]};function jh(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function hv(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function dv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function pv(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Bh(t,e,s,{once:!0}),e!=="error"&&fv(t,n,{once:!0})})}function fv(t,e,r){typeof t.on=="function"&&Bh(t,"error",e,r)}function Bh(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Ut=Go.exports;const Yo=Ro(Ut);function gv(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let u=0;u<e.length;u++)e[u]=255;for(let u=0;u<t.length;u++){const l=t.charAt(u),h=l.charCodeAt(0);if(e[h]!==255)throw new TypeError(l+" is ambiguous");e[h]=u}const r=t.length,i=t.charAt(0),n=Math.log(r)/Math.log(256),s=Math.log(256)/Math.log(r);function o(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";let l=0,h=0,d=0;const f=u.length;for(;d!==f&&u[d]===0;)d++,l++;const p=(f-d)*s+1>>>0,y=new Uint8Array(p);for(;d!==f;){let b=u[d],E=0;for(let $=p-1;(b!==0||E<h)&&$!==-1;$--,E++)b+=256*y[$]>>>0,y[$]=b%r>>>0,b=b/r>>>0;if(b!==0)throw new Error("Non-zero carry");h=E,d++}let w=p-h;for(;w!==p&&y[w]===0;)w++;let v=i.repeat(l);for(;w<p;++w)v+=t.charAt(y[w]);return v}function a(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;let l=0,h=0,d=0;for(;u[l]===i;)h++,l++;const f=(u.length-l)*n+1>>>0,p=new Uint8Array(f);for(;l<u.length;){const b=u.charCodeAt(l);if(b>255)return;let E=e[b];if(E===255)return;let $=0;for(let A=f-1;(E!==0||$<d)&&A!==-1;A--,$++)E+=r*p[A]>>>0,p[A]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");d=$,l++}let y=f-d;for(;y!==f&&p[y]===0;)y++;const w=new Uint8Array(h+(f-y));let v=h;for(;y!==f;)w[v++]=p[y++];return w}function c(u){const l=a(u);if(l)return l;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var yv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const mv=gv(yv);function Mh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function $i(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Mh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function Fh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const gc=Fh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),bs=Fh("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Mh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Uh={utf8:gc,"utf-8":gc,hex:tc.base16,latin1:bs,ascii:bs,binary:bs,...tc};function st(t,e="utf8"){const r=Uh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function Ke(t,e="utf8"){const r=Uh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var wv={};const{recoverAddress:bv}=await Ip("viem"),vv=":";function Jr(t){const[e,r]=t.split(vv);return{namespace:e,reference:r}}function yc(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.accounts)}),r}function qh(t,e){return t.includes(":")?[t]:e.chains||[]}var Ev=Object.defineProperty,_v=Object.defineProperties,Iv=Object.getOwnPropertyDescriptors,mc=Object.getOwnPropertySymbols,$v=Object.prototype.hasOwnProperty,Ov=Object.prototype.propertyIsEnumerable,wc=(t,e,r)=>e in t?Ev(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bc=(t,e)=>{for(var r in e||(e={}))$v.call(e,r)&&wc(t,r,e[r]);if(mc)for(var r of mc(e))Ov.call(e,r)&&wc(t,r,e[r]);return t},Dv=(t,e)=>_v(t,Iv(e));const Sv="ReactNative",Qe={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Pv="js";function Sn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Zt(){return!dr()&&!!ko()&&navigator.product===Sv}function Av(){return Zt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function xv(){return Zt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ai(){return!Sn()&&!!ko()&&!!dr()}function qi(){return Zt()?Qe.reactNative:Sn()?Qe.node:ai()?Qe.browser:Qe.unknown}function vc(){var t;try{return Zt()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Cv(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&r.set(i,n)}return r.toString()}function Rv(t){var e,r;const i=kh();try{return t!=null&&t.url&&i.url&&new URL(t.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),t.url=i.url),(e=t?.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(n=>n!=="")),Dv(bc(bc({},i),t),{url:t?.url||i.url,name:t?.name||i.name,description:t?.description||i.description,icons:(r=t?.icons)!=null&&r.length&&t.icons.length>0?t.icons:i.icons})}catch(n){return console.warn("Error populating app metadata",n),t||i}}function kh(){return nh()||{name:"",description:"",url:"",icons:[""]}}function Tv(){if(qi()===Qe.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=Wm();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Nv(){var t;const e=qi();return e===Qe.browser?[e,((t=ih())==null?void 0:t.host)||"unknown"].join(":"):e}function zh(t,e,r){const i=Tv(),n=Nv();return[[t,e].join("-"),[Pv,r].join("-"),i,n].join("/")}function Lv({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const u=r.split("?"),l=zh(t,e,i),h={auth:n,ua:l,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=Cv(u[1]||"",h);return u[0]+"?"+d}function ur(t,e){return t.filter(r=>e.includes(r)).length===t.length}function ro(t){return Object.fromEntries(t.entries())}function io(t){return new Map(Object.entries(t))}function rr(t=N.FIVE_MINUTES,e){const r=N.toMiliseconds(t||N.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const u=new Error(e);o=Promise.reject(u),c(u)},r),i=a,n=c})}}function Gt(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function Hh(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function jv(t){return Hh("topic",t)}function Bv(t){return Hh("id",t)}function Kh(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function me(t,e){return N.fromMiliseconds(Date.now()+N.toMiliseconds(t))}function Kt(t){return Date.now()>=N.toMiliseconds(t)}function X(t,e){return`${t}${e?`:${e}`:""}`}function Dt(t=[],e=[]){return[...new Set([...t,...e])]}async function Mv({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=Fv(s,t,e),a=qi();if(a===Qe.browser){if(!((i=dr())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Uv(o)}else a===Qe.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function Fv(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${Hv(i,!0)}`}else n=`${n}/wc?${i}`;return n}function Uv(t){let e="_self";zv()?e="_top":(kv()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function qv(t,e){let r="";try{if(ai()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Ec(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function _c(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Jo(){return typeof process<"u"&&wv.IS_VITEST==="true"}function kv(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function zv(){try{return window.self!==window.top}catch{return!1}}function Hv(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Vh(t){return Buffer.from(t,"base64").toString("utf-8")}function Kv(t){return new Promise(e=>setTimeout(e,t))}function Ri(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Vv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ki(t,...e){if(!Vv(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Zo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ri(t.outputLen),Ri(t.blockLen)}function Qr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Wh(t,e){ki(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Xi=BigInt(2**32-1),Ic=BigInt(32);function Wv(t,e=!1){return e?{h:Number(t&Xi),l:Number(t>>Ic&Xi)}:{h:Number(t>>Ic&Xi)|0,l:Number(t&Xi)|0}}function Gv(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=Wv(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const Yv=(t,e,r)=>t<<r|e>>>32-r,Jv=(t,e,r)=>e<<r|t>>>32-r,Zv=(t,e,r)=>e<<r-32|t>>>64-r,Qv=(t,e,r)=>t<<r-32|e>>>64-r,Dr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Xv(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function vs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function mt(t,e){return t<<32-e|t>>>e}const $c=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function e0(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Oc(t){for(let e=0;e<t.length;e++)t[e]=e0(t[e])}function t0(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Xr(t){return typeof t=="string"&&(t=t0(t)),ki(t),t}function r0(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];ki(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}let Qo=class{clone(){return this._cloneInto()}};function Gh(t){const e=i=>t().update(Xr(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ci(t=32){if(Dr&&typeof Dr.getRandomValues=="function")return Dr.getRandomValues(new Uint8Array(t));if(Dr&&typeof Dr.randomBytes=="function")return Dr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Yh=[],Jh=[],Zh=[],i0=BigInt(0),fi=BigInt(1),n0=BigInt(2),s0=BigInt(7),o0=BigInt(256),a0=BigInt(113);for(let t=0,e=fi,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Yh.push(2*(5*i+r)),Jh.push((t+1)*(t+2)/2%64);let n=i0;for(let s=0;s<7;s++)e=(e<<fi^(e>>s0)*a0)%o0,e&n0&&(n^=fi<<(fi<<BigInt(s))-fi);Zh.push(n)}const[c0,u0]=Gv(Zh,!0),Dc=(t,e,r)=>r>32?Zv(t,e,r):Yv(t,e,r),Sc=(t,e,r)=>r>32?Qv(t,e,r):Jv(t,e,r);function l0(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=r[c],l=r[c+1],h=Dc(u,l,1)^r[a],d=Sc(u,l,1)^r[a+1];for(let f=0;f<50;f+=10)t[o+f]^=h,t[o+f+1]^=d}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Jh[o],c=Dc(n,s,a),u=Sc(n,s,a),l=Yh[o];n=t[l],s=t[l+1],t[l]=c,t[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=c0[i],t[1]^=u0[i]}r.fill(0)}let h0=class Qh extends Qo{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ri(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Xv(this.state)}keccak(){$c||Oc(this.state32),l0(this.state32,this.rounds),$c||Oc(this.state32),this.posOut=0,this.pos=0}update(e){Qr(this);const{blockLen:r,state:i}=this;e=Xr(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Qr(this,!1),ki(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ri(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Wh(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new Qh(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}};const d0=(t,e,r)=>Gh(()=>new h0(e,t,r)),p0=d0(1,136,256/8),f0="https://rpc.walletconnect.org/v1";function Xh(t){const e=`Ethereum Signed Message:
|
|
29
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(p0(r)).toString("hex")}async function g0(t,e,r,i,n,s){switch(r.t){case"eip191":return await y0(t,e,r.s);case"eip1271":return await m0(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function y0(t,e,r){return(await bv({hash:Xh(e),signature:r})).toLowerCase()===t.toLowerCase()}async function m0(t,e,r,i,n,s){const o=Jr(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),h=Xh(e).substring(2),d=a+h+c+u+l,f=await fetch(`${s||f0}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:w0(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function w0(){return Date.now()+Math.floor(Math.random()*1e3)}function b0(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);const i=r[0];if(i===0)throw new Error("No signatures found");const n=1+i*64;if(r.length<n)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const s=Buffer.from(t,"base64").slice(1,65);return mv.encode(s)}var v0=Object.defineProperty,E0=Object.defineProperties,_0=Object.getOwnPropertyDescriptors,Pc=Object.getOwnPropertySymbols,I0=Object.prototype.hasOwnProperty,$0=Object.prototype.propertyIsEnumerable,Ac=(t,e,r)=>e in t?v0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O0=(t,e)=>{for(var r in e||(e={}))I0.call(e,r)&&Ac(t,r,e[r]);if(Pc)for(var r of Pc(e))$0.call(e,r)&&Ac(t,r,e[r]);return t},D0=(t,e)=>E0(t,_0(e));const S0="did:pkh:",Xo=t=>t?.split(":"),P0=t=>{const e=t&&Xo(t);if(e)return t.includes(S0)?e[3]:e[1]},no=t=>{const e=t&&Xo(t);if(e)return e[2]+":"+e[3]},Pn=t=>{const e=t&&Xo(t);if(e)return e.pop()};async function xc(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=ed(n,n.iss),o=Pn(n.iss);return await g0(o,s,i,no(n.iss),r)}const ed=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=Pn(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${P0(e)}`,c=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,l=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,f=t.resources?`Resources:${t.resources.map(y=>`
|
|
30
|
+
- ${y}`).join("")}`:void 0,p=yn(t.resources);if(p){const y=Ti(p);n=B0(n,y)}return[r,i,"",n,"",s,o,a,c,u,l,h,d,f].filter(y=>y!=null).join(`
|
|
31
|
+
`)};function A0(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function x0(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function pr(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function C0(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:R0(e,r,i)}}}function R0(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function td(t){return pr(t),`urn:recap:${A0(t).replace(/=/g,"")}`}function Ti(t){const e=x0(t.replace("urn:recap:",""));return pr(e),e}function T0(t,e,r){const i=C0(t,e,r);return td(i)}function N0(t){return t&&t.includes("urn:recap:")}function L0(t,e){const r=Ti(t),i=Ti(e),n=j0(r,i);return td(n)}function j0(t,e){pr(t),pr(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,u;i.att[n]=D0(O0({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function B0(t="",e){pr(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));c.sort((h,d)=>h.action.localeCompare(d.action));const u={};c.forEach(h=>{u[h.ability]||(u[h.ability]=[]),u[h.ability].push(h.action)});const l=Object.keys(u).map(h=>(n++,`(${n}) '${h}': '${u[h].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Cc(t){var e;const r=Ti(t);pr(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Rc(t){const e=Ti(t);pr(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function yn(t){if(!t)return;const e=t?.[t.length-1];return N0(e)?e:void 0}function Es(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function rd(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ze(t,...e){if(!rd(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Tc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function M0(t,e){Ze(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Nc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Yt=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),F0=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),U0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!U0)throw new Error("Non little-endian hardware is not supported");function q0(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function so(t){if(typeof t=="string")t=q0(t);else if(rd(t))t=oo(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function k0(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function z0(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const H0=(t,e)=>{function r(i,...n){if(Ze(i),t.nonceLength!==void 0){const u=n[0];if(!u)throw new Error("nonce / iv required");t.varSizeNonce?Ze(u):Ze(u,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Ze(n[1]);const o=e(i,...n),a=(u,l)=>{if(l!==void 0){if(u!==2)throw new Error("cipher output not supported");Ze(l)}};let c=!1;return{encrypt(u,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Ze(u),a(o.encrypt.length,l),o.encrypt(u,l)},decrypt(u,l){if(Ze(u),s&&u.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,l),o.decrypt(u,l)}}}return Object.assign(r,t),r};function Lc(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!K0(e))throw new Error("invalid output, must be aligned");return e}function jc(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s);t.setUint32(e+4,o,i),t.setUint32(e+0,a,i)}function K0(t){return t.byteOffset%4===0}function oo(t){return Uint8Array.from(t)}function ei(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const id=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),V0=id("expand 16-byte k"),W0=id("expand 32-byte k"),G0=Yt(V0),Y0=Yt(W0);function J(t,e){return t<<e|t>>>32-e}function ao(t){return t.byteOffset%4===0}const en=64,J0=16,nd=2**32-1,Bc=new Uint32Array;function Z0(t,e,r,i,n,s,o,a){const c=n.length,u=new Uint8Array(en),l=Yt(u),h=ao(n)&&ao(s),d=h?Yt(n):Bc,f=h?Yt(s):Bc;for(let p=0;p<c;o++){if(t(e,r,i,l,o,a),o>=nd)throw new Error("arx: counter overflow");const y=Math.min(en,c-p);if(h&&y===en){const w=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let v=0,b;v<J0;v++)b=w+v,f[b]=d[b]^l[v];p+=en;continue}for(let w=0,v;w<y;w++)v=p+w,s[v]=n[v]^u[w];p+=y}}function Q0(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=k0({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Es(n),Es(o),Nc(s),Nc(r),(a,c,u,l,h=0)=>{Ze(a),Ze(c),Ze(u);const d=u.length;if(l===void 0&&(l=new Uint8Array(d)),Ze(l),Es(h),h<0||h>=nd)throw new Error("arx: counter overflow");if(l.length<d)throw new Error(`arx: output (${l.length}) is shorter than data (${d})`);const f=[];let p=a.length,y,w;if(p===32)f.push(y=oo(a)),w=Y0;else if(p===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),w=G0,f.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);ao(c)||f.push(c=oo(c));const v=Yt(y);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(w,v,Yt(c.subarray(0,16)),v),c=c.subarray(16)}const b=16-n;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const $=new Uint8Array(12);$.set(c,s?0:12-c.length),c=$,f.push(c)}const E=Yt(c);return Z0(t,w,v,E,u,l,h,o),ei(...f),l}}const Se=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class X0{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,e=so(e),Ze(e,32);const r=Se(e,0),i=Se(e,2),n=Se(e,4),s=Se(e,6),o=Se(e,8),a=Se(e,10),c=Se(e,12),u=Se(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let l=0;l<8;l++)this.pad[l]=Se(e,16+2*l)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],u=o[2],l=o[3],h=o[4],d=o[5],f=o[6],p=o[7],y=o[8],w=o[9],v=Se(e,r+0),b=Se(e,r+2),E=Se(e,r+4),$=Se(e,r+6),A=Se(e,r+8),P=Se(e,r+10),S=Se(e,r+12),C=Se(e,r+14);let O=s[0]+(v&8191),q=s[1]+((v>>>13|b<<3)&8191),B=s[2]+((b>>>10|E<<6)&8191),j=s[3]+((E>>>7|$<<9)&8191),k=s[4]+(($>>>4|A<<12)&8191),R=s[5]+(A>>>1&8191),g=s[6]+((A>>>14|P<<2)&8191),m=s[7]+((P>>>11|S<<5)&8191),_=s[8]+((S>>>8|C<<8)&8191),D=s[9]+(C>>>5|n),I=0,x=I+O*a+q*(5*w)+B*(5*y)+j*(5*p)+k*(5*f);I=x>>>13,x&=8191,x+=R*(5*d)+g*(5*h)+m*(5*l)+_*(5*u)+D*(5*c),I+=x>>>13,x&=8191;let M=I+O*c+q*a+B*(5*w)+j*(5*y)+k*(5*p);I=M>>>13,M&=8191,M+=R*(5*f)+g*(5*d)+m*(5*h)+_*(5*l)+D*(5*u),I+=M>>>13,M&=8191;let U=I+O*u+q*c+B*a+j*(5*w)+k*(5*y);I=U>>>13,U&=8191,U+=R*(5*p)+g*(5*f)+m*(5*d)+_*(5*h)+D*(5*l),I+=U>>>13,U&=8191;let z=I+O*l+q*u+B*c+j*a+k*(5*w);I=z>>>13,z&=8191,z+=R*(5*y)+g*(5*p)+m*(5*f)+_*(5*d)+D*(5*h),I+=z>>>13,z&=8191;let F=I+O*h+q*l+B*u+j*c+k*a;I=F>>>13,F&=8191,F+=R*(5*w)+g*(5*y)+m*(5*p)+_*(5*f)+D*(5*d),I+=F>>>13,F&=8191;let H=I+O*d+q*h+B*l+j*u+k*c;I=H>>>13,H&=8191,H+=R*a+g*(5*w)+m*(5*y)+_*(5*p)+D*(5*f),I+=H>>>13,H&=8191;let G=I+O*f+q*d+B*h+j*l+k*u;I=G>>>13,G&=8191,G+=R*c+g*a+m*(5*w)+_*(5*y)+D*(5*p),I+=G>>>13,G&=8191;let ue=I+O*p+q*f+B*d+j*h+k*l;I=ue>>>13,ue&=8191,ue+=R*u+g*c+m*a+_*(5*w)+D*(5*y),I+=ue>>>13,ue&=8191;let ee=I+O*y+q*p+B*f+j*d+k*h;I=ee>>>13,ee&=8191,ee+=R*l+g*u+m*c+_*a+D*(5*w),I+=ee>>>13,ee&=8191;let Y=I+O*w+q*y+B*p+j*f+k*d;I=Y>>>13,Y&=8191,Y+=R*h+g*l+m*u+_*c+D*a,I+=Y>>>13,Y&=8191,I=(I<<2)+I|0,I=I+x|0,x=I&8191,I=I>>>13,M+=I,s[0]=x,s[1]=M,s[2]=U,s[3]=z,s[4]=F,s[5]=H,s[6]=G,s[7]=ue,s[8]=ee,s[9]=Y}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;ei(i)}update(e){Tc(this);const{buffer:r,blockLen:i}=this;e=so(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){ei(this.h,this.r,this.buffer,this.pad)}digestInto(e){Tc(this),M0(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function e1(t){const e=(i,n)=>t(n).update(so(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const t1=e1(t=>new X0(t));function r1(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],u=t[3],l=e[0],h=e[1],d=e[2],f=e[3],p=e[4],y=e[5],w=e[6],v=e[7],b=n,E=r[0],$=r[1],A=r[2],P=o,S=a,C=c,O=u,q=l,B=h,j=d,k=f,R=p,g=y,m=w,_=v,D=b,I=E,x=$,M=A;for(let z=0;z<s;z+=2)P=P+q|0,D=J(D^P,16),R=R+D|0,q=J(q^R,12),P=P+q|0,D=J(D^P,8),R=R+D|0,q=J(q^R,7),S=S+B|0,I=J(I^S,16),g=g+I|0,B=J(B^g,12),S=S+B|0,I=J(I^S,8),g=g+I|0,B=J(B^g,7),C=C+j|0,x=J(x^C,16),m=m+x|0,j=J(j^m,12),C=C+j|0,x=J(x^C,8),m=m+x|0,j=J(j^m,7),O=O+k|0,M=J(M^O,16),_=_+M|0,k=J(k^_,12),O=O+k|0,M=J(M^O,8),_=_+M|0,k=J(k^_,7),P=P+B|0,M=J(M^P,16),m=m+M|0,B=J(B^m,12),P=P+B|0,M=J(M^P,8),m=m+M|0,B=J(B^m,7),S=S+j|0,D=J(D^S,16),_=_+D|0,j=J(j^_,12),S=S+j|0,D=J(D^S,8),_=_+D|0,j=J(j^_,7),C=C+k|0,I=J(I^C,16),R=R+I|0,k=J(k^R,12),C=C+k|0,I=J(I^C,8),R=R+I|0,k=J(k^R,7),O=O+q|0,x=J(x^O,16),g=g+x|0,q=J(q^g,12),O=O+q|0,x=J(x^O,8),g=g+x|0,q=J(q^g,7);let U=0;i[U++]=o+P|0,i[U++]=a+S|0,i[U++]=c+C|0,i[U++]=u+O|0,i[U++]=l+q|0,i[U++]=h+B|0,i[U++]=d+j|0,i[U++]=f+k|0,i[U++]=p+R|0,i[U++]=y+g|0,i[U++]=w+m|0,i[U++]=v+_|0,i[U++]=b+D|0,i[U++]=E+I|0,i[U++]=$+x|0,i[U++]=A+M|0}const i1=Q0(r1,{counterRight:!1,counterLength:4,allowShortKeys:!1}),n1=new Uint8Array(16),Mc=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(n1.subarray(r))},s1=new Uint8Array(32);function Fc(t,e,r,i,n){const s=t(e,r,s1),o=t1.create(s);n&&Mc(o,n),Mc(o,i);const a=new Uint8Array(16),c=F0(a);jc(c,0,BigInt(n?n.length:0),!0),jc(c,8,BigInt(i.length),!0),o.update(a);const u=o.digest();return ei(s,a),u}const o1=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=Lc(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Fc(t,e,r,a,i);return s.set(c,o),ei(c),s},decrypt(n,s){s=Lc(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Fc(t,e,r,o,i);if(!z0(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),ei(c),s}}),sd=H0({blockSize:64,nonceLength:12,tagLength:16},o1(i1));let od=class extends Qo{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Zo(e);const i=Xr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Qr(this),this.iHash.update(e),this}digestInto(e){Qr(this),ki(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:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Yn=(t,e,r)=>new od(t,e).update(r).digest();Yn.create=(t,e)=>new od(t,e);function a1(t,e,r){return Zo(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Yn(t,Xr(r),Xr(e))}const _s=new Uint8Array([0]),Uc=new Uint8Array;function c1(t,e,r,i=32){if(Zo(t),Ri(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=Uc);const s=new Uint8Array(n*t.outputLen),o=Yn.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let u=0;u<n;u++)_s[0]=u+1,a.update(u===0?Uc:c).update(r).update(_s).digestInto(c),s.set(c,t.outputLen*u),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),_s.fill(0),s.slice(0,i)}const u1=(t,e,r,i,n)=>c1(t,a1(t,e,r),i,n);function l1(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,u=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+u,a,i)}function h1(t,e,r){return t&e^~t&r}function d1(t,e,r){return t&e^t&r^e&r}let p1=class extends Qo{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=vs(this.buffer)}update(e){Qr(this);const{view:r,buffer:i,blockLen:n}=this;e=Xr(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=vs(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qr(this),Wh(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)r[h]=0;l1(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=vs(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}};const f1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64);class g1 extends p1{constructor(){super(64,32,8,!1),this.A=zt[0]|0,this.B=zt[1]|0,this.C=zt[2]|0,this.D=zt[3]|0,this.E=zt[4]|0,this.F=zt[5]|0,this.G=zt[6]|0,this.H=zt[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)Ht[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const d=Ht[h-15],f=Ht[h-2],p=mt(d,7)^mt(d,18)^d>>>3,y=mt(f,17)^mt(f,19)^f>>>10;Ht[h]=y+Ht[h-7]+p+Ht[h-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:u,H:l}=this;for(let h=0;h<64;h++){const d=mt(a,6)^mt(a,11)^mt(a,25),f=l+d+h1(a,c,u)+f1[h]+Ht[h]|0,p=(mt(i,2)^mt(i,13)^mt(i,22))+d1(i,n,s)|0;l=u,u=c,c=a,a=o+f|0,o=s,s=n,n=i,i=f+p|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(i,n,s,o,a,c,u,l)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const zi=Gh(()=>new g1);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jn=BigInt(0),Zn=BigInt(1),y1=BigInt(2);function fr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hi(t){if(!fr(t))throw new Error("Uint8Array expected")}function ti(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const m1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ri(t){Hi(t);let e="";for(let r=0;r<t.length;r++)e+=m1[t[r]];return e}function zr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function ea(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Jn:BigInt("0x"+t)}const Tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function qc(t){if(t>=Tt._0&&t<=Tt._9)return t-Tt._0;if(t>=Tt.A&&t<=Tt.F)return t-(Tt.A-10);if(t>=Tt.a&&t<=Tt.f)return t-(Tt.a-10)}function ii(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=qc(t.charCodeAt(s)),a=qc(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function lr(t){return ea(ri(t))}function Ni(t){return Hi(t),ea(ri(Uint8Array.from(t).reverse()))}function ni(t,e){return ii(t.toString(16).padStart(e*2,"0"))}function Qn(t,e){return ni(t,e).reverse()}function w1(t){return ii(zr(t))}function Je(t,e,r){let i;if(typeof e=="string")try{i=ii(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(fr(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function Li(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Hi(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}function b1(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}function v1(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Is=t=>typeof t=="bigint"&&Jn<=t;function Xn(t,e,r){return Is(t)&&Is(e)&&Is(r)&&e<=t&&t<r}function Bt(t,e,r,i){if(!Xn(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function ad(t){let e;for(e=0;t>Jn;t>>=Zn,e+=1);return e}function E1(t,e){return t>>BigInt(e)&Zn}function _1(t,e,r){return t|(r?Zn:Jn)<<BigInt(e)}const ta=t=>(y1<<BigInt(t-1))-Zn,$s=t=>new Uint8Array(t),kc=t=>Uint8Array.from(t);function cd(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let i=$s(t),n=$s(t),s=0;const o=()=>{i.fill(1),n.fill(0),s=0},a=(...l)=>r(n,i,...l),c=(l=$s())=>{n=a(kc([0]),l),i=a(),l.length!==0&&(n=a(kc([1]),l),i=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const h=[];for(;l<e;){i=a();const d=i.slice();h.push(d),l+=i.length}return Li(...h)};return(l,h)=>{o(),c(l);let d;for(;!(d=h(u()));)c();return o(),d}}const I1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||fr(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ui(t,e,r={}){const i=(n,s,o)=>{const a=I1[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const $1=()=>{throw new Error("not implemented")};function co(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}var O1=Object.freeze({__proto__:null,isBytes:fr,abytes:Hi,abool:ti,bytesToHex:ri,numberToHexUnpadded:zr,hexToNumber:ea,hexToBytes:ii,bytesToNumberBE:lr,bytesToNumberLE:Ni,numberToBytesBE:ni,numberToBytesLE:Qn,numberToVarBytesBE:w1,ensureBytes:Je,concatBytes:Li,equalBytes:b1,utf8ToBytes:v1,inRange:Xn,aInRange:Bt,bitLen:ad,bitGet:E1,bitSet:_1,bitMask:ta,createHmacDrbg:cd,validateObject:ui,notImplemented:$1,memoized:co});const Oe=BigInt(0),fe=BigInt(1),sr=BigInt(2),D1=BigInt(3),uo=BigInt(4),zc=BigInt(5),Hc=BigInt(8);function He(t,e){const r=t%e;return r>=Oe?r:e+r}function ud(t,e,r){if(e<Oe)throw new Error("invalid exponent, negatives unsupported");if(r<=Oe)throw new Error("invalid modulus");if(r===fe)return Oe;let i=fe;for(;e>Oe;)e&fe&&(i=i*t%r),t=t*t%r,e>>=fe;return i}function dt(t,e,r){let i=t;for(;e-- >Oe;)i*=i,i%=r;return i}function lo(t,e){if(t===Oe)throw new Error("invert: expected non-zero number");if(e<=Oe)throw new Error("invert: expected positive modulus, got "+e);let r=He(t,e),i=e,n=Oe,s=fe;for(;r!==Oe;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==fe)throw new Error("invert: does not exist");return He(n,e)}function S1(t){const e=(t-fe)/sr;let r,i,n;for(r=t-fe,i=0;r%sr===Oe;r/=sr,i++);for(n=sr;n<t&&ud(n,e,t)!==t-fe;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+fe)/uo;return function(a,c){const u=a.pow(c,o);if(!a.eql(a.sqr(u),c))throw new Error("Cannot find square root");return u}}const s=(r+fe)/sr;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,u=o.pow(o.mul(o.ONE,n),r),l=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(h);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(u,fe<<BigInt(c-d-1));u=o.sqr(f),l=o.mul(l,f),h=o.mul(h,u),c=d}return l}}function P1(t){if(t%uo===D1){const e=(t+fe)/uo;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%Hc===zc){const e=(t-zc)/Hc;return function(r,i){const n=r.mul(i,sr),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,sr),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return S1(t)}const A1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function x1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=A1.reduce((i,n)=>(i[n]="function",i),e);return ui(t,r)}function C1(t,e,r){if(r<Oe)throw new Error("invalid exponent, negatives unsupported");if(r===Oe)return t.ONE;if(r===fe)return e;let i=t.ONE,n=e;for(;r>Oe;)r&fe&&(i=t.mul(i,n)),n=t.sqr(n),r>>=fe;return i}function R1(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function ld(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function hd(t,e,r=!1,i={}){if(t<=Oe)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=ld(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:ta(n),ZERO:Oe,ONE:fe,create:c=>He(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Oe<=c&&c<t},is0:c=>c===Oe,isOdd:c=>(c&fe)===fe,neg:c=>He(-c,t),eql:(c,u)=>c===u,sqr:c=>He(c*c,t),add:(c,u)=>He(c+u,t),sub:(c,u)=>He(c-u,t),mul:(c,u)=>He(c*u,t),pow:(c,u)=>C1(a,c,u),div:(c,u)=>He(c*lo(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>lo(c,t),sqrt:i.sqrt||(c=>(o||(o=P1(t)),o(a,c))),invertBatch:c=>R1(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>r?Qn(c,s):ni(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Ni(c):lr(c)}});return Object.freeze(a)}function dd(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function pd(t){const e=dd(t);return e+Math.ceil(e/2)}function T1(t,e,r=!1){const i=t.length,n=dd(e),s=pd(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?Ni(t):lr(t),a=He(o,e-fe)+fe;return r?Qn(a,n):ni(a,n)}const Kc=BigInt(0),tn=BigInt(1);function Os(t,e){const r=e.negate();return t?r:e}function fd(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ds(t,e){fd(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function N1(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function L1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const Ss=new WeakMap,gd=new WeakMap;function Ps(t){return gd.get(t)||1}function j1(t,e){return{constTimeNegate:Os,hasPrecomputes(r){return Ps(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Kc;)i&tn&&(n=n.add(s)),s=s.double(),i>>=tn;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=Ds(i,e),o=[];let a=r,c=a;for(let u=0;u<n;u++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=Ds(r,e);let a=t.ZERO,c=t.BASE;const u=BigInt(2**r-1),l=2**r,h=BigInt(r);for(let d=0;d<s;d++){const f=d*o;let p=Number(n&u);n>>=h,p>o&&(p-=l,n+=tn);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(Os(v,i[y])):a=a.add(Os(b,i[w]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=Ds(r,e),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<o;h++){const d=h*a;if(n===Kc)break;let f=Number(n&c);if(n>>=l,f>a&&(f-=u,n+=tn),f===0)continue;let p=i[d+Math.abs(f)-1];f<0&&(p=p.negate()),s=s.add(p)}return s},getPrecomputes(r,i,n){let s=Ss.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&Ss.set(i,n(s))),s},wNAFCached(r,i,n){const s=Ps(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=Ps(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){fd(i,e),gd.set(r,i),Ss.delete(r)}}}function B1(t,e,r,i){if(N1(r,t),L1(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=ad(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),u=Math.floor((e.BITS-1)/o)*o;let l=n;for(let h=u;h>=0;h-=o){c.fill(n);for(let f=0;f<i.length;f++){const p=i[f],y=Number(p>>BigInt(h)&BigInt(a));c[y]=c[y].add(r[f])}let d=n;for(let f=c.length-1,p=n;f>0;f--)p=p.add(c[f]),d=d.add(p);if(l=l.add(d),h!==0)for(let f=0;f<o;f++)l=l.double()}return l}function yd(t){return x1(t.Fp),ui(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ld(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Sr=BigInt(0),As=BigInt(1);function M1(t){return ui(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function F1(t){const e=M1(t),{P:r}=e,i=b=>He(b,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>ud(b,r-BigInt(2),r));function u(b,E,$){const A=i(b*(E-$));return E=i(E-A),$=i($+A),[E,$]}const l=(e.a-BigInt(2))/BigInt(4);function h(b,E){Bt("u",b,Sr,r),Bt("scalar",E,Sr,r);const $=E,A=b;let P=As,S=Sr,C=b,O=As,q=Sr,B;for(let k=BigInt(n-1);k>=Sr;k--){const R=$>>k&As;q^=R,B=u(q,P,C),P=B[0],C=B[1],B=u(q,S,O),S=B[0],O=B[1],q=R;const g=P+S,m=i(g*g),_=P-S,D=i(_*_),I=m-D,x=C+O,M=C-O,U=i(M*g),z=i(x*_),F=U+z,H=U-z;C=i(F*F),O=i(A*i(H*H)),P=i(m*D),S=i(I*(m+i(l*I)))}B=u(q,P,C),P=B[0],C=B[1],B=u(q,S,O),S=B[0],O=B[1];const j=c(S);return i(P*j)}function d(b){return Qn(i(b),s)}function f(b){const E=Je("u coordinate",b,s);return o===32&&(E[31]&=127),Ni(E)}function p(b){const E=Je("scalar",b),$=E.length;if($!==s&&$!==o){let A=""+s+" or "+o;throw new Error("invalid scalar, expected "+A+" bytes, got "+$)}return Ni(a(E))}function y(b,E){const $=f(E),A=p(b),P=h($,A);if(P===Sr)throw new Error("invalid private or public key received");return d(P)}const w=d(e.Gu);function v(b){return y(b,w)}return{scalarMult:y,scalarMultBase:v,getSharedSecret:(b,E)=>y(b,E),getPublicKey:b=>v(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:w}}const ho=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const U1=BigInt(1),Vc=BigInt(2),q1=BigInt(3),k1=BigInt(5);BigInt(8);function z1(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=ho,o=t*t%s*t%s,a=dt(o,Vc,s)*o%s,c=dt(a,U1,s)*t%s,u=dt(c,k1,s)*c%s,l=dt(u,e,s)*u%s,h=dt(l,r,s)*l%s,d=dt(h,i,s)*h%s,f=dt(d,n,s)*d%s,p=dt(f,n,s)*d%s,y=dt(p,e,s)*u%s;return{pow_p_5_8:dt(y,Vc,s)*t%s,b2:o}}function H1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const po=F1({P:ho,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=ho,{pow_p_5_8:r,b2:i}=z1(t);return He(dt(r,q1,e)*i,e)},adjustScalarBytes:H1,randomBytes:ci});function Wc(t){t.lowS!==void 0&&ti("lowS",t.lowS),t.prehash!==void 0&&ti("prehash",t.prehash)}function K1(t){const e=yd(t);ui(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a:n}=e;if(r){if(!i.eql(n,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:V1,hexToBytes:W1}=O1;class G1 extends Error{constructor(e=""){super(e)}}const Lt={Err:G1,_tlv:{encode:(t,e)=>{const{Err:r}=Lt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,n=zr(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?zr(n.length/2|128):"";return zr(t)+s+n+e},decode(t,e){const{Err:r}=Lt;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const n=e[i++],s=!!(n&128);let o=0;if(!s)o=n;else{const c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const u=e.subarray(i,i+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const l of u)o=o<<8|l;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=Lt;if(t<jt)throw new e("integer: negative integers are not allowed");let r=zr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Lt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return V1(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Lt,n=typeof t=="string"?W1(t):t;Hi(n);const{v:s,l:o}=i.decode(48,n);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,s),{v:u,l}=i.decode(2,c);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){const{_tlv:e,_int:r}=Lt,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}},jt=BigInt(0),_e=BigInt(1);BigInt(2);const Gc=BigInt(3);BigInt(4);function Y1(t){const e=K1(t),{Fp:r}=e,i=hd(e.n,e.nBitLength),n=e.toBytes||((y,w,v)=>{const b=w.toAffine();return Li(Uint8Array.from([4]),r.toBytes(b.x),r.toBytes(b.y))}),s=e.fromBytes||(y=>{const w=y.subarray(1),v=r.fromBytes(w.subarray(0,r.BYTES)),b=r.fromBytes(w.subarray(r.BYTES,2*r.BYTES));return{x:v,y:b}});function o(y){const{a:w,b:v}=e,b=r.sqr(y),E=r.mul(b,y);return r.add(r.add(E,r.mul(y,w)),v)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Xn(y,_e,e.n)}function c(y){const{allowedPrivateKeyLengths:w,nByteLength:v,wrapPrivateKey:b,n:E}=e;if(w&&typeof y!="bigint"){if(fr(y)&&(y=ri(y)),typeof y!="string"||!w.includes(y.length))throw new Error("invalid private key");y=y.padStart(v*2,"0")}let $;try{$=typeof y=="bigint"?y:lr(Je("private key",y,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof y)}return b&&($=He($,E)),Bt("private key",$,_e,E),$}function u(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}const l=co((y,w)=>{const{px:v,py:b,pz:E}=y;if(r.eql(E,r.ONE))return{x:v,y:b};const $=y.is0();w==null&&(w=$?r.ONE:r.inv(E));const A=r.mul(v,w),P=r.mul(b,w),S=r.mul(E,w);if($)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:A,y:P}}),h=co(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}const{x:w,y:v}=y.toAffine();if(!r.isValid(w)||!r.isValid(v))throw new Error("bad point: x or y not FE");const b=r.sqr(v),E=o(w);if(!r.eql(b,E))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(w,v,b){if(this.px=w,this.py=v,this.pz=b,w==null||!r.isValid(w))throw new Error("x required");if(v==null||!r.isValid(v))throw new Error("y required");if(b==null||!r.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(w){const{x:v,y:b}=w||{};if(!w||!r.isValid(v)||!r.isValid(b))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");const E=$=>r.eql($,r.ZERO);return E(v)&&E(b)?d.ZERO:new d(v,b,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const v=r.invertBatch(w.map(b=>b.pz));return w.map((b,E)=>b.toAffine(v[E])).map(d.fromAffine)}static fromHex(w){const v=d.fromAffine(s(Je("pointHex",w)));return v.assertValidity(),v}static fromPrivateKey(w){return d.BASE.multiply(c(w))}static msm(w,v){return B1(d,i,w,v)}_setWindowSize(w){p.setWindowSize(this,w)}assertValidity(){h(this)}hasEvenY(){const{y:w}=this.toAffine();if(r.isOdd)return!r.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){u(w);const{px:v,py:b,pz:E}=this,{px:$,py:A,pz:P}=w,S=r.eql(r.mul(v,P),r.mul($,E)),C=r.eql(r.mul(b,P),r.mul(A,E));return S&&C}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){const{a:w,b:v}=e,b=r.mul(v,Gc),{px:E,py:$,pz:A}=this;let P=r.ZERO,S=r.ZERO,C=r.ZERO,O=r.mul(E,E),q=r.mul($,$),B=r.mul(A,A),j=r.mul(E,$);return j=r.add(j,j),C=r.mul(E,A),C=r.add(C,C),P=r.mul(w,C),S=r.mul(b,B),S=r.add(P,S),P=r.sub(q,S),S=r.add(q,S),S=r.mul(P,S),P=r.mul(j,P),C=r.mul(b,C),B=r.mul(w,B),j=r.sub(O,B),j=r.mul(w,j),j=r.add(j,C),C=r.add(O,O),O=r.add(C,O),O=r.add(O,B),O=r.mul(O,j),S=r.add(S,O),B=r.mul($,A),B=r.add(B,B),O=r.mul(B,j),P=r.sub(P,O),C=r.mul(B,q),C=r.add(C,C),C=r.add(C,C),new d(P,S,C)}add(w){u(w);const{px:v,py:b,pz:E}=this,{px:$,py:A,pz:P}=w;let S=r.ZERO,C=r.ZERO,O=r.ZERO;const q=e.a,B=r.mul(e.b,Gc);let j=r.mul(v,$),k=r.mul(b,A),R=r.mul(E,P),g=r.add(v,b),m=r.add($,A);g=r.mul(g,m),m=r.add(j,k),g=r.sub(g,m),m=r.add(v,E);let _=r.add($,P);return m=r.mul(m,_),_=r.add(j,R),m=r.sub(m,_),_=r.add(b,E),S=r.add(A,P),_=r.mul(_,S),S=r.add(k,R),_=r.sub(_,S),O=r.mul(q,m),S=r.mul(B,R),O=r.add(S,O),S=r.sub(k,O),O=r.add(k,O),C=r.mul(S,O),k=r.add(j,j),k=r.add(k,j),R=r.mul(q,R),m=r.mul(B,m),k=r.add(k,R),R=r.sub(j,R),R=r.mul(q,R),m=r.add(m,R),j=r.mul(k,m),C=r.add(C,j),j=r.mul(_,m),S=r.mul(g,S),S=r.sub(S,j),j=r.mul(g,k),O=r.mul(_,O),O=r.add(O,j),new d(S,C,O)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return p.wNAFCached(this,w,d.normalizeZ)}multiplyUnsafe(w){const{endo:v,n:b}=e;Bt("scalar",w,jt,b);const E=d.ZERO;if(w===jt)return E;if(this.is0()||w===_e)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,w,d.normalizeZ);let{k1neg:$,k1:A,k2neg:P,k2:S}=v.splitScalar(w),C=E,O=E,q=this;for(;A>jt||S>jt;)A&_e&&(C=C.add(q)),S&_e&&(O=O.add(q)),q=q.double(),A>>=_e,S>>=_e;return $&&(C=C.negate()),P&&(O=O.negate()),O=new d(r.mul(O.px,v.beta),O.py,O.pz),C.add(O)}multiply(w){const{endo:v,n:b}=e;Bt("scalar",w,_e,b);let E,$;if(v){const{k1neg:A,k1:P,k2neg:S,k2:C}=v.splitScalar(w);let{p:O,f:q}=this.wNAF(P),{p:B,f:j}=this.wNAF(C);O=p.constTimeNegate(A,O),B=p.constTimeNegate(S,B),B=new d(r.mul(B.px,v.beta),B.py,B.pz),E=O.add(B),$=q.add(j)}else{const{p:A,f:P}=this.wNAF(w);E=A,$=P}return d.normalizeZ([E,$])[0]}multiplyAndAddUnsafe(w,v,b){const E=d.BASE,$=(P,S)=>S===jt||S===_e||!P.equals(E)?P.multiplyUnsafe(S):P.multiply(S),A=$(this,v).add($(w,b));return A.is0()?void 0:A}toAffine(w){return l(this,w)}isTorsionFree(){const{h:w,isTorsionFree:v}=e;if(w===_e)return!0;if(v)return v(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:v}=e;return w===_e?this:v?v(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return ti("isCompressed",w),this.assertValidity(),n(d,this,w)}toHex(w=!0){return ti("isCompressed",w),ri(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,p=j1(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function J1(t){const e=yd(t);return ui(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Z1(t){const e=J1(t),{Fp:r,n:i}=e,n=r.BYTES+1,s=2*r.BYTES+1;function o(R){return He(R,i)}function a(R){return lo(R,i)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=Y1({...e,toBytes(R,g,m){const _=g.toAffine(),D=r.toBytes(_.x),I=Li;return ti("isCompressed",m),m?I(Uint8Array.from([g.hasEvenY()?2:3]),D):I(Uint8Array.from([4]),D,r.toBytes(_.y))},fromBytes(R){const g=R.length,m=R[0],_=R.subarray(1);if(g===n&&(m===2||m===3)){const D=lr(_);if(!Xn(D,_e,r.ORDER))throw new Error("Point is not on curve");const I=l(D);let x;try{x=r.sqrt(I)}catch(U){const z=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+z)}const M=(x&_e)===_e;return(m&1)===1!==M&&(x=r.neg(x)),{x:D,y:x}}else if(g===s&&m===4){const D=r.fromBytes(_.subarray(0,r.BYTES)),I=r.fromBytes(_.subarray(r.BYTES,2*r.BYTES));return{x:D,y:I}}else{const D=n,I=s;throw new Error("invalid Point, expected length of "+D+", or uncompressed "+I+", got "+g)}}}),d=R=>ri(ni(R,e.nByteLength));function f(R){const g=i>>_e;return R>g}function p(R){return f(R)?o(-R):R}const y=(R,g,m)=>lr(R.slice(g,m));class w{constructor(g,m,_){this.r=g,this.s=m,this.recovery=_,this.assertValidity()}static fromCompact(g){const m=e.nByteLength;return g=Je("compactSignature",g,m*2),new w(y(g,0,m),y(g,m,2*m))}static fromDER(g){const{r:m,s:_}=Lt.toSig(Je("DER",g));return new w(m,_)}assertValidity(){Bt("r",this.r,_e,i),Bt("s",this.s,_e,i)}addRecoveryBit(g){return new w(this.r,this.s,g)}recoverPublicKey(g){const{r:m,s:_,recovery:D}=this,I=P(Je("msgHash",g));if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");const x=D===2||D===3?m+e.n:m;if(x>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const M=D&1?"03":"02",U=c.fromHex(M+d(x)),z=a(x),F=o(-I*z),H=o(_*z),G=c.BASE.multiplyAndAddUnsafe(U,F,H);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return ii(this.toDERHex())}toDERHex(){return Lt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ii(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const v={isValidPrivateKey(R){try{return u(R),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const R=pd(e.n);return T1(e.randomBytes(R),e.n)},precompute(R=8,g=c.BASE){return g._setWindowSize(R),g.multiply(BigInt(3)),g}};function b(R,g=!0){return c.fromPrivateKey(R).toRawBytes(g)}function E(R){const g=fr(R),m=typeof R=="string",_=(g||m)&&R.length;return g?_===n||_===s:m?_===2*n||_===2*s:R instanceof c}function $(R,g,m=!0){if(E(R))throw new Error("first arg must be private key");if(!E(g))throw new Error("second arg must be public key");return c.fromHex(g).multiply(u(R)).toRawBytes(m)}const A=e.bits2int||function(R){if(R.length>8192)throw new Error("input is too large");const g=lr(R),m=R.length*8-e.nBitLength;return m>0?g>>BigInt(m):g},P=e.bits2int_modN||function(R){return o(A(R))},S=ta(e.nBitLength);function C(R){return Bt("num < 2^"+e.nBitLength,R,jt,S),ni(R,e.nByteLength)}function O(R,g,m=q){if(["recovered","canonical"].some(ee=>ee in m))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:D}=e;let{lowS:I,prehash:x,extraEntropy:M}=m;I==null&&(I=!0),R=Je("msgHash",R),Wc(m),x&&(R=Je("prehashed msgHash",_(R)));const U=P(R),z=u(g),F=[C(z),C(U)];if(M!=null&&M!==!1){const ee=M===!0?D(r.BYTES):M;F.push(Je("extraEntropy",ee))}const H=Li(...F),G=U;function ue(ee){const Y=A(ee);if(!h(Y))return;const Te=a(Y),De=c.BASE.multiply(Y).toAffine(),je=o(De.x);if(je===jt)return;const et=o(Te*o(G+je*z));if(et===jt)return;let Pt=(De.x===je?0:2)|Number(De.y&_e),Er=et;return I&&f(et)&&(Er=p(et),Pt^=1),new w(je,Er,Pt)}return{seed:H,k2sig:ue}}const q={lowS:e.lowS,prehash:!1},B={lowS:e.lowS,prehash:!1};function j(R,g,m=q){const{seed:_,k2sig:D}=O(R,g,m),I=e;return cd(I.hash.outputLen,I.nByteLength,I.hmac)(_,D)}c.BASE._setWindowSize(8);function k(R,g,m,_=B){const D=R;g=Je("msgHash",g),m=Je("publicKey",m);const{lowS:I,prehash:x,format:M}=_;if(Wc(_),"strict"in _)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");const U=typeof D=="string"||fr(D),z=!U&&!M&&typeof D=="object"&&D!==null&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!U&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,H;try{if(z&&(F=new w(D.r,D.s)),U){try{M!=="compact"&&(F=w.fromDER(D))}catch(et){if(!(et instanceof Lt.Err))throw et}!F&&M!=="der"&&(F=w.fromCompact(D))}H=c.fromHex(m)}catch{return!1}if(!F||I&&F.hasHighS())return!1;x&&(g=e.hash(g));const{r:G,s:ue}=F,ee=P(g),Y=a(ue),Te=o(ee*Y),De=o(G*Y),je=c.BASE.multiplyAndAddUnsafe(H,Te,De)?.toAffine();return je?o(je.x)===G:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:$,sign:j,verify:k,ProjectivePoint:c,Signature:w,utils:v}}function Q1(t){return{hash:t,hmac:(e,...r)=>Yn(t,e,r0(...r)),randomBytes:ci}}function X1(t,e){const r=i=>Z1({...t,...Q1(i)});return{...r(e),create:r}}const md=hd(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),eE=md.create(BigInt("-3")),tE=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),rE=X1({a:eE,b:tE,Fp:md,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},zi),wd="base10",Me="base16",pt="base64pad",Vt="base64url",Ki="utf8",bd=0,Mt=1,Vi=2,iE=0,Yc=1,Oi=12,ra=32;function nE(){const t=po.utils.randomPrivateKey(),e=po.getPublicKey(t);return{privateKey:Ke(t,Me),publicKey:Ke(e,Me)}}function fo(){const t=ci(ra);return Ke(t,Me)}function sE(t,e){const r=po.getSharedSecret(st(t,Me),st(e,Me)),i=u1(zi,r,void 0,void 0,ra);return Ke(i,Me)}function mn(t){const e=zi(st(t,Me));return Ke(e,Me)}function $t(t){const e=zi(st(t,Ki));return Ke(e,Me)}function vd(t){return st(`${t}`,wd)}function gr(t){return Number(Ke(t,wd))}function Ed(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function _d(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4;return e+"=".repeat(r)}function oE(t){const e=vd(typeof t.type<"u"?t.type:bd);if(gr(e)===Mt&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?st(t.senderPublicKey,Me):void 0,i=typeof t.iv<"u"?st(t.iv,Me):ci(Oi),n=st(t.symKey,Me),s=sd(n,i).encrypt(st(t.message,Ki)),o=Id({type:e,sealed:s,iv:i,senderPublicKey:r});return t.encoding===Vt?Ed(o):o}function aE(t){const e=st(t.symKey,Me),{sealed:r,iv:i}=ji({encoded:t.encoded,encoding:t.encoding}),n=sd(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return Ke(n,Ki)}function cE(t,e){const r=vd(Vi),i=ci(Oi),n=st(t,Ki),s=Id({type:r,sealed:n,iv:i});return e===Vt?Ed(s):s}function uE(t,e){const{sealed:r}=ji({encoded:t,encoding:e});return Ke(r,Ki)}function Id(t){if(gr(t.type)===Vi)return Ke($i([t.type,t.sealed]),pt);if(gr(t.type)===Mt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ke($i([t.type,t.senderPublicKey,t.iv,t.sealed]),pt)}return Ke($i([t.type,t.iv,t.sealed]),pt)}function ji(t){const e=(t.encoding||pt)===Vt?_d(t.encoded):t.encoded,r=st(e,pt),i=r.slice(iE,Yc),n=Yc;if(gr(i)===Mt){const c=n+ra,u=c+Oi,l=r.slice(n,c),h=r.slice(c,u),d=r.slice(u);return{type:i,sealed:d,iv:h,senderPublicKey:l}}if(gr(i)===Vi){const c=r.slice(n),u=ci(Oi);return{type:i,sealed:c,iv:u}}const s=n+Oi,o=r.slice(n,s),a=r.slice(s);return{type:i,sealed:a,iv:o}}function lE(t,e){const r=ji({encoded:t,encoding:e?.encoding});return $d({type:gr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Ke(r.senderPublicKey,Me):void 0,receiverPublicKey:e?.receiverPublicKey})}function $d(t){const e=t?.type||bd;if(e===Mt){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Jc(t){return t.type===Mt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Zc(t){return t.type===Vi}function hE(t){const e=Buffer.from(t.x,"base64"),r=Buffer.from(t.y,"base64");return $i([new Uint8Array([4]),e,r])}function dE(t,e){const[r,i,n]=t.split("."),s=Buffer.from(_d(n),"base64");if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32),a=s.slice(32,64),c=`${r}.${i}`,u=zi(c),l=hE(e);if(!rE.verify($i([o,a]),u,l))throw new Error("Invalid signature");return Qs(t).payload}const pE="irn";function An(t){return t?.relay||{protocol:pE}}function Ei(t){const e=ob[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function fE(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function Qc(t){if(!t.includes("wc:")){const u=Vh(t);u!=null&&u.includes("wc:")&&(t=u)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((u,l)=>{a[l]=u});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:gE(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:fE(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function gE(t){return t.startsWith("//")?t.substring(2):t}function yE(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=n,o=r+e+s;t[s]&&(i[o]=t[s])}),i}function Xc(t){const e=new URLSearchParams,r=yE(t.relay);Object.keys(r).sort().forEach(n=>{e.set(n,r[n])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function rn(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}var mE=Object.defineProperty,wE=Object.defineProperties,bE=Object.getOwnPropertyDescriptors,eu=Object.getOwnPropertySymbols,vE=Object.prototype.hasOwnProperty,EE=Object.prototype.propertyIsEnumerable,tu=(t,e,r)=>e in t?mE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_E=(t,e)=>{for(var r in e||(e={}))vE.call(e,r)&&tu(t,r,e[r]);if(eu)for(var r of eu(e))EE.call(e,r)&&tu(t,r,e[r]);return t},IE=(t,e)=>wE(t,bE(e));function li(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function $E(t){const e=[];return Object.values(t).forEach(r=>{e.push(...li(r.accounts))}),e}function OE(t,e){const r=[];return Object.values(t).forEach(i=>{li(i.accounts).includes(e)&&r.push(...i.methods)}),r}function DE(t,e){const r=[];return Object.values(t).forEach(i=>{li(i.accounts).includes(e)&&r.push(...i.events)}),r}function es(t){return t.includes(":")}function Hr(t){return es(t)?t.split(":")[0]:t}function ru(t){var e,r,i;const n={};if(!Jt(t))return n;for(const[s,o]of Object.entries(t)){const a=es(s)?[s]:o.chains,c=o.methods||[],u=o.events||[],l=Hr(s);n[l]=IE(_E({},n[l]),{chains:Dt(a,(e=n[l])==null?void 0:e.chains),methods:Dt(c,(r=n[l])==null?void 0:r.methods),events:Dt(u,(i=n[l])==null?void 0:i.events)})}return n}function SE(t){const e={};return t?.forEach(r=>{var i;const[n,s]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[],methods:[]}),e[n].accounts.push(r),(i=e[n].chains)==null||i.push(`${n}:${s}`)}),e}function iu(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=SE(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=Dt(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}function PE(t,e){var r,i,n,s,o,a;const c=ru(t),u=ru(e),l={},h=Object.keys(c).concat(Object.keys(u));for(const d of h)l[d]={chains:Dt((r=c[d])==null?void 0:r.chains,(i=u[d])==null?void 0:i.chains),methods:Dt((n=c[d])==null?void 0:n.methods,(s=u[d])==null?void 0:s.methods),events:Dt((o=c[d])==null?void 0:o.events,(a=u[d])==null?void 0:a.events)};return l}const AE={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}},xE={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 L(t,e){const{message:r,code:i}=xE[t];return{message:e?`${r} ${e}`:r,code:i}}function te(t,e){const{message:r,code:i}=AE[t];return{message:e?`${r} ${e}`:r,code:i}}function ft(t,e){return!!Array.isArray(t)}function Jt(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Le(t){return typeof t>"u"}function ye(t,e){return e&&Le(t)?!0:typeof t=="string"&&!!t.trim().length}function ia(t,e){return typeof t=="number"&&!isNaN(t)}function CE(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return ur(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:u}=t.namespaces[o],l=li(a),h=r[o];(!ur(qh(o,h),l)||!ur(h.methods,c)||!ur(h.events,u))&&(s=!1)}),s):!1}function xn(t){return ye(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function RE(t){if(ye(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&xn(r)}}return!1}function TE(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(ye(t,!1)){if(e(t))return!0;const r=Vh(t);return e(r)}}catch{}return!1}function NE(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function LE(t){return t?.topic}function jE(t,e){let r=null;return ye(t?.publicKey,!1)||(r=L("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function nu(t){let e=!0;return ft(t)?t.length&&(e=t.every(r=>ye(r,!1))):e=!1,e}function BE(t,e,r){let i=null;return ft(e)&&e.length?e.forEach(n=>{i||xn(n)||(i=te("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):xn(t)||(i=te("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function ME(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=BE(n,qh(n,s),`${e} ${r}`);o&&(i=o)}),i}function FE(t,e){let r=null;return ft(t)?t.forEach(i=>{r||RE(i)||(r=te("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=te("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function UE(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=FE(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function qE(t,e){let r=null;return nu(t?.methods)?nu(t?.events)||(r=te("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=te("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Od(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=qE(i,`${e}, namespace`);n&&(r=n)}),r}function kE(t,e,r){let i=null;if(t&&Jt(t)){const n=Od(t,e);n&&(i=n);const s=ME(t,e,r);s&&(i=s)}else i=L("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function xs(t,e){let r=null;if(t&&Jt(t)){const i=Od(t,e);i&&(r=i);const n=UE(t,e);n&&(r=n)}else r=L("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Dd(t){return ye(t.protocol,!0)}function zE(t,e){let r=!1;return t?t&&ft(t)&&t.length&&t.forEach(i=>{r=Dd(i)}):r=!0,r}function HE(t){return typeof t=="number"}function ze(t){return typeof t<"u"&&typeof t!==null}function KE(t){return!(!t||typeof t!="object"||!t.code||!ia(t.code)||!t.message||!ye(t.message,!1))}function VE(t){return!(Le(t)||!ye(t.method,!1))}function WE(t){return!(Le(t)||Le(t.result)&&Le(t.error)||!ia(t.id)||!ye(t.jsonrpc,!1))}function GE(t){return!(Le(t)||!ye(t.name,!1))}function su(t,e){return!(!xn(e)||!$E(t).includes(e))}function YE(t,e,r){return ye(r,!1)?OE(t,e).includes(r):!1}function JE(t,e,r){return ye(r,!1)?DE(t,e).includes(r):!1}function ou(t,e,r){let i=null;const n=ZE(t),s=QE(e),o=Object.keys(n),a=Object.keys(s),c=au(Object.keys(t)),u=au(Object.keys(e)),l=c.filter(h=>!u.includes(h));return l.length&&(i=L("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
32
|
+
Required: ${l.toString()}
|
|
33
|
+
Received: ${Object.keys(e).toString()}`)),ur(o,a)||(i=L("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
34
|
+
Required: ${o.toString()}
|
|
35
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const d=li(e[h].accounts);d.includes(h)||(i=L("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
36
|
+
Required: ${h}
|
|
37
|
+
Approved: ${d.toString()}`))}),o.forEach(h=>{i||(ur(n[h].methods,s[h].methods)?ur(n[h].events,s[h].events)||(i=L("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${h}`)):i=L("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function ZE(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function au(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function QE(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:li(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function XE(t,e){return ia(t)&&t<=e.max&&t>=e.min}function cu(){const t=qi();return new Promise(e=>{switch(t){case Qe.browser:e(e_());break;case Qe.reactNative:e(t_());break;case Qe.node:e(r_());break;default:e(!0)}})}function e_(){return ai()&&navigator?.onLine}async function t_(){return Zt()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function r_(){return!0}function i_(t){switch(qi()){case Qe.browser:n_(t);break;case Qe.reactNative:s_(t);break}}function n_(t){!Zt()&&ai()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function s_(t){Zt()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}function o_(){var t;return ai()&&dr()?((t=dr())==null?void 0:t.visibilityState)==="visible":!0}const Cs={};class gi{static get(e){return Cs[e]}static set(e,r){Cs[e]=r}static delete(e){delete Cs[e]}}function a_(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Ee(t,...e){try{return a_(t(...e))}catch(r){return Promise.reject(r)}}function c_(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function u_(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function wn(t){if(c_(t))return String(t);if(u_(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return wn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const go="base64:";function l_(t){return typeof t=="string"?t:go+p_(t)}function h_(t){return typeof t!="string"||!t.startsWith(go)?t:d_(t.slice(go.length))}function d_(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function p_(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function ke(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function f_(...t){return ke(t.join(":"))}function nn(t){return t=ke(t),t?t+":":""}function g_(t,e){if(e===void 0)return!0;let r=0,i=t.indexOf(":");for(;i>-1;)r++,i=t.indexOf(":",i+1);return r<=e}function y_(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const m_="memory",w_=()=>{const t=new Map;return{name:m_,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function b_(t={}){const e={mounts:{"":t.driver||w_()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const l of e.mountpoints)if(u.startsWith(l))return{base:l,relativeKey:u.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,l)=>e.mountpoints.filter(h=>h.startsWith(u)||l&&u.startsWith(h)).map(h=>({relativeBase:u.length>h.length?u.slice(h.length):void 0,mountpoint:h,driver:e.mounts[h]})),n=(u,l)=>{if(e.watching){l=ke(l);for(const h of e.watchListeners)h(u,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await uu(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,l,h)=>{const d=new Map,f=p=>{let y=d.get(p.base);return y||(y={driver:p.driver,base:p.base,items:[]},d.set(p.base,y)),y};for(const p of u){const y=typeof p=="string",w=ke(y?p:p.key),v=y?void 0:p.value,b=y||!p.options?l:{...l,...p.options},E=r(w);f(E).items.push({key:w,value:v,relativeKey:E.relativeKey,options:b})}return Promise.all([...d.values()].map(p=>h(p))).then(p=>p.flat())},c={hasItem(u,l={}){u=ke(u);const{relativeKey:h,driver:d}=r(u);return Ee(d.hasItem,h,l)},getItem(u,l={}){u=ke(u);const{relativeKey:h,driver:d}=r(u);return Ee(d.getItem,h,l).then(f=>Gi(f))},getItems(u,l={}){return a(u,l,h=>h.driver.getItems?Ee(h.driver.getItems,h.items.map(d=>({key:d.relativeKey,options:d.options})),l).then(d=>d.map(f=>({key:f_(h.base,f.key),value:Gi(f.value)}))):Promise.all(h.items.map(d=>Ee(h.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:Gi(f)})))))},getItemRaw(u,l={}){u=ke(u);const{relativeKey:h,driver:d}=r(u);return d.getItemRaw?Ee(d.getItemRaw,h,l):Ee(d.getItem,h,l).then(f=>h_(f))},async setItem(u,l,h={}){if(l===void 0)return c.removeItem(u);u=ke(u);const{relativeKey:d,driver:f}=r(u);f.setItem&&(await Ee(f.setItem,d,wn(l),h),f.watch||n("update",u))},async setItems(u,l){await a(u,l,async h=>{if(h.driver.setItems)return Ee(h.driver.setItems,h.items.map(d=>({key:d.relativeKey,value:wn(d.value),options:d.options})),l);h.driver.setItem&&await Promise.all(h.items.map(d=>Ee(h.driver.setItem,d.relativeKey,wn(d.value),d.options)))})},async setItemRaw(u,l,h={}){if(l===void 0)return c.removeItem(u,h);u=ke(u);const{relativeKey:d,driver:f}=r(u);if(f.setItemRaw)await Ee(f.setItemRaw,d,l,h);else if(f.setItem)await Ee(f.setItem,d,l_(l),h);else return;f.watch||n("update",u)},async removeItem(u,l={}){typeof l=="boolean"&&(l={removeMeta:l}),u=ke(u);const{relativeKey:h,driver:d}=r(u);d.removeItem&&(await Ee(d.removeItem,h,l),(l.removeMeta||l.removeMata)&&await Ee(d.removeItem,h+"$",l),d.watch||n("remove",u))},async getMeta(u,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),u=ke(u);const{relativeKey:h,driver:d}=r(u),f=Object.create(null);if(d.getMeta&&Object.assign(f,await Ee(d.getMeta,h,l)),!l.nativeOnly){const p=await Ee(d.getItem,h+"$",l).then(y=>Gi(y));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(u,l,h={}){return this.setItem(u+"$",l,h)},removeMeta(u,l={}){return this.removeItem(u+"$",l)},async getKeys(u,l={}){u=nn(u);const h=i(u,!0);let d=[];const f=[];let p=!0;for(const w of h){w.driver.flags?.maxDepth||(p=!1);const v=await Ee(w.driver.getKeys,w.relativeBase,l);for(const b of v){const E=w.mountpoint+ke(b);d.some($=>E.startsWith($))||f.push(E)}d=[w.mountpoint,...d.filter(b=>!b.startsWith(w.mountpoint))]}const y=l.maxDepth!==void 0&&!p;return f.filter(w=>(!y||g_(w,l.maxDepth))&&y_(w,u))},async clear(u,l={}){u=nn(u),await Promise.all(i(u,!1).map(async h=>{if(h.driver.clear)return Ee(h.driver.clear,h.relativeBase,l);if(h.driver.removeItem){const d=await h.driver.getKeys(h.relativeBase||"",l);return Promise.all(d.map(f=>h.driver.removeItem(f,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>lu(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,l){if(u=nn(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((h,d)=>d.length-h.length)),e.mounts[u]=l,e.watching&&Promise.resolve(uu(l,n,u)).then(h=>{e.unwatch[u]=h}).catch(console.error),c},async unmount(u,l=!0){u=nn(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u]?.(),delete e.unwatch[u]),l&&await lu(e.mounts[u]),e.mountpoints=e.mountpoints.filter(h=>h!==u),delete e.mounts[u])},getMount(u=""){u=ke(u)+":";const l=r(u);return{driver:l.driver,base:l.base}},getMounts(u="",l={}){return u=ke(u),i(u,l.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(u,l={})=>c.getKeys(u,l),get:(u,l={})=>c.getItem(u,l),set:(u,l,h={})=>c.setItem(u,l,h),has:(u,l={})=>c.hasItem(u,l),del:(u,l={})=>c.removeItem(u,l),remove:(u,l={})=>c.removeItem(u,l)};return c}function uu(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function lu(t){typeof t.dispose=="function"&&await Ee(t.dispose)}const v_="idb-keyval";var E_=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=$p(t.dbName,t.storeName)),{name:v_,options:t,async hasItem(n){return!(typeof await ga(r(n),i)>"u")},async getItem(n){return await ga(r(n),i)??null},setItem(n,s){return Op(r(n),s,i)},removeItem(n){return Dp(r(n),i)},getKeys(){return Sp(i)},clear(){return Pp(i)}}};const __="WALLET_CONNECT_V2_INDEXED_DB",I_="keyvaluestorage";let $_=class{constructor(){this.indexedDb=b_({driver:E_({dbName:__,storeName:I_})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,Ft(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Rs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},bn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Rs<"u"&&Rs.localStorage?bn.exports=Rs.localStorage:typeof window<"u"&&window.localStorage?bn.exports=window.localStorage:bn.exports=new e})();function O_(t){var e;return[t[0],hr((e=t[1])!=null?e:"")]}let D_=class{constructor(){this.localStorage=bn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(O_)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return hr(r)}async setItem(e,r){this.localStorage.setItem(e,Ft(r))}async removeItem(e){this.localStorage.removeItem(e)}};const S_="wc_storage_version",hu=1,P_=async(t,e,r)=>{const i=S_,n=await e.getItem(i);if(n&&n>=hu){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const u=await t.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,hu),r(e),A_(t,o)},A_=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let x_=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new D_;this.storage=e;try{const r=new $_;P_(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};var C_=Object.defineProperty,R_=(t,e,r)=>e in t?C_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,du=(t,e,r)=>R_(t,typeof e!="symbol"?e+"":e,r);let T_=class extends yr{constructor(e){super(),this.opts=e,du(this,"protocol","wc"),du(this,"version",2)}};var N_=Object.defineProperty,L_=(t,e,r)=>e in t?N_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,j_=(t,e,r)=>L_(t,e+"",r);let B_=class extends yr{constructor(e,r){super(),this.core=e,this.logger=r,j_(this,"records",new Map)}},M_=class{constructor(e,r){this.logger=e,this.core=r}};class F_ extends yr{constructor(e,r){super(),this.relayer=e,this.logger=r}}let U_=class extends yr{constructor(e){super()}},q_=class{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}},k_=class extends yr{constructor(e,r){super(),this.relayer=e,this.logger=r}},z_=class extends yr{constructor(e,r){super(),this.core=e,this.logger=r}},H_=class{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}},K_=class{constructor(e,r){this.projectId=e,this.logger=r}},V_=class{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}};var W_=Object.defineProperty,G_=(t,e,r)=>e in t?W_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pu=(t,e,r)=>G_(t,typeof e!="symbol"?e+"":e,r);let Y_=class{constructor(e){this.opts=e,pu(this,"protocol","wc"),pu(this,"version",2)}},J_=class{constructor(e){this.client=e}};var Z_={};const Sd="wc",Pd=2,Cn="core",St=`${Sd}@2:${Cn}:`,Q_={name:Cn,logger:"error"},X_={database:":memory:"},eI="crypto",fu="client_ed25519_seed",tI=N.ONE_DAY,rI="keychain",iI="0.3",nI="messages",sI="0.3",gu=N.SIX_HOURS,oI="publisher",Ad="irn",aI="error",xd="wss://relay.walletconnect.org",cI="relayer",Ie={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},uI="_subscription",tt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},lI=.1,yo="2.21.1",de={link_mode:"link_mode",relay:"relay"},vn={inbound:"inbound",outbound:"outbound"},hI="0.3",dI="WALLETCONNECT_CLIENT_ID",yu="WALLETCONNECT_LINK_MODE_APPS",Ye={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},pI="subscription",fI="0.3",gI="pairing",yI="0.3",yi={wc_pairingDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:N.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:N.ONE_DAY,prompt:!1,tag:0},res:{ttl:N.ONE_DAY,prompt:!1,tag:0}}},or={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},ut={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},mI="history",wI="0.3",bI="expirer",it={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},vI="0.3",EI="verify-api",_I="https://verify.walletconnect.com",Cd="https://verify.walletconnect.org",Di=Cd,II=`${Di}/v3`,$I=[_I,Cd],OI="echo",DI="https://echo.walletconnect.com",vt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Nt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},lt={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},er={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},tr={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},mi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},SI=.1,PI="event-client",AI=86400,xI="https://pulse.walletconnect.org/batch";function CI(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*l+1>>>0,$=new Uint8Array(E);v!==b;){for(var A=p[v],P=0,S=E-1;(A!==0||P<w)&&S!==-1;S--,P++)A+=256*$[S]>>>0,$[S]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=P,v++}for(var C=E-w;C!==E&&$[C]===0;)C++;for(var O=c.repeat(y);C<E;++C)O+=t.charAt($[C]);return O}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var $=r[p.charCodeAt(y)];if($===255)return;for(var A=0,P=b-1;($!==0||A<v)&&P!==-1;P--,A++)$+=a*E[P]>>>0,E[P]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");v=A,y++}if(p[y]!==" "){for(var S=b-v;S!==b&&E[S]===0;)S++;for(var C=new Uint8Array(w+(b-S)),O=w;S!==b;)C[O++]=E[S++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var RI=CI,TI=RI;const Rd=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},NI=t=>new TextEncoder().encode(t),LI=t=>new TextDecoder().decode(t);class jI{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class BI{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Td(this,e)}}class MI{constructor(e){this.decoders=e}or(e){return Td(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Td=(t,e)=>new MI({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class FI{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new jI(e,r,i),this.decoder=new BI(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ts=({name:t,prefix:e,encode:r,decode:i})=>new FI(t,e,r,i),Wi=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=TI(r,e);return ts({prefix:t,name:e,encode:i,decode:s=>Rd(n(s))})},UI=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},qI=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Re=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ts({prefix:e,name:t,encode(n){return qI(n,i,r)},decode(n){return UI(n,i,r,t)}}),kI=ts({prefix:"\0",name:"identity",encode:t=>LI(t),decode:t=>NI(t)});var zI=Object.freeze({__proto__:null,identity:kI});const HI=Re({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var KI=Object.freeze({__proto__:null,base2:HI});const VI=Re({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var WI=Object.freeze({__proto__:null,base8:VI});const GI=Wi({prefix:"9",name:"base10",alphabet:"0123456789"});var YI=Object.freeze({__proto__:null,base10:GI});const JI=Re({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ZI=Re({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var QI=Object.freeze({__proto__:null,base16:JI,base16upper:ZI});const XI=Re({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),e$=Re({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),t$=Re({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),r$=Re({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),i$=Re({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),n$=Re({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),s$=Re({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),o$=Re({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),a$=Re({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var c$=Object.freeze({__proto__:null,base32:XI,base32upper:e$,base32pad:t$,base32padupper:r$,base32hex:i$,base32hexupper:n$,base32hexpad:s$,base32hexpadupper:o$,base32z:a$});const u$=Wi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),l$=Wi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var h$=Object.freeze({__proto__:null,base36:u$,base36upper:l$});const d$=Wi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),p$=Wi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var f$=Object.freeze({__proto__:null,base58btc:d$,base58flickr:p$});const g$=Re({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),y$=Re({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),m$=Re({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),w$=Re({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var b$=Object.freeze({__proto__:null,base64:g$,base64pad:y$,base64url:m$,base64urlpad:w$});const Nd=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),v$=Nd.reduce((t,e,r)=>(t[r]=e,t),[]),E$=Nd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function _$(t){return t.reduce((e,r)=>(e+=v$[r],e),"")}function I$(t){const e=[];for(const r of t){const i=E$[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const $$=ts({prefix:"🚀",name:"base256emoji",encode:_$,decode:I$});var O$=Object.freeze({__proto__:null,base256emoji:$$}),D$=Ld,mu=128,S$=127,P$=~S$,A$=Math.pow(2,31);function Ld(t,e,r){e=e||[],r=r||0;for(var i=r;t>=A$;)e[r++]=t&255|mu,t/=128;for(;t&P$;)e[r++]=t&255|mu,t>>>=7;return e[r]=t|0,Ld.bytes=r-i+1,e}var x$=mo,C$=128,wu=127;function mo(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw mo.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&wu)<<n:(o&wu)*Math.pow(2,n),n+=7}while(o>=C$);return mo.bytes=s-i,r}var R$=Math.pow(2,7),T$=Math.pow(2,14),N$=Math.pow(2,21),L$=Math.pow(2,28),j$=Math.pow(2,35),B$=Math.pow(2,42),M$=Math.pow(2,49),F$=Math.pow(2,56),U$=Math.pow(2,63),q$=function(t){return t<R$?1:t<T$?2:t<N$?3:t<L$?4:t<j$?5:t<B$?6:t<M$?7:t<F$?8:t<U$?9:10},k$={encode:D$,decode:x$,encodingLength:q$},jd=k$;const bu=(t,e,r=0)=>(jd.encode(t,e,r),e),vu=t=>jd.encodingLength(t),wo=(t,e)=>{const r=e.byteLength,i=vu(t),n=i+vu(r),s=new Uint8Array(n+r);return bu(t,s,0),bu(r,s,i),s.set(e,n),new z$(t,r,e,s)};class z${constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Bd=({name:t,code:e,encode:r})=>new H$(t,e,r);class H${constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?wo(this.code,r):r.then(i=>wo(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Md=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),K$=Bd({name:"sha2-256",code:18,encode:Md("SHA-256")}),V$=Bd({name:"sha2-512",code:19,encode:Md("SHA-512")});var W$=Object.freeze({__proto__:null,sha256:K$,sha512:V$});const Fd=0,G$="identity",Ud=Rd,Y$=t=>wo(Fd,Ud(t)),J$={code:Fd,name:G$,encode:Ud,digest:Y$};var Z$=Object.freeze({__proto__:null,identity:J$});new TextEncoder,new TextDecoder;const Eu={...zI,...KI,...WI,...YI,...QI,...c$,...h$,...f$,...b$,...O$};({...W$,...Z$});function Q$(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function qd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const _u=qd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ts=qd("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Q$(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),X$={utf8:_u,"utf-8":_u,hex:Eu.base16,latin1:Ts,ascii:Ts,binary:Ts,...Eu};function eO(t,e="utf8"){const r=X$[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var tO=Object.defineProperty,rO=(t,e,r)=>e in t?tO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wt=(t,e,r)=>rO(t,typeof e!="symbol"?e+"":e,r);class iO{constructor(e,r){this.core=e,this.logger=r,wt(this,"keychain",new Map),wt(this,"name",rI),wt(this,"version",iI),wt(this,"initialized",!1),wt(this,"storagePrefix",St),wt(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),wt(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),wt(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),wt(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=L("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),wt(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=Fe(r,this.name)}get context(){return Ve(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ro(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?io(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var nO=Object.defineProperty,sO=(t,e,r)=>e in t?nO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pe=(t,e,r)=>sO(t,typeof e!="symbol"?e+"":e,r);class oO{constructor(e,r,i){this.core=e,this.logger=r,Pe(this,"name",eI),Pe(this,"keychain"),Pe(this,"randomSessionIdentifier",fo()),Pe(this,"initialized",!1),Pe(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Pe(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),Pe(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Ja(n);return rh(s.publicKey)}),Pe(this,"generateKeyPair",()=>{this.isInitialized();const n=nE();return this.setPrivateKey(n.publicKey,n.privateKey)}),Pe(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Ja(s),a=this.randomSessionIdentifier;return await Mm(a,n,tI,o)}),Pe(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=sE(a,s);return this.setSymKey(c,o)}),Pe(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||mn(n);return await this.keychain.set(o,n),o}),Pe(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),Pe(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),Pe(this,"encode",async(n,s,o)=>{this.isInitialized();const a=$d(o),c=Ft(s);if(Zc(a))return cE(c,o?.encoding);if(Jc(a)){const d=a.senderPublicKey,f=a.receiverPublicKey;n=await this.generateSharedKey(d,f)}const u=this.getSymKey(n),{type:l,senderPublicKey:h}=a;return oE({type:l,symKey:u,message:c,senderPublicKey:h,encoding:o?.encoding})}),Pe(this,"decode",async(n,s,o)=>{this.isInitialized();const a=lE(s,o);if(Zc(a)){const c=uE(s,o?.encoding);return hr(c)}if(Jc(a)){const c=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(c,u)}try{const c=this.getSymKey(n),u=aE({symKey:c,encoded:s,encoding:o?.encoding});return hr(u)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Pe(this,"getPayloadType",(n,s=pt)=>{const o=ji({encoded:n,encoding:s});return gr(o.type)}),Pe(this,"getPayloadSenderPublicKey",(n,s=pt)=>{const o=ji({encoded:n,encoding:s});return o.senderPublicKey?Ke(o.senderPublicKey,Me):void 0}),this.core=e,this.logger=Fe(r,this.name),this.keychain=i||new iO(this.core,this.logger)}get context(){return Ve(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(fu)}catch{e=fo(),await this.keychain.set(fu,e)}return eO(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var aO=Object.defineProperty,cO=Object.defineProperties,uO=Object.getOwnPropertyDescriptors,Iu=Object.getOwnPropertySymbols,lO=Object.prototype.hasOwnProperty,hO=Object.prototype.propertyIsEnumerable,bo=(t,e,r)=>e in t?aO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dO=(t,e)=>{for(var r in e||(e={}))lO.call(e,r)&&bo(t,r,e[r]);if(Iu)for(var r of Iu(e))hO.call(e,r)&&bo(t,r,e[r]);return t},pO=(t,e)=>cO(t,uO(e)),We=(t,e,r)=>bo(t,typeof e!="symbol"?e+"":e,r);class fO extends M_{constructor(e,r){super(e,r),this.logger=e,this.core=r,We(this,"messages",new Map),We(this,"messagesWithoutClientAck",new Map),We(this,"name",nI),We(this,"version",sI),We(this,"initialized",!1),We(this,"storagePrefix",St),We(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const n=await this.getRelayerMessagesWithoutClientAck();typeof n<"u"&&(this.messagesWithoutClientAck=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),We(this,"set",async(i,n,s)=>{this.isInitialized();const o=$t(n);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=n,this.messages.set(i,a),s===vn.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,pO(dO({},c),{[o]:n}))}return await this.persist(),o}),We(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),We(this,"getWithoutAck",i=>{this.isInitialized();const n={};for(const s of i){const o=this.messagesWithoutClientAck.get(s)||{};n[s]=Object.values(o)}return n}),We(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=$t(n);return typeof s[o]<"u"}),We(this,"ack",async(i,n)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(i);if(typeof s>"u")return;const o=$t(n);delete s[o],Object.keys(s).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,s),await this.persist()}),We(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist()}),this.logger=Fe(e,this.name),this.core=r}get context(){return Ve(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,ro(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ro(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?io(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?io(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var gO=Object.defineProperty,yO=Object.defineProperties,mO=Object.getOwnPropertyDescriptors,$u=Object.getOwnPropertySymbols,wO=Object.prototype.hasOwnProperty,bO=Object.prototype.propertyIsEnumerable,vo=(t,e,r)=>e in t?gO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sn=(t,e)=>{for(var r in e||(e={}))wO.call(e,r)&&vo(t,r,e[r]);if($u)for(var r of $u(e))bO.call(e,r)&&vo(t,r,e[r]);return t},Ns=(t,e)=>yO(t,mO(e)),ht=(t,e,r)=>vo(t,typeof e!="symbol"?e+"":e,r);class vO extends F_{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ht(this,"events",new Ut.EventEmitter),ht(this,"name",oI),ht(this,"queue",new Map),ht(this,"publishTimeout",N.toMiliseconds(N.ONE_MINUTE)),ht(this,"initialPublishTimeout",N.toMiliseconds(N.ONE_SECOND*15)),ht(this,"needsTransportRestart",!1),ht(this,"publish",async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=s?.ttl||gu,c=An(s),u=s?.prompt||!1,l=s?.tag||0,h=s?.id||cr().toString(),d={topic:i,message:n,opts:{ttl:a,relay:c,prompt:u,tag:l,id:h,attestation:s?.attestation,tvf:s?.tvf}},f=`Failed to publish payload, please try again. id:${h} tag:${l}`;try{const p=new Promise(async y=>{const w=({id:b})=>{d.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(Ie.publish,w),y(d))};this.relayer.events.on(Ie.publish,w);const v=Gt(new Promise((b,E)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:u,tag:l,id:h,attestation:s?.attestation,tvf:s?.tvf}).then(b).catch($=>{this.logger.warn($,$?.message),E($)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${l}`);try{await v,this.events.removeListener(Ie.publish,w)}catch(b){this.queue.set(h,Ns(sn({},d),{attempt:1})),this.logger.warn(b,b?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:i,message:n,opts:s}}),await Gt(p,this.publishTimeout,f)}catch(p){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(p),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw p}finally{this.queue.delete(h)}}),ht(this,"on",(i,n)=>{this.events.on(i,n)}),ht(this,"once",(i,n)=>{this.events.once(i,n)}),ht(this,"off",(i,n)=>{this.events.off(i,n)}),ht(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=Fe(r,this.name),this.registerEventListeners()}get context(){return Ve(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=gu,prompt:u,tag:l,id:h,attestation:d,tvf:f}=e,p={method:Ei(An().protocol).publish,params:sn({topic:o,message:a,ttl:c,prompt:u,tag:l,attestation:d},f),id:h};Le((r=p.params)==null?void 0:r.prompt)&&((i=p.params)==null||delete i.prompt),Le((n=p.params)==null?void 0:n.tag)&&((s=p.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});const y=await this.relayer.request(p);return this.relayer.events.emit(Ie.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Ns(sn({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Ns(sn({},e),{topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(mr.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ie.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ie.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var EO=Object.defineProperty,_O=(t,e,r)=>e in t?EO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pr=(t,e,r)=>_O(t,typeof e!="symbol"?e+"":e,r);class IO{constructor(){Pr(this,"map",new Map),Pr(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),Pr(this,"get",e=>this.map.get(e)||[]),Pr(this,"exists",(e,r)=>this.get(e).includes(r)),Pr(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)}),Pr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var $O=Object.defineProperty,OO=Object.defineProperties,DO=Object.getOwnPropertyDescriptors,Ou=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,PO=Object.prototype.propertyIsEnumerable,Eo=(t,e,r)=>e in t?$O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wi=(t,e)=>{for(var r in e||(e={}))SO.call(e,r)&&Eo(t,r,e[r]);if(Ou)for(var r of Ou(e))PO.call(e,r)&&Eo(t,r,e[r]);return t},Ls=(t,e)=>OO(t,DO(e)),ae=(t,e,r)=>Eo(t,typeof e!="symbol"?e+"":e,r);class AO extends k_{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ae(this,"subscriptions",new Map),ae(this,"topicMap",new IO),ae(this,"events",new Ut.EventEmitter),ae(this,"name",pI),ae(this,"version",fI),ae(this,"pending",new Map),ae(this,"cached",[]),ae(this,"initialized",!1),ae(this,"storagePrefix",St),ae(this,"subscribeTimeout",N.toMiliseconds(N.ONE_MINUTE)),ae(this,"initialSubscribeTimeout",N.toMiliseconds(N.ONE_SECOND*15)),ae(this,"clientId"),ae(this,"batchSubscribeTopicsLimit",500),ae(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ae(this,"subscribe",async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=An(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),ae(this,"unsubscribe",async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),ae(this,"isSubscribed",i=>new Promise(n=>{n(this.topicMap.topics.includes(i))})),ae(this,"isKnownTopic",i=>new Promise(n=>{n(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(s=>s.topic===i))})),ae(this,"on",(i,n)=>{this.events.on(i,n)}),ae(this,"once",(i,n)=>{this.events.once(i,n)}),ae(this,"off",(i,n)=>{this.events.off(i,n)}),ae(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),ae(this,"start",async()=>{await this.onConnect()}),ae(this,"stop",async()=>{await this.onDisconnect()}),ae(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ae(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)}),ae(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(mr.pulse,async()=>{await this.checkPending()}),this.events.on(Ye.created,async i=>{const n=Ye.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(Ye.deleted,async i=>{const n=Ye.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=Fe(r,this.name),this.clientId=""}get context(){return Ve(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,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=An(i);await this.restartToComplete({topic:e,id:r,relay:n}),await this.rpcUnsubscribe(e,r,n);const s=te("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n;(!i||i?.transportType===de.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const s={method:Ei(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===de.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(l=>this.logger.warn(l))},N.toMiliseconds(N.ONE_SECOND)),a;const c=new Promise(async l=>{const h=d=>{d.topic===e&&(this.events.removeListener(Ye.created,h),l(d.id))};this.events.on(Ye.created,h);try{const d=await Gt(new Promise((f,p)=>{this.relayer.request(s).catch(y=>{this.logger.warn(y,y?.message),p(y)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Ye.created,h),l(d)}catch{}}),u=await Gt(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ie.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Ei(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Gt(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ie.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Ei(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Gt(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ie.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Ei(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,Ls(wi({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,wi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,wi({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ye.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=L("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Ye.deleted,Ls(wi({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ye.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(Ye.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=L("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>Ls(wi({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await Kv(N.toMiliseconds(N.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=L("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 $t(e+await this.getClientId())}}var xO=Object.defineProperty,Du=Object.getOwnPropertySymbols,CO=Object.prototype.hasOwnProperty,RO=Object.prototype.propertyIsEnumerable,_o=(t,e,r)=>e in t?xO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Su=(t,e)=>{for(var r in e||(e={}))CO.call(e,r)&&_o(t,r,e[r]);if(Du)for(var r of Du(e))RO.call(e,r)&&_o(t,r,e[r]);return t},Z=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);class TO extends U_{constructor(e){super(e),Z(this,"protocol","wc"),Z(this,"version",2),Z(this,"core"),Z(this,"logger"),Z(this,"events",new Ut.EventEmitter),Z(this,"provider"),Z(this,"messages"),Z(this,"subscriber"),Z(this,"publisher"),Z(this,"name",cI),Z(this,"transportExplicitlyClosed",!1),Z(this,"initialized",!1),Z(this,"connectionAttemptInProgress",!1),Z(this,"relayUrl"),Z(this,"projectId"),Z(this,"packageName"),Z(this,"bundleId"),Z(this,"hasExperiencedNetworkDisruption",!1),Z(this,"pingTimeout"),Z(this,"heartBeatTimeout",N.toMiliseconds(N.THIRTY_SECONDS+N.FIVE_SECONDS)),Z(this,"reconnectTimeout"),Z(this,"connectPromise"),Z(this,"reconnectInProgress",!1),Z(this,"requestsInFlight",[]),Z(this,"connectTimeout",N.toMiliseconds(N.ONE_SECOND*15)),Z(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||cr().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=r.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}}),Z(this,"resetPingTimeout",()=>{Sn()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n,s;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(s=(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null?void 0:n.terminate)==null||s.call(n)}catch(o){this.logger.warn(o,o?.message)}},this.heartBeatTimeout))}),Z(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),Z(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Ie.connect)}),Z(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Z(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(Ie.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Z(this,"registerProviderListeners",()=>{this.provider.on(tt.payload,this.onPayloadHandler),this.provider.on(tt.connect,this.onConnectHandler),this.provider.on(tt.disconnect,this.onDisconnectHandler),this.provider.on(tt.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Fe(e.logger,this.name):Bi(Mn({level:e.logger||aI})),this.messages=new fO(this.logger,e.core),this.subscriber=new AO(this,this.logger),this.publisher=new vO(this,this.logger),this.relayUrl=e?.relayUrl||xd,this.projectId=e.projectId,Av()?this.packageName=vc():xv()&&(this.bundleId=vc()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return Ve(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:de.relay},vn.outbound)}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const u=l=>{l.topic===e&&(this.subscriber.off(Ye.created,u),c())};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(Ye.created,u)}),new Promise(async(l,h)=>{a=await this.subscriber.subscribe(e,Su({internal:{throwOnFailedPublish:o}},r)).catch(d=>{o&&h(d)})||a,l()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Gt(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){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}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(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}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 cu())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=me(N.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ie.message,e),await this.recordMessageEvent(e,vn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(tt.disconnect,s),await Gt(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(tt.disconnect,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(tt.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(tt.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,N.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(Sn())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new ot(new cv(Lv({sdkVersion:yo,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,r){const{topic:i,message:n}=e;await this.messages.set(i,n,r)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isKnownTopic(r))return this.logger.warn(`Ignoring message for unknown topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Vo(e)){if(!e.method.endsWith(uI))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:de.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Su({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Vn(e)&&this.events.emit(Ie.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,vn.inbound),this.events.emit(Ie.message,e))}async acknowledgePayload(e){const r=Hn(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(tt.payload,this.onPayloadHandler),this.provider.off(tt.connect,this.onConnectHandler),this.provider.off(tt.disconnect,this.onDisconnectHandler),this.provider.off(tt.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await cu();i_(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(mr.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&o_())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(r){this.logger.warn(r,r?.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Ie.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},N.toMiliseconds(lI)))))}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function NO(){}function Pu(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function Au(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function xu(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const LO="[object RegExp]",jO="[object String]",BO="[object Number]",MO="[object Boolean]",Cu="[object Arguments]",FO="[object Symbol]",UO="[object Date]",qO="[object Map]",kO="[object Set]",zO="[object Array]",HO="[object Function]",KO="[object ArrayBuffer]",js="[object Object]",VO="[object Error]",WO="[object DataView]",GO="[object Uint8Array]",YO="[object Uint8ClampedArray]",JO="[object Uint16Array]",ZO="[object Uint32Array]",QO="[object BigUint64Array]",XO="[object Int8Array]",e2="[object Int16Array]",t2="[object Int32Array]",r2="[object BigInt64Array]",i2="[object Float32Array]",n2="[object Float64Array]";function s2(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function o2(t,e,r){return _i(t,e,void 0,void 0,void 0,void 0,r)}function _i(t,e,r,i,n,s,o){const a=o(t,e,r,i,n,s);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return Si(t,e,s,o)}return Si(t,e,s,o)}function Si(t,e,r,i){if(Object.is(t,e))return!0;let n=xu(t),s=xu(e);if(n===Cu&&(n=js),s===Cu&&(s=js),n!==s)return!1;switch(n){case jO:return t.toString()===e.toString();case BO:{const c=t.valueOf(),u=e.valueOf();return s2(c,u)}case MO:case UO:case FO:return Object.is(t.valueOf(),e.valueOf());case LO:return t.source===e.source&&t.flags===e.flags;case HO:return t===e}r=r??new Map;const o=r.get(t),a=r.get(e);if(o!=null&&a!=null)return o===e;r.set(t,e),r.set(e,t);try{switch(n){case qO:{if(t.size!==e.size)return!1;for(const[c,u]of t.entries())if(!e.has(c)||!_i(u,e.get(c),c,t,e,r,i))return!1;return!0}case kO:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),u=Array.from(e.values());for(let l=0;l<c.length;l++){const h=c[l],d=u.findIndex(f=>_i(h,f,void 0,t,e,r,i));if(d===-1)return!1;u.splice(d,1)}return!0}case zO:case GO:case YO:case JO:case ZO:case QO:case XO:case e2:case t2:case r2:case i2:case n2:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!_i(t[c],e[c],c,t,e,r,i))return!1;return!0}case KO:return t.byteLength!==e.byteLength?!1:Si(new Uint8Array(t),new Uint8Array(e),r,i);case WO:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Si(new Uint8Array(t),new Uint8Array(e),r,i);case VO:return t.name===e.name&&t.message===e.message;case js:{if(!(Si(t.constructor,e.constructor,r,i)||Pu(t)&&Pu(e)))return!1;const c=[...Object.keys(t),...Au(t)],u=[...Object.keys(e),...Au(e)];if(c.length!==u.length)return!1;for(let l=0;l<c.length;l++){const h=c[l],d=t[h];if(!Object.hasOwn(e,h))return!1;const f=e[h];if(!_i(d,f,h,t,e,r,i))return!1}return!0}default:return!1}}finally{r.delete(t),r.delete(e)}}function a2(t,e){return o2(t,e,NO)}var c2=Object.defineProperty,Ru=Object.getOwnPropertySymbols,u2=Object.prototype.hasOwnProperty,l2=Object.prototype.propertyIsEnumerable,Io=(t,e,r)=>e in t?c2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tu=(t,e)=>{for(var r in e||(e={}))u2.call(e,r)&&Io(t,r,e[r]);if(Ru)for(var r of Ru(e))l2.call(e,r)&&Io(t,r,e[r]);return t},qe=(t,e,r)=>Io(t,typeof e!="symbol"?e+"":e,r);class br extends q_{constructor(e,r,i,n=St,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,qe(this,"map",new Map),qe(this,"version",hI),qe(this,"cached",[]),qe(this,"initialized",!1),qe(this,"getKey"),qe(this,"storagePrefix",St),qe(this,"recentlyDeleted",[]),qe(this,"recentlyDeletedLimit",200),qe(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Le(o)?this.map.set(this.getKey(o),o):NE(o)?this.map.set(o.id,o):LE(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),qe(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),qe(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),qe(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>a2(a[c],o[c]))):this.values)),qe(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Tu(Tu({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),qe(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Fe(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Ve(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 r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=L("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=L("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=L("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var h2=Object.defineProperty,d2=(t,e,r)=>e in t?h2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V=(t,e,r)=>d2(t,typeof e!="symbol"?e+"":e,r);class p2{constructor(e,r){this.core=e,this.logger=r,V(this,"name",gI),V(this,"version",yI),V(this,"events",new Yo),V(this,"pairings"),V(this,"initialized",!1),V(this,"storagePrefix",St),V(this,"ignoredPayloadTypes",[Mt]),V(this,"registeredMethods",[]),V(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),V(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),V(this,"create",async i=>{this.isInitialized();const n=fo(),s=await this.core.crypto.setSymKey(n),o=me(N.FIVE_MINUTES),a={protocol:Ad},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=Xc({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(or.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}}),V(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[vt.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:u}=Qc(i.uri);n.props.properties.topic=s,n.addTrace(vt.pairing_uri_validation_success),n.addTrace(vt.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),n.addTrace(vt.existing_pairing),l.active)throw n.setError(Nt.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(vt.pairing_not_expired)}const h=c||me(N.FIVE_MINUTES),d={topic:s,relay:a,expiry:h,active:!1,methods:u};this.core.expirer.set(s,h),await this.pairings.set(s,d),n.addTrace(vt.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(or.create,d),n.addTrace(vt.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(vt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Nt.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(f){throw n.setError(Nt.subscribe_pairing_topic_failure),f}return n.addTrace(vt.subscribe_pairing_topic_success),d}),V(this,"activate",async({topic:i})=>{this.isInitialized();const n=me(N.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),V(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=rr();this.events.once(X("pairing_ping",s),({error:u})=>{u?c(u):a()}),await o()}}),V(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),V(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),V(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),V(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",te("USER_DISCONNECTED")),await this.deletePairing(n))}),V(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return Xc({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),V(this,"sendRequest",async(i,n,s)=>{const o=Wt(n,s),a=await this.core.crypto.encode(i,o),c=yi[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),V(this,"sendResult",async(i,n,s)=>{const o=Hn(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,u=yi[c].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)}),V(this,"sendError",async(i,n,s)=>{const o=Kn(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,u=yi[c]?yi[c].res:yi.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)}),V(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,te("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),V(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>Kt(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),V(this,"onRelayEventRequest",async i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(n,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(n,s);default:return await this.onUnknownRpcMethodRequest(n,s)}}),V(this,"onRelayEventResponse",async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}}),V(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(or.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),V(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{_t(n)?this.events.emit(X("pairing_ping",s),{}):nt(n)&&this.events.emit(X("pairing_ping",s),{error:n.error})},500)}),V(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(or.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),V(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=te("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}}),V(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(te("WC_METHOD_UNSUPPORTED",i))}),V(this,"isValidPair",(i,n)=>{var s;if(!ze(i)){const{message:a}=L("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Nt.malformed_pairing_uri),new Error(a)}if(!TE(i.uri)){const{message:a}=L("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Nt.malformed_pairing_uri),new Error(a)}const o=Qc(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=L("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Nt.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=L("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Nt.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&N.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(Nt.pairing_expired);const{message:a}=L("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),V(this,"isValidPing",async i=>{if(!ze(i)){const{message:s}=L("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),V(this,"isValidDisconnect",async i=>{if(!ze(i)){const{message:s}=L("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),V(this,"isValidPairingTopic",async i=>{if(!ye(i,!1)){const{message:n}=L("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=L("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Kt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=L("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=Fe(r,this.name),this.pairings=new br(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ve(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ie.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(this.pairings.keys.includes(r)&&n!==de.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const s=await this.core.crypto.decode(r,i);Vo(s)?(this.core.history.set(r,s),await this.onRelayEventRequest({topic:r,payload:s})):Vn(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id)),await this.core.relayer.messages.ack(r,i)}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(it.expired,async e=>{const{topic:r}=Kh(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(or.expire,{topic:r}))})}}var f2=Object.defineProperty,g2=(t,e,r)=>e in t?f2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ae=(t,e,r)=>g2(t,typeof e!="symbol"?e+"":e,r);class y2 extends B_{constructor(e,r){super(e,r),this.core=e,this.logger=r,Ae(this,"records",new Map),Ae(this,"events",new Ut.EventEmitter),Ae(this,"name",mI),Ae(this,"version",wI),Ae(this,"cached",[]),Ae(this,"initialized",!1),Ae(this,"storagePrefix",St),Ae(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ae(this,"set",(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:me(N.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(ut.created,o)}),Ae(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=nt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(ut.updated,n))}),Ae(this,"get",async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n))),Ae(this,"delete",(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(ut.deleted,s)}}),this.persist()}),Ae(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),Ae(this,"on",(i,n)=>{this.events.on(i,n)}),Ae(this,"once",(i,n)=>{this.events.once(i,n)}),Ae(this,"off",(i,n)=>{this.events.off(i,n)}),Ae(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Fe(r,this.name)}get context(){return Ve(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:Wt(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=L("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(ut.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=L("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(ut.created,e=>{const r=ut.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(ut.updated,e=>{const r=ut.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(ut.deleted,e=>{const r=ut.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(mr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{N.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(ut.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var m2=Object.defineProperty,w2=(t,e,r)=>e in t?m2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ne=(t,e,r)=>w2(t,typeof e!="symbol"?e+"":e,r);class b2 extends z_{constructor(e,r){super(e,r),this.core=e,this.logger=r,Ne(this,"expirations",new Map),Ne(this,"events",new Ut.EventEmitter),Ne(this,"name",bI),Ne(this,"version",vI),Ne(this,"cached",[]),Ne(this,"initialized",!1),Ne(this,"storagePrefix",St),Ne(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ne(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),Ne(this,"set",(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(it.created,{target:s,expiration:o})}),Ne(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),Ne(this,"del",i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(it.deleted,{target:n,expiration:s})}}),Ne(this,"on",(i,n)=>{this.events.on(i,n)}),Ne(this,"once",(i,n)=>{this.events.once(i,n)}),Ne(this,"off",(i,n)=>{this.events.off(i,n)}),Ne(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Fe(r,this.name)}get context(){return Ve(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return jv(e);if(typeof e=="number")return Bv(e);const{message:r}=L("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(it.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=L("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=L("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;N.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(it.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(mr.pulse,()=>this.checkExpirations()),this.events.on(it.created,e=>{const r=it.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(it.expired,e=>{const r=it.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(it.deleted,e=>{const r=it.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}}var v2=Object.defineProperty,E2=(t,e,r)=>e in t?v2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ge=(t,e,r)=>E2(t,typeof e!="symbol"?e+"":e,r);class _2 extends H_{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,ge(this,"name",EI),ge(this,"abortController"),ge(this,"isDevEnv"),ge(this,"verifyUrlV3",II),ge(this,"storagePrefix",St),ge(this,"version",Pd),ge(this,"publicKey"),ge(this,"fetchPromise"),ge(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&N.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ge(this,"register",async n=>{if(!ai()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const u=dr(),l=this.startAbortTimer(N.ONE_SECOND*5),h=await new Promise((d,f)=>{const p=()=>{window.removeEventListener("message",w),u.body.removeChild(y),f("attestation aborted")};this.abortController.signal.addEventListener("abort",p);const y=u.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",p,{signal:this.abortController.signal});const w=v=>{if(v.data&&typeof v.data=="string")try{const b=JSON.parse(v.data);if(b.type==="verify_attestation"){if(Qs(b.attestation).payload.id!==o)return;clearInterval(l),u.body.removeChild(y),this.abortController.signal.removeEventListener("abort",p),window.removeEventListener("message",w),d(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};u.body.appendChild(y),window.addEventListener("message",w,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(u){this.logger.warn(u)}return""}),ge(this,"resolve",async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Qs(s).payload.id!==a)return;const u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),ge(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(N.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),ge(this,"getVerifyUrl",n=>{let s=n||Di;return $I.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Di}`),s=Di),s}),ge(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(N.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}}),ge(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),ge(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ge(this,"isValidJwtAttestation",async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),ge(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ge(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n}),ge(this,"validateAttestation",(n,s)=>{const o=dE(n,s.publicKey),a={hasExpired:N.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Fe(r,this.name),this.abortController=new AbortController,this.isDevEnv=Jo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Ve(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),N.toMiliseconds(e))}}var I2=Object.defineProperty,$2=(t,e,r)=>e in t?I2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nu=(t,e,r)=>$2(t,typeof e!="symbol"?e+"":e,r);class O2 extends K_{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,Nu(this,"context",OI),Nu(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${DI}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})}),this.logger=Fe(r,this.context)}}var D2=Object.defineProperty,Lu=Object.getOwnPropertySymbols,S2=Object.prototype.hasOwnProperty,P2=Object.prototype.propertyIsEnumerable,$o=(t,e,r)=>e in t?D2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bi=(t,e)=>{for(var r in e||(e={}))S2.call(e,r)&&$o(t,r,e[r]);if(Lu)for(var r of Lu(e))P2.call(e,r)&&$o(t,r,e[r]);return t},be=(t,e,r)=>$o(t,typeof e!="symbol"?e+"":e,r);class A2 extends V_{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,be(this,"context",PI),be(this,"storagePrefix",St),be(this,"storageVersion",SI),be(this,"events",new Map),be(this,"shouldPersist",!1),be(this,"init",async()=>{if(!Jo())try{const n={eventId:_c(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:zh(this.core.relayer.protocol,this.core.relayer.version,yo)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),be(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,u=_c(),l=this.core.projectId||"",h=Date.now(),d=bi({eventId:u,timestamp:h,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,d),this.shouldPersist=!0),d}),be(this,"getEvent",n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return bi(bi({},a),this.setMethods(a.eventId))}),be(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),be(this,"setEventListeners",()=>{this.core.heartbeat.on(mr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{N.fromMiliseconds(Date.now())-N.fromMiliseconds(n.timestamp)>AI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),be(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),be(this,"addTrace",(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)}),be(this,"setError",(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)}),be(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),be(this,"restore",async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,bi(bi({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),be(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),be(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${xI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${yo}${s}`,{method:"POST",body:JSON.stringify(n)})}),be(this,"getAppDomain",()=>kh().url),this.logger=Fe(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var x2=Object.defineProperty,ju=Object.getOwnPropertySymbols,C2=Object.prototype.hasOwnProperty,R2=Object.prototype.propertyIsEnumerable,Oo=(t,e,r)=>e in t?x2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bu=(t,e)=>{for(var r in e||(e={}))C2.call(e,r)&&Oo(t,r,e[r]);if(ju)for(var r of ju(e))R2.call(e,r)&&Oo(t,r,e[r]);return t},le=(t,e,r)=>Oo(t,typeof e!="symbol"?e+"":e,r);let T2=class kd extends T_{constructor(e){var r;super(e),le(this,"protocol",Sd),le(this,"version",Pd),le(this,"name",Cn),le(this,"relayUrl"),le(this,"projectId"),le(this,"customStoragePrefix"),le(this,"events",new Ut.EventEmitter),le(this,"logger"),le(this,"heartbeat"),le(this,"relayer"),le(this,"crypto"),le(this,"storage"),le(this,"history"),le(this,"expirer"),le(this,"pairing"),le(this,"verify"),le(this,"echoClient"),le(this,"linkModeSupportedApps"),le(this,"eventClient"),le(this,"initialized",!1),le(this,"logChunkController"),le(this,"on",(a,c)=>this.events.on(a,c)),le(this,"once",(a,c)=>this.events.once(a,c)),le(this,"off",(a,c)=>this.events.off(a,c)),le(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),le(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:u})=>{if(!a||!c)return;const l={topic:a,message:c,publishedAt:Date.now(),transportType:de.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:u})});const i=this.getGlobalCore(e?.customStoragePrefix);if(i)try{return this.customStoragePrefix=i.customStoragePrefix,this.logger=i.logger,this.heartbeat=i.heartbeat,this.crypto=i.crypto,this.history=i.history,this.expirer=i.expirer,this.storage=i.storage,this.relayer=i.relayer,this.pairing=i.pairing,this.verify=i.verify,this.echoClient=i.echoClient,this.linkModeSupportedApps=i.linkModeSupportedApps,this.eventClient=i.eventClient,this.initialized=i.initialized,this.logChunkController=i.logChunkController,i}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||xd,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const n=Mn({level:typeof e?.logger=="string"&&e.logger?e.logger:Q_.logger,name:Cn}),{logger:s,chunkLoggerController:o}=Wf({opts:n,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=o,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Fe(s,this.name),this.heartbeat=new df,this.crypto=new oO(this,this.logger,e?.keychain),this.history=new y2(this,this.logger),this.expirer=new b2(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new x_(Bu(Bu({},X_),e?.storageOptions)),this.relayer=new TO({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new p2(this,this.logger),this.verify=new _2(this,this.logger,this.storage),this.echoClient=new O2(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new A2(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const r=new kd(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(dI,i),r}get context(){return Ve(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(yu,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(yu)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${e}`,i=`${r}_count`;return globalThis[i]=(globalThis[i]||0)+1,globalThis[i]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`),globalThis[r]}catch(r){console.warn("Failed to get global WalletConnect core",r);return}}setGlobalCore(e){var r;try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${((r=e.opts)==null?void 0:r.customStoragePrefix)||""}`;globalThis[i]=e}catch(i){console.warn("Failed to set global WalletConnect core",i)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&Z_.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const N2=T2,zd="wc",Hd=2,Kd="client",na=`${zd}@${Hd}:${Kd}:`,Bs={name:Kd,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Mu="WALLETCONNECT_DEEPLINK_CHOICE",L2="proposal",Fu="Proposal expired",j2="session",Ar=N.SEVEN_DAYS,B2="engine",ve={wc_sessionPropose:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1104},res:{ttl:N.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1106},res:{ttl:N.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1112},res:{ttl:N.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1114},res:{ttl:N.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:N.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:N.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1119}}},Ms={min:N.FIVE_MINUTES,max:N.SEVEN_DAYS},bt={idle:"IDLE",active:"ACTIVE"},Uu={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},M2="request",F2=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],U2="wc",q2="auth",k2="authKeys",z2="pairingTopics",H2="requests",rs=`${U2}@${1.5}:${q2}:`,En=`${rs}:PUB_KEY`;var K2=Object.defineProperty,V2=Object.defineProperties,W2=Object.getOwnPropertyDescriptors,qu=Object.getOwnPropertySymbols,G2=Object.prototype.hasOwnProperty,Y2=Object.prototype.propertyIsEnumerable,Do=(t,e,r)=>e in t?K2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ce=(t,e)=>{for(var r in e||(e={}))G2.call(e,r)&&Do(t,r,e[r]);if(qu)for(var r of qu(e))Y2.call(e,r)&&Do(t,r,e[r]);return t},Be=(t,e)=>V2(t,W2(e)),T=(t,e,r)=>Do(t,typeof e!="symbol"?e+"":e,r);class J2 extends J_{constructor(e){super(e),T(this,"name",B2),T(this,"events",new Yo),T(this,"initialized",!1),T(this,"requestQueue",{state:bt.idle,queue:[]}),T(this,"sessionRequestQueue",{state:bt.idle,queue:[]}),T(this,"requestQueueDelay",N.ONE_SECOND),T(this,"expectedPairingMethodMap",new Map),T(this,"recentlyDeletedMap",new Map),T(this,"recentlyDeletedLimit",200),T(this,"relayMessageCache",[]),T(this,"pendingSessions",new Map),T(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(ve)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay)))}),T(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Be(ce({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i),i.optionalNamespaces=PE(i.requiredNamespaces,i.optionalNamespaces),i.requiredNamespaces={};const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:u}=i;let l=n,h,d=!1;try{if(l){const P=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=P.active}}catch(P){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),P}if(!l||!d){const{topic:P,uri:S}=await this.client.core.pairing.create();l=P,h=S}if(!l){const{message:P}=L("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(P)}const f=await this.client.core.crypto.generateKeyPair(),p=ve.wc_sessionPropose.req.ttl||N.FIVE_MINUTES,y=me(p),w=Be(ce(ce({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:Ad}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:l},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:Et()}),v=X("session_connect",w.id),{reject:b,resolve:E,done:$}=rr(p,Fu),A=({id:P})=>{P===w.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(w.id),this.events.emit(v,{error:{message:Fu,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(v,({error:P,session:S})=>{this.client.events.off("proposal_expire",A),P?b(P):S&&E(S)}),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:h,approval:$}}),T(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),T(this,"approve",async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[lt.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(er.no_internet_connection),O}try{await this.isValidProposalId(r?.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(er.proposal_not_found),O}try{await this.isValidApprove(r)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(er.session_approve_namespace_validation_failure),O}const{id:a,relayProtocol:c,namespaces:u,sessionProperties:l,scopedProperties:h,sessionConfig:d}=r,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:p,proposer:y,requiredNamespaces:w,optionalNamespaces:v}=f;let b=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:p});b||(b=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:lt.session_approve_started,properties:{topic:p,trace:[lt.session_approve_started,lt.session_namespaces_validation_success]}}));const E=await this.client.core.crypto.generateKeyPair(),$=y.publicKey,A=await this.client.core.crypto.generateSharedKey(E,$),P=ce(ce(ce({relay:{protocol:c??"irn"},namespaces:u,controller:{publicKey:E,metadata:this.client.metadata},expiry:me(Ar)},l&&{sessionProperties:l}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),S=de.relay;b.addTrace(lt.subscribing_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:S})}catch(O){throw b.setError(er.subscribe_session_topic_failure),O}b.addTrace(lt.subscribe_session_topic_success);const C=Be(ce({},P),{topic:A,requiredNamespaces:w,optionalNamespaces:v,pairingTopic:p,acknowledged:!1,self:P.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:E,transportType:de.relay});await this.client.session.set(A,C),b.addTrace(lt.store_session);try{b.addTrace(lt.publishing_session_settle),await this.sendRequest({topic:A,method:"wc_sessionSettle",params:P,throwOnFailedPublish:!0}).catch(O=>{throw b?.setError(er.session_settle_publish_failure),O}),b.addTrace(lt.session_settle_publish_success),b.addTrace(lt.publishing_session_approve),await this.sendResult({id:a,topic:p,result:{relay:{protocol:c??"irn"},responderPublicKey:E},throwOnFailedPublish:!0}).catch(O=>{throw b?.setError(er.session_approve_publish_failure),O}),b.addTrace(lt.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(A,te("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(A),O}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:y.metadata}),await this.client.proposal.delete(a,te("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(A,me(Ar)),{topic:A,acknowledged:()=>Promise.resolve(this.client.session.get(A))}}),T(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:ve.wc_sessionPropose.reject}),await this.client.proposal.delete(i,te("USER_DISCONNECTED")))}),T(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=rr(),c=Et(),u=cr().toString(),l=this.client.session.get(i).namespaces;return this.events.once(X("session_update",c),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:u}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:l}),a(h)}),{acknowledged:s}}),T(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=Et(),{done:s,resolve:o,reject:a}=rr();return this.events.once(X("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,me(Ar)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),T(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(v){throw this.client.logger.error("request() -> isValidRequest() failed"),v}const{chainId:i,request:n,topic:s,expiry:o=ve.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===de.relay&&await this.confirmOnlineStateOrThrow();const c=Et(),u=cr().toString(),{done:l,resolve:h,reject:d}=rr(o,"Request expired. Please try again.");this.events.once(X("session_request",c),({error:v,result:b})=>{v?d(v):h(b)});const f="wc_sessionRequest",p=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(p)return await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:f,params:{request:Be(ce({},n),{expiryTimestamp:me(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:p}).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await l();const y={request:Be(ce({},n),{expiryTimestamp:me(o)}),chainId:i},w=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async v=>{await this.sendRequest(ce({clientRpcId:c,relayRpcId:u,topic:s,method:f,params:y,expiry:o,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,y)})).catch(b=>d(b)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),v()}),new Promise(async v=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const E=await qv(this.client.core.storage,Mu);await Mv({id:c,topic:s,wcDeepLink:E})}v()}),l()]).then(v=>v[2])}),T(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n,o=this.client.session.get(i);o.transportType===de.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);_t(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):nt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),T(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=Et(),s=cr().toString(),{done:o,resolve:a,reject:c}=rr();this.events.once(X("session_ping",n),({error:u})=>{u?c(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(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:i}))}),T(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=cr().toString(),a=Et();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),T(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:te("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=L("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),T(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>CE(i,r)))),T(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),T(this,"authenticate",async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?de.link_mode:de.relay;o===de.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:u,domain:l,nonce:h,type:d,exp:f,nbf:p,methods:y=[],expiry:w}=r,v=[...r.resources||[]],{topic:b,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:E}});const $=await this.client.core.crypto.generateKeyPair(),A=mn($);if(await Promise.all([this.client.auth.authKeys.set(En,{responseTopic:A,publicKey:$}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:b})]),await this.client.core.relayer.subscribe(A,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),y.length>0){const{namespace:I}=Jr(a[0]);let x=T0(I,"request",y);yn(v)&&(x=L0(x,v.pop())),v.push(x)}const P=w&&w>ve.wc_sessionAuthenticate.req.ttl?w:ve.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:d??"caip122",chains:a,statement:c,aud:u,domain:l,version:"1",nonce:h,iat:new Date().toISOString(),exp:f,nbf:p,resources:v},requester:{publicKey:$,metadata:this.client.metadata},expiryTimestamp:me(P)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},O={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:$,metadata:this.client.metadata},expiryTimestamp:me(ve.wc_sessionPropose.req.ttl),id:Et()},{done:q,resolve:B,reject:j}=rr(P,"Request expired"),k=Et(),R=X("session_connect",O.id),g=X("session_request",k),m=async({error:I,session:x})=>{this.events.off(g,_),I?j(I):x&&B({session:x})},_=async I=>{var x,M,U;if(await this.deletePendingAuthRequest(k,{message:"fulfilled",code:0}),I.error){const Y=te("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return I.error.code===Y.code?void 0:(this.events.off(R,m),j(I.error.message))}await this.deleteProposal(O.id),this.events.off(R,m);const{cacaos:z,responder:F}=I.result,H=[],G=[];for(const Y of z){await xc({cacao:Y,projectId:this.client.core.projectId})||(this.client.logger.error(Y,"Signature verification failed"),j(te("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Te}=Y,De=yn(Te.resources),je=[no(Te.iss)],et=Pn(Te.iss);if(De){const Pt=Cc(De),Er=Rc(De);H.push(...Pt),je.push(...Er)}for(const Pt of je)G.push(`${Pt}:${et}`)}const ue=await this.client.core.crypto.generateSharedKey($,F.publicKey);let ee;H.length>0&&(ee={topic:ue,acknowledged:!0,self:{publicKey:$,metadata:this.client.metadata},peer:F,controller:F.publicKey,expiry:me(Ar),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:iu([...new Set(H)],[...new Set(G)]),transportType:o},await this.client.core.relayer.subscribe(ue,{transportType:o}),await this.client.session.set(ue,ee),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:F.metadata}),ee=this.client.session.get(ue)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(M=F.metadata.redirect)!=null&&M.linkMode&&(U=F.metadata.redirect)!=null&&U.universal&&i&&(this.client.core.addLinkModeSupportedApp(F.metadata.redirect.universal),this.client.session.update(ue,{transportType:de.link_mode})),B({auths:z,session:ee})};this.events.once(R,m),this.events.once(g,_);let D;try{if(s){const I=Wt("wc_sessionAuthenticate",S,k);this.client.core.history.set(b,I);const x=await this.client.core.crypto.encode("",I,{type:Vi,encoding:Vt});D=rn(i,b,x)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:S,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:k}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:O,expiry:ve.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:O.id})])}catch(I){throw this.events.off(R,m),this.events.off(g,_),I}return await this.setProposal(O.id,O),await this.setAuthRequest(k,{request:Be(ce({},S),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:D??E,response:q}}),T(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[tr.authenticated_session_approve_started]}});try{this.isInitialized()}catch(w){throw s.setError(mi.no_internet_connection),w}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(mi.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||de.relay;a===de.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),l=mn(c),h={type:Mt,receiverPublicKey:c,senderPublicKey:u},d=[],f=[];for(const w of n){if(!await xc({cacao:w,projectId:this.client.core.projectId})){s.setError(mi.invalid_cacao);const A=te("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:A,encodeOpts:h}),new Error(A.message)}s.addTrace(tr.cacaos_verified);const{p:v}=w,b=yn(v.resources),E=[no(v.iss)],$=Pn(v.iss);if(b){const A=Cc(b),P=Rc(b);d.push(...A),E.push(...P)}for(const A of E)f.push(`${A}:${$}`)}const p=await this.client.core.crypto.generateSharedKey(u,c);s.addTrace(tr.create_authenticated_session_topic);let y;if(d?.length>0){y={topic:p,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:me(Ar),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:iu([...new Set(d)],[...new Set(f)]),transportType:a},s.addTrace(tr.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:a})}catch(w){throw s.setError(mi.subscribe_authenticated_session_topic_failure),w}s.addTrace(tr.subscribe_authenticated_session_topic_success),await this.client.session.set(p,y),s.addTrace(tr.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(tr.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(w){throw s.setError(mi.authenticated_session_approve_publish_failure),w}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:y}}),T(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===de.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=mn(o),u={type:Mt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:u,rpcOpts:ve.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,te("USER_DISCONNECTED"))}),T(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return ed(i,n)}),T(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),T(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),T(this,"deleteSession",async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,te("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Mu).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,te("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=bt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),T(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(er.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,te("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),T(this,"deletePendingSessionRequest",async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=bt.idle,this.client.events.emit("session_request_expire",{id:r}))}),T(this,"deletePendingAuthRequest",async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])}),T(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),T(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,me(ve.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),T(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=de.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})}),T(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||me(ve.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})}),T(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:u,appLink:l,tvf:h}=r,d=Wt(n,s,c);let f;const p=!!l;try{const v=p?Vt:pt;f=await this.client.core.crypto.encode(i,d,{encoding:v})}catch(v){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),v}let y;if(F2.includes(n)){const v=$t(JSON.stringify(d)),b=$t(f);y=await this.client.core.verify.register({id:b,decryptedId:v})}const w=ve[n].req;if(w.attestation=y,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(i,d),p){const v=rn(l,i,f);await global.Linking.openURL(v,this.client.name)}else{const v=ve[n].req;o&&(v.ttl=o),a&&(v.id=a),v.tvf=Be(ce({},h),{correlationId:d.id}),u?(v.internal=Be(ce({},v.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,f,v)):this.client.core.relayer.publish(i,f,v).catch(b=>this.client.logger.error(b))}return d.id}),T(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,u=Hn(i,s);let l;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=h?Vt:pt;l=await this.client.core.crypto.encode(n,u,Be(ce({},a||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),p}let d,f;try{d=await this.client.core.history.get(n,i);const p=d.request;try{this.shouldSetTVF(p.method,p.params)&&(f=this.getTVFParams(i,p.params,s))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(p){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),p}if(h){const p=rn(c,n,l);await global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,y=ve[p].res;y.tvf=Be(ce({},f),{correlationId:i}),o?(y.internal=Be(ce({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,l,y)):this.client.core.relayer.publish(n,l,y).catch(w=>this.client.logger.error(w))}await this.client.core.history.resolve(u)}),T(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,u=Kn(i,s);let l;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=h?Vt:pt;l=await this.client.core.crypto.encode(n,u,Be(ce({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),f}let d;try{d=await this.client.core.history.get(n,i)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),f}if(h){const f=rn(c,n,l);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,p=a||ve[f].res;this.client.core.relayer.publish(n,l,p)}await this.client.core.history.resolve(u)}),T(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Kt(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Kt(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),T(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),T(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),T(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===bt.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=bt.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=bt.idle}),T(this,"processRequest",async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),T(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),T(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=L("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),T(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),T(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const u=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(Nt.proposal_listener_not_found)),this.isValidConnect(ce({},n.params));const l=a.expiryTimestamp||me(ve.wc_sessionPropose.req.ttl),h=ce({id:c,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(c,h);const d=await this.getVerifyContext({attestationId:s,hash:$t(JSON.stringify(n)),encryptedId:o,metadata:h.proposer.metadata});u?.addTrace(vt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:d})}catch(u){await this.sendError({id:c,topic:i,error:u,rpcOpts:ve.wc_sessionPropose.autoReject}),this.client.logger.error(u)}}),T(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(_t(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const l=await this.client.core.crypto.generateSharedKey(c,u);this.pendingSessions.set(s,{sessionTopic:l,pairingTopic:r,proposalId:s,publicKey:c});const h=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:r})}else if(nt(i)){await this.client.proposal.delete(s,te("USER_DISCONNECTED"));const o=X("session_connect",s);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),T(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:u,sessionProperties:l,scopedProperties:h,sessionConfig:d}=i.params,f=[...this.pendingSessions.values()].find(w=>w.sessionTopic===r);if(!f)return this.client.logger.error(`Pending session not found for topic ${r}`);const p=this.client.proposal.get(f.proposalId),y=Be(ce(ce(ce({topic:r,relay:o,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),{transportType:de.relay});await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit(X("session_connect",f.proposalId),{session:y}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(y),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),T(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;_t(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(X("session_approve",n),{})):nt(i)&&(await this.client.session.delete(r,te("USER_DISCONNECTED")),this.events.emit(X("session_approve",n),{error:i.error}))}),T(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=gi.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:te("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ce({topic:r},n));try{gi.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw gi.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),T(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),T(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=X("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_t(i)?this.events.emit(X("session_update",n),{}):nt(i)&&this.events.emit(X("session_update",n),{error:i.error})}),T(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,me(Ar)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),T(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=X("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_t(i)?this.events.emit(X("session_extend",n),{}):nt(i)&&this.events.emit(X("session_extend",n),{error:i.error})}),T(this,"onSessionPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),T(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=X("session_ping",n);setTimeout(()=>{if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners 2176`);_t(i)?this.events.emit(X("session_ping",n),{}):nt(i)&&this.events.emit(X("session_ping",n),{error:i.error})},500)}),T(this,"onSessionDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ie.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:te("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),T(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:u,transportType:l}=r,{id:h,params:d}=a;try{await this.isValidRequest(ce({topic:o},d));const f=this.client.session.get(o),p=await this.getVerifyContext({attestationId:c,hash:$t(JSON.stringify(Wt("wc_sessionRequest",d,h))),encryptedId:u,metadata:f.peer.metadata,transportType:l}),y={id:h,topic:o,params:d,verifyContext:p};await this.setPendingSessionRequest(y),l===de.link_mode&&(i=f.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=f.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(f){await this.sendError({id:h,topic:o,error:f}),this.client.logger.error(f)}}),T(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=X("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_t(i)?this.events.emit(X("session_request",n),{result:i.result}):nt(i)&&this.events.emit(X("session_request",n),{error:i.error})}),T(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=gi.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(ce({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),gi.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),T(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),_t(i)?this.events.emit(X("session_request",n),{result:i.result}):nt(i)&&this.events.emit(X("session_request",n),{error:i.error})}),T(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:u,authPayload:l,expiryTimestamp:h}=s.params,d=await this.getVerifyContext({attestationId:o,hash:$t(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:c}),f={requester:u,pairingTopic:n,id:s.id,authPayload:l,verifyContext:d,expiryTimestamp:h};await this.setAuthRequest(s.id,{request:f,pairingTopic:n,transportType:c}),c===de.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:d})}catch(u){this.client.logger.error(u);const l=s.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(s.params.requester.metadata,c),f={type:Mt,receiverPublicKey:l,senderPublicKey:h};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:f,rpcOpts:ve.wc_sessionAuthenticate.autoReject,appLink:d})}}),T(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),T(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=bt.idle,this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay))}),T(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=X("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(X("session_request",s.request.id),{error:i})})}),T(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===bt.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=bt.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),T(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),T(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:Wt("wc_sessionPropose",Be(ce({},i),{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties,scopedProperties:i.scopedProperties}),i.id)})}),T(this,"isValidConnect",async r=>{if(!ze(r)){const{message:u}=L("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,scopedProperties:a,relays:c}=r;if(Le(i)||await this.isValidPairingTopic(i),!zE(c)){const{message:u}=L("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(u)}if(!Le(n)&&Jt(n)!==0){const u="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(u):this.client.logger.warn(u),this.validateNamespaces(n,"requiredNamespaces")}if(!Le(s)&&Jt(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Le(o)||this.validateSessionProps(o,"sessionProperties"),!Le(a)){this.validateSessionProps(a,"scopedProperties");const u=Object.keys(n||{}).concat(Object.keys(s||{}));if(!Object.keys(a).every(l=>u.includes(l)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(u)}`)}}),T(this,"validateNamespaces",(r,i)=>{const n=kE(r,"connect()",i);if(n)throw new Error(n.message)}),T(this,"isValidApprove",async r=>{if(!ze(r))throw new Error(L("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const c=this.client.proposal.get(i),u=xs(n,"approve()");if(u)throw new Error(u.message);const l=ou(c.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!ye(s,!0)){const{message:h}=L("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}if(Le(o)||this.validateSessionProps(o,"sessionProperties"),!Le(a)){this.validateSessionProps(a,"scopedProperties");const h=new Set(Object.keys(n));if(!Object.keys(a).every(d=>h.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),T(this,"isValidReject",async r=>{if(!ze(r)){const{message:s}=L("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!KE(n)){const{message:s}=L("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),T(this,"isValidSessionSettleRequest",r=>{if(!ze(r)){const{message:u}=L("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(u)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Dd(i)){const{message:u}=L("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const a=jE(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=xs(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Kt(o)){const{message:u}=L("EXPIRED","onSessionSettleRequest()");throw new Error(u)}}),T(this,"isValidUpdate",async r=>{if(!ze(r)){const{message:c}=L("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=xs(n,"update()");if(o)throw new Error(o.message);const a=ou(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),T(this,"isValidExtend",async r=>{if(!ze(r)){const{message:n}=L("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),T(this,"isValidRequest",async r=>{if(!ze(r)){const{message:c}=L("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!su(a,s)){const{message:c}=L("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!VE(n)){const{message:c}=L("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!YE(a,s,n.method)){const{message:c}=L("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!XE(o,Ms)){const{message:c}=L("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ms.min} and ${Ms.max}`);throw new Error(c)}}),T(this,"isValidRespond",async r=>{var i;if(!ze(r)){const{message:o}=L("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!WE(s)){const{message:o}=L("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),T(this,"isValidPing",async r=>{if(!ze(r)){const{message:n}=L("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),T(this,"isValidEmit",async r=>{if(!ze(r)){const{message:a}=L("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!su(o,s)){const{message:a}=L("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!GE(n)){const{message:a}=L("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!JE(o,s,n.name)){const{message:a}=L("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),T(this,"isValidDisconnect",async r=>{if(!ze(r)){const{message:n}=L("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),T(this,"isValidAuthenticate",r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ye(n,!1))throw new Error("uri is required parameter");if(!ye(s,!1))throw new Error("domain is required parameter");if(!ye(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Jr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Jr(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),T(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Di,validation:"UNKNOWN",origin:o.url||""}};try{if(a===de.link_mode){const l=this.getAppLinkIfEnabled(o,a);return c.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",c}const u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(c.verified.origin=u.origin,c.verified.isScam=u.isScam,c.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),T(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach((n,s)=>{if(n==null){const{message:o}=L("MISSING_OR_INVALID",`${i} must contain an existing value for each key. Received: ${n} for key ${Object.keys(r)[s]}`);throw new Error(o)}})}),T(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),T(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}}),T(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=L("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),T(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,u,l,h,d;return!r||i!==de.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:u.universal)!==""&&((l=r?.redirect)==null?void 0:l.universal)!==void 0&&((h=r?.redirect)==null?void 0:h.universal)!==""&&((d=r?.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),T(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),T(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=Ec(r,"topic")||"",n=decodeURIComponent(Ec(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:de.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),T(this,"registerLinkModeListeners",async()=>{var r;if(Jo()||Zt()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}),T(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(Uu).includes(n.method)}),T(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return Be(ce({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(s=i.request.params)==null?void 0:s[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),T(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const n=r?.data||((i=r?.[0])==null?void 0:i.data);if(!n.startsWith("0x"))return!1;const s=n.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),T(this,"extractTxHashesFromResult",(r,i)=>{try{const n=Uu[r];if(typeof i=="string")return[i];const s=i[n.key];if(ft(s))return r==="solana_signAllTransactions"?s.map(o=>b0(o)):s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[i,n]of Object.entries(r))for(const s of n)try{await this.onProviderMessageEvent({topic:i,message:s,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${i}, message: ${s}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=L("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ie.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(En)?this.client.auth.authKeys.get(En):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===de.link_mode?Vt:pt});Vo(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:$t(i)})):Vn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s}),await this.client.core.relayer.messages.ack(r,i)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(it.expired,async e=>{const{topic:r,id:i}=Kh(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,L("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,L("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(or.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(or.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ye(e,!1)){const{message:r}=L("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=L("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=L("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ye(e,!1)){const{message:r}=L("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=L("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=L("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=L("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}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))this.isValidPairingTopic(e);else if(ye(e,!1)){const{message:r}=L("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=L("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!HE(e)){const{message:r}=L("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=L("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=L("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class Z2 extends br{constructor(e,r){super(e,r,L2,na),this.core=e,this.logger=r}}let Q2=class extends br{constructor(e,r){super(e,r,j2,na),this.core=e,this.logger=r}};class X2 extends br{constructor(e,r){super(e,r,M2,na,i=>i.id),this.core=e,this.logger=r}}class eD extends br{constructor(e,r){super(e,r,k2,rs,()=>En),this.core=e,this.logger=r}}class tD extends br{constructor(e,r){super(e,r,z2,rs),this.core=e,this.logger=r}}class rD extends br{constructor(e,r){super(e,r,H2,rs,i=>i.id),this.core=e,this.logger=r}}var iD=Object.defineProperty,nD=(t,e,r)=>e in t?iD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fs=(t,e,r)=>nD(t,typeof e!="symbol"?e+"":e,r);class sD{constructor(e,r){this.core=e,this.logger=r,Fs(this,"authKeys"),Fs(this,"pairingTopics"),Fs(this,"requests"),this.authKeys=new eD(this.core,this.logger),this.pairingTopics=new tD(this.core,this.logger),this.requests=new rD(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var oD=Object.defineProperty,aD=(t,e,r)=>e in t?oD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,W=(t,e,r)=>aD(t,typeof e!="symbol"?e+"":e,r);let cD=class Vd extends Y_{constructor(e){super(e),W(this,"protocol",zd),W(this,"version",Hd),W(this,"name",Bs.name),W(this,"metadata"),W(this,"core"),W(this,"logger"),W(this,"events",new Ut.EventEmitter),W(this,"engine"),W(this,"session"),W(this,"proposal"),W(this,"pendingRequest"),W(this,"auth"),W(this,"signConfig"),W(this,"on",(i,n)=>this.events.on(i,n)),W(this,"once",(i,n)=>this.events.once(i,n)),W(this,"off",(i,n)=>this.events.off(i,n)),W(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),W(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),W(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),W(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),W(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),W(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||Bs.name,this.metadata=Rv(e?.metadata),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Bi(Mn({level:e?.logger||Bs.logger}));this.core=e?.core||new N2(e),this.logger=Fe(r,this.name),this.session=new Q2(this.core,this.logger),this.proposal=new Z2(this.core,this.logger),this.pendingRequest=new X2(this.core,this.logger),this.engine=new J2(this),this.auth=new sD(this.core,this.logger)}static async init(e){const r=new Vd(e);return await r.initialize(),r}get context(){return Ve(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},N.toMiliseconds(N.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var sa={exports:{}},Zr=typeof Reflect=="object"?Reflect:null,ku=Zr&&typeof Zr.apply=="function"?Zr.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},_n;Zr&&typeof Zr.ownKeys=="function"?_n=Zr.ownKeys:Object.getOwnPropertySymbols?_n=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:_n=function(e){return Object.getOwnPropertyNames(e)};function uD(t){console&&console.warn&&console.warn(t)}var Wd=Number.isNaN||function(e){return e!==e};function oe(){oe.init.call(this)}sa.exports=oe;sa.exports.once=pD;oe.EventEmitter=oe;oe.prototype._events=void 0;oe.prototype._eventsCount=0;oe.prototype._maxListeners=void 0;var zu=10;function is(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(oe,"defaultMaxListeners",{enumerable:!0,get:function(){return zu},set:function(t){if(typeof t!="number"||t<0||Wd(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");zu=t}});oe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};oe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Wd(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Gd(t){return t._maxListeners===void 0?oe.defaultMaxListeners:t._maxListeners}oe.prototype.getMaxListeners=function(){return Gd(this)};oe.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")ku(c,this,r);else for(var u=c.length,l=Xd(c,u),i=0;i<u;++i)ku(l[i],this,r);return!0};function Yd(t,e,r,i){var n,s,o;if(is(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Gd(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,uD(a)}return t}oe.prototype.addListener=function(e,r){return Yd(this,e,r,!1)};oe.prototype.on=oe.prototype.addListener;oe.prototype.prependListener=function(e,r){return Yd(this,e,r,!0)};function lD(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Jd(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=lD.bind(i);return n.listener=r,i.wrapFn=n,n}oe.prototype.once=function(e,r){return is(r),this.on(e,Jd(this,e,r)),this};oe.prototype.prependOnceListener=function(e,r){return is(r),this.prependListener(e,Jd(this,e,r)),this};oe.prototype.removeListener=function(e,r){var i,n,s,o,a;if(is(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():hD(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};oe.prototype.off=oe.prototype.removeListener;oe.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Zd(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?dD(n):Xd(n,n.length)}oe.prototype.listeners=function(e){return Zd(this,e,!0)};oe.prototype.rawListeners=function(e){return Zd(this,e,!1)};oe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Qd.call(t,e)};oe.prototype.listenerCount=Qd;function Qd(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}oe.prototype.eventNames=function(){return this._eventsCount>0?_n(this._events):[]};function Xd(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function hD(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function dD(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function pD(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}ep(t,e,s,{once:!0}),e!=="error"&&fD(t,n,{once:!0})})}function fD(t,e,r){typeof t.on=="function"&&ep(t,"error",e,r)}function ep(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var gD=sa.exports,So={exports:{}};(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof It<"u"&&It,i=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof It<"u"&&It||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function u(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(g){return g&&l.indexOf(Object.prototype.toString.call(g))>-1};function d(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(g)||g==="")throw new TypeError('Invalid character in header field name: "'+g+'"');return g.toLowerCase()}function f(g){return typeof g!="string"&&(g=String(g)),g}function p(g){var m={next:function(){var _=g.shift();return{done:_===void 0,value:_}}};return c.iterable&&(m[Symbol.iterator]=function(){return m}),m}function y(g){this.map={},g instanceof y?g.forEach(function(m,_){this.append(_,m)},this):Array.isArray(g)?g.forEach(function(m){if(m.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+m.length);this.append(m[0],m[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(m){this.append(m,g[m])},this)}y.prototype.append=function(g,m){g=d(g),m=f(m);var _=this.map[g];this.map[g]=_?_+", "+m:m},y.prototype.delete=function(g){delete this.map[d(g)]},y.prototype.get=function(g){return g=d(g),this.has(g)?this.map[g]:null},y.prototype.has=function(g){return this.map.hasOwnProperty(d(g))},y.prototype.set=function(g,m){this.map[d(g)]=f(m)},y.prototype.forEach=function(g,m){for(var _ in this.map)this.map.hasOwnProperty(_)&&g.call(m,this.map[_],_,this)},y.prototype.keys=function(){var g=[];return this.forEach(function(m,_){g.push(_)}),p(g)},y.prototype.values=function(){var g=[];return this.forEach(function(m){g.push(m)}),p(g)},y.prototype.entries=function(){var g=[];return this.forEach(function(m,_){g.push([_,m])}),p(g)},c.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function w(g){if(!g._noBody){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}}function v(g){return new Promise(function(m,_){g.onload=function(){m(g.result)},g.onerror=function(){_(g.error)}})}function b(g){var m=new FileReader,_=v(m);return m.readAsArrayBuffer(g),_}function E(g){var m=new FileReader,_=v(m),D=/charset=([A-Za-z0-9_-]+)/.exec(g.type),I=D?D[1]:"utf-8";return m.readAsText(g,I),_}function $(g){for(var m=new Uint8Array(g),_=new Array(m.length),D=0;D<m.length;D++)_[D]=String.fromCharCode(m[D]);return _.join("")}function A(g){if(g.slice)return g.slice(0);var m=new Uint8Array(g.byteLength);return m.set(new Uint8Array(g)),m.buffer}function P(){return this.bodyUsed=!1,this._initBody=function(g){this.bodyUsed=this.bodyUsed,this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:c.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:c.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():c.arrayBuffer&&c.blob&&u(g)?(this._bodyArrayBuffer=A(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||h(g))?this._bodyArrayBuffer=A(g):this._bodyText=g=Object.prototype.toString.call(g):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof g=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var g=w(this);return g||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(b);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return E(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve($(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(q)}),this.json=function(){return this.text().then(JSON.parse)},this}var S=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function C(g){var m=g.toUpperCase();return S.indexOf(m)>-1?m:g}function O(g,m){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');m=m||{};var _=m.body;if(g instanceof O){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,m.headers||(this.headers=new y(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!_&&g._bodyInit!=null&&(_=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new y(m.headers)),this.method=C(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal||function(){if("AbortController"in a){var x=new AbortController;return x.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(_),(this.method==="GET"||this.method==="HEAD")&&(m.cache==="no-store"||m.cache==="no-cache")){var D=/([?&])_=[^&]*/;if(D.test(this.url))this.url=this.url.replace(D,"$1_="+new Date().getTime());else{var I=/\?/;this.url+=(I.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}O.prototype.clone=function(){return new O(this,{body:this._bodyInit})};function q(g){var m=new FormData;return g.trim().split("&").forEach(function(_){if(_){var D=_.split("="),I=D.shift().replace(/\+/g," "),x=D.join("=").replace(/\+/g," ");m.append(decodeURIComponent(I),decodeURIComponent(x))}}),m}function B(g){var m=new y,_=g.replace(/\r?\n[\t ]+/g," ");return _.split("\r").map(function(D){return D.indexOf(`
|
|
38
|
+
`)===0?D.substr(1,D.length):D}).forEach(function(D){var I=D.split(":"),x=I.shift().trim();if(x){var M=I.join(":").trim();try{m.append(x,M)}catch(U){console.warn("Response "+U.message)}}}),m}P.call(O.prototype);function j(g,m){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=m.statusText===void 0?"":""+m.statusText,this.headers=new y(m.headers),this.url=m.url||"",this._initBody(g)}P.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},j.error=function(){var g=new j(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var k=[301,302,303,307,308];j.redirect=function(g,m){if(k.indexOf(m)===-1)throw new RangeError("Invalid status code");return new j(null,{status:m,headers:{location:g}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,_){this.message=m,this.name=_;var D=Error(m);this.stack=D.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function R(g,m){return new Promise(function(_,D){var I=new O(g,m);if(I.signal&&I.signal.aborted)return D(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function M(){x.abort()}x.onload=function(){var F={statusText:x.statusText,headers:B(x.getAllResponseHeaders()||"")};I.url.indexOf("file://")===0&&(x.status<200||x.status>599)?F.status=200:F.status=x.status,F.url="responseURL"in x?x.responseURL:F.headers.get("X-Request-URL");var H="response"in x?x.response:x.responseText;setTimeout(function(){_(new j(H,F))},0)},x.onerror=function(){setTimeout(function(){D(new TypeError("Network request failed"))},0)},x.ontimeout=function(){setTimeout(function(){D(new TypeError("Network request timed out"))},0)},x.onabort=function(){setTimeout(function(){D(new o.DOMException("Aborted","AbortError"))},0)};function U(F){try{return F===""&&a.location.href?a.location.href:F}catch{return F}}if(x.open(I.method,U(I.url),!0),I.credentials==="include"?x.withCredentials=!0:I.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&(c.blob?x.responseType="blob":c.arrayBuffer&&(x.responseType="arraybuffer")),m&&typeof m.headers=="object"&&!(m.headers instanceof y||a.Headers&&m.headers instanceof a.Headers)){var z=[];Object.getOwnPropertyNames(m.headers).forEach(function(F){z.push(d(F)),x.setRequestHeader(F,f(m.headers[F]))}),I.headers.forEach(function(F,H){z.indexOf(H)===-1&&x.setRequestHeader(H,F)})}else I.headers.forEach(function(F,H){x.setRequestHeader(H,F)});I.signal&&(I.signal.addEventListener("abort",M),x.onreadystatechange=function(){x.readyState===4&&I.signal.removeEventListener("abort",M)}),x.send(typeof I._bodyInit>"u"?null:I._bodyInit)})}return R.polyfill=!0,a.fetch||(a.fetch=R,a.Headers=y,a.Request=O,a.Response=j),o.Headers=y,o.Request=O,o.Response=j,o.fetch=R,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=r.fetch?r:i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e})(So,So.exports);var yD=So.exports;const Hu=Ro(yD);var mD=Object.defineProperty,wD=Object.defineProperties,bD=Object.getOwnPropertyDescriptors,Ku=Object.getOwnPropertySymbols,vD=Object.prototype.hasOwnProperty,ED=Object.prototype.propertyIsEnumerable,Vu=(t,e,r)=>e in t?mD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wu=(t,e)=>{for(var r in e||(e={}))vD.call(e,r)&&Vu(t,r,e[r]);if(Ku)for(var r of Ku(e))ED.call(e,r)&&Vu(t,r,e[r]);return t},Gu=(t,e)=>wD(t,bD(e));const _D={Accept:"application/json","Content-Type":"application/json"},ID="POST",Yu={headers:_D,method:ID},Ju=10;let gt=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new gD.EventEmitter,this.isAvailable=!1,this.registering=!1,!ac(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Ft(e),i=await(await Hu(this.url,Gu(Wu({},Yu),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!ac(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Ft({id:1,jsonrpc:"2.0",method:"test",params:[]});await Hu(e,Gu(Wu({},Yu),{body:r}))}this.onOpen()}catch(r){const i=this.parseError(r);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?hr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Kn(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return mh(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Ju&&this.events.setMaxListeners(Ju)}};const Zu="error",$D="wss://relay.walletconnect.org",OD="wc",DD="universal_provider",on=`${OD}@2:${DD}:`,tp="https://rpc.walletconnect.org/v1/",kr="generic",SD=`${tp}bundler`,at={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function PD(){}function oa(t){return t==null||typeof t!="object"&&typeof t!="function"}function aa(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function AD(t){if(oa(t))return t;if(Array.isArray(t)||aa(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),r=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new r(t);if(t instanceof RegExp){const i=new r(t);return i.lastIndex=t.lastIndex,i}if(t instanceof DataView)return new r(t.buffer.slice(0));if(t instanceof Error){const i=new r(t.message);return i.stack=t.stack,i.name=t.name,i.cause=t.cause,i}if(typeof File<"u"&&t instanceof File)return new r([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const i=Object.create(e);return Object.assign(i,t)}return t}function Qu(t){return typeof t=="object"&&t!==null}function rp(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function ip(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const xD="[object RegExp]",np="[object String]",sp="[object Number]",op="[object Boolean]",ap="[object Arguments]",CD="[object Symbol]",RD="[object Date]",TD="[object Map]",ND="[object Set]",LD="[object Array]",jD="[object ArrayBuffer]",BD="[object Object]",MD="[object DataView]",FD="[object Uint8Array]",UD="[object Uint8ClampedArray]",qD="[object Uint16Array]",kD="[object Uint32Array]",zD="[object Int8Array]",HD="[object Int16Array]",KD="[object Int32Array]",VD="[object Float32Array]",WD="[object Float64Array]";function GD(t,e){return Kr(t,void 0,t,new Map,e)}function Kr(t,e,r,i=new Map,n=void 0){const s=n?.(t,e,r,i);if(s!=null)return s;if(oa(t))return t;if(i.has(t))return i.get(t);if(Array.isArray(t)){const o=new Array(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=Kr(t[a],a,r,i,n);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;i.set(t,o);for(const[a,c]of t)o.set(a,Kr(c,a,r,i,n));return o}if(t instanceof Set){const o=new Set;i.set(t,o);for(const a of t)o.add(Kr(a,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(aa(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=Kr(t[a],a,r,i,n);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return i.set(t,o),ar(o,t,r,i,n),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return i.set(t,o),ar(o,t,r,i,n),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return i.set(t,o),ar(o,t,r,i,n),o}if(t instanceof Error){const o=new t.constructor;return i.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,ar(o,t,r,i,n),o}if(typeof t=="object"&&YD(t)){const o=Object.create(Object.getPrototypeOf(t));return i.set(t,o),ar(o,t,r,i,n),o}return t}function ar(t,e,r=t,i,n){const s=[...Object.keys(e),...rp(e)];for(let o=0;o<s.length;o++){const a=s[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Kr(e[a],a,r,i,n))}}function YD(t){switch(ip(t)){case ap:case LD:case jD:case MD:case op:case RD:case VD:case WD:case zD:case HD:case KD:case TD:case sp:case BD:case xD:case ND:case np:case CD:case FD:case UD:case qD:case kD:return!0;default:return!1}}function JD(t,e){return GD(t,(r,i,n,s)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case sp:case np:case op:{const o=new t.constructor(t?.valueOf());return ar(o,t),o}case ap:{const o={};return ar(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function Xu(t){return JD(t)}function el(t){return t!==null&&typeof t=="object"&&ip(t)==="[object Arguments]"}function ZD(t){return aa(t)}function QD(t){if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function XD(t,...e){const r=e.slice(0,-1),i=e[e.length-1];let n=t;for(let s=0;s<r.length;s++){const o=r[s];n=Po(n,o,i,new Map)}return n}function Po(t,e,r,i){if(oa(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return AD(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let s=0;s<e.length;s++)e[s]=e[s]??void 0}const n=[...Object.keys(e),...rp(e)];for(let s=0;s<n.length;s++){const o=n[s];let a=e[o],c=t[o];if(el(a)&&(a={...a}),el(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Xu(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const l=[],h=Reflect.ownKeys(c);for(let d=0;d<h.length;d++){const f=h[d];l[f]=c[f]}c=l}else c=[];const u=r(c,a,o,t,e,i);u!=null?t[o]=u:Array.isArray(a)||Qu(c)&&Qu(a)?t[o]=Po(c,a,r,i):c==null&&QD(a)?t[o]=Po({},a,r,i):c==null&&ZD(a)?t[o]=Xu(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function eS(t,...e){return XD(t,...e,PD)}var tS=Object.defineProperty,rS=Object.defineProperties,iS=Object.getOwnPropertyDescriptors,tl=Object.getOwnPropertySymbols,nS=Object.prototype.hasOwnProperty,sS=Object.prototype.propertyIsEnumerable,rl=(t,e,r)=>e in t?tS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,an=(t,e)=>{for(var r in e||(e={}))nS.call(e,r)&&rl(t,r,e[r]);if(tl)for(var r of tl(e))sS.call(e,r)&&rl(t,r,e[r]);return t},oS=(t,e)=>rS(t,iS(e));function Xe(t,e,r){var i;const n=Jr(t);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${tp}?chainId=${n.namespace}:${n.reference}&projectId=${r}`}function vr(t){return t.includes(":")?t.split(":")[1]:t}function cp(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function aS(t,e){const r=Object.keys(e.namespaces).filter(n=>n.includes(t));if(!r.length)return[];const i=[];return r.forEach(n=>{const s=e.namespaces[n].accounts;i.push(...s)}),i}function cn(t={},e={}){const r=il(t),i=il(e);return eS(r,i)}function il(t){var e,r,i,n,s;const o={};if(!Jt(t))return o;for(const[a,c]of Object.entries(t)){const u=es(a)?[a]:c.chains,l=c.methods||[],h=c.events||[],d=c.rpcMap||{},f=Hr(a);o[f]=oS(an(an({},o[f]),c),{chains:Dt(u,(e=o[f])==null?void 0:e.chains),methods:Dt(l,(r=o[f])==null?void 0:r.methods),events:Dt(h,(i=o[f])==null?void 0:i.events)}),(Jt(d)||Jt(((n=o[f])==null?void 0:n.rpcMap)||{}))&&(o[f].rpcMap=an(an({},d),(s=o[f])==null?void 0:s.rpcMap))}return o}function nl(t){return t.includes(":")?t.split(":")[2]:t}function sl(t){const e={};for(const[r,i]of Object.entries(t)){const n=i.methods||[],s=i.events||[],o=i.accounts||[],a=es(r)?[r]:i.chains?i.chains:cp(i.accounts);e[r]={chains:a,methods:n,events:s,accounts:o}}return e}function Us(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const up={},Q=t=>up[t],qs=(t,e)=>{up[t]=e};var cS=Object.defineProperty,uS=(t,e,r)=>e in t?cS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xr=(t,e,r)=>uS(t,typeof e!="symbol"?e+"":e,r);class lS{constructor(e){xr(this,"name","polkadot"),xr(this,"client"),xr(this,"httpProviders"),xr(this,"events"),xr(this,"namespace"),xr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=vr(r);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var hS=Object.defineProperty,dS=Object.defineProperties,pS=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,fS=Object.prototype.hasOwnProperty,gS=Object.prototype.propertyIsEnumerable,Ao=(t,e,r)=>e in t?hS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,al=(t,e)=>{for(var r in e||(e={}))fS.call(e,r)&&Ao(t,r,e[r]);if(ol)for(var r of ol(e))gS.call(e,r)&&Ao(t,r,e[r]);return t},cl=(t,e)=>dS(t,pS(e)),Cr=(t,e,r)=>Ao(t,typeof e!="symbol"?e+"":e,r);class yS{constructor(e){Cr(this,"name","eip155"),Cr(this,"client"),Cr(this,"chainId"),Cr(this,"namespace"),Cr(this,"httpProviders"),Cr(this,"events"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const i=r||Xe(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=parseInt(vr(r));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,i;let n=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const s=parseInt(n,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,i,n,s,o;const a=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0],c=((s=(n=e.request)==null?void 0:n.params)==null?void 0:s[1])||[],u=`${a}${c.join(",")}`;if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const l=this.client.session.get(e.topic),h=((o=l?.sessionProperties)==null?void 0:o.capabilities)||{};if(h!=null&&h[u])return h?.[u];const d=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:cl(al({},l.sessionProperties||{}),{capabilities:cl(al({},h||{}),{[u]:d})})})}catch(f){console.warn("Failed to update session with capabilities",f)}return d}async getCallStatus(e){var r,i;const n=this.client.session.get(e.topic),s=(r=n.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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,r){var i;const n=new URL(e),s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Wt("eth_getUserOperationReceipt",[(i=r.request.params)==null?void 0:i[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${SD}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var mS=Object.defineProperty,wS=(t,e,r)=>e in t?mS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rr=(t,e,r)=>wS(t,typeof e!="symbol"?e+"":e,r);class bS{constructor(e){Rr(this,"name","solana"),Rr(this,"client"),Rr(this,"httpProviders"),Rr(this,"events"),Rr(this,"namespace"),Rr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=vr(r);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var vS=Object.defineProperty,ES=(t,e,r)=>e in t?vS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tr=(t,e,r)=>ES(t,typeof e!="symbol"?e+"":e,r);class _S{constructor(e){Tr(this,"name","cosmos"),Tr(this,"client"),Tr(this,"httpProviders"),Tr(this,"events"),Tr(this,"namespace"),Tr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=vr(r);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var IS=Object.defineProperty,$S=(t,e,r)=>e in t?IS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nr=(t,e,r)=>$S(t,typeof e!="symbol"?e+"":e,r);class OS{constructor(e){Nr(this,"name","algorand"),Nr(this,"client"),Nr(this,"httpProviders"),Nr(this,"events"),Nr(this,"namespace"),Nr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const i=r||Xe(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new ot(new gt(i,Q("disableProviderPing")))}}var DS=Object.defineProperty,SS=(t,e,r)=>e in t?DS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lr=(t,e,r)=>SS(t,typeof e!="symbol"?e+"":e,r);class PS{constructor(e){Lr(this,"name","cip34"),Lr(this,"client"),Lr(this,"httpProviders"),Lr(this,"events"),Lr(this,"namespace"),Lr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const i=this.getCardanoRPCUrl(r),n=vr(r);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var AS=Object.defineProperty,xS=(t,e,r)=>e in t?AS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jr=(t,e,r)=>xS(t,typeof e!="symbol"?e+"":e,r);class CS{constructor(e){jr(this,"name","elrond"),jr(this,"client"),jr(this,"httpProviders"),jr(this,"events"),jr(this,"namespace"),jr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=vr(r);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var RS=Object.defineProperty,TS=(t,e,r)=>e in t?RS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Br=(t,e,r)=>TS(t,typeof e!="symbol"?e+"":e,r);class NS{constructor(e){Br(this,"name","multiversx"),Br(this,"client"),Br(this,"httpProviders"),Br(this,"events"),Br(this,"namespace"),Br(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=vr(r);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var LS=Object.defineProperty,jS=(t,e,r)=>e in t?LS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mr=(t,e,r)=>jS(t,typeof e!="symbol"?e+"":e,r);class BS{constructor(e){Mr(this,"name","near"),Mr(this,"client"),Mr(this,"httpProviders"),Mr(this,"events"),Mr(this,"namespace"),Mr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||Xe(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace);return typeof i>"u"?void 0:new ot(new gt(i,Q("disableProviderPing")))}}var MS=Object.defineProperty,FS=(t,e,r)=>e in t?MS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fr=(t,e,r)=>FS(t,typeof e!="symbol"?e+"":e,r);class US{constructor(e){Fr(this,"name","tezos"),Fr(this,"client"),Fr(this,"httpProviders"),Fr(this,"events"),Fr(this,"namespace"),Fr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||Xe(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace);return typeof i>"u"?void 0:new ot(new gt(i))}}var qS=Object.defineProperty,kS=(t,e,r)=>e in t?qS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ur=(t,e,r)=>kS(t,typeof e!="symbol"?e+"":e,r);class zS{constructor(e){Ur(this,"name",kr),Ur(this,"client"),Ur(this,"httpProviders"),Ur(this,"events"),Ur(this,"namespace"),Ur(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(at.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const i={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(n=>{const s=Jr(n);i[`${s.namespace}:${s.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Xe(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ot(new gt(i,Q("disableProviderPing")))}}var HS=Object.defineProperty,KS=Object.defineProperties,VS=Object.getOwnPropertyDescriptors,ul=Object.getOwnPropertySymbols,WS=Object.prototype.hasOwnProperty,GS=Object.prototype.propertyIsEnumerable,xo=(t,e,r)=>e in t?HS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,un=(t,e)=>{for(var r in e||(e={}))WS.call(e,r)&&xo(t,r,e[r]);if(ul)for(var r of ul(e))GS.call(e,r)&&xo(t,r,e[r]);return t},ks=(t,e)=>KS(t,VS(e)),rt=(t,e,r)=>xo(t,typeof e!="symbol"?e+"":e,r);let YS=class lp{constructor(e){rt(this,"client"),rt(this,"namespaces"),rt(this,"optionalNamespaces"),rt(this,"sessionProperties"),rt(this,"scopedProperties"),rt(this,"events",new Yo),rt(this,"rpcProviders",{}),rt(this,"session"),rt(this,"providerOpts"),rt(this,"logger"),rt(this,"uri"),rt(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Bi(Mn({level:e?.logger||Zu})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new lp(e);return await r.initialize(),r}async request(e,r,i){const[n,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:un({},e),chainId:`${n}:${s}`,topic:this.session.topic,expiry:i})}sendAsync(e,r,i,n){const s=new Date().getTime();this.request(e,i,n).then(o=>r(null,Hn(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,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:(e=this.session)==null?void 0:e.topic,reason:te("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,r);i&&(this.uri=i,this.events.emit("display_uri",i));const s=await n();if(this.session=s.session,this.session){const o=sl(this.session.namespaces);this.namespaces=cn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){const{uri:r,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();this.session=n;const s=sl(n.namespaces);return this.namespaces=cn(this.namespaces,s),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,n]=this.validateChain(e),s=this.getProvider(i);s.name===kr?s.setDefaultChain(`${i}:${n}`,r):s.setDefaultChain(n,r)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(ft(r)){for(const i of r)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,r;if(this.client=this.providerOpts.client||await cD.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Zu,relayUrl:this.providerOpts.relayUrl||$D,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(i){throw this.logger.error("Failed to get session",i),new Error(`The provided session: ${(r=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:r.topic} doesn't exist in the Sign client`)}else{const i=this.client.session.getAll();this.session=i[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(r=>Hr(r)))];qs("client",this.client),qs("events",this.events),qs("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=aS(r,this.session),n=cp(i),s=cn(this.namespaces,this.optionalNamespaces),o=ks(un({},s[r]),{accounts:i,chains:n});switch(r){case"eip155":this.rpcProviders[r]=new yS({namespace:o});break;case"algorand":this.rpcProviders[r]=new OS({namespace:o});break;case"solana":this.rpcProviders[r]=new bS({namespace:o});break;case"cosmos":this.rpcProviders[r]=new _S({namespace:o});break;case"polkadot":this.rpcProviders[r]=new lS({namespace:o});break;case"cip34":this.rpcProviders[r]=new PS({namespace:o});break;case"elrond":this.rpcProviders[r]=new CS({namespace:o});break;case"multiversx":this.rpcProviders[r]=new NS({namespace:o});break;case"near":this.rpcProviders[r]=new BS({namespace:o});break;case"tezos":this.rpcProviders[r]=new US({namespace:o});break;default:this.rpcProviders[kr]?this.rpcProviders[kr].updateNamespace(o):this.rpcProviders[kr]=new zS({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var r;const{topic:i}=e;i===((r=this.session)==null?void 0:r.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:i,topic:n}=e;if(n!==((r=this.session)==null?void 0:r.topic))return;const{event:s}=i;if(s.name==="accountsChanged"){const o=s.data;o&&ft(o)&&this.events.emit("accountsChanged",o.map(nl))}else if(s.name==="chainChanged"){const o=i.chainId,a=i.event.data,c=Hr(o),u=Us(o)!==Us(a)?`${c}:${Us(a)}`:o;this.onChainChanged(u)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i,n;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:s}=r,o=(n=this.client)==null?void 0:n.session.get(e);this.session=ks(un({},o),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{var r;e.topic===((r=this.session)==null?void 0:r.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",ks(un({},te("USER_DISCONNECTED")),{data:e.topic})))}),this.on(at.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[kr]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r={},optionalNamespaces:i={},sessionProperties:n,scopedProperties:s}=e;this.optionalNamespaces=cn(r,i),this.sessionProperties=n,this.scopedProperties=s}validateChain(e){const[r,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,i];if(r&&!Object.keys(this.namespaces||{}).map(o=>Hr(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&i)return[r,i];const n=Hr(Object.keys(this.namespaces)[0]),s=this.rpcProviders[n].getDefaultChain();return[n,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);if(!n)return;this.updateNamespaceChain(i,n),this.events.emit("chainChanged",n);const s=this.getProvider(i).getDefaultChain();r||this.getProvider(i).setDefaultChain(n),this.emitAccountsChangedOnChainChange({namespace:i,previousChainId:s,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:r,newChainId:i}){var n,s;try{if(r===i)return;const o=(s=(n=this.session)==null?void 0:n.namespaces[e])==null?void 0:s.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${i}:`)).map(nl);if(!ft(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,r){if(!this.namespaces)return;const i=this.namespaces[e]?e:`${e}:${r}`,n={chains:[],methods:[],events:[],defaultChain:r};this.namespaces[i]?this.namespaces[i]&&(this.namespaces[i].defaultChain=r):this.namespaces[i]=n}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var i;const n=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${on}/${e}${n}`,r)}async getFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${on}/${e}${i}`)}async deleteFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${on}/${e}${i}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const r=await this.client.core.storage.getKeys();for(const i of r)i.startsWith(on)&&await this.client.core.storage.removeItem(i)}catch(r){this.logger.warn("Failed to cleanup storage",r)}}};const JS=YS,ZS="wc",QS="ethereum_provider",XS=`${ZS}@2:${QS}:`,eP="https://rpc.walletconnect.org/v1/",Rn=["eth_sendTransaction","personal_sign"],hp=["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_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Tn=["chainChanged","accountsChanged"],dp=["chainChanged","accountsChanged","message","disconnect","connect"],tP=async()=>{const{createAppKit:t}=await _p(()=>import("./core-BGxUaCGc.js").then(e=>e.G),__vite__mapDeps([0,1,2,3,4]));return t};var rP=Object.defineProperty,iP=Object.defineProperties,nP=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,sP=Object.prototype.hasOwnProperty,oP=Object.prototype.propertyIsEnumerable,Co=(t,e,r)=>e in t?rP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ir=(t,e)=>{for(var r in e||(e={}))sP.call(e,r)&&Co(t,r,e[r]);if(ll)for(var r of ll(e))oP.call(e,r)&&Co(t,r,e[r]);return t},vi=(t,e)=>iP(t,nP(e)),Ge=(t,e,r)=>Co(t,typeof e!="symbol"?e+"":e,r);function Nn(t){return Number(t[0].split(":")[1])}function ln(t){return`0x${t.toString(16)}`}function aP(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=t;if(!ft(e))throw new Error("Invalid chains");const c={chains:e,methods:i||Rn,events:s||Tn,rpcMap:ir({},e.length?{[Nn(e)]:a[Nn(e)]}:{})},u=s?.filter(f=>!Tn.includes(f)),l=i?.filter(f=>!Rn.includes(f));if(!r&&!o&&!n&&!(u!=null&&u.length)&&!(l!=null&&l.length))return{required:e.length?c:void 0};const h=u?.length&&l?.length||!r,d={chains:[...new Set(h?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(n!=null&&n.length?n:hp))],events:[...new Set(c.events.concat(o!=null&&o.length?o:dp))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?d:void 0}}class ns{constructor(){Ge(this,"events",new Ut.EventEmitter),Ge(this,"namespace","eip155"),Ge(this,"accounts",[]),Ge(this,"signer"),Ge(this,"chainId",1),Ge(this,"modal"),Ge(this,"rpc"),Ge(this,"STORAGE_KEY",XS),Ge(this,"on",(e,r)=>(this.events.on(e,r),this)),Ge(this,"once",(e,r)=>(this.events.once(e,r),this)),Ge(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),Ge(this,"off",(e,r)=>(this.events.off(e,r),this)),Ge(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new ns;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,i){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){var r;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:i,optional:n}=aP(this.rpc);try{const s=await new Promise(async(a,c)=>{var u,l;this.rpc.showQrModal&&((u=this.modal)==null||u.open(),(l=this.modal)==null||l.subscribeState(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const h=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(vi(ir({namespaces:ir({},i&&{[this.namespace]:i})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e?.pairingTopic,scopedProperties:h})).then(d=>{a(d)}).catch(d=>{var f;(f=this.modal)==null||f.showErrorMessage("Unable to connect"),c(new Error(d.message))})});if(!s)return;const o=yc(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:ln(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{(r=this.modal)==null||r.close()}}async authenticate(e,r){var i;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{const n=await new Promise(async(o,a)=>{var c,u;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(u=this.modal)==null||u.subscribeState(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(vi(ir({},e),{chains:this.rpc.chains}),r).then(l=>{o(l)}).catch(l=>{var h;(h=this.modal)==null||h.showErrorMessage("Unable to connect"),a(new Error(l.message))})}),s=n.session;if(s){const o=yc(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:ln(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{(i=this.modal)==null||i.close()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:i}=r;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",ln(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",vi(ir({},te("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",ln(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,i,n]=e.split(":");return{chainId:`${r}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,i;const n=(r=e?.chains)!=null?r:[],s=(i=e?.optionalChains)!=null?i:[],o=n.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=n.length?e?.methods||Rn:[],c=n.length?e?.events||Tn:[],u=e?.optionalMethods||[],l=e?.optionalEvents||[],h=e?.rpcMap||this.buildRpcMap(o,e.projectId),d=e?.qrModalOptions||void 0;return{chains:n?.map(f=>this.formatChainId(f)),optionalChains:s.map(f=>this.formatChainId(f)),methods:a,events:c,optionalMethods:u,optionalEvents:l,rpcMap:h,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,r)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Nn(this.rpc.chains):Nn(this.rpc.optionalChains),this.signer=await JS.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const i=await tP(),{convertWCMToAppKitOptions:n}=await Promise.resolve().then(function(){return wP}),s=n(vi(ir({},this.rpc.qrModalOptions),{chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId}));if(!s.networks.length)throw new Error("No networks found for WalletConnect·");r=i(vi(ir({},s),{universalProvider:this.signer,manualWCControl:!0}))}catch(i){throw console.warn(i),new Error("To use QR modal, please install @reown/appkit package")}if(r)try{this.modal=r}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:i,rpcMap:n}=e;r&&ft(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)})),i&&ft(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map(s=>this.formatChainId(s)),i.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)}))}getRpcUrl(e,r){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${eP}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r?.accounts),this.setAccounts(r?.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const cP=ns;var uP=Object.defineProperty,lP=Object.defineProperties,hP=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,pP=Object.prototype.propertyIsEnumerable,dl=(t,e,r)=>e in t?uP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pp=(t,e)=>{for(var r in e||(e={}))dP.call(e,r)&&dl(t,r,e[r]);if(hl)for(var r of hl(e))pP.call(e,r)&&dl(t,r,e[r]);return t},fP=(t,e)=>lP(t,hP(e));function gP(t){if(t)return{"--w3m-font-family":t["--wcm-font-family"],"--w3m-accent":t["--wcm-accent-color"],"--w3m-color-mix":t["--wcm-background-color"],"--w3m-z-index":t["--wcm-z-index"]?Number(t["--wcm-z-index"]):void 0,"--w3m-qr-color":t["--wcm-accent-color"],"--w3m-font-size-master":t["--wcm-text-medium-regular-size"],"--w3m-border-radius-master":t["--wcm-container-border-radius"],"--w3m-color-mix-strength":0}}const yP=t=>{const[e,r]=t.split(":");return fp({id:r,caipNetworkId:t,chainNamespace:e,name:"",nativeCurrency:{name:"",symbol:"",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}})};function mP(t){var e,r,i,n,s,o,a;const c=(e=t.chains)==null?void 0:e.map(yP).filter(Boolean);if(c.length===0)throw new Error("At least one chain must be specified");const u=c.find(h=>{var d;return h.id===((d=t.defaultChain)==null?void 0:d.id)}),l={projectId:t.projectId,networks:c,themeMode:t.themeMode,themeVariables:gP(t.themeVariables),chainImages:t.chainImages,connectorImages:t.walletImages,defaultNetwork:u,metadata:fP(pp({},t.metadata),{name:((r=t.metadata)==null?void 0:r.name)||"WalletConnect",description:((i=t.metadata)==null?void 0:i.description)||"Connect to WalletConnect-compatible wallets",url:((n=t.metadata)==null?void 0:n.url)||"https://walletconnect.org",icons:((s=t.metadata)==null?void 0:s.icons)||["https://walletconnect.org/walletconnect-logo.png"]}),showWallets:!0,featuredWalletIds:t.explorerRecommendedWalletIds==="NONE"?[]:Array.isArray(t.explorerRecommendedWalletIds)?t.explorerRecommendedWalletIds:[],excludeWalletIds:t.explorerExcludedWalletIds==="ALL"?[]:Array.isArray(t.explorerExcludedWalletIds)?t.explorerExcludedWalletIds:[],enableEIP6963:!1,enableInjected:!1,enableCoinbase:!0,enableWalletConnect:!0,features:{email:!1,socials:!1}};if((o=t.mobileWallets)!=null&&o.length||(a=t.desktopWallets)!=null&&a.length){const h=[...(t.mobileWallets||[]).map(p=>({id:p.id,name:p.name,links:p.links})),...(t.desktopWallets||[]).map(p=>({id:p.id,name:p.name,links:{native:p.links.native,universal:p.links.universal}}))],d=[...l.featuredWalletIds||[],...l.excludeWalletIds||[]],f=h.filter(p=>!d.includes(p.id));f.length&&(l.customWallets=f)}return l}function fp(t){return pp({formatters:void 0,fees:void 0,serializers:void 0},t)}var wP=Object.freeze({__proto__:null,convertWCMToAppKitOptions:mP,defineChain:fp});const oA=Object.freeze(Object.defineProperty({__proto__:null,EthereumProvider:cP,OPTIONAL_EVENTS:dp,OPTIONAL_METHODS:hp,REQUIRED_EVENTS:Tn,REQUIRED_METHODS:Rn,default:ns},Symbol.toStringTag,{value:"Module"}));export{Wf as A,Bi as B,ob as C,Et as D,Fe as E,gt as F,oA as G,yr as I,Ja as P,rh as Q,hr as a,tc as b,N as c,Gi as d,dr as e,ko as f,nh as g,Wm as h,ih as i,Qs as j,Mn as k,df as l,cv as m,Vo as n,ot as o,Vn as p,Hn as q,mr as r,Ft as s,Wt as t,Mm as u,cr as v,Kn as w,_t as x,Ve as y,nt as z};
|