@walletconnect/ethereum-provider 2.18.1 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +32 -36
- package/dist/index.umd.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(wi,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(wi=typeof globalThis<"u"?globalThis:wi||self,Ft(wi["@walletconnect/ethereum-provider"]={}))})(this,function(wi){"use strict";var Ft=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ly(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ch(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var nr={exports:{}},Ys=typeof Reflect=="object"?Reflect:null,w0=Ys&&typeof Ys.apply=="function"?Ys.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Mc;Ys&&typeof Ys.ownKeys=="function"?Mc=Ys.ownKeys:Object.getOwnPropertySymbols?Mc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Mc=function(e){return Object.getOwnPropertyNames(e)};function By(t){console&&console.warn&&console.warn(t)}var _0=Number.isNaN||function(e){return e!==e};function _t(){_t.init.call(this)}nr.exports=_t,nr.exports.once=ky,_t.EventEmitter=_t,_t.prototype._events=void 0,_t.prototype._eventsCount=0,_t.prototype._maxListeners=void 0;var x0=10;function Pc(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(_t,"defaultMaxListeners",{enumerable:!0,get:function(){return x0},set:function(t){if(typeof t!="number"||t<0||_0(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");x0=t}}),_t.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},_t.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||_0(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 E0(t){return t._maxListeners===void 0?_t.defaultMaxListeners:t._maxListeners}_t.prototype.getMaxListeners=function(){return E0(this)},_t.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")w0(c,this,r);else for(var l=c.length,u=M0(c,l),i=0;i<l;++i)w0(u[i],this,r);return!0};function $0(t,e,r,i){var n,s,o;if(Pc(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=E0(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,By(a)}return t}_t.prototype.addListener=function(e,r){return $0(this,e,r,!1)},_t.prototype.on=_t.prototype.addListener,_t.prototype.prependListener=function(e,r){return $0(this,e,r,!0)};function Uy(){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 S0(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Uy.bind(i);return n.listener=r,i.wrapFn=n,n}_t.prototype.once=function(e,r){return Pc(r),this.on(e,S0(this,e,r)),this},_t.prototype.prependOnceListener=function(e,r){return Pc(r),this.prependListener(e,S0(this,e,r)),this},_t.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Pc(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():qy(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},_t.prototype.off=_t.prototype.removeListener,_t.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 I0(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?jy(n):M0(n,n.length)}_t.prototype.listeners=function(e){return I0(this,e,!0)},_t.prototype.rawListeners=function(e){return I0(this,e,!1)},_t.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):A0.call(t,e)},_t.prototype.listenerCount=A0;function A0(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}_t.prototype.eventNames=function(){return this._eventsCount>0?Mc(this._events):[]};function M0(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function qy(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function jy(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ky(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))}P0(t,e,s,{once:!0}),e!=="error"&&zy(t,n,{once:!0})})}function zy(t,e,r){typeof t.on=="function"&&P0(t,"error",e,r)}function P0(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 O0=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))},Hy=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Wy=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Vy=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}(),Ky=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Gy=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Jy=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Zy=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,C0=3,Yy=[["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",Jy]],D0=[["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 Xy(t){return t?R0(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Gy:typeof navigator<"u"?R0(navigator.userAgent):tw()}function Qy(t){return t!==""&&Yy.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 R0(t){var e=Qy(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Ky;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<C0&&(n=O0(O0([],n,!0),rw(C0-n.length),!0)):n=[];var s=n.join("."),o=ew(t),a=Zy.exec(t);return a&&a[1]?new Vy(r,s,o,a[1]):new Hy(r,s,o)}function ew(t){for(var e=0,r=D0.length;e<r;e++){var i=D0[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function tw(){var t=typeof process<"u"&&process.version;return t?new Wy(process.version.slice(1)):null}function rw(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var X={};/*! *****************************************************************************
|
|
1
|
+
(function(Ur,wt){typeof exports=="object"&&typeof module<"u"?wt(exports):typeof define=="function"&&define.amd?define(["exports"],wt):(Ur=typeof globalThis<"u"?globalThis:Ur||self,wt(Ur["@walletconnect/ethereum-provider"]={}))})(this,function(Ur){"use strict";var wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function zu(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var Lt={exports:{}},Is=typeof Reflect=="object"?Reflect:null,W0=Is&&typeof Is.apply=="function"?Is.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Pc;Is&&typeof Is.ownKeys=="function"?Pc=Is.ownKeys:Object.getOwnPropertySymbols?Pc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Pc=function(e){return Object.getOwnPropertyNames(e)};function Hw(t){console&&console.warn&&console.warn(t)}var V0=Number.isNaN||function(e){return e!==e};function Ee(){Ee.init.call(this)}Lt.exports=Ee,Lt.exports.once=Gw,Ee.EventEmitter=Ee,Ee.prototype._events=void 0,Ee.prototype._eventsCount=0,Ee.prototype._maxListeners=void 0;var K0=10;function Oc(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ee,"defaultMaxListeners",{enumerable:!0,get:function(){return K0},set:function(t){if(typeof t!="number"||t<0||V0(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");K0=t}}),Ee.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},Ee.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||V0(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 G0(t){return t._maxListeners===void 0?Ee.defaultMaxListeners:t._maxListeners}Ee.prototype.getMaxListeners=function(){return G0(this)},Ee.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")W0(c,this,r);else for(var l=c.length,u=X0(c,l),i=0;i<l;++i)W0(u[i],this,r);return!0};function Z0(t,e,r,i){var n,s,o;if(Oc(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=G0(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,Hw(a)}return t}Ee.prototype.addListener=function(e,r){return Z0(this,e,r,!1)},Ee.prototype.on=Ee.prototype.addListener,Ee.prototype.prependListener=function(e,r){return Z0(this,e,r,!0)};function Ww(){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 Y0(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Ww.bind(i);return n.listener=r,i.wrapFn=n,n}Ee.prototype.once=function(e,r){return Oc(r),this.on(e,Y0(this,e,r)),this},Ee.prototype.prependOnceListener=function(e,r){return Oc(r),this.prependListener(e,Y0(this,e,r)),this},Ee.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Oc(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():Vw(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Ee.prototype.off=Ee.prototype.removeListener,Ee.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 J0(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?Kw(n):X0(n,n.length)}Ee.prototype.listeners=function(e){return J0(this,e,!0)},Ee.prototype.rawListeners=function(e){return J0(this,e,!1)},Ee.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Q0.call(t,e)},Ee.prototype.listenerCount=Q0;function Q0(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}Ee.prototype.eventNames=function(){return this._eventsCount>0?Pc(this._events):[]};function X0(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Vw(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Kw(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Gw(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"&&Zw(t,n,{once:!0})})}function Zw(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 tp=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))},Yw=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Jw=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Qw=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}(),Xw=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),e3=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),t3=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,r3=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,rp=3,i3=[["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",t3]],ip=[["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 n3(t){return t?np(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new e3:typeof navigator<"u"?np(navigator.userAgent):a3()}function s3(t){return t!==""&&i3.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 np(t){var e=s3(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Xw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<rp&&(n=tp(tp([],n,!0),c3(rp-n.length),!0)):n=[];var s=n.join("."),o=o3(t),a=r3.exec(t);return a&&a[1]?new Qw(r,s,o,a[1]):new Yw(r,s,o)}function o3(t){for(var e=0,r=ip.length;e<r;e++){var i=ip[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function a3(){var t=typeof process<"u"&&process.version;return t?new Jw(process.version.slice(1)):null}function c3(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var V={};/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,23 +11,19 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var Dh=function(t,e){return Dh=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])},Dh(t,e)};function iw(t,e){Dh(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Rh=function(){return Rh=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},Rh.apply(this,arguments)};function nw(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 sw(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 ow(t,e){return function(r,i){e(r,i,t)}}function aw(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function cw(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(u){try{l(i.next(u))}catch(m){o(m)}}function c(u){try{l(i.throw(u))}catch(m){o(m)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(t,e||[])).next())})}function lw(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(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function hw(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function fw(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Nh(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 N0(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 uw(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(N0(arguments[e]));return t}function dw(){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 da(t){return this instanceof da?(this.v=t,this):new da(t)}function pw(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(x){i[x]&&(n[x]=function(S){return new Promise(function(E,A){s.push([x,S,E,A])>1||a(x,S)})})}function a(x,S){try{c(i[x](S))}catch(E){m(s[0][3],E)}}function c(x){x.value instanceof da?Promise.resolve(x.value.v).then(l,u):m(s[0][2],x)}function l(x){a("next",x)}function u(x){a("throw",x)}function m(x,S){x(S),s.shift(),s.length&&a(s[0][0],s[0][1])}}function gw(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:da(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function vw(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 Nh=="function"?Nh(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(l){s({value:l,done:a})},o)}}function mw(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function bw(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 yw(t){return t&&t.__esModule?t:{default:t}}function ww(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function _w(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var xw=Object.freeze({__proto__:null,__extends:iw,get __assign(){return Rh},__rest:nw,__decorate:sw,__param:ow,__metadata:aw,__awaiter:cw,__generator:lw,__createBinding:hw,__exportStar:fw,__values:Nh,__read:N0,__spread:uw,__spreadArrays:dw,__await:da,__asyncGenerator:pw,__asyncDelegator:gw,__asyncValues:vw,__makeTemplateObject:mw,__importStar:bw,__importDefault:yw,__classPrivateFieldGet:ww,__classPrivateFieldSet:_w}),Oc=Ch(xw),Th={},pa={},T0;function Ew(){if(T0)return pa;T0=1,Object.defineProperty(pa,"__esModule",{value:!0}),pa.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return pa.delay=t,pa}var fs={},Fh={},us={},F0;function $w(){return F0||(F0=1,Object.defineProperty(us,"__esModule",{value:!0}),us.ONE_THOUSAND=us.ONE_HUNDRED=void 0,us.ONE_HUNDRED=100,us.ONE_THOUSAND=1e3),us}var Lh={},L0;function Sw(){return L0||(L0=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}(Lh)),Lh}var B0;function U0(){return B0||(B0=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Oc;e.__exportStar($w(),t),e.__exportStar(Sw(),t)}(Fh)),Fh}var q0;function Iw(){if(q0)return fs;q0=1,Object.defineProperty(fs,"__esModule",{value:!0}),fs.fromMiliseconds=fs.toMiliseconds=void 0;const t=U0();function e(i){return i*t.ONE_THOUSAND}fs.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return fs.fromMiliseconds=r,fs}var j0;function Aw(){return j0||(j0=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Oc;e.__exportStar(Ew(),t),e.__exportStar(Iw(),t)}(Th)),Th}var Xs={},k0;function Mw(){if(k0)return Xs;k0=1,Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.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 Xs.Watch=t,Xs.default=t,Xs}var Bh={},ga={},z0;function Pw(){if(z0)return ga;z0=1,Object.defineProperty(ga,"__esModule",{value:!0}),ga.IWatch=void 0;class t{}return ga.IWatch=t,ga}var H0;function Ow(){return H0||(H0=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Oc.__exportStar(Pw(),t)}(Bh)),Bh}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Oc;e.__exportStar(Aw(),t),e.__exportStar(Mw(),t),e.__exportStar(Ow(),t),e.__exportStar(U0(),t)})(X);var Et={};Object.defineProperty(Et,"__esModule",{value:!0}),Et.getLocalStorage=Et.getLocalStorageOrThrow=Et.getCrypto=Et.getCryptoOrThrow=W0=Et.getLocation=Et.getLocationOrThrow=Uh=Et.getNavigator=Et.getNavigatorOrThrow=va=Et.getDocument=Et.getDocumentOrThrow=Et.getFromWindowOrThrow=Et.getFromWindow=void 0;function ds(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Et.getFromWindow=ds;function Qs(t){const e=ds(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Et.getFromWindowOrThrow=Qs;function Cw(){return Qs("document")}Et.getDocumentOrThrow=Cw;function Dw(){return ds("document")}var va=Et.getDocument=Dw;function Rw(){return Qs("navigator")}Et.getNavigatorOrThrow=Rw;function Nw(){return ds("navigator")}var Uh=Et.getNavigator=Nw;function Tw(){return Qs("location")}Et.getLocationOrThrow=Tw;function Fw(){return ds("location")}var W0=Et.getLocation=Fw;function Lw(){return Qs("crypto")}Et.getCryptoOrThrow=Lw;function Bw(){return ds("crypto")}Et.getCrypto=Bw;function Uw(){return Qs("localStorage")}Et.getLocalStorageOrThrow=Uw;function qw(){return ds("localStorage")}Et.getLocalStorage=qw;var qh={};Object.defineProperty(qh,"__esModule",{value:!0});var V0=qh.getWindowMetadata=void 0;const K0=Et;function jw(){let t,e;try{t=K0.getDocumentOrThrow(),e=K0.getLocationOrThrow()}catch{return null}function r(){const m=t.getElementsByTagName("link"),x=[];for(let S=0;S<m.length;S++){const E=m[S],A=E.getAttribute("rel");if(A&&A.toLowerCase().indexOf("icon")>-1){const R=E.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let O=e.protocol+"//"+e.host;if(R.indexOf("/")===0)O+=R;else{const C=e.pathname.split("/");C.pop();const N=C.join("/");O+=N+"/"+R}x.push(O)}else if(R.indexOf("//")===0){const O=e.protocol+R;x.push(O)}else x.push(R)}}return x}function i(...m){const x=t.getElementsByTagName("meta");for(let S=0;S<x.length;S++){const E=x[S],A=["itemprop","property","name"].map(R=>E.getAttribute(R)).filter(R=>R?m.includes(R):!1);if(A.length&&A){const R=E.getAttribute("content");if(R)return R}}return""}function n(){let m=i("name","og:site_name","og:title","twitter:title");return m||(m=t.title),m}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,l=r();return{description:a,url:c,icons:l,name:o}}V0=qh.getWindowMetadata=jw;const kw="logger/5.7.0";let G0=!1,J0=!1;const Cc={debug:1,default:2,info:2,warning:3,error:4,off:5};let Z0=Cc.default,jh=null;function zw(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(t){return t.message}return null}const Y0=zw();var kh;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(kh||(kh={}));var _i;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(_i||(_i={}));const X0="0123456789abcdef";class Me{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();Cc[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Z0>Cc[i])&&console.log.apply(console,r)}debug(...e){this._log(Me.levels.DEBUG,e)}info(...e){this._log(Me.levels.INFO,e)}warn(...e){this._log(Me.levels.WARNING,e)}makeError(e,r,i){if(J0)return this.makeError("censored error",r,{});r||(r=Me.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(c=>{const l=i[c];try{if(l instanceof Uint8Array){let u="";for(let m=0;m<l.length;m++)u+=X0[l[m]>>4],u+=X0[l[m]&15];n.push(c+"=Uint8Array(0x"+u+")")}else n.push(c+"="+JSON.stringify(l))}catch{n.push(c+"="+JSON.stringify(i[c].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case _i.NUMERIC_FAULT:{o="NUMERIC_FAULT";const c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case _i.CALL_EXCEPTION:case _i.INSUFFICIENT_FUNDS:case _i.MISSING_NEW:case _i.NONCE_EXPIRED:case _i.REPLACEMENT_UNDERPRICED:case _i.TRANSACTION_REPLACED:case _i.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=r,Object.keys(i).forEach(function(c){a[c]=i[c]}),a}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,Me.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n)}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n)}checkNormalize(e){Y0&&this.throwError("platform missing String.prototype.normalize",Me.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Y0})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Me.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Me.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,Me.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Me.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Me.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",Me.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Me.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return jh||(jh=new Me(kw)),jh}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Me.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),G0){if(!e)return;this.globalLogger().throwError("error censorship permanent",Me.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}J0=!!e,G0=!!r}static setLogLevel(e){const r=Cc[e.toLowerCase()];if(r==null){Me.globalLogger().warn("invalid log level - "+e);return}Z0=r}static from(e){return new Me(e)}}Me.errors=_i,Me.levels=kh;const Hw="bytes/5.7.0",Lt=new Me(Hw);function Q0(t){return!!t.toHexString}function ma(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return ma(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ww(t){return Hr(t)&&!(t.length%2)||eo(t)}function ep(t){return typeof t=="number"&&t==t&&t%1===0}function eo(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!ep(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!ep(r)||r<0||r>=256)return!1}return!0}function zt(t,e){if(e||(e={}),typeof t=="number"){Lt.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),ma(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Q0(t)&&(t=t.toHexString()),Hr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":Lt.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return ma(new Uint8Array(i))}return eo(t)?ma(new Uint8Array(t)):Lt.throwArgumentError("invalid arrayify value","value",t)}function Vw(t,e){t=zt(t),t.length>e&&Lt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),ma(r)}function Hr(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const zh="0123456789abcdef";function xr(t,e){if(e||(e={}),typeof t=="number"){Lt.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=zh[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Q0(t))return t.toHexString();if(Hr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":Lt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(eo(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=zh[(n&240)>>4]+zh[n&15]}return r}return Lt.throwArgumentError("invalid hexlify value","value",t)}function Kw(t){if(typeof t!="string")t=xr(t);else if(!Hr(t)||t.length%2)return null;return(t.length-2)/2}function tp(t,e,r){return typeof t!="string"?t=xr(t):(!Hr(t)||t.length%2)&&Lt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Nn(t,e){for(typeof t!="string"?t=xr(t):Hr(t)||Lt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Lt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function rp(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Ww(t)){let r=zt(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=xr(r.slice(0,32)),e.s=xr(r.slice(32,64))):r.length===65?(e.r=xr(r.slice(0,32)),e.s=xr(r.slice(32,64)),e.v=r[64]):Lt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:Lt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=xr(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const n=Vw(zt(e._vs),32);e._vs=xr(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&Lt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=xr(n);e.s==null?e.s=o:e.s!==o&&Lt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?Lt.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&Lt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Hr(e.r)?Lt.throwArgumentError("signature missing or invalid r","signature",t):e.r=Nn(e.r,32),e.s==null||!Hr(e.s)?Lt.throwArgumentError("signature missing or invalid s","signature",t):e.s=Nn(e.s,32);const r=zt(e.s);r[0]>=128&&Lt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=xr(r);e._vs&&(Hr(e._vs)||Lt.throwArgumentError("signature invalid _vs","signature",t),e._vs=Nn(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&Lt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var ip={exports:{}},Gw={},Jw=Object.freeze({__proto__:null,default:Gw}),Hh=Ch(Jw);(function(t){(function(e,r){function i(g,h){if(!g)throw new Error(h||"Assertion failed")}function n(g,h){g.super_=h;var f=function(){};f.prototype=h.prototype,g.prototype=new f,g.prototype.constructor=g}function s(g,h,f){if(s.isBN(g))return g;this.negative=0,this.words=null,this.length=0,this.red=null,g!==null&&((h==="le"||h==="be")&&(f=h,h=10),this._init(g||0,h||10,f||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Hh.Buffer}catch{}s.isBN=function(h){return h instanceof s?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===s.wordSize&&Array.isArray(h.words)},s.max=function(h,f){return h.cmp(f)>0?h:f},s.min=function(h,f){return h.cmp(f)<0?h:f},s.prototype._init=function(h,f,p){if(typeof h=="number")return this._initNumber(h,f,p);if(typeof h=="object")return this._initArray(h,f,p);f==="hex"&&(f=16),i(f===(f|0)&&f>=2&&f<=36),h=h.toString().replace(/\s+/g,"");var _=0;h[0]==="-"&&(_++,this.negative=1),_<h.length&&(f===16?this._parseHex(h,_,p):(this._parseBase(h,f,_),p==="le"&&this._initArray(this.toArray(),f,p)))},s.prototype._initNumber=function(h,f,p){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(i(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),f,p)},s.prototype._initArray=function(h,f,p){if(i(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var $,y,d=0;if(p==="be")for(_=h.length-1,$=0;_>=0;_-=3)y=h[_]|h[_-1]<<8|h[_-2]<<16,this.words[$]|=y<<d&67108863,this.words[$+1]=y>>>26-d&67108863,d+=24,d>=26&&(d-=26,$++);else if(p==="le")for(_=0,$=0;_<h.length;_+=3)y=h[_]|h[_+1]<<8|h[_+2]<<16,this.words[$]|=y<<d&67108863,this.words[$+1]=y>>>26-d&67108863,d+=24,d>=26&&(d-=26,$++);return this._strip()};function a(g,h){var f=g.charCodeAt(h);if(f>=48&&f<=57)return f-48;if(f>=65&&f<=70)return f-55;if(f>=97&&f<=102)return f-87;i(!1,"Invalid character in "+g)}function c(g,h,f){var p=a(g,f);return f-1>=h&&(p|=a(g,f-1)<<4),p}s.prototype._parseHex=function(h,f,p){this.length=Math.ceil((h.length-f)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var $=0,y=0,d;if(p==="be")for(_=h.length-1;_>=f;_-=2)d=c(h,f,_)<<$,this.words[y]|=d&67108863,$>=18?($-=18,y+=1,this.words[y]|=d>>>26):$+=8;else{var w=h.length-f;for(_=w%2===0?f+1:f;_<h.length;_+=2)d=c(h,f,_)<<$,this.words[y]|=d&67108863,$>=18?($-=18,y+=1,this.words[y]|=d>>>26):$+=8}this._strip()};function l(g,h,f,p){for(var _=0,$=0,y=Math.min(g.length,f),d=h;d<y;d++){var w=g.charCodeAt(d)-48;_*=p,w>=49?$=w-49+10:w>=17?$=w-17+10:$=w,i(w>=0&&$<p,"Invalid character"),_+=$}return _}s.prototype._parseBase=function(h,f,p){this.words=[0],this.length=1;for(var _=0,$=1;$<=67108863;$*=f)_++;_--,$=$/f|0;for(var y=h.length-p,d=y%_,w=Math.min(y,y-d)+p,b=0,P=p;P<w;P+=_)b=l(h,P,P+_,f),this.imuln($),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b);if(d!==0){var q=1;for(b=l(h,P,h.length,f),P=0;P<d;P++)q*=f;this.imuln(q),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b)}this._strip()},s.prototype.copy=function(h){h.words=new Array(this.length);for(var f=0;f<this.length;f++)h.words[f]=this.words[f];h.length=this.length,h.negative=this.negative,h.red=this.red};function u(g,h){g.words=h.words,g.length=h.length,g.negative=h.negative,g.red=h.red}if(s.prototype._move=function(h){u(h,this)},s.prototype.clone=function(){var h=new s(null);return this.copy(h),h},s.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch{s.prototype.inspect=m}else s.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],E=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(h,f){h=h||10,f=f|0||1;var p;if(h===16||h==="hex"){p="";for(var _=0,$=0,y=0;y<this.length;y++){var d=this.words[y],w=((d<<_|$)&16777215).toString(16);$=d>>>24-_&16777215,_+=2,_>=26&&(_-=26,y--),$!==0||y!==this.length-1?p=x[6-w.length]+w+p:p=w+p}for($!==0&&(p=$.toString(16)+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(h===(h|0)&&h>=2&&h<=36){var b=S[h],P=E[h];p="";var q=this.clone();for(q.negative=0;!q.isZero();){var I=q.modrn(P).toString(h);q=q.idivn(P),q.isZero()?p=I+p:p=x[b-I.length]+I+p}for(this.isZero()&&(p="0"+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(h,f){return this.toArrayLike(o,h,f)}),s.prototype.toArray=function(h,f){return this.toArrayLike(Array,h,f)};var A=function(h,f){return h.allocUnsafe?h.allocUnsafe(f):new h(f)};s.prototype.toArrayLike=function(h,f,p){this._strip();var _=this.byteLength(),$=p||Math.max(1,_);i(_<=$,"byte array longer than desired length"),i($>0,"Requested array length <= 0");var y=A(h,$),d=f==="le"?"LE":"BE";return this["_toArrayLike"+d](y,_),y},s.prototype._toArrayLikeLE=function(h,f){for(var p=0,_=0,$=0,y=0;$<this.length;$++){var d=this.words[$]<<y|_;h[p++]=d&255,p<h.length&&(h[p++]=d>>8&255),p<h.length&&(h[p++]=d>>16&255),y===6?(p<h.length&&(h[p++]=d>>24&255),_=0,y=0):(_=d>>>24,y+=2)}if(p<h.length)for(h[p++]=_;p<h.length;)h[p++]=0},s.prototype._toArrayLikeBE=function(h,f){for(var p=h.length-1,_=0,$=0,y=0;$<this.length;$++){var d=this.words[$]<<y|_;h[p--]=d&255,p>=0&&(h[p--]=d>>8&255),p>=0&&(h[p--]=d>>16&255),y===6?(p>=0&&(h[p--]=d>>24&255),_=0,y=0):(_=d>>>24,y+=2)}if(p>=0)for(h[p--]=_;p>=0;)h[p--]=0},Math.clz32?s.prototype._countBits=function(h){return 32-Math.clz32(h)}:s.prototype._countBits=function(h){var f=h,p=0;return f>=4096&&(p+=13,f>>>=13),f>=64&&(p+=7,f>>>=7),f>=8&&(p+=4,f>>>=4),f>=2&&(p+=2,f>>>=2),p+f},s.prototype._zeroBits=function(h){if(h===0)return 26;var f=h,p=0;return(f&8191)===0&&(p+=13,f>>>=13),(f&127)===0&&(p+=7,f>>>=7),(f&15)===0&&(p+=4,f>>>=4),(f&3)===0&&(p+=2,f>>>=2),(f&1)===0&&p++,p},s.prototype.bitLength=function(){var h=this.words[this.length-1],f=this._countBits(h);return(this.length-1)*26+f};function R(g){for(var h=new Array(g.bitLength()),f=0;f<h.length;f++){var p=f/26|0,_=f%26;h[f]=g.words[p]>>>_&1}return h}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,f=0;f<this.length;f++){var p=this._zeroBits(this.words[f]);if(h+=p,p!==26)break}return h},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},s.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var f=0;f<h.length;f++)this.words[f]=this.words[f]|h.words[f];return this._strip()},s.prototype.ior=function(h){return i((this.negative|h.negative)===0),this.iuor(h)},s.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},s.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},s.prototype.iuand=function(h){var f;this.length>h.length?f=h:f=this;for(var p=0;p<f.length;p++)this.words[p]=this.words[p]&h.words[p];return this.length=f.length,this._strip()},s.prototype.iand=function(h){return i((this.negative|h.negative)===0),this.iuand(h)},s.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},s.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},s.prototype.iuxor=function(h){var f,p;this.length>h.length?(f=this,p=h):(f=h,p=this);for(var _=0;_<p.length;_++)this.words[_]=f.words[_]^p.words[_];if(this!==f)for(;_<f.length;_++)this.words[_]=f.words[_];return this.length=f.length,this._strip()},s.prototype.ixor=function(h){return i((this.negative|h.negative)===0),this.iuxor(h)},s.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},s.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},s.prototype.inotn=function(h){i(typeof h=="number"&&h>=0);var f=Math.ceil(h/26)|0,p=h%26;this._expand(f),p>0&&f--;for(var _=0;_<f;_++)this.words[_]=~this.words[_]&67108863;return p>0&&(this.words[_]=~this.words[_]&67108863>>26-p),this._strip()},s.prototype.notn=function(h){return this.clone().inotn(h)},s.prototype.setn=function(h,f){i(typeof h=="number"&&h>=0);var p=h/26|0,_=h%26;return this._expand(p+1),f?this.words[p]=this.words[p]|1<<_:this.words[p]=this.words[p]&~(1<<_),this._strip()},s.prototype.iadd=function(h){var f;if(this.negative!==0&&h.negative===0)return this.negative=0,f=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,f=this.isub(h),h.negative=1,f._normSign();var p,_;this.length>h.length?(p=this,_=h):(p=h,_=this);for(var $=0,y=0;y<_.length;y++)f=(p.words[y]|0)+(_.words[y]|0)+$,this.words[y]=f&67108863,$=f>>>26;for(;$!==0&&y<p.length;y++)f=(p.words[y]|0)+$,this.words[y]=f&67108863,$=f>>>26;if(this.length=p.length,$!==0)this.words[this.length]=$,this.length++;else if(p!==this)for(;y<p.length;y++)this.words[y]=p.words[y];return this},s.prototype.add=function(h){var f;return h.negative!==0&&this.negative===0?(h.negative=0,f=this.sub(h),h.negative^=1,f):h.negative===0&&this.negative!==0?(this.negative=0,f=h.sub(this),this.negative=1,f):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},s.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var f=this.iadd(h);return h.negative=1,f._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var p=this.cmp(h);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,$;p>0?(_=this,$=h):(_=h,$=this);for(var y=0,d=0;d<$.length;d++)f=(_.words[d]|0)-($.words[d]|0)+y,y=f>>26,this.words[d]=f&67108863;for(;y!==0&&d<_.length;d++)f=(_.words[d]|0)+y,y=f>>26,this.words[d]=f&67108863;if(y===0&&d<_.length&&_!==this)for(;d<_.length;d++)this.words[d]=_.words[d];return this.length=Math.max(this.length,d),_!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(h){return this.clone().isub(h)};function O(g,h,f){f.negative=h.negative^g.negative;var p=g.length+h.length|0;f.length=p,p=p-1|0;var _=g.words[0]|0,$=h.words[0]|0,y=_*$,d=y&67108863,w=y/67108864|0;f.words[0]=d;for(var b=1;b<p;b++){for(var P=w>>>26,q=w&67108863,I=Math.min(b,h.length-1),F=Math.max(0,b-g.length+1);F<=I;F++){var j=b-F|0;_=g.words[j]|0,$=h.words[F]|0,y=_*$+q,P+=y/67108864|0,q=y&67108863}f.words[b]=q|0,w=P|0}return w!==0?f.words[b]=w|0:f.length--,f._strip()}var C=function(h,f,p){var _=h.words,$=f.words,y=p.words,d=0,w,b,P,q=_[0]|0,I=q&8191,F=q>>>13,j=_[1]|0,k=j&8191,H=j>>>13,Y=_[2]|0,Q=Y&8191,J=Y>>>13,ae=_[3]|0,re=ae&8191,ie=ae>>>13,Ze=_[4]|0,Ye=Ze&8191,de=Ze>>>13,qe=_[5]|0,je=qe&8191,he=qe>>>13,ke=_[6]|0,ze=ke&8191,ue=ke>>>13,He=_[7]|0,We=He&8191,le=He>>>13,Be=_[8]|0,Ve=Be&8191,oe=Be>>>13,nt=_[9]|0,st=nt&8191,me=nt>>>13,ot=$[0]|0,Ke=ot&8191,ge=ot>>>13,at=$[1]|0,ft=at&8191,ce=at>>>13,ct=$[2]|0,ut=ct&8191,be=ct>>>13,Xe=$[3]|0,Ue=Xe&8191,pe=Xe>>>13,Qe=$[4]|0,et=Qe&8191,fe=Qe>>>13,dt=$[5]|0,pt=dt&8191,ye=dt>>>13,gt=$[6]|0,vt=gt&8191,ve=gt>>>13,tt=$[7]|0,Re=tt&8191,we=tt>>>13,mt=$[8]|0,bt=mt&8191,_e=mt>>>13,yt=$[9]|0,Ae=yt&8191,lt=yt>>>13;p.negative=h.negative^f.negative,p.length=19,w=Math.imul(I,Ke),b=Math.imul(I,ge),b=b+Math.imul(F,Ke)|0,P=Math.imul(F,ge);var qr=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(qr>>>26)|0,qr&=67108863,w=Math.imul(k,Ke),b=Math.imul(k,ge),b=b+Math.imul(H,Ke)|0,P=Math.imul(H,ge),w=w+Math.imul(I,ft)|0,b=b+Math.imul(I,ce)|0,b=b+Math.imul(F,ft)|0,P=P+Math.imul(F,ce)|0;var jr=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(jr>>>26)|0,jr&=67108863,w=Math.imul(Q,Ke),b=Math.imul(Q,ge),b=b+Math.imul(J,Ke)|0,P=Math.imul(J,ge),w=w+Math.imul(k,ft)|0,b=b+Math.imul(k,ce)|0,b=b+Math.imul(H,ft)|0,P=P+Math.imul(H,ce)|0,w=w+Math.imul(I,ut)|0,b=b+Math.imul(I,be)|0,b=b+Math.imul(F,ut)|0,P=P+Math.imul(F,be)|0;var kr=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(kr>>>26)|0,kr&=67108863,w=Math.imul(re,Ke),b=Math.imul(re,ge),b=b+Math.imul(ie,Ke)|0,P=Math.imul(ie,ge),w=w+Math.imul(Q,ft)|0,b=b+Math.imul(Q,ce)|0,b=b+Math.imul(J,ft)|0,P=P+Math.imul(J,ce)|0,w=w+Math.imul(k,ut)|0,b=b+Math.imul(k,be)|0,b=b+Math.imul(H,ut)|0,P=P+Math.imul(H,be)|0,w=w+Math.imul(I,Ue)|0,b=b+Math.imul(I,pe)|0,b=b+Math.imul(F,Ue)|0,P=P+Math.imul(F,pe)|0;var zr=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(zr>>>26)|0,zr&=67108863,w=Math.imul(Ye,Ke),b=Math.imul(Ye,ge),b=b+Math.imul(de,Ke)|0,P=Math.imul(de,ge),w=w+Math.imul(re,ft)|0,b=b+Math.imul(re,ce)|0,b=b+Math.imul(ie,ft)|0,P=P+Math.imul(ie,ce)|0,w=w+Math.imul(Q,ut)|0,b=b+Math.imul(Q,be)|0,b=b+Math.imul(J,ut)|0,P=P+Math.imul(J,be)|0,w=w+Math.imul(k,Ue)|0,b=b+Math.imul(k,pe)|0,b=b+Math.imul(H,Ue)|0,P=P+Math.imul(H,pe)|0,w=w+Math.imul(I,et)|0,b=b+Math.imul(I,fe)|0,b=b+Math.imul(F,et)|0,P=P+Math.imul(F,fe)|0;var kt=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(kt>>>26)|0,kt&=67108863,w=Math.imul(je,Ke),b=Math.imul(je,ge),b=b+Math.imul(he,Ke)|0,P=Math.imul(he,ge),w=w+Math.imul(Ye,ft)|0,b=b+Math.imul(Ye,ce)|0,b=b+Math.imul(de,ft)|0,P=P+Math.imul(de,ce)|0,w=w+Math.imul(re,ut)|0,b=b+Math.imul(re,be)|0,b=b+Math.imul(ie,ut)|0,P=P+Math.imul(ie,be)|0,w=w+Math.imul(Q,Ue)|0,b=b+Math.imul(Q,pe)|0,b=b+Math.imul(J,Ue)|0,P=P+Math.imul(J,pe)|0,w=w+Math.imul(k,et)|0,b=b+Math.imul(k,fe)|0,b=b+Math.imul(H,et)|0,P=P+Math.imul(H,fe)|0,w=w+Math.imul(I,pt)|0,b=b+Math.imul(I,ye)|0,b=b+Math.imul(F,pt)|0,P=P+Math.imul(F,ye)|0;var En=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(En>>>26)|0,En&=67108863,w=Math.imul(ze,Ke),b=Math.imul(ze,ge),b=b+Math.imul(ue,Ke)|0,P=Math.imul(ue,ge),w=w+Math.imul(je,ft)|0,b=b+Math.imul(je,ce)|0,b=b+Math.imul(he,ft)|0,P=P+Math.imul(he,ce)|0,w=w+Math.imul(Ye,ut)|0,b=b+Math.imul(Ye,be)|0,b=b+Math.imul(de,ut)|0,P=P+Math.imul(de,be)|0,w=w+Math.imul(re,Ue)|0,b=b+Math.imul(re,pe)|0,b=b+Math.imul(ie,Ue)|0,P=P+Math.imul(ie,pe)|0,w=w+Math.imul(Q,et)|0,b=b+Math.imul(Q,fe)|0,b=b+Math.imul(J,et)|0,P=P+Math.imul(J,fe)|0,w=w+Math.imul(k,pt)|0,b=b+Math.imul(k,ye)|0,b=b+Math.imul(H,pt)|0,P=P+Math.imul(H,ye)|0,w=w+Math.imul(I,vt)|0,b=b+Math.imul(I,ve)|0,b=b+Math.imul(F,vt)|0,P=P+Math.imul(F,ve)|0;var $n=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+($n>>>26)|0,$n&=67108863,w=Math.imul(We,Ke),b=Math.imul(We,ge),b=b+Math.imul(le,Ke)|0,P=Math.imul(le,ge),w=w+Math.imul(ze,ft)|0,b=b+Math.imul(ze,ce)|0,b=b+Math.imul(ue,ft)|0,P=P+Math.imul(ue,ce)|0,w=w+Math.imul(je,ut)|0,b=b+Math.imul(je,be)|0,b=b+Math.imul(he,ut)|0,P=P+Math.imul(he,be)|0,w=w+Math.imul(Ye,Ue)|0,b=b+Math.imul(Ye,pe)|0,b=b+Math.imul(de,Ue)|0,P=P+Math.imul(de,pe)|0,w=w+Math.imul(re,et)|0,b=b+Math.imul(re,fe)|0,b=b+Math.imul(ie,et)|0,P=P+Math.imul(ie,fe)|0,w=w+Math.imul(Q,pt)|0,b=b+Math.imul(Q,ye)|0,b=b+Math.imul(J,pt)|0,P=P+Math.imul(J,ye)|0,w=w+Math.imul(k,vt)|0,b=b+Math.imul(k,ve)|0,b=b+Math.imul(H,vt)|0,P=P+Math.imul(H,ve)|0,w=w+Math.imul(I,Re)|0,b=b+Math.imul(I,we)|0,b=b+Math.imul(F,Re)|0,P=P+Math.imul(F,we)|0;var Sn=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,w=Math.imul(Ve,Ke),b=Math.imul(Ve,ge),b=b+Math.imul(oe,Ke)|0,P=Math.imul(oe,ge),w=w+Math.imul(We,ft)|0,b=b+Math.imul(We,ce)|0,b=b+Math.imul(le,ft)|0,P=P+Math.imul(le,ce)|0,w=w+Math.imul(ze,ut)|0,b=b+Math.imul(ze,be)|0,b=b+Math.imul(ue,ut)|0,P=P+Math.imul(ue,be)|0,w=w+Math.imul(je,Ue)|0,b=b+Math.imul(je,pe)|0,b=b+Math.imul(he,Ue)|0,P=P+Math.imul(he,pe)|0,w=w+Math.imul(Ye,et)|0,b=b+Math.imul(Ye,fe)|0,b=b+Math.imul(de,et)|0,P=P+Math.imul(de,fe)|0,w=w+Math.imul(re,pt)|0,b=b+Math.imul(re,ye)|0,b=b+Math.imul(ie,pt)|0,P=P+Math.imul(ie,ye)|0,w=w+Math.imul(Q,vt)|0,b=b+Math.imul(Q,ve)|0,b=b+Math.imul(J,vt)|0,P=P+Math.imul(J,ve)|0,w=w+Math.imul(k,Re)|0,b=b+Math.imul(k,we)|0,b=b+Math.imul(H,Re)|0,P=P+Math.imul(H,we)|0,w=w+Math.imul(I,bt)|0,b=b+Math.imul(I,_e)|0,b=b+Math.imul(F,bt)|0,P=P+Math.imul(F,_e)|0;var In=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(In>>>26)|0,In&=67108863,w=Math.imul(st,Ke),b=Math.imul(st,ge),b=b+Math.imul(me,Ke)|0,P=Math.imul(me,ge),w=w+Math.imul(Ve,ft)|0,b=b+Math.imul(Ve,ce)|0,b=b+Math.imul(oe,ft)|0,P=P+Math.imul(oe,ce)|0,w=w+Math.imul(We,ut)|0,b=b+Math.imul(We,be)|0,b=b+Math.imul(le,ut)|0,P=P+Math.imul(le,be)|0,w=w+Math.imul(ze,Ue)|0,b=b+Math.imul(ze,pe)|0,b=b+Math.imul(ue,Ue)|0,P=P+Math.imul(ue,pe)|0,w=w+Math.imul(je,et)|0,b=b+Math.imul(je,fe)|0,b=b+Math.imul(he,et)|0,P=P+Math.imul(he,fe)|0,w=w+Math.imul(Ye,pt)|0,b=b+Math.imul(Ye,ye)|0,b=b+Math.imul(de,pt)|0,P=P+Math.imul(de,ye)|0,w=w+Math.imul(re,vt)|0,b=b+Math.imul(re,ve)|0,b=b+Math.imul(ie,vt)|0,P=P+Math.imul(ie,ve)|0,w=w+Math.imul(Q,Re)|0,b=b+Math.imul(Q,we)|0,b=b+Math.imul(J,Re)|0,P=P+Math.imul(J,we)|0,w=w+Math.imul(k,bt)|0,b=b+Math.imul(k,_e)|0,b=b+Math.imul(H,bt)|0,P=P+Math.imul(H,_e)|0,w=w+Math.imul(I,Ae)|0,b=b+Math.imul(I,lt)|0,b=b+Math.imul(F,Ae)|0,P=P+Math.imul(F,lt)|0;var An=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(An>>>26)|0,An&=67108863,w=Math.imul(st,ft),b=Math.imul(st,ce),b=b+Math.imul(me,ft)|0,P=Math.imul(me,ce),w=w+Math.imul(Ve,ut)|0,b=b+Math.imul(Ve,be)|0,b=b+Math.imul(oe,ut)|0,P=P+Math.imul(oe,be)|0,w=w+Math.imul(We,Ue)|0,b=b+Math.imul(We,pe)|0,b=b+Math.imul(le,Ue)|0,P=P+Math.imul(le,pe)|0,w=w+Math.imul(ze,et)|0,b=b+Math.imul(ze,fe)|0,b=b+Math.imul(ue,et)|0,P=P+Math.imul(ue,fe)|0,w=w+Math.imul(je,pt)|0,b=b+Math.imul(je,ye)|0,b=b+Math.imul(he,pt)|0,P=P+Math.imul(he,ye)|0,w=w+Math.imul(Ye,vt)|0,b=b+Math.imul(Ye,ve)|0,b=b+Math.imul(de,vt)|0,P=P+Math.imul(de,ve)|0,w=w+Math.imul(re,Re)|0,b=b+Math.imul(re,we)|0,b=b+Math.imul(ie,Re)|0,P=P+Math.imul(ie,we)|0,w=w+Math.imul(Q,bt)|0,b=b+Math.imul(Q,_e)|0,b=b+Math.imul(J,bt)|0,P=P+Math.imul(J,_e)|0,w=w+Math.imul(k,Ae)|0,b=b+Math.imul(k,lt)|0,b=b+Math.imul(H,Ae)|0,P=P+Math.imul(H,lt)|0;var mi=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(mi>>>26)|0,mi&=67108863,w=Math.imul(st,ut),b=Math.imul(st,be),b=b+Math.imul(me,ut)|0,P=Math.imul(me,be),w=w+Math.imul(Ve,Ue)|0,b=b+Math.imul(Ve,pe)|0,b=b+Math.imul(oe,Ue)|0,P=P+Math.imul(oe,pe)|0,w=w+Math.imul(We,et)|0,b=b+Math.imul(We,fe)|0,b=b+Math.imul(le,et)|0,P=P+Math.imul(le,fe)|0,w=w+Math.imul(ze,pt)|0,b=b+Math.imul(ze,ye)|0,b=b+Math.imul(ue,pt)|0,P=P+Math.imul(ue,ye)|0,w=w+Math.imul(je,vt)|0,b=b+Math.imul(je,ve)|0,b=b+Math.imul(he,vt)|0,P=P+Math.imul(he,ve)|0,w=w+Math.imul(Ye,Re)|0,b=b+Math.imul(Ye,we)|0,b=b+Math.imul(de,Re)|0,P=P+Math.imul(de,we)|0,w=w+Math.imul(re,bt)|0,b=b+Math.imul(re,_e)|0,b=b+Math.imul(ie,bt)|0,P=P+Math.imul(ie,_e)|0,w=w+Math.imul(Q,Ae)|0,b=b+Math.imul(Q,lt)|0,b=b+Math.imul(J,Ae)|0,P=P+Math.imul(J,lt)|0;var Mn=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,w=Math.imul(st,Ue),b=Math.imul(st,pe),b=b+Math.imul(me,Ue)|0,P=Math.imul(me,pe),w=w+Math.imul(Ve,et)|0,b=b+Math.imul(Ve,fe)|0,b=b+Math.imul(oe,et)|0,P=P+Math.imul(oe,fe)|0,w=w+Math.imul(We,pt)|0,b=b+Math.imul(We,ye)|0,b=b+Math.imul(le,pt)|0,P=P+Math.imul(le,ye)|0,w=w+Math.imul(ze,vt)|0,b=b+Math.imul(ze,ve)|0,b=b+Math.imul(ue,vt)|0,P=P+Math.imul(ue,ve)|0,w=w+Math.imul(je,Re)|0,b=b+Math.imul(je,we)|0,b=b+Math.imul(he,Re)|0,P=P+Math.imul(he,we)|0,w=w+Math.imul(Ye,bt)|0,b=b+Math.imul(Ye,_e)|0,b=b+Math.imul(de,bt)|0,P=P+Math.imul(de,_e)|0,w=w+Math.imul(re,Ae)|0,b=b+Math.imul(re,lt)|0,b=b+Math.imul(ie,Ae)|0,P=P+Math.imul(ie,lt)|0;var Pn=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,w=Math.imul(st,et),b=Math.imul(st,fe),b=b+Math.imul(me,et)|0,P=Math.imul(me,fe),w=w+Math.imul(Ve,pt)|0,b=b+Math.imul(Ve,ye)|0,b=b+Math.imul(oe,pt)|0,P=P+Math.imul(oe,ye)|0,w=w+Math.imul(We,vt)|0,b=b+Math.imul(We,ve)|0,b=b+Math.imul(le,vt)|0,P=P+Math.imul(le,ve)|0,w=w+Math.imul(ze,Re)|0,b=b+Math.imul(ze,we)|0,b=b+Math.imul(ue,Re)|0,P=P+Math.imul(ue,we)|0,w=w+Math.imul(je,bt)|0,b=b+Math.imul(je,_e)|0,b=b+Math.imul(he,bt)|0,P=P+Math.imul(he,_e)|0,w=w+Math.imul(Ye,Ae)|0,b=b+Math.imul(Ye,lt)|0,b=b+Math.imul(de,Ae)|0,P=P+Math.imul(de,lt)|0;var wr=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(wr>>>26)|0,wr&=67108863,w=Math.imul(st,pt),b=Math.imul(st,ye),b=b+Math.imul(me,pt)|0,P=Math.imul(me,ye),w=w+Math.imul(Ve,vt)|0,b=b+Math.imul(Ve,ve)|0,b=b+Math.imul(oe,vt)|0,P=P+Math.imul(oe,ve)|0,w=w+Math.imul(We,Re)|0,b=b+Math.imul(We,we)|0,b=b+Math.imul(le,Re)|0,P=P+Math.imul(le,we)|0,w=w+Math.imul(ze,bt)|0,b=b+Math.imul(ze,_e)|0,b=b+Math.imul(ue,bt)|0,P=P+Math.imul(ue,_e)|0,w=w+Math.imul(je,Ae)|0,b=b+Math.imul(je,lt)|0,b=b+Math.imul(he,Ae)|0,P=P+Math.imul(he,lt)|0;var On=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(On>>>26)|0,On&=67108863,w=Math.imul(st,vt),b=Math.imul(st,ve),b=b+Math.imul(me,vt)|0,P=Math.imul(me,ve),w=w+Math.imul(Ve,Re)|0,b=b+Math.imul(Ve,we)|0,b=b+Math.imul(oe,Re)|0,P=P+Math.imul(oe,we)|0,w=w+Math.imul(We,bt)|0,b=b+Math.imul(We,_e)|0,b=b+Math.imul(le,bt)|0,P=P+Math.imul(le,_e)|0,w=w+Math.imul(ze,Ae)|0,b=b+Math.imul(ze,lt)|0,b=b+Math.imul(ue,Ae)|0,P=P+Math.imul(ue,lt)|0;var Cn=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,w=Math.imul(st,Re),b=Math.imul(st,we),b=b+Math.imul(me,Re)|0,P=Math.imul(me,we),w=w+Math.imul(Ve,bt)|0,b=b+Math.imul(Ve,_e)|0,b=b+Math.imul(oe,bt)|0,P=P+Math.imul(oe,_e)|0,w=w+Math.imul(We,Ae)|0,b=b+Math.imul(We,lt)|0,b=b+Math.imul(le,Ae)|0,P=P+Math.imul(le,lt)|0;var Dn=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,w=Math.imul(st,bt),b=Math.imul(st,_e),b=b+Math.imul(me,bt)|0,P=Math.imul(me,_e),w=w+Math.imul(Ve,Ae)|0,b=b+Math.imul(Ve,lt)|0,b=b+Math.imul(oe,Ae)|0,P=P+Math.imul(oe,lt)|0;var $c=(d+w|0)+((b&8191)<<13)|0;d=(P+(b>>>13)|0)+($c>>>26)|0,$c&=67108863,w=Math.imul(st,Ae),b=Math.imul(st,lt),b=b+Math.imul(me,Ae)|0,P=Math.imul(me,lt);var Sc=(d+w|0)+((b&8191)<<13)|0;return d=(P+(b>>>13)|0)+(Sc>>>26)|0,Sc&=67108863,y[0]=qr,y[1]=jr,y[2]=kr,y[3]=zr,y[4]=kt,y[5]=En,y[6]=$n,y[7]=Sn,y[8]=In,y[9]=An,y[10]=mi,y[11]=Mn,y[12]=Pn,y[13]=wr,y[14]=On,y[15]=Cn,y[16]=Dn,y[17]=$c,y[18]=Sc,d!==0&&(y[19]=d,p.length++),p};Math.imul||(C=O);function N(g,h,f){f.negative=h.negative^g.negative,f.length=g.length+h.length;for(var p=0,_=0,$=0;$<f.length-1;$++){var y=_;_=0;for(var d=p&67108863,w=Math.min($,h.length-1),b=Math.max(0,$-g.length+1);b<=w;b++){var P=$-b,q=g.words[P]|0,I=h.words[b]|0,F=q*I,j=F&67108863;y=y+(F/67108864|0)|0,j=j+d|0,d=j&67108863,y=y+(j>>>26)|0,_+=y>>>26,y&=67108863}f.words[$]=d,p=y,y=_}return p!==0?f.words[$]=p:f.length--,f._strip()}function T(g,h,f){return N(g,h,f)}s.prototype.mulTo=function(h,f){var p,_=this.length+h.length;return this.length===10&&h.length===10?p=C(this,h,f):_<63?p=O(this,h,f):_<1024?p=N(this,h,f):p=T(this,h,f),p},s.prototype.mul=function(h){var f=new s(null);return f.words=new Array(this.length+h.length),this.mulTo(h,f)},s.prototype.mulf=function(h){var f=new s(null);return f.words=new Array(this.length+h.length),T(this,h,f)},s.prototype.imul=function(h){return this.clone().mulTo(h,this)},s.prototype.imuln=function(h){var f=h<0;f&&(h=-h),i(typeof h=="number"),i(h<67108864);for(var p=0,_=0;_<this.length;_++){var $=(this.words[_]|0)*h,y=($&67108863)+(p&67108863);p>>=26,p+=$/67108864|0,p+=y>>>26,this.words[_]=y&67108863}return p!==0&&(this.words[_]=p,this.length++),f?this.ineg():this},s.prototype.muln=function(h){return this.clone().imuln(h)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(h){var f=R(h);if(f.length===0)return new s(1);for(var p=this,_=0;_<f.length&&f[_]===0;_++,p=p.sqr());if(++_<f.length)for(var $=p.sqr();_<f.length;_++,$=$.sqr())f[_]!==0&&(p=p.mul($));return p},s.prototype.iushln=function(h){i(typeof h=="number"&&h>=0);var f=h%26,p=(h-f)/26,_=67108863>>>26-f<<26-f,$;if(f!==0){var y=0;for($=0;$<this.length;$++){var d=this.words[$]&_,w=(this.words[$]|0)-d<<f;this.words[$]=w|y,y=d>>>26-f}y&&(this.words[$]=y,this.length++)}if(p!==0){for($=this.length-1;$>=0;$--)this.words[$+p]=this.words[$];for($=0;$<p;$++)this.words[$]=0;this.length+=p}return this._strip()},s.prototype.ishln=function(h){return i(this.negative===0),this.iushln(h)},s.prototype.iushrn=function(h,f,p){i(typeof h=="number"&&h>=0);var _;f?_=(f-f%26)/26:_=0;var $=h%26,y=Math.min((h-$)/26,this.length),d=67108863^67108863>>>$<<$,w=p;if(_-=y,_=Math.max(0,_),w){for(var b=0;b<y;b++)w.words[b]=this.words[b];w.length=y}if(y!==0)if(this.length>y)for(this.length-=y,b=0;b<this.length;b++)this.words[b]=this.words[b+y];else this.words[0]=0,this.length=1;var P=0;for(b=this.length-1;b>=0&&(P!==0||b>=_);b--){var q=this.words[b]|0;this.words[b]=P<<26-$|q>>>$,P=q&d}return w&&P!==0&&(w.words[w.length++]=P),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(h,f,p){return i(this.negative===0),this.iushrn(h,f,p)},s.prototype.shln=function(h){return this.clone().ishln(h)},s.prototype.ushln=function(h){return this.clone().iushln(h)},s.prototype.shrn=function(h){return this.clone().ishrn(h)},s.prototype.ushrn=function(h){return this.clone().iushrn(h)},s.prototype.testn=function(h){i(typeof h=="number"&&h>=0);var f=h%26,p=(h-f)/26,_=1<<f;if(this.length<=p)return!1;var $=this.words[p];return!!($&_)},s.prototype.imaskn=function(h){i(typeof h=="number"&&h>=0);var f=h%26,p=(h-f)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(f!==0&&p++,this.length=Math.min(p,this.length),f!==0){var _=67108863^67108863>>>f<<f;this.words[this.length-1]&=_}return this._strip()},s.prototype.maskn=function(h){return this.clone().imaskn(h)},s.prototype.iaddn=function(h){return i(typeof h=="number"),i(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<=h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},s.prototype._iaddn=function(h){this.words[0]+=h;for(var f=0;f<this.length&&this.words[f]>=67108864;f++)this.words[f]-=67108864,f===this.length-1?this.words[f+1]=1:this.words[f+1]++;return this.length=Math.max(this.length,f+1),this},s.prototype.isubn=function(h){if(i(typeof h=="number"),i(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var f=0;f<this.length&&this.words[f]<0;f++)this.words[f]+=67108864,this.words[f+1]-=1;return this._strip()},s.prototype.addn=function(h){return this.clone().iaddn(h)},s.prototype.subn=function(h){return this.clone().isubn(h)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(h,f,p){var _=h.length+p,$;this._expand(_);var y,d=0;for($=0;$<h.length;$++){y=(this.words[$+p]|0)+d;var w=(h.words[$]|0)*f;y-=w&67108863,d=(y>>26)-(w/67108864|0),this.words[$+p]=y&67108863}for(;$<this.length-p;$++)y=(this.words[$+p]|0)+d,d=y>>26,this.words[$+p]=y&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,$=0;$<this.length;$++)y=-(this.words[$]|0)+d,d=y>>26,this.words[$]=y&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(h,f){var p=this.length-h.length,_=this.clone(),$=h,y=$.words[$.length-1]|0,d=this._countBits(y);p=26-d,p!==0&&($=$.ushln(p),_.iushln(p),y=$.words[$.length-1]|0);var w=_.length-$.length,b;if(f!=="mod"){b=new s(null),b.length=w+1,b.words=new Array(b.length);for(var P=0;P<b.length;P++)b.words[P]=0}var q=_.clone()._ishlnsubmul($,1,w);q.negative===0&&(_=q,b&&(b.words[w]=1));for(var I=w-1;I>=0;I--){var F=(_.words[$.length+I]|0)*67108864+(_.words[$.length+I-1]|0);for(F=Math.min(F/y|0,67108863),_._ishlnsubmul($,F,I);_.negative!==0;)F--,_.negative=0,_._ishlnsubmul($,1,I),_.isZero()||(_.negative^=1);b&&(b.words[I]=F)}return b&&b._strip(),_._strip(),f!=="div"&&p!==0&&_.iushrn(p),{div:b||null,mod:_}},s.prototype.divmod=function(h,f,p){if(i(!h.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var _,$,y;return this.negative!==0&&h.negative===0?(y=this.neg().divmod(h,f),f!=="mod"&&(_=y.div.neg()),f!=="div"&&($=y.mod.neg(),p&&$.negative!==0&&$.iadd(h)),{div:_,mod:$}):this.negative===0&&h.negative!==0?(y=this.divmod(h.neg(),f),f!=="mod"&&(_=y.div.neg()),{div:_,mod:y.mod}):(this.negative&h.negative)!==0?(y=this.neg().divmod(h.neg(),f),f!=="div"&&($=y.mod.neg(),p&&$.negative!==0&&$.isub(h)),{div:y.div,mod:$}):h.length>this.length||this.cmp(h)<0?{div:new s(0),mod:this}:h.length===1?f==="div"?{div:this.divn(h.words[0]),mod:null}:f==="mod"?{div:null,mod:new s(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new s(this.modrn(h.words[0]))}:this._wordDiv(h,f)},s.prototype.div=function(h){return this.divmod(h,"div",!1).div},s.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},s.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},s.prototype.divRound=function(h){var f=this.divmod(h);if(f.mod.isZero())return f.div;var p=f.div.negative!==0?f.mod.isub(h):f.mod,_=h.ushrn(1),$=h.andln(1),y=p.cmp(_);return y<0||$===1&&y===0?f.div:f.div.negative!==0?f.div.isubn(1):f.div.iaddn(1)},s.prototype.modrn=function(h){var f=h<0;f&&(h=-h),i(h<=67108863);for(var p=(1<<26)%h,_=0,$=this.length-1;$>=0;$--)_=(p*_+(this.words[$]|0))%h;return f?-_:_},s.prototype.modn=function(h){return this.modrn(h)},s.prototype.idivn=function(h){var f=h<0;f&&(h=-h),i(h<=67108863);for(var p=0,_=this.length-1;_>=0;_--){var $=(this.words[_]|0)+p*67108864;this.words[_]=$/h|0,p=$%h}return this._strip(),f?this.ineg():this},s.prototype.divn=function(h){return this.clone().idivn(h)},s.prototype.egcd=function(h){i(h.negative===0),i(!h.isZero());var f=this,p=h.clone();f.negative!==0?f=f.umod(h):f=f.clone();for(var _=new s(1),$=new s(0),y=new s(0),d=new s(1),w=0;f.isEven()&&p.isEven();)f.iushrn(1),p.iushrn(1),++w;for(var b=p.clone(),P=f.clone();!f.isZero();){for(var q=0,I=1;(f.words[0]&I)===0&&q<26;++q,I<<=1);if(q>0)for(f.iushrn(q);q-- >0;)(_.isOdd()||$.isOdd())&&(_.iadd(b),$.isub(P)),_.iushrn(1),$.iushrn(1);for(var F=0,j=1;(p.words[0]&j)===0&&F<26;++F,j<<=1);if(F>0)for(p.iushrn(F);F-- >0;)(y.isOdd()||d.isOdd())&&(y.iadd(b),d.isub(P)),y.iushrn(1),d.iushrn(1);f.cmp(p)>=0?(f.isub(p),_.isub(y),$.isub(d)):(p.isub(f),y.isub(_),d.isub($))}return{a:y,b:d,gcd:p.iushln(w)}},s.prototype._invmp=function(h){i(h.negative===0),i(!h.isZero());var f=this,p=h.clone();f.negative!==0?f=f.umod(h):f=f.clone();for(var _=new s(1),$=new s(0),y=p.clone();f.cmpn(1)>0&&p.cmpn(1)>0;){for(var d=0,w=1;(f.words[0]&w)===0&&d<26;++d,w<<=1);if(d>0)for(f.iushrn(d);d-- >0;)_.isOdd()&&_.iadd(y),_.iushrn(1);for(var b=0,P=1;(p.words[0]&P)===0&&b<26;++b,P<<=1);if(b>0)for(p.iushrn(b);b-- >0;)$.isOdd()&&$.iadd(y),$.iushrn(1);f.cmp(p)>=0?(f.isub(p),_.isub($)):(p.isub(f),$.isub(_))}var q;return f.cmpn(1)===0?q=_:q=$,q.cmpn(0)<0&&q.iadd(h),q},s.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var f=this.clone(),p=h.clone();f.negative=0,p.negative=0;for(var _=0;f.isEven()&&p.isEven();_++)f.iushrn(1),p.iushrn(1);do{for(;f.isEven();)f.iushrn(1);for(;p.isEven();)p.iushrn(1);var $=f.cmp(p);if($<0){var y=f;f=p,p=y}else if($===0||p.cmpn(1)===0)break;f.isub(p)}while(!0);return p.iushln(_)},s.prototype.invm=function(h){return this.egcd(h).a.umod(h)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(h){return this.words[0]&h},s.prototype.bincn=function(h){i(typeof h=="number");var f=h%26,p=(h-f)/26,_=1<<f;if(this.length<=p)return this._expand(p+1),this.words[p]|=_,this;for(var $=_,y=p;$!==0&&y<this.length;y++){var d=this.words[y]|0;d+=$,$=d>>>26,d&=67108863,this.words[y]=d}return $!==0&&(this.words[y]=$,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(h){var f=h<0;if(this.negative!==0&&!f)return-1;if(this.negative===0&&f)return 1;this._strip();var p;if(this.length>1)p=1;else{f&&(h=-h),i(h<=67108863,"Number is too big");var _=this.words[0]|0;p=_===h?0:_<h?-1:1}return this.negative!==0?-p|0:p},s.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var f=this.ucmp(h);return this.negative!==0?-f|0:f},s.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var f=0,p=this.length-1;p>=0;p--){var _=this.words[p]|0,$=h.words[p]|0;if(_!==$){_<$?f=-1:_>$&&(f=1);break}}return f},s.prototype.gtn=function(h){return this.cmpn(h)===1},s.prototype.gt=function(h){return this.cmp(h)===1},s.prototype.gten=function(h){return this.cmpn(h)>=0},s.prototype.gte=function(h){return this.cmp(h)>=0},s.prototype.ltn=function(h){return this.cmpn(h)===-1},s.prototype.lt=function(h){return this.cmp(h)===-1},s.prototype.lten=function(h){return this.cmpn(h)<=0},s.prototype.lte=function(h){return this.cmp(h)<=0},s.prototype.eqn=function(h){return this.cmpn(h)===0},s.prototype.eq=function(h){return this.cmp(h)===0},s.red=function(h){return new M(h)},s.prototype.toRed=function(h){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(h){return this.red=h,this},s.prototype.forceRed=function(h){return i(!this.red,"Already a number in reduction context"),this._forceRed(h)},s.prototype.redAdd=function(h){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},s.prototype.redIAdd=function(h){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},s.prototype.redSub=function(h){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},s.prototype.redISub=function(h){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},s.prototype.redShl=function(h){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},s.prototype.redMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},s.prototype.redIMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(h){return i(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var U={k256:null,p224:null,p192:null,p25519:null};function z(g,h){this.name=g,this.p=new s(h,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var h=new s(null);return h.words=new Array(Math.ceil(this.n/13)),h},z.prototype.ireduce=function(h){var f=h,p;do this.split(f,this.tmp),f=this.imulK(f),f=f.iadd(this.tmp),p=f.bitLength();while(p>this.n);var _=p<this.n?-1:f.ucmp(this.p);return _===0?(f.words[0]=0,f.length=1):_>0?f.isub(this.p):f.strip!==void 0?f.strip():f._strip(),f},z.prototype.split=function(h,f){h.iushrn(this.n,0,f)},z.prototype.imulK=function(h){return h.imul(this.k)};function W(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(W,z),W.prototype.split=function(h,f){for(var p=4194303,_=Math.min(h.length,9),$=0;$<_;$++)f.words[$]=h.words[$];if(f.length=_,h.length<=9){h.words[0]=0,h.length=1;return}var y=h.words[9];for(f.words[f.length++]=y&p,$=10;$<h.length;$++){var d=h.words[$]|0;h.words[$-10]=(d&p)<<4|y>>>22,y=d}y>>>=22,h.words[$-10]=y,y===0&&h.length>10?h.length-=10:h.length-=9},W.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var f=0,p=0;p<h.length;p++){var _=h.words[p]|0;f+=_*977,h.words[p]=f&67108863,f=_*64+(f/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function V(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(V,z);function B(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(B,z);function K(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(K,z),K.prototype.imulK=function(h){for(var f=0,p=0;p<h.length;p++){var _=(h.words[p]|0)*19+f,$=_&67108863;_>>>=26,h.words[p]=$,f=_}return f!==0&&(h.words[h.length++]=f),h},s._prime=function(h){if(U[h])return U[h];var f;if(h==="k256")f=new W;else if(h==="p224")f=new V;else if(h==="p192")f=new B;else if(h==="p25519")f=new K;else throw new Error("Unknown prime "+h);return U[h]=f,f};function M(g){if(typeof g=="string"){var h=s._prime(g);this.m=h.p,this.prime=h}else i(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}M.prototype._verify1=function(h){i(h.negative===0,"red works only with positives"),i(h.red,"red works only with red numbers")},M.prototype._verify2=function(h,f){i((h.negative|f.negative)===0,"red works only with positives"),i(h.red&&h.red===f.red,"red works only with red numbers")},M.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(u(h,h.umod(this.m)._forceRed(this)),h)},M.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},M.prototype.add=function(h,f){this._verify2(h,f);var p=h.add(f);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},M.prototype.iadd=function(h,f){this._verify2(h,f);var p=h.iadd(f);return p.cmp(this.m)>=0&&p.isub(this.m),p},M.prototype.sub=function(h,f){this._verify2(h,f);var p=h.sub(f);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},M.prototype.isub=function(h,f){this._verify2(h,f);var p=h.isub(f);return p.cmpn(0)<0&&p.iadd(this.m),p},M.prototype.shl=function(h,f){return this._verify1(h),this.imod(h.ushln(f))},M.prototype.imul=function(h,f){return this._verify2(h,f),this.imod(h.imul(f))},M.prototype.mul=function(h,f){return this._verify2(h,f),this.imod(h.mul(f))},M.prototype.isqr=function(h){return this.imul(h,h.clone())},M.prototype.sqr=function(h){return this.mul(h,h)},M.prototype.sqrt=function(h){if(h.isZero())return h.clone();var f=this.m.andln(3);if(i(f%2===1),f===3){var p=this.m.add(new s(1)).iushrn(2);return this.pow(h,p)}for(var _=this.m.subn(1),$=0;!_.isZero()&&_.andln(1)===0;)$++,_.iushrn(1);i(!_.isZero());var y=new s(1).toRed(this),d=y.redNeg(),w=this.m.subn(1).iushrn(1),b=this.m.bitLength();for(b=new s(2*b*b).toRed(this);this.pow(b,w).cmp(d)!==0;)b.redIAdd(d);for(var P=this.pow(b,_),q=this.pow(h,_.addn(1).iushrn(1)),I=this.pow(h,_),F=$;I.cmp(y)!==0;){for(var j=I,k=0;j.cmp(y)!==0;k++)j=j.redSqr();i(k<F);var H=this.pow(P,new s(1).iushln(F-k-1));q=q.redMul(H),P=H.redSqr(),I=I.redMul(P),F=k}return q},M.prototype.invm=function(h){var f=h._invmp(this.m);return f.negative!==0?(f.negative=0,this.imod(f).redNeg()):this.imod(f)},M.prototype.pow=function(h,f){if(f.isZero())return new s(1).toRed(this);if(f.cmpn(1)===0)return h.clone();var p=4,_=new Array(1<<p);_[0]=new s(1).toRed(this),_[1]=h;for(var $=2;$<_.length;$++)_[$]=this.mul(_[$-1],h);var y=_[0],d=0,w=0,b=f.bitLength()%26;for(b===0&&(b=26),$=f.length-1;$>=0;$--){for(var P=f.words[$],q=b-1;q>=0;q--){var I=P>>q&1;if(y!==_[0]&&(y=this.sqr(y)),I===0&&d===0){w=0;continue}d<<=1,d|=I,w++,!(w!==p&&($!==0||q!==0))&&(y=this.mul(y,_[d]),w=0,d=0)}b=26}return y},M.prototype.convertTo=function(h){var f=h.umod(this.m);return f===h?f.clone():f},M.prototype.convertFrom=function(h){var f=h.clone();return f.red=null,f},s.mont=function(h){return new v(h)};function v(g){M.call(this,g),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(v,M),v.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},v.prototype.convertFrom=function(h){var f=this.imod(h.mul(this.rinv));return f.red=null,f},v.prototype.imul=function(h,f){if(h.isZero()||f.isZero())return h.words[0]=0,h.length=1,h;var p=h.imul(f),_=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),$=p.isub(_).iushrn(this.shift),y=$;return $.cmp(this.m)>=0?y=$.isub(this.m):$.cmpn(0)<0&&(y=$.iadd(this.m)),y._forceRed(this)},v.prototype.mul=function(h,f){if(h.isZero()||f.isZero())return new s(0)._forceRed(this);var p=h.mul(f),_=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),$=p.isub(_).iushrn(this.shift),y=$;return $.cmp(this.m)>=0?y=$.isub(this.m):$.cmpn(0)<0&&(y=$.iadd(this.m)),y._forceRed(this)},v.prototype.invm=function(h){var f=this.imod(h._invmp(this.m).mul(this.r2));return f._forceRed(this)}})(t,Ft)})(ip);var Ee=ip.exports;const np="bignumber/5.7.0";var Dc=Ee.BN;const sn=new Me(np),Wh={},sp=9007199254740991;function Zw(t){return t!=null&&(Dt.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||Hr(t)||typeof t=="bigint"||eo(t))}let op=!1;class Dt{constructor(e,r){e!==Wh&&sn.throwError("cannot call constructor directly; use BigNumber.from",Me.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Pr(Ce(this).fromTwos(e))}toTwos(e){return Pr(Ce(this).toTwos(e))}abs(){return this._hex[0]==="-"?Dt.from(this._hex.substring(1)):this}add(e){return Pr(Ce(this).add(Ce(e)))}sub(e){return Pr(Ce(this).sub(Ce(e)))}div(e){return Dt.from(e).isZero()&&ii("division-by-zero","div"),Pr(Ce(this).div(Ce(e)))}mul(e){return Pr(Ce(this).mul(Ce(e)))}mod(e){const r=Ce(e);return r.isNeg()&&ii("division-by-zero","mod"),Pr(Ce(this).umod(r))}pow(e){const r=Ce(e);return r.isNeg()&&ii("negative-power","pow"),Pr(Ce(this).pow(r))}and(e){const r=Ce(e);return(this.isNegative()||r.isNeg())&&ii("unbound-bitwise-result","and"),Pr(Ce(this).and(r))}or(e){const r=Ce(e);return(this.isNegative()||r.isNeg())&&ii("unbound-bitwise-result","or"),Pr(Ce(this).or(r))}xor(e){const r=Ce(e);return(this.isNegative()||r.isNeg())&&ii("unbound-bitwise-result","xor"),Pr(Ce(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&ii("negative-width","mask"),Pr(Ce(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&ii("negative-width","shl"),Pr(Ce(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&ii("negative-width","shr"),Pr(Ce(this).shrn(e))}eq(e){return Ce(this).eq(Ce(e))}lt(e){return Ce(this).lt(Ce(e))}lte(e){return Ce(this).lte(Ce(e))}gt(e){return Ce(this).gt(Ce(e))}gte(e){return Ce(this).gte(Ce(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ce(this).isZero()}toNumber(){try{return Ce(this).toNumber()}catch{ii("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return sn.throwError("this platform does not support BigInt",Me.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?op||(op=!0,sn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?sn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Me.errors.UNEXPECTED_ARGUMENT,{}):sn.throwError("BigNumber.toString does not accept parameters",Me.errors.UNEXPECTED_ARGUMENT,{})),Ce(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Dt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Dt(Wh,ba(e)):e.match(/^-?[0-9]+$/)?new Dt(Wh,ba(new Dc(e))):sn.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&ii("underflow","BigNumber.from",e),(e>=sp||e<=-sp)&&ii("overflow","BigNumber.from",e),Dt.from(String(e));const r=e;if(typeof r=="bigint")return Dt.from(r.toString());if(eo(r))return Dt.from(xr(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return Dt.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(Hr(i)||i[0]==="-"&&Hr(i.substring(1))))return Dt.from(i)}return sn.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function ba(t){if(typeof t!="string")return ba(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&sn.throwArgumentError("invalid hex","value",t),t=ba(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function Pr(t){return Dt.from(ba(t))}function Ce(t){const e=Dt.from(t).toHexString();return e[0]==="-"?new Dc("-"+e.substring(3),16):new Dc(e.substring(2),16)}function ii(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),sn.throwError(t,Me.errors.NUMERIC_FAULT,i)}function Yw(t){return new Dc(t,36).toString(16)}const Er=new Me(np),ya={},ap=Dt.from(0),cp=Dt.from(-1);function lp(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Er.throwError(t,Me.errors.NUMERIC_FAULT,n)}let wa="0";for(;wa.length<256;)wa+=wa;function Vh(t){if(typeof t!="number")try{t=Dt.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+wa.substring(0,t):Er.throwArgumentError("invalid decimal size","decimals",t)}function Kh(t,e){e==null&&(e=0);const r=Vh(e);t=Dt.from(t);const i=t.lt(ap);i&&(t=t.mul(cp));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=t.div(r).toString();return r.length===1?t=s:t=s+"."+n,i&&(t="-"+t),t}function on(t,e){e==null&&(e=0);const r=Vh(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Er.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Er.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Er.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>r.length-1&&lp("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const a=Dt.from(s),c=Dt.from(o);let l=a.mul(r).add(c);return i&&(l=l.mul(cp)),l}class to{constructor(e,r,i,n){e!==ya&&Er.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Me.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=r,this.width=i,this.decimals=n,this.name=(r?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=Vh(n),Object.freeze(this)}static from(e){if(e instanceof to)return e;typeof e=="number"&&(e=`fixed128x${e}`);let r=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")r=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Er.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,a,c)=>e[o]==null?c:(typeof e[o]!==a&&Er.throwArgumentError("invalid fixed format ("+o+" not "+a+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Er.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Er.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new to(ya,r,i,n)}}class sr{constructor(e,r,i,n){e!==ya&&Er.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Me.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=r,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Er.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=on(this._value,this.format.decimals),i=on(e._value,e.format.decimals);return sr.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=on(this._value,this.format.decimals),i=on(e._value,e.format.decimals);return sr.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=on(this._value,this.format.decimals),i=on(e._value,e.format.decimals);return sr.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=on(this._value,this.format.decimals),i=on(e._value,e.format.decimals);return sr.fromValue(r.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=sr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(hp.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=sr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(hp.toFormat(r.format))),r}round(e){e==null&&(e=0);const r=this.toString().split(".");if(r.length===1&&r.push("0"),(e<0||e>80||e%1)&&Er.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=sr.from("1"+wa.substring(0,e),this.format),n=Xw.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Er.throwArgumentError("invalid byte width","width",e);const r=Dt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Nn(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return sr.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!Zw(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),sr.fromString(Kh(e,r),to.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=to.from(r),n=on(e,i.decimals);!i.signed&&n.lt(ap)&&lp("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Nn(s,i.width/8));const o=Kh(n,i.decimals);return new sr(ya,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=to.from(r);if(zt(e).length>i.width/8)throw new Error("overflow");let n=Dt.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=Kh(n,i.decimals);return new sr(ya,s,o,i)}static from(e,r){if(typeof e=="string")return sr.fromString(e,r);if(eo(e))return sr.fromBytes(e,r);try{return sr.fromValue(e,0,r)}catch(i){if(i.code!==Me.errors.INVALID_ARGUMENT)throw i}return Er.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const hp=sr.from(1),Xw=sr.from("0.5");var fp={exports:{}};/**
|
|
15
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
16
|
-
*
|
|
17
|
-
* @version 0.8.0
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @license MIT
|
|
21
|
-
*/(function(t){(function(){var e="input is invalid type",r="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=Ft:s&&(n=self);var a=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,c=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),u=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],x=[1,256,65536,16777216],S=[6,1536,393216,100663296],E=[0,8,16,24],A=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],R=[224,256,384,512],O=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],N={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(I){return Object.prototype.toString.call(I)==="[object Array]"}),c&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(I){return typeof I=="object"&&I.buffer&&I.buffer.constructor===ArrayBuffer});for(var T=function(I,F,j){return function(k){return new b(I,F,I).update(k)[j]()}},U=function(I,F,j){return function(k,H){return new b(I,F,H).update(k)[j]()}},z=function(I,F,j){return function(k,H,Y,Q){return h["cshake"+I].update(k,H,Y,Q)[j]()}},W=function(I,F,j){return function(k,H,Y,Q){return h["kmac"+I].update(k,H,Y,Q)[j]()}},V=function(I,F,j,k){for(var H=0;H<C.length;++H){var Y=C[H];I[Y]=F(j,k,Y)}return I},B=function(I,F){var j=T(I,F,"hex");return j.create=function(){return new b(I,F,I)},j.update=function(k){return j.create().update(k)},V(j,T,I,F)},K=function(I,F){var j=U(I,F,"hex");return j.create=function(k){return new b(I,F,k)},j.update=function(k,H){return j.create(H).update(k)},V(j,U,I,F)},M=function(I,F){var j=N[I],k=z(I,F,"hex");return k.create=function(H,Y,Q){return!Y&&!Q?h["shake"+I].create(H):new b(I,F,H).bytepad([Y,Q],j)},k.update=function(H,Y,Q,J){return k.create(Y,Q,J).update(H)},V(k,z,I,F)},v=function(I,F){var j=N[I],k=W(I,F,"hex");return k.create=function(H,Y,Q){return new P(I,F,Y).bytepad(["KMAC",Q],j).bytepad([H],j)},k.update=function(H,Y,Q,J){return k.create(H,Q,J).update(Y)},V(k,W,I,F)},g=[{name:"keccak",padding:x,bits:R,createMethod:B},{name:"sha3",padding:S,bits:R,createMethod:B},{name:"shake",padding:u,bits:O,createMethod:K},{name:"cshake",padding:m,bits:O,createMethod:M},{name:"kmac",padding:m,bits:O,createMethod:v}],h={},f=[],p=0;p<g.length;++p)for(var _=g[p],$=_.bits,y=0;y<$.length;++y){var d=_.name+"_"+$[y];if(f.push(d),h[d]=_.createMethod($[y],_.padding),_.name!=="sha3"){var w=_.name+$[y];f.push(w),h[w]=h[d]}}function b(I,F,j){this.blocks=[],this.s=[],this.padding=F,this.outputBits=j,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(I<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=j>>5,this.extraBytes=(j&31)>>3;for(var k=0;k<50;++k)this.s[k]=0}b.prototype.update=function(I){if(this.finalized)throw new Error(r);var F,j=typeof I;if(j!=="string"){if(j==="object"){if(I===null)throw new Error(e);if(c&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!c||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);F=!0}for(var k=this.blocks,H=this.byteCount,Y=I.length,Q=this.blockCount,J=0,ae=this.s,re,ie;J<Y;){if(this.reset)for(this.reset=!1,k[0]=this.block,re=1;re<Q+1;++re)k[re]=0;if(F)for(re=this.start;J<Y&&re<H;++J)k[re>>2]|=I[J]<<E[re++&3];else for(re=this.start;J<Y&&re<H;++J)ie=I.charCodeAt(J),ie<128?k[re>>2]|=ie<<E[re++&3]:ie<2048?(k[re>>2]|=(192|ie>>6)<<E[re++&3],k[re>>2]|=(128|ie&63)<<E[re++&3]):ie<55296||ie>=57344?(k[re>>2]|=(224|ie>>12)<<E[re++&3],k[re>>2]|=(128|ie>>6&63)<<E[re++&3],k[re>>2]|=(128|ie&63)<<E[re++&3]):(ie=65536+((ie&1023)<<10|I.charCodeAt(++J)&1023),k[re>>2]|=(240|ie>>18)<<E[re++&3],k[re>>2]|=(128|ie>>12&63)<<E[re++&3],k[re>>2]|=(128|ie>>6&63)<<E[re++&3],k[re>>2]|=(128|ie&63)<<E[re++&3]);if(this.lastByteIndex=re,re>=H){for(this.start=re-H,this.block=k[Q],re=0;re<Q;++re)ae[re]^=k[re];q(ae),this.reset=!0}else this.start=re}return this},b.prototype.encode=function(I,F){var j=I&255,k=1,H=[j];for(I=I>>8,j=I&255;j>0;)H.unshift(j),I=I>>8,j=I&255,++k;return F?H.push(k):H.unshift(k),this.update(H),H.length},b.prototype.encodeString=function(I){var F,j=typeof I;if(j!=="string"){if(j==="object"){if(I===null)throw new Error(e);if(c&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!c||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);F=!0}var k=0,H=I.length;if(F)k=H;else for(var Y=0;Y<I.length;++Y){var Q=I.charCodeAt(Y);Q<128?k+=1:Q<2048?k+=2:Q<55296||Q>=57344?k+=3:(Q=65536+((Q&1023)<<10|I.charCodeAt(++Y)&1023),k+=4)}return k+=this.encode(k*8),this.update(I),k},b.prototype.bytepad=function(I,F){for(var j=this.encode(F),k=0;k<I.length;++k)j+=this.encodeString(I[k]);var H=F-j%F,Y=[];return Y.length=H,this.update(Y),this},b.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var I=this.blocks,F=this.lastByteIndex,j=this.blockCount,k=this.s;if(I[F>>2]|=this.padding[F&3],this.lastByteIndex===this.byteCount)for(I[0]=I[j],F=1;F<j+1;++F)I[F]=0;for(I[j-1]|=2147483648,F=0;F<j;++F)k[F]^=I[F];q(k)}},b.prototype.toString=b.prototype.hex=function(){this.finalize();for(var I=this.blockCount,F=this.s,j=this.outputBlocks,k=this.extraBytes,H=0,Y=0,Q="",J;Y<j;){for(H=0;H<I&&Y<j;++H,++Y)J=F[H],Q+=l[J>>4&15]+l[J&15]+l[J>>12&15]+l[J>>8&15]+l[J>>20&15]+l[J>>16&15]+l[J>>28&15]+l[J>>24&15];Y%I===0&&(q(F),H=0)}return k&&(J=F[H],Q+=l[J>>4&15]+l[J&15],k>1&&(Q+=l[J>>12&15]+l[J>>8&15]),k>2&&(Q+=l[J>>20&15]+l[J>>16&15])),Q},b.prototype.arrayBuffer=function(){this.finalize();var I=this.blockCount,F=this.s,j=this.outputBlocks,k=this.extraBytes,H=0,Y=0,Q=this.outputBits>>3,J;k?J=new ArrayBuffer(j+1<<2):J=new ArrayBuffer(Q);for(var ae=new Uint32Array(J);Y<j;){for(H=0;H<I&&Y<j;++H,++Y)ae[Y]=F[H];Y%I===0&&q(F)}return k&&(ae[H]=F[H],J=J.slice(0,Q)),J},b.prototype.buffer=b.prototype.arrayBuffer,b.prototype.digest=b.prototype.array=function(){this.finalize();for(var I=this.blockCount,F=this.s,j=this.outputBlocks,k=this.extraBytes,H=0,Y=0,Q=[],J,ae;Y<j;){for(H=0;H<I&&Y<j;++H,++Y)J=Y<<2,ae=F[H],Q[J]=ae&255,Q[J+1]=ae>>8&255,Q[J+2]=ae>>16&255,Q[J+3]=ae>>24&255;Y%I===0&&q(F)}return k&&(J=Y<<2,ae=F[H],Q[J]=ae&255,k>1&&(Q[J+1]=ae>>8&255),k>2&&(Q[J+2]=ae>>16&255)),Q};function P(I,F,j){b.call(this,I,F,j)}P.prototype=new b,P.prototype.finalize=function(){return this.encode(this.outputBits,!0),b.prototype.finalize.call(this)};var q=function(I){var F,j,k,H,Y,Q,J,ae,re,ie,Ze,Ye,de,qe,je,he,ke,ze,ue,He,We,le,Be,Ve,oe,nt,st,me,ot,Ke,ge,at,ft,ce,ct,ut,be,Xe,Ue,pe,Qe,et,fe,dt,pt,ye,gt,vt,ve,tt,Re,we,mt,bt,_e,yt,Ae,lt,qr,jr,kr,zr,kt;for(k=0;k<48;k+=2)H=I[0]^I[10]^I[20]^I[30]^I[40],Y=I[1]^I[11]^I[21]^I[31]^I[41],Q=I[2]^I[12]^I[22]^I[32]^I[42],J=I[3]^I[13]^I[23]^I[33]^I[43],ae=I[4]^I[14]^I[24]^I[34]^I[44],re=I[5]^I[15]^I[25]^I[35]^I[45],ie=I[6]^I[16]^I[26]^I[36]^I[46],Ze=I[7]^I[17]^I[27]^I[37]^I[47],Ye=I[8]^I[18]^I[28]^I[38]^I[48],de=I[9]^I[19]^I[29]^I[39]^I[49],F=Ye^(Q<<1|J>>>31),j=de^(J<<1|Q>>>31),I[0]^=F,I[1]^=j,I[10]^=F,I[11]^=j,I[20]^=F,I[21]^=j,I[30]^=F,I[31]^=j,I[40]^=F,I[41]^=j,F=H^(ae<<1|re>>>31),j=Y^(re<<1|ae>>>31),I[2]^=F,I[3]^=j,I[12]^=F,I[13]^=j,I[22]^=F,I[23]^=j,I[32]^=F,I[33]^=j,I[42]^=F,I[43]^=j,F=Q^(ie<<1|Ze>>>31),j=J^(Ze<<1|ie>>>31),I[4]^=F,I[5]^=j,I[14]^=F,I[15]^=j,I[24]^=F,I[25]^=j,I[34]^=F,I[35]^=j,I[44]^=F,I[45]^=j,F=ae^(Ye<<1|de>>>31),j=re^(de<<1|Ye>>>31),I[6]^=F,I[7]^=j,I[16]^=F,I[17]^=j,I[26]^=F,I[27]^=j,I[36]^=F,I[37]^=j,I[46]^=F,I[47]^=j,F=ie^(H<<1|Y>>>31),j=Ze^(Y<<1|H>>>31),I[8]^=F,I[9]^=j,I[18]^=F,I[19]^=j,I[28]^=F,I[29]^=j,I[38]^=F,I[39]^=j,I[48]^=F,I[49]^=j,qe=I[0],je=I[1],ye=I[11]<<4|I[10]>>>28,gt=I[10]<<4|I[11]>>>28,me=I[20]<<3|I[21]>>>29,ot=I[21]<<3|I[20]>>>29,jr=I[31]<<9|I[30]>>>23,kr=I[30]<<9|I[31]>>>23,et=I[40]<<18|I[41]>>>14,fe=I[41]<<18|I[40]>>>14,ce=I[2]<<1|I[3]>>>31,ct=I[3]<<1|I[2]>>>31,he=I[13]<<12|I[12]>>>20,ke=I[12]<<12|I[13]>>>20,vt=I[22]<<10|I[23]>>>22,ve=I[23]<<10|I[22]>>>22,Ke=I[33]<<13|I[32]>>>19,ge=I[32]<<13|I[33]>>>19,zr=I[42]<<2|I[43]>>>30,kt=I[43]<<2|I[42]>>>30,bt=I[5]<<30|I[4]>>>2,_e=I[4]<<30|I[5]>>>2,ut=I[14]<<6|I[15]>>>26,be=I[15]<<6|I[14]>>>26,ze=I[25]<<11|I[24]>>>21,ue=I[24]<<11|I[25]>>>21,tt=I[34]<<15|I[35]>>>17,Re=I[35]<<15|I[34]>>>17,at=I[45]<<29|I[44]>>>3,ft=I[44]<<29|I[45]>>>3,Ve=I[6]<<28|I[7]>>>4,oe=I[7]<<28|I[6]>>>4,yt=I[17]<<23|I[16]>>>9,Ae=I[16]<<23|I[17]>>>9,Xe=I[26]<<25|I[27]>>>7,Ue=I[27]<<25|I[26]>>>7,He=I[36]<<21|I[37]>>>11,We=I[37]<<21|I[36]>>>11,we=I[47]<<24|I[46]>>>8,mt=I[46]<<24|I[47]>>>8,dt=I[8]<<27|I[9]>>>5,pt=I[9]<<27|I[8]>>>5,nt=I[18]<<20|I[19]>>>12,st=I[19]<<20|I[18]>>>12,lt=I[29]<<7|I[28]>>>25,qr=I[28]<<7|I[29]>>>25,pe=I[38]<<8|I[39]>>>24,Qe=I[39]<<8|I[38]>>>24,le=I[48]<<14|I[49]>>>18,Be=I[49]<<14|I[48]>>>18,I[0]=qe^~he&ze,I[1]=je^~ke&ue,I[10]=Ve^~nt&me,I[11]=oe^~st&ot,I[20]=ce^~ut&Xe,I[21]=ct^~be&Ue,I[30]=dt^~ye&vt,I[31]=pt^~gt&ve,I[40]=bt^~yt<,I[41]=_e^~Ae&qr,I[2]=he^~ze&He,I[3]=ke^~ue&We,I[12]=nt^~me&Ke,I[13]=st^~ot&ge,I[22]=ut^~Xe&pe,I[23]=be^~Ue&Qe,I[32]=ye^~vt&tt,I[33]=gt^~ve&Re,I[42]=yt^~lt&jr,I[43]=Ae^~qr&kr,I[4]=ze^~He&le,I[5]=ue^~We&Be,I[14]=me^~Ke&at,I[15]=ot^~ge&ft,I[24]=Xe^~pe&et,I[25]=Ue^~Qe&fe,I[34]=vt^~tt&we,I[35]=ve^~Re&mt,I[44]=lt^~jr&zr,I[45]=qr^~kr&kt,I[6]=He^~le&qe,I[7]=We^~Be&je,I[16]=Ke^~at&Ve,I[17]=ge^~ft&oe,I[26]=pe^~et&ce,I[27]=Qe^~fe&ct,I[36]=tt^~we&dt,I[37]=Re^~mt&pt,I[46]=jr^~zr&bt,I[47]=kr^~kt&_e,I[8]=le^~qe&he,I[9]=Be^~je&ke,I[18]=at^~Ve&nt,I[19]=ft^~oe&st,I[28]=et^~ce&ut,I[29]=fe^~ct&be,I[38]=we^~dt&ye,I[39]=mt^~pt>,I[48]=zr^~bt&yt,I[49]=kt^~_e&Ae,I[0]^=A[k],I[1]^=A[k+1]};if(a)t.exports=h;else for(p=0;p<f.length;++p)n[f[p]]=h[f[p]]})()})(fp);var Qw=fp.exports;function up(t){return"0x"+Qw.keccak_256(zt(t))}const e3="rlp/5.7.0";new Me(e3);const t3="address/5.7.0",_a=new Me(t3);function dp(t){Hr(t,20)||_a.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);const i=zt(up(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const r3=9007199254740991;function i3(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const Gh={};for(let t=0;t<10;t++)Gh[String(t)]=String(t);for(let t=0;t<26;t++)Gh[String.fromCharCode(65+t)]=String(10+t);const pp=Math.floor(i3(r3));function n3(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>Gh[i]).join("");for(;e.length>=pp;){let i=e.substring(0,pp);e=parseInt(i,10)%97+e.substring(i.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function s3(t){let e=null;if(typeof t!="string"&&_a.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=dp(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&_a.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==n3(t)&&_a.throwArgumentError("bad icap checksum","address",t),e=Yw(t.substring(4));e.length<40;)e="0"+e;e=dp("0x"+e)}else _a.throwArgumentError("invalid address","address",t);return e}const o3="properties/5.7.0";new Me(o3);function xa(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var Wr={},De={},ps=gp;function gp(t,e){if(!t)throw new Error(e||"Assertion failed")}gp.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var ro={exports:{}};typeof Object.create=="function"?ro.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ro.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var a3=ps,c3=ro.exports;De.inherits=c3;function l3(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function h3(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):l3(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}De.toArray=h3;function f3(t){for(var e="",r=0;r<t.length;r++)e+=mp(t[r].toString(16));return e}De.toHex=f3;function vp(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}De.htonl=vp;function u3(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=vp(n)),r+=bp(n.toString(16))}return r}De.toHex32=u3;function mp(t){return t.length===1?"0"+t:t}De.zero2=mp;function bp(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}De.zero8=bp;function d3(t,e,r,i){var n=r-e;a3(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}De.join32=d3;function p3(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}De.split32=p3;function g3(t,e){return t>>>e|t<<32-e}De.rotr32=g3;function v3(t,e){return t<<e|t>>>32-e}De.rotl32=v3;function m3(t,e){return t+e>>>0}De.sum32=m3;function b3(t,e,r){return t+e+r>>>0}De.sum32_3=b3;function y3(t,e,r,i){return t+e+r+i>>>0}De.sum32_4=y3;function w3(t,e,r,i,n){return t+e+r+i+n>>>0}De.sum32_5=w3;function _3(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}De.sum64=_3;function x3(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}De.sum64_hi=x3;function E3(t,e,r,i){var n=e+i;return n>>>0}De.sum64_lo=E3;function $3(t,e,r,i,n,s,o,a){var c=0,l=e;l=l+i>>>0,c+=l<e?1:0,l=l+s>>>0,c+=l<s?1:0,l=l+a>>>0,c+=l<a?1:0;var u=t+r+n+o+c;return u>>>0}De.sum64_4_hi=$3;function S3(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}De.sum64_4_lo=S3;function I3(t,e,r,i,n,s,o,a,c,l){var u=0,m=e;m=m+i>>>0,u+=m<e?1:0,m=m+s>>>0,u+=m<s?1:0,m=m+a>>>0,u+=m<a?1:0,m=m+l>>>0,u+=m<l?1:0;var x=t+r+n+o+c+u;return x>>>0}De.sum64_5_hi=I3;function A3(t,e,r,i,n,s,o,a,c,l){var u=e+i+s+a+l;return u>>>0}De.sum64_5_lo=A3;function M3(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}De.rotr64_hi=M3;function P3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}De.rotr64_lo=P3;function O3(t,e,r){return t>>>r}De.shr64_hi=O3;function C3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}De.shr64_lo=C3;var io={},yp=De,D3=ps;function Rc(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}io.BlockHash=Rc,Rc.prototype.update=function(e,r){if(e=yp.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=yp.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},Rc.prototype.digest=function(e){return this.update(this._pad()),D3(this.pending===null),this._digest(e)},Rc.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var no={},Ri={},R3=De,Ni=R3.rotr32;function N3(t,e,r,i){if(t===0)return wp(e,r,i);if(t===1||t===3)return xp(e,r,i);if(t===2)return _p(e,r,i)}Ri.ft_1=N3;function wp(t,e,r){return t&e^~t&r}Ri.ch32=wp;function _p(t,e,r){return t&e^t&r^e&r}Ri.maj32=_p;function xp(t,e,r){return t^e^r}Ri.p32=xp;function T3(t){return Ni(t,2)^Ni(t,13)^Ni(t,22)}Ri.s0_256=T3;function F3(t){return Ni(t,6)^Ni(t,11)^Ni(t,25)}Ri.s1_256=F3;function L3(t){return Ni(t,7)^Ni(t,18)^t>>>3}Ri.g0_256=L3;function B3(t){return Ni(t,17)^Ni(t,19)^t>>>10}Ri.g1_256=B3;var so=De,U3=io,q3=Ri,Jh=so.rotl32,Ea=so.sum32,j3=so.sum32_5,k3=q3.ft_1,Ep=U3.BlockHash,z3=[1518500249,1859775393,2400959708,3395469782];function Ti(){if(!(this instanceof Ti))return new Ti;Ep.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}so.inherits(Ti,Ep);var H3=Ti;Ti.blockSize=512,Ti.outSize=160,Ti.hmacStrength=80,Ti.padLength=64,Ti.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=Jh(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4];for(n=0;n<i.length;n++){var u=~~(n/20),m=j3(Jh(s,5),k3(u,o,a,c),l,i[n],z3[u]);l=c,c=a,a=Jh(o,30),o=s,s=m}this.h[0]=Ea(this.h[0],s),this.h[1]=Ea(this.h[1],o),this.h[2]=Ea(this.h[2],a),this.h[3]=Ea(this.h[3],c),this.h[4]=Ea(this.h[4],l)},Ti.prototype._digest=function(e){return e==="hex"?so.toHex32(this.h,"big"):so.split32(this.h,"big")};var oo=De,W3=io,ao=Ri,V3=ps,xi=oo.sum32,K3=oo.sum32_4,G3=oo.sum32_5,J3=ao.ch32,Z3=ao.maj32,Y3=ao.s0_256,X3=ao.s1_256,Q3=ao.g0_256,e4=ao.g1_256,$p=W3.BlockHash,t4=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Fi(){if(!(this instanceof Fi))return new Fi;$p.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=t4,this.W=new Array(64)}oo.inherits(Fi,$p);var Sp=Fi;Fi.blockSize=512,Fi.outSize=256,Fi.hmacStrength=192,Fi.padLength=64,Fi.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=K3(e4(i[n-2]),i[n-7],Q3(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4],u=this.h[5],m=this.h[6],x=this.h[7];for(V3(this.k.length===i.length),n=0;n<i.length;n++){var S=G3(x,X3(l),J3(l,u,m),this.k[n],i[n]),E=xi(Y3(s),Z3(s,o,a));x=m,m=u,u=l,l=xi(c,S),c=a,a=o,o=s,s=xi(S,E)}this.h[0]=xi(this.h[0],s),this.h[1]=xi(this.h[1],o),this.h[2]=xi(this.h[2],a),this.h[3]=xi(this.h[3],c),this.h[4]=xi(this.h[4],l),this.h[5]=xi(this.h[5],u),this.h[6]=xi(this.h[6],m),this.h[7]=xi(this.h[7],x)},Fi.prototype._digest=function(e){return e==="hex"?oo.toHex32(this.h,"big"):oo.split32(this.h,"big")};var Zh=De,Ip=Sp;function an(){if(!(this instanceof an))return new an;Ip.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Zh.inherits(an,Ip);var r4=an;an.blockSize=512,an.outSize=224,an.hmacStrength=192,an.padLength=64,an.prototype._digest=function(e){return e==="hex"?Zh.toHex32(this.h.slice(0,7),"big"):Zh.split32(this.h.slice(0,7),"big")};var Or=De,i4=io,n4=ps,Li=Or.rotr64_hi,Bi=Or.rotr64_lo,Ap=Or.shr64_hi,Mp=Or.shr64_lo,Tn=Or.sum64,Yh=Or.sum64_hi,Xh=Or.sum64_lo,s4=Or.sum64_4_hi,o4=Or.sum64_4_lo,a4=Or.sum64_5_hi,c4=Or.sum64_5_lo,Pp=i4.BlockHash,l4=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Ei(){if(!(this instanceof Ei))return new Ei;Pp.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=l4,this.W=new Array(160)}Or.inherits(Ei,Pp);var Op=Ei;Ei.blockSize=1024,Ei.outSize=512,Ei.hmacStrength=192,Ei.padLength=128,Ei.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=w4(i[n-4],i[n-3]),o=_4(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],l=b4(i[n-30],i[n-29]),u=y4(i[n-30],i[n-29]),m=i[n-32],x=i[n-31];i[n]=s4(s,o,a,c,l,u,m,x),i[n+1]=o4(s,o,a,c,l,u,m,x)}},Ei.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],l=this.h[5],u=this.h[6],m=this.h[7],x=this.h[8],S=this.h[9],E=this.h[10],A=this.h[11],R=this.h[12],O=this.h[13],C=this.h[14],N=this.h[15];n4(this.k.length===i.length);for(var T=0;T<i.length;T+=2){var U=C,z=N,W=v4(x,S),V=m4(x,S),B=h4(x,S,E,A,R),K=f4(x,S,E,A,R,O),M=this.k[T],v=this.k[T+1],g=i[T],h=i[T+1],f=a4(U,z,W,V,B,K,M,v,g,h),p=c4(U,z,W,V,B,K,M,v,g,h);U=p4(n,s),z=g4(n,s),W=u4(n,s,o,a,c),V=d4(n,s,o,a,c,l);var _=Yh(U,z,W,V),$=Xh(U,z,W,V);C=R,N=O,R=E,O=A,E=x,A=S,x=Yh(u,m,f,p),S=Xh(m,m,f,p),u=c,m=l,c=o,l=a,o=n,a=s,n=Yh(f,p,_,$),s=Xh(f,p,_,$)}Tn(this.h,0,n,s),Tn(this.h,2,o,a),Tn(this.h,4,c,l),Tn(this.h,6,u,m),Tn(this.h,8,x,S),Tn(this.h,10,E,A),Tn(this.h,12,R,O),Tn(this.h,14,C,N)},Ei.prototype._digest=function(e){return e==="hex"?Or.toHex32(this.h,"big"):Or.split32(this.h,"big")};function h4(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function f4(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function u4(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function d4(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function p4(t,e){var r=Li(t,e,28),i=Li(e,t,2),n=Li(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function g4(t,e){var r=Bi(t,e,28),i=Bi(e,t,2),n=Bi(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function v4(t,e){var r=Li(t,e,14),i=Li(t,e,18),n=Li(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function m4(t,e){var r=Bi(t,e,14),i=Bi(t,e,18),n=Bi(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function b4(t,e){var r=Li(t,e,1),i=Li(t,e,8),n=Ap(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function y4(t,e){var r=Bi(t,e,1),i=Bi(t,e,8),n=Mp(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function w4(t,e){var r=Li(t,e,19),i=Li(e,t,29),n=Ap(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function _4(t,e){var r=Bi(t,e,19),i=Bi(e,t,29),n=Mp(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Qh=De,Cp=Op;function cn(){if(!(this instanceof cn))return new cn;Cp.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Qh.inherits(cn,Cp);var x4=cn;cn.blockSize=1024,cn.outSize=384,cn.hmacStrength=192,cn.padLength=128,cn.prototype._digest=function(e){return e==="hex"?Qh.toHex32(this.h.slice(0,12),"big"):Qh.split32(this.h.slice(0,12),"big")},no.sha1=H3,no.sha224=r4,no.sha256=Sp,no.sha384=x4,no.sha512=Op;var Dp={},gs=De,E4=io,Nc=gs.rotl32,Rp=gs.sum32,$a=gs.sum32_3,Np=gs.sum32_4,Tp=E4.BlockHash;function Ui(){if(!(this instanceof Ui))return new Ui;Tp.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}gs.inherits(Ui,Tp),Dp.ripemd160=Ui,Ui.blockSize=512,Ui.outSize=160,Ui.hmacStrength=192,Ui.padLength=64,Ui.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,l=n,u=s,m=o,x=a,S=0;S<80;S++){var E=Rp(Nc(Np(i,Fp(S,n,s,o),e[I4[S]+r],$4(S)),M4[S]),a);i=a,a=o,o=Nc(s,10),s=n,n=E,E=Rp(Nc(Np(c,Fp(79-S,l,u,m),e[A4[S]+r],S4(S)),P4[S]),x),c=x,x=m,m=Nc(u,10),u=l,l=E}E=$a(this.h[1],s,m),this.h[1]=$a(this.h[2],o,x),this.h[2]=$a(this.h[3],a,c),this.h[3]=$a(this.h[4],i,l),this.h[4]=$a(this.h[0],n,u),this.h[0]=E},Ui.prototype._digest=function(e){return e==="hex"?gs.toHex32(this.h,"little"):gs.split32(this.h,"little")};function Fp(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function $4(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function S4(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var I4=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],A4=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],M4=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],P4=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],O4=De,C4=ps;function co(t,e,r){if(!(this instanceof co))return new co(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(O4.toArray(e,r))}var D4=co;co.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),C4(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},co.prototype.update=function(e,r){return this.inner.update(e,r),this},co.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=De,e.common=io,e.sha=no,e.ripemd=Dp,e.hmac=D4,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(Wr);function lo(t,e,r){return r={path:e,exports:{},require:function(i,n){return R4(i,n??r.path)}},t(r,r.exports),r.exports}function R4(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var ef=Lp;function Lp(t,e){if(!t)throw new Error(e||"Assertion failed")}Lp.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var $i=lo(function(t,e){var r=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var l=0;l<o.length;l++)c[l]=o[l]|0;return c}if(a==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var l=0;l<o.length;l+=2)c.push(parseInt(o[l]+o[l+1],16))}else for(var l=0;l<o.length;l++){var u=o.charCodeAt(l),m=u>>8,x=u&255;m?c.push(m,x):c.push(x)}return c}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var a="",c=0;c<o.length;c++)a+=n(o[c].toString(16));return a}r.toHex=s,r.encode=function(a,c){return c==="hex"?s(a):a}}),Vr=lo(function(t,e){var r=e;r.assert=ef,r.toArray=$i.toArray,r.zero2=$i.zero2,r.toHex=$i.toHex,r.encode=$i.encode;function i(c,l,u){var m=new Array(Math.max(c.bitLength(),u)+1);m.fill(0);for(var x=1<<l+1,S=c.clone(),E=0;E<m.length;E++){var A,R=S.andln(x-1);S.isOdd()?(R>(x>>1)-1?A=(x>>1)-R:A=R,S.isubn(A)):A=0,m[E]=A,S.iushrn(1)}return m}r.getNAF=i;function n(c,l){var u=[[],[]];c=c.clone(),l=l.clone();for(var m=0,x=0,S;c.cmpn(-m)>0||l.cmpn(-x)>0;){var E=c.andln(3)+m&3,A=l.andln(3)+x&3;E===3&&(E=-1),A===3&&(A=-1);var R;(E&1)===0?R=0:(S=c.andln(7)+m&7,(S===3||S===5)&&A===2?R=-E:R=E),u[0].push(R);var O;(A&1)===0?O=0:(S=l.andln(7)+x&7,(S===3||S===5)&&E===2?O=-A:O=A),u[1].push(O),2*m===R+1&&(m=1-m),2*x===O+1&&(x=1-x),c.iushrn(1),l.iushrn(1)}return u}r.getJSF=n;function s(c,l,u){var m="_"+l;c.prototype[l]=function(){return this[m]!==void 0?this[m]:this[m]=u.call(this)}}r.cachedProperty=s;function o(c){return typeof c=="string"?r.toArray(c,"hex"):c}r.parseBytes=o;function a(c){return new Ee(c,"hex","le")}r.intFromLE=a}),Tc=Vr.getNAF,N4=Vr.getJSF,Fc=Vr.assert;function Fn(t,e){this.type=t,this.p=new Ee(e.p,16),this.red=e.prime?Ee.red(e.prime):Ee.mont(this.p),this.zero=new Ee(0).toRed(this.red),this.one=new Ee(1).toRed(this.red),this.two=new Ee(2).toRed(this.red),this.n=e.n&&new Ee(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var vs=Fn;Fn.prototype.point=function(){throw new Error("Not implemented")},Fn.prototype.validate=function(){throw new Error("Not implemented")},Fn.prototype._fixedNafMul=function(e,r){Fc(e.precomputed);var i=e._getDoubles(),n=Tc(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var l=a+i.step-1;l>=a;l--)c=(c<<1)+n[l];o.push(c)}for(var u=this.jpoint(null,null,null),m=this.jpoint(null,null,null),x=s;x>0;x--){for(a=0;a<o.length;a++)c=o[a],c===x?m=m.mixedAdd(i.points[a]):c===-x&&(m=m.mixedAdd(i.points[a].neg()));u=u.add(m)}return u.toP()},Fn.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Tc(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var l=0;c>=0&&o[c]===0;c--)l++;if(c>=0&&l++,a=a.dblp(l),c<0)break;var u=o[c];Fc(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a},Fn.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,l=0,u,m,x;for(u=0;u<n;u++){x=r[u];var S=x._getNAFPoints(e);o[u]=S.wnd,a[u]=S.points}for(u=n-1;u>=1;u-=2){var E=u-1,A=u;if(o[E]!==1||o[A]!==1){c[E]=Tc(i[E],o[E],this._bitLength),c[A]=Tc(i[A],o[A],this._bitLength),l=Math.max(c[E].length,l),l=Math.max(c[A].length,l);continue}var R=[r[E],null,null,r[A]];r[E].y.cmp(r[A].y)===0?(R[1]=r[E].add(r[A]),R[2]=r[E].toJ().mixedAdd(r[A].neg())):r[E].y.cmp(r[A].y.redNeg())===0?(R[1]=r[E].toJ().mixedAdd(r[A]),R[2]=r[E].add(r[A].neg())):(R[1]=r[E].toJ().mixedAdd(r[A]),R[2]=r[E].toJ().mixedAdd(r[A].neg()));var O=[-3,-1,-5,-7,0,7,5,1,3],C=N4(i[E],i[A]);for(l=Math.max(C[0].length,l),c[E]=new Array(l),c[A]=new Array(l),m=0;m<l;m++){var N=C[0][m]|0,T=C[1][m]|0;c[E][m]=O[(N+1)*3+(T+1)],c[A][m]=0,a[E]=R}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(u=l;u>=0;u--){for(var W=0;u>=0;){var V=!0;for(m=0;m<n;m++)z[m]=c[m][u]|0,z[m]!==0&&(V=!1);if(!V)break;W++,u--}if(u>=0&&W++,U=U.dblp(W),u<0)break;for(m=0;m<n;m++){var B=z[m];B!==0&&(B>0?x=a[m][B-1>>1]:B<0&&(x=a[m][-B-1>>1].neg()),x.type==="affine"?U=U.mixedAdd(x):U=U.add(x))}}for(u=0;u<n;u++)a[u]=null;return s?U:U.toP()};function ni(t,e){this.curve=t,this.type=e,this.precomputed=null}Fn.BasePoint=ni,ni.prototype.eq=function(){throw new Error("Not implemented")},ni.prototype.validate=function(){return this.curve.validate(this)},Fn.prototype.decodePoint=function(e,r){e=Vr.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Fc(e[e.length-1]%2===0):e[0]===7&&Fc(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},ni.prototype.encodeCompressed=function(e){return this.encode(e,!0)},ni.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},ni.prototype.encode=function(e,r){return Vr.encode(this._encode(r),e)},ni.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},ni.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},ni.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},ni.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},ni.prototype._getBeta=function(){return null},ni.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var tf=lo(function(t){typeof Object.create=="function"?t.exports=function(r,i){i&&(r.super_=i,r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(r,i){if(i){r.super_=i;var n=function(){};n.prototype=i.prototype,r.prototype=new n,r.prototype.constructor=r}}}),T4=Vr.assert;function si(t){vs.call(this,"short",t),this.a=new Ee(t.a,16).toRed(this.red),this.b=new Ee(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}tf(si,vs);var F4=si;si.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new Ee(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new Ee(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],T4(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new Ee(a.a,16),b:new Ee(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},si.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:Ee.mont(e),i=new Ee(2).toRed(r).redInvm(),n=i.redNeg(),s=new Ee(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},si.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new Ee(1),o=new Ee(0),a=new Ee(0),c=new Ee(1),l,u,m,x,S,E,A,R=0,O,C;i.cmpn(0)!==0;){var N=n.div(i);O=n.sub(N.mul(i)),C=a.sub(N.mul(s));var T=c.sub(N.mul(o));if(!m&&O.cmp(r)<0)l=A.neg(),u=s,m=O.neg(),x=C;else if(m&&++R===2)break;A=O,n=i,i=O,a=s,s=C,c=o,o=T}S=O.neg(),E=C;var U=m.sqr().add(x.sqr()),z=S.sqr().add(E.sqr());return z.cmp(U)>=0&&(S=l,E=u),m.negative&&(m=m.neg(),x=x.neg()),S.negative&&(S=S.neg(),E=E.neg()),[{a:m,b:x},{a:S,b:E}]},si.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),l=s.mul(i.b),u=o.mul(n.b),m=e.sub(a).sub(c),x=l.add(u).neg();return{k1:m,k2:x}},si.prototype.pointFromX=function(e,r){e=new Ee(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},si.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},si.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],l=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),l=l.neg(!0)),n[o*2]=c,n[o*2+1]=l,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return u};function Kt(t,e,r,i){vs.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Ee(e,16),this.y=new Ee(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}tf(Kt,vs.BasePoint),si.prototype.point=function(e,r,i){return new Kt(this,e,r,i)},si.prototype.pointFromJSON=function(e,r){return Kt.fromJSON(this,e,r)},Kt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},Kt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Kt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Kt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Kt.prototype.isInfinity=function(){return this.inf},Kt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Kt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Kt.prototype.getX=function(){return this.x.fromRed()},Kt.prototype.getY=function(){return this.y.fromRed()},Kt.prototype.mul=function(e){return e=new Ee(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Kt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Kt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Kt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Kt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},Kt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function or(t,e,r,i){vs.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ee(0)):(this.x=new Ee(e,16),this.y=new Ee(r,16),this.z=new Ee(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}tf(or,vs.BasePoint),si.prototype.jpoint=function(e,r,i){return new or(this,e,r,i)},or.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},or.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},or.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),l=o.redSub(a);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),m=u.redMul(c),x=n.redMul(u),S=l.redSqr().redIAdd(m).redISub(x).redISub(x),E=l.redMul(x.redISub(S)).redISub(o.redMul(m)),A=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(S,E,A)},or.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),m=i.redMul(l),x=c.redSqr().redIAdd(u).redISub(m).redISub(m),S=c.redMul(m.redISub(x)).redISub(s.redMul(u)),E=this.z.redMul(a);return this.curve.jpoint(x,S,E)},or.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,l=c.redSqr().redSqr(),u=a.redAdd(a);for(r=0;r<e;r++){var m=o.redSqr(),x=u.redSqr(),S=x.redSqr(),E=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(l)),A=o.redMul(x),R=E.redSqr().redISub(A.redAdd(A)),O=A.redISub(R),C=E.redMul(O);C=C.redIAdd(C).redISub(S);var N=u.redMul(c);r+1<e&&(l=l.redMul(S)),o=R,c=N,u=C}return this.curve.jpoint(o,u.redMul(s),c)},or.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},or.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),l=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=l,r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),x=this.y.redSqr(),S=x.redSqr(),E=this.x.redAdd(x).redSqr().redISub(m).redISub(S);E=E.redIAdd(E);var A=m.redAdd(m).redIAdd(m),R=A.redSqr(),O=S.redIAdd(S);O=O.redIAdd(O),O=O.redIAdd(O),e=R.redISub(E).redISub(E),r=A.redMul(E.redISub(e)).redISub(O),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},or.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),l=c.redSqr().redISub(a).redISub(a);e=l;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),x=this.y.redSqr(),S=this.x.redMul(x),E=this.x.redSub(m).redMul(this.x.redAdd(m));E=E.redAdd(E).redIAdd(E);var A=S.redIAdd(S);A=A.redIAdd(A);var R=A.redAdd(A);e=E.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(x).redISub(m);var O=x.redSqr();O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O),r=E.redMul(A.redISub(e)).redISub(O)}return this.curve.jpoint(e,r,i)},or.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),l=r.redAdd(r);l=l.redIAdd(l);var u=l.redMul(a),m=c.redSqr().redISub(u.redAdd(u)),x=u.redISub(m),S=a.redSqr();S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var E=c.redMul(x).redISub(S),A=i.redAdd(i).redMul(n);return this.curve.jpoint(m,E,A)},or.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),l=n.redIAdd(n);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(l),m=r.redMul(u);m=m.redIAdd(m),m=m.redIAdd(m);var x=this.x.redMul(c).redISub(m);x=x.redIAdd(x),x=x.redIAdd(x);var S=this.y.redMul(u.redMul(l.redISub(u)).redISub(a.redMul(c)));S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var E=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(x,S,E)},or.prototype.mul=function(e,r){return e=new Ee(e,r),this.curve._wnafMul(this,e)},or.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},or.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},or.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},or.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Lc=lo(function(t,e){var r=e;r.base=vs,r.short=F4,r.mont=null,r.edwards=null}),Bc=lo(function(t,e){var r=e,i=Vr.assert;function n(a){a.type==="short"?this.curve=new Lc.short(a):a.type==="edwards"?this.curve=new Lc.edwards(a):this.curve=new Lc.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(a,c){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var l=new n(c);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:l}),l}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Wr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Wr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Wr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Wr.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Wr.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Wr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Wr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Wr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ln(t){if(!(this instanceof Ln))return new Ln(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=$i.toArray(t.entropy,t.entropyEnc||"hex"),r=$i.toArray(t.nonce,t.nonceEnc||"hex"),i=$i.toArray(t.pers,t.persEnc||"hex");ef(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Bp=Ln;Ln.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Ln.prototype._hmac=function(){return new Wr.hmac(this.hash,this.K)},Ln.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Ln.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=$i.toArray(e,r),i=$i.toArray(i,n),ef(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ln.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=$i.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,$i.encode(o,r)};var rf=Vr.assert;function gr(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var nf=gr;gr.fromPublic=function(e,r,i){return r instanceof gr?r:new gr(e,{pub:r,pubEnc:i})},gr.fromPrivate=function(e,r,i){return r instanceof gr?r:new gr(e,{priv:r,privEnc:i})},gr.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},gr.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},gr.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},gr.prototype._importPrivate=function(e,r){this.priv=new Ee(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},gr.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?rf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&rf(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},gr.prototype.derive=function(e){return e.validate()||rf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},gr.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},gr.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},gr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var L4=Vr.assert;function Uc(t,e){if(t instanceof Uc)return t;this._importDER(t,e)||(L4(t.r&&t.s,"Signature without r or s"),this.r=new Ee(t.r,16),this.s=new Ee(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var qc=Uc;function B4(){this.place=0}function sf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Up(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}Uc.prototype._importDER=function(e,r){e=Vr.toArray(e,r);var i=new B4;if(e[i.place++]!==48)return!1;var n=sf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=sf(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=sf(e,i);if(a===!1||e.length!==a+i.place)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new Ee(o),this.s=new Ee(c),this.recoveryParam=null,!0};function of(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Uc.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Up(r),i=Up(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];of(n,r.length),n=n.concat(r),n.push(2),of(n,i.length);var s=n.concat(i),o=[48];return of(o,s.length),o=o.concat(s),Vr.encode(o,e)};var U4=function(){throw new Error("unsupported")},qp=Vr.assert;function oi(t){if(!(this instanceof oi))return new oi(t);typeof t=="string"&&(qp(Object.prototype.hasOwnProperty.call(Bc,t),"Unknown curve "+t),t=Bc[t]),t instanceof Bc.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var q4=oi;oi.prototype.keyPair=function(e){return new nf(this,e)},oi.prototype.keyFromPrivate=function(e,r){return nf.fromPrivate(this,e,r)},oi.prototype.keyFromPublic=function(e,r){return nf.fromPublic(this,e,r)},oi.prototype.genKeyPair=function(e){e||(e={});for(var r=new Bp({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||U4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ee(2));;){var s=new Ee(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},oi.prototype._truncateToN=function(e,r){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},oi.prototype.sign=function(e,r,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),r=this.keyFromPrivate(r,i),e=this._truncateToN(new Ee(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new Bp({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new Ee(1)),u=0;;u++){var m=n.k?n.k(u):new Ee(c.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(l)>=0)){var x=this.g.mul(m);if(!x.isInfinity()){var S=x.getX(),E=S.umod(this.n);if(E.cmpn(0)!==0){var A=m.invm(this.n).mul(E.mul(r.getPrivate()).iadd(e));if(A=A.umod(this.n),A.cmpn(0)!==0){var R=(x.getY().isOdd()?1:0)|(S.cmp(E)!==0?2:0);return n.canonical&&A.cmp(this.nh)>0&&(A=this.n.sub(A),R^=1),new qc({r:E,s:A,recoveryParam:R})}}}}}},oi.prototype.verify=function(e,r,i,n){e=this._truncateToN(new Ee(e,16)),i=this.keyFromPublic(i,n),r=new qc(r,"hex");var s=r.r,o=r.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),c=a.mul(e).umod(this.n),l=a.mul(s).umod(this.n),u;return this.curve._maxwellTrick?(u=this.g.jmulAdd(c,i.getPublic(),l),u.isInfinity()?!1:u.eqXToP(s)):(u=this.g.mulAdd(c,i.getPublic(),l),u.isInfinity()?!1:u.getX().umod(this.n).cmp(s)===0)},oi.prototype.recoverPubKey=function(t,e,r,i){qp((3&r)===r,"The recovery param is more than two bits"),e=new qc(e,i);var n=this.n,s=new Ee(t),o=e.r,a=e.s,c=r&1,l=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var u=e.r.invm(n),m=n.sub(s).mul(u).umod(n),x=a.mul(u).umod(n);return this.g.mulAdd(m,o,x)},oi.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new qc(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var j4=lo(function(t,e){var r=e;r.version="6.5.4",r.utils=Vr,r.rand=function(){throw new Error("unsupported")},r.curve=Lc,r.curves=Bc,r.ec=q4,r.eddsa=null}),k4=j4.ec;const z4="signing-key/5.7.0",af=new Me(z4);let cf=null;function qi(){return cf||(cf=new k4("secp256k1")),cf}class H4{constructor(e){xa(this,"curve","secp256k1"),xa(this,"privateKey",xr(e)),Kw(this.privateKey)!==32&&af.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=qi().keyFromPrivate(zt(this.privateKey));xa(this,"publicKey","0x"+r.getPublic(!1,"hex")),xa(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),xa(this,"_isSigningKey",!0)}_addPoint(e){const r=qi().keyFromPublic(zt(this.publicKey)),i=qi().keyFromPublic(zt(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=qi().keyFromPrivate(zt(this.privateKey)),i=zt(e);i.length!==32&&af.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return rp({recoveryParam:n.recoveryParam,r:Nn("0x"+n.r.toString(16),32),s:Nn("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=qi().keyFromPrivate(zt(this.privateKey)),i=qi().keyFromPublic(zt(jp(e)));return Nn("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function W4(t,e){const r=rp(e),i={r:zt(r.r),s:zt(r.s)};return"0x"+qi().recoverPubKey(zt(t),i,r.recoveryParam).encode("hex",!1)}function jp(t,e){const r=zt(t);if(r.length===32){const i=new H4(r);return e?"0x"+qi().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?xr(r):"0x"+qi().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+qi().keyFromPublic(r).getPublic(!0,"hex"):xr(r)}return af.throwArgumentError("invalid public or private key","key","[REDACTED]")}const V4="transactions/5.7.0";new Me(V4);var kp;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(kp||(kp={}));function K4(t){const e=jp(t);return s3(tp(up(tp(e,1)),12))}function G4(t,e){return K4(W4(zt(t),e))}const J4=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Z4=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 ms(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Z4(t)}catch{return t}}function ln(t){return typeof t=="string"?t:J4(t)||""}function Y4(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zp(t,...e){if(!Y4(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 Hp(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 X4(t,e){zp(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ho=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const lf=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Q4(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Wp(t){return typeof t=="string"&&(t=Q4(t)),zp(t),t}class e6{clone(){return this._cloneInto()}}function t6(t){const e=i=>t().update(Wp(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Vp(t=32){if(ho&&typeof ho.getRandomValues=="function")return ho.getRandomValues(new Uint8Array(t));if(ho&&typeof ho.randomBytes=="function")return ho.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function r6(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}class i6 extends e6{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=lf(this.buffer)}update(e){Hp(this);const{view:r,buffer:i,blockLen:n}=this;e=Wp(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=lf(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){Hp(this),X4(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 m=o;m<n;m++)r[m]=0;r6(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=lf(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)a.setUint32(4*m,u[m],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 jc=BigInt(2**32-1),hf=BigInt(32);function Kp(t,e=!1){return e?{h:Number(t&jc),l:Number(t>>hf&jc)}:{h:Number(t>>hf&jc)|0,l:Number(t&jc)|0}}function n6(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}=Kp(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const s6=(t,e)=>BigInt(t>>>0)<<hf|BigInt(e>>>0),o6=(t,e,r)=>t>>>r,a6=(t,e,r)=>t<<32-r|e>>>r,c6=(t,e,r)=>t>>>r|e<<32-r,l6=(t,e,r)=>t<<32-r|e>>>r,h6=(t,e,r)=>t<<64-r|e>>>r-32,f6=(t,e,r)=>t>>>r-32|e<<64-r,u6=(t,e)=>e,d6=(t,e)=>t,p6=(t,e,r)=>t<<r|e>>>32-r,g6=(t,e,r)=>e<<r|t>>>32-r,v6=(t,e,r)=>e<<r-32|t>>>64-r,m6=(t,e,r)=>t<<r-32|e>>>64-r;function b6(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const y6=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),w6=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,_6=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),x6=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,E6=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),$6=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,Ie={fromBig:Kp,split:n6,toBig:s6,shrSH:o6,shrSL:a6,rotrSH:c6,rotrSL:l6,rotrBH:h6,rotrBL:f6,rotr32H:u6,rotr32L:d6,rotlSH:p6,rotlSL:g6,rotlBH:v6,rotlBL:m6,add:b6,add3L:y6,add3H:w6,add4L:_6,add4H:x6,add5H:$6,add5L:E6},[S6,I6]=Ie.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))),Bn=new Uint32Array(80),Un=new Uint32Array(80);class A6 extends i6{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:l,El:u,Fh:m,Fl:x,Gh:S,Gl:E,Hh:A,Hl:R}=this;return[e,r,i,n,s,o,a,c,l,u,m,x,S,E,A,R]}set(e,r,i,n,s,o,a,c,l,u,m,x,S,E,A,R){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=l|0,this.El=u|0,this.Fh=m|0,this.Fl=x|0,this.Gh=S|0,this.Gl=E|0,this.Hh=A|0,this.Hl=R|0}process(e,r){for(let N=0;N<16;N++,r+=4)Bn[N]=e.getUint32(r),Un[N]=e.getUint32(r+=4);for(let N=16;N<80;N++){const T=Bn[N-15]|0,U=Un[N-15]|0,z=Ie.rotrSH(T,U,1)^Ie.rotrSH(T,U,8)^Ie.shrSH(T,U,7),W=Ie.rotrSL(T,U,1)^Ie.rotrSL(T,U,8)^Ie.shrSL(T,U,7),V=Bn[N-2]|0,B=Un[N-2]|0,K=Ie.rotrSH(V,B,19)^Ie.rotrBH(V,B,61)^Ie.shrSH(V,B,6),M=Ie.rotrSL(V,B,19)^Ie.rotrBL(V,B,61)^Ie.shrSL(V,B,6),v=Ie.add4L(W,M,Un[N-7],Un[N-16]),g=Ie.add4H(v,z,K,Bn[N-7],Bn[N-16]);Bn[N]=g|0,Un[N]=v|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:m,El:x,Fh:S,Fl:E,Gh:A,Gl:R,Hh:O,Hl:C}=this;for(let N=0;N<80;N++){const T=Ie.rotrSH(m,x,14)^Ie.rotrSH(m,x,18)^Ie.rotrBH(m,x,41),U=Ie.rotrSL(m,x,14)^Ie.rotrSL(m,x,18)^Ie.rotrBL(m,x,41),z=m&S^~m&A,W=x&E^~x&R,V=Ie.add5L(C,U,W,I6[N],Un[N]),B=Ie.add5H(V,O,T,z,S6[N],Bn[N]),K=V|0,M=Ie.rotrSH(i,n,28)^Ie.rotrBH(i,n,34)^Ie.rotrBH(i,n,39),v=Ie.rotrSL(i,n,28)^Ie.rotrBL(i,n,34)^Ie.rotrBL(i,n,39),g=i&s^i&a^s&a,h=n&o^n&c^o&c;O=A|0,C=R|0,A=S|0,R=E|0,S=m|0,E=x|0,{h:m,l:x}=Ie.add(l|0,u|0,B|0,K|0),l=a|0,u=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const f=Ie.add3L(K,v,h);i=Ie.add3H(f,B,M,g),n=f|0}({h:i,l:n}=Ie.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=Ie.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=Ie.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Ie.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:m,l:x}=Ie.add(this.Eh|0,this.El|0,m|0,x|0),{h:S,l:E}=Ie.add(this.Fh|0,this.Fl|0,S|0,E|0),{h:A,l:R}=Ie.add(this.Gh|0,this.Gl|0,A|0,R|0),{h:O,l:C}=Ie.add(this.Hh|0,this.Hl|0,O|0,C|0),this.set(i,n,s,o,a,c,l,u,m,x,S,E,A,R,O,C)}roundClean(){Bn.fill(0),Un.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 M6=t6(()=>new A6);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ff=BigInt(0),Gp=BigInt(1),P6=BigInt(2);function uf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function df(t){if(!uf(t))throw new Error("Uint8Array expected")}function pf(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const O6=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gf(t){df(t);let e="";for(let r=0;r<t.length;r++)e+=O6[t[r]];return e}function Jp(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ff:BigInt("0x"+t)}const hn={_0:48,_9:57,A:65,F:70,a:97,f:102};function Zp(t){if(t>=hn._0&&t<=hn._9)return t-hn._0;if(t>=hn.A&&t<=hn.F)return t-(hn.A-10);if(t>=hn.a&&t<=hn.f)return t-(hn.a-10)}function Yp(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=Zp(t.charCodeAt(s)),a=Zp(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 C6(t){return Jp(gf(t))}function kc(t){return df(t),Jp(gf(Uint8Array.from(t).reverse()))}function Xp(t,e){return Yp(t.toString(16).padStart(e*2,"0"))}function vf(t,e){return Xp(t,e).reverse()}function fn(t,e,r){let i;if(typeof e=="string")try{i=Yp(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(uf(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 Qp(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];df(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 mf=t=>typeof t=="bigint"&&ff<=t;function D6(t,e,r){return mf(t)&&mf(e)&&mf(r)&&e<=t&&t<r}function Sa(t,e,r,i){if(!D6(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function R6(t){let e;for(e=0;t>ff;t>>=Gp,e+=1);return e}const N6=t=>(P6<<BigInt(t-1))-Gp,T6={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"||uf(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 bf(t,e,r={}){const i=(n,s,o)=>{const a=T6[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 e1(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 Gt=BigInt(0),Bt=BigInt(1),bs=BigInt(2),F6=BigInt(3),yf=BigInt(4),t1=BigInt(5),r1=BigInt(8);function Ht(t,e){const r=t%e;return r>=Gt?r:e+r}function L6(t,e,r){if(e<Gt)throw new Error("invalid exponent, negatives unsupported");if(r<=Gt)throw new Error("invalid modulus");if(r===Bt)return Gt;let i=Bt;for(;e>Gt;)e&Bt&&(i=i*t%r),t=t*t%r,e>>=Bt;return i}function ji(t,e,r){let i=t;for(;e-- >Gt;)i*=i,i%=r;return i}function i1(t,e){if(t===Gt)throw new Error("invert: expected non-zero number");if(e<=Gt)throw new Error("invert: expected positive modulus, got "+e);let r=Ht(t,e),i=e,n=Gt,s=Bt;for(;r!==Gt;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==Bt)throw new Error("invert: does not exist");return Ht(n,e)}function B6(t){const e=(t-Bt)/bs;let r,i,n;for(r=t-Bt,i=0;r%bs===Gt;r/=bs,i++);for(n=bs;n<t&&L6(n,e,t)!==t-Bt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+Bt)/yf;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(r+Bt)/bs;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,l=o.pow(o.mul(o.ONE,n),r),u=o.pow(a,s),m=o.pow(a,r);for(;!o.eql(m,o.ONE);){if(o.eql(m,o.ZERO))return o.ZERO;let x=1;for(let E=o.sqr(m);x<c&&!o.eql(E,o.ONE);x++)E=o.sqr(E);const S=o.pow(l,Bt<<BigInt(c-x-1));l=o.sqr(S),u=o.mul(u,S),m=o.mul(m,l),c=x}return u}}function U6(t){if(t%yf===F6){const e=(t+Bt)/yf;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%r1===t1){const e=(t-t1)/r1;return function(r,i){const n=r.mul(i,bs),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,bs),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 B6(t)}const q6=(t,e)=>(Ht(t,e)&Bt)===Bt,j6=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function k6(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=j6.reduce((i,n)=>(i[n]="function",i),e);return bf(t,r)}function z6(t,e,r){if(r<Gt)throw new Error("invalid exponent, negatives unsupported");if(r===Gt)return t.ONE;if(r===Bt)return e;let i=t.ONE,n=e;for(;r>Gt;)r&Bt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=Bt;return i}function H6(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 n1(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function s1(t,e,r=!1,i={}){if(t<=Gt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=n1(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:N6(n),ZERO:Gt,ONE:Bt,create:c=>Ht(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Gt<=c&&c<t},is0:c=>c===Gt,isOdd:c=>(c&Bt)===Bt,neg:c=>Ht(-c,t),eql:(c,l)=>c===l,sqr:c=>Ht(c*c,t),add:(c,l)=>Ht(c+l,t),sub:(c,l)=>Ht(c-l,t),mul:(c,l)=>Ht(c*l,t),pow:(c,l)=>z6(a,c,l),div:(c,l)=>Ht(c*i1(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>i1(c,t),sqrt:i.sqrt||(c=>(o||(o=U6(t)),o(a,c))),invertBatch:c=>H6(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?vf(c,s):Xp(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?kc(c):C6(c)}});return Object.freeze(a)}const o1=BigInt(0),zc=BigInt(1);function wf(t,e){const r=e.negate();return t?r:e}function a1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function _f(t,e){a1(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function W6(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 V6(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 xf=new WeakMap,c1=new WeakMap;function Ef(t){return c1.get(t)||1}function K6(t,e){return{constTimeNegate:wf,hasPrecomputes(r){return Ef(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>o1;)i&zc&&(n=n.add(s)),s=s.double(),i>>=zc;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=_f(i,e),o=[];let a=r,c=a;for(let l=0;l<n;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=_f(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,m=BigInt(r);for(let x=0;x<s;x++){const S=x*o;let E=Number(n&l);n>>=m,E>o&&(E-=u,n+=zc);const A=S,R=S+Math.abs(E)-1,O=x%2!==0,C=E<0;E===0?c=c.add(wf(O,i[A])):a=a.add(wf(C,i[R]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=_f(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let m=0;m<o;m++){const x=m*a;if(n===o1)break;let S=Number(n&c);if(n>>=u,S>a&&(S-=l,n+=zc),S===0)continue;let E=i[x+Math.abs(S)-1];S<0&&(E=E.negate()),s=s.add(E)}return s},getPrecomputes(r,i,n){let s=xf.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&xf.set(i,n(s))),s},wNAFCached(r,i,n){const s=Ef(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=Ef(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){a1(i,e),c1.set(r,i),xf.delete(r)}}}function G6(t,e,r,i){if(W6(r,t),V6(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=R6(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),l=Math.floor((e.BITS-1)/o)*o;let u=n;for(let m=l;m>=0;m-=o){c.fill(n);for(let S=0;S<i.length;S++){const E=i[S],A=Number(E>>BigInt(m)&BigInt(a));c[A]=c[A].add(r[S])}let x=n;for(let S=c.length-1,E=n;S>0;S--)E=E.add(c[S]),x=x.add(E);if(u=u.add(x),m!==0)for(let S=0;S<o;S++)u=u.double()}return u}function J6(t){return k6(t.Fp),bf(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...n1(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Si=BigInt(0),Cr=BigInt(1),Hc=BigInt(2),Z6=BigInt(8),Y6={zip215:!0};function X6(t){const e=J6(t);return bf(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Q6(t){const e=X6(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=Hc<<BigInt(a*8)-Cr,u=r.create,m=s1(e.n,e.nBitLength),x=e.uvRatio||((f,p)=>{try{return{isValid:!0,value:r.sqrt(f*r.inv(p))}}catch{return{isValid:!1,value:Si}}}),S=e.adjustScalarBytes||(f=>f),E=e.domain||((f,p,_)=>{if(pf("phflag",_),p.length||_)throw new Error("Contexts/pre-hash are not supported");return f});function A(f,p){Sa("coordinate "+f,p,Si,l)}function R(f){if(!(f instanceof N))throw new Error("ExtendedPoint expected")}const O=e1((f,p)=>{const{ex:_,ey:$,ez:y}=f,d=f.is0();p==null&&(p=d?Z6:r.inv(y));const w=u(_*p),b=u($*p),P=u(y*p);if(d)return{x:Si,y:Cr};if(P!==Cr)throw new Error("invZ was invalid");return{x:w,y:b}}),C=e1(f=>{const{a:p,d:_}=e;if(f.is0())throw new Error("bad point: ZERO");const{ex:$,ey:y,ez:d,et:w}=f,b=u($*$),P=u(y*y),q=u(d*d),I=u(q*q),F=u(b*p),j=u(q*u(F+P)),k=u(I+u(_*u(b*P)));if(j!==k)throw new Error("bad point: equation left != right (1)");const H=u($*y),Y=u(d*w);if(H!==Y)throw new Error("bad point: equation left != right (2)");return!0});class N{constructor(p,_,$,y){this.ex=p,this.ey=_,this.ez=$,this.et=y,A("x",p),A("y",_),A("z",$),A("t",y),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof N)throw new Error("extended point not allowed");const{x:_,y:$}=p||{};return A("x",_),A("y",$),new N(_,$,Cr,u(_*$))}static normalizeZ(p){const _=r.invertBatch(p.map($=>$.ez));return p.map(($,y)=>$.toAffine(_[y])).map(N.fromAffine)}static msm(p,_){return G6(N,m,p,_)}_setWindowSize(p){z.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){R(p);const{ex:_,ey:$,ez:y}=this,{ex:d,ey:w,ez:b}=p,P=u(_*b),q=u(d*y),I=u($*b),F=u(w*y);return P===q&&I===F}is0(){return this.equals(N.ZERO)}negate(){return new N(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:p}=e,{ex:_,ey:$,ez:y}=this,d=u(_*_),w=u($*$),b=u(Hc*u(y*y)),P=u(p*d),q=_+$,I=u(u(q*q)-d-w),F=P+w,j=F-b,k=P-w,H=u(I*j),Y=u(F*k),Q=u(I*k),J=u(j*F);return new N(H,Y,J,Q)}add(p){R(p);const{a:_,d:$}=e,{ex:y,ey:d,ez:w,et:b}=this,{ex:P,ey:q,ez:I,et:F}=p;if(_===BigInt(-1)){const qe=u((d-y)*(q+P)),je=u((d+y)*(q-P)),he=u(je-qe);if(he===Si)return this.double();const ke=u(w*Hc*F),ze=u(b*Hc*I),ue=ze+ke,He=je+qe,We=ze-ke,le=u(ue*he),Be=u(He*We),Ve=u(ue*We),oe=u(he*He);return new N(le,Be,oe,Ve)}const j=u(y*P),k=u(d*q),H=u(b*$*F),Y=u(w*I),Q=u((y+d)*(P+q)-j-k),J=Y-H,ae=Y+H,re=u(k-_*j),ie=u(Q*J),Ze=u(ae*re),Ye=u(Q*re),de=u(J*ae);return new N(ie,Ze,de,Ye)}subtract(p){return this.add(p.negate())}wNAF(p){return z.wNAFCached(this,p,N.normalizeZ)}multiply(p){const _=p;Sa("scalar",_,Cr,i);const{p:$,f:y}=this.wNAF(_);return N.normalizeZ([$,y])[0]}multiplyUnsafe(p,_=N.ZERO){const $=p;return Sa("scalar",$,Si,i),$===Si?U:this.is0()||$===Cr?this:z.wNAFCachedUnsafe(this,$,N.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return z.unsafeLadder(this,i).is0()}toAffine(p){return O(this,p)}clearCofactor(){const{h:p}=e;return p===Cr?this:this.multiplyUnsafe(p)}static fromHex(p,_=!1){const{d:$,a:y}=e,d=r.BYTES;p=fn("pointHex",p,d),pf("zip215",_);const w=p.slice(),b=p[d-1];w[d-1]=b&-129;const P=kc(w),q=_?l:r.ORDER;Sa("pointHex.y",P,Si,q);const I=u(P*P),F=u(I-Cr),j=u($*I-y);let{isValid:k,value:H}=x(F,j);if(!k)throw new Error("Point.fromHex: invalid y coordinate");const Y=(H&Cr)===Cr,Q=(b&128)!==0;if(!_&&H===Si&&Q)throw new Error("Point.fromHex: x=0 and x_0=1");return Q!==Y&&(H=u(-H)),N.fromAffine({x:H,y:P})}static fromPrivateKey(p){return B(p).point}toRawBytes(){const{x:p,y:_}=this.toAffine(),$=vf(_,r.BYTES);return $[$.length-1]|=p&Cr?128:0,$}toHex(){return gf(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,Cr,u(e.Gx*e.Gy)),N.ZERO=new N(Si,Cr,Cr,Si);const{BASE:T,ZERO:U}=N,z=K6(N,a*8);function W(f){return Ht(f,i)}function V(f){return W(kc(f))}function B(f){const p=r.BYTES;f=fn("private key",f,p);const _=fn("hashed private key",s(f),2*p),$=S(_.slice(0,p)),y=_.slice(p,2*p),d=V($),w=T.multiply(d),b=w.toRawBytes();return{head:$,prefix:y,scalar:d,point:w,pointBytes:b}}function K(f){return B(f).pointBytes}function M(f=new Uint8Array,...p){const _=Qp(...p);return V(s(E(_,fn("context",f),!!n)))}function v(f,p,_={}){f=fn("message",f),n&&(f=n(f));const{prefix:$,scalar:y,pointBytes:d}=B(p),w=M(_.context,$,f),b=T.multiply(w).toRawBytes(),P=M(_.context,b,d,f),q=W(w+P*y);Sa("signature.s",q,Si,i);const I=Qp(b,vf(q,r.BYTES));return fn("result",I,r.BYTES*2)}const g=Y6;function h(f,p,_,$=g){const{context:y,zip215:d}=$,w=r.BYTES;f=fn("signature",f,2*w),p=fn("message",p),_=fn("publicKey",_,w),d!==void 0&&pf("zip215",d),n&&(p=n(p));const b=kc(f.slice(w,2*w));let P,q,I;try{P=N.fromHex(_,d),q=N.fromHex(f.slice(0,w),d),I=T.multiplyUnsafe(b)}catch{return!1}if(!d&&P.isSmallOrder())return!1;const F=M(y,q.toRawBytes(),P.toRawBytes(),p);return q.add(P.multiplyUnsafe(F)).subtract(I).clearCofactor().equals(N.ZERO)}return T._setWindowSize(8),{CURVE:e,getPublicKey:K,sign:v,verify:h,ExtendedPoint:N,utils:{getExtendedPublicKey:B,randomPrivateKey:()=>o(r.BYTES),precompute(f=8,p=N.BASE){return p._setWindowSize(f),p.multiply(BigInt(3)),p}}}}BigInt(0),BigInt(1);const $f=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const e5=BigInt(1),h1=BigInt(2);BigInt(3);const t5=BigInt(5),r5=BigInt(8);function i5(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=$f,o=t*t%s*t%s,a=ji(o,h1,s)*o%s,c=ji(a,e5,s)*t%s,l=ji(c,t5,s)*c%s,u=ji(l,e,s)*l%s,m=ji(u,r,s)*u%s,x=ji(m,i,s)*m%s,S=ji(x,n,s)*x%s,E=ji(S,n,s)*x%s,A=ji(E,e,s)*l%s;return{pow_p_5_8:ji(A,h1,s)*t%s,b2:o}}function n5(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function s5(t,e){const r=$f,i=Ht(e*e*e,r),n=Ht(i*i*e,r),s=i5(t*n).pow_p_5_8;let o=Ht(t*i*s,r);const a=Ht(e*o*o,r),c=o,l=Ht(o*l1,r),u=a===t,m=a===Ht(-t,r),x=a===Ht(-t*l1,r);return u&&(o=c),(m||x)&&(o=l),q6(o,r)&&(o=Ht(-o,r)),{isValid:u||m,value:o}}const o5=s1($f,void 0,!0),a5={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:o5,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:r5,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:M6,randomBytes:Vp,adjustScalarBytes:n5,uvRatio:s5},f1=Q6(a5),c5="EdDSA",l5="JWT",Wc=".",Vc="base64url",u1="utf8",d1="utf8",h5=":",f5="did",u5="key",p1="base58btc",d5="z",p5="K36",g5=32;function Sf(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function g1(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Sf(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function v1(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=g1(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return Sf(r)}function v5(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function m(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var A=0,R=0,O=0,C=E.length;O!==C&&E[O]===0;)O++,A++;for(var N=(C-O)*u+1>>>0,T=new Uint8Array(N);O!==C;){for(var U=E[O],z=0,W=N-1;(U!==0||z<R)&&W!==-1;W--,z++)U+=256*T[W]>>>0,T[W]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");R=z,O++}for(var V=N-R;V!==N&&T[V]===0;)V++;for(var B=c.repeat(A);V<N;++V)B+=t.charAt(T[V]);return B}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var R=0,O=0;E[A]===c;)R++,A++;for(var C=(E.length-A)*l+1>>>0,N=new Uint8Array(C);E[A];){var T=r[E.charCodeAt(A)];if(T===255)return;for(var U=0,z=C-1;(T!==0||U<O)&&z!==-1;z--,U++)T+=a*N[z]>>>0,N[z]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");O=U,A++}if(E[A]!==" "){for(var W=C-O;W!==C&&N[W]===0;)W++;for(var V=new Uint8Array(R+(C-W)),B=R;W!==C;)V[B++]=N[W++];return V}}}function S(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:x,decode:S}}var m5=v5,b5=m5;const m1=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")},y5=t=>new TextEncoder().encode(t),w5=t=>new TextDecoder().decode(t);class _5{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 x5{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 b1(this,e)}}class E5{constructor(e){this.decoders=e}or(e){return b1(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 b1=(t,e)=>new E5({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class $5{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new _5(e,r,i),this.decoder=new x5(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Kc=({name:t,prefix:e,encode:r,decode:i})=>new $5(t,e,r,i),Ia=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=b5(r,e);return Kc({prefix:t,name:e,encode:i,decode:s=>m1(n(s))})},S5=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const m=n[t[u]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|m,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},I5=(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},ar=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Kc({prefix:e,name:t,encode(n){return I5(n,i,r)},decode(n){return S5(n,i,r,t)}}),A5=Kc({prefix:"\0",name:"identity",encode:t=>w5(t),decode:t=>y5(t)});var M5=Object.freeze({__proto__:null,identity:A5});const P5=ar({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var O5=Object.freeze({__proto__:null,base2:P5});const C5=ar({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var D5=Object.freeze({__proto__:null,base8:C5});const R5=Ia({prefix:"9",name:"base10",alphabet:"0123456789"});var N5=Object.freeze({__proto__:null,base10:R5});const T5=ar({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),F5=ar({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var L5=Object.freeze({__proto__:null,base16:T5,base16upper:F5});const B5=ar({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U5=ar({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),q5=ar({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j5=ar({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),k5=ar({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),z5=ar({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H5=ar({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),W5=ar({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),V5=ar({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var K5=Object.freeze({__proto__:null,base32:B5,base32upper:U5,base32pad:q5,base32padupper:j5,base32hex:k5,base32hexupper:z5,base32hexpad:H5,base32hexpadupper:W5,base32z:V5});const G5=Ia({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),J5=Ia({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Z5=Object.freeze({__proto__:null,base36:G5,base36upper:J5});const Y5=Ia({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),X5=Ia({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Q5=Object.freeze({__proto__:null,base58btc:Y5,base58flickr:X5});const e8=ar({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),t8=ar({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),r8=ar({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),i8=ar({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var n8=Object.freeze({__proto__:null,base64:e8,base64pad:t8,base64url:r8,base64urlpad:i8});const y1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),s8=y1.reduce((t,e,r)=>(t[r]=e,t),[]),o8=y1.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function a8(t){return t.reduce((e,r)=>(e+=s8[r],e),"")}function c8(t){const e=[];for(const r of t){const i=o8[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const l8=Kc({prefix:"\u{1F680}",name:"base256emoji",encode:a8,decode:c8});var h8=Object.freeze({__proto__:null,base256emoji:l8}),f8=_1,w1=128,u8=127,d8=~u8,p8=Math.pow(2,31);function _1(t,e,r){e=e||[],r=r||0;for(var i=r;t>=p8;)e[r++]=t&255|w1,t/=128;for(;t&d8;)e[r++]=t&255|w1,t>>>=7;return e[r]=t|0,_1.bytes=r-i+1,e}var g8=If,v8=128,x1=127;function If(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw If.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&x1)<<n:(o&x1)*Math.pow(2,n),n+=7}while(o>=v8);return If.bytes=s-i,r}var m8=Math.pow(2,7),b8=Math.pow(2,14),y8=Math.pow(2,21),w8=Math.pow(2,28),_8=Math.pow(2,35),x8=Math.pow(2,42),E8=Math.pow(2,49),$8=Math.pow(2,56),S8=Math.pow(2,63),I8=function(t){return t<m8?1:t<b8?2:t<y8?3:t<w8?4:t<_8?5:t<x8?6:t<E8?7:t<$8?8:t<S8?9:10},A8={encode:f8,decode:g8,encodingLength:I8},E1=A8;const $1=(t,e,r=0)=>(E1.encode(t,e,r),e),S1=t=>E1.encodingLength(t),Af=(t,e)=>{const r=e.byteLength,i=S1(t),n=i+S1(r),s=new Uint8Array(n+r);return $1(t,s,0),$1(r,s,i),s.set(e,n),new M8(t,r,e,s)};class M8{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const I1=({name:t,code:e,encode:r})=>new P8(t,e,r);class P8{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?Af(this.code,r):r.then(i=>Af(this.code,i))}else throw Error("Unknown type, must be binary type")}}const A1=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),O8=I1({name:"sha2-256",code:18,encode:A1("SHA-256")}),C8=I1({name:"sha2-512",code:19,encode:A1("SHA-512")});var D8=Object.freeze({__proto__:null,sha256:O8,sha512:C8});const M1=0,R8="identity",P1=m1;var N8=Object.freeze({__proto__:null,identity:{code:M1,name:R8,encode:P1,digest:t=>Af(M1,P1(t))}});new TextEncoder,new TextDecoder;const O1={...M5,...O5,...D5,...N5,...L5,...K5,...Z5,...Q5,...n8,...h8};({...D8,...N8});function C1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const D1=C1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Mf=C1("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=g1(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),R1={utf8:D1,"utf-8":D1,hex:O1.base16,latin1:Mf,ascii:Mf,binary:Mf,...O1};function Gc(t,e="utf8"){const r=R1[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 fo(t,e="utf8"){const r=R1[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Sf(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function N1(t){return ms(Gc(fo(t,Vc),u1))}function Jc(t){return Gc(fo(ln(t),u1),Vc)}function T1(t){const e=fo(p5,p1),r=d5+Gc(v1([e,t]),p1);return[f5,u5,r].join(h5)}function T8(t){return Gc(t,Vc)}function F8(t){return fo(t,Vc)}function L8(t){return fo([Jc(t.header),Jc(t.payload)].join(Wc),d1)}function B8(t){return[Jc(t.header),Jc(t.payload),T8(t.signature)].join(Wc)}function Pf(t){const e=t.split(Wc),r=N1(e[0]),i=N1(e[1]),n=F8(e[2]),s=fo(e.slice(0,2).join(Wc),d1);return{header:r,payload:i,signature:n,data:s}}function F1(t=Vp(g5)){const e=f1.getPublicKey(t);return{secretKey:v1([t,e]),publicKey:e}}async function U8(t,e,r,i,n=X.fromMiliseconds(Date.now())){const s={alg:c5,typ:l5},o=T1(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},l=L8({header:s,payload:c}),u=f1.sign(l,i.secretKey.slice(0,32));return B8({header:s,payload:c,signature:u})}function L1(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Of(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=L1(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function q8(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function m(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var A=0,R=0,O=0,C=E.length;O!==C&&E[O]===0;)O++,A++;for(var N=(C-O)*u+1>>>0,T=new Uint8Array(N);O!==C;){for(var U=E[O],z=0,W=N-1;(U!==0||z<R)&&W!==-1;W--,z++)U+=256*T[W]>>>0,T[W]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");R=z,O++}for(var V=N-R;V!==N&&T[V]===0;)V++;for(var B=c.repeat(A);V<N;++V)B+=t.charAt(T[V]);return B}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var R=0,O=0;E[A]===c;)R++,A++;for(var C=(E.length-A)*l+1>>>0,N=new Uint8Array(C);E[A];){var T=r[E.charCodeAt(A)];if(T===255)return;for(var U=0,z=C-1;(T!==0||U<O)&&z!==-1;z--,U++)T+=a*N[z]>>>0,N[z]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");O=U,A++}if(E[A]!==" "){for(var W=C-O;W!==C&&N[W]===0;)W++;for(var V=new Uint8Array(R+(C-W)),B=R;W!==C;)V[B++]=N[W++];return V}}}function S(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:x,decode:S}}var j8=q8,k8=j8;const B1=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")},z8=t=>new TextEncoder().encode(t),H8=t=>new TextDecoder().decode(t);class W8{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 V8{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 U1(this,e)}}class K8{constructor(e){this.decoders=e}or(e){return U1(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 U1=(t,e)=>new K8({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class G8{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new W8(e,r,i),this.decoder=new V8(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Zc=({name:t,prefix:e,encode:r,decode:i})=>new G8(t,e,r,i),Aa=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=k8(r,e);return Zc({prefix:t,name:e,encode:i,decode:s=>B1(n(s))})},J8=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const m=n[t[u]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|m,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Z8=(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},cr=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Zc({prefix:e,name:t,encode(n){return Z8(n,i,r)},decode(n){return J8(n,i,r,t)}}),Y8=Zc({prefix:"\0",name:"identity",encode:t=>H8(t),decode:t=>z8(t)});var X8=Object.freeze({__proto__:null,identity:Y8});const Q8=cr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var e7=Object.freeze({__proto__:null,base2:Q8});const t7=cr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var r7=Object.freeze({__proto__:null,base8:t7});const i7=Aa({prefix:"9",name:"base10",alphabet:"0123456789"});var n7=Object.freeze({__proto__:null,base10:i7});const s7=cr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),o7=cr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var a7=Object.freeze({__proto__:null,base16:s7,base16upper:o7});const c7=cr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),l7=cr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),h7=cr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),f7=cr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),u7=cr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),d7=cr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),p7=cr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),g7=cr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),v7=cr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var m7=Object.freeze({__proto__:null,base32:c7,base32upper:l7,base32pad:h7,base32padupper:f7,base32hex:u7,base32hexupper:d7,base32hexpad:p7,base32hexpadupper:g7,base32z:v7});const b7=Aa({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),y7=Aa({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var w7=Object.freeze({__proto__:null,base36:b7,base36upper:y7});const _7=Aa({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),x7=Aa({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var E7=Object.freeze({__proto__:null,base58btc:_7,base58flickr:x7});const $7=cr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),S7=cr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),I7=cr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),A7=cr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var M7=Object.freeze({__proto__:null,base64:$7,base64pad:S7,base64url:I7,base64urlpad:A7});const q1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),P7=q1.reduce((t,e,r)=>(t[r]=e,t),[]),O7=q1.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function C7(t){return t.reduce((e,r)=>(e+=P7[r],e),"")}function D7(t){const e=[];for(const r of t){const i=O7[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const R7=Zc({prefix:"\u{1F680}",name:"base256emoji",encode:C7,decode:D7});var N7=Object.freeze({__proto__:null,base256emoji:R7}),T7=k1,j1=128,F7=127,L7=~F7,B7=Math.pow(2,31);function k1(t,e,r){e=e||[],r=r||0;for(var i=r;t>=B7;)e[r++]=t&255|j1,t/=128;for(;t&L7;)e[r++]=t&255|j1,t>>>=7;return e[r]=t|0,k1.bytes=r-i+1,e}var U7=Cf,q7=128,z1=127;function Cf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Cf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&z1)<<n:(o&z1)*Math.pow(2,n),n+=7}while(o>=q7);return Cf.bytes=s-i,r}var j7=Math.pow(2,7),k7=Math.pow(2,14),z7=Math.pow(2,21),H7=Math.pow(2,28),W7=Math.pow(2,35),V7=Math.pow(2,42),K7=Math.pow(2,49),G7=Math.pow(2,56),J7=Math.pow(2,63),Z7=function(t){return t<j7?1:t<k7?2:t<z7?3:t<H7?4:t<W7?5:t<V7?6:t<K7?7:t<G7?8:t<J7?9:10},Y7={encode:T7,decode:U7,encodingLength:Z7},H1=Y7;const W1=(t,e,r=0)=>(H1.encode(t,e,r),e),V1=t=>H1.encodingLength(t),Df=(t,e)=>{const r=e.byteLength,i=V1(t),n=i+V1(r),s=new Uint8Array(n+r);return W1(t,s,0),W1(r,s,i),s.set(e,n),new X7(t,r,e,s)};class X7{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const K1=({name:t,code:e,encode:r})=>new Q7(t,e,r);class Q7{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?Df(this.code,r):r.then(i=>Df(this.code,i))}else throw Error("Unknown type, must be binary type")}}const G1=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),e9=K1({name:"sha2-256",code:18,encode:G1("SHA-256")}),t9=K1({name:"sha2-512",code:19,encode:G1("SHA-512")});var r9=Object.freeze({__proto__:null,sha256:e9,sha512:t9});const J1=0,i9="identity",Z1=B1;var n9=Object.freeze({__proto__:null,identity:{code:J1,name:i9,encode:Z1,digest:t=>Df(J1,Z1(t))}});new TextEncoder,new TextDecoder;const Y1={...X8,...e7,...r7,...n7,...a7,...m7,...w7,...E7,...M7,...N7};({...r9,...n9});function X1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Q1=X1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Rf=X1("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=L1(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),eg={utf8:Q1,"utf-8":Q1,hex:Y1.base16,latin1:Rf,ascii:Rf,binary:Rf,...Y1};function ai(t,e="utf8"){const r=eg[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 $r(t,e="utf8"){const r=eg[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 tg={},s9="elliptic",o9="6.6.1",a9="EC cryptography",c9="lib/elliptic.js",l9=["lib"],h9={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},f9={type:"git",url:"git@github.com:indutny/elliptic"},u9=["EC","Elliptic","curve","Cryptography"],d9="Fedor Indutny <fedor@indutny.com>",p9="MIT",g9={url:"https://github.com/indutny/elliptic/issues"},v9="https://github.com/indutny/elliptic",m9={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},b9={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},y9={name:s9,version:o9,description:a9,main:c9,files:l9,scripts:h9,repository:f9,keywords:u9,author:d9,license:p9,bugs:g9,homepage:v9,devDependencies:m9,dependencies:b9},Kr={},ki={exports:{}};(function(t){(function(e,r){function i(M,v){if(!M)throw new Error(v||"Assertion failed")}function n(M,v){M.super_=v;var g=function(){};g.prototype=v.prototype,M.prototype=new g,M.prototype.constructor=M}function s(M,v,g){if(s.isBN(M))return M;this.negative=0,this.words=null,this.length=0,this.red=null,M!==null&&((v==="le"||v==="be")&&(g=v,v=10),this._init(M||0,v||10,g||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Hh.Buffer}catch{}s.isBN=function(v){return v instanceof s?!0:v!==null&&typeof v=="object"&&v.constructor.wordSize===s.wordSize&&Array.isArray(v.words)},s.max=function(v,g){return v.cmp(g)>0?v:g},s.min=function(v,g){return v.cmp(g)<0?v:g},s.prototype._init=function(v,g,h){if(typeof v=="number")return this._initNumber(v,g,h);if(typeof v=="object")return this._initArray(v,g,h);g==="hex"&&(g=16),i(g===(g|0)&&g>=2&&g<=36),v=v.toString().replace(/\s+/g,"");var f=0;v[0]==="-"&&(f++,this.negative=1),f<v.length&&(g===16?this._parseHex(v,f,h):(this._parseBase(v,g,f),h==="le"&&this._initArray(this.toArray(),g,h)))},s.prototype._initNumber=function(v,g,h){v<0&&(this.negative=1,v=-v),v<67108864?(this.words=[v&67108863],this.length=1):v<4503599627370496?(this.words=[v&67108863,v/67108864&67108863],this.length=2):(i(v<9007199254740992),this.words=[v&67108863,v/67108864&67108863,1],this.length=3),h==="le"&&this._initArray(this.toArray(),g,h)},s.prototype._initArray=function(v,g,h){if(i(typeof v.length=="number"),v.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(v.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var p,_,$=0;if(h==="be")for(f=v.length-1,p=0;f>=0;f-=3)_=v[f]|v[f-1]<<8|v[f-2]<<16,this.words[p]|=_<<$&67108863,this.words[p+1]=_>>>26-$&67108863,$+=24,$>=26&&($-=26,p++);else if(h==="le")for(f=0,p=0;f<v.length;f+=3)_=v[f]|v[f+1]<<8|v[f+2]<<16,this.words[p]|=_<<$&67108863,this.words[p+1]=_>>>26-$&67108863,$+=24,$>=26&&($-=26,p++);return this.strip()};function a(M,v){var g=M.charCodeAt(v);return g>=65&&g<=70?g-55:g>=97&&g<=102?g-87:g-48&15}function c(M,v,g){var h=a(M,g);return g-1>=v&&(h|=a(M,g-1)<<4),h}s.prototype._parseHex=function(v,g,h){this.length=Math.ceil((v.length-g)/6),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var p=0,_=0,$;if(h==="be")for(f=v.length-1;f>=g;f-=2)$=c(v,g,f)<<p,this.words[_]|=$&67108863,p>=18?(p-=18,_+=1,this.words[_]|=$>>>26):p+=8;else{var y=v.length-g;for(f=y%2===0?g+1:g;f<v.length;f+=2)$=c(v,g,f)<<p,this.words[_]|=$&67108863,p>=18?(p-=18,_+=1,this.words[_]|=$>>>26):p+=8}this.strip()};function l(M,v,g,h){for(var f=0,p=Math.min(M.length,g),_=v;_<p;_++){var $=M.charCodeAt(_)-48;f*=h,$>=49?f+=$-49+10:$>=17?f+=$-17+10:f+=$}return f}s.prototype._parseBase=function(v,g,h){this.words=[0],this.length=1;for(var f=0,p=1;p<=67108863;p*=g)f++;f--,p=p/g|0;for(var _=v.length-h,$=_%f,y=Math.min(_,_-$)+h,d=0,w=h;w<y;w+=f)d=l(v,w,w+f,g),this.imuln(p),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if($!==0){var b=1;for(d=l(v,w,v.length,g),w=0;w<$;w++)b*=g;this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(v){v.words=new Array(this.length);for(var g=0;g<this.length;g++)v.words[g]=this.words[g];v.length=this.length,v.negative=this.negative,v.red=this.red},s.prototype.clone=function(){var v=new s(null);return this.copy(v),v},s.prototype._expand=function(v){for(;this.length<v;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],x=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(v,g){v=v||10,g=g|0||1;var h;if(v===16||v==="hex"){h="";for(var f=0,p=0,_=0;_<this.length;_++){var $=this.words[_],y=(($<<f|p)&16777215).toString(16);p=$>>>24-f&16777215,f+=2,f>=26&&(f-=26,_--),p!==0||_!==this.length-1?h=u[6-y.length]+y+h:h=y+h}for(p!==0&&(h=p.toString(16)+h);h.length%g!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}if(v===(v|0)&&v>=2&&v<=36){var d=m[v],w=x[v];h="";var b=this.clone();for(b.negative=0;!b.isZero();){var P=b.modn(w).toString(v);b=b.idivn(w),b.isZero()?h=P+h:h=u[d-P.length]+P+h}for(this.isZero()&&(h="0"+h);h.length%g!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var v=this.words[0];return this.length===2?v+=this.words[1]*67108864:this.length===3&&this.words[2]===1?v+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-v:v},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(v,g){return i(typeof o<"u"),this.toArrayLike(o,v,g)},s.prototype.toArray=function(v,g){return this.toArrayLike(Array,v,g)},s.prototype.toArrayLike=function(v,g,h){var f=this.byteLength(),p=h||Math.max(1,f);i(f<=p,"byte array longer than desired length"),i(p>0,"Requested array length <= 0"),this.strip();var _=g==="le",$=new v(p),y,d,w=this.clone();if(_){for(d=0;!w.isZero();d++)y=w.andln(255),w.iushrn(8),$[d]=y;for(;d<p;d++)$[d]=0}else{for(d=0;d<p-f;d++)$[d]=0;for(d=0;!w.isZero();d++)y=w.andln(255),w.iushrn(8),$[p-d-1]=y}return $},Math.clz32?s.prototype._countBits=function(v){return 32-Math.clz32(v)}:s.prototype._countBits=function(v){var g=v,h=0;return g>=4096&&(h+=13,g>>>=13),g>=64&&(h+=7,g>>>=7),g>=8&&(h+=4,g>>>=4),g>=2&&(h+=2,g>>>=2),h+g},s.prototype._zeroBits=function(v){if(v===0)return 26;var g=v,h=0;return(g&8191)===0&&(h+=13,g>>>=13),(g&127)===0&&(h+=7,g>>>=7),(g&15)===0&&(h+=4,g>>>=4),(g&3)===0&&(h+=2,g>>>=2),(g&1)===0&&h++,h},s.prototype.bitLength=function(){var v=this.words[this.length-1],g=this._countBits(v);return(this.length-1)*26+g};function S(M){for(var v=new Array(M.bitLength()),g=0;g<v.length;g++){var h=g/26|0,f=g%26;v[g]=(M.words[h]&1<<f)>>>f}return v}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var v=0,g=0;g<this.length;g++){var h=this._zeroBits(this.words[g]);if(v+=h,h!==26)break}return v},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(v){return this.negative!==0?this.abs().inotn(v).iaddn(1):this.clone()},s.prototype.fromTwos=function(v){return this.testn(v-1)?this.notn(v).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(v){for(;this.length<v.length;)this.words[this.length++]=0;for(var g=0;g<v.length;g++)this.words[g]=this.words[g]|v.words[g];return this.strip()},s.prototype.ior=function(v){return i((this.negative|v.negative)===0),this.iuor(v)},s.prototype.or=function(v){return this.length>v.length?this.clone().ior(v):v.clone().ior(this)},s.prototype.uor=function(v){return this.length>v.length?this.clone().iuor(v):v.clone().iuor(this)},s.prototype.iuand=function(v){var g;this.length>v.length?g=v:g=this;for(var h=0;h<g.length;h++)this.words[h]=this.words[h]&v.words[h];return this.length=g.length,this.strip()},s.prototype.iand=function(v){return i((this.negative|v.negative)===0),this.iuand(v)},s.prototype.and=function(v){return this.length>v.length?this.clone().iand(v):v.clone().iand(this)},s.prototype.uand=function(v){return this.length>v.length?this.clone().iuand(v):v.clone().iuand(this)},s.prototype.iuxor=function(v){var g,h;this.length>v.length?(g=this,h=v):(g=v,h=this);for(var f=0;f<h.length;f++)this.words[f]=g.words[f]^h.words[f];if(this!==g)for(;f<g.length;f++)this.words[f]=g.words[f];return this.length=g.length,this.strip()},s.prototype.ixor=function(v){return i((this.negative|v.negative)===0),this.iuxor(v)},s.prototype.xor=function(v){return this.length>v.length?this.clone().ixor(v):v.clone().ixor(this)},s.prototype.uxor=function(v){return this.length>v.length?this.clone().iuxor(v):v.clone().iuxor(this)},s.prototype.inotn=function(v){i(typeof v=="number"&&v>=0);var g=Math.ceil(v/26)|0,h=v%26;this._expand(g),h>0&&g--;for(var f=0;f<g;f++)this.words[f]=~this.words[f]&67108863;return h>0&&(this.words[f]=~this.words[f]&67108863>>26-h),this.strip()},s.prototype.notn=function(v){return this.clone().inotn(v)},s.prototype.setn=function(v,g){i(typeof v=="number"&&v>=0);var h=v/26|0,f=v%26;return this._expand(h+1),g?this.words[h]=this.words[h]|1<<f:this.words[h]=this.words[h]&~(1<<f),this.strip()},s.prototype.iadd=function(v){var g;if(this.negative!==0&&v.negative===0)return this.negative=0,g=this.isub(v),this.negative^=1,this._normSign();if(this.negative===0&&v.negative!==0)return v.negative=0,g=this.isub(v),v.negative=1,g._normSign();var h,f;this.length>v.length?(h=this,f=v):(h=v,f=this);for(var p=0,_=0;_<f.length;_++)g=(h.words[_]|0)+(f.words[_]|0)+p,this.words[_]=g&67108863,p=g>>>26;for(;p!==0&&_<h.length;_++)g=(h.words[_]|0)+p,this.words[_]=g&67108863,p=g>>>26;if(this.length=h.length,p!==0)this.words[this.length]=p,this.length++;else if(h!==this)for(;_<h.length;_++)this.words[_]=h.words[_];return this},s.prototype.add=function(v){var g;return v.negative!==0&&this.negative===0?(v.negative=0,g=this.sub(v),v.negative^=1,g):v.negative===0&&this.negative!==0?(this.negative=0,g=v.sub(this),this.negative=1,g):this.length>v.length?this.clone().iadd(v):v.clone().iadd(this)},s.prototype.isub=function(v){if(v.negative!==0){v.negative=0;var g=this.iadd(v);return v.negative=1,g._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(v),this.negative=1,this._normSign();var h=this.cmp(v);if(h===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,p;h>0?(f=this,p=v):(f=v,p=this);for(var _=0,$=0;$<p.length;$++)g=(f.words[$]|0)-(p.words[$]|0)+_,_=g>>26,this.words[$]=g&67108863;for(;_!==0&&$<f.length;$++)g=(f.words[$]|0)+_,_=g>>26,this.words[$]=g&67108863;if(_===0&&$<f.length&&f!==this)for(;$<f.length;$++)this.words[$]=f.words[$];return this.length=Math.max(this.length,$),f!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(v){return this.clone().isub(v)};function E(M,v,g){g.negative=v.negative^M.negative;var h=M.length+v.length|0;g.length=h,h=h-1|0;var f=M.words[0]|0,p=v.words[0]|0,_=f*p,$=_&67108863,y=_/67108864|0;g.words[0]=$;for(var d=1;d<h;d++){for(var w=y>>>26,b=y&67108863,P=Math.min(d,v.length-1),q=Math.max(0,d-M.length+1);q<=P;q++){var I=d-q|0;f=M.words[I]|0,p=v.words[q]|0,_=f*p+b,w+=_/67108864|0,b=_&67108863}g.words[d]=b|0,y=w|0}return y!==0?g.words[d]=y|0:g.length--,g.strip()}var A=function(v,g,h){var f=v.words,p=g.words,_=h.words,$=0,y,d,w,b=f[0]|0,P=b&8191,q=b>>>13,I=f[1]|0,F=I&8191,j=I>>>13,k=f[2]|0,H=k&8191,Y=k>>>13,Q=f[3]|0,J=Q&8191,ae=Q>>>13,re=f[4]|0,ie=re&8191,Ze=re>>>13,Ye=f[5]|0,de=Ye&8191,qe=Ye>>>13,je=f[6]|0,he=je&8191,ke=je>>>13,ze=f[7]|0,ue=ze&8191,He=ze>>>13,We=f[8]|0,le=We&8191,Be=We>>>13,Ve=f[9]|0,oe=Ve&8191,nt=Ve>>>13,st=p[0]|0,me=st&8191,ot=st>>>13,Ke=p[1]|0,ge=Ke&8191,at=Ke>>>13,ft=p[2]|0,ce=ft&8191,ct=ft>>>13,ut=p[3]|0,be=ut&8191,Xe=ut>>>13,Ue=p[4]|0,pe=Ue&8191,Qe=Ue>>>13,et=p[5]|0,fe=et&8191,dt=et>>>13,pt=p[6]|0,ye=pt&8191,gt=pt>>>13,vt=p[7]|0,ve=vt&8191,tt=vt>>>13,Re=p[8]|0,we=Re&8191,mt=Re>>>13,bt=p[9]|0,_e=bt&8191,yt=bt>>>13;h.negative=v.negative^g.negative,h.length=19,y=Math.imul(P,me),d=Math.imul(P,ot),d=d+Math.imul(q,me)|0,w=Math.imul(q,ot);var Ae=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,y=Math.imul(F,me),d=Math.imul(F,ot),d=d+Math.imul(j,me)|0,w=Math.imul(j,ot),y=y+Math.imul(P,ge)|0,d=d+Math.imul(P,at)|0,d=d+Math.imul(q,ge)|0,w=w+Math.imul(q,at)|0;var lt=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(lt>>>26)|0,lt&=67108863,y=Math.imul(H,me),d=Math.imul(H,ot),d=d+Math.imul(Y,me)|0,w=Math.imul(Y,ot),y=y+Math.imul(F,ge)|0,d=d+Math.imul(F,at)|0,d=d+Math.imul(j,ge)|0,w=w+Math.imul(j,at)|0,y=y+Math.imul(P,ce)|0,d=d+Math.imul(P,ct)|0,d=d+Math.imul(q,ce)|0,w=w+Math.imul(q,ct)|0;var qr=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(qr>>>26)|0,qr&=67108863,y=Math.imul(J,me),d=Math.imul(J,ot),d=d+Math.imul(ae,me)|0,w=Math.imul(ae,ot),y=y+Math.imul(H,ge)|0,d=d+Math.imul(H,at)|0,d=d+Math.imul(Y,ge)|0,w=w+Math.imul(Y,at)|0,y=y+Math.imul(F,ce)|0,d=d+Math.imul(F,ct)|0,d=d+Math.imul(j,ce)|0,w=w+Math.imul(j,ct)|0,y=y+Math.imul(P,be)|0,d=d+Math.imul(P,Xe)|0,d=d+Math.imul(q,be)|0,w=w+Math.imul(q,Xe)|0;var jr=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(jr>>>26)|0,jr&=67108863,y=Math.imul(ie,me),d=Math.imul(ie,ot),d=d+Math.imul(Ze,me)|0,w=Math.imul(Ze,ot),y=y+Math.imul(J,ge)|0,d=d+Math.imul(J,at)|0,d=d+Math.imul(ae,ge)|0,w=w+Math.imul(ae,at)|0,y=y+Math.imul(H,ce)|0,d=d+Math.imul(H,ct)|0,d=d+Math.imul(Y,ce)|0,w=w+Math.imul(Y,ct)|0,y=y+Math.imul(F,be)|0,d=d+Math.imul(F,Xe)|0,d=d+Math.imul(j,be)|0,w=w+Math.imul(j,Xe)|0,y=y+Math.imul(P,pe)|0,d=d+Math.imul(P,Qe)|0,d=d+Math.imul(q,pe)|0,w=w+Math.imul(q,Qe)|0;var kr=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(kr>>>26)|0,kr&=67108863,y=Math.imul(de,me),d=Math.imul(de,ot),d=d+Math.imul(qe,me)|0,w=Math.imul(qe,ot),y=y+Math.imul(ie,ge)|0,d=d+Math.imul(ie,at)|0,d=d+Math.imul(Ze,ge)|0,w=w+Math.imul(Ze,at)|0,y=y+Math.imul(J,ce)|0,d=d+Math.imul(J,ct)|0,d=d+Math.imul(ae,ce)|0,w=w+Math.imul(ae,ct)|0,y=y+Math.imul(H,be)|0,d=d+Math.imul(H,Xe)|0,d=d+Math.imul(Y,be)|0,w=w+Math.imul(Y,Xe)|0,y=y+Math.imul(F,pe)|0,d=d+Math.imul(F,Qe)|0,d=d+Math.imul(j,pe)|0,w=w+Math.imul(j,Qe)|0,y=y+Math.imul(P,fe)|0,d=d+Math.imul(P,dt)|0,d=d+Math.imul(q,fe)|0,w=w+Math.imul(q,dt)|0;var zr=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(zr>>>26)|0,zr&=67108863,y=Math.imul(he,me),d=Math.imul(he,ot),d=d+Math.imul(ke,me)|0,w=Math.imul(ke,ot),y=y+Math.imul(de,ge)|0,d=d+Math.imul(de,at)|0,d=d+Math.imul(qe,ge)|0,w=w+Math.imul(qe,at)|0,y=y+Math.imul(ie,ce)|0,d=d+Math.imul(ie,ct)|0,d=d+Math.imul(Ze,ce)|0,w=w+Math.imul(Ze,ct)|0,y=y+Math.imul(J,be)|0,d=d+Math.imul(J,Xe)|0,d=d+Math.imul(ae,be)|0,w=w+Math.imul(ae,Xe)|0,y=y+Math.imul(H,pe)|0,d=d+Math.imul(H,Qe)|0,d=d+Math.imul(Y,pe)|0,w=w+Math.imul(Y,Qe)|0,y=y+Math.imul(F,fe)|0,d=d+Math.imul(F,dt)|0,d=d+Math.imul(j,fe)|0,w=w+Math.imul(j,dt)|0,y=y+Math.imul(P,ye)|0,d=d+Math.imul(P,gt)|0,d=d+Math.imul(q,ye)|0,w=w+Math.imul(q,gt)|0;var kt=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(kt>>>26)|0,kt&=67108863,y=Math.imul(ue,me),d=Math.imul(ue,ot),d=d+Math.imul(He,me)|0,w=Math.imul(He,ot),y=y+Math.imul(he,ge)|0,d=d+Math.imul(he,at)|0,d=d+Math.imul(ke,ge)|0,w=w+Math.imul(ke,at)|0,y=y+Math.imul(de,ce)|0,d=d+Math.imul(de,ct)|0,d=d+Math.imul(qe,ce)|0,w=w+Math.imul(qe,ct)|0,y=y+Math.imul(ie,be)|0,d=d+Math.imul(ie,Xe)|0,d=d+Math.imul(Ze,be)|0,w=w+Math.imul(Ze,Xe)|0,y=y+Math.imul(J,pe)|0,d=d+Math.imul(J,Qe)|0,d=d+Math.imul(ae,pe)|0,w=w+Math.imul(ae,Qe)|0,y=y+Math.imul(H,fe)|0,d=d+Math.imul(H,dt)|0,d=d+Math.imul(Y,fe)|0,w=w+Math.imul(Y,dt)|0,y=y+Math.imul(F,ye)|0,d=d+Math.imul(F,gt)|0,d=d+Math.imul(j,ye)|0,w=w+Math.imul(j,gt)|0,y=y+Math.imul(P,ve)|0,d=d+Math.imul(P,tt)|0,d=d+Math.imul(q,ve)|0,w=w+Math.imul(q,tt)|0;var En=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(En>>>26)|0,En&=67108863,y=Math.imul(le,me),d=Math.imul(le,ot),d=d+Math.imul(Be,me)|0,w=Math.imul(Be,ot),y=y+Math.imul(ue,ge)|0,d=d+Math.imul(ue,at)|0,d=d+Math.imul(He,ge)|0,w=w+Math.imul(He,at)|0,y=y+Math.imul(he,ce)|0,d=d+Math.imul(he,ct)|0,d=d+Math.imul(ke,ce)|0,w=w+Math.imul(ke,ct)|0,y=y+Math.imul(de,be)|0,d=d+Math.imul(de,Xe)|0,d=d+Math.imul(qe,be)|0,w=w+Math.imul(qe,Xe)|0,y=y+Math.imul(ie,pe)|0,d=d+Math.imul(ie,Qe)|0,d=d+Math.imul(Ze,pe)|0,w=w+Math.imul(Ze,Qe)|0,y=y+Math.imul(J,fe)|0,d=d+Math.imul(J,dt)|0,d=d+Math.imul(ae,fe)|0,w=w+Math.imul(ae,dt)|0,y=y+Math.imul(H,ye)|0,d=d+Math.imul(H,gt)|0,d=d+Math.imul(Y,ye)|0,w=w+Math.imul(Y,gt)|0,y=y+Math.imul(F,ve)|0,d=d+Math.imul(F,tt)|0,d=d+Math.imul(j,ve)|0,w=w+Math.imul(j,tt)|0,y=y+Math.imul(P,we)|0,d=d+Math.imul(P,mt)|0,d=d+Math.imul(q,we)|0,w=w+Math.imul(q,mt)|0;var $n=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+($n>>>26)|0,$n&=67108863,y=Math.imul(oe,me),d=Math.imul(oe,ot),d=d+Math.imul(nt,me)|0,w=Math.imul(nt,ot),y=y+Math.imul(le,ge)|0,d=d+Math.imul(le,at)|0,d=d+Math.imul(Be,ge)|0,w=w+Math.imul(Be,at)|0,y=y+Math.imul(ue,ce)|0,d=d+Math.imul(ue,ct)|0,d=d+Math.imul(He,ce)|0,w=w+Math.imul(He,ct)|0,y=y+Math.imul(he,be)|0,d=d+Math.imul(he,Xe)|0,d=d+Math.imul(ke,be)|0,w=w+Math.imul(ke,Xe)|0,y=y+Math.imul(de,pe)|0,d=d+Math.imul(de,Qe)|0,d=d+Math.imul(qe,pe)|0,w=w+Math.imul(qe,Qe)|0,y=y+Math.imul(ie,fe)|0,d=d+Math.imul(ie,dt)|0,d=d+Math.imul(Ze,fe)|0,w=w+Math.imul(Ze,dt)|0,y=y+Math.imul(J,ye)|0,d=d+Math.imul(J,gt)|0,d=d+Math.imul(ae,ye)|0,w=w+Math.imul(ae,gt)|0,y=y+Math.imul(H,ve)|0,d=d+Math.imul(H,tt)|0,d=d+Math.imul(Y,ve)|0,w=w+Math.imul(Y,tt)|0,y=y+Math.imul(F,we)|0,d=d+Math.imul(F,mt)|0,d=d+Math.imul(j,we)|0,w=w+Math.imul(j,mt)|0,y=y+Math.imul(P,_e)|0,d=d+Math.imul(P,yt)|0,d=d+Math.imul(q,_e)|0,w=w+Math.imul(q,yt)|0;var Sn=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,y=Math.imul(oe,ge),d=Math.imul(oe,at),d=d+Math.imul(nt,ge)|0,w=Math.imul(nt,at),y=y+Math.imul(le,ce)|0,d=d+Math.imul(le,ct)|0,d=d+Math.imul(Be,ce)|0,w=w+Math.imul(Be,ct)|0,y=y+Math.imul(ue,be)|0,d=d+Math.imul(ue,Xe)|0,d=d+Math.imul(He,be)|0,w=w+Math.imul(He,Xe)|0,y=y+Math.imul(he,pe)|0,d=d+Math.imul(he,Qe)|0,d=d+Math.imul(ke,pe)|0,w=w+Math.imul(ke,Qe)|0,y=y+Math.imul(de,fe)|0,d=d+Math.imul(de,dt)|0,d=d+Math.imul(qe,fe)|0,w=w+Math.imul(qe,dt)|0,y=y+Math.imul(ie,ye)|0,d=d+Math.imul(ie,gt)|0,d=d+Math.imul(Ze,ye)|0,w=w+Math.imul(Ze,gt)|0,y=y+Math.imul(J,ve)|0,d=d+Math.imul(J,tt)|0,d=d+Math.imul(ae,ve)|0,w=w+Math.imul(ae,tt)|0,y=y+Math.imul(H,we)|0,d=d+Math.imul(H,mt)|0,d=d+Math.imul(Y,we)|0,w=w+Math.imul(Y,mt)|0,y=y+Math.imul(F,_e)|0,d=d+Math.imul(F,yt)|0,d=d+Math.imul(j,_e)|0,w=w+Math.imul(j,yt)|0;var In=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(In>>>26)|0,In&=67108863,y=Math.imul(oe,ce),d=Math.imul(oe,ct),d=d+Math.imul(nt,ce)|0,w=Math.imul(nt,ct),y=y+Math.imul(le,be)|0,d=d+Math.imul(le,Xe)|0,d=d+Math.imul(Be,be)|0,w=w+Math.imul(Be,Xe)|0,y=y+Math.imul(ue,pe)|0,d=d+Math.imul(ue,Qe)|0,d=d+Math.imul(He,pe)|0,w=w+Math.imul(He,Qe)|0,y=y+Math.imul(he,fe)|0,d=d+Math.imul(he,dt)|0,d=d+Math.imul(ke,fe)|0,w=w+Math.imul(ke,dt)|0,y=y+Math.imul(de,ye)|0,d=d+Math.imul(de,gt)|0,d=d+Math.imul(qe,ye)|0,w=w+Math.imul(qe,gt)|0,y=y+Math.imul(ie,ve)|0,d=d+Math.imul(ie,tt)|0,d=d+Math.imul(Ze,ve)|0,w=w+Math.imul(Ze,tt)|0,y=y+Math.imul(J,we)|0,d=d+Math.imul(J,mt)|0,d=d+Math.imul(ae,we)|0,w=w+Math.imul(ae,mt)|0,y=y+Math.imul(H,_e)|0,d=d+Math.imul(H,yt)|0,d=d+Math.imul(Y,_e)|0,w=w+Math.imul(Y,yt)|0;var An=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(An>>>26)|0,An&=67108863,y=Math.imul(oe,be),d=Math.imul(oe,Xe),d=d+Math.imul(nt,be)|0,w=Math.imul(nt,Xe),y=y+Math.imul(le,pe)|0,d=d+Math.imul(le,Qe)|0,d=d+Math.imul(Be,pe)|0,w=w+Math.imul(Be,Qe)|0,y=y+Math.imul(ue,fe)|0,d=d+Math.imul(ue,dt)|0,d=d+Math.imul(He,fe)|0,w=w+Math.imul(He,dt)|0,y=y+Math.imul(he,ye)|0,d=d+Math.imul(he,gt)|0,d=d+Math.imul(ke,ye)|0,w=w+Math.imul(ke,gt)|0,y=y+Math.imul(de,ve)|0,d=d+Math.imul(de,tt)|0,d=d+Math.imul(qe,ve)|0,w=w+Math.imul(qe,tt)|0,y=y+Math.imul(ie,we)|0,d=d+Math.imul(ie,mt)|0,d=d+Math.imul(Ze,we)|0,w=w+Math.imul(Ze,mt)|0,y=y+Math.imul(J,_e)|0,d=d+Math.imul(J,yt)|0,d=d+Math.imul(ae,_e)|0,w=w+Math.imul(ae,yt)|0;var mi=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(mi>>>26)|0,mi&=67108863,y=Math.imul(oe,pe),d=Math.imul(oe,Qe),d=d+Math.imul(nt,pe)|0,w=Math.imul(nt,Qe),y=y+Math.imul(le,fe)|0,d=d+Math.imul(le,dt)|0,d=d+Math.imul(Be,fe)|0,w=w+Math.imul(Be,dt)|0,y=y+Math.imul(ue,ye)|0,d=d+Math.imul(ue,gt)|0,d=d+Math.imul(He,ye)|0,w=w+Math.imul(He,gt)|0,y=y+Math.imul(he,ve)|0,d=d+Math.imul(he,tt)|0,d=d+Math.imul(ke,ve)|0,w=w+Math.imul(ke,tt)|0,y=y+Math.imul(de,we)|0,d=d+Math.imul(de,mt)|0,d=d+Math.imul(qe,we)|0,w=w+Math.imul(qe,mt)|0,y=y+Math.imul(ie,_e)|0,d=d+Math.imul(ie,yt)|0,d=d+Math.imul(Ze,_e)|0,w=w+Math.imul(Ze,yt)|0;var Mn=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,y=Math.imul(oe,fe),d=Math.imul(oe,dt),d=d+Math.imul(nt,fe)|0,w=Math.imul(nt,dt),y=y+Math.imul(le,ye)|0,d=d+Math.imul(le,gt)|0,d=d+Math.imul(Be,ye)|0,w=w+Math.imul(Be,gt)|0,y=y+Math.imul(ue,ve)|0,d=d+Math.imul(ue,tt)|0,d=d+Math.imul(He,ve)|0,w=w+Math.imul(He,tt)|0,y=y+Math.imul(he,we)|0,d=d+Math.imul(he,mt)|0,d=d+Math.imul(ke,we)|0,w=w+Math.imul(ke,mt)|0,y=y+Math.imul(de,_e)|0,d=d+Math.imul(de,yt)|0,d=d+Math.imul(qe,_e)|0,w=w+Math.imul(qe,yt)|0;var Pn=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,y=Math.imul(oe,ye),d=Math.imul(oe,gt),d=d+Math.imul(nt,ye)|0,w=Math.imul(nt,gt),y=y+Math.imul(le,ve)|0,d=d+Math.imul(le,tt)|0,d=d+Math.imul(Be,ve)|0,w=w+Math.imul(Be,tt)|0,y=y+Math.imul(ue,we)|0,d=d+Math.imul(ue,mt)|0,d=d+Math.imul(He,we)|0,w=w+Math.imul(He,mt)|0,y=y+Math.imul(he,_e)|0,d=d+Math.imul(he,yt)|0,d=d+Math.imul(ke,_e)|0,w=w+Math.imul(ke,yt)|0;var wr=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(wr>>>26)|0,wr&=67108863,y=Math.imul(oe,ve),d=Math.imul(oe,tt),d=d+Math.imul(nt,ve)|0,w=Math.imul(nt,tt),y=y+Math.imul(le,we)|0,d=d+Math.imul(le,mt)|0,d=d+Math.imul(Be,we)|0,w=w+Math.imul(Be,mt)|0,y=y+Math.imul(ue,_e)|0,d=d+Math.imul(ue,yt)|0,d=d+Math.imul(He,_e)|0,w=w+Math.imul(He,yt)|0;var On=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(On>>>26)|0,On&=67108863,y=Math.imul(oe,we),d=Math.imul(oe,mt),d=d+Math.imul(nt,we)|0,w=Math.imul(nt,mt),y=y+Math.imul(le,_e)|0,d=d+Math.imul(le,yt)|0,d=d+Math.imul(Be,_e)|0,w=w+Math.imul(Be,yt)|0;var Cn=($+y|0)+((d&8191)<<13)|0;$=(w+(d>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,y=Math.imul(oe,_e),d=Math.imul(oe,yt),d=d+Math.imul(nt,_e)|0,w=Math.imul(nt,yt);var Dn=($+y|0)+((d&8191)<<13)|0;return $=(w+(d>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,_[0]=Ae,_[1]=lt,_[2]=qr,_[3]=jr,_[4]=kr,_[5]=zr,_[6]=kt,_[7]=En,_[8]=$n,_[9]=Sn,_[10]=In,_[11]=An,_[12]=mi,_[13]=Mn,_[14]=Pn,_[15]=wr,_[16]=On,_[17]=Cn,_[18]=Dn,$!==0&&(_[19]=$,h.length++),h};Math.imul||(A=E);function R(M,v,g){g.negative=v.negative^M.negative,g.length=M.length+v.length;for(var h=0,f=0,p=0;p<g.length-1;p++){var _=f;f=0;for(var $=h&67108863,y=Math.min(p,v.length-1),d=Math.max(0,p-M.length+1);d<=y;d++){var w=p-d,b=M.words[w]|0,P=v.words[d]|0,q=b*P,I=q&67108863;_=_+(q/67108864|0)|0,I=I+$|0,$=I&67108863,_=_+(I>>>26)|0,f+=_>>>26,_&=67108863}g.words[p]=$,h=_,_=f}return h!==0?g.words[p]=h:g.length--,g.strip()}function O(M,v,g){var h=new C;return h.mulp(M,v,g)}s.prototype.mulTo=function(v,g){var h,f=this.length+v.length;return this.length===10&&v.length===10?h=A(this,v,g):f<63?h=E(this,v,g):f<1024?h=R(this,v,g):h=O(this,v,g),h};function C(M,v){this.x=M,this.y=v}C.prototype.makeRBT=function(v){for(var g=new Array(v),h=s.prototype._countBits(v)-1,f=0;f<v;f++)g[f]=this.revBin(f,h,v);return g},C.prototype.revBin=function(v,g,h){if(v===0||v===h-1)return v;for(var f=0,p=0;p<g;p++)f|=(v&1)<<g-p-1,v>>=1;return f},C.prototype.permute=function(v,g,h,f,p,_){for(var $=0;$<_;$++)f[$]=g[v[$]],p[$]=h[v[$]]},C.prototype.transform=function(v,g,h,f,p,_){this.permute(_,v,g,h,f,p);for(var $=1;$<p;$<<=1)for(var y=$<<1,d=Math.cos(2*Math.PI/y),w=Math.sin(2*Math.PI/y),b=0;b<p;b+=y)for(var P=d,q=w,I=0;I<$;I++){var F=h[b+I],j=f[b+I],k=h[b+I+$],H=f[b+I+$],Y=P*k-q*H;H=P*H+q*k,k=Y,h[b+I]=F+k,f[b+I]=j+H,h[b+I+$]=F-k,f[b+I+$]=j-H,I!==y&&(Y=d*P-w*q,q=d*q+w*P,P=Y)}},C.prototype.guessLen13b=function(v,g){var h=Math.max(g,v)|1,f=h&1,p=0;for(h=h/2|0;h;h=h>>>1)p++;return 1<<p+1+f},C.prototype.conjugate=function(v,g,h){if(!(h<=1))for(var f=0;f<h/2;f++){var p=v[f];v[f]=v[h-f-1],v[h-f-1]=p,p=g[f],g[f]=-g[h-f-1],g[h-f-1]=-p}},C.prototype.normalize13b=function(v,g){for(var h=0,f=0;f<g/2;f++){var p=Math.round(v[2*f+1]/g)*8192+Math.round(v[2*f]/g)+h;v[f]=p&67108863,p<67108864?h=0:h=p/67108864|0}return v},C.prototype.convert13b=function(v,g,h,f){for(var p=0,_=0;_<g;_++)p=p+(v[_]|0),h[2*_]=p&8191,p=p>>>13,h[2*_+1]=p&8191,p=p>>>13;for(_=2*g;_<f;++_)h[_]=0;i(p===0),i((p&-8192)===0)},C.prototype.stub=function(v){for(var g=new Array(v),h=0;h<v;h++)g[h]=0;return g},C.prototype.mulp=function(v,g,h){var f=2*this.guessLen13b(v.length,g.length),p=this.makeRBT(f),_=this.stub(f),$=new Array(f),y=new Array(f),d=new Array(f),w=new Array(f),b=new Array(f),P=new Array(f),q=h.words;q.length=f,this.convert13b(v.words,v.length,$,f),this.convert13b(g.words,g.length,w,f),this.transform($,_,y,d,f,p),this.transform(w,_,b,P,f,p);for(var I=0;I<f;I++){var F=y[I]*b[I]-d[I]*P[I];d[I]=y[I]*P[I]+d[I]*b[I],y[I]=F}return this.conjugate(y,d,f),this.transform(y,d,q,_,f,p),this.conjugate(q,_,f),this.normalize13b(q,f),h.negative=v.negative^g.negative,h.length=v.length+g.length,h.strip()},s.prototype.mul=function(v){var g=new s(null);return g.words=new Array(this.length+v.length),this.mulTo(v,g)},s.prototype.mulf=function(v){var g=new s(null);return g.words=new Array(this.length+v.length),O(this,v,g)},s.prototype.imul=function(v){return this.clone().mulTo(v,this)},s.prototype.imuln=function(v){i(typeof v=="number"),i(v<67108864);for(var g=0,h=0;h<this.length;h++){var f=(this.words[h]|0)*v,p=(f&67108863)+(g&67108863);g>>=26,g+=f/67108864|0,g+=p>>>26,this.words[h]=p&67108863}return g!==0&&(this.words[h]=g,this.length++),this},s.prototype.muln=function(v){return this.clone().imuln(v)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(v){var g=S(v);if(g.length===0)return new s(1);for(var h=this,f=0;f<g.length&&g[f]===0;f++,h=h.sqr());if(++f<g.length)for(var p=h.sqr();f<g.length;f++,p=p.sqr())g[f]!==0&&(h=h.mul(p));return h},s.prototype.iushln=function(v){i(typeof v=="number"&&v>=0);var g=v%26,h=(v-g)/26,f=67108863>>>26-g<<26-g,p;if(g!==0){var _=0;for(p=0;p<this.length;p++){var $=this.words[p]&f,y=(this.words[p]|0)-$<<g;this.words[p]=y|_,_=$>>>26-g}_&&(this.words[p]=_,this.length++)}if(h!==0){for(p=this.length-1;p>=0;p--)this.words[p+h]=this.words[p];for(p=0;p<h;p++)this.words[p]=0;this.length+=h}return this.strip()},s.prototype.ishln=function(v){return i(this.negative===0),this.iushln(v)},s.prototype.iushrn=function(v,g,h){i(typeof v=="number"&&v>=0);var f;g?f=(g-g%26)/26:f=0;var p=v%26,_=Math.min((v-p)/26,this.length),$=67108863^67108863>>>p<<p,y=h;if(f-=_,f=Math.max(0,f),y){for(var d=0;d<_;d++)y.words[d]=this.words[d];y.length=_}if(_!==0)if(this.length>_)for(this.length-=_,d=0;d<this.length;d++)this.words[d]=this.words[d+_];else this.words[0]=0,this.length=1;var w=0;for(d=this.length-1;d>=0&&(w!==0||d>=f);d--){var b=this.words[d]|0;this.words[d]=w<<26-p|b>>>p,w=b&$}return y&&w!==0&&(y.words[y.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(v,g,h){return i(this.negative===0),this.iushrn(v,g,h)},s.prototype.shln=function(v){return this.clone().ishln(v)},s.prototype.ushln=function(v){return this.clone().iushln(v)},s.prototype.shrn=function(v){return this.clone().ishrn(v)},s.prototype.ushrn=function(v){return this.clone().iushrn(v)},s.prototype.testn=function(v){i(typeof v=="number"&&v>=0);var g=v%26,h=(v-g)/26,f=1<<g;if(this.length<=h)return!1;var p=this.words[h];return!!(p&f)},s.prototype.imaskn=function(v){i(typeof v=="number"&&v>=0);var g=v%26,h=(v-g)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=h)return this;if(g!==0&&h++,this.length=Math.min(h,this.length),g!==0){var f=67108863^67108863>>>g<<g;this.words[this.length-1]&=f}return this.strip()},s.prototype.maskn=function(v){return this.clone().imaskn(v)},s.prototype.iaddn=function(v){return i(typeof v=="number"),i(v<67108864),v<0?this.isubn(-v):this.negative!==0?this.length===1&&(this.words[0]|0)<v?(this.words[0]=v-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(v),this.negative=1,this):this._iaddn(v)},s.prototype._iaddn=function(v){this.words[0]+=v;for(var g=0;g<this.length&&this.words[g]>=67108864;g++)this.words[g]-=67108864,g===this.length-1?this.words[g+1]=1:this.words[g+1]++;return this.length=Math.max(this.length,g+1),this},s.prototype.isubn=function(v){if(i(typeof v=="number"),i(v<67108864),v<0)return this.iaddn(-v);if(this.negative!==0)return this.negative=0,this.iaddn(v),this.negative=1,this;if(this.words[0]-=v,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var g=0;g<this.length&&this.words[g]<0;g++)this.words[g]+=67108864,this.words[g+1]-=1;return this.strip()},s.prototype.addn=function(v){return this.clone().iaddn(v)},s.prototype.subn=function(v){return this.clone().isubn(v)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(v,g,h){var f=v.length+h,p;this._expand(f);var _,$=0;for(p=0;p<v.length;p++){_=(this.words[p+h]|0)+$;var y=(v.words[p]|0)*g;_-=y&67108863,$=(_>>26)-(y/67108864|0),this.words[p+h]=_&67108863}for(;p<this.length-h;p++)_=(this.words[p+h]|0)+$,$=_>>26,this.words[p+h]=_&67108863;if($===0)return this.strip();for(i($===-1),$=0,p=0;p<this.length;p++)_=-(this.words[p]|0)+$,$=_>>26,this.words[p]=_&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(v,g){var h=this.length-v.length,f=this.clone(),p=v,_=p.words[p.length-1]|0,$=this._countBits(_);h=26-$,h!==0&&(p=p.ushln(h),f.iushln(h),_=p.words[p.length-1]|0);var y=f.length-p.length,d;if(g!=="mod"){d=new s(null),d.length=y+1,d.words=new Array(d.length);for(var w=0;w<d.length;w++)d.words[w]=0}var b=f.clone()._ishlnsubmul(p,1,y);b.negative===0&&(f=b,d&&(d.words[y]=1));for(var P=y-1;P>=0;P--){var q=(f.words[p.length+P]|0)*67108864+(f.words[p.length+P-1]|0);for(q=Math.min(q/_|0,67108863),f._ishlnsubmul(p,q,P);f.negative!==0;)q--,f.negative=0,f._ishlnsubmul(p,1,P),f.isZero()||(f.negative^=1);d&&(d.words[P]=q)}return d&&d.strip(),f.strip(),g!=="div"&&h!==0&&f.iushrn(h),{div:d||null,mod:f}},s.prototype.divmod=function(v,g,h){if(i(!v.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var f,p,_;return this.negative!==0&&v.negative===0?(_=this.neg().divmod(v,g),g!=="mod"&&(f=_.div.neg()),g!=="div"&&(p=_.mod.neg(),h&&p.negative!==0&&p.iadd(v)),{div:f,mod:p}):this.negative===0&&v.negative!==0?(_=this.divmod(v.neg(),g),g!=="mod"&&(f=_.div.neg()),{div:f,mod:_.mod}):(this.negative&v.negative)!==0?(_=this.neg().divmod(v.neg(),g),g!=="div"&&(p=_.mod.neg(),h&&p.negative!==0&&p.isub(v)),{div:_.div,mod:p}):v.length>this.length||this.cmp(v)<0?{div:new s(0),mod:this}:v.length===1?g==="div"?{div:this.divn(v.words[0]),mod:null}:g==="mod"?{div:null,mod:new s(this.modn(v.words[0]))}:{div:this.divn(v.words[0]),mod:new s(this.modn(v.words[0]))}:this._wordDiv(v,g)},s.prototype.div=function(v){return this.divmod(v,"div",!1).div},s.prototype.mod=function(v){return this.divmod(v,"mod",!1).mod},s.prototype.umod=function(v){return this.divmod(v,"mod",!0).mod},s.prototype.divRound=function(v){var g=this.divmod(v);if(g.mod.isZero())return g.div;var h=g.div.negative!==0?g.mod.isub(v):g.mod,f=v.ushrn(1),p=v.andln(1),_=h.cmp(f);return _<0||p===1&&_===0?g.div:g.div.negative!==0?g.div.isubn(1):g.div.iaddn(1)},s.prototype.modn=function(v){i(v<=67108863);for(var g=(1<<26)%v,h=0,f=this.length-1;f>=0;f--)h=(g*h+(this.words[f]|0))%v;return h},s.prototype.idivn=function(v){i(v<=67108863);for(var g=0,h=this.length-1;h>=0;h--){var f=(this.words[h]|0)+g*67108864;this.words[h]=f/v|0,g=f%v}return this.strip()},s.prototype.divn=function(v){return this.clone().idivn(v)},s.prototype.egcd=function(v){i(v.negative===0),i(!v.isZero());var g=this,h=v.clone();g.negative!==0?g=g.umod(v):g=g.clone();for(var f=new s(1),p=new s(0),_=new s(0),$=new s(1),y=0;g.isEven()&&h.isEven();)g.iushrn(1),h.iushrn(1),++y;for(var d=h.clone(),w=g.clone();!g.isZero();){for(var b=0,P=1;(g.words[0]&P)===0&&b<26;++b,P<<=1);if(b>0)for(g.iushrn(b);b-- >0;)(f.isOdd()||p.isOdd())&&(f.iadd(d),p.isub(w)),f.iushrn(1),p.iushrn(1);for(var q=0,I=1;(h.words[0]&I)===0&&q<26;++q,I<<=1);if(q>0)for(h.iushrn(q);q-- >0;)(_.isOdd()||$.isOdd())&&(_.iadd(d),$.isub(w)),_.iushrn(1),$.iushrn(1);g.cmp(h)>=0?(g.isub(h),f.isub(_),p.isub($)):(h.isub(g),_.isub(f),$.isub(p))}return{a:_,b:$,gcd:h.iushln(y)}},s.prototype._invmp=function(v){i(v.negative===0),i(!v.isZero());var g=this,h=v.clone();g.negative!==0?g=g.umod(v):g=g.clone();for(var f=new s(1),p=new s(0),_=h.clone();g.cmpn(1)>0&&h.cmpn(1)>0;){for(var $=0,y=1;(g.words[0]&y)===0&&$<26;++$,y<<=1);if($>0)for(g.iushrn($);$-- >0;)f.isOdd()&&f.iadd(_),f.iushrn(1);for(var d=0,w=1;(h.words[0]&w)===0&&d<26;++d,w<<=1);if(d>0)for(h.iushrn(d);d-- >0;)p.isOdd()&&p.iadd(_),p.iushrn(1);g.cmp(h)>=0?(g.isub(h),f.isub(p)):(h.isub(g),p.isub(f))}var b;return g.cmpn(1)===0?b=f:b=p,b.cmpn(0)<0&&b.iadd(v),b},s.prototype.gcd=function(v){if(this.isZero())return v.abs();if(v.isZero())return this.abs();var g=this.clone(),h=v.clone();g.negative=0,h.negative=0;for(var f=0;g.isEven()&&h.isEven();f++)g.iushrn(1),h.iushrn(1);do{for(;g.isEven();)g.iushrn(1);for(;h.isEven();)h.iushrn(1);var p=g.cmp(h);if(p<0){var _=g;g=h,h=_}else if(p===0||h.cmpn(1)===0)break;g.isub(h)}while(!0);return h.iushln(f)},s.prototype.invm=function(v){return this.egcd(v).a.umod(v)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(v){return this.words[0]&v},s.prototype.bincn=function(v){i(typeof v=="number");var g=v%26,h=(v-g)/26,f=1<<g;if(this.length<=h)return this._expand(h+1),this.words[h]|=f,this;for(var p=f,_=h;p!==0&&_<this.length;_++){var $=this.words[_]|0;$+=p,p=$>>>26,$&=67108863,this.words[_]=$}return p!==0&&(this.words[_]=p,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(v){var g=v<0;if(this.negative!==0&&!g)return-1;if(this.negative===0&&g)return 1;this.strip();var h;if(this.length>1)h=1;else{g&&(v=-v),i(v<=67108863,"Number is too big");var f=this.words[0]|0;h=f===v?0:f<v?-1:1}return this.negative!==0?-h|0:h},s.prototype.cmp=function(v){if(this.negative!==0&&v.negative===0)return-1;if(this.negative===0&&v.negative!==0)return 1;var g=this.ucmp(v);return this.negative!==0?-g|0:g},s.prototype.ucmp=function(v){if(this.length>v.length)return 1;if(this.length<v.length)return-1;for(var g=0,h=this.length-1;h>=0;h--){var f=this.words[h]|0,p=v.words[h]|0;if(f!==p){f<p?g=-1:f>p&&(g=1);break}}return g},s.prototype.gtn=function(v){return this.cmpn(v)===1},s.prototype.gt=function(v){return this.cmp(v)===1},s.prototype.gten=function(v){return this.cmpn(v)>=0},s.prototype.gte=function(v){return this.cmp(v)>=0},s.prototype.ltn=function(v){return this.cmpn(v)===-1},s.prototype.lt=function(v){return this.cmp(v)===-1},s.prototype.lten=function(v){return this.cmpn(v)<=0},s.prototype.lte=function(v){return this.cmp(v)<=0},s.prototype.eqn=function(v){return this.cmpn(v)===0},s.prototype.eq=function(v){return this.cmp(v)===0},s.red=function(v){return new B(v)},s.prototype.toRed=function(v){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),v.convertTo(this)._forceRed(v)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(v){return this.red=v,this},s.prototype.forceRed=function(v){return i(!this.red,"Already a number in reduction context"),this._forceRed(v)},s.prototype.redAdd=function(v){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,v)},s.prototype.redIAdd=function(v){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,v)},s.prototype.redSub=function(v){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,v)},s.prototype.redISub=function(v){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,v)},s.prototype.redShl=function(v){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,v)},s.prototype.redMul=function(v){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,v),this.red.mul(this,v)},s.prototype.redIMul=function(v){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,v),this.red.imul(this,v)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(v){return i(this.red&&!v.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,v)};var N={k256:null,p224:null,p192:null,p25519:null};function T(M,v){this.name=M,this.p=new s(v,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}T.prototype._tmp=function(){var v=new s(null);return v.words=new Array(Math.ceil(this.n/13)),v},T.prototype.ireduce=function(v){var g=v,h;do this.split(g,this.tmp),g=this.imulK(g),g=g.iadd(this.tmp),h=g.bitLength();while(h>this.n);var f=h<this.n?-1:g.ucmp(this.p);return f===0?(g.words[0]=0,g.length=1):f>0?g.isub(this.p):g.strip!==void 0?g.strip():g._strip(),g},T.prototype.split=function(v,g){v.iushrn(this.n,0,g)},T.prototype.imulK=function(v){return v.imul(this.k)};function U(){T.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(U,T),U.prototype.split=function(v,g){for(var h=4194303,f=Math.min(v.length,9),p=0;p<f;p++)g.words[p]=v.words[p];if(g.length=f,v.length<=9){v.words[0]=0,v.length=1;return}var _=v.words[9];for(g.words[g.length++]=_&h,p=10;p<v.length;p++){var $=v.words[p]|0;v.words[p-10]=($&h)<<4|_>>>22,_=$}_>>>=22,v.words[p-10]=_,_===0&&v.length>10?v.length-=10:v.length-=9},U.prototype.imulK=function(v){v.words[v.length]=0,v.words[v.length+1]=0,v.length+=2;for(var g=0,h=0;h<v.length;h++){var f=v.words[h]|0;g+=f*977,v.words[h]=g&67108863,g=f*64+(g/67108864|0)}return v.words[v.length-1]===0&&(v.length--,v.words[v.length-1]===0&&v.length--),v};function z(){T.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(z,T);function W(){T.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(W,T);function V(){T.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(V,T),V.prototype.imulK=function(v){for(var g=0,h=0;h<v.length;h++){var f=(v.words[h]|0)*19+g,p=f&67108863;f>>>=26,v.words[h]=p,g=f}return g!==0&&(v.words[v.length++]=g),v},s._prime=function(v){if(N[v])return N[v];var g;if(v==="k256")g=new U;else if(v==="p224")g=new z;else if(v==="p192")g=new W;else if(v==="p25519")g=new V;else throw new Error("Unknown prime "+v);return N[v]=g,g};function B(M){if(typeof M=="string"){var v=s._prime(M);this.m=v.p,this.prime=v}else i(M.gtn(1),"modulus must be greater than 1"),this.m=M,this.prime=null}B.prototype._verify1=function(v){i(v.negative===0,"red works only with positives"),i(v.red,"red works only with red numbers")},B.prototype._verify2=function(v,g){i((v.negative|g.negative)===0,"red works only with positives"),i(v.red&&v.red===g.red,"red works only with red numbers")},B.prototype.imod=function(v){return this.prime?this.prime.ireduce(v)._forceRed(this):v.umod(this.m)._forceRed(this)},B.prototype.neg=function(v){return v.isZero()?v.clone():this.m.sub(v)._forceRed(this)},B.prototype.add=function(v,g){this._verify2(v,g);var h=v.add(g);return h.cmp(this.m)>=0&&h.isub(this.m),h._forceRed(this)},B.prototype.iadd=function(v,g){this._verify2(v,g);var h=v.iadd(g);return h.cmp(this.m)>=0&&h.isub(this.m),h},B.prototype.sub=function(v,g){this._verify2(v,g);var h=v.sub(g);return h.cmpn(0)<0&&h.iadd(this.m),h._forceRed(this)},B.prototype.isub=function(v,g){this._verify2(v,g);var h=v.isub(g);return h.cmpn(0)<0&&h.iadd(this.m),h},B.prototype.shl=function(v,g){return this._verify1(v),this.imod(v.ushln(g))},B.prototype.imul=function(v,g){return this._verify2(v,g),this.imod(v.imul(g))},B.prototype.mul=function(v,g){return this._verify2(v,g),this.imod(v.mul(g))},B.prototype.isqr=function(v){return this.imul(v,v.clone())},B.prototype.sqr=function(v){return this.mul(v,v)},B.prototype.sqrt=function(v){if(v.isZero())return v.clone();var g=this.m.andln(3);if(i(g%2===1),g===3){var h=this.m.add(new s(1)).iushrn(2);return this.pow(v,h)}for(var f=this.m.subn(1),p=0;!f.isZero()&&f.andln(1)===0;)p++,f.iushrn(1);i(!f.isZero());var _=new s(1).toRed(this),$=_.redNeg(),y=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,y).cmp($)!==0;)d.redIAdd($);for(var w=this.pow(d,f),b=this.pow(v,f.addn(1).iushrn(1)),P=this.pow(v,f),q=p;P.cmp(_)!==0;){for(var I=P,F=0;I.cmp(_)!==0;F++)I=I.redSqr();i(F<q);var j=this.pow(w,new s(1).iushln(q-F-1));b=b.redMul(j),w=j.redSqr(),P=P.redMul(w),q=F}return b},B.prototype.invm=function(v){var g=v._invmp(this.m);return g.negative!==0?(g.negative=0,this.imod(g).redNeg()):this.imod(g)},B.prototype.pow=function(v,g){if(g.isZero())return new s(1).toRed(this);if(g.cmpn(1)===0)return v.clone();var h=4,f=new Array(1<<h);f[0]=new s(1).toRed(this),f[1]=v;for(var p=2;p<f.length;p++)f[p]=this.mul(f[p-1],v);var _=f[0],$=0,y=0,d=g.bitLength()%26;for(d===0&&(d=26),p=g.length-1;p>=0;p--){for(var w=g.words[p],b=d-1;b>=0;b--){var P=w>>b&1;if(_!==f[0]&&(_=this.sqr(_)),P===0&&$===0){y=0;continue}$<<=1,$|=P,y++,!(y!==h&&(p!==0||b!==0))&&(_=this.mul(_,f[$]),y=0,$=0)}d=26}return _},B.prototype.convertTo=function(v){var g=v.umod(this.m);return g===v?g.clone():g},B.prototype.convertFrom=function(v){var g=v.clone();return g.red=null,g},s.mont=function(v){return new K(v)};function K(M){B.call(this,M),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(K,B),K.prototype.convertTo=function(v){return this.imod(v.ushln(this.shift))},K.prototype.convertFrom=function(v){var g=this.imod(v.mul(this.rinv));return g.red=null,g},K.prototype.imul=function(v,g){if(v.isZero()||g.isZero())return v.words[0]=0,v.length=1,v;var h=v.imul(g),f=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=h.isub(f).iushrn(this.shift),_=p;return p.cmp(this.m)>=0?_=p.isub(this.m):p.cmpn(0)<0&&(_=p.iadd(this.m)),_._forceRed(this)},K.prototype.mul=function(v,g){if(v.isZero()||g.isZero())return new s(0)._forceRed(this);var h=v.mul(g),f=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),p=h.isub(f).iushrn(this.shift),_=p;return p.cmp(this.m)>=0?_=p.isub(this.m):p.cmpn(0)<0&&(_=p.iadd(this.m)),_._forceRed(this)},K.prototype.invm=function(v){var g=this.imod(v._invmp(this.m).mul(this.r2));return g._forceRed(this)}})(t,Ft)})(ki);var Nf={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var l=s.charCodeAt(c),u=l>>8,m=l&255;u?a.push(u,m):a.push(m)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(Nf),function(t){var e=t,r=ki.exports,i=ps,n=Nf;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(u,m,x){var S=new Array(Math.max(u.bitLength(),x)+1),E;for(E=0;E<S.length;E+=1)S[E]=0;var A=1<<m+1,R=u.clone();for(E=0;E<S.length;E++){var O,C=R.andln(A-1);R.isOdd()?(C>(A>>1)-1?O=(A>>1)-C:O=C,R.isubn(O)):O=0,S[E]=O,R.iushrn(1)}return S}e.getNAF=s;function o(u,m){var x=[[],[]];u=u.clone(),m=m.clone();for(var S=0,E=0,A;u.cmpn(-S)>0||m.cmpn(-E)>0;){var R=u.andln(3)+S&3,O=m.andln(3)+E&3;R===3&&(R=-1),O===3&&(O=-1);var C;(R&1)===0?C=0:(A=u.andln(7)+S&7,(A===3||A===5)&&O===2?C=-R:C=R),x[0].push(C);var N;(O&1)===0?N=0:(A=m.andln(7)+E&7,(A===3||A===5)&&R===2?N=-O:N=O),x[1].push(N),2*S===C+1&&(S=1-S),2*E===N+1&&(E=1-E),u.iushrn(1),m.iushrn(1)}return x}e.getJSF=o;function a(u,m,x){var S="_"+m;u.prototype[m]=function(){return this[S]!==void 0?this[S]:this[S]=x.call(this)}}e.cachedProperty=a;function c(u){return typeof u=="string"?e.toArray(u,"hex"):u}e.parseBytes=c;function l(u){return new r(u,"hex","le")}e.intFromLE=l}(Kr);var Yc={exports:{}},Tf;Yc.exports=function(e){return Tf||(Tf=new qn(null)),Tf.generate(e)};function qn(t){this.rand=t}if(Yc.exports.Rand=qn,qn.prototype.generate=function(e){return this._rand(e)},qn.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?qn.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?qn.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(qn.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var rg=Hh;if(typeof rg.randomBytes!="function")throw new Error("Not supported");qn.prototype._rand=function(e){return rg.randomBytes(e)}}catch{}var Ff={},ys=ki.exports,Ma=Kr,Xc=Ma.getNAF,w9=Ma.getJSF,Qc=Ma.assert;function jn(t,e){this.type=t,this.p=new ys(e.p,16),this.red=e.prime?ys.red(e.prime):ys.mont(this.p),this.zero=new ys(0).toRed(this.red),this.one=new ys(1).toRed(this.red),this.two=new ys(2).toRed(this.red),this.n=e.n&&new ys(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var el=jn;jn.prototype.point=function(){throw new Error("Not implemented")},jn.prototype.validate=function(){throw new Error("Not implemented")},jn.prototype._fixedNafMul=function(e,r){Qc(e.precomputed);var i=e._getDoubles(),n=Xc(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var l=a+i.step-1;l>=a;l--)c=(c<<1)+n[l];o.push(c)}for(var u=this.jpoint(null,null,null),m=this.jpoint(null,null,null),x=s;x>0;x--){for(a=0;a<o.length;a++)c=o[a],c===x?m=m.mixedAdd(i.points[a]):c===-x&&(m=m.mixedAdd(i.points[a].neg()));u=u.add(m)}return u.toP()},jn.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Xc(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var l=0;c>=0&&o[c]===0;c--)l++;if(c>=0&&l++,a=a.dblp(l),c<0)break;var u=o[c];Qc(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a},jn.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,l=0,u,m,x;for(u=0;u<n;u++){x=r[u];var S=x._getNAFPoints(e);o[u]=S.wnd,a[u]=S.points}for(u=n-1;u>=1;u-=2){var E=u-1,A=u;if(o[E]!==1||o[A]!==1){c[E]=Xc(i[E],o[E],this._bitLength),c[A]=Xc(i[A],o[A],this._bitLength),l=Math.max(c[E].length,l),l=Math.max(c[A].length,l);continue}var R=[r[E],null,null,r[A]];r[E].y.cmp(r[A].y)===0?(R[1]=r[E].add(r[A]),R[2]=r[E].toJ().mixedAdd(r[A].neg())):r[E].y.cmp(r[A].y.redNeg())===0?(R[1]=r[E].toJ().mixedAdd(r[A]),R[2]=r[E].add(r[A].neg())):(R[1]=r[E].toJ().mixedAdd(r[A]),R[2]=r[E].toJ().mixedAdd(r[A].neg()));var O=[-3,-1,-5,-7,0,7,5,1,3],C=w9(i[E],i[A]);for(l=Math.max(C[0].length,l),c[E]=new Array(l),c[A]=new Array(l),m=0;m<l;m++){var N=C[0][m]|0,T=C[1][m]|0;c[E][m]=O[(N+1)*3+(T+1)],c[A][m]=0,a[E]=R}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(u=l;u>=0;u--){for(var W=0;u>=0;){var V=!0;for(m=0;m<n;m++)z[m]=c[m][u]|0,z[m]!==0&&(V=!1);if(!V)break;W++,u--}if(u>=0&&W++,U=U.dblp(W),u<0)break;for(m=0;m<n;m++){var B=z[m];B!==0&&(B>0?x=a[m][B-1>>1]:B<0&&(x=a[m][-B-1>>1].neg()),x.type==="affine"?U=U.mixedAdd(x):U=U.add(x))}}for(u=0;u<n;u++)a[u]=null;return s?U:U.toP()};function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}jn.BasePoint=ci,ci.prototype.eq=function(){throw new Error("Not implemented")},ci.prototype.validate=function(){return this.curve.validate(this)},jn.prototype.decodePoint=function(e,r){e=Ma.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Qc(e[e.length-1]%2===0):e[0]===7&&Qc(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},ci.prototype.encodeCompressed=function(e){return this.encode(e,!0)},ci.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},ci.prototype.encode=function(e,r){return Ma.encode(this._encode(r),e)},ci.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},ci.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},ci.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},ci.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},ci.prototype._getBeta=function(){return null},ci.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var _9=Kr,Rt=ki.exports,Lf=ro.exports,uo=el,x9=_9.assert;function li(t){uo.call(this,"short",t),this.a=new Rt(t.a,16).toRed(this.red),this.b=new Rt(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Lf(li,uo);var E9=li;li.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new Rt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new Rt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],x9(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new Rt(a.a,16),b:new Rt(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},li.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:Rt.mont(e),i=new Rt(2).toRed(r).redInvm(),n=i.redNeg(),s=new Rt(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},li.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new Rt(1),o=new Rt(0),a=new Rt(0),c=new Rt(1),l,u,m,x,S,E,A,R=0,O,C;i.cmpn(0)!==0;){var N=n.div(i);O=n.sub(N.mul(i)),C=a.sub(N.mul(s));var T=c.sub(N.mul(o));if(!m&&O.cmp(r)<0)l=A.neg(),u=s,m=O.neg(),x=C;else if(m&&++R===2)break;A=O,n=i,i=O,a=s,s=C,c=o,o=T}S=O.neg(),E=C;var U=m.sqr().add(x.sqr()),z=S.sqr().add(E.sqr());return z.cmp(U)>=0&&(S=l,E=u),m.negative&&(m=m.neg(),x=x.neg()),S.negative&&(S=S.neg(),E=E.neg()),[{a:m,b:x},{a:S,b:E}]},li.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),l=s.mul(i.b),u=o.mul(n.b),m=e.sub(a).sub(c),x=l.add(u).neg();return{k1:m,k2:x}},li.prototype.pointFromX=function(e,r){e=new Rt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},li.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},li.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],l=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),l=l.neg(!0)),n[o*2]=c,n[o*2+1]=l,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return u};function Jt(t,e,r,i){uo.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Rt(e,16),this.y=new Rt(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Lf(Jt,uo.BasePoint),li.prototype.point=function(e,r,i){return new Jt(this,e,r,i)},li.prototype.pointFromJSON=function(e,r){return Jt.fromJSON(this,e,r)},Jt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},Jt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Jt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Jt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Jt.prototype.isInfinity=function(){return this.inf},Jt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Jt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Jt.prototype.getX=function(){return this.x.fromRed()},Jt.prototype.getY=function(){return this.y.fromRed()},Jt.prototype.mul=function(e){return e=new Rt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Jt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Jt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Jt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Jt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},Jt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function lr(t,e,r,i){uo.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Rt(0)):(this.x=new Rt(e,16),this.y=new Rt(r,16),this.z=new Rt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Lf(lr,uo.BasePoint),li.prototype.jpoint=function(e,r,i){return new lr(this,e,r,i)},lr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},lr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},lr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),l=o.redSub(a);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),m=u.redMul(c),x=n.redMul(u),S=l.redSqr().redIAdd(m).redISub(x).redISub(x),E=l.redMul(x.redISub(S)).redISub(o.redMul(m)),A=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(S,E,A)},lr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),m=i.redMul(l),x=c.redSqr().redIAdd(u).redISub(m).redISub(m),S=c.redMul(m.redISub(x)).redISub(s.redMul(u)),E=this.z.redMul(a);return this.curve.jpoint(x,S,E)},lr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,l=c.redSqr().redSqr(),u=a.redAdd(a);for(r=0;r<e;r++){var m=o.redSqr(),x=u.redSqr(),S=x.redSqr(),E=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(l)),A=o.redMul(x),R=E.redSqr().redISub(A.redAdd(A)),O=A.redISub(R),C=E.redMul(O);C=C.redIAdd(C).redISub(S);var N=u.redMul(c);r+1<e&&(l=l.redMul(S)),o=R,c=N,u=C}return this.curve.jpoint(o,u.redMul(s),c)},lr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},lr.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),l=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=l,r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),x=this.y.redSqr(),S=x.redSqr(),E=this.x.redAdd(x).redSqr().redISub(m).redISub(S);E=E.redIAdd(E);var A=m.redAdd(m).redIAdd(m),R=A.redSqr(),O=S.redIAdd(S);O=O.redIAdd(O),O=O.redIAdd(O),e=R.redISub(E).redISub(E),r=A.redMul(E.redISub(e)).redISub(O),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},lr.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),l=c.redSqr().redISub(a).redISub(a);e=l;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),x=this.y.redSqr(),S=this.x.redMul(x),E=this.x.redSub(m).redMul(this.x.redAdd(m));E=E.redAdd(E).redIAdd(E);var A=S.redIAdd(S);A=A.redIAdd(A);var R=A.redAdd(A);e=E.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(x).redISub(m);var O=x.redSqr();O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O),r=E.redMul(A.redISub(e)).redISub(O)}return this.curve.jpoint(e,r,i)},lr.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),l=r.redAdd(r);l=l.redIAdd(l);var u=l.redMul(a),m=c.redSqr().redISub(u.redAdd(u)),x=u.redISub(m),S=a.redSqr();S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var E=c.redMul(x).redISub(S),A=i.redAdd(i).redMul(n);return this.curve.jpoint(m,E,A)},lr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),l=n.redIAdd(n);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(l),m=r.redMul(u);m=m.redIAdd(m),m=m.redIAdd(m);var x=this.x.redMul(c).redISub(m);x=x.redIAdd(x),x=x.redIAdd(x);var S=this.y.redMul(u.redMul(l.redISub(u)).redISub(a.redMul(c)));S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var E=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(x,S,E)},lr.prototype.mul=function(e,r){return e=new Rt(e,r),this.curve._wnafMul(this,e)},lr.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},lr.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},lr.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},lr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var po=ki.exports,ig=ro.exports,tl=el,$9=Kr;function go(t){tl.call(this,"mont",t),this.a=new po(t.a,16).toRed(this.red),this.b=new po(t.b,16).toRed(this.red),this.i4=new po(4).toRed(this.red).redInvm(),this.two=new po(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}ig(go,tl);var S9=go;go.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function Zt(t,e,r){tl.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new po(e,16),this.z=new po(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}ig(Zt,tl.BasePoint),go.prototype.decodePoint=function(e,r){return this.point($9.toArray(e,r),1)},go.prototype.point=function(e,r){return new Zt(this,e,r)},go.prototype.pointFromJSON=function(e){return Zt.fromJSON(this,e)},Zt.prototype.precompute=function(){},Zt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Zt.fromJSON=function(e,r){return new Zt(e,r[0],r[1]||e.one)},Zt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Zt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Zt.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},Zt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Zt.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),l=r.z.redMul(a.redAdd(c).redSqr()),u=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(l,u)},Zt.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Zt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Zt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Zt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Zt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Zt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var I9=Kr,un=ki.exports,ng=ro.exports,rl=el,A9=I9.assert;function zi(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,rl.call(this,"edwards",t),this.a=new un(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new un(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new un(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),A9(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}ng(zi,rl);var M9=zi;zi.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},zi.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},zi.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},zi.prototype.pointFromX=function(e,r){e=new un(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},zi.prototype.pointFromY=function(e,r){e=new un(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},zi.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function $t(t,e,r,i,n){rl.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new un(e,16),this.y=new un(r,16),this.z=i?new un(i,16):this.curve.one,this.t=n&&new un(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}ng($t,rl.BasePoint),zi.prototype.pointFromJSON=function(e){return $t.fromJSON(this,e)},zi.prototype.point=function(e,r,i,n){return new $t(this,e,r,i,n)},$t.fromJSON=function(e,r){return new $t(e,r[0],r[1],r[2])},$t.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},$t.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},$t.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),l=s.redMul(a),u=o.redMul(c),m=s.redMul(c),x=a.redMul(o);return this.curve.point(l,u,x,m)},$t.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,l;if(this.curve.twisted){a=this.curve._mulA(r);var u=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(u.redSub(this.curve.two)),s=u.redMul(a.redSub(i)),o=u.redSqr().redSub(u).redSub(u)):(c=this.z.redSqr(),l=u.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(l),s=u.redMul(a.redSub(i)),o=u.redMul(l))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),l=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(l),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(l);return this.curve.point(n,s,o)},$t.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},$t.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),l=i.redAdd(r),u=o.redMul(a),m=c.redMul(l),x=o.redMul(l),S=a.redMul(c);return this.curve.point(u,m,S,x)},$t.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),u=r.redMul(a).redMul(l),m,x;return this.curve.twisted?(m=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),x=a.redMul(c)):(m=r.redMul(c).redMul(s.redSub(n)),x=this.curve._mulC(a).redMul(c)),this.curve.point(u,m,x)},$t.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},$t.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},$t.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},$t.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},$t.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},$t.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},$t.prototype.getX=function(){return this.normalize(),this.x.fromRed()},$t.prototype.getY=function(){return this.normalize(),this.y.fromRed()},$t.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},$t.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},$t.prototype.toP=$t.prototype.normalize,$t.prototype.mixedAdd=$t.prototype.add,function(t){var e=t;e.base=el,e.short=E9,e.mont=S9,e.edwards=M9}(Ff);var il={},Bf,sg;function P9(){return sg||(sg=1,Bf={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),Bf}(function(t){var e=t,r=Wr,i=Ff,n=Kr,s=n.assert;function o(l){l.type==="short"?this.curve=new i.short(l):l.type==="edwards"?this.curve=new i.edwards(l):this.curve=new i.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(l,u){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var m=new o(u);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:m}),m}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=P9()}catch{c=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(il);var O9=Wr,ws=Nf,og=ps;function kn(t){if(!(this instanceof kn))return new kn(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ws.toArray(t.entropy,t.entropyEnc||"hex"),r=ws.toArray(t.nonce,t.nonceEnc||"hex"),i=ws.toArray(t.pers,t.persEnc||"hex");og(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var C9=kn;kn.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},kn.prototype._hmac=function(){return new O9.hmac(this.hash,this.K)},kn.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},kn.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=ws.toArray(e,r),i=ws.toArray(i,n),og(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},kn.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=ws.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,ws.encode(o,r)};var D9=ki.exports,R9=Kr,Uf=R9.assert;function vr(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var N9=vr;vr.fromPublic=function(e,r,i){return r instanceof vr?r:new vr(e,{pub:r,pubEnc:i})},vr.fromPrivate=function(e,r,i){return r instanceof vr?r:new vr(e,{priv:r,privEnc:i})},vr.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},vr.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},vr.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},vr.prototype._importPrivate=function(e,r){this.priv=new D9(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},vr.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Uf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Uf(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},vr.prototype.derive=function(e){return e.validate()||Uf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},vr.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},vr.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},vr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var nl=ki.exports,qf=Kr,T9=qf.assert;function sl(t,e){if(t instanceof sl)return t;this._importDER(t,e)||(T9(t.r&&t.s,"Signature without r or s"),this.r=new nl(t.r,16),this.s=new nl(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var F9=sl;function L9(){this.place=0}function jf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function ag(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}sl.prototype._importDER=function(e,r){e=qf.toArray(e,r);var i=new L9;if(e[i.place++]!==48)return!1;var n=jf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=jf(e,i);if(s===!1||(e[i.place]&128)!==0)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=jf(e,i);if(a===!1||e.length!==a+i.place||(e[i.place]&128)!==0)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new nl(o),this.s=new nl(c),this.recoveryParam=null,!0};function kf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}sl.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=ag(r),i=ag(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];kf(n,r.length),n=n.concat(r),n.push(2),kf(n,i.length);var s=n.concat(i),o=[48];return kf(o,s.length),o=o.concat(s),qf.encode(o,e)};var Ii=ki.exports,cg=C9,B9=Kr,zf=il,U9=Yc.exports,_s=B9.assert,Hf=N9,ol=F9;function hi(t){if(!(this instanceof hi))return new hi(t);typeof t=="string"&&(_s(Object.prototype.hasOwnProperty.call(zf,t),"Unknown curve "+t),t=zf[t]),t instanceof zf.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var q9=hi;hi.prototype.keyPair=function(e){return new Hf(this,e)},hi.prototype.keyFromPrivate=function(e,r){return Hf.fromPrivate(this,e,r)},hi.prototype.keyFromPublic=function(e,r){return Hf.fromPublic(this,e,r)},hi.prototype.genKeyPair=function(e){e||(e={});for(var r=new cg({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||U9(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ii(2));;){var s=new Ii(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},hi.prototype._truncateToN=function(e,r,i){var n;if(Ii.isBN(e)||typeof e=="number")e=new Ii(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Ii(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Ii(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},hi.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Ii.isBN(e)){_s(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),_s(e.length>>>0===e.length);for(var s=0;s<e.length;s++)_s((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),_s(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);_s(new Ii(c).eq(e),"Can not sign message");for(var l=new cg({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Ii(1)),m=0;;m++){var x=n.k?n.k(m):new Ii(l.generate(this.n.byteLength()));if(x=this._truncateToN(x,!0),!(x.cmpn(1)<=0||x.cmp(u)>=0)){var S=this.g.mul(x);if(!S.isInfinity()){var E=S.getX(),A=E.umod(this.n);if(A.cmpn(0)!==0){var R=x.invm(this.n).mul(A.mul(r.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(E.cmp(A)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),O^=1),new ol({r:A,s:R,recoveryParam:O})}}}}}},hi.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new ol(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),l=c.mul(e).umod(this.n),u=c.mul(o).umod(this.n),m;return this.curve._maxwellTrick?(m=this.g.jmulAdd(l,i.getPublic(),u),m.isInfinity()?!1:m.eqXToP(o)):(m=this.g.mulAdd(l,i.getPublic(),u),m.isInfinity()?!1:m.getX().umod(this.n).cmp(o)===0)},hi.prototype.recoverPubKey=function(t,e,r,i){_s((3&r)===r,"The recovery param is more than two bits"),e=new ol(e,i);var n=this.n,s=new Ii(t),o=e.r,a=e.s,c=r&1,l=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var u=e.r.invm(n),m=n.sub(s).mul(u).umod(n),x=a.mul(u).umod(n);return this.g.mulAdd(m,o,x)},hi.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new ol(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Pa=Kr,lg=Pa.assert,hg=Pa.parseBytes,vo=Pa.cachedProperty;function Yt(t,e){this.eddsa=t,this._secret=hg(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=hg(e.pub)}Yt.fromPublic=function(e,r){return r instanceof Yt?r:new Yt(e,{pub:r})},Yt.fromSecret=function(e,r){return r instanceof Yt?r:new Yt(e,{secret:r})},Yt.prototype.secret=function(){return this._secret},vo(Yt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),vo(Yt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),vo(Yt,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),vo(Yt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),vo(Yt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),vo(Yt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Yt.prototype.sign=function(e){return lg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Yt.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Yt.prototype.getSecret=function(e){return lg(this._secret,"KeyPair is public only"),Pa.encode(this.secret(),e)},Yt.prototype.getPublic=function(e){return Pa.encode(this.pubBytes(),e)};var j9=Yt,k9=ki.exports,al=Kr,fg=al.assert,cl=al.cachedProperty,z9=al.parseBytes;function xs(t,e){this.eddsa=t,typeof e!="object"&&(e=z9(e)),Array.isArray(e)&&(fg(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),fg(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof k9&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}cl(xs,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),cl(xs,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),cl(xs,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),cl(xs,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),xs.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},xs.prototype.toHex=function(){return al.encode(this.toBytes(),"hex").toUpperCase()};var H9=xs,W9=Wr,V9=il,mo=Kr,K9=mo.assert,ug=mo.parseBytes,dg=j9,pg=H9;function Dr(t){if(K9(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Dr))return new Dr(t);t=V9[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=W9.sha512}var G9=Dr;Dr.prototype.sign=function(e,r){e=ug(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},Dr.prototype.verify=function(e,r,i){if(e=ug(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},Dr.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return mo.intFromLE(e.digest()).umod(this.curve.n)},Dr.prototype.keyFromPublic=function(e){return dg.fromPublic(this,e)},Dr.prototype.keyFromSecret=function(e){return dg.fromSecret(this,e)},Dr.prototype.makeSignature=function(e){return e instanceof pg?e:new pg(this,e)},Dr.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},Dr.prototype.decodePoint=function(e){e=mo.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=mo.intFromLE(i);return this.curve.pointFromY(s,n)},Dr.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},Dr.prototype.decodeInt=function(e){return mo.intFromLE(e)},Dr.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=y9.version,e.utils=Kr,e.rand=Yc.exports,e.curve=Ff,e.curves=il,e.ec=q9,e.eddsa=G9}(tg);const J9={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 Z9=Object.defineProperty,gg=Object.getOwnPropertySymbols,Y9=Object.prototype.hasOwnProperty,X9=Object.prototype.propertyIsEnumerable,vg=(t,e,r)=>e in t?Z9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Q9=(t,e)=>{for(var r in e||(e={}))Y9.call(e,r)&&vg(t,r,e[r]);if(gg)for(var r of gg(e))X9.call(e,r)&&vg(t,r,e[r]);return t};const e_=":";function bo(t){const[e,r]=t.split(e_);return{namespace:e,reference:r}}function mg(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 bg(t,e){return t.includes(":")?[t]:e.chains||[]}const t_="ReactNative",Gr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},r_="js";function ll(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function zn(){return!va()&&!!Uh()&&navigator.product===t_}function i_(){return zn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function n_(){return zn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Oa(){return!ll()&&!!Uh()&&!!va()}function Ca(){return zn()?Gr.reactNative:ll()?Gr.node:Oa()?Gr.browser:Gr.unknown}function yg(){var t;try{return zn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function s_(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 wg(){return V0()||{name:"",description:"",url:"",icons:[""]}}function o_(){if(Ca()===Gr.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=Xy();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 a_(){var t;const e=Ca();return e===Gr.browser?[e,((t=W0())==null?void 0:t.host)||"unknown"].join(":"):e}function _g(t,e,r){const i=o_(),n=a_();return[[t,e].join("-"),[r_,r].join("-"),i,n].join("/")}function c_({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=r.split("?"),u=_g(t,e,i),m={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},x=s_(l[1]||"",m);return l[0]+"?"+x}function Es(t,e){return t.filter(r=>e.includes(r)).length===t.length}function xg(t){return Object.fromEntries(t.entries())}function Eg(t){return new Map(Object.entries(t))}function $s(t=X.FIVE_MINUTES,e){const r=X.toMiliseconds(t||X.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 l=new Error(e);o=Promise.reject(l),c(l)},r),i=a,n=c})}}function Hn(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 $g(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 l_(t){return $g("topic",t)}function h_(t){return $g("id",t)}function Sg(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 Wt(t,e){return X.fromMiliseconds((e||Date.now())+X.toMiliseconds(t))}function Wn(t){return Date.now()>=X.toMiliseconds(t)}function Oe(t,e){return`${t}${e?`:${e}`:""}`}function hl(t=[],e=[]){return[...new Set([...t,...e])]}async function f_({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=u_(s,t,e),a=Ca();if(a===Gr.browser){if(!((i=va())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}d_(o)}else a===Gr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function u_(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}${m_(i,!0)}`}else n=`${n}/wc?${i}`;return n}function d_(t){let e="_self";v_()?e="_top":(g_()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function p_(t,e){let r="";try{if(Oa()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Ig(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Ag(){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 Wf(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function g_(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function v_(){try{return window.self!==window.top}catch{return!1}}function m_(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Mg(t){return Buffer.from(t,"base64").toString("utf-8")}function b_(t){return new Promise(e=>setTimeout(e,t))}function Da(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function y_(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fl(t,...e){if(!y_(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 Vf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Da(t.outputLen),Da(t.blockLen)}function yo(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 Pg(t,e){fl(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ul=BigInt(2**32-1),Og=BigInt(32);function w_(t,e=!1){return e?{h:Number(t&ul),l:Number(t>>Og&ul)}:{h:Number(t>>Og&ul)|0,l:Number(t&ul)|0}}function __(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}=w_(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const x_=(t,e,r)=>t<<r|e>>>32-r,E_=(t,e,r)=>e<<r|t>>>32-r,$_=(t,e,r)=>e<<r-32|t>>>64-r,S_=(t,e,r)=>t<<r-32|e>>>64-r,wo=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function I_(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Kf(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Hi(t,e){return t<<32-e|t>>>e}const Cg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function A_(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Dg(t){for(let e=0;e<t.length;e++)t[e]=A_(t[e])}function M_(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function _o(t){return typeof t=="string"&&(t=M_(t)),fl(t),t}class Gf{clone(){return this._cloneInto()}}function Rg(t){const e=i=>t().update(_o(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ra(t=32){if(wo&&typeof wo.getRandomValues=="function")return wo.getRandomValues(new Uint8Array(t));if(wo&&typeof wo.randomBytes=="function")return wo.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Ng=[],Tg=[],Fg=[],P_=BigInt(0),Na=BigInt(1),O_=BigInt(2),C_=BigInt(7),D_=BigInt(256),R_=BigInt(113);for(let t=0,e=Na,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Ng.push(2*(5*i+r)),Tg.push((t+1)*(t+2)/2%64);let n=P_;for(let s=0;s<7;s++)e=(e<<Na^(e>>C_)*R_)%D_,e&O_&&(n^=Na<<(Na<<BigInt(s))-Na);Fg.push(n)}const[N_,T_]=__(Fg,!0),Lg=(t,e,r)=>r>32?$_(t,e,r):x_(t,e,r),Bg=(t,e,r)=>r>32?S_(t,e,r):E_(t,e,r);function F_(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,l=r[c],u=r[c+1],m=Lg(l,u,1)^r[a],x=Bg(l,u,1)^r[a+1];for(let S=0;S<50;S+=10)t[o+S]^=m,t[o+S+1]^=x}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Tg[o],c=Lg(n,s,a),l=Bg(n,s,a),u=Ng[o];n=t[u],s=t[u+1],t[u]=c,t[u+1]=l}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]^=N_[i],t[1]^=T_[i]}r.fill(0)}class Jf extends Gf{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,Da(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=I_(this.state)}keccak(){Cg||Dg(this.state32),F_(this.state32,this.rounds),Cg||Dg(this.state32),this.posOut=0,this.pos=0}update(e){yo(this);const{blockLen:r,state:i}=this;e=_o(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)!==0&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){yo(this,!1),fl(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 Da(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Pg(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 Jf(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 L_=(t,e,r)=>Rg(()=>new Jf(e,t,r)),B_=L_(1,136,256/8),U_="https://rpc.walletconnect.org/v1";function Ug(t){const e=`Ethereum Signed Message:
|
|
22
|
-
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(B_(r)).toString("hex")}async function q_(t,e,r,i,n,s){switch(r.t){case"eip191":return j_(t,e,r.s);case"eip1271":return await k_(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function j_(t,e,r){return G4(Ug(e),r).toLowerCase()===t.toLowerCase()}async function k_(t,e,r,i,n,s){const o=bo(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",l="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),m=Ug(e).substring(2),x=a+m+c+l+u,S=await fetch(`${s||U_}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:z_(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:x},"latest"]})}),{result:E}=await S.json();return E?E.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function z_(){return Date.now()+Math.floor(Math.random()*1e3)}var H_=Object.defineProperty,W_=Object.defineProperties,V_=Object.getOwnPropertyDescriptors,qg=Object.getOwnPropertySymbols,K_=Object.prototype.hasOwnProperty,G_=Object.prototype.propertyIsEnumerable,jg=(t,e,r)=>e in t?H_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,J_=(t,e)=>{for(var r in e||(e={}))K_.call(e,r)&&jg(t,r,e[r]);if(qg)for(var r of qg(e))G_.call(e,r)&&jg(t,r,e[r]);return t},Z_=(t,e)=>W_(t,V_(e));const Y_="did:pkh:",Zf=t=>t?.split(":"),X_=t=>{const e=t&&Zf(t);if(e)return t.includes(Y_)?e[3]:e[1]},Yf=t=>{const e=t&&Zf(t);if(e)return e[2]+":"+e[3]},dl=t=>{const e=t&&Zf(t);if(e)return e.pop()};async function kg(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=zg(n,n.iss),o=dl(n.iss);return await q_(o,s,i,Yf(n.iss),r)}const zg=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=dl(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: ${X_(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,m=t.nbf?`Not Before: ${t.nbf}`:void 0,x=t.requestId?`Request ID: ${t.requestId}`:void 0,S=t.resources?`Resources:${t.resources.map(A=>`
|
|
23
|
-
- ${A}`).join("")}`:void 0,E=pl(t.resources);if(E){const A=Ta(E);n=ax(n,A)}return[r,i,"",n,"",s,o,a,c,l,u,m,x,S].filter(A=>A!=null).join(`
|
|
24
|
-
`)};function Q_(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function ex(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Ss(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 tx(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:rx(e,r,i)}}}function rx(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function Hg(t){return Ss(t),`urn:recap:${Q_(t).replace(/=/g,"")}`}function Ta(t){const e=ex(t.replace("urn:recap:",""));return Ss(e),e}function ix(t,e,r){const i=tx(t,e,r);return Hg(i)}function nx(t){return t&&t.includes("urn:recap:")}function sx(t,e){const r=Ta(t),i=Ta(e),n=ox(r,i);return Hg(n)}function ox(t,e){Ss(t),Ss(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,l;i.att[n]=Z_(J_({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((l=e.att[n])==null?void 0:l[a])})})}),i}function ax(t="",e){Ss(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(m=>({ability:m.split("/")[0],action:m.split("/")[1]}));c.sort((m,x)=>m.action.localeCompare(x.action));const l={};c.forEach(m=>{l[m.ability]||(l[m.ability]=[]),l[m.ability].push(m.action)});const u=Object.keys(l).map(m=>(n++,`(${n}) '${m}': '${l[m].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Wg(t){var e;const r=Ta(t);Ss(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Vg(t){const e=Ta(t);Ss(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 pl(t){if(!t)return;const e=t?.[t.length-1];return nx(e)?e:void 0}function Xf(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Kg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Jr(t,...e){if(!Kg(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 Gg(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 cx(t,e){Jr(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Jg(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Vn=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),lx=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function hx(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Qf(t){if(typeof t=="string")t=hx(t);else if(Kg(t))t=eu(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function fx(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function ux(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 dx=(t,e)=>{function r(i,...n){if(Jr(i),t.nonceLength!==void 0){const l=n[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?Jr(l):Jr(l,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Jr(n[1]);const o=e(i,...n),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");Jr(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Jr(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(Jr(l),s&&l.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(r,t),r};function Zg(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&&!px(e))throw new Error("invalid output, must be aligned");return e}function Yg(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}function px(t){return t.byteOffset%4===0}function eu(t){return Uint8Array.from(t)}function xo(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Xg=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),gx=Xg("expand 16-byte k"),vx=Xg("expand 32-byte k"),mx=Vn(gx),bx=Vn(vx);function Ge(t,e){return t<<e|t>>>32-e}function tu(t){return t.byteOffset%4===0}const gl=64,yx=16,Qg=2**32-1,ev=new Uint32Array;function wx(t,e,r,i,n,s,o,a){const c=n.length,l=new Uint8Array(gl),u=Vn(l),m=tu(n)&&tu(s),x=m?Vn(n):ev,S=m?Vn(s):ev;for(let E=0;E<c;o++){if(t(e,r,i,u,o,a),o>=Qg)throw new Error("arx: counter overflow");const A=Math.min(gl,c-E);if(m&&A===gl){const R=E/4;if(E%4!==0)throw new Error("arx: invalid block position");for(let O=0,C;O<yx;O++)C=R+O,S[C]=x[C]^u[O];E+=gl;continue}for(let R=0,O;R<A;R++)O=E+R,s[O]=n[O]^l[R];E+=A}}function _x(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=fx({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Xf(n),Xf(o),Jg(s),Jg(r),(a,c,l,u,m=0)=>{Jr(a),Jr(c),Jr(l);const x=l.length;if(u===void 0&&(u=new Uint8Array(x)),Jr(u),Xf(m),m<0||m>=Qg)throw new Error("arx: counter overflow");if(u.length<x)throw new Error(`arx: output (${u.length}) is shorter than data (${x})`);const S=[];let E=a.length,A,R;if(E===32)S.push(A=eu(a)),R=bx;else if(E===16&&r)A=new Uint8Array(32),A.set(a),A.set(a,16),R=mx,S.push(A);else throw new Error(`arx: invalid 32-byte key, got length=${E}`);tu(c)||S.push(c=eu(c));const O=Vn(A);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(R,O,Vn(c.subarray(0,16)),O),c=c.subarray(16)}const C=16-n;if(C!==c.length)throw new Error(`arx: nonce must be ${C} or 16 bytes`);if(C!==12){const T=new Uint8Array(12);T.set(c,s?0:12-c.length),c=T,S.push(c)}const N=Vn(c);return wx(t,R,O,N,l,u,m,o),xo(...S),u}}const hr=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class xx{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=Qf(e),Jr(e,32);const r=hr(e,0),i=hr(e,2),n=hr(e,4),s=hr(e,6),o=hr(e,8),a=hr(e,10),c=hr(e,12),l=hr(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|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=hr(e,16+2*u)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],m=o[4],x=o[5],S=o[6],E=o[7],A=o[8],R=o[9],O=hr(e,r+0),C=hr(e,r+2),N=hr(e,r+4),T=hr(e,r+6),U=hr(e,r+8),z=hr(e,r+10),W=hr(e,r+12),V=hr(e,r+14);let B=s[0]+(O&8191),K=s[1]+((O>>>13|C<<3)&8191),M=s[2]+((C>>>10|N<<6)&8191),v=s[3]+((N>>>7|T<<9)&8191),g=s[4]+((T>>>4|U<<12)&8191),h=s[5]+(U>>>1&8191),f=s[6]+((U>>>14|z<<2)&8191),p=s[7]+((z>>>11|W<<5)&8191),_=s[8]+((W>>>8|V<<8)&8191),$=s[9]+(V>>>5|n),y=0,d=y+B*a+K*(5*R)+M*(5*A)+v*(5*E)+g*(5*S);y=d>>>13,d&=8191,d+=h*(5*x)+f*(5*m)+p*(5*u)+_*(5*l)+$*(5*c),y+=d>>>13,d&=8191;let w=y+B*c+K*a+M*(5*R)+v*(5*A)+g*(5*E);y=w>>>13,w&=8191,w+=h*(5*S)+f*(5*x)+p*(5*m)+_*(5*u)+$*(5*l),y+=w>>>13,w&=8191;let b=y+B*l+K*c+M*a+v*(5*R)+g*(5*A);y=b>>>13,b&=8191,b+=h*(5*E)+f*(5*S)+p*(5*x)+_*(5*m)+$*(5*u),y+=b>>>13,b&=8191;let P=y+B*u+K*l+M*c+v*a+g*(5*R);y=P>>>13,P&=8191,P+=h*(5*A)+f*(5*E)+p*(5*S)+_*(5*x)+$*(5*m),y+=P>>>13,P&=8191;let q=y+B*m+K*u+M*l+v*c+g*a;y=q>>>13,q&=8191,q+=h*(5*R)+f*(5*A)+p*(5*E)+_*(5*S)+$*(5*x),y+=q>>>13,q&=8191;let I=y+B*x+K*m+M*u+v*l+g*c;y=I>>>13,I&=8191,I+=h*a+f*(5*R)+p*(5*A)+_*(5*E)+$*(5*S),y+=I>>>13,I&=8191;let F=y+B*S+K*x+M*m+v*u+g*l;y=F>>>13,F&=8191,F+=h*c+f*a+p*(5*R)+_*(5*A)+$*(5*E),y+=F>>>13,F&=8191;let j=y+B*E+K*S+M*x+v*m+g*u;y=j>>>13,j&=8191,j+=h*l+f*c+p*a+_*(5*R)+$*(5*A),y+=j>>>13,j&=8191;let k=y+B*A+K*E+M*S+v*x+g*m;y=k>>>13,k&=8191,k+=h*u+f*l+p*c+_*a+$*(5*R),y+=k>>>13,k&=8191;let H=y+B*R+K*A+M*E+v*S+g*x;y=H>>>13,H&=8191,H+=h*m+f*u+p*l+_*c+$*a,y+=H>>>13,H&=8191,y=(y<<2)+y|0,y=y+d|0,d=y&8191,y=y>>>13,w+=y,s[0]=d,s[1]=w,s[2]=b,s[3]=P,s[4]=q,s[5]=I,s[6]=F,s[7]=j,s[8]=k,s[9]=H}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;xo(i)}update(e){Gg(this);const{buffer:r,blockLen:i}=this;e=Qf(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(){xo(this.h,this.r,this.buffer,this.pad)}digestInto(e){Gg(this),cx(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 Ex(t){const e=(i,n)=>t(n).update(Qf(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const $x=Ex(t=>new xx(t));function Sx(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],m=e[1],x=e[2],S=e[3],E=e[4],A=e[5],R=e[6],O=e[7],C=n,N=r[0],T=r[1],U=r[2],z=o,W=a,V=c,B=l,K=u,M=m,v=x,g=S,h=E,f=A,p=R,_=O,$=C,y=N,d=T,w=U;for(let P=0;P<s;P+=2)z=z+K|0,$=Ge($^z,16),h=h+$|0,K=Ge(K^h,12),z=z+K|0,$=Ge($^z,8),h=h+$|0,K=Ge(K^h,7),W=W+M|0,y=Ge(y^W,16),f=f+y|0,M=Ge(M^f,12),W=W+M|0,y=Ge(y^W,8),f=f+y|0,M=Ge(M^f,7),V=V+v|0,d=Ge(d^V,16),p=p+d|0,v=Ge(v^p,12),V=V+v|0,d=Ge(d^V,8),p=p+d|0,v=Ge(v^p,7),B=B+g|0,w=Ge(w^B,16),_=_+w|0,g=Ge(g^_,12),B=B+g|0,w=Ge(w^B,8),_=_+w|0,g=Ge(g^_,7),z=z+M|0,w=Ge(w^z,16),p=p+w|0,M=Ge(M^p,12),z=z+M|0,w=Ge(w^z,8),p=p+w|0,M=Ge(M^p,7),W=W+v|0,$=Ge($^W,16),_=_+$|0,v=Ge(v^_,12),W=W+v|0,$=Ge($^W,8),_=_+$|0,v=Ge(v^_,7),V=V+g|0,y=Ge(y^V,16),h=h+y|0,g=Ge(g^h,12),V=V+g|0,y=Ge(y^V,8),h=h+y|0,g=Ge(g^h,7),B=B+K|0,d=Ge(d^B,16),f=f+d|0,K=Ge(K^f,12),B=B+K|0,d=Ge(d^B,8),f=f+d|0,K=Ge(K^f,7);let b=0;i[b++]=o+z|0,i[b++]=a+W|0,i[b++]=c+V|0,i[b++]=l+B|0,i[b++]=u+K|0,i[b++]=m+M|0,i[b++]=x+v|0,i[b++]=S+g|0,i[b++]=E+h|0,i[b++]=A+f|0,i[b++]=R+p|0,i[b++]=O+_|0,i[b++]=C+$|0,i[b++]=N+y|0,i[b++]=T+d|0,i[b++]=U+w|0}const Ix=_x(Sx,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Ax=new Uint8Array(16),tv=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(Ax.subarray(r))},Mx=new Uint8Array(32);function rv(t,e,r,i,n){const s=t(e,r,Mx),o=$x.create(s);n&&tv(o,n),tv(o,i);const a=new Uint8Array(16),c=lx(a);Yg(c,0,BigInt(n?n.length:0),!0),Yg(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return xo(s,a),l}const Px=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=Zg(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=rv(t,e,r,a,i);return s.set(c,o),xo(c),s},decrypt(n,s){s=Zg(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=rv(t,e,r,o,i);if(!ux(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),xo(c),s}}),iv=dx({blockSize:64,nonceLength:12,tagLength:16},Px(Ix));class nv extends Gf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Vf(e);const i=_o(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 yo(this),this.iHash.update(e),this}digestInto(e){yo(this),fl(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 ru=(t,e,r)=>new nv(t,e).update(r).digest();ru.create=(t,e)=>new nv(t,e);function Ox(t,e,r){return Vf(t),r===void 0&&(r=new Uint8Array(t.outputLen)),ru(t,_o(r),_o(e))}const iu=new Uint8Array([0]),sv=new Uint8Array;function Cx(t,e,r,i=32){if(Vf(t),Da(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=sv);const s=new Uint8Array(n*t.outputLen),o=ru.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<n;l++)iu[0]=l+1,a.update(l===0?sv:c).update(r).update(iu).digestInto(c),s.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),iu.fill(0),s.slice(0,i)}const Dx=(t,e,r,i,n)=>Cx(t,Ox(t,e,r),i,n);function Rx(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}function Nx(t,e,r){return t&e^~t&r}function Tx(t,e,r){return t&e^t&r^e&r}class Fx extends Gf{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=Kf(this.buffer)}update(e){yo(this);const{view:r,buffer:i,blockLen:n}=this;e=_o(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=Kf(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){yo(this),Pg(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 m=o;m<n;m++)r[m]=0;Rx(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Kf(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)a.setUint32(4*m,u[m],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 Lx=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]),Kn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Gn=new Uint32Array(64);class Bx extends Fx{constructor(){super(64,32,8,!1),this.A=Kn[0]|0,this.B=Kn[1]|0,this.C=Kn[2]|0,this.D=Kn[3]|0,this.E=Kn[4]|0,this.F=Kn[5]|0,this.G=Kn[6]|0,this.H=Kn[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 m=0;m<16;m++,r+=4)Gn[m]=e.getUint32(r,!1);for(let m=16;m<64;m++){const x=Gn[m-15],S=Gn[m-2],E=Hi(x,7)^Hi(x,18)^x>>>3,A=Hi(S,17)^Hi(S,19)^S>>>10;Gn[m]=A+Gn[m-7]+E+Gn[m-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let m=0;m<64;m++){const x=Hi(a,6)^Hi(a,11)^Hi(a,25),S=u+x+Nx(a,c,l)+Lx[m]+Gn[m]|0,E=(Hi(i,2)^Hi(i,13)^Hi(i,22))+Tx(i,n,s)|0;u=l,l=c,c=a,a=o+S|0,o=s,s=n,n=i,i=S+E|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,l=l+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,l,u)}roundClean(){Gn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const vl=Rg(()=>new Bx);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ov=BigInt(0);function nu(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function av(t){if(!nu(t))throw new Error("Uint8Array expected")}const Ux=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function qx(t){av(t);let e="";for(let r=0;r<t.length;r++)e+=Ux[t[r]];return e}function jx(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ov:BigInt("0x"+t)}const dn={_0:48,_9:57,A:65,F:70,a:97,f:102};function cv(t){if(t>=dn._0&&t<=dn._9)return t-dn._0;if(t>=dn.A&&t<=dn.F)return t-(dn.A-10);if(t>=dn.a&&t<=dn.f)return t-(dn.a-10)}function lv(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=cv(t.charCodeAt(s)),a=cv(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 hv(t){return av(t),jx(qx(Uint8Array.from(t).reverse()))}function kx(t,e){return lv(t.toString(16).padStart(e*2,"0"))}function zx(t,e){return kx(t,e).reverse()}function fv(t,e,r){let i;if(typeof e=="string")try{i=lv(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(nu(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}const su=t=>typeof t=="bigint"&&ov<=t;function Hx(t,e,r){return su(t)&&su(e)&&su(r)&&e<=t&&t<r}function uv(t,e,r,i){if(!Hx(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const Wx={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"||nu(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 Vx(t,e,r={}){const i=(n,s,o)=>{const a=Wx[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 Eo=BigInt(0),ml=BigInt(1);function dv(t,e){const r=t%e;return r>=Eo?r:e+r}function Kx(t,e,r){if(e<Eo)throw new Error("invalid exponent, negatives unsupported");if(r<=Eo)throw new Error("invalid modulus");if(r===ml)return Eo;let i=ml;for(;e>Eo;)e&ml&&(i=i*t%r),t=t*t%r,e>>=ml;return i}function Ai(t,e,r){let i=t;for(;e-- >Eo;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const $o=BigInt(0),ou=BigInt(1);function Gx(t){return Vx(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze(Q9({},t))}function Jx(t){const e=Gx(t),{P:r}=e,i=C=>dv(C,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(C=>C),c=e.powPminus2||(C=>Kx(C,r-BigInt(2),r));function l(C,N,T){const U=i(C*(N-T));return N=i(N-U),T=i(T+U),[N,T]}const u=(e.a-BigInt(2))/BigInt(4);function m(C,N){uv("u",C,$o,r),uv("scalar",N,$o,r);const T=N,U=C;let z=ou,W=$o,V=C,B=ou,K=$o,M;for(let g=BigInt(n-1);g>=$o;g--){const h=T>>g&ou;K^=h,M=l(K,z,V),z=M[0],V=M[1],M=l(K,W,B),W=M[0],B=M[1],K=h;const f=z+W,p=i(f*f),_=z-W,$=i(_*_),y=p-$,d=V+B,w=V-B,b=i(w*f),P=i(d*_),q=b+P,I=b-P;V=i(q*q),B=i(U*i(I*I)),z=i(p*$),W=i(y*(p+i(u*y)))}M=l(K,z,V),z=M[0],V=M[1],M=l(K,W,B),W=M[0],B=M[1];const v=c(W);return i(z*v)}function x(C){return zx(i(C),s)}function S(C){const N=fv("u coordinate",C,s);return o===32&&(N[31]&=127),hv(N)}function E(C){const N=fv("scalar",C),T=N.length;if(T!==s&&T!==o){let U=""+s+" or "+o;throw new Error("invalid scalar, expected "+U+" bytes, got "+T)}return hv(a(N))}function A(C,N){const T=S(N),U=E(C),z=m(T,U);if(z===$o)throw new Error("invalid private or public key received");return x(z)}const R=x(e.Gu);function O(C){return A(C,R)}return{scalarMult:A,scalarMultBase:O,getSharedSecret:(C,N)=>A(C,N),getPublicKey:C=>O(C),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:R}}const au=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Zx=BigInt(1),pv=BigInt(2),Yx=BigInt(3),Xx=BigInt(5);BigInt(8);function Qx(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=au,o=t*t%s*t%s,a=Ai(o,pv,s)*o%s,c=Ai(a,Zx,s)*t%s,l=Ai(c,Xx,s)*c%s,u=Ai(l,e,s)*l%s,m=Ai(u,r,s)*u%s,x=Ai(m,i,s)*m%s,S=Ai(x,n,s)*x%s,E=Ai(S,n,s)*x%s,A=Ai(E,e,s)*l%s;return{pow_p_5_8:Ai(A,pv,s)*t%s,b2:o}}function eE(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const cu=Jx({P:au,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=au,{pow_p_5_8:r,b2:i}=Qx(t);return dv(Ai(r,Yx,e)*i,e)},adjustScalarBytes:eE,randomBytes:Ra}),gv="base10",mr="base16",Jn="base64pad",Fa="base64url",La="utf8",vv=0,pn=1,Ba=2,tE=0,mv=1,Ua=12,lu=32;function rE(){const t=cu.utils.randomPrivateKey(),e=cu.getPublicKey(t);return{privateKey:$r(t,mr),publicKey:$r(e,mr)}}function hu(){const t=Ra(lu);return $r(t,mr)}function iE(t,e){const r=cu.getSharedSecret(ai(t,mr),ai(e,mr)),i=Dx(vl,r,void 0,void 0,lu);return $r(i,mr)}function bl(t){const e=vl(ai(t,mr));return $r(e,mr)}function gn(t){const e=vl(ai(t,La));return $r(e,mr)}function bv(t){return ai(`${t}`,gv)}function Is(t){return Number($r(t,gv))}function nE(t){const e=bv(typeof t.type<"u"?t.type:vv);if(Is(e)===pn&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ai(t.senderPublicKey,mr):void 0,i=typeof t.iv<"u"?ai(t.iv,mr):Ra(Ua),n=ai(t.symKey,mr),s=iv(n,i).encrypt(ai(t.message,La));return yv({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function sE(t){const e=ai(t.symKey,mr),{sealed:r,iv:i}=qa(t),n=iv(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return $r(n,La)}function oE(t,e){const r=bv(Ba),i=Ra(Ua),n=ai(t,La);return yv({type:r,sealed:n,iv:i,encoding:e})}function aE(t,e){const{sealed:r}=qa({encoded:t,encoding:e});return $r(r,La)}function yv(t){const{encoding:e=Jn}=t;if(Is(t.type)===Ba)return $r(Of([t.type,t.sealed]),e);if(Is(t.type)===pn){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return $r(Of([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return $r(Of([t.type,t.iv,t.sealed]),e)}function qa(t){const{encoded:e,encoding:r=Jn}=t,i=ai(e,r),n=i.slice(tE,mv),s=mv;if(Is(n)===pn){const l=s+lu,u=l+Ua,m=i.slice(s,l),x=i.slice(l,u),S=i.slice(u);return{type:n,sealed:S,iv:x,senderPublicKey:m}}if(Is(n)===Ba){const l=i.slice(s),u=Ra(Ua);return{type:n,sealed:l,iv:u}}const o=s+Ua,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function cE(t,e){const r=qa({encoded:t,encoding:e?.encoding});return wv({type:Is(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?$r(r.senderPublicKey,mr):void 0,receiverPublicKey:e?.receiverPublicKey})}function wv(t){const e=t?.type||vv;if(e===pn){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 _v(t){return t.type===pn&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function xv(t){return t.type===Ba}function lE(t){return new tg.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function hE(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function fE(t){return Buffer.from(hE(t),"base64")}function uE(t,e){const[r,i,n]=t.split("."),s=fE(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,l=vl(c),u=lE(e),m=$r(l,mr);if(!u.verify(m,{r:o,s:a}))throw new Error("Invalid signature");return Pf(t).payload}const dE="irn";function yl(t){return t?.relay||{protocol:dE}}function ja(t){const e=J9[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function pE(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 Ev(t){if(!t.includes("wc:")){const l=Mg(t);l!=null&&l.includes("wc:")&&(t=l)}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((l,u)=>{a[u]=l});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:pE(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function gE(t){return t.startsWith("//")?t.substring(2):t}function vE(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=r+e+n;t[n]&&(i[s]=t[n])}),i}function $v(t){const e=new URLSearchParams,r=vE(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 wl(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function So(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function mE(t){const e=[];return Object.values(t).forEach(r=>{e.push(...So(r.accounts))}),e}function bE(t,e){const r=[];return Object.values(t).forEach(i=>{So(i.accounts).includes(e)&&r.push(...i.methods)}),r}function yE(t,e){const r=[];return Object.values(t).forEach(i=>{So(i.accounts).includes(e)&&r.push(...i.events)}),r}function fu(t){return t.includes(":")}function ka(t){return fu(t)?t.split(":")[0]:t}function wE(t){const e={};return t?.forEach(r=>{const[i,n]=r.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(r),e[i].chains.push(`${i}:${n}`)}),e}function Sv(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=wE(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=hl(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const _E={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 ee(t,e){const{message:r,code:i}=xE[t];return{message:e?`${r} ${e}`:r,code:i}}function wt(t,e){const{message:r,code:i}=_E[t];return{message:e?`${r} ${e}`:r,code:i}}function Wi(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function za(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Sr(t){return typeof t>"u"}function Ut(t,e){return e&&Sr(t)?!0:typeof t=="string"&&!!t.trim().length}function uu(t,e){return e&&Sr(t)?!0:typeof t=="number"&&!isNaN(t)}function EE(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return Es(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=So(a),m=r[o];(!Es(bg(o,m),u)||!Es(m.methods,c)||!Es(m.events,l))&&(s=!1)}),s):!1}function _l(t){return Ut(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function $E(t){if(Ut(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&_l(r)}}return!1}function SE(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(Ut(t,!1)){if(e(t))return!0;const r=Mg(t);return e(r)}}catch{}return!1}function IE(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function AE(t){return t?.topic}function ME(t,e){let r=null;return Ut(t?.publicKey,!1)||(r=ee("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Iv(t){let e=!0;return Wi(t)?t.length&&(e=t.every(r=>Ut(r,!1))):e=!1,e}function PE(t,e,r){let i=null;return Wi(e)&&e.length?e.forEach(n=>{i||_l(n)||(i=wt("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):_l(t)||(i=wt("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 OE(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=PE(n,bg(n,s),`${e} ${r}`);o&&(i=o)}),i}function CE(t,e){let r=null;return Wi(t)?t.forEach(i=>{r||$E(i)||(r=wt("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=wt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function DE(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=CE(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function RE(t,e){let r=null;return Iv(t?.methods)?Iv(t?.events)||(r=wt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=wt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Av(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=RE(i,`${e}, namespace`);n&&(r=n)}),r}function NE(t,e,r){let i=null;if(t&&za(t)){const n=Av(t,e);n&&(i=n);const s=OE(t,e,r);s&&(i=s)}else i=ee("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function du(t,e){let r=null;if(t&&za(t)){const i=Av(t,e);i&&(r=i);const n=DE(t,e);n&&(r=n)}else r=ee("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Mv(t){return Ut(t.protocol,!0)}function TE(t,e){let r=!1;return e&&!t?r=!0:t&&Wi(t)&&t.length&&t.forEach(i=>{r=Mv(i)}),r}function FE(t){return typeof t=="number"}function Rr(t){return typeof t<"u"&&typeof t!==null}function LE(t){return!(!t||typeof t!="object"||!t.code||!uu(t.code,!1)||!t.message||!Ut(t.message,!1))}function BE(t){return!(Sr(t)||!Ut(t.method,!1))}function UE(t){return!(Sr(t)||Sr(t.result)&&Sr(t.error)||!uu(t.id,!1)||!Ut(t.jsonrpc,!1))}function qE(t){return!(Sr(t)||!Ut(t.name,!1))}function Pv(t,e){return!(!_l(e)||!mE(t).includes(e))}function jE(t,e,r){return Ut(r,!1)?bE(t,e).includes(r):!1}function kE(t,e,r){return Ut(r,!1)?yE(t,e).includes(r):!1}function Ov(t,e,r){let i=null;const n=zE(t),s=HE(e),o=Object.keys(n),a=Object.keys(s),c=Cv(Object.keys(t)),l=Cv(Object.keys(e)),u=c.filter(m=>!l.includes(m));return u.length&&(i=ee("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
14
|
+
***************************************************************************** */var ku=function(t,e){return ku=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])},ku(t,e)};function l3(t,e){ku(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Hu=function(){return Hu=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},Hu.apply(this,arguments)};function u3(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 h3(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 d3(t,e){return function(r,i){e(r,i,t)}}function f3(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function p3(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(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(t,e||[])).next())})}function g3(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(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function b3(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function m3(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Wu(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 sp(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 v3(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(sp(arguments[e]));return t}function y3(){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 Jo(t){return this instanceof Jo?(this.v=t,this):new Jo(t)}function w3(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(p){i[p]&&(n[p]=function(y){return new Promise(function(m,_){s.push([p,y,m,_])>1||a(p,y)})})}function a(p,y){try{c(i[p](y))}catch(m){d(s[0][3],m)}}function c(p){p.value instanceof Jo?Promise.resolve(p.value.v).then(l,u):d(s[0][2],p)}function l(p){a("next",p)}function u(p){a("throw",p)}function d(p,y){p(y),s.shift(),s.length&&a(s[0][0],s[0][1])}}function _3(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:Jo(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function x3(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 Wu=="function"?Wu(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(l){s({value:l,done:a})},o)}}function E3(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $3(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 I3(t){return t&&t.__esModule?t:{default:t}}function S3(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function A3(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var P3=Object.freeze({__proto__:null,__extends:l3,get __assign(){return Hu},__rest:u3,__decorate:h3,__param:d3,__metadata:f3,__awaiter:p3,__generator:g3,__createBinding:b3,__exportStar:m3,__values:Wu,__read:sp,__spread:v3,__spreadArrays:y3,__await:Jo,__asyncGenerator:w3,__asyncDelegator:_3,__asyncValues:x3,__makeTemplateObject:E3,__importStar:$3,__importDefault:I3,__classPrivateFieldGet:S3,__classPrivateFieldSet:A3}),Cc=zu(P3),Vu={},Qo={},op;function O3(){if(op)return Qo;op=1,Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Qo.delay=t,Qo}var Mn={},Ku={},Tn={},ap;function C3(){return ap||(ap=1,Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.ONE_THOUSAND=Tn.ONE_HUNDRED=void 0,Tn.ONE_HUNDRED=100,Tn.ONE_THOUSAND=1e3),Tn}var Gu={},cp;function D3(){return cp||(cp=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}(Gu)),Gu}var lp;function up(){return lp||(lp=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Cc;e.__exportStar(C3(),t),e.__exportStar(D3(),t)}(Ku)),Ku}var hp;function M3(){if(hp)return Mn;hp=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.fromMiliseconds=Mn.toMiliseconds=void 0;const t=up();function e(i){return i*t.ONE_THOUSAND}Mn.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Mn.fromMiliseconds=r,Mn}var dp;function T3(){return dp||(dp=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Cc;e.__exportStar(O3(),t),e.__exportStar(M3(),t)}(Vu)),Vu}var Ss={},fp;function R3(){if(fp)return Ss;fp=1,Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.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 Ss.Watch=t,Ss.default=t,Ss}var Zu={},Xo={},pp;function N3(){if(pp)return Xo;pp=1,Object.defineProperty(Xo,"__esModule",{value:!0}),Xo.IWatch=void 0;class t{}return Xo.IWatch=t,Xo}var gp;function B3(){return gp||(gp=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Cc.__exportStar(N3(),t)}(Zu)),Zu}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Cc;e.__exportStar(T3(),t),e.__exportStar(R3(),t),e.__exportStar(B3(),t),e.__exportStar(up(),t)})(V);var Pe={};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.getLocalStorage=Pe.getLocalStorageOrThrow=Pe.getCrypto=Pe.getCryptoOrThrow=bp=Pe.getLocation=Pe.getLocationOrThrow=Yu=Pe.getNavigator=Pe.getNavigatorOrThrow=ea=Pe.getDocument=Pe.getDocumentOrThrow=Pe.getFromWindowOrThrow=Pe.getFromWindow=void 0;function Rn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Pe.getFromWindow=Rn;function As(t){const e=Rn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Pe.getFromWindowOrThrow=As;function L3(){return As("document")}Pe.getDocumentOrThrow=L3;function F3(){return Rn("document")}var ea=Pe.getDocument=F3;function U3(){return As("navigator")}Pe.getNavigatorOrThrow=U3;function j3(){return Rn("navigator")}var Yu=Pe.getNavigator=j3;function q3(){return As("location")}Pe.getLocationOrThrow=q3;function z3(){return Rn("location")}var bp=Pe.getLocation=z3;function k3(){return As("crypto")}Pe.getCryptoOrThrow=k3;function H3(){return Rn("crypto")}Pe.getCrypto=H3;function W3(){return As("localStorage")}Pe.getLocalStorageOrThrow=W3;function V3(){return Rn("localStorage")}Pe.getLocalStorage=V3;var Ju={};Object.defineProperty(Ju,"__esModule",{value:!0});var mp=Ju.getWindowMetadata=void 0;const vp=Pe;function K3(){let t,e;try{t=vp.getDocumentOrThrow(),e=vp.getLocationOrThrow()}catch{return null}function r(){const d=t.getElementsByTagName("link"),p=[];for(let y=0;y<d.length;y++){const m=d[y],_=m.getAttribute("rel");if(_&&_.toLowerCase().indexOf("icon")>-1){const S=m.getAttribute("href");if(S)if(S.toLowerCase().indexOf("https:")===-1&&S.toLowerCase().indexOf("http:")===-1&&S.indexOf("//")!==0){let E=e.protocol+"//"+e.host;if(S.indexOf("/")===0)E+=S;else{const P=e.pathname.split("/");P.pop();const C=P.join("/");E+=C+"/"+S}p.push(E)}else if(S.indexOf("//")===0){const E=e.protocol+S;p.push(E)}else p.push(S)}}return p}function i(...d){const p=t.getElementsByTagName("meta");for(let y=0;y<p.length;y++){const m=p[y],_=["itemprop","property","name"].map(S=>m.getAttribute(S)).filter(S=>S?d.includes(S):!1);if(_.length&&_){const S=m.getAttribute("content");if(S)return S}}return""}function n(){let d=i("name","og:site_name","og:title","twitter:title");return d||(d=t.title),d}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,l=r();return{description:a,url:c,icons:l,name:o}}mp=Ju.getWindowMetadata=K3;function ta(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function yp(t){return ta(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const wp="2.23.2";let Qu={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${wp}`};class Nn extends Error{constructor(e,r={}){const i=r.cause instanceof Nn?r.cause.details:r.cause?.message?r.cause.message:r.details,n=r.cause instanceof Nn&&r.cause.docsPath||r.docsPath,s=Qu.getDocsUrl?.({...r,docsPath:n}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...i?[`Details: ${i}`]:[],...Qu.version?[`Version: ${Qu.version}`]:[]].join(`
|
|
15
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=wp}walk(e){return _p(this,e)}}function _p(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?_p(t.cause,e):e?null:t}class xp extends Nn{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function Ps(t,{dir:e,size:r=32}={}){return typeof t=="string"?G3(t,{dir:e,size:r}):Z3(t,{dir:e,size:r})}function G3(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new xp({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function Z3(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new xp({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let n=0;n<r;n++){const s=e==="right";i[s?n:r-n-1]=t[s?n:t.length-n-1]}return i}class Y3 extends Nn{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class J3 extends Nn{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Os(t,{size:e}){if(yp(t)>e)throw new J3({givenSize:yp(t),maxSize:e})}function Xu(t,e={}){const{signed:r}=e;e.size&&Os(t,{size:e.size});const i=BigInt(t);if(!r)return i;const n=(t.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return i<=s?i:i-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function Q3(t,e={}){return Number(Xu(t,e))}const X3=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function eh(t,e={}){return typeof t=="number"||typeof t=="bigint"?$p(t,e):typeof t=="string"?r4(t,e):typeof t=="boolean"?e4(t,e):Ep(t,e)}function e4(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Os(r,{size:e.size}),Ps(r,{size:e.size})):r}function Ep(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=X3[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(Os(i,{size:e.size}),Ps(i,{dir:"right",size:e.size})):i}function $p(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const c=typeof t=="bigint"?"n":"";throw new Y3({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:i,value:`${t}${c}`})}const a=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?Ps(a,{size:i}):a}const t4=new TextEncoder;function r4(t,e={}){const r=t4.encode(t);return Ep(r,e)}const i4=new TextEncoder;function n4(t,e={}){return typeof t=="number"||typeof t=="bigint"?o4(t,e):typeof t=="boolean"?s4(t,e):ta(t)?Sp(t,e):Ap(t,e)}function s4(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(Os(r,{size:e.size}),Ps(r,{size:e.size})):r}const Pi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ip(t){if(t>=Pi.zero&&t<=Pi.nine)return t-Pi.zero;if(t>=Pi.A&&t<=Pi.F)return t-(Pi.A-10);if(t>=Pi.a&&t<=Pi.f)return t-(Pi.a-10)}function Sp(t,e={}){let r=t;e.size&&(Os(r,{size:e.size}),r=Ps(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const n=i.length/2,s=new Uint8Array(n);for(let o=0,a=0;o<n;o++){const c=Ip(i.charCodeAt(a++)),l=Ip(i.charCodeAt(a++));if(c===void 0||l===void 0)throw new Nn(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);s[o]=c*16+l}return s}function o4(t,e){const r=$p(t,e);return Sp(r)}function Ap(t,e={}){const r=i4.encode(t);return typeof e.size=="number"?(Os(r,{size:e.size}),Ps(r,{dir:"right",size:e.size})):r}function Dc(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function a4(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ra(t,...e){if(!a4(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 c4(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Dc(t.outputLen),Dc(t.blockLen)}function Cs(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 Pp(t,e){ra(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Mc=BigInt(2**32-1),Op=BigInt(32);function l4(t,e=!1){return e?{h:Number(t&Mc),l:Number(t>>Op&Mc)}:{h:Number(t>>Op&Mc)|0,l:Number(t&Mc)|0}}function u4(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}=l4(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const h4=(t,e,r)=>t<<r|e>>>32-r,d4=(t,e,r)=>e<<r|t>>>32-r,f4=(t,e,r)=>e<<r-32|t>>>64-r,p4=(t,e,r)=>t<<r-32|e>>>64-r,Ds=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function g4(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function th(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Xr(t,e){return t<<32-e|t>>>e}const Cp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function b4(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Dp(t){for(let e=0;e<t.length;e++)t[e]=b4(t[e])}function m4(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Tc(t){return typeof t=="string"&&(t=m4(t)),ra(t),t}function v4(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];ra(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}class rh{clone(){return this._cloneInto()}}function Mp(t){const e=i=>t().update(Tc(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Tp(t=32){if(Ds&&typeof Ds.getRandomValues=="function")return Ds.getRandomValues(new Uint8Array(t));if(Ds&&typeof Ds.randomBytes=="function")return Ds.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Rp=[],Np=[],Bp=[],y4=BigInt(0),ia=BigInt(1),w4=BigInt(2),_4=BigInt(7),x4=BigInt(256),E4=BigInt(113);for(let t=0,e=ia,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Rp.push(2*(5*i+r)),Np.push((t+1)*(t+2)/2%64);let n=y4;for(let s=0;s<7;s++)e=(e<<ia^(e>>_4)*E4)%x4,e&w4&&(n^=ia<<(ia<<BigInt(s))-ia);Bp.push(n)}const[$4,I4]=u4(Bp,!0),Lp=(t,e,r)=>r>32?f4(t,e,r):h4(t,e,r),Fp=(t,e,r)=>r>32?p4(t,e,r):d4(t,e,r);function S4(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,l=r[c],u=r[c+1],d=Lp(l,u,1)^r[a],p=Fp(l,u,1)^r[a+1];for(let y=0;y<50;y+=10)t[o+y]^=d,t[o+y+1]^=p}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Np[o],c=Lp(n,s,a),l=Fp(n,s,a),u=Rp[o];n=t[u],s=t[u+1],t[u]=c,t[u+1]=l}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]^=$4[i],t[1]^=I4[i]}r.fill(0)}class ih extends rh{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,Dc(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=g4(this.state)}keccak(){Cp||Dp(this.state32),S4(this.state32,this.rounds),Cp||Dp(this.state32),this.posOut=0,this.pos=0}update(e){Cs(this);const{blockLen:r,state:i}=this;e=Tc(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)!==0&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Cs(this,!1),ra(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 Dc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Pp(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 ih(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 Up=((t,e,r)=>Mp(()=>new ih(e,t,r)))(1,136,256/8);function jp(t,e){const r=e||"hex",i=Up(ta(t,{strict:!1})?n4(t):t);return r==="bytes"?i:eh(i)}class qp extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const nh=new qp(8192);function A4(t,e){if(nh.has(`${t}.${e}`))return nh.get(`${t}.${e}`);const r=e?`${e}${t.toLowerCase()}`:t.substring(2).toLowerCase(),i=jp(Ap(r),"bytes"),n=(e?r.substring(`${e}0x`.length):r).split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&n[o]&&(n[o]=n[o].toUpperCase()),(i[o>>1]&15)>=8&&n[o+1]&&(n[o+1]=n[o+1].toUpperCase());const s=`0x${n.join("")}`;return nh.set(`${t}.${e}`,s),s}function P4(t){const e=jp(`0x${t.substring(4)}`).substring(26);return A4(`0x${e}`)}async function O4({hash:t,signature:e}){const r=ta(t)?t:eh(t),{secp256k1:i}=await Promise.resolve().then(function(){return l6});return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:d,yParity:p}=e,y=Number(p??d),m=zp(y);return new i.Signature(Xu(l),Xu(u)).addRecoveryBit(m)}const o=ta(e)?e:eh(e),a=Q3(`0x${o.slice(130)}`),c=zp(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function zp(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function C4({hash:t,signature:e}){return P4(await O4({hash:t,signature:e}))}function D4(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}function M4(t,e,r){return t&e^~t&r}function T4(t,e,r){return t&e^t&r^e&r}class R4 extends rh{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=th(this.buffer)}update(e){Cs(this);const{view:r,buffer:i,blockLen:n}=this;e=Tc(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=th(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){Cs(this),Pp(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 d=o;d<n;d++)r[d]=0;D4(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=th(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],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 N4=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]),Gi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zi=new Uint32Array(64);class B4 extends R4{constructor(){super(64,32,8,!1),this.A=Gi[0]|0,this.B=Gi[1]|0,this.C=Gi[2]|0,this.D=Gi[3]|0,this.E=Gi[4]|0,this.F=Gi[5]|0,this.G=Gi[6]|0,this.H=Gi[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 d=0;d<16;d++,r+=4)Zi[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){const p=Zi[d-15],y=Zi[d-2],m=Xr(p,7)^Xr(p,18)^p>>>3,_=Xr(y,17)^Xr(y,19)^y>>>10;Zi[d]=_+Zi[d-7]+m+Zi[d-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const p=Xr(a,6)^Xr(a,11)^Xr(a,25),y=u+p+M4(a,c,l)+N4[d]+Zi[d]|0,_=(Xr(i,2)^Xr(i,13)^Xr(i,22))+T4(i,n,s)|0;u=l,l=c,c=a,a=o+y|0,o=s,s=n,n=i,i=y+_|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,l=l+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,l,u)}roundClean(){Zi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Rc=Mp(()=>new B4);new qp(128);const L4=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),kp=new Uint8Array(new Array(16).fill(0).map((t,e)=>e)),F4=kp.map(t=>(9*t+5)%16);let U4=[kp],j4=[F4];for(let t=0;t<4;t++)for(let e of[U4,j4])e.push(e[t].map(r=>L4[r]));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nc=BigInt(0),Bc=BigInt(1),q4=BigInt(2);function Bn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ei(t){if(!Bn(t))throw new Error("Uint8Array expected")}function Ms(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const z4=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ts(t){ei(t);let e="";for(let r=0;r<t.length;r++)e+=z4[t[r]];return e}function Rs(t){const e=t.toString(16);return e.length&1?"0"+e:e}function sh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Nc:BigInt("0x"+t)}const Oi={_0:48,_9:57,A:65,F:70,a:97,f:102};function Hp(t){if(t>=Oi._0&&t<=Oi._9)return t-Oi._0;if(t>=Oi.A&&t<=Oi.F)return t-(Oi.A-10);if(t>=Oi.a&&t<=Oi.f)return t-(Oi.a-10)}function Ns(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=Hp(t.charCodeAt(s)),a=Hp(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 ti(t){return sh(Ts(t))}function oh(t){return ei(t),sh(Ts(Uint8Array.from(t).reverse()))}function Yi(t,e){return Ns(t.toString(16).padStart(e*2,"0"))}function ah(t,e){return Yi(t,e).reverse()}function k4(t){return Ns(Rs(t))}function Vt(t,e,r){let i;if(typeof e=="string")try{i=Ns(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Bn(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 pr(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];ei(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 H4(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 Lc(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const ch=t=>typeof t=="bigint"&&Nc<=t;function Bs(t,e,r){return ch(t)&&ch(e)&&ch(r)&&e<=t&&t<r}function Ji(t,e,r,i){if(!Bs(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Wp(t){let e;for(e=0;t>Nc;t>>=Bc,e+=1);return e}function W4(t,e){return t>>BigInt(e)&Bc}function V4(t,e,r){return t|(r?Bc:Nc)<<BigInt(e)}const lh=t=>(q4<<BigInt(t-1))-Bc,uh=t=>new Uint8Array(t),Vp=t=>Uint8Array.from(t);function Kp(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=uh(t),n=uh(t),s=0;const o=()=>{i.fill(1),n.fill(0),s=0},a=(...d)=>r(n,i,...d),c=(d=uh())=>{n=a(Vp([0]),d),i=a(),d.length!==0&&(n=a(Vp([1]),d),i=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const p=[];for(;d<e;){i=a();const y=i.slice();p.push(y),d+=i.length}return pr(...p)};return(d,p)=>{o(),c(d);let y;for(;!(y=p(l()));)c();return o(),y}}const K4={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"||Bn(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 Ls(t,e,r={}){const i=(n,s,o)=>{const a=K4[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 G4=()=>{throw new Error("not implemented")};function hh(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 Z4=Object.freeze({__proto__:null,isBytes:Bn,abytes:ei,abool:Ms,bytesToHex:Ts,numberToHexUnpadded:Rs,hexToNumber:sh,hexToBytes:Ns,bytesToNumberBE:ti,bytesToNumberLE:oh,numberToBytesBE:Yi,numberToBytesLE:ah,numberToVarBytesBE:k4,ensureBytes:Vt,concatBytes:pr,equalBytes:H4,utf8ToBytes:Lc,inRange:Bs,aInRange:Ji,bitLen:Wp,bitGet:W4,bitSet:V4,bitMask:lh,createHmacDrbg:Kp,validateObject:Ls,notImplemented:G4,memoized:hh});const Y4="0.1.1";function J4(){return Y4}class Qt extends Error{constructor(e,r={}){const i=(()=>{if(r.cause instanceof Qt){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause?.message?r.cause.message:r.details})(),n=r.cause instanceof Qt&&r.cause.docsPath||r.docsPath,o=`https://oxlib.sh${n??""}`,a=[e||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...i||n?["",i?`Details: ${i}`:void 0,n?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
16
|
+
`);super(a,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${J4()}`}),this.cause=r.cause,this.details=i,this.docs=o,this.docsPath=n,this.shortMessage=e}walk(e){return Gp(this,e)}}function Gp(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Gp(t.cause,e):e?null:t}function Q4(t,e){if(Jp(t)>e)throw new o5({givenSize:Jp(t),maxSize:e})}const Ci={zero:48,nine:57,A:65,F:70,a:97,f:102};function Zp(t){if(t>=Ci.zero&&t<=Ci.nine)return t-Ci.zero;if(t>=Ci.A&&t<=Ci.F)return t-(Ci.A-10);if(t>=Ci.a&&t<=Ci.f)return t-(Ci.a-10)}function X4(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;if(t.length>i)throw new a5({size:t.length,targetSize:i,type:"Bytes"});const n=new Uint8Array(i);for(let s=0;s<i;s++){const o=r==="right";n[o?s:i-s-1]=t[o?s:t.length-s-1]}return n}function dh(t,e){if(ph(t)>e)throw new p5({givenSize:ph(t),maxSize:e})}function Yp(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;const n=t.replace("0x","");if(n.length>i*2)throw new g5({size:Math.ceil(n.length/2),targetSize:i,type:"Hex"});return`0x${n[r==="right"?"padEnd":"padStart"](i*2,"0")}`}const e5=new TextEncoder;function t5(t){return t instanceof Uint8Array?t:typeof t=="string"?i5(t):r5(t)}function r5(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function i5(t,e={}){const{size:r}=e;let i=t;r&&(dh(t,r),i=fh(t,r));let n=i.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,o=new Uint8Array(s);for(let a=0,c=0;a<s;a++){const l=Zp(n.charCodeAt(c++)),u=Zp(n.charCodeAt(c++));if(l===void 0||u===void 0)throw new Qt(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);o[a]=l*16+u}return o}function n5(t,e={}){const{size:r}=e,i=e5.encode(t);return typeof r=="number"?(Q4(i,r),s5(i,r)):i}function s5(t,e){return X4(t,{dir:"right",size:e})}function Jp(t){return t.length}class o5 extends Qt{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class a5 extends Qt{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const c5=new TextEncoder,l5=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Qp(...t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function u5(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(dh(r,e.size),Fc(r,e.size)):r}function Xp(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=l5[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(dh(i,e.size),fh(i,e.size)):i}function h5(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const l=typeof t=="bigint"?"n":"";throw new f5({max:s?`${s}${l}`:void 0,min:`${o}${l}`,signed:r,size:i,value:`${t}${l}`})}const c=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?Fc(c,i):c}function d5(t,e={}){return Xp(c5.encode(t),e)}function Fc(t,e){return Yp(t,{dir:"left",size:e})}function fh(t,e){return Yp(t,{dir:"right",size:e})}function ph(t){return Math.ceil((t.length-2)/2)}class f5 extends Qt{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number \`${s}\` is not in safe${n?` ${n*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${r}\` to \`${e}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class p5 extends Qt{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class g5 extends Qt{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function b5(t,e={}){const{as:r=typeof t=="string"?"Hex":"Bytes"}=e,i=Up(t5(t));return r==="Bytes"?i:Xp(i)}class m5 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const gh={checksum:new m5(8192)}.checksum,v5=/^0x[a-fA-F0-9]{40}$/;function e1(t,e={}){const{strict:r=!0}=e;if(!v5.test(t))throw new t1({address:t,cause:new w5});if(r){if(t.toLowerCase()===t)return;if(y5(t)!==t)throw new t1({address:t,cause:new _5})}}function y5(t){if(gh.has(t))return gh.get(t);e1(t,{strict:!1});const e=t.substring(2).toLowerCase(),r=b5(n5(e),{as:"Bytes"}),i=e.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const n=`0x${i.join("")}`;return gh.set(t,n),n}class t1 extends Qt{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class w5 extends Qt{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class _5 extends Qt{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const x5=/^(.*)\[([0-9]*)\]$/,E5=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,$5=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function bh(t,e){if(t.length!==e.length)throw new S5({expectedLength:t.length,givenLength:e.length});const r=[];for(let i=0;i<t.length;i++){const n=t[i],s=e[i];r.push(bh.encode(n,s))}return Qp(...r)}(function(t){function e(r,i,n=!1){if(r==="address"){const c=i;return e1(c),Fc(c.toLowerCase(),n?32:0)}if(r==="string")return d5(i);if(r==="bytes")return i;if(r==="bool")return Fc(u5(i),n?32:1);const s=r.match($5);if(s){const[c,l,u="256"]=s,d=Number.parseInt(u)/8;return h5(i,{size:n?32:d,signed:l==="int"})}const o=r.match(E5);if(o){const[c,l]=o;if(Number.parseInt(l)!==(i.length-2)/2)throw new I5({expectedSize:Number.parseInt(l),value:i});return fh(i,n?32:0)}const a=r.match(x5);if(a&&Array.isArray(i)){const[c,l]=a,u=[];for(let d=0;d<i.length;d++)u.push(e(l,i[d],!0));return u.length===0?"0x":Qp(...u)}throw new A5(r)}t.encode=e})(bh||(bh={}));class I5 extends Qt{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${ph(r)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class S5 extends Qt{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${r}`].join(`
|
|
17
|
+
`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class A5 extends Qt{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class r1 extends rh{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,c4(e);const i=Tc(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 Cs(this),this.iHash.update(e),this}digestInto(e){Cs(this),ra(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 i1=(t,e,r)=>new r1(t,e).update(r).digest();i1.create=(t,e)=>new r1(t,e);const It=BigInt(0),gt=BigInt(1),Ln=BigInt(2),P5=BigInt(3),mh=BigInt(4),n1=BigInt(5),s1=BigInt(8);function St(t,e){const r=t%e;return r>=It?r:e+r}function O5(t,e,r){if(e<It)throw new Error("invalid exponent, negatives unsupported");if(r<=It)throw new Error("invalid modulus");if(r===gt)return It;let i=gt;for(;e>It;)e>&&(i=i*t%r),t=t*t%r,e>>=gt;return i}function Ir(t,e,r){let i=t;for(;e-- >It;)i*=i,i%=r;return i}function vh(t,e){if(t===It)throw new Error("invert: expected non-zero number");if(e<=It)throw new Error("invert: expected positive modulus, got "+e);let r=St(t,e),i=e,n=It,s=gt;for(;r!==It;){const a=i/r,c=i%r,l=n-s*a;i=r,r=c,n=s,s=l}if(i!==gt)throw new Error("invert: does not exist");return St(n,e)}function C5(t){const e=(t-gt)/Ln;let r,i,n;for(r=t-gt,i=0;r%Ln===It;r/=Ln,i++);for(n=Ln;n<t&&O5(n,e,t)!==t-gt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+gt)/mh;return function(c,l){const u=c.pow(l,o);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}const s=(r+gt)/Ln;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=i,u=a.pow(a.mul(a.ONE,n),r),d=a.pow(c,s),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let y=1;for(let _=a.sqr(p);y<l&&!a.eql(_,a.ONE);y++)_=a.sqr(_);const m=a.pow(u,gt<<BigInt(l-y-1));u=a.sqr(m),d=a.mul(d,m),p=a.mul(p,u),l=y}return d}}function D5(t){if(t%mh===P5){const e=(t+gt)/mh;return function(i,n){const s=i.pow(n,e);if(!i.eql(i.sqr(s),n))throw new Error("Cannot find square root");return s}}if(t%s1===n1){const e=(t-n1)/s1;return function(i,n){const s=i.mul(n,Ln),o=i.pow(s,e),a=i.mul(n,o),c=i.mul(i.mul(a,Ln),o),l=i.mul(a,i.sub(c,i.ONE));if(!i.eql(i.sqr(l),n))throw new Error("Cannot find square root");return l}}return C5(t)}const M5=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function o1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=M5.reduce((i,n)=>(i[n]="function",i),e);return Ls(t,r)}function T5(t,e,r){if(r<It)throw new Error("invalid exponent, negatives unsupported");if(r===It)return t.ONE;if(r===gt)return e;let i=t.ONE,n=e;for(;r>It;)r>&&(i=t.mul(i,n)),n=t.sqr(n),r>>=gt;return i}function R5(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 a1(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function c1(t,e,r=!1,i={}){if(t<=It)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=a1(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:lh(n),ZERO:It,ONE:gt,create:c=>St(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return It<=c&&c<t},is0:c=>c===It,isOdd:c=>(c>)===gt,neg:c=>St(-c,t),eql:(c,l)=>c===l,sqr:c=>St(c*c,t),add:(c,l)=>St(c+l,t),sub:(c,l)=>St(c-l,t),mul:(c,l)=>St(c*l,t),pow:(c,l)=>T5(a,c,l),div:(c,l)=>St(c*vh(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>vh(c,t),sqrt:i.sqrt||(c=>(o||(o=D5(t)),o(a,c))),invertBatch:c=>R5(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?ah(c,s):Yi(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?oh(c):ti(c)}});return Object.freeze(a)}function l1(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 u1(t){const e=l1(t);return e+Math.ceil(e/2)}function N5(t,e,r=!1){const i=t.length,n=l1(e),s=u1(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?oh(t):ti(t),a=St(o,e-gt)+gt;return r?ah(a,n):Yi(a,n)}const h1=BigInt(0),Uc=BigInt(1);function yh(t,e){const r=e.negate();return t?r:e}function d1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function wh(t,e){d1(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function B5(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 L5(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 _h=new WeakMap,f1=new WeakMap;function xh(t){return f1.get(t)||1}function F5(t,e){return{constTimeNegate:yh,hasPrecomputes(r){return xh(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>h1;)i&Uc&&(n=n.add(s)),s=s.double(),i>>=Uc;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=wh(i,e),o=[];let a=r,c=a;for(let l=0;l<n;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=wh(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,d=BigInt(r);for(let p=0;p<s;p++){const y=p*o;let m=Number(n&l);n>>=d,m>o&&(m-=u,n+=Uc);const _=y,S=y+Math.abs(m)-1,E=p%2!==0,P=m<0;m===0?c=c.add(yh(E,i[_])):a=a.add(yh(P,i[S]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=wh(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let d=0;d<o;d++){const p=d*a;if(n===h1)break;let y=Number(n&c);if(n>>=u,y>a&&(y-=l,n+=Uc),y===0)continue;let m=i[p+Math.abs(y)-1];y<0&&(m=m.negate()),s=s.add(m)}return s},getPrecomputes(r,i,n){let s=_h.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&_h.set(i,n(s))),s},wNAFCached(r,i,n){const s=xh(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=xh(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){d1(i,e),f1.set(r,i),_h.delete(r)}}}function U5(t,e,r,i){if(B5(r,t),L5(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Wp(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),l=Math.floor((e.BITS-1)/o)*o;let u=n;for(let d=l;d>=0;d-=o){c.fill(n);for(let y=0;y<i.length;y++){const m=i[y],_=Number(m>>BigInt(d)&BigInt(a));c[_]=c[_].add(r[y])}let p=n;for(let y=c.length-1,m=n;y>0;y--)m=m.add(c[y]),p=p.add(m);if(u=u.add(p),d!==0)for(let y=0;y<o;y++)u=u.double()}return u}function p1(t){return o1(t.Fp),Ls(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...a1(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function g1(t){t.lowS!==void 0&&Ms("lowS",t.lowS),t.prehash!==void 0&&Ms("prehash",t.prehash)}function j5(t){const e=p1(t);Ls(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:q5,hexToBytes:z5}=Z4;class k5 extends Error{constructor(e=""){super(e)}}const Di={Err:k5,_tlv:{encode:(t,e)=>{const{Err:r}=Di;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=Rs(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?Rs(n.length/2|128):"";return Rs(t)+s+n+e},decode(t,e){const{Err:r}=Di;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 l=e.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;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}=Di;if(t<jr)throw new e("integer: negative integers are not allowed");let r=Rs(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}=Di;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 q5(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Di,n=typeof t=="string"?z5(t):t;ei(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:l,l:u}=i.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){const{_tlv:e,_int:r}=Di,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}},jr=BigInt(0),$e=BigInt(1),Qi=BigInt(2),jc=BigInt(3),b1=BigInt(4);function H5(t){const e=j5(t),{Fp:r}=e,i=c1(e.n,e.nBitLength),n=e.toBytes||((_,S,E)=>{const P=S.toAffine();return pr(Uint8Array.from([4]),r.toBytes(P.x),r.toBytes(P.y))}),s=e.fromBytes||(_=>{const S=_.subarray(1),E=r.fromBytes(S.subarray(0,r.BYTES)),P=r.fromBytes(S.subarray(r.BYTES,2*r.BYTES));return{x:E,y:P}});function o(_){const{a:S,b:E}=e,P=r.sqr(_),C=r.mul(P,_);return r.add(r.add(C,r.mul(_,S)),E)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(_){return Bs(_,$e,e.n)}function c(_){const{allowedPrivateKeyLengths:S,nByteLength:E,wrapPrivateKey:P,n:C}=e;if(S&&typeof _!="bigint"){if(Bn(_)&&(_=Ts(_)),typeof _!="string"||!S.includes(_.length))throw new Error("invalid private key");_=_.padStart(E*2,"0")}let M;try{M=typeof _=="bigint"?_:ti(Vt("private key",_,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof _)}return P&&(M=St(M,C)),Ji("private key",M,$e,C),M}function l(_){if(!(_ instanceof p))throw new Error("ProjectivePoint expected")}const u=hh((_,S)=>{const{px:E,py:P,pz:C}=_;if(r.eql(C,r.ONE))return{x:E,y:P};const M=_.is0();S==null&&(S=M?r.ONE:r.inv(C));const R=r.mul(E,S),L=r.mul(P,S),B=r.mul(C,S);if(M)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:R,y:L}}),d=hh(_=>{if(_.is0()){if(e.allowInfinityPoint&&!r.is0(_.py))return;throw new Error("bad point: ZERO")}const{x:S,y:E}=_.toAffine();if(!r.isValid(S)||!r.isValid(E))throw new Error("bad point: x or y not FE");const P=r.sqr(E),C=o(S);if(!r.eql(P,C))throw new Error("bad point: equation left != right");if(!_.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(S,E,P){if(this.px=S,this.py=E,this.pz=P,S==null||!r.isValid(S))throw new Error("x required");if(E==null||!r.isValid(E))throw new Error("y required");if(P==null||!r.isValid(P))throw new Error("z required");Object.freeze(this)}static fromAffine(S){const{x:E,y:P}=S||{};if(!S||!r.isValid(E)||!r.isValid(P))throw new Error("invalid affine point");if(S instanceof p)throw new Error("projective point not allowed");const C=M=>r.eql(M,r.ZERO);return C(E)&&C(P)?p.ZERO:new p(E,P,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const E=r.invertBatch(S.map(P=>P.pz));return S.map((P,C)=>P.toAffine(E[C])).map(p.fromAffine)}static fromHex(S){const E=p.fromAffine(s(Vt("pointHex",S)));return E.assertValidity(),E}static fromPrivateKey(S){return p.BASE.multiply(c(S))}static msm(S,E){return U5(p,i,S,E)}_setWindowSize(S){m.setWindowSize(this,S)}assertValidity(){d(this)}hasEvenY(){const{y:S}=this.toAffine();if(r.isOdd)return!r.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){l(S);const{px:E,py:P,pz:C}=this,{px:M,py:R,pz:L}=S,B=r.eql(r.mul(E,L),r.mul(M,C)),F=r.eql(r.mul(P,L),r.mul(R,C));return B&&F}negate(){return new p(this.px,r.neg(this.py),this.pz)}double(){const{a:S,b:E}=e,P=r.mul(E,jc),{px:C,py:M,pz:R}=this;let L=r.ZERO,B=r.ZERO,F=r.ZERO,T=r.mul(C,C),q=r.mul(M,M),$=r.mul(R,R),h=r.mul(C,M);return h=r.add(h,h),F=r.mul(C,R),F=r.add(F,F),L=r.mul(S,F),B=r.mul(P,$),B=r.add(L,B),L=r.sub(q,B),B=r.add(q,B),B=r.mul(L,B),L=r.mul(h,L),F=r.mul(P,F),$=r.mul(S,$),h=r.sub(T,$),h=r.mul(S,h),h=r.add(h,F),F=r.add(T,T),T=r.add(F,T),T=r.add(T,$),T=r.mul(T,h),B=r.add(B,T),$=r.mul(M,R),$=r.add($,$),T=r.mul($,h),L=r.sub(L,T),F=r.mul($,q),F=r.add(F,F),F=r.add(F,F),new p(L,B,F)}add(S){l(S);const{px:E,py:P,pz:C}=this,{px:M,py:R,pz:L}=S;let B=r.ZERO,F=r.ZERO,T=r.ZERO;const q=e.a,$=r.mul(e.b,jc);let h=r.mul(E,M),b=r.mul(P,R),w=r.mul(C,L),g=r.add(E,P),v=r.add(M,R);g=r.mul(g,v),v=r.add(h,b),g=r.sub(g,v),v=r.add(E,C);let I=r.add(M,L);return v=r.mul(v,I),I=r.add(h,w),v=r.sub(v,I),I=r.add(P,C),B=r.add(R,L),I=r.mul(I,B),B=r.add(b,w),I=r.sub(I,B),T=r.mul(q,v),B=r.mul($,w),T=r.add(B,T),B=r.sub(b,T),T=r.add(b,T),F=r.mul(B,T),b=r.add(h,h),b=r.add(b,h),w=r.mul(q,w),v=r.mul($,v),b=r.add(b,w),w=r.sub(h,w),w=r.mul(q,w),v=r.add(v,w),h=r.mul(b,v),F=r.add(F,h),h=r.mul(I,v),B=r.mul(g,B),B=r.sub(B,h),h=r.mul(g,b),T=r.mul(I,T),T=r.add(T,h),new p(B,F,T)}subtract(S){return this.add(S.negate())}is0(){return this.equals(p.ZERO)}wNAF(S){return m.wNAFCached(this,S,p.normalizeZ)}multiplyUnsafe(S){const{endo:E,n:P}=e;Ji("scalar",S,jr,P);const C=p.ZERO;if(S===jr)return C;if(this.is0()||S===$e)return this;if(!E||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,S,p.normalizeZ);let{k1neg:M,k1:R,k2neg:L,k2:B}=E.splitScalar(S),F=C,T=C,q=this;for(;R>jr||B>jr;)R&$e&&(F=F.add(q)),B&$e&&(T=T.add(q)),q=q.double(),R>>=$e,B>>=$e;return M&&(F=F.negate()),L&&(T=T.negate()),T=new p(r.mul(T.px,E.beta),T.py,T.pz),F.add(T)}multiply(S){const{endo:E,n:P}=e;Ji("scalar",S,$e,P);let C,M;if(E){const{k1neg:R,k1:L,k2neg:B,k2:F}=E.splitScalar(S);let{p:T,f:q}=this.wNAF(L),{p:$,f:h}=this.wNAF(F);T=m.constTimeNegate(R,T),$=m.constTimeNegate(B,$),$=new p(r.mul($.px,E.beta),$.py,$.pz),C=T.add($),M=q.add(h)}else{const{p:R,f:L}=this.wNAF(S);C=R,M=L}return p.normalizeZ([C,M])[0]}multiplyAndAddUnsafe(S,E,P){const C=p.BASE,M=(L,B)=>B===jr||B===$e||!L.equals(C)?L.multiplyUnsafe(B):L.multiply(B),R=M(this,E).add(M(S,P));return R.is0()?void 0:R}toAffine(S){return u(this,S)}isTorsionFree(){const{h:S,isTorsionFree:E}=e;if(S===$e)return!0;if(E)return E(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:E}=e;return S===$e?this:E?E(p,this):this.multiplyUnsafe(e.h)}toRawBytes(S=!0){return Ms("isCompressed",S),this.assertValidity(),n(p,this,S)}toHex(S=!0){return Ms("isCompressed",S),Ts(this.toRawBytes(S))}}p.BASE=new p(e.Gx,e.Gy,r.ONE),p.ZERO=new p(r.ZERO,r.ONE,r.ZERO);const y=e.nBitLength,m=F5(p,e.endo?Math.ceil(y/2):y);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function W5(t){const e=p1(t);return Ls(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function V5(t){const e=W5(t),{Fp:r,n:i}=e,n=r.BYTES+1,s=2*r.BYTES+1;function o(w){return St(w,i)}function a(w){return vh(w,i)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:d}=H5({...e,toBytes(w,g,v){const I=g.toAffine(),O=r.toBytes(I.x),x=pr;return Ms("isCompressed",v),v?x(Uint8Array.from([g.hasEvenY()?2:3]),O):x(Uint8Array.from([4]),O,r.toBytes(I.y))},fromBytes(w){const g=w.length,v=w[0],I=w.subarray(1);if(g===n&&(v===2||v===3)){const O=ti(I);if(!Bs(O,$e,r.ORDER))throw new Error("Point is not on curve");const x=u(O);let f;try{f=r.sqrt(x)}catch(z){const U=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+U)}const A=(f&$e)===$e;return(v&1)===1!==A&&(f=r.neg(f)),{x:O,y:f}}else if(g===s&&v===4){const O=r.fromBytes(I.subarray(0,r.BYTES)),x=r.fromBytes(I.subarray(r.BYTES,2*r.BYTES));return{x:O,y:x}}else{const O=n,x=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+x+", got "+g)}}}),p=w=>Ts(Yi(w,e.nByteLength));function y(w){const g=i>>$e;return w>g}function m(w){return y(w)?o(-w):w}const _=(w,g,v)=>ti(w.slice(g,v));class S{constructor(g,v,I){this.r=g,this.s=v,this.recovery=I,this.assertValidity()}static fromCompact(g){const v=e.nByteLength;return g=Vt("compactSignature",g,v*2),new S(_(g,0,v),_(g,v,2*v))}static fromDER(g){const{r:v,s:I}=Di.toSig(Vt("DER",g));return new S(v,I)}assertValidity(){Ji("r",this.r,$e,i),Ji("s",this.s,$e,i)}addRecoveryBit(g){return new S(this.r,this.s,g)}recoverPublicKey(g){const{r:v,s:I,recovery:O}=this,x=L(Vt("msgHash",g));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const f=O===2||O===3?v+e.n:v;if(f>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=(O&1)===0?"02":"03",j=c.fromHex(A+p(f)),z=a(f),U=o(-x*z),k=o(I*z),Z=c.BASE.multiplyAndAddUnsafe(j,U,k);if(!Z)throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ns(this.toDERHex())}toDERHex(){return Di.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ns(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}const E={isValidPrivateKey(w){try{return l(w),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const w=u1(e.n);return N5(e.randomBytes(w),e.n)},precompute(w=8,g=c.BASE){return g._setWindowSize(w),g.multiply(BigInt(3)),g}};function P(w,g=!0){return c.fromPrivateKey(w).toRawBytes(g)}function C(w){const g=Bn(w),v=typeof w=="string",I=(g||v)&&w.length;return g?I===n||I===s:v?I===2*n||I===2*s:w instanceof c}function M(w,g,v=!0){if(C(w))throw new Error("first arg must be private key");if(!C(g))throw new Error("second arg must be public key");return c.fromHex(g).multiply(l(w)).toRawBytes(v)}const R=e.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");const g=ti(w),v=w.length*8-e.nBitLength;return v>0?g>>BigInt(v):g},L=e.bits2int_modN||function(w){return o(R(w))},B=lh(e.nBitLength);function F(w){return Ji("num < 2^"+e.nBitLength,w,jr,B),Yi(w,e.nByteLength)}function T(w,g,v=q){if(["recovered","canonical"].some(ee=>ee in v))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:O}=e;let{lowS:x,prehash:f,extraEntropy:A}=v;x==null&&(x=!0),w=Vt("msgHash",w),g1(v),f&&(w=Vt("prehashed msgHash",I(w)));const j=L(w),z=l(g),U=[F(z),F(j)];if(A!=null&&A!==!1){const ee=A===!0?O(r.BYTES):A;U.push(Vt("extraEntropy",ee))}const k=pr(...U),Z=j;function X(ee){const Q=R(ee);if(!d(Q))return;const re=a(Q),Ze=c.BASE.multiply(Q).toAffine(),oe=o(Ze.x);if(oe===jr)return;const fe=o(re*o(Z+oe*z));if(fe===jr)return;let $t=(Ze.x===oe?0:2)|Number(Ze.y&$e),xe=fe;return x&&y(fe)&&(xe=m(fe),$t^=1),new S(oe,xe,$t)}return{seed:k,k2sig:X}}const q={lowS:e.lowS,prehash:!1},$={lowS:e.lowS,prehash:!1};function h(w,g,v=q){const{seed:I,k2sig:O}=T(w,g,v),x=e;return Kp(x.hash.outputLen,x.nByteLength,x.hmac)(I,O)}c.BASE._setWindowSize(8);function b(w,g,v,I=$){const O=w;g=Vt("msgHash",g),v=Vt("publicKey",v);const{lowS:x,prehash:f,format:A}=I;if(g1(I),"strict"in I)throw new Error("options.strict was renamed to lowS");if(A!==void 0&&A!=="compact"&&A!=="der")throw new Error("format must be compact or der");const j=typeof O=="string"||Bn(O),z=!j&&!A&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!j&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let U,k;try{if(z&&(U=new S(O.r,O.s)),j){try{A!=="compact"&&(U=S.fromDER(O))}catch($t){if(!($t instanceof Di.Err))throw $t}!U&&A!=="der"&&(U=S.fromCompact(O))}k=c.fromHex(v)}catch{return!1}if(!U||x&&U.hasHighS())return!1;f&&(g=e.hash(g));const{r:Z,s:X}=U,ee=L(g),Q=a(X),re=o(ee*Q),Ze=o(Z*Q),oe=c.BASE.multiplyAndAddUnsafe(k,re,Ze)?.toAffine();return oe?o(oe.x)===Z:!1}return{CURVE:e,getPublicKey:P,getSharedSecret:M,sign:h,verify:b,ProjectivePoint:c,Signature:S,utils:E}}function K5(t,e){const r=t.ORDER;let i=jr;for(let m=r-$e;m%Qi===jr;m/=Qi)i+=$e;const n=i,s=Qi<<n-$e-$e,o=s*Qi,a=(r-$e)/o,c=(a-$e)/Qi,l=o-$e,u=s,d=t.pow(e,a),p=t.pow(e,(a+$e)/Qi);let y=(m,_)=>{let S=d,E=t.pow(_,l),P=t.sqr(E);P=t.mul(P,_);let C=t.mul(m,P);C=t.pow(C,c),C=t.mul(C,E),E=t.mul(C,_),P=t.mul(C,m);let M=t.mul(P,E);C=t.pow(M,u);let R=t.eql(C,t.ONE);E=t.mul(P,p),C=t.mul(M,S),P=t.cmov(E,P,R),M=t.cmov(C,M,R);for(let L=n;L>$e;L--){let B=L-Qi;B=Qi<<B-$e;let F=t.pow(M,B);const T=t.eql(F,t.ONE);E=t.mul(P,S),S=t.mul(S,S),F=t.mul(M,S),P=t.cmov(E,P,T),M=t.cmov(F,M,T)}return{isValid:R,value:P}};if(t.ORDER%b1===jc){const m=(t.ORDER-jc)/b1,_=t.sqrt(t.neg(e));y=(S,E)=>{let P=t.sqr(E);const C=t.mul(S,E);P=t.mul(P,C);let M=t.pow(P,m);M=t.mul(M,C);const R=t.mul(M,_),L=t.mul(t.sqr(M),E),B=t.eql(L,S);let F=t.cmov(R,M,B);return{isValid:B,value:F}}}return y}function G5(t,e){if(o1(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=K5(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return i=>{let n,s,o,a,c,l,u,d;n=t.sqr(i),n=t.mul(n,e.Z),s=t.sqr(n),s=t.add(s,n),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),l=t.sqr(a),c=t.mul(l,e.A),s=t.add(s,c),s=t.mul(s,o),l=t.mul(l,a),c=t.mul(l,e.B),s=t.add(s,c),u=t.mul(n,o);const{isValid:p,value:y}=r(s,l);d=t.mul(n,i),d=t.mul(d,y),u=t.cmov(u,o,p),d=t.cmov(d,y,p);const m=t.isOdd(i)===t.isOdd(d);return d=t.cmov(t.neg(d),d,m),u=t.div(u,a),{x:u,y:d}}}function Z5(t){return{hash:t,hmac:(e,...r)=>i1(t,e,v4(...r)),randomBytes:Tp}}function Y5(t,e){const r=i=>V5({...t,...Z5(i)});return{...r(e),create:r}}const J5=ti;function Xi(t,e){if(na(t),na(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let i=e-1;i>=0;i--)r[i]=t&255,t>>>=8;return new Uint8Array(r)}function Q5(t,e){const r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t[i]^e[i];return r}function na(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function X5(t,e,r,i){ei(t),ei(e),na(r),e.length>255&&(e=i(pr(Lc("H2C-OVERSIZE-DST-"),e)));const{outputLen:n,blockLen:s}=i,o=Math.ceil(r/n);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=pr(e,Xi(e.length,1)),c=Xi(0,s),l=Xi(r,2),u=new Array(o),d=i(pr(c,t,l,Xi(0,1),a));u[0]=i(pr(d,Xi(1,1),a));for(let y=1;y<=o;y++){const m=[Q5(d,u[y-1]),Xi(y+1,1),a];u[y]=i(pr(...m))}return pr(...u).slice(0,r)}function e6(t,e,r,i,n){if(ei(t),ei(e),na(r),e.length>255){const s=Math.ceil(2*i/8);e=n.create({dkLen:s}).update(Lc("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(t).update(Xi(r,2)).update(e).update(Xi(e.length,1)).digest()}function m1(t,e,r){Ls(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:i,k:n,m:s,hash:o,expand:a,DST:c}=r;ei(t),na(e);const l=typeof c=="string"?Lc(c):c,u=i.toString(2).length,d=Math.ceil((u+n)/8),p=e*s*d;let y;if(a==="xmd")y=X5(t,l,p,o);else if(a==="xof")y=e6(t,l,p,n,o);else if(a==="_internal_pass")y=t;else throw new Error('expand must be "xmd" or "xof"');const m=new Array(e);for(let _=0;_<e;_++){const S=new Array(s);for(let E=0;E<s;E++){const P=d*(E+_*s),C=y.subarray(P,P+d);S[E]=St(J5(C),i)}m[_]=S}return m}function t6(t,e){const r=e.map(i=>Array.from(i).reverse());return(i,n)=>{const[s,o,a,c]=r.map(l=>l.reduce((u,d)=>t.add(t.mul(u,i),d)));return i=t.div(s,o),n=t.mul(n,t.div(a,c)),{x:i,y:n}}}function r6(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(i,n){const s=m1(i,2,{...r,DST:r.DST,...n}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(i,n){const s=m1(i,1,{...r,DST:r.encodeDST,...n}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(i){if(!Array.isArray(i))throw new Error("mapToCurve: expected array of bigints");for(const s of i)if(typeof s!="bigint")throw new Error("mapToCurve: expected array of bigints");const n=t.fromAffine(e(i)).clearCofactor();return n.assertValidity(),n}}}const sa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),qc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),oa=BigInt(1),zc=BigInt(2),v1=(t,e)=>(t+e/zc)/e;function y1(t){const e=sa,r=BigInt(3),i=BigInt(6),n=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,d=Ir(u,r,e)*u%e,p=Ir(d,r,e)*u%e,y=Ir(p,zc,e)*l%e,m=Ir(y,n,e)*y%e,_=Ir(m,s,e)*m%e,S=Ir(_,a,e)*_%e,E=Ir(S,c,e)*S%e,P=Ir(E,a,e)*_%e,C=Ir(P,r,e)*u%e,M=Ir(C,o,e)*m%e,R=Ir(M,i,e)*l%e,L=Ir(R,zc,e);if(!en.eql(en.sqr(L),t))throw new Error("Cannot find square root");return L}const en=c1(sa,void 0,void 0,{sqrt:y1}),aa=Y5({a:BigInt(0),b:BigInt(7),Fp:en,n:qc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=qc,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-oa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=v1(s*t,e),c=v1(-i*t,e);let l=St(t-a*r-c*n,e),u=St(-a*i-c*s,e);const d=l>o,p=u>o;if(d&&(l=e-l),p&&(u=e-u),l>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:l,k2neg:p,k2:u}}}},Rc),w1=BigInt(0),_1={};function kc(t,...e){let r=_1[t];if(r===void 0){const i=Rc(Uint8Array.from(t,n=>n.charCodeAt(0)));r=pr(i,i),_1[t]=r}return Rc(pr(r,...e))}const Eh=t=>t.toRawBytes(!0).slice(1),$h=t=>Yi(t,32),Ih=t=>St(t,sa),ca=t=>St(t,qc),Sh=aa.ProjectivePoint,i6=(t,e,r)=>Sh.BASE.multiplyAndAddUnsafe(t,e,r);function Ah(t){let e=aa.utils.normPrivateKeyToScalar(t),r=Sh.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:ca(-e),bytes:Eh(r)}}function x1(t){Ji("x",t,oa,sa);const e=Ih(t*t),r=Ih(e*t+BigInt(7));let i=y1(r);i%zc!==w1&&(i=Ih(-i));const n=new Sh(t,i,oa);return n.assertValidity(),n}const Fs=ti;function E1(...t){return ca(Fs(kc("BIP0340/challenge",...t)))}function n6(t){return Ah(t).bytes}function s6(t,e,r=Tp(32)){const i=Vt("message",t),{bytes:n,scalar:s}=Ah(e),o=Vt("auxRand",r,32),a=$h(s^Fs(kc("BIP0340/aux",o))),c=kc("BIP0340/nonce",a,n,i),l=ca(Fs(c));if(l===w1)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ah(l),p=E1(u,n,i),y=new Uint8Array(64);if(y.set(u,0),y.set($h(ca(d+p*s)),32),!$1(y,i,n))throw new Error("sign: Invalid signature produced");return y}function $1(t,e,r){const i=Vt("signature",t,64),n=Vt("message",e),s=Vt("publicKey",r,32);try{const o=x1(Fs(s)),a=Fs(i.subarray(0,32));if(!Bs(a,oa,sa))return!1;const c=Fs(i.subarray(32,64));if(!Bs(c,oa,qc))return!1;const l=E1($h(a),Eh(o),n),u=i6(o,c,ca(-l));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}const o6={getPublicKey:n6,sign:s6,verify:$1,utils:{randomPrivateKey:aa.utils.randomPrivateKey,lift_x:x1,pointToBytes:Eh,numberToBytesBE:Yi,bytesToNumberBE:ti,taggedHash:kc,mod:St}},a6=t6(en,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),c6=G5(en,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:en.create(BigInt("-11"))}),I1=r6(aa.ProjectivePoint,t=>{const{x:e,y:r}=c6(en.create(t[0]));return a6(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:en.ORDER,m:1,k:128,expand:"xmd",hash:Rc});var l6=Object.freeze({__proto__:null,secp256k1:aa,schnorr:o6,hashToCurve:I1.hashToCurve,encodeToCurve:I1.encodeToCurve});const u6=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),h6=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 Fn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return h6(t)}catch{return t}}function Mi(t){return typeof t=="string"?t:u6(t)||""}function d6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function S1(t,...e){if(!d6(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 A1(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 f6(t,e){S1(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Us=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ph=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function p6(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function P1(t){return typeof t=="string"&&(t=p6(t)),S1(t),t}class g6{clone(){return this._cloneInto()}}function b6(t){const e=i=>t().update(P1(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function O1(t=32){if(Us&&typeof Us.getRandomValues=="function")return Us.getRandomValues(new Uint8Array(t));if(Us&&typeof Us.randomBytes=="function")return Us.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function m6(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}class v6 extends g6{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=Ph(this.buffer)}update(e){A1(this);const{view:r,buffer:i,blockLen:n}=this;e=P1(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=Ph(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){A1(this),f6(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 d=o;d<n;d++)r[d]=0;m6(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ph(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],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 Hc=BigInt(2**32-1),Oh=BigInt(32);function C1(t,e=!1){return e?{h:Number(t&Hc),l:Number(t>>Oh&Hc)}:{h:Number(t>>Oh&Hc)|0,l:Number(t&Hc)|0}}function y6(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}=C1(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const w6=(t,e)=>BigInt(t>>>0)<<Oh|BigInt(e>>>0),_6=(t,e,r)=>t>>>r,x6=(t,e,r)=>t<<32-r|e>>>r,E6=(t,e,r)=>t>>>r|e<<32-r,$6=(t,e,r)=>t<<32-r|e>>>r,I6=(t,e,r)=>t<<64-r|e>>>r-32,S6=(t,e,r)=>t>>>r-32|e<<64-r,A6=(t,e)=>e,P6=(t,e)=>t,O6=(t,e,r)=>t<<r|e>>>32-r,C6=(t,e,r)=>e<<r|t>>>32-r,D6=(t,e,r)=>e<<r-32|t>>>64-r,M6=(t,e,r)=>t<<r-32|e>>>64-r;function T6(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const R6=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),N6=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,B6=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),L6=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,F6=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),U6=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,se={fromBig:C1,split:y6,toBig:w6,shrSH:_6,shrSL:x6,rotrSH:E6,rotrSL:$6,rotrBH:I6,rotrBL:S6,rotr32H:A6,rotr32L:P6,rotlSH:O6,rotlSL:C6,rotlBH:D6,rotlBL:M6,add:T6,add3L:R6,add3H:N6,add4L:B6,add4H:L6,add5H:U6,add5L:F6},[j6,q6]=se.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))),tn=new Uint32Array(80),rn=new Uint32Array(80);class z6 extends v6{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:l,El:u,Fh:d,Fl:p,Gh:y,Gl:m,Hh:_,Hl:S}=this;return[e,r,i,n,s,o,a,c,l,u,d,p,y,m,_,S]}set(e,r,i,n,s,o,a,c,l,u,d,p,y,m,_,S){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=l|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=y|0,this.Gl=m|0,this.Hh=_|0,this.Hl=S|0}process(e,r){for(let C=0;C<16;C++,r+=4)tn[C]=e.getUint32(r),rn[C]=e.getUint32(r+=4);for(let C=16;C<80;C++){const M=tn[C-15]|0,R=rn[C-15]|0,L=se.rotrSH(M,R,1)^se.rotrSH(M,R,8)^se.shrSH(M,R,7),B=se.rotrSL(M,R,1)^se.rotrSL(M,R,8)^se.shrSL(M,R,7),F=tn[C-2]|0,T=rn[C-2]|0,q=se.rotrSH(F,T,19)^se.rotrBH(F,T,61)^se.shrSH(F,T,6),$=se.rotrSL(F,T,19)^se.rotrBL(F,T,61)^se.shrSL(F,T,6),h=se.add4L(B,$,rn[C-7],rn[C-16]),b=se.add4H(h,L,q,tn[C-7],tn[C-16]);tn[C]=b|0,rn[C]=h|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:p,Fh:y,Fl:m,Gh:_,Gl:S,Hh:E,Hl:P}=this;for(let C=0;C<80;C++){const M=se.rotrSH(d,p,14)^se.rotrSH(d,p,18)^se.rotrBH(d,p,41),R=se.rotrSL(d,p,14)^se.rotrSL(d,p,18)^se.rotrBL(d,p,41),L=d&y^~d&_,B=p&m^~p&S,F=se.add5L(P,R,B,q6[C],rn[C]),T=se.add5H(F,E,M,L,j6[C],tn[C]),q=F|0,$=se.rotrSH(i,n,28)^se.rotrBH(i,n,34)^se.rotrBH(i,n,39),h=se.rotrSL(i,n,28)^se.rotrBL(i,n,34)^se.rotrBL(i,n,39),b=i&s^i&a^s&a,w=n&o^n&c^o&c;E=_|0,P=S|0,_=y|0,S=m|0,y=d|0,m=p|0,{h:d,l:p}=se.add(l|0,u|0,T|0,q|0),l=a|0,u=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const g=se.add3L(q,h,w);i=se.add3H(g,T,$,b),n=g|0}({h:i,l:n}=se.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=se.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=se.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=se.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:p}=se.add(this.Eh|0,this.El|0,d|0,p|0),{h:y,l:m}=se.add(this.Fh|0,this.Fl|0,y|0,m|0),{h:_,l:S}=se.add(this.Gh|0,this.Gl|0,_|0,S|0),{h:E,l:P}=se.add(this.Hh|0,this.Hl|0,E|0,P|0),this.set(i,n,s,o,a,c,l,u,d,p,y,m,_,S,E,P)}roundClean(){tn.fill(0),rn.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 k6=b6(()=>new z6);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ch=BigInt(0),D1=BigInt(1),H6=BigInt(2);function Dh(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Mh(t){if(!Dh(t))throw new Error("Uint8Array expected")}function Th(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const W6=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Rh(t){Mh(t);let e="";for(let r=0;r<t.length;r++)e+=W6[t[r]];return e}function M1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ch:BigInt("0x"+t)}const Ti={_0:48,_9:57,A:65,F:70,a:97,f:102};function T1(t){if(t>=Ti._0&&t<=Ti._9)return t-Ti._0;if(t>=Ti.A&&t<=Ti.F)return t-(Ti.A-10);if(t>=Ti.a&&t<=Ti.f)return t-(Ti.a-10)}function R1(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=T1(t.charCodeAt(s)),a=T1(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 V6(t){return M1(Rh(t))}function Wc(t){return Mh(t),M1(Rh(Uint8Array.from(t).reverse()))}function N1(t,e){return R1(t.toString(16).padStart(e*2,"0"))}function Nh(t,e){return N1(t,e).reverse()}function Ri(t,e,r){let i;if(typeof e=="string")try{i=R1(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Dh(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 B1(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Mh(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 Bh=t=>typeof t=="bigint"&&Ch<=t;function K6(t,e,r){return Bh(t)&&Bh(e)&&Bh(r)&&e<=t&&t<r}function la(t,e,r,i){if(!K6(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function G6(t){let e;for(e=0;t>Ch;t>>=D1,e+=1);return e}const Z6=t=>(H6<<BigInt(t-1))-D1,Y6={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"||Dh(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 Lh(t,e,r={}){const i=(n,s,o)=>{const a=Y6[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 L1(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 At=BigInt(0),bt=BigInt(1),Un=BigInt(2),J6=BigInt(3),Fh=BigInt(4),F1=BigInt(5),U1=BigInt(8);function _t(t,e){const r=t%e;return r>=At?r:e+r}function Q6(t,e,r){if(e<At)throw new Error("invalid exponent, negatives unsupported");if(r<=At)throw new Error("invalid modulus");if(r===bt)return At;let i=bt;for(;e>At;)e&bt&&(i=i*t%r),t=t*t%r,e>>=bt;return i}function ri(t,e,r){let i=t;for(;e-- >At;)i*=i,i%=r;return i}function j1(t,e){if(t===At)throw new Error("invert: expected non-zero number");if(e<=At)throw new Error("invert: expected positive modulus, got "+e);let r=_t(t,e),i=e,n=At,s=bt;for(;r!==At;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==bt)throw new Error("invert: does not exist");return _t(n,e)}function X6(t){const e=(t-bt)/Un;let r,i,n;for(r=t-bt,i=0;r%Un===At;r/=Un,i++);for(n=Un;n<t&&Q6(n,e,t)!==t-bt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+bt)/Fh;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(r+bt)/Un;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,l=o.pow(o.mul(o.ONE,n),r),u=o.pow(a,s),d=o.pow(a,r);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let p=1;for(let m=o.sqr(d);p<c&&!o.eql(m,o.ONE);p++)m=o.sqr(m);const y=o.pow(l,bt<<BigInt(c-p-1));l=o.sqr(y),u=o.mul(u,y),d=o.mul(d,l),c=p}return u}}function e8(t){if(t%Fh===J6){const e=(t+bt)/Fh;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%U1===F1){const e=(t-F1)/U1;return function(r,i){const n=r.mul(i,Un),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,Un),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 X6(t)}const t8=(t,e)=>(_t(t,e)&bt)===bt,r8=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function i8(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=r8.reduce((i,n)=>(i[n]="function",i),e);return Lh(t,r)}function n8(t,e,r){if(r<At)throw new Error("invalid exponent, negatives unsupported");if(r===At)return t.ONE;if(r===bt)return e;let i=t.ONE,n=e;for(;r>At;)r&bt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=bt;return i}function s8(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 q1(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function z1(t,e,r=!1,i={}){if(t<=At)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=q1(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:Z6(n),ZERO:At,ONE:bt,create:c=>_t(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return At<=c&&c<t},is0:c=>c===At,isOdd:c=>(c&bt)===bt,neg:c=>_t(-c,t),eql:(c,l)=>c===l,sqr:c=>_t(c*c,t),add:(c,l)=>_t(c+l,t),sub:(c,l)=>_t(c-l,t),mul:(c,l)=>_t(c*l,t),pow:(c,l)=>n8(a,c,l),div:(c,l)=>_t(c*j1(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>j1(c,t),sqrt:i.sqrt||(c=>(o||(o=e8(t)),o(a,c))),invertBatch:c=>s8(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Nh(c,s):N1(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Wc(c):V6(c)}});return Object.freeze(a)}const k1=BigInt(0),Vc=BigInt(1);function Uh(t,e){const r=e.negate();return t?r:e}function H1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function jh(t,e){H1(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function o8(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 a8(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 qh=new WeakMap,W1=new WeakMap;function zh(t){return W1.get(t)||1}function c8(t,e){return{constTimeNegate:Uh,hasPrecomputes(r){return zh(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>k1;)i&Vc&&(n=n.add(s)),s=s.double(),i>>=Vc;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=jh(i,e),o=[];let a=r,c=a;for(let l=0;l<n;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=jh(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,d=BigInt(r);for(let p=0;p<s;p++){const y=p*o;let m=Number(n&l);n>>=d,m>o&&(m-=u,n+=Vc);const _=y,S=y+Math.abs(m)-1,E=p%2!==0,P=m<0;m===0?c=c.add(Uh(E,i[_])):a=a.add(Uh(P,i[S]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=jh(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let d=0;d<o;d++){const p=d*a;if(n===k1)break;let y=Number(n&c);if(n>>=u,y>a&&(y-=l,n+=Vc),y===0)continue;let m=i[p+Math.abs(y)-1];y<0&&(m=m.negate()),s=s.add(m)}return s},getPrecomputes(r,i,n){let s=qh.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&qh.set(i,n(s))),s},wNAFCached(r,i,n){const s=zh(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=zh(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){H1(i,e),W1.set(r,i),qh.delete(r)}}}function l8(t,e,r,i){if(o8(r,t),a8(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=G6(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),l=Math.floor((e.BITS-1)/o)*o;let u=n;for(let d=l;d>=0;d-=o){c.fill(n);for(let y=0;y<i.length;y++){const m=i[y],_=Number(m>>BigInt(d)&BigInt(a));c[_]=c[_].add(r[y])}let p=n;for(let y=c.length-1,m=n;y>0;y--)m=m.add(c[y]),p=p.add(m);if(u=u.add(p),d!==0)for(let y=0;y<o;y++)u=u.double()}return u}function u8(t){return i8(t.Fp),Lh(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...q1(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const qr=BigInt(0),nr=BigInt(1),Kc=BigInt(2),h8=BigInt(8),d8={zip215:!0};function f8(t){const e=u8(t);return Lh(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function p8(t){const e=f8(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=Kc<<BigInt(a*8)-nr,u=r.create,d=z1(e.n,e.nBitLength),p=e.uvRatio||((g,v)=>{try{return{isValid:!0,value:r.sqrt(g*r.inv(v))}}catch{return{isValid:!1,value:qr}}}),y=e.adjustScalarBytes||(g=>g),m=e.domain||((g,v,I)=>{if(Th("phflag",I),v.length||I)throw new Error("Contexts/pre-hash are not supported");return g});function _(g,v){la("coordinate "+g,v,qr,l)}function S(g){if(!(g instanceof C))throw new Error("ExtendedPoint expected")}const E=L1((g,v)=>{const{ex:I,ey:O,ez:x}=g,f=g.is0();v==null&&(v=f?h8:r.inv(x));const A=u(I*v),j=u(O*v),z=u(x*v);if(f)return{x:qr,y:nr};if(z!==nr)throw new Error("invZ was invalid");return{x:A,y:j}}),P=L1(g=>{const{a:v,d:I}=e;if(g.is0())throw new Error("bad point: ZERO");const{ex:O,ey:x,ez:f,et:A}=g,j=u(O*O),z=u(x*x),U=u(f*f),k=u(U*U),Z=u(j*v),X=u(U*u(Z+z)),ee=u(k+u(I*u(j*z)));if(X!==ee)throw new Error("bad point: equation left != right (1)");const Q=u(O*x),re=u(f*A);if(Q!==re)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(v,I,O,x){this.ex=v,this.ey=I,this.ez=O,this.et=x,_("x",v),_("y",I),_("z",O),_("t",x),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(v){if(v instanceof C)throw new Error("extended point not allowed");const{x:I,y:O}=v||{};return _("x",I),_("y",O),new C(I,O,nr,u(I*O))}static normalizeZ(v){const I=r.invertBatch(v.map(O=>O.ez));return v.map((O,x)=>O.toAffine(I[x])).map(C.fromAffine)}static msm(v,I){return l8(C,d,v,I)}_setWindowSize(v){L.setWindowSize(this,v)}assertValidity(){P(this)}equals(v){S(v);const{ex:I,ey:O,ez:x}=this,{ex:f,ey:A,ez:j}=v,z=u(I*j),U=u(f*x),k=u(O*j),Z=u(A*x);return z===U&&k===Z}is0(){return this.equals(C.ZERO)}negate(){return new C(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:v}=e,{ex:I,ey:O,ez:x}=this,f=u(I*I),A=u(O*O),j=u(Kc*u(x*x)),z=u(v*f),U=I+O,k=u(u(U*U)-f-A),Z=z+A,X=Z-j,ee=z-A,Q=u(k*X),re=u(Z*ee),Ze=u(k*ee),oe=u(X*Z);return new C(Q,re,oe,Ze)}add(v){S(v);const{a:I,d:O}=e,{ex:x,ey:f,ez:A,et:j}=this,{ex:z,ey:U,ez:k,et:Z}=v;if(I===BigInt(-1)){const Be=u((f-x)*(U+z)),vs=u((f+x)*(U-z)),De=u(vs-Be);if(De===qr)return this.double();const Le=u(A*Kc*Z),ys=u(j*Kc*k),Fe=ys+Le,Ue=vs+Be,ws=ys-Le,Ae=u(Fe*De),Me=u(Ue*ws),_s=u(Fe*ws),pe=u(De*Ue);return new C(Ae,Me,pe,_s)}const X=u(x*z),ee=u(f*U),Q=u(j*O*Z),re=u(A*k),Ze=u((x+f)*(z+U)-X-ee),oe=re-Q,fe=re+Q,$t=u(ee-I*X),xe=u(Ze*oe),qe=u(fe*$t),Go=u(Ze*$t),ze=u(oe*fe);return new C(xe,qe,ze,Go)}subtract(v){return this.add(v.negate())}wNAF(v){return L.wNAFCached(this,v,C.normalizeZ)}multiply(v){const I=v;la("scalar",I,nr,i);const{p:O,f:x}=this.wNAF(I);return C.normalizeZ([O,x])[0]}multiplyUnsafe(v,I=C.ZERO){const O=v;return la("scalar",O,qr,i),O===qr?R:this.is0()||O===nr?this:L.wNAFCachedUnsafe(this,O,C.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,i).is0()}toAffine(v){return E(this,v)}clearCofactor(){const{h:v}=e;return v===nr?this:this.multiplyUnsafe(v)}static fromHex(v,I=!1){const{d:O,a:x}=e,f=r.BYTES;v=Ri("pointHex",v,f),Th("zip215",I);const A=v.slice(),j=v[f-1];A[f-1]=j&-129;const z=Wc(A),U=I?l:r.ORDER;la("pointHex.y",z,qr,U);const k=u(z*z),Z=u(k-nr),X=u(O*k-x);let{isValid:ee,value:Q}=p(Z,X);if(!ee)throw new Error("Point.fromHex: invalid y coordinate");const re=(Q&nr)===nr,Ze=(j&128)!==0;if(!I&&Q===qr&&Ze)throw new Error("Point.fromHex: x=0 and x_0=1");return Ze!==re&&(Q=u(-Q)),C.fromAffine({x:Q,y:z})}static fromPrivateKey(v){return T(v).point}toRawBytes(){const{x:v,y:I}=this.toAffine(),O=Nh(I,r.BYTES);return O[O.length-1]|=v&nr?128:0,O}toHex(){return Rh(this.toRawBytes())}}C.BASE=new C(e.Gx,e.Gy,nr,u(e.Gx*e.Gy)),C.ZERO=new C(qr,nr,nr,qr);const{BASE:M,ZERO:R}=C,L=c8(C,a*8);function B(g){return _t(g,i)}function F(g){return B(Wc(g))}function T(g){const v=r.BYTES;g=Ri("private key",g,v);const I=Ri("hashed private key",s(g),2*v),O=y(I.slice(0,v)),x=I.slice(v,2*v),f=F(O),A=M.multiply(f),j=A.toRawBytes();return{head:O,prefix:x,scalar:f,point:A,pointBytes:j}}function q(g){return T(g).pointBytes}function $(g=new Uint8Array,...v){const I=B1(...v);return F(s(m(I,Ri("context",g),!!n)))}function h(g,v,I={}){g=Ri("message",g),n&&(g=n(g));const{prefix:O,scalar:x,pointBytes:f}=T(v),A=$(I.context,O,g),j=M.multiply(A).toRawBytes(),z=$(I.context,j,f,g),U=B(A+z*x);la("signature.s",U,qr,i);const k=B1(j,Nh(U,r.BYTES));return Ri("result",k,r.BYTES*2)}const b=d8;function w(g,v,I,O=b){const{context:x,zip215:f}=O,A=r.BYTES;g=Ri("signature",g,2*A),v=Ri("message",v),I=Ri("publicKey",I,A),f!==void 0&&Th("zip215",f),n&&(v=n(v));const j=Wc(g.slice(A,2*A));let z,U,k;try{z=C.fromHex(I,f),U=C.fromHex(g.slice(0,A),f),k=M.multiplyUnsafe(j)}catch{return!1}if(!f&&z.isSmallOrder())return!1;const Z=$(x,U.toRawBytes(),z.toRawBytes(),v);return U.add(z.multiplyUnsafe(Z)).subtract(k).clearCofactor().equals(C.ZERO)}return M._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:h,verify:w,ExtendedPoint:C,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>o(r.BYTES),precompute(g=8,v=C.BASE){return v._setWindowSize(g),v.multiply(BigInt(3)),v}}}}BigInt(0),BigInt(1);const kh=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),V1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const g8=BigInt(1),K1=BigInt(2);BigInt(3);const b8=BigInt(5),m8=BigInt(8);function v8(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=kh,o=t*t%s*t%s,a=ri(o,K1,s)*o%s,c=ri(a,g8,s)*t%s,l=ri(c,b8,s)*c%s,u=ri(l,e,s)*l%s,d=ri(u,r,s)*u%s,p=ri(d,i,s)*d%s,y=ri(p,n,s)*p%s,m=ri(y,n,s)*p%s,_=ri(m,e,s)*l%s;return{pow_p_5_8:ri(_,K1,s)*t%s,b2:o}}function y8(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function w8(t,e){const r=kh,i=_t(e*e*e,r),n=_t(i*i*e,r),s=v8(t*n).pow_p_5_8;let o=_t(t*i*s,r);const a=_t(e*o*o,r),c=o,l=_t(o*V1,r),u=a===t,d=a===_t(-t,r),p=a===_t(-t*V1,r);return u&&(o=c),(d||p)&&(o=l),t8(o,r)&&(o=_t(-o,r)),{isValid:u||d,value:o}}const _8=z1(kh,void 0,!0),x8={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:_8,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:m8,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:k6,randomBytes:O1,adjustScalarBytes:y8,uvRatio:w8},G1=p8(x8),E8="EdDSA",$8="JWT",Gc=".",Zc="base64url",Z1="utf8",Y1="utf8",I8=":",S8="did",A8="key",J1="base58btc",P8="z",O8="K36",C8=32;function Hh(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Q1(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Hh(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function X1(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Q1(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return Hh(r)}function D8(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var _=0,S=0,E=0,P=m.length;E!==P&&m[E]===0;)E++,_++;for(var C=(P-E)*u+1>>>0,M=new Uint8Array(C);E!==P;){for(var R=m[E],L=0,B=C-1;(R!==0||L<S)&&B!==-1;B--,L++)R+=256*M[B]>>>0,M[B]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");S=L,E++}for(var F=C-S;F!==C&&M[F]===0;)F++;for(var T=c.repeat(_);F<C;++F)T+=t.charAt(M[F]);return T}function p(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var _=0;if(m[_]!==" "){for(var S=0,E=0;m[_]===c;)S++,_++;for(var P=(m.length-_)*l+1>>>0,C=new Uint8Array(P);m[_];){var M=r[m.charCodeAt(_)];if(M===255)return;for(var R=0,L=P-1;(M!==0||R<E)&&L!==-1;L--,R++)M+=a*C[L]>>>0,C[L]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=R,_++}if(m[_]!==" "){for(var B=P-E;B!==P&&C[B]===0;)B++;for(var F=new Uint8Array(S+(P-B)),T=S;B!==P;)F[T++]=C[B++];return F}}}function y(m){var _=p(m);if(_)return _;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:y}}var M8=D8,T8=M8;const eg=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")},R8=t=>new TextEncoder().encode(t),N8=t=>new TextDecoder().decode(t);class B8{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 L8{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 tg(this,e)}}class F8{constructor(e){this.decoders=e}or(e){return tg(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 tg=(t,e)=>new F8({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class U8{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new B8(e,r,i),this.decoder=new L8(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Yc=({name:t,prefix:e,encode:r,decode:i})=>new U8(t,e,r,i),ua=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=T8(r,e);return Yc({prefix:t,name:e,encode:i,decode:s=>eg(n(s))})},j8=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},q8=(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},Ft=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Yc({prefix:e,name:t,encode(n){return q8(n,i,r)},decode(n){return j8(n,i,r,t)}}),z8=Yc({prefix:"\0",name:"identity",encode:t=>N8(t),decode:t=>R8(t)});var k8=Object.freeze({__proto__:null,identity:z8});const H8=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var W8=Object.freeze({__proto__:null,base2:H8});const V8=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var K8=Object.freeze({__proto__:null,base8:V8});const G8=ua({prefix:"9",name:"base10",alphabet:"0123456789"});var Z8=Object.freeze({__proto__:null,base10:G8});const Y8=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),J8=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Q8=Object.freeze({__proto__:null,base16:Y8,base16upper:J8});const X8=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),e7=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),t7=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),r7=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),i7=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),n7=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),s7=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),o7=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),a7=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var c7=Object.freeze({__proto__:null,base32:X8,base32upper:e7,base32pad:t7,base32padupper:r7,base32hex:i7,base32hexupper:n7,base32hexpad:s7,base32hexpadupper:o7,base32z:a7});const l7=ua({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),u7=ua({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var h7=Object.freeze({__proto__:null,base36:l7,base36upper:u7});const d7=ua({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),f7=ua({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var p7=Object.freeze({__proto__:null,base58btc:d7,base58flickr:f7});const g7=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),b7=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),m7=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),v7=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var y7=Object.freeze({__proto__:null,base64:g7,base64pad:b7,base64url:m7,base64urlpad:v7});const rg=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),w7=rg.reduce((t,e,r)=>(t[r]=e,t),[]),_7=rg.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function x7(t){return t.reduce((e,r)=>(e+=w7[r],e),"")}function E7(t){const e=[];for(const r of t){const i=_7[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const $7=Yc({prefix:"\u{1F680}",name:"base256emoji",encode:x7,decode:E7});var I7=Object.freeze({__proto__:null,base256emoji:$7}),S7=ng,ig=128,A7=127,P7=~A7,O7=Math.pow(2,31);function ng(t,e,r){e=e||[],r=r||0;for(var i=r;t>=O7;)e[r++]=t&255|ig,t/=128;for(;t&P7;)e[r++]=t&255|ig,t>>>=7;return e[r]=t|0,ng.bytes=r-i+1,e}var C7=Wh,D7=128,sg=127;function Wh(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Wh.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&sg)<<n:(o&sg)*Math.pow(2,n),n+=7}while(o>=D7);return Wh.bytes=s-i,r}var M7=Math.pow(2,7),T7=Math.pow(2,14),R7=Math.pow(2,21),N7=Math.pow(2,28),B7=Math.pow(2,35),L7=Math.pow(2,42),F7=Math.pow(2,49),U7=Math.pow(2,56),j7=Math.pow(2,63),q7=function(t){return t<M7?1:t<T7?2:t<R7?3:t<N7?4:t<B7?5:t<L7?6:t<F7?7:t<U7?8:t<j7?9:10},z7={encode:S7,decode:C7,encodingLength:q7},og=z7;const ag=(t,e,r=0)=>(og.encode(t,e,r),e),cg=t=>og.encodingLength(t),Vh=(t,e)=>{const r=e.byteLength,i=cg(t),n=i+cg(r),s=new Uint8Array(n+r);return ag(t,s,0),ag(r,s,i),s.set(e,n),new k7(t,r,e,s)};class k7{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const lg=({name:t,code:e,encode:r})=>new H7(t,e,r);class H7{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?Vh(this.code,r):r.then(i=>Vh(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ug=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),W7=lg({name:"sha2-256",code:18,encode:ug("SHA-256")}),V7=lg({name:"sha2-512",code:19,encode:ug("SHA-512")});var K7=Object.freeze({__proto__:null,sha256:W7,sha512:V7});const hg=0,G7="identity",dg=eg;var Z7=Object.freeze({__proto__:null,identity:{code:hg,name:G7,encode:dg,digest:t=>Vh(hg,dg(t))}});new TextEncoder,new TextDecoder;const fg={...k8,...W8,...K8,...Z8,...Q8,...c7,...h7,...p7,...y7,...I7};({...K7,...Z7});function pg(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const gg=pg("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Kh=pg("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=Q1(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),bg={utf8:gg,"utf-8":gg,hex:fg.base16,latin1:Kh,ascii:Kh,binary:Kh,...fg};function Jc(t,e="utf8"){const r=bg[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 js(t,e="utf8"){const r=bg[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Hh(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function mg(t){return Fn(Jc(js(t,Zc),Z1))}function Qc(t){return Jc(js(Mi(t),Z1),Zc)}function vg(t){const e=js(O8,J1),r=P8+Jc(X1([e,t]),J1);return[S8,A8,r].join(I8)}function Y7(t){return Jc(t,Zc)}function J7(t){return js(t,Zc)}function Q7(t){return js([Qc(t.header),Qc(t.payload)].join(Gc),Y1)}function X7(t){return[Qc(t.header),Qc(t.payload),Y7(t.signature)].join(Gc)}function Gh(t){const e=t.split(Gc),r=mg(e[0]),i=mg(e[1]),n=J7(e[2]),s=js(e.slice(0,2).join(Gc),Y1);return{header:r,payload:i,signature:n,data:s}}function yg(t=O1(C8)){const e=G1.getPublicKey(t);return{secretKey:X1([t,e]),publicKey:e}}async function e9(t,e,r,i,n=V.fromMiliseconds(Date.now())){const s={alg:E8,typ:$8},o=vg(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},l=Q7({header:s,payload:c}),u=G1.sign(l,i.secretKey.slice(0,32));return X7({header:s,payload:c,signature:u})}function wg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Zh(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=wg(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function t9(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var _=0,S=0,E=0,P=m.length;E!==P&&m[E]===0;)E++,_++;for(var C=(P-E)*u+1>>>0,M=new Uint8Array(C);E!==P;){for(var R=m[E],L=0,B=C-1;(R!==0||L<S)&&B!==-1;B--,L++)R+=256*M[B]>>>0,M[B]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");S=L,E++}for(var F=C-S;F!==C&&M[F]===0;)F++;for(var T=c.repeat(_);F<C;++F)T+=t.charAt(M[F]);return T}function p(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var _=0;if(m[_]!==" "){for(var S=0,E=0;m[_]===c;)S++,_++;for(var P=(m.length-_)*l+1>>>0,C=new Uint8Array(P);m[_];){var M=r[m.charCodeAt(_)];if(M===255)return;for(var R=0,L=P-1;(M!==0||R<E)&&L!==-1;L--,R++)M+=a*C[L]>>>0,C[L]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=R,_++}if(m[_]!==" "){for(var B=P-E;B!==P&&C[B]===0;)B++;for(var F=new Uint8Array(S+(P-B)),T=S;B!==P;)F[T++]=C[B++];return F}}}function y(m){var _=p(m);if(_)return _;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:y}}var r9=t9,i9=r9;const _g=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")},n9=t=>new TextEncoder().encode(t),s9=t=>new TextDecoder().decode(t);class o9{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 a9{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 xg(this,e)}}class c9{constructor(e){this.decoders=e}or(e){return xg(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 xg=(t,e)=>new c9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class l9{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new o9(e,r,i),this.decoder=new a9(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Xc=({name:t,prefix:e,encode:r,decode:i})=>new l9(t,e,r,i),ha=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=i9(r,e);return Xc({prefix:t,name:e,encode:i,decode:s=>_g(n(s))})},u9=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},h9=(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},Ut=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Xc({prefix:e,name:t,encode(n){return h9(n,i,r)},decode(n){return u9(n,i,r,t)}}),d9=Xc({prefix:"\0",name:"identity",encode:t=>s9(t),decode:t=>n9(t)});var f9=Object.freeze({__proto__:null,identity:d9});const p9=Ut({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var g9=Object.freeze({__proto__:null,base2:p9});const b9=Ut({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var m9=Object.freeze({__proto__:null,base8:b9});const v9=ha({prefix:"9",name:"base10",alphabet:"0123456789"});var y9=Object.freeze({__proto__:null,base10:v9});const w9=Ut({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_9=Ut({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var x9=Object.freeze({__proto__:null,base16:w9,base16upper:_9});const E9=Ut({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$9=Ut({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),I9=Ut({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),S9=Ut({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A9=Ut({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),P9=Ut({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),O9=Ut({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C9=Ut({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),D9=Ut({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var M9=Object.freeze({__proto__:null,base32:E9,base32upper:$9,base32pad:I9,base32padupper:S9,base32hex:A9,base32hexupper:P9,base32hexpad:O9,base32hexpadupper:C9,base32z:D9});const T9=ha({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),R9=ha({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var N9=Object.freeze({__proto__:null,base36:T9,base36upper:R9});const B9=ha({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),L9=ha({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var F9=Object.freeze({__proto__:null,base58btc:B9,base58flickr:L9});const U9=Ut({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j9=Ut({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),q9=Ut({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),z9=Ut({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var k9=Object.freeze({__proto__:null,base64:U9,base64pad:j9,base64url:q9,base64urlpad:z9});const Eg=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),H9=Eg.reduce((t,e,r)=>(t[r]=e,t),[]),W9=Eg.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function V9(t){return t.reduce((e,r)=>(e+=H9[r],e),"")}function K9(t){const e=[];for(const r of t){const i=W9[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const G9=Xc({prefix:"\u{1F680}",name:"base256emoji",encode:V9,decode:K9});var Z9=Object.freeze({__proto__:null,base256emoji:G9}),Y9=Ig,$g=128,J9=127,Q9=~J9,X9=Math.pow(2,31);function Ig(t,e,r){e=e||[],r=r||0;for(var i=r;t>=X9;)e[r++]=t&255|$g,t/=128;for(;t&Q9;)e[r++]=t&255|$g,t>>>=7;return e[r]=t|0,Ig.bytes=r-i+1,e}var e_=Yh,t_=128,Sg=127;function Yh(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Yh.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Sg)<<n:(o&Sg)*Math.pow(2,n),n+=7}while(o>=t_);return Yh.bytes=s-i,r}var r_=Math.pow(2,7),i_=Math.pow(2,14),n_=Math.pow(2,21),s_=Math.pow(2,28),o_=Math.pow(2,35),a_=Math.pow(2,42),c_=Math.pow(2,49),l_=Math.pow(2,56),u_=Math.pow(2,63),h_=function(t){return t<r_?1:t<i_?2:t<n_?3:t<s_?4:t<o_?5:t<a_?6:t<c_?7:t<l_?8:t<u_?9:10},d_={encode:Y9,decode:e_,encodingLength:h_},Ag=d_;const Pg=(t,e,r=0)=>(Ag.encode(t,e,r),e),Og=t=>Ag.encodingLength(t),Jh=(t,e)=>{const r=e.byteLength,i=Og(t),n=i+Og(r),s=new Uint8Array(n+r);return Pg(t,s,0),Pg(r,s,i),s.set(e,n),new f_(t,r,e,s)};class f_{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Cg=({name:t,code:e,encode:r})=>new p_(t,e,r);class p_{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?Jh(this.code,r):r.then(i=>Jh(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Dg=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),g_=Cg({name:"sha2-256",code:18,encode:Dg("SHA-256")}),b_=Cg({name:"sha2-512",code:19,encode:Dg("SHA-512")});var m_=Object.freeze({__proto__:null,sha256:g_,sha512:b_});const Mg=0,v_="identity",Tg=_g;var y_=Object.freeze({__proto__:null,identity:{code:Mg,name:v_,encode:Tg,digest:t=>Jh(Mg,Tg(t))}});new TextEncoder,new TextDecoder;const Rg={...f9,...g9,...m9,...y9,...x9,...M9,...N9,...F9,...k9,...Z9};({...m_,...y_});function Ng(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Bg=Ng("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Qh=Ng("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=wg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Lg={utf8:Bg,"utf-8":Bg,hex:Rg.base16,latin1:Qh,ascii:Qh,binary:Qh,...Rg};function Sr(t,e="utf8"){const r=Lg[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 Xt(t,e="utf8"){const r=Lg[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 Fg={},w_="elliptic",__="6.6.1",x_="EC cryptography",E_="lib/elliptic.js",$_=["lib"],I_={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},S_={type:"git",url:"git@github.com:indutny/elliptic"},A_=["EC","Elliptic","curve","Cryptography"],P_="Fedor Indutny <fedor@indutny.com>",O_="MIT",C_={url:"https://github.com/indutny/elliptic/issues"},D_="https://github.com/indutny/elliptic",M_={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},T_={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},R_={name:w_,version:__,description:x_,main:E_,files:$_,scripts:I_,repository:S_,keywords:A_,author:P_,license:O_,bugs:C_,homepage:D_,devDependencies:M_,dependencies:T_},gr={},ii={exports:{}},N_={},B_=Object.freeze({__proto__:null,default:N_}),Ug=zu(B_);(function(t){(function(e,r){function i($,h){if(!$)throw new Error(h||"Assertion failed")}function n($,h){$.super_=h;var b=function(){};b.prototype=h.prototype,$.prototype=new b,$.prototype.constructor=$}function s($,h,b){if(s.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((h==="le"||h==="be")&&(b=h,h=10),this._init($||0,h||10,b||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Ug.Buffer}catch{}s.isBN=function(h){return h instanceof s?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===s.wordSize&&Array.isArray(h.words)},s.max=function(h,b){return h.cmp(b)>0?h:b},s.min=function(h,b){return h.cmp(b)<0?h:b},s.prototype._init=function(h,b,w){if(typeof h=="number")return this._initNumber(h,b,w);if(typeof h=="object")return this._initArray(h,b,w);b==="hex"&&(b=16),i(b===(b|0)&&b>=2&&b<=36),h=h.toString().replace(/\s+/g,"");var g=0;h[0]==="-"&&(g++,this.negative=1),g<h.length&&(b===16?this._parseHex(h,g,w):(this._parseBase(h,b,g),w==="le"&&this._initArray(this.toArray(),b,w)))},s.prototype._initNumber=function(h,b,w){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(i(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),w==="le"&&this._initArray(this.toArray(),b,w)},s.prototype._initArray=function(h,b,w){if(i(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var g=0;g<this.length;g++)this.words[g]=0;var v,I,O=0;if(w==="be")for(g=h.length-1,v=0;g>=0;g-=3)I=h[g]|h[g-1]<<8|h[g-2]<<16,this.words[v]|=I<<O&67108863,this.words[v+1]=I>>>26-O&67108863,O+=24,O>=26&&(O-=26,v++);else if(w==="le")for(g=0,v=0;g<h.length;g+=3)I=h[g]|h[g+1]<<8|h[g+2]<<16,this.words[v]|=I<<O&67108863,this.words[v+1]=I>>>26-O&67108863,O+=24,O>=26&&(O-=26,v++);return this.strip()};function a($,h){var b=$.charCodeAt(h);return b>=65&&b<=70?b-55:b>=97&&b<=102?b-87:b-48&15}function c($,h,b){var w=a($,b);return b-1>=h&&(w|=a($,b-1)<<4),w}s.prototype._parseHex=function(h,b,w){this.length=Math.ceil((h.length-b)/6),this.words=new Array(this.length);for(var g=0;g<this.length;g++)this.words[g]=0;var v=0,I=0,O;if(w==="be")for(g=h.length-1;g>=b;g-=2)O=c(h,b,g)<<v,this.words[I]|=O&67108863,v>=18?(v-=18,I+=1,this.words[I]|=O>>>26):v+=8;else{var x=h.length-b;for(g=x%2===0?b+1:b;g<h.length;g+=2)O=c(h,b,g)<<v,this.words[I]|=O&67108863,v>=18?(v-=18,I+=1,this.words[I]|=O>>>26):v+=8}this.strip()};function l($,h,b,w){for(var g=0,v=Math.min($.length,b),I=h;I<v;I++){var O=$.charCodeAt(I)-48;g*=w,O>=49?g+=O-49+10:O>=17?g+=O-17+10:g+=O}return g}s.prototype._parseBase=function(h,b,w){this.words=[0],this.length=1;for(var g=0,v=1;v<=67108863;v*=b)g++;g--,v=v/b|0;for(var I=h.length-w,O=I%g,x=Math.min(I,I-O)+w,f=0,A=w;A<x;A+=g)f=l(h,A,A+g,b),this.imuln(v),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(O!==0){var j=1;for(f=l(h,A,h.length,b),A=0;A<O;A++)j*=b;this.imuln(j),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this.strip()},s.prototype.copy=function(h){h.words=new Array(this.length);for(var b=0;b<this.length;b++)h.words[b]=this.words[b];h.length=this.length,h.negative=this.negative,h.red=this.red},s.prototype.clone=function(){var h=new s(null);return this.copy(h),h},s.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(h,b){h=h||10,b=b|0||1;var w;if(h===16||h==="hex"){w="";for(var g=0,v=0,I=0;I<this.length;I++){var O=this.words[I],x=((O<<g|v)&16777215).toString(16);v=O>>>24-g&16777215,g+=2,g>=26&&(g-=26,I--),v!==0||I!==this.length-1?w=u[6-x.length]+x+w:w=x+w}for(v!==0&&(w=v.toString(16)+w);w.length%b!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(h===(h|0)&&h>=2&&h<=36){var f=d[h],A=p[h];w="";var j=this.clone();for(j.negative=0;!j.isZero();){var z=j.modn(A).toString(h);j=j.idivn(A),j.isZero()?w=z+w:w=u[f-z.length]+z+w}for(this.isZero()&&(w="0"+w);w.length%b!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(h,b){return i(typeof o<"u"),this.toArrayLike(o,h,b)},s.prototype.toArray=function(h,b){return this.toArrayLike(Array,h,b)},s.prototype.toArrayLike=function(h,b,w){var g=this.byteLength(),v=w||Math.max(1,g);i(g<=v,"byte array longer than desired length"),i(v>0,"Requested array length <= 0"),this.strip();var I=b==="le",O=new h(v),x,f,A=this.clone();if(I){for(f=0;!A.isZero();f++)x=A.andln(255),A.iushrn(8),O[f]=x;for(;f<v;f++)O[f]=0}else{for(f=0;f<v-g;f++)O[f]=0;for(f=0;!A.isZero();f++)x=A.andln(255),A.iushrn(8),O[v-f-1]=x}return O},Math.clz32?s.prototype._countBits=function(h){return 32-Math.clz32(h)}:s.prototype._countBits=function(h){var b=h,w=0;return b>=4096&&(w+=13,b>>>=13),b>=64&&(w+=7,b>>>=7),b>=8&&(w+=4,b>>>=4),b>=2&&(w+=2,b>>>=2),w+b},s.prototype._zeroBits=function(h){if(h===0)return 26;var b=h,w=0;return(b&8191)===0&&(w+=13,b>>>=13),(b&127)===0&&(w+=7,b>>>=7),(b&15)===0&&(w+=4,b>>>=4),(b&3)===0&&(w+=2,b>>>=2),(b&1)===0&&w++,w},s.prototype.bitLength=function(){var h=this.words[this.length-1],b=this._countBits(h);return(this.length-1)*26+b};function y($){for(var h=new Array($.bitLength()),b=0;b<h.length;b++){var w=b/26|0,g=b%26;h[b]=($.words[w]&1<<g)>>>g}return h}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,b=0;b<this.length;b++){var w=this._zeroBits(this.words[b]);if(h+=w,w!==26)break}return h},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},s.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var b=0;b<h.length;b++)this.words[b]=this.words[b]|h.words[b];return this.strip()},s.prototype.ior=function(h){return i((this.negative|h.negative)===0),this.iuor(h)},s.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},s.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},s.prototype.iuand=function(h){var b;this.length>h.length?b=h:b=this;for(var w=0;w<b.length;w++)this.words[w]=this.words[w]&h.words[w];return this.length=b.length,this.strip()},s.prototype.iand=function(h){return i((this.negative|h.negative)===0),this.iuand(h)},s.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},s.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},s.prototype.iuxor=function(h){var b,w;this.length>h.length?(b=this,w=h):(b=h,w=this);for(var g=0;g<w.length;g++)this.words[g]=b.words[g]^w.words[g];if(this!==b)for(;g<b.length;g++)this.words[g]=b.words[g];return this.length=b.length,this.strip()},s.prototype.ixor=function(h){return i((this.negative|h.negative)===0),this.iuxor(h)},s.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},s.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},s.prototype.inotn=function(h){i(typeof h=="number"&&h>=0);var b=Math.ceil(h/26)|0,w=h%26;this._expand(b),w>0&&b--;for(var g=0;g<b;g++)this.words[g]=~this.words[g]&67108863;return w>0&&(this.words[g]=~this.words[g]&67108863>>26-w),this.strip()},s.prototype.notn=function(h){return this.clone().inotn(h)},s.prototype.setn=function(h,b){i(typeof h=="number"&&h>=0);var w=h/26|0,g=h%26;return this._expand(w+1),b?this.words[w]=this.words[w]|1<<g:this.words[w]=this.words[w]&~(1<<g),this.strip()},s.prototype.iadd=function(h){var b;if(this.negative!==0&&h.negative===0)return this.negative=0,b=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,b=this.isub(h),h.negative=1,b._normSign();var w,g;this.length>h.length?(w=this,g=h):(w=h,g=this);for(var v=0,I=0;I<g.length;I++)b=(w.words[I]|0)+(g.words[I]|0)+v,this.words[I]=b&67108863,v=b>>>26;for(;v!==0&&I<w.length;I++)b=(w.words[I]|0)+v,this.words[I]=b&67108863,v=b>>>26;if(this.length=w.length,v!==0)this.words[this.length]=v,this.length++;else if(w!==this)for(;I<w.length;I++)this.words[I]=w.words[I];return this},s.prototype.add=function(h){var b;return h.negative!==0&&this.negative===0?(h.negative=0,b=this.sub(h),h.negative^=1,b):h.negative===0&&this.negative!==0?(this.negative=0,b=h.sub(this),this.negative=1,b):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},s.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var b=this.iadd(h);return h.negative=1,b._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var w=this.cmp(h);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,v;w>0?(g=this,v=h):(g=h,v=this);for(var I=0,O=0;O<v.length;O++)b=(g.words[O]|0)-(v.words[O]|0)+I,I=b>>26,this.words[O]=b&67108863;for(;I!==0&&O<g.length;O++)b=(g.words[O]|0)+I,I=b>>26,this.words[O]=b&67108863;if(I===0&&O<g.length&&g!==this)for(;O<g.length;O++)this.words[O]=g.words[O];return this.length=Math.max(this.length,O),g!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(h){return this.clone().isub(h)};function m($,h,b){b.negative=h.negative^$.negative;var w=$.length+h.length|0;b.length=w,w=w-1|0;var g=$.words[0]|0,v=h.words[0]|0,I=g*v,O=I&67108863,x=I/67108864|0;b.words[0]=O;for(var f=1;f<w;f++){for(var A=x>>>26,j=x&67108863,z=Math.min(f,h.length-1),U=Math.max(0,f-$.length+1);U<=z;U++){var k=f-U|0;g=$.words[k]|0,v=h.words[U]|0,I=g*v+j,A+=I/67108864|0,j=I&67108863}b.words[f]=j|0,x=A|0}return x!==0?b.words[f]=x|0:b.length--,b.strip()}var _=function(h,b,w){var g=h.words,v=b.words,I=w.words,O=0,x,f,A,j=g[0]|0,z=j&8191,U=j>>>13,k=g[1]|0,Z=k&8191,X=k>>>13,ee=g[2]|0,Q=ee&8191,re=ee>>>13,Ze=g[3]|0,oe=Ze&8191,fe=Ze>>>13,$t=g[4]|0,xe=$t&8191,qe=$t>>>13,Go=g[5]|0,ze=Go&8191,Be=Go>>>13,vs=g[6]|0,De=vs&8191,Le=vs>>>13,ys=g[7]|0,Fe=ys&8191,Ue=ys>>>13,ws=g[8]|0,Ae=ws&8191,Me=ws>>>13,_s=g[9]|0,pe=_s&8191,Ye=_s>>>13,uc=v[0]|0,st=uc&8191,Je=uc>>>13,xs=v[1]|0,Qe=xs&8191,Xe=xs>>>13,Mu=v[2]|0,Se=Mu&8191,et=Mu>>>13,Tu=v[3]|0,ot=Tu&8191,ke=Tu>>>13,Pn=v[4]|0,He=Pn&8191,We=Pn>>>13,Zo=v[5]|0,Te=Zo&8191,at=Zo>>>13,Ru=v[6]|0,ct=Ru&8191,lt=Ru>>>13,Nu=v[7]|0,tt=Nu&8191,Ve=Nu>>>13,Ai=v[8]|0,ut=Ai&8191,ht=Ai>>>13,Bu=v[9]|0,dt=Bu&8191,ft=Bu>>>13;w.negative=h.negative^b.negative,w.length=19,x=Math.imul(z,st),f=Math.imul(z,Je),f=f+Math.imul(U,st)|0,A=Math.imul(U,Je);var Er=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(Er>>>26)|0,Er&=67108863,x=Math.imul(Z,st),f=Math.imul(Z,Je),f=f+Math.imul(X,st)|0,A=Math.imul(X,Je),x=x+Math.imul(z,Qe)|0,f=f+Math.imul(z,Xe)|0,f=f+Math.imul(U,Qe)|0,A=A+Math.imul(U,Xe)|0;var hc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(hc>>>26)|0,hc&=67108863,x=Math.imul(Q,st),f=Math.imul(Q,Je),f=f+Math.imul(re,st)|0,A=Math.imul(re,Je),x=x+Math.imul(Z,Qe)|0,f=f+Math.imul(Z,Xe)|0,f=f+Math.imul(X,Qe)|0,A=A+Math.imul(X,Xe)|0,x=x+Math.imul(z,Se)|0,f=f+Math.imul(z,et)|0,f=f+Math.imul(U,Se)|0,A=A+Math.imul(U,et)|0;var dc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(dc>>>26)|0,dc&=67108863,x=Math.imul(oe,st),f=Math.imul(oe,Je),f=f+Math.imul(fe,st)|0,A=Math.imul(fe,Je),x=x+Math.imul(Q,Qe)|0,f=f+Math.imul(Q,Xe)|0,f=f+Math.imul(re,Qe)|0,A=A+Math.imul(re,Xe)|0,x=x+Math.imul(Z,Se)|0,f=f+Math.imul(Z,et)|0,f=f+Math.imul(X,Se)|0,A=A+Math.imul(X,et)|0,x=x+Math.imul(z,ot)|0,f=f+Math.imul(z,ke)|0,f=f+Math.imul(U,ot)|0,A=A+Math.imul(U,ke)|0;var fc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(fc>>>26)|0,fc&=67108863,x=Math.imul(xe,st),f=Math.imul(xe,Je),f=f+Math.imul(qe,st)|0,A=Math.imul(qe,Je),x=x+Math.imul(oe,Qe)|0,f=f+Math.imul(oe,Xe)|0,f=f+Math.imul(fe,Qe)|0,A=A+Math.imul(fe,Xe)|0,x=x+Math.imul(Q,Se)|0,f=f+Math.imul(Q,et)|0,f=f+Math.imul(re,Se)|0,A=A+Math.imul(re,et)|0,x=x+Math.imul(Z,ot)|0,f=f+Math.imul(Z,ke)|0,f=f+Math.imul(X,ot)|0,A=A+Math.imul(X,ke)|0,x=x+Math.imul(z,He)|0,f=f+Math.imul(z,We)|0,f=f+Math.imul(U,He)|0,A=A+Math.imul(U,We)|0;var pc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(pc>>>26)|0,pc&=67108863,x=Math.imul(ze,st),f=Math.imul(ze,Je),f=f+Math.imul(Be,st)|0,A=Math.imul(Be,Je),x=x+Math.imul(xe,Qe)|0,f=f+Math.imul(xe,Xe)|0,f=f+Math.imul(qe,Qe)|0,A=A+Math.imul(qe,Xe)|0,x=x+Math.imul(oe,Se)|0,f=f+Math.imul(oe,et)|0,f=f+Math.imul(fe,Se)|0,A=A+Math.imul(fe,et)|0,x=x+Math.imul(Q,ot)|0,f=f+Math.imul(Q,ke)|0,f=f+Math.imul(re,ot)|0,A=A+Math.imul(re,ke)|0,x=x+Math.imul(Z,He)|0,f=f+Math.imul(Z,We)|0,f=f+Math.imul(X,He)|0,A=A+Math.imul(X,We)|0,x=x+Math.imul(z,Te)|0,f=f+Math.imul(z,at)|0,f=f+Math.imul(U,Te)|0,A=A+Math.imul(U,at)|0;var gc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(gc>>>26)|0,gc&=67108863,x=Math.imul(De,st),f=Math.imul(De,Je),f=f+Math.imul(Le,st)|0,A=Math.imul(Le,Je),x=x+Math.imul(ze,Qe)|0,f=f+Math.imul(ze,Xe)|0,f=f+Math.imul(Be,Qe)|0,A=A+Math.imul(Be,Xe)|0,x=x+Math.imul(xe,Se)|0,f=f+Math.imul(xe,et)|0,f=f+Math.imul(qe,Se)|0,A=A+Math.imul(qe,et)|0,x=x+Math.imul(oe,ot)|0,f=f+Math.imul(oe,ke)|0,f=f+Math.imul(fe,ot)|0,A=A+Math.imul(fe,ke)|0,x=x+Math.imul(Q,He)|0,f=f+Math.imul(Q,We)|0,f=f+Math.imul(re,He)|0,A=A+Math.imul(re,We)|0,x=x+Math.imul(Z,Te)|0,f=f+Math.imul(Z,at)|0,f=f+Math.imul(X,Te)|0,A=A+Math.imul(X,at)|0,x=x+Math.imul(z,ct)|0,f=f+Math.imul(z,lt)|0,f=f+Math.imul(U,ct)|0,A=A+Math.imul(U,lt)|0;var Jr=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,x=Math.imul(Fe,st),f=Math.imul(Fe,Je),f=f+Math.imul(Ue,st)|0,A=Math.imul(Ue,Je),x=x+Math.imul(De,Qe)|0,f=f+Math.imul(De,Xe)|0,f=f+Math.imul(Le,Qe)|0,A=A+Math.imul(Le,Xe)|0,x=x+Math.imul(ze,Se)|0,f=f+Math.imul(ze,et)|0,f=f+Math.imul(Be,Se)|0,A=A+Math.imul(Be,et)|0,x=x+Math.imul(xe,ot)|0,f=f+Math.imul(xe,ke)|0,f=f+Math.imul(qe,ot)|0,A=A+Math.imul(qe,ke)|0,x=x+Math.imul(oe,He)|0,f=f+Math.imul(oe,We)|0,f=f+Math.imul(fe,He)|0,A=A+Math.imul(fe,We)|0,x=x+Math.imul(Q,Te)|0,f=f+Math.imul(Q,at)|0,f=f+Math.imul(re,Te)|0,A=A+Math.imul(re,at)|0,x=x+Math.imul(Z,ct)|0,f=f+Math.imul(Z,lt)|0,f=f+Math.imul(X,ct)|0,A=A+Math.imul(X,lt)|0,x=x+Math.imul(z,tt)|0,f=f+Math.imul(z,Ve)|0,f=f+Math.imul(U,tt)|0,A=A+Math.imul(U,Ve)|0;var bc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(bc>>>26)|0,bc&=67108863,x=Math.imul(Ae,st),f=Math.imul(Ae,Je),f=f+Math.imul(Me,st)|0,A=Math.imul(Me,Je),x=x+Math.imul(Fe,Qe)|0,f=f+Math.imul(Fe,Xe)|0,f=f+Math.imul(Ue,Qe)|0,A=A+Math.imul(Ue,Xe)|0,x=x+Math.imul(De,Se)|0,f=f+Math.imul(De,et)|0,f=f+Math.imul(Le,Se)|0,A=A+Math.imul(Le,et)|0,x=x+Math.imul(ze,ot)|0,f=f+Math.imul(ze,ke)|0,f=f+Math.imul(Be,ot)|0,A=A+Math.imul(Be,ke)|0,x=x+Math.imul(xe,He)|0,f=f+Math.imul(xe,We)|0,f=f+Math.imul(qe,He)|0,A=A+Math.imul(qe,We)|0,x=x+Math.imul(oe,Te)|0,f=f+Math.imul(oe,at)|0,f=f+Math.imul(fe,Te)|0,A=A+Math.imul(fe,at)|0,x=x+Math.imul(Q,ct)|0,f=f+Math.imul(Q,lt)|0,f=f+Math.imul(re,ct)|0,A=A+Math.imul(re,lt)|0,x=x+Math.imul(Z,tt)|0,f=f+Math.imul(Z,Ve)|0,f=f+Math.imul(X,tt)|0,A=A+Math.imul(X,Ve)|0,x=x+Math.imul(z,ut)|0,f=f+Math.imul(z,ht)|0,f=f+Math.imul(U,ut)|0,A=A+Math.imul(U,ht)|0;var mc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(mc>>>26)|0,mc&=67108863,x=Math.imul(pe,st),f=Math.imul(pe,Je),f=f+Math.imul(Ye,st)|0,A=Math.imul(Ye,Je),x=x+Math.imul(Ae,Qe)|0,f=f+Math.imul(Ae,Xe)|0,f=f+Math.imul(Me,Qe)|0,A=A+Math.imul(Me,Xe)|0,x=x+Math.imul(Fe,Se)|0,f=f+Math.imul(Fe,et)|0,f=f+Math.imul(Ue,Se)|0,A=A+Math.imul(Ue,et)|0,x=x+Math.imul(De,ot)|0,f=f+Math.imul(De,ke)|0,f=f+Math.imul(Le,ot)|0,A=A+Math.imul(Le,ke)|0,x=x+Math.imul(ze,He)|0,f=f+Math.imul(ze,We)|0,f=f+Math.imul(Be,He)|0,A=A+Math.imul(Be,We)|0,x=x+Math.imul(xe,Te)|0,f=f+Math.imul(xe,at)|0,f=f+Math.imul(qe,Te)|0,A=A+Math.imul(qe,at)|0,x=x+Math.imul(oe,ct)|0,f=f+Math.imul(oe,lt)|0,f=f+Math.imul(fe,ct)|0,A=A+Math.imul(fe,lt)|0,x=x+Math.imul(Q,tt)|0,f=f+Math.imul(Q,Ve)|0,f=f+Math.imul(re,tt)|0,A=A+Math.imul(re,Ve)|0,x=x+Math.imul(Z,ut)|0,f=f+Math.imul(Z,ht)|0,f=f+Math.imul(X,ut)|0,A=A+Math.imul(X,ht)|0,x=x+Math.imul(z,dt)|0,f=f+Math.imul(z,ft)|0,f=f+Math.imul(U,dt)|0,A=A+Math.imul(U,ft)|0;var vc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(vc>>>26)|0,vc&=67108863,x=Math.imul(pe,Qe),f=Math.imul(pe,Xe),f=f+Math.imul(Ye,Qe)|0,A=Math.imul(Ye,Xe),x=x+Math.imul(Ae,Se)|0,f=f+Math.imul(Ae,et)|0,f=f+Math.imul(Me,Se)|0,A=A+Math.imul(Me,et)|0,x=x+Math.imul(Fe,ot)|0,f=f+Math.imul(Fe,ke)|0,f=f+Math.imul(Ue,ot)|0,A=A+Math.imul(Ue,ke)|0,x=x+Math.imul(De,He)|0,f=f+Math.imul(De,We)|0,f=f+Math.imul(Le,He)|0,A=A+Math.imul(Le,We)|0,x=x+Math.imul(ze,Te)|0,f=f+Math.imul(ze,at)|0,f=f+Math.imul(Be,Te)|0,A=A+Math.imul(Be,at)|0,x=x+Math.imul(xe,ct)|0,f=f+Math.imul(xe,lt)|0,f=f+Math.imul(qe,ct)|0,A=A+Math.imul(qe,lt)|0,x=x+Math.imul(oe,tt)|0,f=f+Math.imul(oe,Ve)|0,f=f+Math.imul(fe,tt)|0,A=A+Math.imul(fe,Ve)|0,x=x+Math.imul(Q,ut)|0,f=f+Math.imul(Q,ht)|0,f=f+Math.imul(re,ut)|0,A=A+Math.imul(re,ht)|0,x=x+Math.imul(Z,dt)|0,f=f+Math.imul(Z,ft)|0,f=f+Math.imul(X,dt)|0,A=A+Math.imul(X,ft)|0;var yc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(yc>>>26)|0,yc&=67108863,x=Math.imul(pe,Se),f=Math.imul(pe,et),f=f+Math.imul(Ye,Se)|0,A=Math.imul(Ye,et),x=x+Math.imul(Ae,ot)|0,f=f+Math.imul(Ae,ke)|0,f=f+Math.imul(Me,ot)|0,A=A+Math.imul(Me,ke)|0,x=x+Math.imul(Fe,He)|0,f=f+Math.imul(Fe,We)|0,f=f+Math.imul(Ue,He)|0,A=A+Math.imul(Ue,We)|0,x=x+Math.imul(De,Te)|0,f=f+Math.imul(De,at)|0,f=f+Math.imul(Le,Te)|0,A=A+Math.imul(Le,at)|0,x=x+Math.imul(ze,ct)|0,f=f+Math.imul(ze,lt)|0,f=f+Math.imul(Be,ct)|0,A=A+Math.imul(Be,lt)|0,x=x+Math.imul(xe,tt)|0,f=f+Math.imul(xe,Ve)|0,f=f+Math.imul(qe,tt)|0,A=A+Math.imul(qe,Ve)|0,x=x+Math.imul(oe,ut)|0,f=f+Math.imul(oe,ht)|0,f=f+Math.imul(fe,ut)|0,A=A+Math.imul(fe,ht)|0,x=x+Math.imul(Q,dt)|0,f=f+Math.imul(Q,ft)|0,f=f+Math.imul(re,dt)|0,A=A+Math.imul(re,ft)|0;var wc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(wc>>>26)|0,wc&=67108863,x=Math.imul(pe,ot),f=Math.imul(pe,ke),f=f+Math.imul(Ye,ot)|0,A=Math.imul(Ye,ke),x=x+Math.imul(Ae,He)|0,f=f+Math.imul(Ae,We)|0,f=f+Math.imul(Me,He)|0,A=A+Math.imul(Me,We)|0,x=x+Math.imul(Fe,Te)|0,f=f+Math.imul(Fe,at)|0,f=f+Math.imul(Ue,Te)|0,A=A+Math.imul(Ue,at)|0,x=x+Math.imul(De,ct)|0,f=f+Math.imul(De,lt)|0,f=f+Math.imul(Le,ct)|0,A=A+Math.imul(Le,lt)|0,x=x+Math.imul(ze,tt)|0,f=f+Math.imul(ze,Ve)|0,f=f+Math.imul(Be,tt)|0,A=A+Math.imul(Be,Ve)|0,x=x+Math.imul(xe,ut)|0,f=f+Math.imul(xe,ht)|0,f=f+Math.imul(qe,ut)|0,A=A+Math.imul(qe,ht)|0,x=x+Math.imul(oe,dt)|0,f=f+Math.imul(oe,ft)|0,f=f+Math.imul(fe,dt)|0,A=A+Math.imul(fe,ft)|0;var On=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(On>>>26)|0,On&=67108863,x=Math.imul(pe,He),f=Math.imul(pe,We),f=f+Math.imul(Ye,He)|0,A=Math.imul(Ye,We),x=x+Math.imul(Ae,Te)|0,f=f+Math.imul(Ae,at)|0,f=f+Math.imul(Me,Te)|0,A=A+Math.imul(Me,at)|0,x=x+Math.imul(Fe,ct)|0,f=f+Math.imul(Fe,lt)|0,f=f+Math.imul(Ue,ct)|0,A=A+Math.imul(Ue,lt)|0,x=x+Math.imul(De,tt)|0,f=f+Math.imul(De,Ve)|0,f=f+Math.imul(Le,tt)|0,A=A+Math.imul(Le,Ve)|0,x=x+Math.imul(ze,ut)|0,f=f+Math.imul(ze,ht)|0,f=f+Math.imul(Be,ut)|0,A=A+Math.imul(Be,ht)|0,x=x+Math.imul(xe,dt)|0,f=f+Math.imul(xe,ft)|0,f=f+Math.imul(qe,dt)|0,A=A+Math.imul(qe,ft)|0;var _c=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(_c>>>26)|0,_c&=67108863,x=Math.imul(pe,Te),f=Math.imul(pe,at),f=f+Math.imul(Ye,Te)|0,A=Math.imul(Ye,at),x=x+Math.imul(Ae,ct)|0,f=f+Math.imul(Ae,lt)|0,f=f+Math.imul(Me,ct)|0,A=A+Math.imul(Me,lt)|0,x=x+Math.imul(Fe,tt)|0,f=f+Math.imul(Fe,Ve)|0,f=f+Math.imul(Ue,tt)|0,A=A+Math.imul(Ue,Ve)|0,x=x+Math.imul(De,ut)|0,f=f+Math.imul(De,ht)|0,f=f+Math.imul(Le,ut)|0,A=A+Math.imul(Le,ht)|0,x=x+Math.imul(ze,dt)|0,f=f+Math.imul(ze,ft)|0,f=f+Math.imul(Be,dt)|0,A=A+Math.imul(Be,ft)|0;var xc=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(xc>>>26)|0,xc&=67108863,x=Math.imul(pe,ct),f=Math.imul(pe,lt),f=f+Math.imul(Ye,ct)|0,A=Math.imul(Ye,lt),x=x+Math.imul(Ae,tt)|0,f=f+Math.imul(Ae,Ve)|0,f=f+Math.imul(Me,tt)|0,A=A+Math.imul(Me,Ve)|0,x=x+Math.imul(Fe,ut)|0,f=f+Math.imul(Fe,ht)|0,f=f+Math.imul(Ue,ut)|0,A=A+Math.imul(Ue,ht)|0,x=x+Math.imul(De,dt)|0,f=f+Math.imul(De,ft)|0,f=f+Math.imul(Le,dt)|0,A=A+Math.imul(Le,ft)|0;var Br=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(Br>>>26)|0,Br&=67108863,x=Math.imul(pe,tt),f=Math.imul(pe,Ve),f=f+Math.imul(Ye,tt)|0,A=Math.imul(Ye,Ve),x=x+Math.imul(Ae,ut)|0,f=f+Math.imul(Ae,ht)|0,f=f+Math.imul(Me,ut)|0,A=A+Math.imul(Me,ht)|0,x=x+Math.imul(Fe,dt)|0,f=f+Math.imul(Fe,ft)|0,f=f+Math.imul(Ue,dt)|0,A=A+Math.imul(Ue,ft)|0;var Ec=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+(Ec>>>26)|0,Ec&=67108863,x=Math.imul(pe,ut),f=Math.imul(pe,ht),f=f+Math.imul(Ye,ut)|0,A=Math.imul(Ye,ht),x=x+Math.imul(Ae,dt)|0,f=f+Math.imul(Ae,ft)|0,f=f+Math.imul(Me,dt)|0,A=A+Math.imul(Me,ft)|0;var $c=(O+x|0)+((f&8191)<<13)|0;O=(A+(f>>>13)|0)+($c>>>26)|0,$c&=67108863,x=Math.imul(pe,dt),f=Math.imul(pe,ft),f=f+Math.imul(Ye,dt)|0,A=Math.imul(Ye,ft);var Ic=(O+x|0)+((f&8191)<<13)|0;return O=(A+(f>>>13)|0)+(Ic>>>26)|0,Ic&=67108863,I[0]=Er,I[1]=hc,I[2]=dc,I[3]=fc,I[4]=pc,I[5]=gc,I[6]=Jr,I[7]=bc,I[8]=mc,I[9]=vc,I[10]=yc,I[11]=wc,I[12]=On,I[13]=_c,I[14]=xc,I[15]=Br,I[16]=Ec,I[17]=$c,I[18]=Ic,O!==0&&(I[19]=O,w.length++),w};Math.imul||(_=m);function S($,h,b){b.negative=h.negative^$.negative,b.length=$.length+h.length;for(var w=0,g=0,v=0;v<b.length-1;v++){var I=g;g=0;for(var O=w&67108863,x=Math.min(v,h.length-1),f=Math.max(0,v-$.length+1);f<=x;f++){var A=v-f,j=$.words[A]|0,z=h.words[f]|0,U=j*z,k=U&67108863;I=I+(U/67108864|0)|0,k=k+O|0,O=k&67108863,I=I+(k>>>26)|0,g+=I>>>26,I&=67108863}b.words[v]=O,w=I,I=g}return w!==0?b.words[v]=w:b.length--,b.strip()}function E($,h,b){var w=new P;return w.mulp($,h,b)}s.prototype.mulTo=function(h,b){var w,g=this.length+h.length;return this.length===10&&h.length===10?w=_(this,h,b):g<63?w=m(this,h,b):g<1024?w=S(this,h,b):w=E(this,h,b),w};function P($,h){this.x=$,this.y=h}P.prototype.makeRBT=function(h){for(var b=new Array(h),w=s.prototype._countBits(h)-1,g=0;g<h;g++)b[g]=this.revBin(g,w,h);return b},P.prototype.revBin=function(h,b,w){if(h===0||h===w-1)return h;for(var g=0,v=0;v<b;v++)g|=(h&1)<<b-v-1,h>>=1;return g},P.prototype.permute=function(h,b,w,g,v,I){for(var O=0;O<I;O++)g[O]=b[h[O]],v[O]=w[h[O]]},P.prototype.transform=function(h,b,w,g,v,I){this.permute(I,h,b,w,g,v);for(var O=1;O<v;O<<=1)for(var x=O<<1,f=Math.cos(2*Math.PI/x),A=Math.sin(2*Math.PI/x),j=0;j<v;j+=x)for(var z=f,U=A,k=0;k<O;k++){var Z=w[j+k],X=g[j+k],ee=w[j+k+O],Q=g[j+k+O],re=z*ee-U*Q;Q=z*Q+U*ee,ee=re,w[j+k]=Z+ee,g[j+k]=X+Q,w[j+k+O]=Z-ee,g[j+k+O]=X-Q,k!==x&&(re=f*z-A*U,U=f*U+A*z,z=re)}},P.prototype.guessLen13b=function(h,b){var w=Math.max(b,h)|1,g=w&1,v=0;for(w=w/2|0;w;w=w>>>1)v++;return 1<<v+1+g},P.prototype.conjugate=function(h,b,w){if(!(w<=1))for(var g=0;g<w/2;g++){var v=h[g];h[g]=h[w-g-1],h[w-g-1]=v,v=b[g],b[g]=-b[w-g-1],b[w-g-1]=-v}},P.prototype.normalize13b=function(h,b){for(var w=0,g=0;g<b/2;g++){var v=Math.round(h[2*g+1]/b)*8192+Math.round(h[2*g]/b)+w;h[g]=v&67108863,v<67108864?w=0:w=v/67108864|0}return h},P.prototype.convert13b=function(h,b,w,g){for(var v=0,I=0;I<b;I++)v=v+(h[I]|0),w[2*I]=v&8191,v=v>>>13,w[2*I+1]=v&8191,v=v>>>13;for(I=2*b;I<g;++I)w[I]=0;i(v===0),i((v&-8192)===0)},P.prototype.stub=function(h){for(var b=new Array(h),w=0;w<h;w++)b[w]=0;return b},P.prototype.mulp=function(h,b,w){var g=2*this.guessLen13b(h.length,b.length),v=this.makeRBT(g),I=this.stub(g),O=new Array(g),x=new Array(g),f=new Array(g),A=new Array(g),j=new Array(g),z=new Array(g),U=w.words;U.length=g,this.convert13b(h.words,h.length,O,g),this.convert13b(b.words,b.length,A,g),this.transform(O,I,x,f,g,v),this.transform(A,I,j,z,g,v);for(var k=0;k<g;k++){var Z=x[k]*j[k]-f[k]*z[k];f[k]=x[k]*z[k]+f[k]*j[k],x[k]=Z}return this.conjugate(x,f,g),this.transform(x,f,U,I,g,v),this.conjugate(U,I,g),this.normalize13b(U,g),w.negative=h.negative^b.negative,w.length=h.length+b.length,w.strip()},s.prototype.mul=function(h){var b=new s(null);return b.words=new Array(this.length+h.length),this.mulTo(h,b)},s.prototype.mulf=function(h){var b=new s(null);return b.words=new Array(this.length+h.length),E(this,h,b)},s.prototype.imul=function(h){return this.clone().mulTo(h,this)},s.prototype.imuln=function(h){i(typeof h=="number"),i(h<67108864);for(var b=0,w=0;w<this.length;w++){var g=(this.words[w]|0)*h,v=(g&67108863)+(b&67108863);b>>=26,b+=g/67108864|0,b+=v>>>26,this.words[w]=v&67108863}return b!==0&&(this.words[w]=b,this.length++),this},s.prototype.muln=function(h){return this.clone().imuln(h)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(h){var b=y(h);if(b.length===0)return new s(1);for(var w=this,g=0;g<b.length&&b[g]===0;g++,w=w.sqr());if(++g<b.length)for(var v=w.sqr();g<b.length;g++,v=v.sqr())b[g]!==0&&(w=w.mul(v));return w},s.prototype.iushln=function(h){i(typeof h=="number"&&h>=0);var b=h%26,w=(h-b)/26,g=67108863>>>26-b<<26-b,v;if(b!==0){var I=0;for(v=0;v<this.length;v++){var O=this.words[v]&g,x=(this.words[v]|0)-O<<b;this.words[v]=x|I,I=O>>>26-b}I&&(this.words[v]=I,this.length++)}if(w!==0){for(v=this.length-1;v>=0;v--)this.words[v+w]=this.words[v];for(v=0;v<w;v++)this.words[v]=0;this.length+=w}return this.strip()},s.prototype.ishln=function(h){return i(this.negative===0),this.iushln(h)},s.prototype.iushrn=function(h,b,w){i(typeof h=="number"&&h>=0);var g;b?g=(b-b%26)/26:g=0;var v=h%26,I=Math.min((h-v)/26,this.length),O=67108863^67108863>>>v<<v,x=w;if(g-=I,g=Math.max(0,g),x){for(var f=0;f<I;f++)x.words[f]=this.words[f];x.length=I}if(I!==0)if(this.length>I)for(this.length-=I,f=0;f<this.length;f++)this.words[f]=this.words[f+I];else this.words[0]=0,this.length=1;var A=0;for(f=this.length-1;f>=0&&(A!==0||f>=g);f--){var j=this.words[f]|0;this.words[f]=A<<26-v|j>>>v,A=j&O}return x&&A!==0&&(x.words[x.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(h,b,w){return i(this.negative===0),this.iushrn(h,b,w)},s.prototype.shln=function(h){return this.clone().ishln(h)},s.prototype.ushln=function(h){return this.clone().iushln(h)},s.prototype.shrn=function(h){return this.clone().ishrn(h)},s.prototype.ushrn=function(h){return this.clone().iushrn(h)},s.prototype.testn=function(h){i(typeof h=="number"&&h>=0);var b=h%26,w=(h-b)/26,g=1<<b;if(this.length<=w)return!1;var v=this.words[w];return!!(v&g)},s.prototype.imaskn=function(h){i(typeof h=="number"&&h>=0);var b=h%26,w=(h-b)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(b!==0&&w++,this.length=Math.min(w,this.length),b!==0){var g=67108863^67108863>>>b<<b;this.words[this.length-1]&=g}return this.strip()},s.prototype.maskn=function(h){return this.clone().imaskn(h)},s.prototype.iaddn=function(h){return i(typeof h=="number"),i(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},s.prototype._iaddn=function(h){this.words[0]+=h;for(var b=0;b<this.length&&this.words[b]>=67108864;b++)this.words[b]-=67108864,b===this.length-1?this.words[b+1]=1:this.words[b+1]++;return this.length=Math.max(this.length,b+1),this},s.prototype.isubn=function(h){if(i(typeof h=="number"),i(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var b=0;b<this.length&&this.words[b]<0;b++)this.words[b]+=67108864,this.words[b+1]-=1;return this.strip()},s.prototype.addn=function(h){return this.clone().iaddn(h)},s.prototype.subn=function(h){return this.clone().isubn(h)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(h,b,w){var g=h.length+w,v;this._expand(g);var I,O=0;for(v=0;v<h.length;v++){I=(this.words[v+w]|0)+O;var x=(h.words[v]|0)*b;I-=x&67108863,O=(I>>26)-(x/67108864|0),this.words[v+w]=I&67108863}for(;v<this.length-w;v++)I=(this.words[v+w]|0)+O,O=I>>26,this.words[v+w]=I&67108863;if(O===0)return this.strip();for(i(O===-1),O=0,v=0;v<this.length;v++)I=-(this.words[v]|0)+O,O=I>>26,this.words[v]=I&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(h,b){var w=this.length-h.length,g=this.clone(),v=h,I=v.words[v.length-1]|0,O=this._countBits(I);w=26-O,w!==0&&(v=v.ushln(w),g.iushln(w),I=v.words[v.length-1]|0);var x=g.length-v.length,f;if(b!=="mod"){f=new s(null),f.length=x+1,f.words=new Array(f.length);for(var A=0;A<f.length;A++)f.words[A]=0}var j=g.clone()._ishlnsubmul(v,1,x);j.negative===0&&(g=j,f&&(f.words[x]=1));for(var z=x-1;z>=0;z--){var U=(g.words[v.length+z]|0)*67108864+(g.words[v.length+z-1]|0);for(U=Math.min(U/I|0,67108863),g._ishlnsubmul(v,U,z);g.negative!==0;)U--,g.negative=0,g._ishlnsubmul(v,1,z),g.isZero()||(g.negative^=1);f&&(f.words[z]=U)}return f&&f.strip(),g.strip(),b!=="div"&&w!==0&&g.iushrn(w),{div:f||null,mod:g}},s.prototype.divmod=function(h,b,w){if(i(!h.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var g,v,I;return this.negative!==0&&h.negative===0?(I=this.neg().divmod(h,b),b!=="mod"&&(g=I.div.neg()),b!=="div"&&(v=I.mod.neg(),w&&v.negative!==0&&v.iadd(h)),{div:g,mod:v}):this.negative===0&&h.negative!==0?(I=this.divmod(h.neg(),b),b!=="mod"&&(g=I.div.neg()),{div:g,mod:I.mod}):(this.negative&h.negative)!==0?(I=this.neg().divmod(h.neg(),b),b!=="div"&&(v=I.mod.neg(),w&&v.negative!==0&&v.isub(h)),{div:I.div,mod:v}):h.length>this.length||this.cmp(h)<0?{div:new s(0),mod:this}:h.length===1?b==="div"?{div:this.divn(h.words[0]),mod:null}:b==="mod"?{div:null,mod:new s(this.modn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new s(this.modn(h.words[0]))}:this._wordDiv(h,b)},s.prototype.div=function(h){return this.divmod(h,"div",!1).div},s.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},s.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},s.prototype.divRound=function(h){var b=this.divmod(h);if(b.mod.isZero())return b.div;var w=b.div.negative!==0?b.mod.isub(h):b.mod,g=h.ushrn(1),v=h.andln(1),I=w.cmp(g);return I<0||v===1&&I===0?b.div:b.div.negative!==0?b.div.isubn(1):b.div.iaddn(1)},s.prototype.modn=function(h){i(h<=67108863);for(var b=(1<<26)%h,w=0,g=this.length-1;g>=0;g--)w=(b*w+(this.words[g]|0))%h;return w},s.prototype.idivn=function(h){i(h<=67108863);for(var b=0,w=this.length-1;w>=0;w--){var g=(this.words[w]|0)+b*67108864;this.words[w]=g/h|0,b=g%h}return this.strip()},s.prototype.divn=function(h){return this.clone().idivn(h)},s.prototype.egcd=function(h){i(h.negative===0),i(!h.isZero());var b=this,w=h.clone();b.negative!==0?b=b.umod(h):b=b.clone();for(var g=new s(1),v=new s(0),I=new s(0),O=new s(1),x=0;b.isEven()&&w.isEven();)b.iushrn(1),w.iushrn(1),++x;for(var f=w.clone(),A=b.clone();!b.isZero();){for(var j=0,z=1;(b.words[0]&z)===0&&j<26;++j,z<<=1);if(j>0)for(b.iushrn(j);j-- >0;)(g.isOdd()||v.isOdd())&&(g.iadd(f),v.isub(A)),g.iushrn(1),v.iushrn(1);for(var U=0,k=1;(w.words[0]&k)===0&&U<26;++U,k<<=1);if(U>0)for(w.iushrn(U);U-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(f),O.isub(A)),I.iushrn(1),O.iushrn(1);b.cmp(w)>=0?(b.isub(w),g.isub(I),v.isub(O)):(w.isub(b),I.isub(g),O.isub(v))}return{a:I,b:O,gcd:w.iushln(x)}},s.prototype._invmp=function(h){i(h.negative===0),i(!h.isZero());var b=this,w=h.clone();b.negative!==0?b=b.umod(h):b=b.clone();for(var g=new s(1),v=new s(0),I=w.clone();b.cmpn(1)>0&&w.cmpn(1)>0;){for(var O=0,x=1;(b.words[0]&x)===0&&O<26;++O,x<<=1);if(O>0)for(b.iushrn(O);O-- >0;)g.isOdd()&&g.iadd(I),g.iushrn(1);for(var f=0,A=1;(w.words[0]&A)===0&&f<26;++f,A<<=1);if(f>0)for(w.iushrn(f);f-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);b.cmp(w)>=0?(b.isub(w),g.isub(v)):(w.isub(b),v.isub(g))}var j;return b.cmpn(1)===0?j=g:j=v,j.cmpn(0)<0&&j.iadd(h),j},s.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var b=this.clone(),w=h.clone();b.negative=0,w.negative=0;for(var g=0;b.isEven()&&w.isEven();g++)b.iushrn(1),w.iushrn(1);do{for(;b.isEven();)b.iushrn(1);for(;w.isEven();)w.iushrn(1);var v=b.cmp(w);if(v<0){var I=b;b=w,w=I}else if(v===0||w.cmpn(1)===0)break;b.isub(w)}while(!0);return w.iushln(g)},s.prototype.invm=function(h){return this.egcd(h).a.umod(h)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(h){return this.words[0]&h},s.prototype.bincn=function(h){i(typeof h=="number");var b=h%26,w=(h-b)/26,g=1<<b;if(this.length<=w)return this._expand(w+1),this.words[w]|=g,this;for(var v=g,I=w;v!==0&&I<this.length;I++){var O=this.words[I]|0;O+=v,v=O>>>26,O&=67108863,this.words[I]=O}return v!==0&&(this.words[I]=v,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(h){var b=h<0;if(this.negative!==0&&!b)return-1;if(this.negative===0&&b)return 1;this.strip();var w;if(this.length>1)w=1;else{b&&(h=-h),i(h<=67108863,"Number is too big");var g=this.words[0]|0;w=g===h?0:g<h?-1:1}return this.negative!==0?-w|0:w},s.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var b=this.ucmp(h);return this.negative!==0?-b|0:b},s.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var b=0,w=this.length-1;w>=0;w--){var g=this.words[w]|0,v=h.words[w]|0;if(g!==v){g<v?b=-1:g>v&&(b=1);break}}return b},s.prototype.gtn=function(h){return this.cmpn(h)===1},s.prototype.gt=function(h){return this.cmp(h)===1},s.prototype.gten=function(h){return this.cmpn(h)>=0},s.prototype.gte=function(h){return this.cmp(h)>=0},s.prototype.ltn=function(h){return this.cmpn(h)===-1},s.prototype.lt=function(h){return this.cmp(h)===-1},s.prototype.lten=function(h){return this.cmpn(h)<=0},s.prototype.lte=function(h){return this.cmp(h)<=0},s.prototype.eqn=function(h){return this.cmpn(h)===0},s.prototype.eq=function(h){return this.cmp(h)===0},s.red=function(h){return new T(h)},s.prototype.toRed=function(h){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(h){return this.red=h,this},s.prototype.forceRed=function(h){return i(!this.red,"Already a number in reduction context"),this._forceRed(h)},s.prototype.redAdd=function(h){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},s.prototype.redIAdd=function(h){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},s.prototype.redSub=function(h){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},s.prototype.redISub=function(h){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},s.prototype.redShl=function(h){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},s.prototype.redMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},s.prototype.redIMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(h){return i(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var C={k256:null,p224:null,p192:null,p25519:null};function M($,h){this.name=$,this.p=new s(h,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}M.prototype._tmp=function(){var h=new s(null);return h.words=new Array(Math.ceil(this.n/13)),h},M.prototype.ireduce=function(h){var b=h,w;do this.split(b,this.tmp),b=this.imulK(b),b=b.iadd(this.tmp),w=b.bitLength();while(w>this.n);var g=w<this.n?-1:b.ucmp(this.p);return g===0?(b.words[0]=0,b.length=1):g>0?b.isub(this.p):b.strip!==void 0?b.strip():b._strip(),b},M.prototype.split=function(h,b){h.iushrn(this.n,0,b)},M.prototype.imulK=function(h){return h.imul(this.k)};function R(){M.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(R,M),R.prototype.split=function(h,b){for(var w=4194303,g=Math.min(h.length,9),v=0;v<g;v++)b.words[v]=h.words[v];if(b.length=g,h.length<=9){h.words[0]=0,h.length=1;return}var I=h.words[9];for(b.words[b.length++]=I&w,v=10;v<h.length;v++){var O=h.words[v]|0;h.words[v-10]=(O&w)<<4|I>>>22,I=O}I>>>=22,h.words[v-10]=I,I===0&&h.length>10?h.length-=10:h.length-=9},R.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var b=0,w=0;w<h.length;w++){var g=h.words[w]|0;b+=g*977,h.words[w]=b&67108863,b=g*64+(b/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function L(){M.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(L,M);function B(){M.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(B,M);function F(){M.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(F,M),F.prototype.imulK=function(h){for(var b=0,w=0;w<h.length;w++){var g=(h.words[w]|0)*19+b,v=g&67108863;g>>>=26,h.words[w]=v,b=g}return b!==0&&(h.words[h.length++]=b),h},s._prime=function(h){if(C[h])return C[h];var b;if(h==="k256")b=new R;else if(h==="p224")b=new L;else if(h==="p192")b=new B;else if(h==="p25519")b=new F;else throw new Error("Unknown prime "+h);return C[h]=b,b};function T($){if(typeof $=="string"){var h=s._prime($);this.m=h.p,this.prime=h}else i($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}T.prototype._verify1=function(h){i(h.negative===0,"red works only with positives"),i(h.red,"red works only with red numbers")},T.prototype._verify2=function(h,b){i((h.negative|b.negative)===0,"red works only with positives"),i(h.red&&h.red===b.red,"red works only with red numbers")},T.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):h.umod(this.m)._forceRed(this)},T.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},T.prototype.add=function(h,b){this._verify2(h,b);var w=h.add(b);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},T.prototype.iadd=function(h,b){this._verify2(h,b);var w=h.iadd(b);return w.cmp(this.m)>=0&&w.isub(this.m),w},T.prototype.sub=function(h,b){this._verify2(h,b);var w=h.sub(b);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},T.prototype.isub=function(h,b){this._verify2(h,b);var w=h.isub(b);return w.cmpn(0)<0&&w.iadd(this.m),w},T.prototype.shl=function(h,b){return this._verify1(h),this.imod(h.ushln(b))},T.prototype.imul=function(h,b){return this._verify2(h,b),this.imod(h.imul(b))},T.prototype.mul=function(h,b){return this._verify2(h,b),this.imod(h.mul(b))},T.prototype.isqr=function(h){return this.imul(h,h.clone())},T.prototype.sqr=function(h){return this.mul(h,h)},T.prototype.sqrt=function(h){if(h.isZero())return h.clone();var b=this.m.andln(3);if(i(b%2===1),b===3){var w=this.m.add(new s(1)).iushrn(2);return this.pow(h,w)}for(var g=this.m.subn(1),v=0;!g.isZero()&&g.andln(1)===0;)v++,g.iushrn(1);i(!g.isZero());var I=new s(1).toRed(this),O=I.redNeg(),x=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);this.pow(f,x).cmp(O)!==0;)f.redIAdd(O);for(var A=this.pow(f,g),j=this.pow(h,g.addn(1).iushrn(1)),z=this.pow(h,g),U=v;z.cmp(I)!==0;){for(var k=z,Z=0;k.cmp(I)!==0;Z++)k=k.redSqr();i(Z<U);var X=this.pow(A,new s(1).iushln(U-Z-1));j=j.redMul(X),A=X.redSqr(),z=z.redMul(A),U=Z}return j},T.prototype.invm=function(h){var b=h._invmp(this.m);return b.negative!==0?(b.negative=0,this.imod(b).redNeg()):this.imod(b)},T.prototype.pow=function(h,b){if(b.isZero())return new s(1).toRed(this);if(b.cmpn(1)===0)return h.clone();var w=4,g=new Array(1<<w);g[0]=new s(1).toRed(this),g[1]=h;for(var v=2;v<g.length;v++)g[v]=this.mul(g[v-1],h);var I=g[0],O=0,x=0,f=b.bitLength()%26;for(f===0&&(f=26),v=b.length-1;v>=0;v--){for(var A=b.words[v],j=f-1;j>=0;j--){var z=A>>j&1;if(I!==g[0]&&(I=this.sqr(I)),z===0&&O===0){x=0;continue}O<<=1,O|=z,x++,!(x!==w&&(v!==0||j!==0))&&(I=this.mul(I,g[O]),x=0,O=0)}f=26}return I},T.prototype.convertTo=function(h){var b=h.umod(this.m);return b===h?b.clone():b},T.prototype.convertFrom=function(h){var b=h.clone();return b.red=null,b},s.mont=function(h){return new q(h)};function q($){T.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(q,T),q.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},q.prototype.convertFrom=function(h){var b=this.imod(h.mul(this.rinv));return b.red=null,b},q.prototype.imul=function(h,b){if(h.isZero()||b.isZero())return h.words[0]=0,h.length=1,h;var w=h.imul(b),g=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=w.isub(g).iushrn(this.shift),I=v;return v.cmp(this.m)>=0?I=v.isub(this.m):v.cmpn(0)<0&&(I=v.iadd(this.m)),I._forceRed(this)},q.prototype.mul=function(h,b){if(h.isZero()||b.isZero())return new s(0)._forceRed(this);var w=h.mul(b),g=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=w.isub(g).iushrn(this.shift),I=v;return v.cmp(this.m)>=0?I=v.isub(this.m):v.cmpn(0)<0&&(I=v.iadd(this.m)),I._forceRed(this)},q.prototype.invm=function(h){var b=this.imod(h._invmp(this.m).mul(this.r2));return b._forceRed(this)}})(t,wt)})(ii);var jn=jg;function jg(t,e){if(!t)throw new Error(e||"Assertion failed")}jg.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var Xh={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var l=s.charCodeAt(c),u=l>>8,d=l&255;u?a.push(u,d):a.push(d)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(Xh),function(t){var e=t,r=ii.exports,i=jn,n=Xh;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(u,d,p){var y=new Array(Math.max(u.bitLength(),p)+1),m;for(m=0;m<y.length;m+=1)y[m]=0;var _=1<<d+1,S=u.clone();for(m=0;m<y.length;m++){var E,P=S.andln(_-1);S.isOdd()?(P>(_>>1)-1?E=(_>>1)-P:E=P,S.isubn(E)):E=0,y[m]=E,S.iushrn(1)}return y}e.getNAF=s;function o(u,d){var p=[[],[]];u=u.clone(),d=d.clone();for(var y=0,m=0,_;u.cmpn(-y)>0||d.cmpn(-m)>0;){var S=u.andln(3)+y&3,E=d.andln(3)+m&3;S===3&&(S=-1),E===3&&(E=-1);var P;(S&1)===0?P=0:(_=u.andln(7)+y&7,(_===3||_===5)&&E===2?P=-S:P=S),p[0].push(P);var C;(E&1)===0?C=0:(_=d.andln(7)+m&7,(_===3||_===5)&&S===2?C=-E:C=E),p[1].push(C),2*y===P+1&&(y=1-y),2*m===C+1&&(m=1-m),u.iushrn(1),d.iushrn(1)}return p}e.getJSF=o;function a(u,d,p){var y="_"+d;u.prototype[d]=function(){return this[y]!==void 0?this[y]:this[y]=p.call(this)}}e.cachedProperty=a;function c(u){return typeof u=="string"?e.toArray(u,"hex"):u}e.parseBytes=c;function l(u){return new r(u,"hex","le")}e.intFromLE=l}(gr);var el={exports:{}},ed;el.exports=function(e){return ed||(ed=new nn(null)),ed.generate(e)};function nn(t){this.rand=t}if(el.exports.Rand=nn,nn.prototype.generate=function(e){return this._rand(e)},nn.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?nn.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?nn.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(nn.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var qg=Ug;if(typeof qg.randomBytes!="function")throw new Error("Not supported");nn.prototype._rand=function(e){return qg.randomBytes(e)}}catch{}var td={},qn=ii.exports,da=gr,tl=da.getNAF,L_=da.getJSF,rl=da.assert;function sn(t,e){this.type=t,this.p=new qn(e.p,16),this.red=e.prime?qn.red(e.prime):qn.mont(this.p),this.zero=new qn(0).toRed(this.red),this.one=new qn(1).toRed(this.red),this.two=new qn(2).toRed(this.red),this.n=e.n&&new qn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var il=sn;sn.prototype.point=function(){throw new Error("Not implemented")},sn.prototype.validate=function(){throw new Error("Not implemented")},sn.prototype._fixedNafMul=function(e,r){rl(e.precomputed);var i=e._getDoubles(),n=tl(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var l=a+i.step-1;l>=a;l--)c=(c<<1)+n[l];o.push(c)}for(var u=this.jpoint(null,null,null),d=this.jpoint(null,null,null),p=s;p>0;p--){for(a=0;a<o.length;a++)c=o[a],c===p?d=d.mixedAdd(i.points[a]):c===-p&&(d=d.mixedAdd(i.points[a].neg()));u=u.add(d)}return u.toP()},sn.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=tl(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var l=0;c>=0&&o[c]===0;c--)l++;if(c>=0&&l++,a=a.dblp(l),c<0)break;var u=o[c];rl(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a},sn.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,l=0,u,d,p;for(u=0;u<n;u++){p=r[u];var y=p._getNAFPoints(e);o[u]=y.wnd,a[u]=y.points}for(u=n-1;u>=1;u-=2){var m=u-1,_=u;if(o[m]!==1||o[_]!==1){c[m]=tl(i[m],o[m],this._bitLength),c[_]=tl(i[_],o[_],this._bitLength),l=Math.max(c[m].length,l),l=Math.max(c[_].length,l);continue}var S=[r[m],null,null,r[_]];r[m].y.cmp(r[_].y)===0?(S[1]=r[m].add(r[_]),S[2]=r[m].toJ().mixedAdd(r[_].neg())):r[m].y.cmp(r[_].y.redNeg())===0?(S[1]=r[m].toJ().mixedAdd(r[_]),S[2]=r[m].add(r[_].neg())):(S[1]=r[m].toJ().mixedAdd(r[_]),S[2]=r[m].toJ().mixedAdd(r[_].neg()));var E=[-3,-1,-5,-7,0,7,5,1,3],P=L_(i[m],i[_]);for(l=Math.max(P[0].length,l),c[m]=new Array(l),c[_]=new Array(l),d=0;d<l;d++){var C=P[0][d]|0,M=P[1][d]|0;c[m][d]=E[(C+1)*3+(M+1)],c[_][d]=0,a[m]=S}}var R=this.jpoint(null,null,null),L=this._wnafT4;for(u=l;u>=0;u--){for(var B=0;u>=0;){var F=!0;for(d=0;d<n;d++)L[d]=c[d][u]|0,L[d]!==0&&(F=!1);if(!F)break;B++,u--}if(u>=0&&B++,R=R.dblp(B),u<0)break;for(d=0;d<n;d++){var T=L[d];T!==0&&(T>0?p=a[d][T-1>>1]:T<0&&(p=a[d][-T-1>>1].neg()),p.type==="affine"?R=R.mixedAdd(p):R=R.add(p))}}for(u=0;u<n;u++)a[u]=null;return s?R:R.toP()};function Ar(t,e){this.curve=t,this.type=e,this.precomputed=null}sn.BasePoint=Ar,Ar.prototype.eq=function(){throw new Error("Not implemented")},Ar.prototype.validate=function(){return this.curve.validate(this)},sn.prototype.decodePoint=function(e,r){e=da.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?rl(e[e.length-1]%2===0):e[0]===7&&rl(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},Ar.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Ar.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},Ar.prototype.encode=function(e,r){return da.encode(this._encode(r),e)},Ar.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},Ar.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},Ar.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},Ar.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},Ar.prototype._getBeta=function(){return null},Ar.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var qs={exports:{}};typeof Object.create=="function"?qs.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:qs.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var F_=gr,it=ii.exports,rd=qs.exports,zs=il,U_=F_.assert;function Pr(t){zs.call(this,"short",t),this.a=new it(t.a,16).toRed(this.red),this.b=new it(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}rd(Pr,zs);var j_=Pr;Pr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new it(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new it(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],U_(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new it(a.a,16),b:new it(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},Pr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:it.mont(e),i=new it(2).toRed(r).redInvm(),n=i.redNeg(),s=new it(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},Pr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new it(1),o=new it(0),a=new it(0),c=new it(1),l,u,d,p,y,m,_,S=0,E,P;i.cmpn(0)!==0;){var C=n.div(i);E=n.sub(C.mul(i)),P=a.sub(C.mul(s));var M=c.sub(C.mul(o));if(!d&&E.cmp(r)<0)l=_.neg(),u=s,d=E.neg(),p=P;else if(d&&++S===2)break;_=E,n=i,i=E,a=s,s=P,c=o,o=M}y=E.neg(),m=P;var R=d.sqr().add(p.sqr()),L=y.sqr().add(m.sqr());return L.cmp(R)>=0&&(y=l,m=u),d.negative&&(d=d.neg(),p=p.neg()),y.negative&&(y=y.neg(),m=m.neg()),[{a:d,b:p},{a:y,b:m}]},Pr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),l=s.mul(i.b),u=o.mul(n.b),d=e.sub(a).sub(c),p=l.add(u).neg();return{k1:d,k2:p}},Pr.prototype.pointFromX=function(e,r){e=new it(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},Pr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},Pr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],l=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),l=l.neg(!0)),n[o*2]=c,n[o*2+1]=l,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),d=0;d<o*2;d++)n[d]=null,s[d]=null;return u};function Pt(t,e,r,i){zs.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new it(e,16),this.y=new it(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}rd(Pt,zs.BasePoint),Pr.prototype.point=function(e,r,i){return new Pt(this,e,r,i)},Pr.prototype.pointFromJSON=function(e,r){return Pt.fromJSON(this,e,r)},Pt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},Pt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Pt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Pt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Pt.prototype.isInfinity=function(){return this.inf},Pt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Pt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Pt.prototype.getX=function(){return this.x.fromRed()},Pt.prototype.getY=function(){return this.y.fromRed()},Pt.prototype.mul=function(e){return e=new it(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Pt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Pt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Pt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Pt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},Pt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function jt(t,e,r,i){zs.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new it(0)):(this.x=new it(e,16),this.y=new it(r,16),this.z=new it(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}rd(jt,zs.BasePoint),Pr.prototype.jpoint=function(e,r,i){return new jt(this,e,r,i)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),l=o.redSub(a);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),d=u.redMul(c),p=n.redMul(u),y=l.redSqr().redIAdd(d).redISub(p).redISub(p),m=l.redMul(p.redISub(y)).redISub(o.redMul(d)),_=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(y,m,_)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),d=i.redMul(l),p=c.redSqr().redIAdd(u).redISub(d).redISub(d),y=c.redMul(d.redISub(p)).redISub(s.redMul(u)),m=this.z.redMul(a);return this.curve.jpoint(p,y,m)},jt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,l=c.redSqr().redSqr(),u=a.redAdd(a);for(r=0;r<e;r++){var d=o.redSqr(),p=u.redSqr(),y=p.redSqr(),m=d.redAdd(d).redIAdd(d).redIAdd(n.redMul(l)),_=o.redMul(p),S=m.redSqr().redISub(_.redAdd(_)),E=_.redISub(S),P=m.redMul(E);P=P.redIAdd(P).redISub(y);var C=u.redMul(c);r+1<e&&(l=l.redMul(y)),o=S,c=C,u=P}return this.curve.jpoint(o,u.redMul(s),c)},jt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},jt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),l=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=l,r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var d=this.x.redSqr(),p=this.y.redSqr(),y=p.redSqr(),m=this.x.redAdd(p).redSqr().redISub(d).redISub(y);m=m.redIAdd(m);var _=d.redAdd(d).redIAdd(d),S=_.redSqr(),E=y.redIAdd(y);E=E.redIAdd(E),E=E.redIAdd(E),e=S.redISub(m).redISub(m),r=_.redMul(m.redISub(e)).redISub(E),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},jt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),l=c.redSqr().redISub(a).redISub(a);e=l;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),r=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var d=this.z.redSqr(),p=this.y.redSqr(),y=this.x.redMul(p),m=this.x.redSub(d).redMul(this.x.redAdd(d));m=m.redAdd(m).redIAdd(m);var _=y.redIAdd(y);_=_.redIAdd(_);var S=_.redAdd(_);e=m.redSqr().redISub(S),i=this.y.redAdd(this.z).redSqr().redISub(p).redISub(d);var E=p.redSqr();E=E.redIAdd(E),E=E.redIAdd(E),E=E.redIAdd(E),r=m.redMul(_.redISub(e)).redISub(E)}return this.curve.jpoint(e,r,i)},jt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),l=r.redAdd(r);l=l.redIAdd(l);var u=l.redMul(a),d=c.redSqr().redISub(u.redAdd(u)),p=u.redISub(d),y=a.redSqr();y=y.redIAdd(y),y=y.redIAdd(y),y=y.redIAdd(y);var m=c.redMul(p).redISub(y),_=i.redAdd(i).redMul(n);return this.curve.jpoint(d,m,_)},jt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),l=n.redIAdd(n);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(l),d=r.redMul(u);d=d.redIAdd(d),d=d.redIAdd(d);var p=this.x.redMul(c).redISub(d);p=p.redIAdd(p),p=p.redIAdd(p);var y=this.y.redMul(u.redMul(l.redISub(u)).redISub(a.redMul(c)));y=y.redIAdd(y),y=y.redIAdd(y),y=y.redIAdd(y);var m=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(p,y,m)},jt.prototype.mul=function(e,r){return e=new it(e,r),this.curve._wnafMul(this,e)},jt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},jt.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},jt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ks=ii.exports,zg=qs.exports,nl=il,q_=gr;function Hs(t){nl.call(this,"mont",t),this.a=new ks(t.a,16).toRed(this.red),this.b=new ks(t.b,16).toRed(this.red),this.i4=new ks(4).toRed(this.red).redInvm(),this.two=new ks(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}zg(Hs,nl);var z_=Hs;Hs.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function Ot(t,e,r){nl.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new ks(e,16),this.z=new ks(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}zg(Ot,nl.BasePoint),Hs.prototype.decodePoint=function(e,r){return this.point(q_.toArray(e,r),1)},Hs.prototype.point=function(e,r){return new Ot(this,e,r)},Hs.prototype.pointFromJSON=function(e){return Ot.fromJSON(this,e)},Ot.prototype.precompute=function(){},Ot.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Ot.fromJSON=function(e,r){return new Ot(e,r[0],r[1]||e.one)},Ot.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Ot.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Ot.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},Ot.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Ot.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),l=r.z.redMul(a.redAdd(c).redSqr()),u=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(l,u)},Ot.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Ot.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Ot.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Ot.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Ot.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Ot.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var k_=gr,Ni=ii.exports,kg=qs.exports,sl=il,H_=k_.assert;function ni(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,sl.call(this,"edwards",t),this.a=new Ni(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Ni(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Ni(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),H_(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}kg(ni,sl);var W_=ni;ni.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},ni.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},ni.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},ni.prototype.pointFromX=function(e,r){e=new Ni(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},ni.prototype.pointFromY=function(e,r){e=new Ni(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},ni.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function Oe(t,e,r,i,n){sl.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Ni(e,16),this.y=new Ni(r,16),this.z=i?new Ni(i,16):this.curve.one,this.t=n&&new Ni(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}kg(Oe,sl.BasePoint),ni.prototype.pointFromJSON=function(e){return Oe.fromJSON(this,e)},ni.prototype.point=function(e,r,i,n){return new Oe(this,e,r,i,n)},Oe.fromJSON=function(e,r){return new Oe(e,r[0],r[1],r[2])},Oe.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Oe.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Oe.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),l=s.redMul(a),u=o.redMul(c),d=s.redMul(c),p=a.redMul(o);return this.curve.point(l,u,p,d)},Oe.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,l;if(this.curve.twisted){a=this.curve._mulA(r);var u=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(u.redSub(this.curve.two)),s=u.redMul(a.redSub(i)),o=u.redSqr().redSub(u).redSub(u)):(c=this.z.redSqr(),l=u.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(l),s=u.redMul(a.redSub(i)),o=u.redMul(l))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),l=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(l),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(l);return this.curve.point(n,s,o)},Oe.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Oe.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),l=i.redAdd(r),u=o.redMul(a),d=c.redMul(l),p=o.redMul(l),y=a.redMul(c);return this.curve.point(u,d,y,p)},Oe.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),u=r.redMul(a).redMul(l),d,p;return this.curve.twisted?(d=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),p=a.redMul(c)):(d=r.redMul(c).redMul(s.redSub(n)),p=this.curve._mulC(a).redMul(c)),this.curve.point(u,d,p)},Oe.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Oe.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Oe.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},Oe.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},Oe.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Oe.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Oe.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Oe.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Oe.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},Oe.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},Oe.prototype.toP=Oe.prototype.normalize,Oe.prototype.mixedAdd=Oe.prototype.add,function(t){var e=t;e.base=il,e.short=j_,e.mont=z_,e.edwards=W_}(td);var ol={},al={},ce={},V_=jn,K_=qs.exports;ce.inherits=K_;function G_(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function Z_(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):G_(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}ce.toArray=Z_;function Y_(t){for(var e="",r=0;r<t.length;r++)e+=Wg(t[r].toString(16));return e}ce.toHex=Y_;function Hg(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}ce.htonl=Hg;function J_(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=Hg(n)),r+=Vg(n.toString(16))}return r}ce.toHex32=J_;function Wg(t){return t.length===1?"0"+t:t}ce.zero2=Wg;function Vg(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}ce.zero8=Vg;function Q_(t,e,r,i){var n=r-e;V_(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}ce.join32=Q_;function X_(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}ce.split32=X_;function ex(t,e){return t>>>e|t<<32-e}ce.rotr32=ex;function tx(t,e){return t<<e|t>>>32-e}ce.rotl32=tx;function rx(t,e){return t+e>>>0}ce.sum32=rx;function ix(t,e,r){return t+e+r>>>0}ce.sum32_3=ix;function nx(t,e,r,i){return t+e+r+i>>>0}ce.sum32_4=nx;function sx(t,e,r,i,n){return t+e+r+i+n>>>0}ce.sum32_5=sx;function ox(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}ce.sum64=ox;function ax(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}ce.sum64_hi=ax;function cx(t,e,r,i){var n=e+i;return n>>>0}ce.sum64_lo=cx;function lx(t,e,r,i,n,s,o,a){var c=0,l=e;l=l+i>>>0,c+=l<e?1:0,l=l+s>>>0,c+=l<s?1:0,l=l+a>>>0,c+=l<a?1:0;var u=t+r+n+o+c;return u>>>0}ce.sum64_4_hi=lx;function ux(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}ce.sum64_4_lo=ux;function hx(t,e,r,i,n,s,o,a,c,l){var u=0,d=e;d=d+i>>>0,u+=d<e?1:0,d=d+s>>>0,u+=d<s?1:0,d=d+a>>>0,u+=d<a?1:0,d=d+l>>>0,u+=d<l?1:0;var p=t+r+n+o+c+u;return p>>>0}ce.sum64_5_hi=hx;function dx(t,e,r,i,n,s,o,a,c,l){var u=e+i+s+a+l;return u>>>0}ce.sum64_5_lo=dx;function fx(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}ce.rotr64_hi=fx;function px(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ce.rotr64_lo=px;function gx(t,e,r){return t>>>r}ce.shr64_hi=gx;function bx(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ce.shr64_lo=bx;var Ws={},Kg=ce,mx=jn;function cl(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Ws.BlockHash=cl,cl.prototype.update=function(e,r){if(e=Kg.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Kg.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},cl.prototype.digest=function(e){return this.update(this._pad()),mx(this.pending===null),this._digest(e)},cl.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var Vs={},si={},vx=ce,oi=vx.rotr32;function yx(t,e,r,i){if(t===0)return Gg(e,r,i);if(t===1||t===3)return Yg(e,r,i);if(t===2)return Zg(e,r,i)}si.ft_1=yx;function Gg(t,e,r){return t&e^~t&r}si.ch32=Gg;function Zg(t,e,r){return t&e^t&r^e&r}si.maj32=Zg;function Yg(t,e,r){return t^e^r}si.p32=Yg;function wx(t){return oi(t,2)^oi(t,13)^oi(t,22)}si.s0_256=wx;function _x(t){return oi(t,6)^oi(t,11)^oi(t,25)}si.s1_256=_x;function xx(t){return oi(t,7)^oi(t,18)^t>>>3}si.g0_256=xx;function Ex(t){return oi(t,17)^oi(t,19)^t>>>10}si.g1_256=Ex;var Ks=ce,$x=Ws,Ix=si,id=Ks.rotl32,fa=Ks.sum32,Sx=Ks.sum32_5,Ax=Ix.ft_1,Jg=$x.BlockHash,Px=[1518500249,1859775393,2400959708,3395469782];function ai(){if(!(this instanceof ai))return new ai;Jg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ks.inherits(ai,Jg);var Ox=ai;ai.blockSize=512,ai.outSize=160,ai.hmacStrength=80,ai.padLength=64,ai.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=id(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4];for(n=0;n<i.length;n++){var u=~~(n/20),d=Sx(id(s,5),Ax(u,o,a,c),l,i[n],Px[u]);l=c,c=a,a=id(o,30),o=s,s=d}this.h[0]=fa(this.h[0],s),this.h[1]=fa(this.h[1],o),this.h[2]=fa(this.h[2],a),this.h[3]=fa(this.h[3],c),this.h[4]=fa(this.h[4],l)},ai.prototype._digest=function(e){return e==="hex"?Ks.toHex32(this.h,"big"):Ks.split32(this.h,"big")};var Gs=ce,Cx=Ws,Zs=si,Dx=jn,zr=Gs.sum32,Mx=Gs.sum32_4,Tx=Gs.sum32_5,Rx=Zs.ch32,Nx=Zs.maj32,Bx=Zs.s0_256,Lx=Zs.s1_256,Fx=Zs.g0_256,Ux=Zs.g1_256,Qg=Cx.BlockHash,jx=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function ci(){if(!(this instanceof ci))return new ci;Qg.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=jx,this.W=new Array(64)}Gs.inherits(ci,Qg);var Xg=ci;ci.blockSize=512,ci.outSize=256,ci.hmacStrength=192,ci.padLength=64,ci.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=Mx(Ux(i[n-2]),i[n-7],Fx(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4],u=this.h[5],d=this.h[6],p=this.h[7];for(Dx(this.k.length===i.length),n=0;n<i.length;n++){var y=Tx(p,Lx(l),Rx(l,u,d),this.k[n],i[n]),m=zr(Bx(s),Nx(s,o,a));p=d,d=u,u=l,l=zr(c,y),c=a,a=o,o=s,s=zr(y,m)}this.h[0]=zr(this.h[0],s),this.h[1]=zr(this.h[1],o),this.h[2]=zr(this.h[2],a),this.h[3]=zr(this.h[3],c),this.h[4]=zr(this.h[4],l),this.h[5]=zr(this.h[5],u),this.h[6]=zr(this.h[6],d),this.h[7]=zr(this.h[7],p)},ci.prototype._digest=function(e){return e==="hex"?Gs.toHex32(this.h,"big"):Gs.split32(this.h,"big")};var nd=ce,eb=Xg;function Bi(){if(!(this instanceof Bi))return new Bi;eb.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}nd.inherits(Bi,eb);var qx=Bi;Bi.blockSize=512,Bi.outSize=224,Bi.hmacStrength=192,Bi.padLength=64,Bi.prototype._digest=function(e){return e==="hex"?nd.toHex32(this.h.slice(0,7),"big"):nd.split32(this.h.slice(0,7),"big")};var sr=ce,zx=Ws,kx=jn,li=sr.rotr64_hi,ui=sr.rotr64_lo,tb=sr.shr64_hi,rb=sr.shr64_lo,on=sr.sum64,sd=sr.sum64_hi,od=sr.sum64_lo,Hx=sr.sum64_4_hi,Wx=sr.sum64_4_lo,Vx=sr.sum64_5_hi,Kx=sr.sum64_5_lo,ib=zx.BlockHash,Gx=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function kr(){if(!(this instanceof kr))return new kr;ib.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Gx,this.W=new Array(160)}sr.inherits(kr,ib);var nb=kr;kr.blockSize=1024,kr.outSize=512,kr.hmacStrength=192,kr.padLength=128,kr.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=sE(i[n-4],i[n-3]),o=oE(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],l=iE(i[n-30],i[n-29]),u=nE(i[n-30],i[n-29]),d=i[n-32],p=i[n-31];i[n]=Hx(s,o,a,c,l,u,d,p),i[n+1]=Wx(s,o,a,c,l,u,d,p)}},kr.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],l=this.h[5],u=this.h[6],d=this.h[7],p=this.h[8],y=this.h[9],m=this.h[10],_=this.h[11],S=this.h[12],E=this.h[13],P=this.h[14],C=this.h[15];kx(this.k.length===i.length);for(var M=0;M<i.length;M+=2){var R=P,L=C,B=tE(p,y),F=rE(p,y),T=Zx(p,y,m,_,S),q=Yx(p,y,m,_,S,E),$=this.k[M],h=this.k[M+1],b=i[M],w=i[M+1],g=Vx(R,L,B,F,T,q,$,h,b,w),v=Kx(R,L,B,F,T,q,$,h,b,w);R=Xx(n,s),L=eE(n,s),B=Jx(n,s,o,a,c),F=Qx(n,s,o,a,c,l);var I=sd(R,L,B,F),O=od(R,L,B,F);P=S,C=E,S=m,E=_,m=p,_=y,p=sd(u,d,g,v),y=od(d,d,g,v),u=c,d=l,c=o,l=a,o=n,a=s,n=sd(g,v,I,O),s=od(g,v,I,O)}on(this.h,0,n,s),on(this.h,2,o,a),on(this.h,4,c,l),on(this.h,6,u,d),on(this.h,8,p,y),on(this.h,10,m,_),on(this.h,12,S,E),on(this.h,14,P,C)},kr.prototype._digest=function(e){return e==="hex"?sr.toHex32(this.h,"big"):sr.split32(this.h,"big")};function Zx(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function Yx(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function Jx(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function Qx(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function Xx(t,e){var r=li(t,e,28),i=li(e,t,2),n=li(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function eE(t,e){var r=ui(t,e,28),i=ui(e,t,2),n=ui(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function tE(t,e){var r=li(t,e,14),i=li(t,e,18),n=li(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function rE(t,e){var r=ui(t,e,14),i=ui(t,e,18),n=ui(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function iE(t,e){var r=li(t,e,1),i=li(t,e,8),n=tb(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function nE(t,e){var r=ui(t,e,1),i=ui(t,e,8),n=rb(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function sE(t,e){var r=li(t,e,19),i=li(e,t,29),n=tb(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function oE(t,e){var r=ui(t,e,19),i=ui(e,t,29),n=rb(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var ad=ce,sb=nb;function Li(){if(!(this instanceof Li))return new Li;sb.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}ad.inherits(Li,sb);var aE=Li;Li.blockSize=1024,Li.outSize=384,Li.hmacStrength=192,Li.padLength=128,Li.prototype._digest=function(e){return e==="hex"?ad.toHex32(this.h.slice(0,12),"big"):ad.split32(this.h.slice(0,12),"big")},Vs.sha1=Ox,Vs.sha224=qx,Vs.sha256=Xg,Vs.sha384=aE,Vs.sha512=nb;var ob={},zn=ce,cE=Ws,ll=zn.rotl32,ab=zn.sum32,pa=zn.sum32_3,cb=zn.sum32_4,lb=cE.BlockHash;function hi(){if(!(this instanceof hi))return new hi;lb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}zn.inherits(hi,lb),ob.ripemd160=hi,hi.blockSize=512,hi.outSize=160,hi.hmacStrength=192,hi.padLength=64,hi.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,l=n,u=s,d=o,p=a,y=0;y<80;y++){var m=ab(ll(cb(i,ub(y,n,s,o),e[hE[y]+r],lE(y)),fE[y]),a);i=a,a=o,o=ll(s,10),s=n,n=m,m=ab(ll(cb(c,ub(79-y,l,u,d),e[dE[y]+r],uE(y)),pE[y]),p),c=p,p=d,d=ll(u,10),u=l,l=m}m=pa(this.h[1],s,d),this.h[1]=pa(this.h[2],o,p),this.h[2]=pa(this.h[3],a,c),this.h[3]=pa(this.h[4],i,l),this.h[4]=pa(this.h[0],n,u),this.h[0]=m},hi.prototype._digest=function(e){return e==="hex"?zn.toHex32(this.h,"little"):zn.split32(this.h,"little")};function ub(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function lE(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function uE(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var hE=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],dE=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],fE=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],pE=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],gE=ce,bE=jn;function Ys(t,e,r){if(!(this instanceof Ys))return new Ys(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(gE.toArray(e,r))}var mE=Ys;Ys.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),bE(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},Ys.prototype.update=function(e,r){return this.inner.update(e,r),this},Ys.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=ce,e.common=Ws,e.sha=Vs,e.ripemd=ob,e.hmac=mE,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(al);var cd,hb;function vE(){return hb||(hb=1,cd={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),cd}(function(t){var e=t,r=al,i=td,n=gr,s=n.assert;function o(l){l.type==="short"?this.curve=new i.short(l):l.type==="edwards"?this.curve=new i.edwards(l):this.curve=new i.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(l,u){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var d=new o(u);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:d}),d}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=vE()}catch{c=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(ol);var yE=al,kn=Xh,db=jn;function an(t){if(!(this instanceof an))return new an(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=kn.toArray(t.entropy,t.entropyEnc||"hex"),r=kn.toArray(t.nonce,t.nonceEnc||"hex"),i=kn.toArray(t.pers,t.persEnc||"hex");db(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var wE=an;an.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},an.prototype._hmac=function(){return new yE.hmac(this.hash,this.K)},an.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},an.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=kn.toArray(e,r),i=kn.toArray(i,n),db(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},an.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=kn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,kn.encode(o,r)};var _E=ii.exports,xE=gr,ld=xE.assert;function Kt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var EE=Kt;Kt.fromPublic=function(e,r,i){return r instanceof Kt?r:new Kt(e,{pub:r,pubEnc:i})},Kt.fromPrivate=function(e,r,i){return r instanceof Kt?r:new Kt(e,{priv:r,privEnc:i})},Kt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Kt.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},Kt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Kt.prototype._importPrivate=function(e,r){this.priv=new _E(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Kt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?ld(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&ld(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},Kt.prototype.derive=function(e){return e.validate()||ld(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Kt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Kt.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},Kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var ul=ii.exports,ud=gr,$E=ud.assert;function hl(t,e){if(t instanceof hl)return t;this._importDER(t,e)||($E(t.r&&t.s,"Signature without r or s"),this.r=new ul(t.r,16),this.s=new ul(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var IE=hl;function SE(){this.place=0}function hd(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function fb(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}hl.prototype._importDER=function(e,r){e=ud.toArray(e,r);var i=new SE;if(e[i.place++]!==48)return!1;var n=hd(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=hd(e,i);if(s===!1||(e[i.place]&128)!==0)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=hd(e,i);if(a===!1||e.length!==a+i.place||(e[i.place]&128)!==0)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new ul(o),this.s=new ul(c),this.recoveryParam=null,!0};function dd(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}hl.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=fb(r),i=fb(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];dd(n,r.length),n=n.concat(r),n.push(2),dd(n,i.length);var s=n.concat(i),o=[48];return dd(o,s.length),o=o.concat(s),ud.encode(o,e)};var Hr=ii.exports,pb=wE,AE=gr,fd=ol,PE=el.exports,Hn=AE.assert,pd=EE,dl=IE;function Or(t){if(!(this instanceof Or))return new Or(t);typeof t=="string"&&(Hn(Object.prototype.hasOwnProperty.call(fd,t),"Unknown curve "+t),t=fd[t]),t instanceof fd.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var OE=Or;Or.prototype.keyPair=function(e){return new pd(this,e)},Or.prototype.keyFromPrivate=function(e,r){return pd.fromPrivate(this,e,r)},Or.prototype.keyFromPublic=function(e,r){return pd.fromPublic(this,e,r)},Or.prototype.genKeyPair=function(e){e||(e={});for(var r=new pb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||PE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Hr(2));;){var s=new Hr(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Or.prototype._truncateToN=function(e,r,i){var n;if(Hr.isBN(e)||typeof e=="number")e=new Hr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Hr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Hr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Or.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Hr.isBN(e)){Hn(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Hn(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Hn((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),Hn(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);Hn(new Hr(c).eq(e),"Can not sign message");for(var l=new pb({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Hr(1)),d=0;;d++){var p=n.k?n.k(d):new Hr(l.generate(this.n.byteLength()));if(p=this._truncateToN(p,!0),!(p.cmpn(1)<=0||p.cmp(u)>=0)){var y=this.g.mul(p);if(!y.isInfinity()){var m=y.getX(),_=m.umod(this.n);if(_.cmpn(0)!==0){var S=p.invm(this.n).mul(_.mul(r.getPrivate()).iadd(e));if(S=S.umod(this.n),S.cmpn(0)!==0){var E=(y.getY().isOdd()?1:0)|(m.cmp(_)!==0?2:0);return n.canonical&&S.cmp(this.nh)>0&&(S=this.n.sub(S),E^=1),new dl({r:_,s:S,recoveryParam:E})}}}}}},Or.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new dl(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),l=c.mul(e).umod(this.n),u=c.mul(o).umod(this.n),d;return this.curve._maxwellTrick?(d=this.g.jmulAdd(l,i.getPublic(),u),d.isInfinity()?!1:d.eqXToP(o)):(d=this.g.mulAdd(l,i.getPublic(),u),d.isInfinity()?!1:d.getX().umod(this.n).cmp(o)===0)},Or.prototype.recoverPubKey=function(t,e,r,i){Hn((3&r)===r,"The recovery param is more than two bits"),e=new dl(e,i);var n=this.n,s=new Hr(t),o=e.r,a=e.s,c=r&1,l=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var u=e.r.invm(n),d=n.sub(s).mul(u).umod(n),p=a.mul(u).umod(n);return this.g.mulAdd(d,o,p)},Or.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new dl(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var ga=gr,gb=ga.assert,bb=ga.parseBytes,Js=ga.cachedProperty;function Ct(t,e){this.eddsa=t,this._secret=bb(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=bb(e.pub)}Ct.fromPublic=function(e,r){return r instanceof Ct?r:new Ct(e,{pub:r})},Ct.fromSecret=function(e,r){return r instanceof Ct?r:new Ct(e,{secret:r})},Ct.prototype.secret=function(){return this._secret},Js(Ct,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Js(Ct,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Js(Ct,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),Js(Ct,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Js(Ct,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Js(Ct,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Ct.prototype.sign=function(e){return gb(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Ct.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Ct.prototype.getSecret=function(e){return gb(this._secret,"KeyPair is public only"),ga.encode(this.secret(),e)},Ct.prototype.getPublic=function(e){return ga.encode(this.pubBytes(),e)};var CE=Ct,DE=ii.exports,fl=gr,mb=fl.assert,pl=fl.cachedProperty,ME=fl.parseBytes;function Wn(t,e){this.eddsa=t,typeof e!="object"&&(e=ME(e)),Array.isArray(e)&&(mb(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),mb(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof DE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}pl(Wn,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),pl(Wn,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),pl(Wn,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),pl(Wn,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Wn.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Wn.prototype.toHex=function(){return fl.encode(this.toBytes(),"hex").toUpperCase()};var TE=Wn,RE=al,NE=ol,Qs=gr,BE=Qs.assert,vb=Qs.parseBytes,yb=CE,wb=TE;function or(t){if(BE(t==="ed25519","only tested with ed25519 so far"),!(this instanceof or))return new or(t);t=NE[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=RE.sha512}var LE=or;or.prototype.sign=function(e,r){e=vb(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},or.prototype.verify=function(e,r,i){if(e=vb(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},or.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Qs.intFromLE(e.digest()).umod(this.curve.n)},or.prototype.keyFromPublic=function(e){return yb.fromPublic(this,e)},or.prototype.keyFromSecret=function(e){return yb.fromSecret(this,e)},or.prototype.makeSignature=function(e){return e instanceof wb?e:new wb(this,e)},or.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},or.prototype.decodePoint=function(e){e=Qs.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Qs.intFromLE(i);return this.curve.pointFromY(s,n)},or.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},or.prototype.decodeInt=function(e){return Qs.intFromLE(e)},or.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=R_.version,e.utils=gr,e.rand=el.exports,e.curve=td,e.curves=ol,e.ec=OE,e.eddsa=LE}(Fg);const FE={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 UE=Object.defineProperty,_b=Object.getOwnPropertySymbols,jE=Object.prototype.hasOwnProperty,qE=Object.prototype.propertyIsEnumerable,xb=(t,e,r)=>e in t?UE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zE=(t,e)=>{for(var r in e||(e={}))jE.call(e,r)&&xb(t,r,e[r]);if(_b)for(var r of _b(e))qE.call(e,r)&&xb(t,r,e[r]);return t};const kE=":";function Xs(t){const[e,r]=t.split(kE);return{namespace:e,reference:r}}function Eb(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 $b(t,e){return t.includes(":")?[t]:e.chains||[]}const HE="ReactNative",br={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},WE="js";function gl(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function cn(){return!ea()&&!!Yu()&&navigator.product===HE}function VE(){return cn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function KE(){return cn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ba(){return!gl()&&!!Yu()&&!!ea()}function ma(){return cn()?br.reactNative:gl()?br.node:ba()?br.browser:br.unknown}function Ib(){var t;try{return cn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function GE(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 Sb(){return mp()||{name:"",description:"",url:"",icons:[""]}}function ZE(){if(ma()===br.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=n3();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 YE(){var t;const e=ma();return e===br.browser?[e,((t=bp())==null?void 0:t.host)||"unknown"].join(":"):e}function Ab(t,e,r){const i=ZE(),n=YE();return[[t,e].join("-"),[WE,r].join("-"),i,n].join("/")}function JE({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=r.split("?"),u=Ab(t,e,i),d={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},p=GE(l[1]||"",d);return l[0]+"?"+p}function Vn(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Pb(t){return Object.fromEntries(t.entries())}function Ob(t){return new Map(Object.entries(t))}function Kn(t=V.FIVE_MINUTES,e){const r=V.toMiliseconds(t||V.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 l=new Error(e);o=Promise.reject(l),c(l)},r),i=a,n=c})}}function ln(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 Cb(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 QE(t){return Cb("topic",t)}function XE(t){return Cb("id",t)}function Db(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 xt(t,e){return V.fromMiliseconds((e||Date.now())+V.toMiliseconds(t))}function un(t){return Date.now()>=V.toMiliseconds(t)}function ye(t,e){return`${t}${e?`:${e}`:""}`}function bl(t=[],e=[]){return[...new Set([...t,...e])]}async function e$({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=t$(s,t,e),a=ma();if(a===br.browser){if(!((i=ea())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}r$(o)}else a===br.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function t$(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}${o$(i,!0)}`}else n=`${n}/wc?${i}`;return n}function r$(t){let e="_self";s$()?e="_top":(n$()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function i$(t,e){let r="";try{if(ba()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Mb(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Tb(){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 gd(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function n$(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function s$(){try{return window.self!==window.top}catch{return!1}}function o$(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Rb(t){return Buffer.from(t,"base64").toString("utf-8")}function a$(t){return new Promise(e=>setTimeout(e,t))}function va(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function c$(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ml(t,...e){if(!c$(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 bd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");va(t.outputLen),va(t.blockLen)}function eo(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 Nb(t,e){ml(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const vl=BigInt(2**32-1),Bb=BigInt(32);function l$(t,e=!1){return e?{h:Number(t&vl),l:Number(t>>Bb&vl)}:{h:Number(t>>Bb&vl)|0,l:Number(t&vl)|0}}function u$(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}=l$(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const h$=(t,e,r)=>t<<r|e>>>32-r,d$=(t,e,r)=>e<<r|t>>>32-r,f$=(t,e,r)=>e<<r-32|t>>>64-r,p$=(t,e,r)=>t<<r-32|e>>>64-r,to=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function g$(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function md(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function di(t,e){return t<<32-e|t>>>e}const Lb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function b$(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Fb(t){for(let e=0;e<t.length;e++)t[e]=b$(t[e])}function m$(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ro(t){return typeof t=="string"&&(t=m$(t)),ml(t),t}class vd{clone(){return this._cloneInto()}}function Ub(t){const e=i=>t().update(ro(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ya(t=32){if(to&&typeof to.getRandomValues=="function")return to.getRandomValues(new Uint8Array(t));if(to&&typeof to.randomBytes=="function")return to.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const jb=[],qb=[],zb=[],v$=BigInt(0),wa=BigInt(1),y$=BigInt(2),w$=BigInt(7),_$=BigInt(256),x$=BigInt(113);for(let t=0,e=wa,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],jb.push(2*(5*i+r)),qb.push((t+1)*(t+2)/2%64);let n=v$;for(let s=0;s<7;s++)e=(e<<wa^(e>>w$)*x$)%_$,e&y$&&(n^=wa<<(wa<<BigInt(s))-wa);zb.push(n)}const[E$,$$]=u$(zb,!0),kb=(t,e,r)=>r>32?f$(t,e,r):h$(t,e,r),Hb=(t,e,r)=>r>32?p$(t,e,r):d$(t,e,r);function I$(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,l=r[c],u=r[c+1],d=kb(l,u,1)^r[a],p=Hb(l,u,1)^r[a+1];for(let y=0;y<50;y+=10)t[o+y]^=d,t[o+y+1]^=p}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=qb[o],c=kb(n,s,a),l=Hb(n,s,a),u=jb[o];n=t[u],s=t[u+1],t[u]=c,t[u+1]=l}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]^=E$[i],t[1]^=$$[i]}r.fill(0)}class yd extends vd{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,va(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=g$(this.state)}keccak(){Lb||Fb(this.state32),I$(this.state32,this.rounds),Lb||Fb(this.state32),this.posOut=0,this.pos=0}update(e){eo(this);const{blockLen:r,state:i}=this;e=ro(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)!==0&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){eo(this,!1),ml(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 va(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Nb(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 yd(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 S$=(t,e,r)=>Ub(()=>new yd(e,t,r)),A$=S$(1,136,256/8),P$="https://rpc.walletconnect.org/v1";function Wb(t){const e=`Ethereum Signed Message:
|
|
18
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(A$(r)).toString("hex")}async function O$(t,e,r,i,n,s){switch(r.t){case"eip191":return await C$(t,e,r.s);case"eip1271":return await D$(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function C$(t,e,r){return(await C4({hash:Wb(e),signature:r})).toLowerCase()===t.toLowerCase()}async function D$(t,e,r,i,n,s){const o=Xs(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",l="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),d=Wb(e).substring(2),p=a+d+c+l+u,y=await fetch(`${s||P$}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:M$(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:p},"latest"]})}),{result:m}=await y.json();return m?m.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function M$(){return Date.now()+Math.floor(Math.random()*1e3)}var T$=Object.defineProperty,R$=Object.defineProperties,N$=Object.getOwnPropertyDescriptors,Vb=Object.getOwnPropertySymbols,B$=Object.prototype.hasOwnProperty,L$=Object.prototype.propertyIsEnumerable,Kb=(t,e,r)=>e in t?T$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,F$=(t,e)=>{for(var r in e||(e={}))B$.call(e,r)&&Kb(t,r,e[r]);if(Vb)for(var r of Vb(e))L$.call(e,r)&&Kb(t,r,e[r]);return t},U$=(t,e)=>R$(t,N$(e));const j$="did:pkh:",wd=t=>t?.split(":"),q$=t=>{const e=t&&wd(t);if(e)return t.includes(j$)?e[3]:e[1]},_d=t=>{const e=t&&wd(t);if(e)return e[2]+":"+e[3]},yl=t=>{const e=t&&wd(t);if(e)return e.pop()};async function Gb(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=Zb(n,n.iss),o=yl(n.iss);return await O$(o,s,i,_d(n.iss),r)}const Zb=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=yl(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: ${q$(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,d=t.nbf?`Not Before: ${t.nbf}`:void 0,p=t.requestId?`Request ID: ${t.requestId}`:void 0,y=t.resources?`Resources:${t.resources.map(_=>`
|
|
19
|
+
- ${_}`).join("")}`:void 0,m=wl(t.resources);if(m){const _=_a(m);n=Y$(n,_)}return[r,i,"",n,"",s,o,a,c,l,u,d,p,y].filter(_=>_!=null).join(`
|
|
20
|
+
`)};function z$(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function k$(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Gn(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 H$(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:W$(e,r,i)}}}function W$(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function Yb(t){return Gn(t),`urn:recap:${z$(t).replace(/=/g,"")}`}function _a(t){const e=k$(t.replace("urn:recap:",""));return Gn(e),e}function V$(t,e,r){const i=H$(t,e,r);return Yb(i)}function K$(t){return t&&t.includes("urn:recap:")}function G$(t,e){const r=_a(t),i=_a(e),n=Z$(r,i);return Yb(n)}function Z$(t,e){Gn(t),Gn(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,l;i.att[n]=U$(F$({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((l=e.att[n])==null?void 0:l[a])})})}),i}function Y$(t="",e){Gn(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(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,p)=>d.action.localeCompare(p.action));const l={};c.forEach(d=>{l[d.ability]||(l[d.ability]=[]),l[d.ability].push(d.action)});const u=Object.keys(l).map(d=>(n++,`(${n}) '${d}': '${l[d].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Jb(t){var e;const r=_a(t);Gn(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Qb(t){const e=_a(t);Gn(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 wl(t){if(!t)return;const e=t?.[t.length-1];return K$(e)?e:void 0}function xd(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Xb(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mr(t,...e){if(!Xb(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 em(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 J$(t,e){mr(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function tm(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const hn=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Q$=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function X$(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ed(t){if(typeof t=="string")t=X$(t);else if(Xb(t))t=$d(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function eI(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function tI(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 rI=(t,e)=>{function r(i,...n){if(mr(i),t.nonceLength!==void 0){const l=n[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?mr(l):mr(l,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&mr(n[1]);const o=e(i,...n),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");mr(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mr(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(mr(l),s&&l.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(r,t),r};function rm(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&&!iI(e))throw new Error("invalid output, must be aligned");return e}function im(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}function iI(t){return t.byteOffset%4===0}function $d(t){return Uint8Array.from(t)}function io(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const nm=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),nI=nm("expand 16-byte k"),sI=nm("expand 32-byte k"),oI=hn(nI),aI=hn(sI);function ge(t,e){return t<<e|t>>>32-e}function Id(t){return t.byteOffset%4===0}const _l=64,cI=16,sm=2**32-1,om=new Uint32Array;function lI(t,e,r,i,n,s,o,a){const c=n.length,l=new Uint8Array(_l),u=hn(l),d=Id(n)&&Id(s),p=d?hn(n):om,y=d?hn(s):om;for(let m=0;m<c;o++){if(t(e,r,i,u,o,a),o>=sm)throw new Error("arx: counter overflow");const _=Math.min(_l,c-m);if(d&&_===_l){const S=m/4;if(m%4!==0)throw new Error("arx: invalid block position");for(let E=0,P;E<cI;E++)P=S+E,y[P]=p[P]^u[E];m+=_l;continue}for(let S=0,E;S<_;S++)E=m+S,s[E]=n[E]^l[S];m+=_}}function uI(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=eI({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return xd(n),xd(o),tm(s),tm(r),(a,c,l,u,d=0)=>{mr(a),mr(c),mr(l);const p=l.length;if(u===void 0&&(u=new Uint8Array(p)),mr(u),xd(d),d<0||d>=sm)throw new Error("arx: counter overflow");if(u.length<p)throw new Error(`arx: output (${u.length}) is shorter than data (${p})`);const y=[];let m=a.length,_,S;if(m===32)y.push(_=$d(a)),S=aI;else if(m===16&&r)_=new Uint8Array(32),_.set(a),_.set(a,16),S=oI,y.push(_);else throw new Error(`arx: invalid 32-byte key, got length=${m}`);Id(c)||y.push(c=$d(c));const E=hn(_);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(S,E,hn(c.subarray(0,16)),E),c=c.subarray(16)}const P=16-n;if(P!==c.length)throw new Error(`arx: nonce must be ${P} or 16 bytes`);if(P!==12){const M=new Uint8Array(12);M.set(c,s?0:12-c.length),c=M,y.push(c)}const C=hn(c);return lI(t,S,E,C,l,u,d,o),io(...y),u}}const qt=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class hI{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=Ed(e),mr(e,32);const r=qt(e,0),i=qt(e,2),n=qt(e,4),s=qt(e,6),o=qt(e,8),a=qt(e,10),c=qt(e,12),l=qt(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|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=qt(e,16+2*u)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],d=o[4],p=o[5],y=o[6],m=o[7],_=o[8],S=o[9],E=qt(e,r+0),P=qt(e,r+2),C=qt(e,r+4),M=qt(e,r+6),R=qt(e,r+8),L=qt(e,r+10),B=qt(e,r+12),F=qt(e,r+14);let T=s[0]+(E&8191),q=s[1]+((E>>>13|P<<3)&8191),$=s[2]+((P>>>10|C<<6)&8191),h=s[3]+((C>>>7|M<<9)&8191),b=s[4]+((M>>>4|R<<12)&8191),w=s[5]+(R>>>1&8191),g=s[6]+((R>>>14|L<<2)&8191),v=s[7]+((L>>>11|B<<5)&8191),I=s[8]+((B>>>8|F<<8)&8191),O=s[9]+(F>>>5|n),x=0,f=x+T*a+q*(5*S)+$*(5*_)+h*(5*m)+b*(5*y);x=f>>>13,f&=8191,f+=w*(5*p)+g*(5*d)+v*(5*u)+I*(5*l)+O*(5*c),x+=f>>>13,f&=8191;let A=x+T*c+q*a+$*(5*S)+h*(5*_)+b*(5*m);x=A>>>13,A&=8191,A+=w*(5*y)+g*(5*p)+v*(5*d)+I*(5*u)+O*(5*l),x+=A>>>13,A&=8191;let j=x+T*l+q*c+$*a+h*(5*S)+b*(5*_);x=j>>>13,j&=8191,j+=w*(5*m)+g*(5*y)+v*(5*p)+I*(5*d)+O*(5*u),x+=j>>>13,j&=8191;let z=x+T*u+q*l+$*c+h*a+b*(5*S);x=z>>>13,z&=8191,z+=w*(5*_)+g*(5*m)+v*(5*y)+I*(5*p)+O*(5*d),x+=z>>>13,z&=8191;let U=x+T*d+q*u+$*l+h*c+b*a;x=U>>>13,U&=8191,U+=w*(5*S)+g*(5*_)+v*(5*m)+I*(5*y)+O*(5*p),x+=U>>>13,U&=8191;let k=x+T*p+q*d+$*u+h*l+b*c;x=k>>>13,k&=8191,k+=w*a+g*(5*S)+v*(5*_)+I*(5*m)+O*(5*y),x+=k>>>13,k&=8191;let Z=x+T*y+q*p+$*d+h*u+b*l;x=Z>>>13,Z&=8191,Z+=w*c+g*a+v*(5*S)+I*(5*_)+O*(5*m),x+=Z>>>13,Z&=8191;let X=x+T*m+q*y+$*p+h*d+b*u;x=X>>>13,X&=8191,X+=w*l+g*c+v*a+I*(5*S)+O*(5*_),x+=X>>>13,X&=8191;let ee=x+T*_+q*m+$*y+h*p+b*d;x=ee>>>13,ee&=8191,ee+=w*u+g*l+v*c+I*a+O*(5*S),x+=ee>>>13,ee&=8191;let Q=x+T*S+q*_+$*m+h*y+b*p;x=Q>>>13,Q&=8191,Q+=w*d+g*u+v*l+I*c+O*a,x+=Q>>>13,Q&=8191,x=(x<<2)+x|0,x=x+f|0,f=x&8191,x=x>>>13,A+=x,s[0]=f,s[1]=A,s[2]=j,s[3]=z,s[4]=U,s[5]=k,s[6]=Z,s[7]=X,s[8]=ee,s[9]=Q}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;io(i)}update(e){em(this);const{buffer:r,blockLen:i}=this;e=Ed(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(){io(this.h,this.r,this.buffer,this.pad)}digestInto(e){em(this),J$(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 dI(t){const e=(i,n)=>t(n).update(Ed(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const fI=dI(t=>new hI(t));function pI(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],d=e[1],p=e[2],y=e[3],m=e[4],_=e[5],S=e[6],E=e[7],P=n,C=r[0],M=r[1],R=r[2],L=o,B=a,F=c,T=l,q=u,$=d,h=p,b=y,w=m,g=_,v=S,I=E,O=P,x=C,f=M,A=R;for(let z=0;z<s;z+=2)L=L+q|0,O=ge(O^L,16),w=w+O|0,q=ge(q^w,12),L=L+q|0,O=ge(O^L,8),w=w+O|0,q=ge(q^w,7),B=B+$|0,x=ge(x^B,16),g=g+x|0,$=ge($^g,12),B=B+$|0,x=ge(x^B,8),g=g+x|0,$=ge($^g,7),F=F+h|0,f=ge(f^F,16),v=v+f|0,h=ge(h^v,12),F=F+h|0,f=ge(f^F,8),v=v+f|0,h=ge(h^v,7),T=T+b|0,A=ge(A^T,16),I=I+A|0,b=ge(b^I,12),T=T+b|0,A=ge(A^T,8),I=I+A|0,b=ge(b^I,7),L=L+$|0,A=ge(A^L,16),v=v+A|0,$=ge($^v,12),L=L+$|0,A=ge(A^L,8),v=v+A|0,$=ge($^v,7),B=B+h|0,O=ge(O^B,16),I=I+O|0,h=ge(h^I,12),B=B+h|0,O=ge(O^B,8),I=I+O|0,h=ge(h^I,7),F=F+b|0,x=ge(x^F,16),w=w+x|0,b=ge(b^w,12),F=F+b|0,x=ge(x^F,8),w=w+x|0,b=ge(b^w,7),T=T+q|0,f=ge(f^T,16),g=g+f|0,q=ge(q^g,12),T=T+q|0,f=ge(f^T,8),g=g+f|0,q=ge(q^g,7);let j=0;i[j++]=o+L|0,i[j++]=a+B|0,i[j++]=c+F|0,i[j++]=l+T|0,i[j++]=u+q|0,i[j++]=d+$|0,i[j++]=p+h|0,i[j++]=y+b|0,i[j++]=m+w|0,i[j++]=_+g|0,i[j++]=S+v|0,i[j++]=E+I|0,i[j++]=P+O|0,i[j++]=C+x|0,i[j++]=M+f|0,i[j++]=R+A|0}const gI=uI(pI,{counterRight:!1,counterLength:4,allowShortKeys:!1}),bI=new Uint8Array(16),am=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(bI.subarray(r))},mI=new Uint8Array(32);function cm(t,e,r,i,n){const s=t(e,r,mI),o=fI.create(s);n&&am(o,n),am(o,i);const a=new Uint8Array(16),c=Q$(a);im(c,0,BigInt(n?n.length:0),!0),im(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return io(s,a),l}const vI=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=rm(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=cm(t,e,r,a,i);return s.set(c,o),io(c),s},decrypt(n,s){s=rm(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=cm(t,e,r,o,i);if(!tI(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),io(c),s}}),lm=rI({blockSize:64,nonceLength:12,tagLength:16},vI(gI));class um extends vd{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,bd(e);const i=ro(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 eo(this),this.iHash.update(e),this}digestInto(e){eo(this),ml(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 Sd=(t,e,r)=>new um(t,e).update(r).digest();Sd.create=(t,e)=>new um(t,e);function yI(t,e,r){return bd(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Sd(t,ro(r),ro(e))}const Ad=new Uint8Array([0]),hm=new Uint8Array;function wI(t,e,r,i=32){if(bd(t),va(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=hm);const s=new Uint8Array(n*t.outputLen),o=Sd.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<n;l++)Ad[0]=l+1,a.update(l===0?hm:c).update(r).update(Ad).digestInto(c),s.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Ad.fill(0),s.slice(0,i)}const _I=(t,e,r,i,n)=>wI(t,yI(t,e,r),i,n);function xI(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,l=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+l,a,i)}function EI(t,e,r){return t&e^~t&r}function $I(t,e,r){return t&e^t&r^e&r}class II extends vd{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=md(this.buffer)}update(e){eo(this);const{view:r,buffer:i,blockLen:n}=this;e=ro(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=md(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){eo(this),Nb(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 d=o;d<n;d++)r[d]=0;xI(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=md(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],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 SI=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]),dn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fn=new Uint32Array(64);class AI extends II{constructor(){super(64,32,8,!1),this.A=dn[0]|0,this.B=dn[1]|0,this.C=dn[2]|0,this.D=dn[3]|0,this.E=dn[4]|0,this.F=dn[5]|0,this.G=dn[6]|0,this.H=dn[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 d=0;d<16;d++,r+=4)fn[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){const p=fn[d-15],y=fn[d-2],m=di(p,7)^di(p,18)^p>>>3,_=di(y,17)^di(y,19)^y>>>10;fn[d]=_+fn[d-7]+m+fn[d-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const p=di(a,6)^di(a,11)^di(a,25),y=u+p+EI(a,c,l)+SI[d]+fn[d]|0,m=(di(i,2)^di(i,13)^di(i,22))+$I(i,n,s)|0;u=l,l=c,c=a,a=o+y|0,o=s,s=n,n=i,i=y+m|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,l=l+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,l,u)}roundClean(){fn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const xl=Ub(()=>new AI);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dm=BigInt(0);function Pd(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fm(t){if(!Pd(t))throw new Error("Uint8Array expected")}const PI=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function OI(t){fm(t);let e="";for(let r=0;r<t.length;r++)e+=PI[t[r]];return e}function CI(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?dm:BigInt("0x"+t)}const Fi={_0:48,_9:57,A:65,F:70,a:97,f:102};function pm(t){if(t>=Fi._0&&t<=Fi._9)return t-Fi._0;if(t>=Fi.A&&t<=Fi.F)return t-(Fi.A-10);if(t>=Fi.a&&t<=Fi.f)return t-(Fi.a-10)}function gm(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=pm(t.charCodeAt(s)),a=pm(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 bm(t){return fm(t),CI(OI(Uint8Array.from(t).reverse()))}function DI(t,e){return gm(t.toString(16).padStart(e*2,"0"))}function MI(t,e){return DI(t,e).reverse()}function mm(t,e,r){let i;if(typeof e=="string")try{i=gm(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Pd(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}const Od=t=>typeof t=="bigint"&&dm<=t;function TI(t,e,r){return Od(t)&&Od(e)&&Od(r)&&e<=t&&t<r}function vm(t,e,r,i){if(!TI(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const RI={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"||Pd(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 NI(t,e,r={}){const i=(n,s,o)=>{const a=RI[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 no=BigInt(0),El=BigInt(1);function ym(t,e){const r=t%e;return r>=no?r:e+r}function BI(t,e,r){if(e<no)throw new Error("invalid exponent, negatives unsupported");if(r<=no)throw new Error("invalid modulus");if(r===El)return no;let i=El;for(;e>no;)e&El&&(i=i*t%r),t=t*t%r,e>>=El;return i}function Wr(t,e,r){let i=t;for(;e-- >no;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const so=BigInt(0),Cd=BigInt(1);function LI(t){return NI(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze(zE({},t))}function FI(t){const e=LI(t),{P:r}=e,i=P=>ym(P,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(P=>P),c=e.powPminus2||(P=>BI(P,r-BigInt(2),r));function l(P,C,M){const R=i(P*(C-M));return C=i(C-R),M=i(M+R),[C,M]}const u=(e.a-BigInt(2))/BigInt(4);function d(P,C){vm("u",P,so,r),vm("scalar",C,so,r);const M=C,R=P;let L=Cd,B=so,F=P,T=Cd,q=so,$;for(let b=BigInt(n-1);b>=so;b--){const w=M>>b&Cd;q^=w,$=l(q,L,F),L=$[0],F=$[1],$=l(q,B,T),B=$[0],T=$[1],q=w;const g=L+B,v=i(g*g),I=L-B,O=i(I*I),x=v-O,f=F+T,A=F-T,j=i(A*g),z=i(f*I),U=j+z,k=j-z;F=i(U*U),T=i(R*i(k*k)),L=i(v*O),B=i(x*(v+i(u*x)))}$=l(q,L,F),L=$[0],F=$[1],$=l(q,B,T),B=$[0],T=$[1];const h=c(B);return i(L*h)}function p(P){return MI(i(P),s)}function y(P){const C=mm("u coordinate",P,s);return o===32&&(C[31]&=127),bm(C)}function m(P){const C=mm("scalar",P),M=C.length;if(M!==s&&M!==o){let R=""+s+" or "+o;throw new Error("invalid scalar, expected "+R+" bytes, got "+M)}return bm(a(C))}function _(P,C){const M=y(C),R=m(P),L=d(M,R);if(L===so)throw new Error("invalid private or public key received");return p(L)}const S=p(e.Gu);function E(P){return _(P,S)}return{scalarMult:_,scalarMultBase:E,getSharedSecret:(P,C)=>_(P,C),getPublicKey:P=>E(P),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}const Dd=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const UI=BigInt(1),wm=BigInt(2),jI=BigInt(3),qI=BigInt(5);BigInt(8);function zI(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Dd,o=t*t%s*t%s,a=Wr(o,wm,s)*o%s,c=Wr(a,UI,s)*t%s,l=Wr(c,qI,s)*c%s,u=Wr(l,e,s)*l%s,d=Wr(u,r,s)*u%s,p=Wr(d,i,s)*d%s,y=Wr(p,n,s)*p%s,m=Wr(y,n,s)*p%s,_=Wr(m,e,s)*l%s;return{pow_p_5_8:Wr(_,wm,s)*t%s,b2:o}}function kI(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Md=FI({P:Dd,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Dd,{pow_p_5_8:r,b2:i}=zI(t);return ym(Wr(r,jI,e)*i,e)},adjustScalarBytes:kI,randomBytes:ya}),_m="base10",Gt="base16",pn="base64pad",xa="base64url",Ea="utf8",xm=0,Ui=1,$a=2,HI=0,Em=1,Ia=12,Td=32;function WI(){const t=Md.utils.randomPrivateKey(),e=Md.getPublicKey(t);return{privateKey:Xt(t,Gt),publicKey:Xt(e,Gt)}}function Rd(){const t=ya(Td);return Xt(t,Gt)}function VI(t,e){const r=Md.getSharedSecret(Sr(t,Gt),Sr(e,Gt)),i=_I(xl,r,void 0,void 0,Td);return Xt(i,Gt)}function $l(t){const e=xl(Sr(t,Gt));return Xt(e,Gt)}function ji(t){const e=xl(Sr(t,Ea));return Xt(e,Gt)}function $m(t){return Sr(`${t}`,_m)}function Zn(t){return Number(Xt(t,_m))}function KI(t){const e=$m(typeof t.type<"u"?t.type:xm);if(Zn(e)===Ui&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Sr(t.senderPublicKey,Gt):void 0,i=typeof t.iv<"u"?Sr(t.iv,Gt):ya(Ia),n=Sr(t.symKey,Gt),s=lm(n,i).encrypt(Sr(t.message,Ea));return Im({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function GI(t){const e=Sr(t.symKey,Gt),{sealed:r,iv:i}=Sa(t),n=lm(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return Xt(n,Ea)}function ZI(t,e){const r=$m($a),i=ya(Ia),n=Sr(t,Ea);return Im({type:r,sealed:n,iv:i,encoding:e})}function YI(t,e){const{sealed:r}=Sa({encoded:t,encoding:e});return Xt(r,Ea)}function Im(t){const{encoding:e=pn}=t;if(Zn(t.type)===$a)return Xt(Zh([t.type,t.sealed]),e);if(Zn(t.type)===Ui){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Xt(Zh([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Xt(Zh([t.type,t.iv,t.sealed]),e)}function Sa(t){const{encoded:e,encoding:r=pn}=t,i=Sr(e,r),n=i.slice(HI,Em),s=Em;if(Zn(n)===Ui){const l=s+Td,u=l+Ia,d=i.slice(s,l),p=i.slice(l,u),y=i.slice(u);return{type:n,sealed:y,iv:p,senderPublicKey:d}}if(Zn(n)===$a){const l=i.slice(s),u=ya(Ia);return{type:n,sealed:l,iv:u}}const o=s+Ia,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function JI(t,e){const r=Sa({encoded:t,encoding:e?.encoding});return Sm({type:Zn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Xt(r.senderPublicKey,Gt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Sm(t){const e=t?.type||xm;if(e===Ui){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 Am(t){return t.type===Ui&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Pm(t){return t.type===$a}function QI(t){return new Fg.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function XI(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function eS(t){return Buffer.from(XI(t),"base64")}function tS(t,e){const[r,i,n]=t.split("."),s=eS(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,l=xl(c),u=QI(e),d=Xt(l,Gt);if(!u.verify(d,{r:o,s:a}))throw new Error("Invalid signature");return Gh(t).payload}const rS="irn";function Il(t){return t?.relay||{protocol:rS}}function Aa(t){const e=FE[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function iS(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 Om(t){if(!t.includes("wc:")){const l=Rb(t);l!=null&&l.includes("wc:")&&(t=l)}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((l,u)=>{a[u]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:nS(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:iS(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function nS(t){return t.startsWith("//")?t.substring(2):t}function sS(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 Cm(t){const e=new URLSearchParams,r=sS(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 Sl(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function oo(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function oS(t){const e=[];return Object.values(t).forEach(r=>{e.push(...oo(r.accounts))}),e}function aS(t,e){const r=[];return Object.values(t).forEach(i=>{oo(i.accounts).includes(e)&&r.push(...i.methods)}),r}function cS(t,e){const r=[];return Object.values(t).forEach(i=>{oo(i.accounts).includes(e)&&r.push(...i.events)}),r}function Nd(t){return t.includes(":")}function Pa(t){return Nd(t)?t.split(":")[0]:t}function lS(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 Dm(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=lS(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=bl(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const uS={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}},hS={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 K(t,e){const{message:r,code:i}=hS[t];return{message:e?`${r} ${e}`:r,code:i}}function _e(t,e){const{message:r,code:i}=uS[t];return{message:e?`${r} ${e}`:r,code:i}}function fi(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Oa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function er(t){return typeof t>"u"}function mt(t,e){return e&&er(t)?!0:typeof t=="string"&&!!t.trim().length}function Bd(t,e){return e&&er(t)?!0:typeof t=="number"&&!isNaN(t)}function dS(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return Vn(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=oo(a),d=r[o];(!Vn($b(o,d),u)||!Vn(d.methods,c)||!Vn(d.events,l))&&(s=!1)}),s):!1}function Al(t){return mt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function fS(t){if(mt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Al(r)}}return!1}function pS(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(mt(t,!1)){if(e(t))return!0;const r=Rb(t);return e(r)}}catch{}return!1}function gS(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function bS(t){return t?.topic}function mS(t,e){let r=null;return mt(t?.publicKey,!1)||(r=K("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Mm(t){let e=!0;return fi(t)?t.length&&(e=t.every(r=>mt(r,!1))):e=!1,e}function vS(t,e,r){let i=null;return fi(e)&&e.length?e.forEach(n=>{i||Al(n)||(i=_e("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Al(t)||(i=_e("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 yS(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=vS(n,$b(n,s),`${e} ${r}`);o&&(i=o)}),i}function wS(t,e){let r=null;return fi(t)?t.forEach(i=>{r||fS(i)||(r=_e("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=_e("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function _S(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=wS(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function xS(t,e){let r=null;return Mm(t?.methods)?Mm(t?.events)||(r=_e("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=_e("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Tm(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=xS(i,`${e}, namespace`);n&&(r=n)}),r}function ES(t,e,r){let i=null;if(t&&Oa(t)){const n=Tm(t,e);n&&(i=n);const s=yS(t,e,r);s&&(i=s)}else i=K("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Ld(t,e){let r=null;if(t&&Oa(t)){const i=Tm(t,e);i&&(r=i);const n=_S(t,e);n&&(r=n)}else r=K("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Rm(t){return mt(t.protocol,!0)}function $S(t,e){let r=!1;return e&&!t?r=!0:t&&fi(t)&&t.length&&t.forEach(i=>{r=Rm(i)}),r}function IS(t){return typeof t=="number"}function ar(t){return typeof t<"u"&&typeof t!==null}function SS(t){return!(!t||typeof t!="object"||!t.code||!Bd(t.code,!1)||!t.message||!mt(t.message,!1))}function AS(t){return!(er(t)||!mt(t.method,!1))}function PS(t){return!(er(t)||er(t.result)&&er(t.error)||!Bd(t.id,!1)||!mt(t.jsonrpc,!1))}function OS(t){return!(er(t)||!mt(t.name,!1))}function Nm(t,e){return!(!Al(e)||!oS(t).includes(e))}function CS(t,e,r){return mt(r,!1)?aS(t,e).includes(r):!1}function DS(t,e,r){return mt(r,!1)?cS(t,e).includes(r):!1}function Bm(t,e,r){let i=null;const n=MS(t),s=TS(e),o=Object.keys(n),a=Object.keys(s),c=Lm(Object.keys(t)),l=Lm(Object.keys(e)),u=c.filter(d=>!l.includes(d));return u.length&&(i=K("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
25
21
|
Required: ${u.toString()}
|
|
26
|
-
Received: ${Object.keys(e).toString()}`)),
|
|
22
|
+
Received: ${Object.keys(e).toString()}`)),Vn(o,a)||(i=K("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
27
23
|
Required: ${o.toString()}
|
|
28
|
-
Approved: ${a.toString()}`)),Object.keys(e).forEach(
|
|
29
|
-
Required: ${
|
|
30
|
-
Approved: ${x.toString()}`))}),o.forEach(m=>{i||(Es(n[m].methods,s[m].methods)?Es(n[m].events,s[m].events)||(i=ee("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${m}`)):i=ee("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${m}`))}),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 Cv(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function HE(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const i=So(t[r].accounts);i?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function WE(t,e){return uu(t,!1)&&t<=e.max&&t>=e.min}function Dv(){const t=Ca();return new Promise(e=>{switch(t){case Gr.browser:e(VE());break;case Gr.reactNative:e(KE());break;case Gr.node:e(GE());break;default:e(!0)}})}function VE(){return Oa()&&navigator?.onLine}async function KE(){if(zn()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t?.isConnected}return!0}function GE(){return!0}function JE(t){switch(Ca()){case Gr.browser:ZE(t);break;case Gr.reactNative:YE(t);break}}function ZE(t){!zn()&&Oa()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function YE(t){zn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const pu={};class Ha{static get(e){return pu[e]}static set(e,r){pu[e]=r}static delete(e){delete pu[e]}}class As{}class XE extends As{constructor(e){super()}}const Rv=X.FIVE_SECONDS,Io={pulse:"heartbeat_pulse"};class gu extends XE{constructor(e){super(e),this.events=new nr.exports.EventEmitter,this.interval=Rv,this.interval=e?.interval||Rv}static async init(e){const r=new gu(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(),X.toMiliseconds(this.interval))}pulse(){this.events.emit(Io.pulse)}}const QE=/"(?:_|\\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*:/,e$=/"(?: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*:/,t$=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function r$(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){i$(t);return}return e}function i$(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function xl(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!t$.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(QE.test(t)||e$.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,r$)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function n$(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Xt(t,...e){try{return n$(t(...e))}catch(r){return Promise.reject(r)}}function s$(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function o$(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function El(t){if(s$(t))return String(t);if(o$(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return El(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const vu="base64:";function a$(t){return typeof t=="string"?t:vu+h$(t)}function c$(t){return typeof t!="string"||!t.startsWith(vu)?t:l$(t.slice(vu.length))}function l$(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function h$(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Nr(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function f$(...t){return Nr(t.join(":"))}function $l(t){return t=Nr(t),t?t+":":""}function Zk(t){return t}const u$="memory",d$=()=>{const t=new Map;return{name:u$,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 p$(t={}){const e={mounts:{"":t.driver||d$()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=l=>{for(const u of e.mountpoints)if(l.startsWith(u))return{base:u,relativeKey:l.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,u)=>e.mountpoints.filter(m=>m.startsWith(l)||u&&l.startsWith(m)).map(m=>({relativeBase:l.length>m.length?l.slice(m.length):void 0,mountpoint:m,driver:e.mounts[m]})),n=(l,u)=>{if(e.watching){u=Nr(u);for(const m of e.watchListeners)m(l,u)}},s=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Nv(e.mounts[l],n,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,u,m)=>{const x=new Map,S=E=>{let A=x.get(E.base);return A||(A={driver:E.driver,base:E.base,items:[]},x.set(E.base,A)),A};for(const E of l){const A=typeof E=="string",R=Nr(A?E:E.key),O=A?void 0:E.value,C=A||!E.options?u:{...u,...E.options},N=r(R);S(N).items.push({key:R,value:O,relativeKey:N.relativeKey,options:C})}return Promise.all([...x.values()].map(E=>m(E))).then(E=>E.flat())},c={hasItem(l,u={}){l=Nr(l);const{relativeKey:m,driver:x}=r(l);return Xt(x.hasItem,m,u)},getItem(l,u={}){l=Nr(l);const{relativeKey:m,driver:x}=r(l);return Xt(x.getItem,m,u).then(S=>xl(S))},getItems(l,u={}){return a(l,u,m=>m.driver.getItems?Xt(m.driver.getItems,m.items.map(x=>({key:x.relativeKey,options:x.options})),u).then(x=>x.map(S=>({key:f$(m.base,S.key),value:xl(S.value)}))):Promise.all(m.items.map(x=>Xt(m.driver.getItem,x.relativeKey,x.options).then(S=>({key:x.key,value:xl(S)})))))},getItemRaw(l,u={}){l=Nr(l);const{relativeKey:m,driver:x}=r(l);return x.getItemRaw?Xt(x.getItemRaw,m,u):Xt(x.getItem,m,u).then(S=>c$(S))},async setItem(l,u,m={}){if(u===void 0)return c.removeItem(l);l=Nr(l);const{relativeKey:x,driver:S}=r(l);S.setItem&&(await Xt(S.setItem,x,El(u),m),S.watch||n("update",l))},async setItems(l,u){await a(l,u,async m=>{if(m.driver.setItems)return Xt(m.driver.setItems,m.items.map(x=>({key:x.relativeKey,value:El(x.value),options:x.options})),u);m.driver.setItem&&await Promise.all(m.items.map(x=>Xt(m.driver.setItem,x.relativeKey,El(x.value),x.options)))})},async setItemRaw(l,u,m={}){if(u===void 0)return c.removeItem(l,m);l=Nr(l);const{relativeKey:x,driver:S}=r(l);if(S.setItemRaw)await Xt(S.setItemRaw,x,u,m);else if(S.setItem)await Xt(S.setItem,x,a$(u),m);else return;S.watch||n("update",l)},async removeItem(l,u={}){typeof u=="boolean"&&(u={removeMeta:u}),l=Nr(l);const{relativeKey:m,driver:x}=r(l);x.removeItem&&(await Xt(x.removeItem,m,u),(u.removeMeta||u.removeMata)&&await Xt(x.removeItem,m+"$",u),x.watch||n("remove",l))},async getMeta(l,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),l=Nr(l);const{relativeKey:m,driver:x}=r(l),S=Object.create(null);if(x.getMeta&&Object.assign(S,await Xt(x.getMeta,m,u)),!u.nativeOnly){const E=await Xt(x.getItem,m+"$",u).then(A=>xl(A));E&&typeof E=="object"&&(typeof E.atime=="string"&&(E.atime=new Date(E.atime)),typeof E.mtime=="string"&&(E.mtime=new Date(E.mtime)),Object.assign(S,E))}return S},setMeta(l,u,m={}){return this.setItem(l+"$",u,m)},removeMeta(l,u={}){return this.removeItem(l+"$",u)},async getKeys(l,u={}){l=$l(l);const m=i(l,!0);let x=[];const S=[];for(const E of m){const A=await Xt(E.driver.getKeys,E.relativeBase,u);for(const R of A){const O=E.mountpoint+Nr(R);x.some(C=>O.startsWith(C))||S.push(O)}x=[E.mountpoint,...x.filter(R=>!R.startsWith(E.mountpoint))]}return l?S.filter(E=>E.startsWith(l)&&E[E.length-1]!=="$"):S.filter(E=>E[E.length-1]!=="$")},async clear(l,u={}){l=$l(l),await Promise.all(i(l,!1).map(async m=>{if(m.driver.clear)return Xt(m.driver.clear,m.relativeBase,u);if(m.driver.removeItem){const x=await m.driver.getKeys(m.relativeBase||"",u);return Promise.all(x.map(S=>m.driver.removeItem(S,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Tv(l)))},async watch(l){return await s(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,u){if(l=$l(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((m,x)=>x.length-m.length)),e.mounts[l]=u,e.watching&&Promise.resolve(Nv(u,n,l)).then(m=>{e.unwatch[l]=m}).catch(console.error),c},async unmount(l,u=!0){l=$l(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l]?.(),delete e.unwatch[l]),u&&await Tv(e.mounts[l]),e.mountpoints=e.mountpoints.filter(m=>m!==l),delete e.mounts[l])},getMount(l=""){l=Nr(l)+":";const u=r(l);return{driver:u.driver,base:u.base}},getMounts(l="",u={}){return l=Nr(l),i(l,u.parents).map(x=>({driver:x.driver,base:x.mountpoint}))},keys:(l,u={})=>c.getKeys(l,u),get:(l,u={})=>c.getItem(l,u),set:(l,u,m={})=>c.setItem(l,u,m),has:(l,u={})=>c.hasItem(l,u),del:(l,u={})=>c.removeItem(l,u),remove:(l,u={})=>c.removeItem(l,u)};return c}function Nv(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Tv(t){typeof t.dispose=="function"&&await Xt(t.dispose)}function Ms(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Fv(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Ms(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let mu;function Wa(){return mu||(mu=Fv("keyval-store","keyval")),mu}function Lv(t,e=Wa()){return e("readonly",r=>Ms(r.get(t)))}function g$(t,e,r=Wa()){return r("readwrite",i=>(i.put(e,t),Ms(i.transaction)))}function v$(t,e=Wa()){return e("readwrite",r=>(r.delete(t),Ms(r.transaction)))}function m$(t=Wa()){return t("readwrite",e=>(e.clear(),Ms(e.transaction)))}function b$(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ms(t.transaction)}function y$(t=Wa()){return t("readonly",e=>{if(e.getAllKeys)return Ms(e.getAllKeys());const r=[];return b$(e,i=>r.push(i.key)).then(()=>r)})}const w$="idb-keyval";var _$=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Fv(t.dbName,t.storeName)),{name:w$,options:t,async hasItem(n){return!(typeof await Lv(r(n),i)>"u")},async getItem(n){return await Lv(r(n),i)??null},setItem(n,s){return g$(r(n),s,i)},removeItem(n){return v$(r(n),i)},getKeys(){return y$(i)},clear(){return m$(i)}}};const x$="WALLET_CONNECT_V2_INDEXED_DB",E$="keyvaluestorage";class $${constructor(){this.indexedDb=p$({driver:_$({dbName:x$,storeName:E$})})}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,ln(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var bu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sl={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 bu<"u"&&bu.localStorage?Sl.exports=bu.localStorage:typeof window<"u"&&window.localStorage?Sl.exports=window.localStorage:Sl.exports=new e})();function S$(t){var e;return[t[0],ms((e=t[1])!=null?e:"")]}class I${constructor(){this.localStorage=Sl.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(S$)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return ms(r)}async setItem(e,r){this.localStorage.setItem(e,ln(r))}async removeItem(e){this.localStorage.removeItem(e)}}const A$="wc_storage_version",Bv=1,M$=async(t,e,r)=>{const i=A$,n=await e.getItem(i);if(n&&n>=Bv){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 l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Bv),r(e),P$(t,o)},P$=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class O${constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new I$;this.storage=e;try{const r=new $$;M$(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)})}}function C$(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var D$=R$;function R$(t,e,r){var i=r&&r.stringify||C$,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 l="",u=1-n,m=-1,x=t&&t.length||0,S=0;S<x;){if(t.charCodeAt(S)===37&&S+1<x){switch(m=m>-1?m:0,t.charCodeAt(S+1)){case 100:case 102:if(u>=c||e[u]==null)break;m<S&&(l+=t.slice(m,S)),l+=Number(e[u]),m=S+2,S++;break;case 105:if(u>=c||e[u]==null)break;m<S&&(l+=t.slice(m,S)),l+=Math.floor(Number(e[u])),m=S+2,S++;break;case 79:case 111:case 106:if(u>=c||e[u]===void 0)break;m<S&&(l+=t.slice(m,S));var E=typeof e[u];if(E==="string"){l+="'"+e[u]+"'",m=S+2,S++;break}if(E==="function"){l+=e[u].name||"<anonymous>",m=S+2,S++;break}l+=i(e[u]),m=S+2,S++;break;case 115:if(u>=c)break;m<S&&(l+=t.slice(m,S)),l+=String(e[u]),m=S+2,S++;break;case 37:m<S&&(l+=t.slice(m,S)),l+="%",m=S+2,S++,u--;break}++u}++S}return m===-1?t:(m<x&&(l+=t.slice(m)),l)}const Uv=D$;var Vi=Ki;const Va=z$().console||{},N$={mapHttpRequest:Al,mapHttpResponse:Al,wrapRequestSerializer:wu,wrapResponseSerializer:wu,wrapErrorSerializer:wu,req:Al,res:Al,err:U$};function T$(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Ki(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||Va;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=T$(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=Ka),Object.defineProperty(c,"levelVal",{get:u}),Object.defineProperty(c,"level",{get:m,set:x});const l={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:q$(t)};c.levels=Ki.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=Ka,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=S,e&&(c._logEvent=yu());function u(){return this.level==="silent"?1/0:this.levels.values[this.level]}function m(){return this._level}function x(E){if(E!=="silent"&&!this.levels.values[E])throw Error("unknown level "+E);this._level=E,Ao(l,c,"error","log"),Ao(l,c,"fatal","error"),Ao(l,c,"warn","error"),Ao(l,c,"info","log"),Ao(l,c,"debug","log"),Ao(l,c,"trace","log")}function S(E,A){if(!E)throw new Error("missing bindings for child Pino");A=A||{},n&&E.serializers&&(A.serializers=E.serializers);const R=A.serializers;if(n&&R){var O=Object.assign({},i,R),C=t.browser.serialize===!0?Object.keys(O):n;delete E.serializers,Il([E],C,O,this._stdErrSerialize)}function N(T){this._childLevel=(T._childLevel|0)+1,this.error=Mo(T,E,"error"),this.fatal=Mo(T,E,"fatal"),this.warn=Mo(T,E,"warn"),this.info=Mo(T,E,"info"),this.debug=Mo(T,E,"debug"),this.trace=Mo(T,E,"trace"),O&&(this.serializers=O,this._serialize=C),e&&(this._logEvent=yu([].concat(T._logEvent.bindings,E)))}return N.prototype=this,new N(this)}return c}Ki.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"}},Ki.stdSerializers=N$,Ki.stdTimeFunctions=Object.assign({},{nullTime:qv,epochTime:jv,unixTime:j$,isoTime:k$});function Ao(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ka:n[r]?n[r]:Va[r]||Va[i]||Ka,F$(t,e,r)}function F$(t,e,r){!t.transmit&&e[r]===Ka||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Va?Va:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&Il(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,L$(this,r,o,s)):i.apply(a,o),t.transmit){const l=t.transmit.level||e.level,u=Ki.levels.values[l],m=Ki.levels.values[r];if(m<u)return;B$(this,{ts:s,methodLevel:r,methodValue:m,transmitLevel:l,transmitValue:Ki.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function L$(t,e,r,i){t._serialize&&Il(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Ki.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?Uv(n.shift(),n):void 0}else typeof s=="string"&&(s=Uv(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Il(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Ki.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 Mo(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 B$(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;Il(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(l){return c.indexOf(l)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=yu(c)}function yu(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function U$(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 q$(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?qv:jv}function Al(){return{}}function wu(t){return t}function Ka(){}function qv(){return!1}function jv(){return Date.now()}function j$(){return Math.round(Date.now()/1e3)}function k$(){return new Date(Date.now()).toISOString()}function z$(){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 H$={level:"info"},Ga="custom_context",_u=1e3*1024;class W${constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class kv{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new W$(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}}}}}class zv{constructor(e,r=_u){this.level=e??"error",this.levelValue=Vi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new kv(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Vi.levels.values.error?console.error(e):r===Vi.levels.values.warn?console.warn(e):r===Vi.levels.values.debug?console.debug(e):r===Vi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ln({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 kv(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(ln({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class V${constructor(e,r=_u){this.baseChunkLogger=new zv(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)}}class K${constructor(e,r=_u){this.baseChunkLogger=new zv(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 G$=Object.defineProperty,J$=Object.defineProperties,Z$=Object.getOwnPropertyDescriptors,Hv=Object.getOwnPropertySymbols,Y$=Object.prototype.hasOwnProperty,X$=Object.prototype.propertyIsEnumerable,Wv=(t,e,r)=>e in t?G$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ml=(t,e)=>{for(var r in e||(e={}))Y$.call(e,r)&&Wv(t,r,e[r]);if(Hv)for(var r of Hv(e))X$.call(e,r)&&Wv(t,r,e[r]);return t},Pl=(t,e)=>J$(t,Z$(e));function Ol(t){return Pl(Ml({},t),{level:t?.level||H$.level})}function Q$(t,e=Ga){return t[e]||""}function eS(t,e,r=Ga){return t[r]=e,t}function Tr(t,e=Ga){let r="";return typeof t.bindings>"u"?r=Q$(t,e):r=t.bindings().context||"",r}function tS(t,e,r=Ga){const i=Tr(t,r);return i.trim()?`${i}/${e}`:e}function Ir(t,e,r=Ga){const i=tS(t,e,r),n=t.child({context:i});return eS(n,i,r)}function rS(t){var e,r;const i=new V$((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Vi(Pl(Ml({},t.opts),{level:"trace",browser:Pl(Ml({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function iS(t){var e;const r=new K$((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Vi(Pl(Ml({},t.opts),{level:"trace"})),chunkLoggerController:r}}function nS(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?rS(t):iS(t)}var sS=Object.defineProperty,oS=(t,e,r)=>e in t?sS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vv=(t,e,r)=>oS(t,typeof e!="symbol"?e+"":e,r);class aS extends As{constructor(e){super(),this.opts=e,Vv(this,"protocol","wc"),Vv(this,"version",2)}}var cS=Object.defineProperty,lS=(t,e,r)=>e in t?cS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hS=(t,e,r)=>lS(t,typeof e!="symbol"?e+"":e,r);class fS extends As{constructor(e,r){super(),this.core=e,this.logger=r,hS(this,"records",new Map)}}class uS{constructor(e,r){this.logger=e,this.core=r}}class dS extends As{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pS extends As{constructor(e){super()}}class gS{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class vS extends As{constructor(e,r){super(),this.relayer=e,this.logger=r}}class mS extends As{constructor(e,r){super(),this.core=e,this.logger=r}}class bS{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class yS{constructor(e,r){this.projectId=e,this.logger=r}}class wS{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}var _S=Object.defineProperty,xS=(t,e,r)=>e in t?_S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kv=(t,e,r)=>xS(t,typeof e!="symbol"?e+"":e,r);class ES{constructor(e){this.opts=e,Kv(this,"protocol","wc"),Kv(this,"version",2)}}class $S{constructor(e){this.client=e}}const SS="PARSE_ERROR",IS="INVALID_REQUEST",AS="METHOD_NOT_FOUND",MS="INVALID_PARAMS",Gv="INTERNAL_ERROR",xu="SERVER_ERROR",PS=[-32700,-32600,-32601,-32602,-32603],Ja={[SS]:{code:-32700,message:"Parse error"},[IS]:{code:-32600,message:"Invalid Request"},[AS]:{code:-32601,message:"Method not found"},[MS]:{code:-32602,message:"Invalid params"},[Gv]:{code:-32603,message:"Internal error"},[xu]:{code:-32e3,message:"Server error"}},Jv=xu;function OS(t){return PS.includes(t)}function Zv(t){return Object.keys(Ja).includes(t)?Ja[t]:Ja[Jv]}function CS(t){const e=Object.values(Ja).find(r=>r.code===t);return e||Ja[Jv]}function Yv(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Xv={};/*! *****************************************************************************
|
|
24
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(d=>{if(!d.includes(":")||i)return;const p=oo(e[d].accounts);p.includes(d)||(i=K("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${d}
|
|
25
|
+
Required: ${d}
|
|
26
|
+
Approved: ${p.toString()}`))}),o.forEach(d=>{i||(Vn(n[d].methods,s[d].methods)?Vn(n[d].events,s[d].events)||(i=K("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${d}`)):i=K("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${d}`))}),i}function MS(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 Lm(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function TS(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const i=oo(t[r].accounts);i?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function RS(t,e){return Bd(t,!1)&&t<=e.max&&t>=e.min}function Fm(){const t=ma();return new Promise(e=>{switch(t){case br.browser:e(NS());break;case br.reactNative:e(BS());break;case br.node:e(LS());break;default:e(!0)}})}function NS(){return ba()&&navigator?.onLine}async function BS(){if(cn()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t?.isConnected}return!0}function LS(){return!0}function FS(t){switch(ma()){case br.browser:US(t);break;case br.reactNative:jS(t);break}}function US(t){!cn()&&ba()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function jS(t){cn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const Fd={};class Ca{static get(e){return Fd[e]}static set(e,r){Fd[e]=r}static delete(e){delete Fd[e]}}class Yn{}class qS extends Yn{constructor(e){super()}}const Um=V.FIVE_SECONDS,ao={pulse:"heartbeat_pulse"};class Ud extends qS{constructor(e){super(e),this.events=new Lt.exports.EventEmitter,this.interval=Um,this.interval=e?.interval||Um}static async init(e){const r=new Ud(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(),V.toMiliseconds(this.interval))}pulse(){this.events.emit(ao.pulse)}}const zS=/"(?:_|\\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*:/,kS=/"(?: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*:/,HS=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function WS(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){VS(t);return}return e}function VS(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Pl(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!HS.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(zS.test(t)||kS.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,WS)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function KS(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Dt(t,...e){try{return KS(t(...e))}catch(r){return Promise.reject(r)}}function GS(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function ZS(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Ol(t){if(GS(t))return String(t);if(ZS(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Ol(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const jd="base64:";function YS(t){return typeof t=="string"?t:jd+XS(t)}function JS(t){return typeof t!="string"||!t.startsWith(jd)?t:QS(t.slice(jd.length))}function QS(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function XS(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function cr(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function eA(...t){return cr(t.join(":"))}function Cl(t){return t=cr(t),t?t+":":""}function WW(t){return t}const tA="memory",rA=()=>{const t=new Map;return{name:tA,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 iA(t={}){const e={mounts:{"":t.driver||rA()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=l=>{for(const u of e.mountpoints)if(l.startsWith(u))return{base:u,relativeKey:l.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,u)=>e.mountpoints.filter(d=>d.startsWith(l)||u&&l.startsWith(d)).map(d=>({relativeBase:l.length>d.length?l.slice(d.length):void 0,mountpoint:d,driver:e.mounts[d]})),n=(l,u)=>{if(e.watching){u=cr(u);for(const d of e.watchListeners)d(l,u)}},s=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await jm(e.mounts[l],n,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,u,d)=>{const p=new Map,y=m=>{let _=p.get(m.base);return _||(_={driver:m.driver,base:m.base,items:[]},p.set(m.base,_)),_};for(const m of l){const _=typeof m=="string",S=cr(_?m:m.key),E=_?void 0:m.value,P=_||!m.options?u:{...u,...m.options},C=r(S);y(C).items.push({key:S,value:E,relativeKey:C.relativeKey,options:P})}return Promise.all([...p.values()].map(m=>d(m))).then(m=>m.flat())},c={hasItem(l,u={}){l=cr(l);const{relativeKey:d,driver:p}=r(l);return Dt(p.hasItem,d,u)},getItem(l,u={}){l=cr(l);const{relativeKey:d,driver:p}=r(l);return Dt(p.getItem,d,u).then(y=>Pl(y))},getItems(l,u={}){return a(l,u,d=>d.driver.getItems?Dt(d.driver.getItems,d.items.map(p=>({key:p.relativeKey,options:p.options})),u).then(p=>p.map(y=>({key:eA(d.base,y.key),value:Pl(y.value)}))):Promise.all(d.items.map(p=>Dt(d.driver.getItem,p.relativeKey,p.options).then(y=>({key:p.key,value:Pl(y)})))))},getItemRaw(l,u={}){l=cr(l);const{relativeKey:d,driver:p}=r(l);return p.getItemRaw?Dt(p.getItemRaw,d,u):Dt(p.getItem,d,u).then(y=>JS(y))},async setItem(l,u,d={}){if(u===void 0)return c.removeItem(l);l=cr(l);const{relativeKey:p,driver:y}=r(l);y.setItem&&(await Dt(y.setItem,p,Ol(u),d),y.watch||n("update",l))},async setItems(l,u){await a(l,u,async d=>{if(d.driver.setItems)return Dt(d.driver.setItems,d.items.map(p=>({key:p.relativeKey,value:Ol(p.value),options:p.options})),u);d.driver.setItem&&await Promise.all(d.items.map(p=>Dt(d.driver.setItem,p.relativeKey,Ol(p.value),p.options)))})},async setItemRaw(l,u,d={}){if(u===void 0)return c.removeItem(l,d);l=cr(l);const{relativeKey:p,driver:y}=r(l);if(y.setItemRaw)await Dt(y.setItemRaw,p,u,d);else if(y.setItem)await Dt(y.setItem,p,YS(u),d);else return;y.watch||n("update",l)},async removeItem(l,u={}){typeof u=="boolean"&&(u={removeMeta:u}),l=cr(l);const{relativeKey:d,driver:p}=r(l);p.removeItem&&(await Dt(p.removeItem,d,u),(u.removeMeta||u.removeMata)&&await Dt(p.removeItem,d+"$",u),p.watch||n("remove",l))},async getMeta(l,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),l=cr(l);const{relativeKey:d,driver:p}=r(l),y=Object.create(null);if(p.getMeta&&Object.assign(y,await Dt(p.getMeta,d,u)),!u.nativeOnly){const m=await Dt(p.getItem,d+"$",u).then(_=>Pl(_));m&&typeof m=="object"&&(typeof m.atime=="string"&&(m.atime=new Date(m.atime)),typeof m.mtime=="string"&&(m.mtime=new Date(m.mtime)),Object.assign(y,m))}return y},setMeta(l,u,d={}){return this.setItem(l+"$",u,d)},removeMeta(l,u={}){return this.removeItem(l+"$",u)},async getKeys(l,u={}){l=Cl(l);const d=i(l,!0);let p=[];const y=[];for(const m of d){const _=await Dt(m.driver.getKeys,m.relativeBase,u);for(const S of _){const E=m.mountpoint+cr(S);p.some(P=>E.startsWith(P))||y.push(E)}p=[m.mountpoint,...p.filter(S=>!S.startsWith(m.mountpoint))]}return l?y.filter(m=>m.startsWith(l)&&m[m.length-1]!=="$"):y.filter(m=>m[m.length-1]!=="$")},async clear(l,u={}){l=Cl(l),await Promise.all(i(l,!1).map(async d=>{if(d.driver.clear)return Dt(d.driver.clear,d.relativeBase,u);if(d.driver.removeItem){const p=await d.driver.getKeys(d.relativeBase||"",u);return Promise.all(p.map(y=>d.driver.removeItem(y,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>qm(l)))},async watch(l){return await s(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,u){if(l=Cl(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((d,p)=>p.length-d.length)),e.mounts[l]=u,e.watching&&Promise.resolve(jm(u,n,l)).then(d=>{e.unwatch[l]=d}).catch(console.error),c},async unmount(l,u=!0){l=Cl(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l]?.(),delete e.unwatch[l]),u&&await qm(e.mounts[l]),e.mountpoints=e.mountpoints.filter(d=>d!==l),delete e.mounts[l])},getMount(l=""){l=cr(l)+":";const u=r(l);return{driver:u.driver,base:u.base}},getMounts(l="",u={}){return l=cr(l),i(l,u.parents).map(p=>({driver:p.driver,base:p.mountpoint}))},keys:(l,u={})=>c.getKeys(l,u),get:(l,u={})=>c.getItem(l,u),set:(l,u,d={})=>c.setItem(l,u,d),has:(l,u={})=>c.hasItem(l,u),del:(l,u={})=>c.removeItem(l,u),remove:(l,u={})=>c.removeItem(l,u)};return c}function jm(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function qm(t){typeof t.dispose=="function"&&await Dt(t.dispose)}function Jn(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function zm(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Jn(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let qd;function Da(){return qd||(qd=zm("keyval-store","keyval")),qd}function km(t,e=Da()){return e("readonly",r=>Jn(r.get(t)))}function nA(t,e,r=Da()){return r("readwrite",i=>(i.put(e,t),Jn(i.transaction)))}function sA(t,e=Da()){return e("readwrite",r=>(r.delete(t),Jn(r.transaction)))}function oA(t=Da()){return t("readwrite",e=>(e.clear(),Jn(e.transaction)))}function aA(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Jn(t.transaction)}function cA(t=Da()){return t("readonly",e=>{if(e.getAllKeys)return Jn(e.getAllKeys());const r=[];return aA(e,i=>r.push(i.key)).then(()=>r)})}const lA="idb-keyval";var uA=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=zm(t.dbName,t.storeName)),{name:lA,options:t,async hasItem(n){return!(typeof await km(r(n),i)>"u")},async getItem(n){return await km(r(n),i)??null},setItem(n,s){return nA(r(n),s,i)},removeItem(n){return sA(r(n),i)},getKeys(){return cA(i)},clear(){return oA(i)}}};const hA="WALLET_CONNECT_V2_INDEXED_DB",dA="keyvaluestorage";class fA{constructor(){this.indexedDb=iA({driver:uA({dbName:hA,storeName:dA})})}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,Mi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var zd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Dl={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 zd<"u"&&zd.localStorage?Dl.exports=zd.localStorage:typeof window<"u"&&window.localStorage?Dl.exports=window.localStorage:Dl.exports=new e})();function pA(t){var e;return[t[0],Fn((e=t[1])!=null?e:"")]}class gA{constructor(){this.localStorage=Dl.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(pA)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return Fn(r)}async setItem(e,r){this.localStorage.setItem(e,Mi(r))}async removeItem(e){this.localStorage.removeItem(e)}}const bA="wc_storage_version",Hm=1,mA=async(t,e,r)=>{const i=bA,n=await e.getItem(i);if(n&&n>=Hm){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 l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Hm),r(e),vA(t,o)},vA=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class yA{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new gA;this.storage=e;try{const r=new fA;mA(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)})}}function wA(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var _A=xA;function xA(t,e,r){var i=r&&r.stringify||wA,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 l="",u=1-n,d=-1,p=t&&t.length||0,y=0;y<p;){if(t.charCodeAt(y)===37&&y+1<p){switch(d=d>-1?d:0,t.charCodeAt(y+1)){case 100:case 102:if(u>=c||e[u]==null)break;d<y&&(l+=t.slice(d,y)),l+=Number(e[u]),d=y+2,y++;break;case 105:if(u>=c||e[u]==null)break;d<y&&(l+=t.slice(d,y)),l+=Math.floor(Number(e[u])),d=y+2,y++;break;case 79:case 111:case 106:if(u>=c||e[u]===void 0)break;d<y&&(l+=t.slice(d,y));var m=typeof e[u];if(m==="string"){l+="'"+e[u]+"'",d=y+2,y++;break}if(m==="function"){l+=e[u].name||"<anonymous>",d=y+2,y++;break}l+=i(e[u]),d=y+2,y++;break;case 115:if(u>=c)break;d<y&&(l+=t.slice(d,y)),l+=String(e[u]),d=y+2,y++;break;case 37:d<y&&(l+=t.slice(d,y)),l+="%",d=y+2,y++,u--;break}++u}++y}return d===-1?t:(d<p&&(l+=t.slice(d)),l)}const Wm=_A;var pi=gi;const Ma=MA().console||{},EA={mapHttpRequest:Tl,mapHttpResponse:Tl,wrapRequestSerializer:Hd,wrapResponseSerializer:Hd,wrapErrorSerializer:Hd,req:Tl,res:Tl,err:PA};function $A(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function gi(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||Ma;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=$A(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=Ta),Object.defineProperty(c,"levelVal",{get:u}),Object.defineProperty(c,"level",{get:d,set:p});const l={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:OA(t)};c.levels=gi.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=Ta,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=y,e&&(c._logEvent=kd());function u(){return this.level==="silent"?1/0:this.levels.values[this.level]}function d(){return this._level}function p(m){if(m!=="silent"&&!this.levels.values[m])throw Error("unknown level "+m);this._level=m,co(l,c,"error","log"),co(l,c,"fatal","error"),co(l,c,"warn","error"),co(l,c,"info","log"),co(l,c,"debug","log"),co(l,c,"trace","log")}function y(m,_){if(!m)throw new Error("missing bindings for child Pino");_=_||{},n&&m.serializers&&(_.serializers=m.serializers);const S=_.serializers;if(n&&S){var E=Object.assign({},i,S),P=t.browser.serialize===!0?Object.keys(E):n;delete m.serializers,Ml([m],P,E,this._stdErrSerialize)}function C(M){this._childLevel=(M._childLevel|0)+1,this.error=lo(M,m,"error"),this.fatal=lo(M,m,"fatal"),this.warn=lo(M,m,"warn"),this.info=lo(M,m,"info"),this.debug=lo(M,m,"debug"),this.trace=lo(M,m,"trace"),E&&(this.serializers=E,this._serialize=P),e&&(this._logEvent=kd([].concat(M._logEvent.bindings,m)))}return C.prototype=this,new C(this)}return c}gi.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"}},gi.stdSerializers=EA,gi.stdTimeFunctions=Object.assign({},{nullTime:Vm,epochTime:Km,unixTime:CA,isoTime:DA});function co(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ta:n[r]?n[r]:Ma[r]||Ma[i]||Ta,IA(t,e,r)}function IA(t,e,r){!t.transmit&&e[r]===Ta||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ma?Ma:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&Ml(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,SA(this,r,o,s)):i.apply(a,o),t.transmit){const l=t.transmit.level||e.level,u=gi.levels.values[l],d=gi.levels.values[r];if(d<u)return;AA(this,{ts:s,methodLevel:r,methodValue:d,transmitLevel:l,transmitValue:gi.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function SA(t,e,r,i){t._serialize&&Ml(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=gi.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?Wm(n.shift(),n):void 0}else typeof s=="string"&&(s=Wm(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Ml(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=gi.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 lo(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 AA(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;Ml(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(l){return c.indexOf(l)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=kd(c)}function kd(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function PA(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 OA(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Vm:Km}function Tl(){return{}}function Hd(t){return t}function Ta(){}function Vm(){return!1}function Km(){return Date.now()}function CA(){return Math.round(Date.now()/1e3)}function DA(){return new Date(Date.now()).toISOString()}function MA(){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 TA={level:"info"},Ra="custom_context",Wd=1e3*1024;class RA{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class Gm{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new RA(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}}}}}class Zm{constructor(e,r=Wd){this.level=e??"error",this.levelValue=pi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Gm(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===pi.levels.values.error?console.error(e):r===pi.levels.values.warn?console.warn(e):r===pi.levels.values.debug?console.debug(e):r===pi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Mi({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 Gm(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Mi({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class NA{constructor(e,r=Wd){this.baseChunkLogger=new Zm(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)}}class BA{constructor(e,r=Wd){this.baseChunkLogger=new Zm(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 LA=Object.defineProperty,FA=Object.defineProperties,UA=Object.getOwnPropertyDescriptors,Ym=Object.getOwnPropertySymbols,jA=Object.prototype.hasOwnProperty,qA=Object.prototype.propertyIsEnumerable,Jm=(t,e,r)=>e in t?LA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rl=(t,e)=>{for(var r in e||(e={}))jA.call(e,r)&&Jm(t,r,e[r]);if(Ym)for(var r of Ym(e))qA.call(e,r)&&Jm(t,r,e[r]);return t},Nl=(t,e)=>FA(t,UA(e));function Bl(t){return Nl(Rl({},t),{level:t?.level||TA.level})}function zA(t,e=Ra){return t[e]||""}function kA(t,e,r=Ra){return t[r]=e,t}function lr(t,e=Ra){let r="";return typeof t.bindings>"u"?r=zA(t,e):r=t.bindings().context||"",r}function HA(t,e,r=Ra){const i=lr(t,r);return i.trim()?`${i}/${e}`:e}function tr(t,e,r=Ra){const i=HA(t,e,r),n=t.child({context:i});return kA(n,i,r)}function WA(t){var e,r;const i=new NA((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:pi(Nl(Rl({},t.opts),{level:"trace",browser:Nl(Rl({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function VA(t){var e;const r=new BA((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:pi(Nl(Rl({},t.opts),{level:"trace"})),chunkLoggerController:r}}function KA(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?WA(t):VA(t)}var GA=Object.defineProperty,ZA=(t,e,r)=>e in t?GA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qm=(t,e,r)=>ZA(t,typeof e!="symbol"?e+"":e,r);class YA extends Yn{constructor(e){super(),this.opts=e,Qm(this,"protocol","wc"),Qm(this,"version",2)}}var JA=Object.defineProperty,QA=(t,e,r)=>e in t?JA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,XA=(t,e,r)=>QA(t,typeof e!="symbol"?e+"":e,r);class eP extends Yn{constructor(e,r){super(),this.core=e,this.logger=r,XA(this,"records",new Map)}}class tP{constructor(e,r){this.logger=e,this.core=r}}class rP extends Yn{constructor(e,r){super(),this.relayer=e,this.logger=r}}class iP extends Yn{constructor(e){super()}}class nP{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class sP extends Yn{constructor(e,r){super(),this.relayer=e,this.logger=r}}class oP extends Yn{constructor(e,r){super(),this.core=e,this.logger=r}}class aP{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class cP{constructor(e,r){this.projectId=e,this.logger=r}}class lP{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}var uP=Object.defineProperty,hP=(t,e,r)=>e in t?uP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xm=(t,e,r)=>hP(t,typeof e!="symbol"?e+"":e,r);class dP{constructor(e){this.opts=e,Xm(this,"protocol","wc"),Xm(this,"version",2)}}class fP{constructor(e){this.client=e}}const pP="PARSE_ERROR",gP="INVALID_REQUEST",bP="METHOD_NOT_FOUND",mP="INVALID_PARAMS",ev="INTERNAL_ERROR",Vd="SERVER_ERROR",vP=[-32700,-32600,-32601,-32602,-32603],Na={[pP]:{code:-32700,message:"Parse error"},[gP]:{code:-32600,message:"Invalid Request"},[bP]:{code:-32601,message:"Method not found"},[mP]:{code:-32602,message:"Invalid params"},[ev]:{code:-32603,message:"Internal error"},[Vd]:{code:-32e3,message:"Server error"}},tv=Vd;function yP(t){return vP.includes(t)}function rv(t){return Object.keys(Na).includes(t)?Na[t]:Na[tv]}function wP(t){const e=Object.values(Na).find(r=>r.code===t);return e||Na[tv]}function iv(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var nv={};/*! *****************************************************************************
|
|
31
27
|
Copyright (c) Microsoft Corporation.
|
|
32
28
|
|
|
33
29
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -40,59 +36,59 @@ ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(B_(r)).toStr
|
|
|
40
36
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41
37
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42
38
|
PERFORMANCE OF THIS SOFTWARE.
|
|
43
|
-
***************************************************************************** */var Eu=function(t,e){return Eu=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])},Eu(t,e)};function DS(t,e){Eu(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var $u=function(){return $u=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},$u.apply(this,arguments)};function RS(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 NS(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 TS(t,e){return function(r,i){e(r,i,t)}}function FS(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function LS(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(u){try{l(i.next(u))}catch(m){o(m)}}function c(u){try{l(i.throw(u))}catch(m){o(m)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(t,e||[])).next())})}function BS(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(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function US(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function qS(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Su(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 Qv(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 jS(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Qv(arguments[e]));return t}function kS(){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 Za(t){return this instanceof Za?(this.v=t,this):new Za(t)}function zS(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(x){i[x]&&(n[x]=function(S){return new Promise(function(E,A){s.push([x,S,E,A])>1||a(x,S)})})}function a(x,S){try{c(i[x](S))}catch(E){m(s[0][3],E)}}function c(x){x.value instanceof Za?Promise.resolve(x.value.v).then(l,u):m(s[0][2],x)}function l(x){a("next",x)}function u(x){a("throw",x)}function m(x,S){x(S),s.shift(),s.length&&a(s[0][0],s[0][1])}}function HS(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:Za(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function WS(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 Su=="function"?Su(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(l){s({value:l,done:a})},o)}}function VS(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function KS(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 GS(t){return t&&t.__esModule?t:{default:t}}function JS(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function ZS(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var YS=Object.freeze({__proto__:null,__extends:DS,get __assign(){return $u},__rest:RS,__decorate:NS,__param:TS,__metadata:FS,__awaiter:LS,__generator:BS,__createBinding:US,__exportStar:qS,__values:Su,__read:Qv,__spread:jS,__spreadArrays:kS,__await:Za,__asyncGenerator:zS,__asyncDelegator:HS,__asyncValues:WS,__makeTemplateObject:VS,__importStar:KS,__importDefault:GS,__classPrivateFieldGet:JS,__classPrivateFieldSet:ZS}),XS=Ch(YS),vn={},em;function QS(){if(em)return vn;em=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.isBrowserCryptoAvailable=vn.getSubtleCrypto=vn.getBrowerCrypto=void 0;function t(){return Ft?.crypto||Ft?.msCrypto||{}}vn.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}vn.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return vn.isBrowserCryptoAvailable=r,vn}var mn={},tm;function eI(){if(tm)return mn;tm=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.isBrowser=mn.isNode=mn.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}mn.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}mn.isNode=e;function r(){return!t()&&!e()}return mn.isBrowser=r,mn}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=XS;e.__exportStar(QS(),t),e.__exportStar(eI(),t)})(Xv);function bn(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function Ps(t=6){return BigInt(bn(t))}function Zn(t,e,r){return{id:r||bn(),jsonrpc:"2.0",method:t,params:e}}function Cl(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Dl(t,e,r){return{id:t,jsonrpc:"2.0",error:tI(e,r)}}function tI(t,e){return typeof t>"u"?Zv(Gv):(typeof t=="string"&&(t=Object.assign(Object.assign({},Zv(xu)),{message:t})),typeof e<"u"&&(t.data=e),OS(t.code)&&(t=CS(t.code)),t)}class rI{}class iI extends rI{constructor(){super()}}class nI extends iI{constructor(e){super()}}const sI="^https?:",oI="^wss?:";function aI(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function rm(t,e){const r=aI(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function im(t){return rm(t,sI)}function nm(t){return rm(t,oI)}function cI(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function sm(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Iu(t){return sm(t)&&"method"in t}function Rl(t){return sm(t)&&(Gi(t)||fi(t))}function Gi(t){return"result"in t}function fi(t){return"error"in t}class ui extends nI{constructor(e){super(e),this.events=new nr.exports.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(Zn(e.method,e.params||[],e.id||Ps().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=>{fi(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),Rl(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)}}const lI=()=>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"),hI=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",om=t=>t.split("?")[0],am=10,fI=lI();class uI{constructor(e){if(this.url=e,this.events=new nr.exports.EventEmitter,this.registering=!1,!nm(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(ln(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!nm(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=Xv.isReactNative()?void 0:{rejectUnauthorized:!cI(e)},s=new fI(e,[],n);hI()?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"?ms(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Dl(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Yv(e,om(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>am&&this.events.setMaxListeners(am)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${om(this.url)}`));return this.events.emit("register_error",r),r}}var Au={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",m="[object Date]",x="[object Error]",S="[object Function]",E="[object GeneratorFunction]",A="[object Map]",R="[object Number]",O="[object Null]",C="[object Object]",N="[object Promise]",T="[object Proxy]",U="[object RegExp]",z="[object Set]",W="[object String]",V="[object Symbol]",B="[object Undefined]",K="[object WeakMap]",M="[object ArrayBuffer]",v="[object DataView]",g="[object Float32Array]",h="[object Float64Array]",f="[object Int8Array]",p="[object Int16Array]",_="[object Int32Array]",$="[object Uint8Array]",y="[object Uint8ClampedArray]",d="[object Uint16Array]",w="[object Uint32Array]",b=/[\\^$.*+?()[\]{}|]/g,P=/^\[object .+?Constructor\]$/,q=/^(?:0|[1-9]\d*)$/,I={};I[g]=I[h]=I[f]=I[p]=I[_]=I[$]=I[y]=I[d]=I[w]=!0,I[a]=I[c]=I[M]=I[u]=I[v]=I[m]=I[x]=I[S]=I[A]=I[R]=I[C]=I[U]=I[z]=I[W]=I[K]=!1;var F=typeof Ft=="object"&&Ft&&Ft.Object===Object&&Ft,j=typeof self=="object"&&self&&self.Object===Object&&self,k=F||j||Function("return this")(),H=e&&!e.nodeType&&e,Y=H&&!0&&t&&!t.nodeType&&t,Q=Y&&Y.exports===H,J=Q&&F.process,ae=function(){try{return J&&J.binding&&J.binding("util")}catch{}}(),re=ae&&ae.isTypedArray;function ie(D,L){for(var G=-1,ne=D==null?0:D.length,Pt=0,Se=[];++G<ne;){var Tt=D[G];L(Tt,G,D)&&(Se[Pt++]=Tt)}return Se}function Ze(D,L){for(var G=-1,ne=L.length,Pt=D.length;++G<ne;)D[Pt+G]=L[G];return D}function Ye(D,L){for(var G=-1,ne=D==null?0:D.length;++G<ne;)if(L(D[G],G,D))return!0;return!1}function de(D,L){for(var G=-1,ne=Array(D);++G<D;)ne[G]=L(G);return ne}function qe(D){return function(L){return D(L)}}function je(D,L){return D.has(L)}function he(D,L){return D?.[L]}function ke(D){var L=-1,G=Array(D.size);return D.forEach(function(ne,Pt){G[++L]=[Pt,ne]}),G}function ze(D,L){return function(G){return D(L(G))}}function ue(D){var L=-1,G=Array(D.size);return D.forEach(function(ne){G[++L]=ne}),G}var He=Array.prototype,We=Function.prototype,le=Object.prototype,Be=k["__core-js_shared__"],Ve=We.toString,oe=le.hasOwnProperty,nt=function(){var D=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return D?"Symbol(src)_1."+D:""}(),st=le.toString,me=RegExp("^"+Ve.call(oe).replace(b,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ot=Q?k.Buffer:void 0,Ke=k.Symbol,ge=k.Uint8Array,at=le.propertyIsEnumerable,ft=He.splice,ce=Ke?Ke.toStringTag:void 0,ct=Object.getOwnPropertySymbols,ut=ot?ot.isBuffer:void 0,be=ze(Object.keys,Object),Xe=ua(k,"DataView"),Ue=ua(k,"Map"),pe=ua(k,"Promise"),Qe=ua(k,"Set"),et=ua(k,"WeakMap"),fe=ua(Object,"create"),dt=Js(Xe),pt=Js(Ue),ye=Js(pe),gt=Js(Qe),vt=Js(et),ve=Ke?Ke.prototype:void 0,tt=ve?ve.valueOf:void 0;function Re(D){var L=-1,G=D==null?0:D.length;for(this.clear();++L<G;){var ne=D[L];this.set(ne[0],ne[1])}}function we(){this.__data__=fe?fe(null):{},this.size=0}function mt(D){var L=this.has(D)&&delete this.__data__[D];return this.size-=L?1:0,L}function bt(D){var L=this.__data__;if(fe){var G=L[D];return G===i?void 0:G}return oe.call(L,D)?L[D]:void 0}function _e(D){var L=this.__data__;return fe?L[D]!==void 0:oe.call(L,D)}function yt(D,L){var G=this.__data__;return this.size+=this.has(D)?0:1,G[D]=fe&&L===void 0?i:L,this}Re.prototype.clear=we,Re.prototype.delete=mt,Re.prototype.get=bt,Re.prototype.has=_e,Re.prototype.set=yt;function Ae(D){var L=-1,G=D==null?0:D.length;for(this.clear();++L<G;){var ne=D[L];this.set(ne[0],ne[1])}}function lt(){this.__data__=[],this.size=0}function qr(D){var L=this.__data__,G=Ih(L,D);if(G<0)return!1;var ne=L.length-1;return G==ne?L.pop():ft.call(L,G,1),--this.size,!0}function jr(D){var L=this.__data__,G=Ih(L,D);return G<0?void 0:L[G][1]}function kr(D){return Ih(this.__data__,D)>-1}function zr(D,L){var G=this.__data__,ne=Ih(G,D);return ne<0?(++this.size,G.push([D,L])):G[ne][1]=L,this}Ae.prototype.clear=lt,Ae.prototype.delete=qr,Ae.prototype.get=jr,Ae.prototype.has=kr,Ae.prototype.set=zr;function kt(D){var L=-1,G=D==null?0:D.length;for(this.clear();++L<G;){var ne=D[L];this.set(ne[0],ne[1])}}function En(){this.size=0,this.__data__={hash:new Re,map:new(Ue||Ae),string:new Re}}function $n(D){var L=Ah(this,D).delete(D);return this.size-=L?1:0,L}function Sn(D){return Ah(this,D).get(D)}function In(D){return Ah(this,D).has(D)}function An(D,L){var G=Ah(this,D),ne=G.size;return G.set(D,L),this.size+=G.size==ne?0:1,this}kt.prototype.clear=En,kt.prototype.delete=$n,kt.prototype.get=Sn,kt.prototype.has=In,kt.prototype.set=An;function mi(D){var L=-1,G=D==null?0:D.length;for(this.__data__=new kt;++L<G;)this.add(D[L])}function Mn(D){return this.__data__.set(D,i),this}function Pn(D){return this.__data__.has(D)}mi.prototype.add=mi.prototype.push=Mn,mi.prototype.has=Pn;function wr(D){var L=this.__data__=new Ae(D);this.size=L.size}function On(){this.__data__=new Ae,this.size=0}function Cn(D){var L=this.__data__,G=L.delete(D);return this.size=L.size,G}function Dn(D){return this.__data__.get(D)}function $c(D){return this.__data__.has(D)}function Sc(D,L){var G=this.__data__;if(G instanceof Ae){var ne=G.__data__;if(!Ue||ne.length<r-1)return ne.push([D,L]),this.size=++G.size,this;G=this.__data__=new kt(ne)}return G.set(D,L),this.size=G.size,this}wr.prototype.clear=On,wr.prototype.delete=Cn,wr.prototype.get=Dn,wr.prototype.has=$c,wr.prototype.set=Sc;function $k(D,L){var G=Mh(D),ne=!G&&Uk(D),Pt=!G&&!ne&&y0(D),Se=!G&&!ne&&!Pt&&Ty(D),Tt=G||ne||Pt||Se,ir=Tt?de(D.length,String):[],pr=ir.length;for(var Ct in D)(L||oe.call(D,Ct))&&!(Tt&&(Ct=="length"||Pt&&(Ct=="offset"||Ct=="parent")||Se&&(Ct=="buffer"||Ct=="byteLength"||Ct=="byteOffset")||Nk(Ct,pr)))&&ir.push(Ct);return ir}function Ih(D,L){for(var G=D.length;G--;)if(Cy(D[G][0],L))return G;return-1}function Sk(D,L,G){var ne=L(D);return Mh(D)?ne:Ze(ne,G(D))}function Ic(D){return D==null?D===void 0?B:O:ce&&ce in Object(D)?Dk(D):Bk(D)}function Ay(D){return Ac(D)&&Ic(D)==a}function My(D,L,G,ne,Pt){return D===L?!0:D==null||L==null||!Ac(D)&&!Ac(L)?D!==D&&L!==L:Ik(D,L,G,ne,My,Pt)}function Ik(D,L,G,ne,Pt,Se){var Tt=Mh(D),ir=Mh(L),pr=Tt?c:ls(D),Ct=ir?c:ls(L);pr=pr==a?C:pr,Ct=Ct==a?C:Ct;var ri=pr==C,Di=Ct==C,_r=pr==Ct;if(_r&&y0(D)){if(!y0(L))return!1;Tt=!0,ri=!1}if(_r&&!ri)return Se||(Se=new wr),Tt||Ty(D)?Py(D,L,G,ne,Pt,Se):Ok(D,L,pr,G,ne,Pt,Se);if(!(G&n)){var bi=ri&&oe.call(D,"__wrapped__"),yi=Di&&oe.call(L,"__wrapped__");if(bi||yi){var hs=bi?D.value():D,Rn=yi?L.value():L;return Se||(Se=new wr),Pt(hs,Rn,G,ne,Se)}}return _r?(Se||(Se=new wr),Ck(D,L,G,ne,Pt,Se)):!1}function Ak(D){if(!Ny(D)||Fk(D))return!1;var L=Dy(D)?me:P;return L.test(Js(D))}function Mk(D){return Ac(D)&&Ry(D.length)&&!!I[Ic(D)]}function Pk(D){if(!Lk(D))return be(D);var L=[];for(var G in Object(D))oe.call(D,G)&&G!="constructor"&&L.push(G);return L}function Py(D,L,G,ne,Pt,Se){var Tt=G&n,ir=D.length,pr=L.length;if(ir!=pr&&!(Tt&&pr>ir))return!1;var Ct=Se.get(D);if(Ct&&Se.get(L))return Ct==L;var ri=-1,Di=!0,_r=G&s?new mi:void 0;for(Se.set(D,L),Se.set(L,D);++ri<ir;){var bi=D[ri],yi=L[ri];if(ne)var hs=Tt?ne(yi,bi,ri,L,D,Se):ne(bi,yi,ri,D,L,Se);if(hs!==void 0){if(hs)continue;Di=!1;break}if(_r){if(!Ye(L,function(Rn,Zs){if(!je(_r,Zs)&&(bi===Rn||Pt(bi,Rn,G,ne,Se)))return _r.push(Zs)})){Di=!1;break}}else if(!(bi===yi||Pt(bi,yi,G,ne,Se))){Di=!1;break}}return Se.delete(D),Se.delete(L),Di}function Ok(D,L,G,ne,Pt,Se,Tt){switch(G){case v:if(D.byteLength!=L.byteLength||D.byteOffset!=L.byteOffset)return!1;D=D.buffer,L=L.buffer;case M:return!(D.byteLength!=L.byteLength||!Se(new ge(D),new ge(L)));case u:case m:case R:return Cy(+D,+L);case x:return D.name==L.name&&D.message==L.message;case U:case W:return D==L+"";case A:var ir=ke;case z:var pr=ne&n;if(ir||(ir=ue),D.size!=L.size&&!pr)return!1;var Ct=Tt.get(D);if(Ct)return Ct==L;ne|=s,Tt.set(D,L);var ri=Py(ir(D),ir(L),ne,Pt,Se,Tt);return Tt.delete(D),ri;case V:if(tt)return tt.call(D)==tt.call(L)}return!1}function Ck(D,L,G,ne,Pt,Se){var Tt=G&n,ir=Oy(D),pr=ir.length,Ct=Oy(L),ri=Ct.length;if(pr!=ri&&!Tt)return!1;for(var Di=pr;Di--;){var _r=ir[Di];if(!(Tt?_r in L:oe.call(L,_r)))return!1}var bi=Se.get(D);if(bi&&Se.get(L))return bi==L;var yi=!0;Se.set(D,L),Se.set(L,D);for(var hs=Tt;++Di<pr;){_r=ir[Di];var Rn=D[_r],Zs=L[_r];if(ne)var Fy=Tt?ne(Zs,Rn,_r,L,D,Se):ne(Rn,Zs,_r,D,L,Se);if(!(Fy===void 0?Rn===Zs||Pt(Rn,Zs,G,ne,Se):Fy)){yi=!1;break}hs||(hs=_r=="constructor")}if(yi&&!hs){var Ph=D.constructor,Oh=L.constructor;Ph!=Oh&&"constructor"in D&&"constructor"in L&&!(typeof Ph=="function"&&Ph instanceof Ph&&typeof Oh=="function"&&Oh instanceof Oh)&&(yi=!1)}return Se.delete(D),Se.delete(L),yi}function Oy(D){return Sk(D,kk,Rk)}function Ah(D,L){var G=D.__data__;return Tk(L)?G[typeof L=="string"?"string":"hash"]:G.map}function ua(D,L){var G=he(D,L);return Ak(G)?G:void 0}function Dk(D){var L=oe.call(D,ce),G=D[ce];try{D[ce]=void 0;var ne=!0}catch{}var Pt=st.call(D);return ne&&(L?D[ce]=G:delete D[ce]),Pt}var Rk=ct?function(D){return D==null?[]:(D=Object(D),ie(ct(D),function(L){return at.call(D,L)}))}:zk,ls=Ic;(Xe&&ls(new Xe(new ArrayBuffer(1)))!=v||Ue&&ls(new Ue)!=A||pe&&ls(pe.resolve())!=N||Qe&&ls(new Qe)!=z||et&&ls(new et)!=K)&&(ls=function(D){var L=Ic(D),G=L==C?D.constructor:void 0,ne=G?Js(G):"";if(ne)switch(ne){case dt:return v;case pt:return A;case ye:return N;case gt:return z;case vt:return K}return L});function Nk(D,L){return L=L??o,!!L&&(typeof D=="number"||q.test(D))&&D>-1&&D%1==0&&D<L}function Tk(D){var L=typeof D;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?D!=="__proto__":D===null}function Fk(D){return!!nt&&nt in D}function Lk(D){var L=D&&D.constructor,G=typeof L=="function"&&L.prototype||le;return D===G}function Bk(D){return st.call(D)}function Js(D){if(D!=null){try{return Ve.call(D)}catch{}try{return D+""}catch{}}return""}function Cy(D,L){return D===L||D!==D&&L!==L}var Uk=Ay(function(){return arguments}())?Ay:function(D){return Ac(D)&&oe.call(D,"callee")&&!at.call(D,"callee")},Mh=Array.isArray;function qk(D){return D!=null&&Ry(D.length)&&!Dy(D)}var y0=ut||Hk;function jk(D,L){return My(D,L)}function Dy(D){if(!Ny(D))return!1;var L=Ic(D);return L==S||L==E||L==l||L==T}function Ry(D){return typeof D=="number"&&D>-1&&D%1==0&&D<=o}function Ny(D){var L=typeof D;return D!=null&&(L=="object"||L=="function")}function Ac(D){return D!=null&&typeof D=="object"}var Ty=re?qe(re):Mk;function kk(D){return qk(D)?$k(D):Pk(D)}function zk(){return[]}function Hk(){return!1}t.exports=jk})(Au,Au.exports);var dI=Au.exports,pI=Object.defineProperty,cm=Object.getOwnPropertySymbols,gI=Object.prototype.hasOwnProperty,vI=Object.prototype.propertyIsEnumerable,lm=(t,e,r)=>e in t?pI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ar=(t,e)=>{for(var r in e||(e={}))gI.call(e,r)&&lm(t,r,e[r]);if(cm)for(var r of cm(e))vI.call(e,r)&&lm(t,r,e[r]);return t};const hm="wc",fm=2,Nl="core",Ji=`${hm}@2:${Nl}:`,mI={name:Nl,logger:"error"},bI={database:":memory:"},yI="crypto",um="client_ed25519_seed",wI=X.ONE_DAY,_I="keychain",xI="0.3",EI="messages",$I="0.3",dm=X.SIX_HOURS,SI="publisher",pm="irn",II="error",gm="wss://relay.walletconnect.org",AI="relayer",Qt={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"},MI="_subscription",di={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},PI=.1,Mu="2.18.1",St={link_mode:"link_mode",relay:"relay"},OI="0.3",CI="WALLETCONNECT_CLIENT_ID",vm="WALLETCONNECT_LINK_MODE_APPS",Zr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},DI="subscription",RI="0.3",NI=X.FIVE_SECONDS*1e3,TI="pairing",FI="0.3",Ya={wc_pairingDelete:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:X.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:X.ONE_DAY,prompt:!1,tag:0},res:{ttl:X.ONE_DAY,prompt:!1,tag:0}}},Os={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Mi={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},LI="history",BI="0.3",UI="expirer",pi={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},qI="0.3",jI="verify-api",kI="https://verify.walletconnect.com",mm="https://verify.walletconnect.org",Xa=mm,zI=`${Xa}/v3`,HI=[kI,mm],WI="echo",VI="https://echo.walletconnect.com",Zi={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"},yn={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"},Pi={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"},Cs={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"},Ds={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"},Qa={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"},KI=.1,GI="event-client",JI=86400,ZI="https://pulse.walletconnect.org/batch";function YI(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function m(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var A=0,R=0,O=0,C=E.length;O!==C&&E[O]===0;)O++,A++;for(var N=(C-O)*u+1>>>0,T=new Uint8Array(N);O!==C;){for(var U=E[O],z=0,W=N-1;(U!==0||z<R)&&W!==-1;W--,z++)U+=256*T[W]>>>0,T[W]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");R=z,O++}for(var V=N-R;V!==N&&T[V]===0;)V++;for(var B=c.repeat(A);V<N;++V)B+=t.charAt(T[V]);return B}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var R=0,O=0;E[A]===c;)R++,A++;for(var C=(E.length-A)*l+1>>>0,N=new Uint8Array(C);E[A];){var T=r[E.charCodeAt(A)];if(T===255)return;for(var U=0,z=C-1;(T!==0||U<O)&&z!==-1;z--,U++)T+=a*N[z]>>>0,N[z]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");O=U,A++}if(E[A]!==" "){for(var W=C-O;W!==C&&N[W]===0;)W++;for(var V=new Uint8Array(R+(C-W)),B=R;W!==C;)V[B++]=N[W++];return V}}}function S(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:x,decode:S}}var XI=YI,QI=XI;const bm=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")},eA=t=>new TextEncoder().encode(t),tA=t=>new TextDecoder().decode(t);class rA{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 iA{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 ym(this,e)}}class nA{constructor(e){this.decoders=e}or(e){return ym(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 ym=(t,e)=>new nA(Ar(Ar({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class sA{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new rA(e,r,i),this.decoder=new iA(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Tl=({name:t,prefix:e,encode:r,decode:i})=>new sA(t,e,r,i),ec=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=QI(r,e);return Tl({prefix:t,name:e,encode:i,decode:s=>bm(n(s))})},oA=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const m=n[t[u]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|m,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},aA=(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},fr=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Tl({prefix:e,name:t,encode(n){return aA(n,i,r)},decode(n){return oA(n,i,r,t)}}),cA=Tl({prefix:"\0",name:"identity",encode:t=>tA(t),decode:t=>eA(t)});var lA=Object.freeze({__proto__:null,identity:cA});const hA=fr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var fA=Object.freeze({__proto__:null,base2:hA});const uA=fr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dA=Object.freeze({__proto__:null,base8:uA});const pA=ec({prefix:"9",name:"base10",alphabet:"0123456789"});var gA=Object.freeze({__proto__:null,base10:pA});const vA=fr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),mA=fr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bA=Object.freeze({__proto__:null,base16:vA,base16upper:mA});const yA=fr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wA=fr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_A=fr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xA=fr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),EA=fr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$A=fr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SA=fr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),IA=fr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),AA=fr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var MA=Object.freeze({__proto__:null,base32:yA,base32upper:wA,base32pad:_A,base32padupper:xA,base32hex:EA,base32hexupper:$A,base32hexpad:SA,base32hexpadupper:IA,base32z:AA});const PA=ec({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),OA=ec({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var CA=Object.freeze({__proto__:null,base36:PA,base36upper:OA});const DA=ec({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),RA=ec({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var NA=Object.freeze({__proto__:null,base58btc:DA,base58flickr:RA});const TA=fr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),FA=fr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),LA=fr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),BA=fr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var UA=Object.freeze({__proto__:null,base64:TA,base64pad:FA,base64url:LA,base64urlpad:BA});const wm=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),qA=wm.reduce((t,e,r)=>(t[r]=e,t),[]),jA=wm.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function kA(t){return t.reduce((e,r)=>(e+=qA[r],e),"")}function zA(t){const e=[];for(const r of t){const i=jA[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const HA=Tl({prefix:"\u{1F680}",name:"base256emoji",encode:kA,decode:zA});var WA=Object.freeze({__proto__:null,base256emoji:HA}),VA=xm,_m=128,KA=127,GA=~KA,JA=Math.pow(2,31);function xm(t,e,r){e=e||[],r=r||0;for(var i=r;t>=JA;)e[r++]=t&255|_m,t/=128;for(;t&GA;)e[r++]=t&255|_m,t>>>=7;return e[r]=t|0,xm.bytes=r-i+1,e}var ZA=Pu,YA=128,Em=127;function Pu(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Pu.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Em)<<n:(o&Em)*Math.pow(2,n),n+=7}while(o>=YA);return Pu.bytes=s-i,r}var XA=Math.pow(2,7),QA=Math.pow(2,14),eM=Math.pow(2,21),tM=Math.pow(2,28),rM=Math.pow(2,35),iM=Math.pow(2,42),nM=Math.pow(2,49),sM=Math.pow(2,56),oM=Math.pow(2,63),aM=function(t){return t<XA?1:t<QA?2:t<eM?3:t<tM?4:t<rM?5:t<iM?6:t<nM?7:t<sM?8:t<oM?9:10},cM={encode:VA,decode:ZA,encodingLength:aM},$m=cM;const Sm=(t,e,r=0)=>($m.encode(t,e,r),e),Im=t=>$m.encodingLength(t),Ou=(t,e)=>{const r=e.byteLength,i=Im(t),n=i+Im(r),s=new Uint8Array(n+r);return Sm(t,s,0),Sm(r,s,i),s.set(e,n),new lM(t,r,e,s)};class lM{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Am=({name:t,code:e,encode:r})=>new hM(t,e,r);class hM{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?Ou(this.code,r):r.then(i=>Ou(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Mm=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),fM=Am({name:"sha2-256",code:18,encode:Mm("SHA-256")}),uM=Am({name:"sha2-512",code:19,encode:Mm("SHA-512")});var dM=Object.freeze({__proto__:null,sha256:fM,sha512:uM});const Pm=0,pM="identity",Om=bm;var gM=Object.freeze({__proto__:null,identity:{code:Pm,name:pM,encode:Om,digest:t=>Ou(Pm,Om(t))}});new TextEncoder,new TextDecoder;const Cm=Ar(Ar(Ar(Ar(Ar(Ar(Ar(Ar(Ar(Ar({},lA),fA),dA),gA),bA),MA),CA),NA),UA),WA);Ar(Ar({},dM),gM);function vM(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Dm(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Rm=Dm("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Cu=Dm("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=vM(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),mM=Ar({utf8:Rm,"utf-8":Rm,hex:Cm.base16,latin1:Cu,ascii:Cu,binary:Cu},Cm);function bM(t,e="utf8"){const r=mM[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 yM=Object.defineProperty,wM=(t,e,r)=>e in t?yM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yi=(t,e,r)=>wM(t,typeof e!="symbol"?e+"":e,r);class _M{constructor(e,r){this.core=e,this.logger=r,Yi(this,"keychain",new Map),Yi(this,"name",_I),Yi(this,"version",xI),Yi(this,"initialized",!1),Yi(this,"storagePrefix",Ji),Yi(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Yi(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Yi(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),Yi(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=ee("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),Yi(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=Ir(r,this.name)}get context(){return Tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,xg(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Eg(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xM=Object.defineProperty,EM=(t,e,r)=>e in t?xM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ur=(t,e,r)=>EM(t,typeof e!="symbol"?e+"":e,r);class $M{constructor(e,r,i){this.core=e,this.logger=r,ur(this,"name",yI),ur(this,"keychain"),ur(this,"randomSessionIdentifier",hu()),ur(this,"initialized",!1),ur(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),ur(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),ur(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=F1(n);return T1(s.publicKey)}),ur(this,"generateKeyPair",()=>{this.isInitialized();const n=rE();return this.setPrivateKey(n.publicKey,n.privateKey)}),ur(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=F1(s),a=this.randomSessionIdentifier;return await U8(a,n,wI,o)}),ur(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=iE(a,s);return this.setSymKey(c,o)}),ur(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||bl(n);return await this.keychain.set(o,n),o}),ur(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),ur(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),ur(this,"encode",async(n,s,o)=>{this.isInitialized();const a=wv(o),c=ln(s);if(xv(a))return oE(c,o?.encoding);if(_v(a)){const x=a.senderPublicKey,S=a.receiverPublicKey;n=await this.generateSharedKey(x,S)}const l=this.getSymKey(n),{type:u,senderPublicKey:m}=a;return nE({type:u,symKey:l,message:c,senderPublicKey:m,encoding:o?.encoding})}),ur(this,"decode",async(n,s,o)=>{this.isInitialized();const a=cE(s,o);if(xv(a)){const c=aE(s,o?.encoding);return ms(c)}if(_v(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;n=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(n),l=sE({symKey:c,encoded:s,encoding:o?.encoding});return ms(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),ur(this,"getPayloadType",(n,s=Jn)=>{const o=qa({encoded:n,encoding:s});return Is(o.type)}),ur(this,"getPayloadSenderPublicKey",(n,s=Jn)=>{const o=qa({encoded:n,encoding:s});return o.senderPublicKey?$r(o.senderPublicKey,mr):void 0}),this.core=e,this.logger=Ir(r,this.name),this.keychain=i||new _M(this.core,this.logger)}get context(){return Tr(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(um)}catch{e=hu(),await this.keychain.set(um,e)}return bM(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var SM=Object.defineProperty,IM=(t,e,r)=>e in t?SM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xi=(t,e,r)=>IM(t,typeof e!="symbol"?e+"":e,r);class AM extends uS{constructor(e,r){super(e,r),this.logger=e,this.core=r,Xi(this,"messages",new Map),Xi(this,"name",EI),Xi(this,"version",$I),Xi(this,"initialized",!1),Xi(this,"storagePrefix",Ji),Xi(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),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}}}),Xi(this,"set",async(i,n)=>{this.isInitialized();const s=gn(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s}),Xi(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),Xi(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=gn(n);return typeof s[o]<"u"}),Xi(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=Ir(e,this.name),this.core=r}get context(){return Tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,xg(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Eg(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var MM=Object.defineProperty,PM=Object.defineProperties,OM=Object.getOwnPropertyDescriptors,Nm=Object.getOwnPropertySymbols,CM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,Du=(t,e,r)=>e in t?MM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fl=(t,e)=>{for(var r in e||(e={}))CM.call(e,r)&&Du(t,r,e[r]);if(Nm)for(var r of Nm(e))DM.call(e,r)&&Du(t,r,e[r]);return t},Ru=(t,e)=>PM(t,OM(e)),Oi=(t,e,r)=>Du(t,typeof e!="symbol"?e+"":e,r);class RM extends dS{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,Oi(this,"events",new nr.exports.EventEmitter),Oi(this,"name",SI),Oi(this,"queue",new Map),Oi(this,"publishTimeout",X.toMiliseconds(X.ONE_MINUTE)),Oi(this,"initialPublishTimeout",X.toMiliseconds(X.ONE_SECOND*15)),Oi(this,"needsTransportRestart",!1),Oi(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||dm,c=yl(s),l=s?.prompt||!1,u=s?.tag||0,m=s?.id||Ps().toString(),x={topic:i,message:n,opts:{ttl:a,relay:c,prompt:l,tag:u,id:m,attestation:s?.attestation,tvf:s?.tvf}},S=`Failed to publish payload, please try again. id:${m} tag:${u}`;try{const E=new Promise(async A=>{const R=({id:C})=>{x.opts.id===C&&(this.removeRequestFromQueue(C),this.relayer.events.removeListener(Qt.publish,R),A(x))};this.relayer.events.on(Qt.publish,R);const O=Hn(new Promise((C,N)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:l,tag:u,id:m,attestation:s?.attestation,tvf:s?.tvf}).then(C).catch(T=>{this.logger.warn(T,T?.message),N(T)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${m} tag:${u}`);try{await O,this.events.removeListener(Qt.publish,R)}catch(C){this.queue.set(m,Ru(Fl({},x),{attempt:1})),this.logger.warn(C,C?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:m,topic:i,message:n,opts:s}}),await Hn(E,this.publishTimeout,S)}catch(E){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(E),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw E}finally{this.queue.delete(m)}}),Oi(this,"on",(i,n)=>{this.events.on(i,n)}),Oi(this,"once",(i,n)=>{this.events.once(i,n)}),Oi(this,"off",(i,n)=>{this.events.off(i,n)}),Oi(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=Ir(r,this.name),this.registerEventListeners()}get context(){return Tr(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=dm,prompt:l,tag:u,id:m,attestation:x,tvf:S}=e,E={method:ja(yl().protocol).publish,params:Fl({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:x},S),id:m};Sr((r=E.params)==null?void 0:r.prompt)&&((i=E.params)==null||delete i.prompt),Sr((n=E.params)==null?void 0:n.tag)&&((s=E.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:E});const A=await this.relayer.request(E);return this.relayer.events.emit(Qt.publish,e),this.logger.debug("Successfully Published Payload"),A}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Ru(Fl({},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(Ru(Fl({},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(Io.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Qt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Qt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var NM=Object.defineProperty,TM=(t,e,r)=>e in t?NM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Po=(t,e,r)=>TM(t,typeof e!="symbol"?e+"":e,r);class FM{constructor(){Po(this,"map",new Map),Po(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),Po(this,"get",e=>this.map.get(e)||[]),Po(this,"exists",(e,r)=>this.get(e).includes(r)),Po(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)}),Po(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var LM=Object.defineProperty,BM=Object.defineProperties,UM=Object.getOwnPropertyDescriptors,Tm=Object.getOwnPropertySymbols,qM=Object.prototype.hasOwnProperty,jM=Object.prototype.propertyIsEnumerable,Nu=(t,e,r)=>e in t?LM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,tc=(t,e)=>{for(var r in e||(e={}))qM.call(e,r)&&Nu(t,r,e[r]);if(Tm)for(var r of Tm(e))jM.call(e,r)&&Nu(t,r,e[r]);return t},Tu=(t,e)=>BM(t,UM(e)),xt=(t,e,r)=>Nu(t,typeof e!="symbol"?e+"":e,r);class kM extends vS{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,xt(this,"subscriptions",new Map),xt(this,"topicMap",new FM),xt(this,"events",new nr.exports.EventEmitter),xt(this,"name",DI),xt(this,"version",RI),xt(this,"pending",new Map),xt(this,"cached",[]),xt(this,"initialized",!1),xt(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),xt(this,"pollingInterval",20),xt(this,"storagePrefix",Ji),xt(this,"subscribeTimeout",X.toMiliseconds(X.ONE_MINUTE)),xt(this,"initialSubscribeTimeout",X.toMiliseconds(X.ONE_SECOND*15)),xt(this,"clientId"),xt(this,"batchSubscribeTopicsLimit",500),xt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),xt(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=yl(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}}),xt(this,"unsubscribe",async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),xt(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new X.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(l=>l.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=NI&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),xt(this,"on",(i,n)=>{this.events.on(i,n)}),xt(this,"once",(i,n)=>{this.events.once(i,n)}),xt(this,"off",(i,n)=>{this.events.off(i,n)}),xt(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),xt(this,"start",async()=>{await this.onConnect()}),xt(this,"stop",async()=>{await this.onDisconnect()}),xt(this,"restart",async()=>{await this.restore(),await this.onRestart()}),xt(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)}),xt(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(Io.pulse,async()=>{await this.checkPending()}),this.events.on(Zr.created,async i=>{const n=Zr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(Zr.deleted,async i=>{const n=Zr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=Ir(r,this.name),this.clientId=""}get context(){return Tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){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=yl(i);await this.rpcUnsubscribe(e,r,n);const s=wt("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?.transportType===St.relay&&await this.restartToComplete();const s={method:ja(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===St.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},X.toMiliseconds(X.ONE_SECOND)),a;const c=new Promise(async u=>{const m=x=>{x.topic===e&&(this.events.removeListener(Zr.created,m),u(x.id))};this.events.on(Zr.created,m);try{const x=await Hn(new Promise((S,E)=>{this.relayer.request(s).catch(A=>{this.logger.warn(A,A?.message),E(A)}).then(S)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Zr.created,m),u(x)}catch{}}),l=await Hn(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Qt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:ja(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 Hn(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(Qt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:ja(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 Hn(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(Qt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:ja(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,Tu(tc({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,tc({},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,tc({},r)),this.topicMap.set(r.topic,e),this.events.emit(Zr.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}=ee("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(Zr.deleted,Tu(tc({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Zr.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(Zr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=ee("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=>Tu(tc({},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 b_(X.toMiliseconds(X.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}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return gn(e+await this.getClientId())}}var zM=Object.defineProperty,Fm=Object.getOwnPropertySymbols,HM=Object.prototype.hasOwnProperty,WM=Object.prototype.propertyIsEnumerable,Fu=(t,e,r)=>e in t?zM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lm=(t,e)=>{for(var r in e||(e={}))HM.call(e,r)&&Fu(t,r,e[r]);if(Fm)for(var r of Fm(e))WM.call(e,r)&&Fu(t,r,e[r]);return t},rt=(t,e,r)=>Fu(t,typeof e!="symbol"?e+"":e,r);class VM extends pS{constructor(e){super(e),rt(this,"protocol","wc"),rt(this,"version",2),rt(this,"core"),rt(this,"logger"),rt(this,"events",new nr.exports.EventEmitter),rt(this,"provider"),rt(this,"messages"),rt(this,"subscriber"),rt(this,"publisher"),rt(this,"name",AI),rt(this,"transportExplicitlyClosed",!1),rt(this,"initialized",!1),rt(this,"connectionAttemptInProgress",!1),rt(this,"relayUrl"),rt(this,"projectId"),rt(this,"packageName"),rt(this,"bundleId"),rt(this,"hasExperiencedNetworkDisruption",!1),rt(this,"pingTimeout"),rt(this,"heartBeatTimeout",X.toMiliseconds(X.THIRTY_SECONDS+X.FIVE_SECONDS)),rt(this,"reconnectTimeout"),rt(this,"connectPromise"),rt(this,"requestsInFlight",[]),rt(this,"connectTimeout",X.toMiliseconds(X.ONE_SECOND*15)),rt(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||Ps().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}}),rt(this,"resetPingTimeout",()=>{if(ll())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),rt(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),rt(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Qt.connect)}),rt(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()}),rt(this,"onProviderErrorHandler",r=>{this.logger.fatal(r,`Fatal socket error: ${r?.message}`),this.events.emit(Qt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),rt(this,"registerProviderListeners",()=>{this.provider.on(di.payload,this.onPayloadHandler),this.provider.on(di.connect,this.onConnectHandler),this.provider.on(di.disconnect,this.onDisconnectHandler),this.provider.on(di.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ir(e.logger,this.name):Vi(Ol({level:e.logger||II})),this.messages=new AM(this.logger,e.core),this.subscriber=new kM(this,this.logger),this.publisher=new RM(this,this.logger),this.relayUrl=e?.relayUrl||gm,this.projectId=e.projectId,i_()?this.packageName=yg():n_()&&(this.bundleId=yg()),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.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return Tr(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}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}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:St.relay})}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 l=u=>{u.topic===e&&(this.subscriber.off(Zr.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(Zr.created,l)}),new Promise(async(u,m)=>{a=await this.subscriber.subscribe(e,Lm({internal:{throwOnFailedPublish:o}},r)).catch(x=>{o&&m(x)})||a,u()})]),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 Hn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){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 Dv())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=Wt(X.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Qt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{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(di.disconnect,s),await Hn(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(di.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(di.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(di.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,X.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(ll())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 ui(new uI(c_({sdkVersion:Mu,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}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.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed 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}),Iu(e)){if(!e.method.endsWith(MI))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:St.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Lm({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Rl(e)&&this.events.emit(Qt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Qt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Cl(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(di.payload,this.onPayloadHandler),this.provider.off(di.connect,this.onConnectHandler),this.provider.off(di.disconnect,this.onDisconnectHandler),this.provider.off(di.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Dv();JE(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))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(Qt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e?.message))},X.toMiliseconds(PI))))}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var KM=Object.defineProperty,Bm=Object.getOwnPropertySymbols,GM=Object.prototype.hasOwnProperty,JM=Object.prototype.propertyIsEnumerable,Lu=(t,e,r)=>e in t?KM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Um=(t,e)=>{for(var r in e||(e={}))GM.call(e,r)&&Lu(t,r,e[r]);if(Bm)for(var r of Bm(e))JM.call(e,r)&&Lu(t,r,e[r]);return t},Fr=(t,e,r)=>Lu(t,typeof e!="symbol"?e+"":e,r);class Rs extends gS{constructor(e,r,i,n=Ji,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,Fr(this,"map",new Map),Fr(this,"version",OI),Fr(this,"cached",[]),Fr(this,"initialized",!1),Fr(this,"getKey"),Fr(this,"storagePrefix",Ji),Fr(this,"recentlyDeleted",[]),Fr(this,"recentlyDeletedLimit",200),Fr(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Sr(o)?this.map.set(this.getKey(o),o):IE(o)?this.map.set(o.id,o):AE(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Fr(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())}),Fr(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Fr(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>dI(a[c],o[c]))):this.values)),Fr(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=Um(Um({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Fr(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=Ir(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Tr(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}=ee("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=ee("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}=ee("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}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var ZM=Object.defineProperty,YM=(t,e,r)=>e in t?ZM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ne=(t,e,r)=>YM(t,typeof e!="symbol"?e+"":e,r);class XM{constructor(e,r){this.core=e,this.logger=r,Ne(this,"name",TI),Ne(this,"version",FI),Ne(this,"events",new nr.exports),Ne(this,"pairings"),Ne(this,"initialized",!1),Ne(this,"storagePrefix",Ji),Ne(this,"ignoredPayloadTypes",[pn]),Ne(this,"registeredMethods",[]),Ne(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Ne(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),Ne(this,"create",async i=>{this.isInitialized();const n=hu(),s=await this.core.crypto.setSymKey(n),o=Wt(X.FIVE_MINUTES),a={protocol:pm},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},l=$v({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Os.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:l}}),Ne(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Zi.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Ev(i.uri);n.props.properties.topic=s,n.addTrace(Zi.pairing_uri_validation_success),n.addTrace(Zi.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(Zi.existing_pairing),u.active)throw n.setError(yn.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Zi.pairing_not_expired)}const m=c||Wt(X.FIVE_MINUTES),x={topic:s,relay:a,expiry:m,active:!1,methods:l};this.core.expirer.set(s,m),await this.pairings.set(s,x),n.addTrace(Zi.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Os.create,x),n.addTrace(Zi.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Zi.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(yn.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(S){throw n.setError(yn.subscribe_pairing_topic_failure),S}return n.addTrace(Zi.subscribe_pairing_topic_success),x}),Ne(this,"activate",async({topic:i})=>{this.isInitialized();const n=Wt(X.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),Ne(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}=$s();this.events.once(Oe("pairing_ping",s),({error:l})=>{l?c(l):a()}),await o()}}),Ne(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),Ne(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),Ne(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Ne(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",wt("USER_DISCONNECTED")),await this.deletePairing(n))}),Ne(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return $v({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),Ne(this,"sendRequest",async(i,n,s)=>{const o=Zn(n,s),a=await this.core.crypto.encode(i,o),c=Ya[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),Ne(this,"sendResult",async(i,n,s)=>{const o=Cl(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=Ya[c.request.method].res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)}),Ne(this,"sendError",async(i,n,s)=>{const o=Dl(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=Ya[c.request.method]?Ya[c.request.method].res:Ya.unregistered_method.res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)}),Ne(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,wt("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),Ne(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>Wn(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),Ne(this,"onRelayEventRequest",i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}}),Ne(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)}}),Ne(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Os.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),Ne(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{Gi(n)?this.events.emit(Oe("pairing_ping",s),{}):fi(n)&&this.events.emit(Oe("pairing_ping",s),{error:n.error})},500)}),Ne(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Os.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),Ne(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=wt("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)}}),Ne(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(wt("WC_METHOD_UNSUPPORTED",i))}),Ne(this,"isValidPair",(i,n)=>{var s;if(!Rr(i)){const{message:a}=ee("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(yn.malformed_pairing_uri),new Error(a)}if(!SE(i.uri)){const{message:a}=ee("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(yn.malformed_pairing_uri),new Error(a)}const o=Ev(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=ee("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(yn.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=ee("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(yn.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&X.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(yn.pairing_expired);const{message:a}=ee("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),Ne(this,"isValidPing",async i=>{if(!Rr(i)){const{message:s}=ee("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),Ne(this,"isValidDisconnect",async i=>{if(!Rr(i)){const{message:s}=ee("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),Ne(this,"isValidPairingTopic",async i=>{if(!Ut(i,!1)){const{message:n}=ee("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=ee("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Wn(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=ee("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=Ir(r,this.name),this.pairings=new Rs(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Tr(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Qt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===St.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Iu(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Rl(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(pi.expired,async e=>{const{topic:r}=Sg(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Os.expire,{topic:r}))})}}var QM=Object.defineProperty,eP=(t,e,r)=>e in t?QM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dr=(t,e,r)=>eP(t,typeof e!="symbol"?e+"":e,r);class tP extends fS{constructor(e,r){super(e,r),this.core=e,this.logger=r,dr(this,"records",new Map),dr(this,"events",new nr.exports.EventEmitter),dr(this,"name",LI),dr(this,"version",BI),dr(this,"cached",[]),dr(this,"initialized",!1),dr(this,"storagePrefix",Ji),dr(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)}),dr(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:Wt(X.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Mi.created,o)}),dr(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=fi(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Mi.updated,n))}),dr(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))),dr(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(Mi.deleted,s)}}),this.persist()}),dr(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),dr(this,"on",(i,n)=>{this.events.on(i,n)}),dr(this,"once",(i,n)=>{this.events.once(i,n)}),dr(this,"off",(i,n)=>{this.events.off(i,n)}),dr(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Ir(r,this.name)}get context(){return Tr(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:Zn(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}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Mi.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=ee("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(Mi.created,e=>{const r=Mi.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Mi.updated,e=>{const r=Mi.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Mi.deleted,e=>{const r=Mi.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Io.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{X.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Mi.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var rP=Object.defineProperty,iP=(t,e,r)=>e in t?rP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,br=(t,e,r)=>iP(t,typeof e!="symbol"?e+"":e,r);class nP extends mS{constructor(e,r){super(e,r),this.core=e,this.logger=r,br(this,"expirations",new Map),br(this,"events",new nr.exports.EventEmitter),br(this,"name",UI),br(this,"version",qI),br(this,"cached",[]),br(this,"initialized",!1),br(this,"storagePrefix",Ji),br(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)}),br(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),br(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(pi.created,{target:s,expiration:o})}),br(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),br(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(pi.deleted,{target:n,expiration:s})}}),br(this,"on",(i,n)=>{this.events.on(i,n)}),br(this,"once",(i,n)=>{this.events.once(i,n)}),br(this,"off",(i,n)=>{this.events.off(i,n)}),br(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Ir(r,this.name)}get context(){return Tr(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 l_(e);if(typeof e=="number")return h_(e);const{message:r}=ee("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(pi.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=ee("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}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;X.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(pi.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Io.pulse,()=>this.checkExpirations()),this.events.on(pi.created,e=>{const r=pi.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(pi.expired,e=>{const r=pi.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(pi.deleted,e=>{const r=pi.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}var sP=Object.defineProperty,oP=(t,e,r)=>e in t?sP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jt=(t,e,r)=>oP(t,typeof e!="symbol"?e+"":e,r);class aP extends bS{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,jt(this,"name",jI),jt(this,"abortController"),jt(this,"isDevEnv"),jt(this,"verifyUrlV3",zI),jt(this,"storagePrefix",Ji),jt(this,"version",fm),jt(this,"publicKey"),jt(this,"fetchPromise"),jt(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&X.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),jt(this,"register",async n=>{if(!Oa()||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 l=va(),u=this.startAbortTimer(X.ONE_SECOND*5),m=await new Promise((x,S)=>{const E=()=>{window.removeEventListener("message",R),l.body.removeChild(A),S("attestation aborted")};this.abortController.signal.addEventListener("abort",E);const A=l.createElement("iframe");A.src=c,A.style.display="none",A.addEventListener("error",E,{signal:this.abortController.signal});const R=O=>{if(O.data&&typeof O.data=="string")try{const C=JSON.parse(O.data);if(C.type==="verify_attestation"){if(Pf(C.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(A),this.abortController.signal.removeEventListener("abort",E),window.removeEventListener("message",R),x(C.attestation===null?"":C.attestation)}}catch(C){this.logger.warn(C)}};l.body.appendChild(A),window.addEventListener("message",R,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",m),m}catch(l){this.logger.warn(l)}return""}),jt(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(Pf(s).payload.id!==a)return;const l=await this.isValidJwtAttestation(s);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),jt(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(X.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}),jt(this,"getVerifyUrl",n=>{let s=n||Xa;return HI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Xa}`),s=Xa),s}),jt(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(X.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)}}),jt(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),jt(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),jt(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")}}),jt(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),jt(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}),jt(this,"validateAttestation",(n,s)=>{const o=uE(n,s.publicKey),a={hasExpired:X.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=Ir(r,this.name),this.abortController=new AbortController,this.isDevEnv=Wf(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Tr(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),X.toMiliseconds(e))}}var cP=Object.defineProperty,lP=(t,e,r)=>e in t?cP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qm=(t,e,r)=>lP(t,typeof e!="symbol"?e+"":e,r);class hP extends yS{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,qm(this,"context",WI),qm(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${VI}/${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=Ir(r,this.context)}}var fP=Object.defineProperty,jm=Object.getOwnPropertySymbols,uP=Object.prototype.hasOwnProperty,dP=Object.prototype.propertyIsEnumerable,Bu=(t,e,r)=>e in t?fP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rc=(t,e)=>{for(var r in e||(e={}))uP.call(e,r)&&Bu(t,r,e[r]);if(jm)for(var r of jm(e))dP.call(e,r)&&Bu(t,r,e[r]);return t},er=(t,e,r)=>Bu(t,typeof e!="symbol"?e+"":e,r);class pP extends wS{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,er(this,"context",GI),er(this,"storagePrefix",Ji),er(this,"storageVersion",KI),er(this,"events",new Map),er(this,"shouldPersist",!1),er(this,"init",async()=>{if(!Wf())try{const n={eventId:Ag(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:_g(this.core.relayer.protocol,this.core.relayer.version,Mu)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),er(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,l=Ag(),u=this.core.projectId||"",m=Date.now(),x=rc({eventId:l,timestamp:m,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,x),this.shouldPersist=!0),x}),er(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 rc(rc({},a),this.setMethods(a.eventId))}),er(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),er(this,"setEventListeners",()=>{this.core.heartbeat.on(Io.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{X.fromMiliseconds(Date.now())-X.fromMiliseconds(n.timestamp)>JI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),er(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),er(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)}),er(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)}),er(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),er(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,rc(rc({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),er(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)}}),er(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${ZI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Mu}${s}`,{method:"POST",body:JSON.stringify(n)})}),er(this,"getAppDomain",()=>wg().url),this.logger=Ir(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 gP=Object.defineProperty,km=Object.getOwnPropertySymbols,vP=Object.prototype.hasOwnProperty,mP=Object.prototype.propertyIsEnumerable,Uu=(t,e,r)=>e in t?gP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zm=(t,e)=>{for(var r in e||(e={}))vP.call(e,r)&&Uu(t,r,e[r]);if(km)for(var r of km(e))mP.call(e,r)&&Uu(t,r,e[r]);return t},It=(t,e,r)=>Uu(t,typeof e!="symbol"?e+"":e,r);class qu extends aS{constructor(e){var r;super(e),It(this,"protocol",hm),It(this,"version",fm),It(this,"name",Nl),It(this,"relayUrl"),It(this,"projectId"),It(this,"customStoragePrefix"),It(this,"events",new nr.exports.EventEmitter),It(this,"logger"),It(this,"heartbeat"),It(this,"relayer"),It(this,"crypto"),It(this,"storage"),It(this,"history"),It(this,"expirer"),It(this,"pairing"),It(this,"verify"),It(this,"echoClient"),It(this,"linkModeSupportedApps"),It(this,"eventClient"),It(this,"initialized",!1),It(this,"logChunkController"),It(this,"on",(o,a)=>this.events.on(o,a)),It(this,"once",(o,a)=>this.events.once(o,a)),It(this,"off",(o,a)=>this.events.off(o,a)),It(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),It(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const l={topic:o,message:a,publishedAt:Date.now(),transportType:St.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:c})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||gm,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Ol({level:typeof e?.logger=="string"&&e.logger?e.logger:mI.logger,name:Nl}),{logger:n,chunkLoggerController:s}=nS({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ir(n,this.name),this.heartbeat=new gu,this.crypto=new $M(this,this.logger,e?.keychain),this.history=new tP(this,this.logger),this.expirer=new nP(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new O$(zm(zm({},bI),e?.storageOptions)),this.relayer=new VM({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new XM(this,this.logger),this.verify=new aP(this,this.logger,this.storage),this.echoClient=new hP(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new pP(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new qu(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(CI,i),r}get context(){return Tr(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(vm,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(vm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const bP=qu,Hm="wc",Wm=2,Vm="client",ju=`${Hm}@${Wm}:${Vm}:`,ku={name:Vm,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Km="WALLETCONNECT_DEEPLINK_CHOICE",yP="proposal",Gm="Proposal expired",wP="session",Oo=X.SEVEN_DAYS,_P="engine",tr={wc_sessionPropose:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1104},res:{ttl:X.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1106},res:{ttl:X.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1112},res:{ttl:X.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1114},res:{ttl:X.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:X.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:X.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1119}}},zu={min:X.FIVE_MINUTES,max:X.SEVEN_DAYS},Qi={idle:"IDLE",active:"ACTIVE"},Jm={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},xP="request",EP=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],$P="wc",SP="auth",IP="authKeys",AP="pairingTopics",MP="requests",Ll=`${$P}@${1.5}:${SP}:`,Bl=`${Ll}:PUB_KEY`;var PP=Object.defineProperty,OP=Object.defineProperties,CP=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,DP=Object.prototype.hasOwnProperty,RP=Object.prototype.propertyIsEnumerable,Hu=(t,e,r)=>e in t?PP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,At=(t,e)=>{for(var r in e||(e={}))DP.call(e,r)&&Hu(t,r,e[r]);if(Zm)for(var r of Zm(e))RP.call(e,r)&&Hu(t,r,e[r]);return t},Lr=(t,e)=>OP(t,CP(e)),Z=(t,e,r)=>Hu(t,typeof e!="symbol"?e+"":e,r);class NP extends $S{constructor(e){super(e),Z(this,"name",_P),Z(this,"events",new nr.exports),Z(this,"initialized",!1),Z(this,"requestQueue",{state:Qi.idle,queue:[]}),Z(this,"sessionRequestQueue",{state:Qi.idle,queue:[]}),Z(this,"requestQueueDelay",X.ONE_SECOND),Z(this,"expectedPairingMethodMap",new Map),Z(this,"recentlyDeletedMap",new Map),Z(this,"recentlyDeletedLimit",200),Z(this,"relayMessageCache",[]),Z(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(tr)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},X.toMiliseconds(this.requestQueueDelay)))}),Z(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Lr(At({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let l=n,u,m=!1;try{if(l){const T=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."),m=T.active}}catch(T){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),T}if(!l||!m){const{topic:T,uri:U}=await this.client.core.pairing.create();l=T,u=U}if(!l){const{message:T}=ee("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(T)}const x=await this.client.core.crypto.generateKeyPair(),S=tr.wc_sessionPropose.req.ttl||X.FIVE_MINUTES,E=Wt(S),A=At({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:pm}],proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:E,pairingTopic:l},a&&{sessionProperties:a}),{reject:R,resolve:O,done:C}=$s(S,Gm);this.events.once(Oe("session_connect"),async({error:T,session:U})=>{if(T)R(T);else if(U){U.self.publicKey=x;const z=Lr(At({},U),{pairingTopic:A.pairingTopic,requiredNamespaces:A.requiredNamespaces,optionalNamespaces:A.optionalNamespaces,transportType:St.relay});await this.client.session.set(U.topic,z),await this.setExpiry(U.topic,U.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:U.peer.metadata}),this.cleanupDuplicatePairings(z),O(z)}});const N=await this.sendRequest({topic:l,method:"wc_sessionPropose",params:A,throwOnFailedPublish:!0});return await this.setProposal(N,At({id:N},A)),{uri:u,approval:C}}),Z(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}}),Z(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:[Pi.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(V){throw o.setError(Cs.no_internet_connection),V}try{await this.isValidProposalId(r?.id)}catch(V){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Cs.proposal_not_found),V}try{await this.isValidApprove(r)}catch(V){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Cs.session_approve_namespace_validation_failure),V}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,sessionConfig:m}=r,x=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:S,proposer:E,requiredNamespaces:A,optionalNamespaces:R}=x;let O=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:S});O||(O=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Pi.session_approve_started,properties:{topic:S,trace:[Pi.session_approve_started,Pi.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),N=E.publicKey,T=await this.client.core.crypto.generateSharedKey(C,N),U=At(At({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:C,metadata:this.client.metadata},expiry:Wt(Oo)},u&&{sessionProperties:u}),m&&{sessionConfig:m}),z=St.relay;O.addTrace(Pi.subscribing_session_topic);try{await this.client.core.relayer.subscribe(T,{transportType:z})}catch(V){throw O.setError(Cs.subscribe_session_topic_failure),V}O.addTrace(Pi.subscribe_session_topic_success);const W=Lr(At({},U),{topic:T,requiredNamespaces:A,optionalNamespaces:R,pairingTopic:S,acknowledged:!1,self:U.controller,peer:{publicKey:E.publicKey,metadata:E.metadata},controller:C,transportType:St.relay});await this.client.session.set(T,W),O.addTrace(Pi.store_session);try{O.addTrace(Pi.publishing_session_settle),await this.sendRequest({topic:T,method:"wc_sessionSettle",params:U,throwOnFailedPublish:!0}).catch(V=>{throw O?.setError(Cs.session_settle_publish_failure),V}),O.addTrace(Pi.session_settle_publish_success),O.addTrace(Pi.publishing_session_approve),await this.sendResult({id:a,topic:S,result:{relay:{protocol:c??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(V=>{throw O?.setError(Cs.session_approve_publish_failure),V}),O.addTrace(Pi.session_approve_publish_success)}catch(V){throw this.client.logger.error(V),this.client.session.delete(T,wt("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(T),V}return this.client.core.eventClient.deleteEvent({eventId:O.eventId}),await this.client.core.pairing.updateMetadata({topic:S,metadata:E.metadata}),await this.client.proposal.delete(a,wt("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:S}),await this.setExpiry(T,Wt(Oo)),{topic:T,acknowledged:()=>Promise.resolve(this.client.session.get(T))}}),Z(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:tr.wc_sessionPropose.reject}),await this.client.proposal.delete(i,wt("USER_DISCONNECTED")))}),Z(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(m){throw this.client.logger.error("update() -> isValidUpdate() failed"),m}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=$s(),c=bn(),l=Ps().toString(),u=this.client.session.get(i).namespaces;return this.events.once(Oe("session_update",c),({error:m})=>{m?a(m):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:l}).catch(m=>{this.client.logger.error(m),this.client.session.update(i,{namespaces:u}),a(m)}),{acknowledged:s}}),Z(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=bn(),{done:s,resolve:o,reject:a}=$s();return this.events.once(Oe("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,Wt(Oo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),Z(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(O){throw this.client.logger.error("request() -> isValidRequest() failed"),O}const{chainId:i,request:n,topic:s,expiry:o=tr.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===St.relay&&await this.confirmOnlineStateOrThrow();const c=bn(),l=Ps().toString(),{done:u,resolve:m,reject:x}=$s(o,"Request expired. Please try again.");this.events.once(Oe("session_request",c),({error:O,result:C})=>{O?x(O):m(C)});const S="wc_sessionRequest",E=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(E)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:s,method:S,params:{request:Lr(At({},n),{expiryTimestamp:Wt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:E}).catch(O=>x(O)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await u();const A={request:Lr(At({},n),{expiryTimestamp:Wt(o)}),chainId:i},R=this.shouldSetTVF(S,A);return await Promise.all([new Promise(async O=>{await this.sendRequest(At({clientRpcId:c,relayRpcId:l,topic:s,method:S,params:A,expiry:o,throwOnFailedPublish:!0},R&&{tvf:this.getTVFParams(c,A)})).catch(C=>x(C)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),O()}),new Promise(async O=>{var C;if(!((C=a.sessionConfig)!=null&&C.disableDeepLink)){const N=await p_(this.client.core.storage,Km);await f_({id:c,topic:s,wcDeepLink:N})}O()}),u()]).then(O=>O[2])}),Z(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===St.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Gi(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):fi(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),Z(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=bn(),s=Ps().toString(),{done:o,resolve:a,reject:c}=$s();this.events.once(Oe("session_ping",n),({error:l})=>{l?c(l):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}))}),Z(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=Ps().toString(),a=bn();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),Z(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:wt("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}=ee("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),Z(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>EE(i,r)))),Z(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),Z(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?St.link_mode:St.relay;o===St.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:m,type:x,exp:S,nbf:E,methods:A=[],expiry:R}=r,O=[...r.resources||[]],{topic:C,uri:N}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:C,uri:N}});const T=await this.client.core.crypto.generateKeyPair(),U=bl(T);if(await Promise.all([this.client.auth.authKeys.set(Bl,{responseTopic:U,publicKey:T}),this.client.auth.pairingTopics.set(U,{topic:U,pairingTopic:C})]),await this.client.core.relayer.subscribe(U,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${C}`),A.length>0){const{namespace:$}=bo(a[0]);let y=ix($,"request",A);pl(O)&&(y=sx(y,O.pop())),O.push(y)}const z=R&&R>tr.wc_sessionAuthenticate.req.ttl?R:tr.wc_sessionAuthenticate.req.ttl,W={authPayload:{type:x??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:m,iat:new Date().toISOString(),exp:S,nbf:E,resources:O},requester:{publicKey:T,metadata:this.client.metadata},expiryTimestamp:Wt(z)},V={eip155:{chains:a,methods:[...new Set(["personal_sign",...A])],events:["chainChanged","accountsChanged"]}},B={requiredNamespaces:{},optionalNamespaces:V,relays:[{protocol:"irn"}],pairingTopic:C,proposer:{publicKey:T,metadata:this.client.metadata},expiryTimestamp:Wt(tr.wc_sessionPropose.req.ttl)},{done:K,resolve:M,reject:v}=$s(z,"Request expired"),g=async({error:$,session:y})=>{if(this.events.off(Oe("session_request",f),h),$)v($);else if(y){y.self.publicKey=T,await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:y.peer.metadata});const d=this.client.session.get(y.topic);await this.deleteProposal(p),M({session:d})}},h=async $=>{var y,d,w;if(await this.deletePendingAuthRequest(f,{message:"fulfilled",code:0}),$.error){const k=wt("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return $.error.code===k.code?void 0:(this.events.off(Oe("session_connect"),g),v($.error.message))}await this.deleteProposal(p),this.events.off(Oe("session_connect"),g);const{cacaos:b,responder:P}=$.result,q=[],I=[];for(const k of b){await kg({cacao:k,projectId:this.client.core.projectId})||(this.client.logger.error(k,"Signature verification failed"),v(wt("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:H}=k,Y=pl(H.resources),Q=[Yf(H.iss)],J=dl(H.iss);if(Y){const ae=Wg(Y),re=Vg(Y);q.push(...ae),Q.push(...re)}for(const ae of Q)I.push(`${ae}:${J}`)}const F=await this.client.core.crypto.generateSharedKey(T,P.publicKey);let j;q.length>0&&(j={topic:F,acknowledged:!0,self:{publicKey:T,metadata:this.client.metadata},peer:P,controller:P.publicKey,expiry:Wt(Oo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:C,namespaces:Sv([...new Set(q)],[...new Set(I)]),transportType:o},await this.client.core.relayer.subscribe(F,{transportType:o}),await this.client.session.set(F,j),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:P.metadata}),j=this.client.session.get(F)),(y=this.client.metadata.redirect)!=null&&y.linkMode&&(d=P.metadata.redirect)!=null&&d.linkMode&&(w=P.metadata.redirect)!=null&&w.universal&&i&&(this.client.core.addLinkModeSupportedApp(P.metadata.redirect.universal),this.client.session.update(F,{transportType:St.link_mode})),M({auths:b,session:j})},f=bn(),p=bn();this.events.once(Oe("session_connect"),g),this.events.once(Oe("session_request",f),h);let _;try{if(s){const $=Zn("wc_sessionAuthenticate",W,f);this.client.core.history.set(C,$);const y=await this.client.core.crypto.encode("",$,{type:Ba,encoding:Fa});_=wl(i,C,y)}else await Promise.all([this.sendRequest({topic:C,method:"wc_sessionAuthenticate",params:W,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:f}),this.sendRequest({topic:C,method:"wc_sessionPropose",params:B,expiry:tr.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:p})])}catch($){throw this.events.off(Oe("session_connect"),g),this.events.off(Oe("session_request",f),h),$}return await this.setProposal(p,At({id:p},B)),await this.setAuthRequest(f,{request:Lr(At({},W),{verifyContext:{}}),pairingTopic:C,transportType:o}),{uri:_??N,response:K}}),Z(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Ds.authenticated_session_approve_started]}});try{this.isInitialized()}catch(R){throw s.setError(Qa.no_internet_connection),R}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Qa.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||St.relay;a===St.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=bl(c),m={type:pn,receiverPublicKey:c,senderPublicKey:l},x=[],S=[];for(const R of n){if(!await kg({cacao:R,projectId:this.client.core.projectId})){s.setError(Qa.invalid_cacao);const U=wt("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:U,encodeOpts:m}),new Error(U.message)}s.addTrace(Ds.cacaos_verified);const{p:O}=R,C=pl(O.resources),N=[Yf(O.iss)],T=dl(O.iss);if(C){const U=Wg(C),z=Vg(C);x.push(...U),N.push(...z)}for(const U of N)S.push(`${U}:${T}`)}const E=await this.client.core.crypto.generateSharedKey(l,c);s.addTrace(Ds.create_authenticated_session_topic);let A;if(x?.length>0){A={topic:E,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:Wt(Oo),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Sv([...new Set(x)],[...new Set(S)]),transportType:a},s.addTrace(Ds.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:a})}catch(R){throw s.setError(Qa.subscribe_authenticated_session_topic_failure),R}s.addTrace(Ds.subscribe_authenticated_session_topic_success),await this.client.session.set(E,A),s.addTrace(Ds.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Ds.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:n,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:m,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(R){throw s.setError(Qa.authenticated_session_approve_publish_failure),R}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:A}}),Z(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===St.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=bl(o),l={type:pn,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:l,rpcOpts:tr.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,wt("USER_DISCONNECTED"))}),Z(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return zg(i,n)}),Z(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)}),Z(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)}}),Z(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,wt("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(Km).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===n&&this.deletePendingSessionRequest(l.id,wt("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Qi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),Z(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r),s=this.client.core.eventClient.getEvent({topic:n.pairingTopic});s?.setError(Cs.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,wt("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),Z(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=Qi.idle,this.client.events.emit("session_request_expire",{id:r}))}),Z(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)])}),Z(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}))}),Z(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,Wt(tr.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),Z(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=St.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})}),Z(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||Wt(tr.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})}),Z(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:m}=r,x=Zn(n,s,c);let S;const E=!!u;try{const O=E?Fa:Jn;S=await this.client.core.crypto.encode(i,x,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let A;if(EP.includes(n)){const O=gn(JSON.stringify(x)),C=gn(S);A=await this.client.core.verify.register({id:C,decryptedId:O})}const R=tr[n].req;if(R.attestation=A,o&&(R.ttl=o),a&&(R.id=a),this.client.core.history.set(i,x),E){const O=wl(u,i,S);await global.Linking.openURL(O,this.client.name)}else{const O=tr[n].req;o&&(O.ttl=o),a&&(O.id=a),O.tvf=Lr(At({},m),{correlationId:x.id}),l?(O.internal=Lr(At({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(C=>this.client.logger.error(C))}return x.id}),Z(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,l=Cl(i,s);let u;const m=c&&typeof(global==null?void 0:global.Linking)<"u";try{const E=m?Fa:Jn;u=await this.client.core.crypto.encode(n,l,Lr(At({},a||{}),{encoding:E}))}catch(E){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),E}let x,S;try{x=await this.client.core.history.get(n,i);const E=x.request;try{this.shouldSetTVF(E.method,E.params)&&(S=this.getTVFParams(i,E.params,s))}catch(A){this.client.logger.warn("sendResult() -> getTVFParams() failed",A)}}catch(E){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),E}if(m){const E=wl(c,n,u);await global.Linking.openURL(E,this.client.name)}else{const E=tr[x.request.method].res;E.tvf=Lr(At({},S),{correlationId:i}),o?(E.internal=Lr(At({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,u,E)):this.client.core.relayer.publish(n,u,E).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(l)}),Z(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,l=Dl(i,s);let u;const m=c&&typeof(global==null?void 0:global.Linking)<"u";try{const S=m?Fa:Jn;u=await this.client.core.crypto.encode(n,l,Lr(At({},o||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),S}let x;try{x=await this.client.core.history.get(n,i)}catch(S){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),S}if(m){const S=wl(c,n,u);await global.Linking.openURL(S,this.client.name)}else{const S=a||tr[x.request.method].res;this.client.core.relayer.publish(n,u,S)}await this.client.core.history.resolve(l)}),Z(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Wn(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=>{Wn(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),Z(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),Z(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Qi.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=Qi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Qi.idle}),Z(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}`)}}),Z(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}`)}}),Z(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=ee("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),Z(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)}),Z(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const l=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l?.setError(yn.proposal_listener_not_found)),this.isValidConnect(At({},n.params));const u=a.expiryTimestamp||Wt(tr.wc_sessionPropose.req.ttl),m=At({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,m);const x=await this.getVerifyContext({attestationId:s,hash:gn(JSON.stringify(n)),encryptedId:o,metadata:m.proposer.metadata});l?.addTrace(Zi.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:m,verifyContext:x})}catch(l){await this.sendError({id:c,topic:i,error:l,rpcOpts:tr.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),Z(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(Gi(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 l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:u});const m=await this.client.core.relayer.subscribe(u,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:m}),await this.client.core.pairing.activate({topic:r})}else if(fi(i)){await this.client.proposal.delete(s,wt("USER_DISCONNECTED"));const o=Oe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Oe("session_connect"),{error:i.error})}}),Z(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,sessionConfig:m}=i.params,x=Lr(At(At({topic:r,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),m&&{sessionConfig:m}),{transportType:St.relay}),S=Oe("session_connect");if(this.events.listenerCount(S)===0)throw new Error(`emitting ${S} without any listeners 997`);this.events.emit(Oe("session_connect"),{session:x}),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)}}),Z(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;Gi(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Oe("session_approve",n),{})):fi(i)&&(await this.client.session.delete(r,wt("USER_DISCONNECTED")),this.events.emit(Oe("session_approve",n),{error:i.error}))}),Z(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Ha.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:wt("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(At({topic:r},n));try{Ha.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 Ha.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)}}),Z(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),Z(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=Oe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gi(i)?this.events.emit(Oe("session_update",n),{}):fi(i)&&this.events.emit(Oe("session_update",n),{error:i.error})}),Z(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Wt(Oo)),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)}}),Z(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=Oe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gi(i)?this.events.emit(Oe("session_extend",n),{}):fi(i)&&this.events.emit(Oe("session_extend",n),{error:i.error})}),Z(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)}}),Z(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=Oe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Gi(i)?this.events.emit(Oe("session_ping",n),{}):fi(i)&&this.events.emit(Oe("session_ping",n),{error:i.error})},500)}),Z(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(Qt.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:wt("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),Z(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=r,{id:m,params:x}=a;try{await this.isValidRequest(At({topic:o},x));const S=this.client.session.get(o),E=await this.getVerifyContext({attestationId:c,hash:gn(JSON.stringify(Zn("wc_sessionRequest",x,m))),encryptedId:l,metadata:S.peer.metadata,transportType:u}),A={id:m,topic:o,params:x,verifyContext:E};await this.setPendingSessionRequest(A),u===St.link_mode&&(i=S.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=S.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(A):(this.addSessionRequestToSessionRequestQueue(A),this.processSessionRequestQueue())}catch(S){await this.sendError({id:m,topic:o,error:S}),this.client.logger.error(S)}}),Z(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=Oe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gi(i)?this.events.emit(Oe("session_request",n),{result:i.result}):fi(i)&&this.events.emit(Oe("session_request",n),{error:i.error})}),Z(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Ha.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(At({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Ha.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),Z(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),Gi(i)?this.events.emit(Oe("session_request",n),{result:i.result}):fi(i)&&this.events.emit(Oe("session_request",n),{error:i.error})}),Z(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:l,authPayload:u,expiryTimestamp:m}=s.params,x=await this.getVerifyContext({attestationId:o,hash:gn(JSON.stringify(s)),encryptedId:a,metadata:l.metadata,transportType:c}),S={requester:l,pairingTopic:n,id:s.id,authPayload:u,verifyContext:x,expiryTimestamp:m};await this.setAuthRequest(s.id,{request:S,pairingTopic:n,transportType:c}),c===St.link_mode&&(i=l.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:x})}catch(l){this.client.logger.error(l);const u=s.params.requester.publicKey,m=await this.client.core.crypto.generateKeyPair(),x=this.getAppLinkIfEnabled(s.params.requester.metadata,c),S={type:pn,receiverPublicKey:u,senderPublicKey:m};await this.sendError({id:s.id,topic:n,error:l,encodeOpts:S,rpcOpts:tr.wc_sessionAuthenticate.autoReject,appLink:x})}}),Z(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),Z(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Qi.idle,this.processSessionRequestQueue()},X.toMiliseconds(this.requestQueueDelay))}),Z(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=Oe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Oe("session_request",s.request.id),{error:i})})}),Z(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Qi.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=Qi.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),Z(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),Z(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:Zn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),Z(this,"isValidConnect",async r=>{if(!Rr(r)){const{message:c}=ee("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(Sr(i)||await this.isValidPairingTopic(i),!TE(a,!0)){const{message:c}=ee("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!Sr(n)&&za(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Sr(s)&&za(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Sr(o)||this.validateSessionProps(o,"sessionProperties")}),Z(this,"validateNamespaces",(r,i)=>{const n=NE(r,"connect()",i);if(n)throw new Error(n.message)}),Z(this,"isValidApprove",async r=>{if(!Rr(r))throw new Error(ee("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=du(n,"approve()");if(c)throw new Error(c.message);const l=Ov(a.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!Ut(s,!0)){const{message:u}=ee("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(u)}Sr(o)||this.validateSessionProps(o,"sessionProperties")}),Z(this,"isValidReject",async r=>{if(!Rr(r)){const{message:s}=ee("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!LE(n)){const{message:s}=ee("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),Z(this,"isValidSessionSettleRequest",r=>{if(!Rr(r)){const{message:l}=ee("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Mv(i)){const{message:l}=ee("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=ME(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=du(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Wn(o)){const{message:l}=ee("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),Z(this,"isValidUpdate",async r=>{if(!Rr(r)){const{message:c}=ee("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=du(n,"update()");if(o)throw new Error(o.message);const a=Ov(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),Z(this,"isValidExtend",async r=>{if(!Rr(r)){const{message:n}=ee("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),Z(this,"isValidRequest",async r=>{if(!Rr(r)){const{message:c}=ee("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(!Pv(a,s)){const{message:c}=ee("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!BE(n)){const{message:c}=ee("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!jE(a,s,n.method)){const{message:c}=ee("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!WE(o,zu)){const{message:c}=ee("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${zu.min} and ${zu.max}`);throw new Error(c)}}),Z(this,"isValidRespond",async r=>{var i;if(!Rr(r)){const{message:o}=ee("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(!UE(s)){const{message:o}=ee("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),Z(this,"isValidPing",async r=>{if(!Rr(r)){const{message:n}=ee("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),Z(this,"isValidEmit",async r=>{if(!Rr(r)){const{message:a}=ee("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(!Pv(o,s)){const{message:a}=ee("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!qE(n)){const{message:a}=ee("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!kE(o,s,n.name)){const{message:a}=ee("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),Z(this,"isValidDisconnect",async r=>{if(!Rr(r)){const{message:n}=ee("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),Z(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(!Ut(n,!1))throw new Error("uri is required parameter");if(!Ut(s,!1))throw new Error("domain is required parameter");if(!Ut(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>bo(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=bo(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),Z(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Xa,validation:"UNKNOWN",origin:o.url||""}};try{if(a===St.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),Z(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach(n=>{if(!Ut(n,!1)){const{message:s}=ee("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})}),Z(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),Z(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)}}}),Z(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=ee("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),Z(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,l,u,m,x;return!r||i!==St.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&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=r?.redirect)==null?void 0:u.universal)!==void 0&&((m=r?.redirect)==null?void 0:m.universal)!==""&&((x=r?.redirect)==null?void 0:x.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),Z(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),Z(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=Ig(r,"topic")||"",n=decodeURIComponent(Ig(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:St.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),Z(this,"registerLinkModeListeners",async()=>{var r;if(Wf()||zn()&&(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)}}}),Z(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(Jm).includes(n.method)}),Z(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return Lr(At({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{}}),Z(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}),Z(this,"extractTxHashesFromResult",(r,i)=>{try{const n=Jm[r];if(typeof i=="string")return[i];const s=i[n.key];if(Wi(s))return s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Qt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Bl)?this.client.auth.authKeys.get(Bl):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===St.link_mode?Fa:Jn});try{Iu(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:gn(i)})):Rl(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)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(pi.expired,async e=>{const{topic:r,id:i}=Sg(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,ee("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,ee("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(Os.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Os.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ut(e,!1)){const{message:r}=ee("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}=ee("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Wn(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=ee("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!Ut(e,!1)){const{message:r}=ee("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}=ee("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Wn(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=ee("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=ee("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(Ut(e,!1)){const{message:r}=ee("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=ee("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!FE(e)){const{message:r}=ee("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=ee("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Wn(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=ee("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class TP extends Rs{constructor(e,r){super(e,r,yP,ju),this.core=e,this.logger=r}}class FP extends Rs{constructor(e,r){super(e,r,wP,ju),this.core=e,this.logger=r}}class LP extends Rs{constructor(e,r){super(e,r,xP,ju,i=>i.id),this.core=e,this.logger=r}}class BP extends Rs{constructor(e,r){super(e,r,IP,Ll,()=>Bl),this.core=e,this.logger=r}}class UP extends Rs{constructor(e,r){super(e,r,AP,Ll),this.core=e,this.logger=r}}class qP extends Rs{constructor(e,r){super(e,r,MP,Ll,i=>i.id),this.core=e,this.logger=r}}var jP=Object.defineProperty,kP=(t,e,r)=>e in t?jP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wu=(t,e,r)=>kP(t,typeof e!="symbol"?e+"":e,r);class zP{constructor(e,r){this.core=e,this.logger=r,Wu(this,"authKeys"),Wu(this,"pairingTopics"),Wu(this,"requests"),this.authKeys=new BP(this.core,this.logger),this.pairingTopics=new UP(this.core,this.logger),this.requests=new qP(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var HP=Object.defineProperty,WP=(t,e,r)=>e in t?HP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Te=(t,e,r)=>WP(t,typeof e!="symbol"?e+"":e,r);class Vu extends ES{constructor(e){super(e),Te(this,"protocol",Hm),Te(this,"version",Wm),Te(this,"name",ku.name),Te(this,"metadata"),Te(this,"core"),Te(this,"logger"),Te(this,"events",new nr.exports.EventEmitter),Te(this,"engine"),Te(this,"session"),Te(this,"proposal"),Te(this,"pendingRequest"),Te(this,"auth"),Te(this,"signConfig"),Te(this,"on",(i,n)=>this.events.on(i,n)),Te(this,"once",(i,n)=>this.events.once(i,n)),Te(this,"off",(i,n)=>this.events.off(i,n)),Te(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),Te(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),Te(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),Te(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),Te(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),Te(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||ku.name,this.metadata=e?.metadata||wg(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Vi(Ol({level:e?.logger||ku.logger}));this.core=e?.core||new bP(e),this.logger=Ir(r,this.name),this.session=new FP(this.core,this.logger),this.proposal=new TP(this.core,this.logger),this.pendingRequest=new LP(this.core,this.logger),this.engine=new NP(this),this.auth=new zP(this.core,this.logger)}static async init(e){const r=new Vu(e);return await r.initialize(),r}get context(){return Tr(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()},X.toMiliseconds(X.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var Ku={exports:{}};(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ft<"u"&&Ft,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 Ft<"u"&&Ft||{},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 l(f){return f&&DataView.prototype.isPrototypeOf(f)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],m=ArrayBuffer.isView||function(f){return f&&u.indexOf(Object.prototype.toString.call(f))>-1};function x(f){if(typeof f!="string"&&(f=String(f)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(f)||f==="")throw new TypeError('Invalid character in header field name: "'+f+'"');return f.toLowerCase()}function S(f){return typeof f!="string"&&(f=String(f)),f}function E(f){var p={next:function(){var _=f.shift();return{done:_===void 0,value:_}}};return c.iterable&&(p[Symbol.iterator]=function(){return p}),p}function A(f){this.map={},f instanceof A?f.forEach(function(p,_){this.append(_,p)},this):Array.isArray(f)?f.forEach(function(p){if(p.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+p.length);this.append(p[0],p[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(p){this.append(p,f[p])},this)}A.prototype.append=function(f,p){f=x(f),p=S(p);var _=this.map[f];this.map[f]=_?_+", "+p:p},A.prototype.delete=function(f){delete this.map[x(f)]},A.prototype.get=function(f){return f=x(f),this.has(f)?this.map[f]:null},A.prototype.has=function(f){return this.map.hasOwnProperty(x(f))},A.prototype.set=function(f,p){this.map[x(f)]=S(p)},A.prototype.forEach=function(f,p){for(var _ in this.map)this.map.hasOwnProperty(_)&&f.call(p,this.map[_],_,this)},A.prototype.keys=function(){var f=[];return this.forEach(function(p,_){f.push(_)}),E(f)},A.prototype.values=function(){var f=[];return this.forEach(function(p){f.push(p)}),E(f)},A.prototype.entries=function(){var f=[];return this.forEach(function(p,_){f.push([_,p])}),E(f)},c.iterable&&(A.prototype[Symbol.iterator]=A.prototype.entries);function R(f){if(!f._noBody){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}}function O(f){return new Promise(function(p,_){f.onload=function(){p(f.result)},f.onerror=function(){_(f.error)}})}function C(f){var p=new FileReader,_=O(p);return p.readAsArrayBuffer(f),_}function N(f){var p=new FileReader,_=O(p),$=/charset=([A-Za-z0-9_-]+)/.exec(f.type),y=$?$[1]:"utf-8";return p.readAsText(f,y),_}function T(f){for(var p=new Uint8Array(f),_=new Array(p.length),$=0;$<p.length;$++)_[$]=String.fromCharCode(p[$]);return _.join("")}function U(f){if(f.slice)return f.slice(0);var p=new Uint8Array(f.byteLength);return p.set(new Uint8Array(f)),p.buffer}function z(){return this.bodyUsed=!1,this._initBody=function(f){this.bodyUsed=this.bodyUsed,this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:c.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:c.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():c.arrayBuffer&&c.blob&&l(f)?(this._bodyArrayBuffer=U(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||m(f))?this._bodyArrayBuffer=U(f):this._bodyText=f=Object.prototype.toString.call(f):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof f=="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(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var f=R(this);if(f)return f;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 f=R(this);return f||(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(C);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var f=R(this);if(f)return f;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(T(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(K)}),this.json=function(){return this.text().then(JSON.parse)},this}var W=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function V(f){var p=f.toUpperCase();return W.indexOf(p)>-1?p:f}function B(f,p){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');p=p||{};var _=p.body;if(f instanceof B){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,p.headers||(this.headers=new A(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!_&&f._bodyInit!=null&&(_=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=p.credentials||this.credentials||"same-origin",(p.headers||!this.headers)&&(this.headers=new A(p.headers)),this.method=V(p.method||this.method||"GET"),this.mode=p.mode||this.mode||null,this.signal=p.signal||this.signal||function(){if("AbortController"in a){var d=new AbortController;return d.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")&&(p.cache==="no-store"||p.cache==="no-cache")){var $=/([?&])_=[^&]*/;if($.test(this.url))this.url=this.url.replace($,"$1_="+new Date().getTime());else{var y=/\?/;this.url+=(y.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}B.prototype.clone=function(){return new B(this,{body:this._bodyInit})};function K(f){var p=new FormData;return f.trim().split("&").forEach(function(_){if(_){var $=_.split("="),y=$.shift().replace(/\+/g," "),d=$.join("=").replace(/\+/g," ");p.append(decodeURIComponent(y),decodeURIComponent(d))}}),p}function M(f){var p=new A,_=f.replace(/\r?\n[\t ]+/g," ");return _.split("\r").map(function($){return $.indexOf(`
|
|
44
|
-
`)===0?$.substr(1,$.length):$}).forEach(function($){var y=$.split(":"),d=y.shift().trim();if(d){var w=y.join(":").trim();try{p.append(d,w)}catch(b){console.warn("Response "+b.message)}}}),p}z.call(B.prototype);function v(f,p){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(p||(p={}),this.type="default",this.status=p.status===void 0?200:p.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=p.statusText===void 0?"":""+p.statusText,this.headers=new A(p.headers),this.url=p.url||"",this._initBody(f)}z.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new A(this.headers),url:this.url})},v.error=function(){var f=new v(null,{status:200,statusText:""});return f.ok=!1,f.status=0,f.type="error",f};var g=[301,302,303,307,308];v.redirect=function(f,p){if(g.indexOf(p)===-1)throw new RangeError("Invalid status code");return new v(null,{status:p,headers:{location:f}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(p,_){this.message=p,this.name=_;var $=Error(p);this.stack=$.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function h(f,p){return new Promise(function(_,$){var y=new B(f,p);if(y.signal&&y.signal.aborted)return $(new o.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function w(){d.abort()}d.onload=function(){var q={statusText:d.statusText,headers:M(d.getAllResponseHeaders()||"")};y.url.indexOf("file://")===0&&(d.status<200||d.status>599)?q.status=200:q.status=d.status,q.url="responseURL"in d?d.responseURL:q.headers.get("X-Request-URL");var I="response"in d?d.response:d.responseText;setTimeout(function(){_(new v(I,q))},0)},d.onerror=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},d.ontimeout=function(){setTimeout(function(){$(new TypeError("Network request timed out"))},0)},d.onabort=function(){setTimeout(function(){$(new o.DOMException("Aborted","AbortError"))},0)};function b(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}if(d.open(y.method,b(y.url),!0),y.credentials==="include"?d.withCredentials=!0:y.credentials==="omit"&&(d.withCredentials=!1),"responseType"in d&&(c.blob?d.responseType="blob":c.arrayBuffer&&(d.responseType="arraybuffer")),p&&typeof p.headers=="object"&&!(p.headers instanceof A||a.Headers&&p.headers instanceof a.Headers)){var P=[];Object.getOwnPropertyNames(p.headers).forEach(function(q){P.push(x(q)),d.setRequestHeader(q,S(p.headers[q]))}),y.headers.forEach(function(q,I){P.indexOf(I)===-1&&d.setRequestHeader(I,q)})}else y.headers.forEach(function(q,I){d.setRequestHeader(I,q)});y.signal&&(y.signal.addEventListener("abort",w),d.onreadystatechange=function(){d.readyState===4&&y.signal.removeEventListener("abort",w)}),d.send(typeof y._bodyInit>"u"?null:y._bodyInit)})}return h.polyfill=!0,a.fetch||(a.fetch=h,a.Headers=A,a.Request=B,a.Response=v),o.Headers=A,o.Request=B,o.Response=v,o.fetch=h,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})(Ku,Ku.exports);var Ym=Ly(Ku.exports),VP=Object.defineProperty,KP=Object.defineProperties,GP=Object.getOwnPropertyDescriptors,Xm=Object.getOwnPropertySymbols,JP=Object.prototype.hasOwnProperty,ZP=Object.prototype.propertyIsEnumerable,Qm=(t,e,r)=>e in t?VP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eb=(t,e)=>{for(var r in e||(e={}))JP.call(e,r)&&Qm(t,r,e[r]);if(Xm)for(var r of Xm(e))ZP.call(e,r)&&Qm(t,r,e[r]);return t},tb=(t,e)=>KP(t,GP(e));const YP={Accept:"application/json","Content-Type":"application/json"},XP="POST",rb={headers:YP,method:XP},ib=10;class Ci{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new nr.exports.EventEmitter,this.isAvailable=!1,this.registering=!1,!im(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=ln(e),i=await(await Ym(this.url,tb(eb({},rb),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!im(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=ln({id:1,jsonrpc:"2.0",method:"test",params:[]});await Ym(e,tb(eb({},rb),{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"?ms(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Dl(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Yv(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ib&&this.events.setMaxListeners(ib)}}const nb="error",QP="wss://relay.walletconnect.org",eO="wc",tO="universal_provider",sb=`${eO}@2:${tO}:`,ob="https://rpc.walletconnect.org/v1/",Co="generic",rO=`${ob}bundler`,gi={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Ul=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function iO(){this.__data__=[],this.size=0}var nO=iO;function sO(t,e){return t===e||t!==t&&e!==e}var ql=sO,oO=ql;function aO(t,e){for(var r=t.length;r--;)if(oO(t[r][0],e))return r;return-1}var jl=aO,cO=jl,lO=Array.prototype,hO=lO.splice;function fO(t){var e=this.__data__,r=cO(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():hO.call(e,r,1),--this.size,!0}var uO=fO,dO=jl;function pO(t){var e=this.__data__,r=dO(e,t);return r<0?void 0:e[r][1]}var gO=pO,vO=jl;function mO(t){return vO(this.__data__,t)>-1}var bO=mO,yO=jl;function wO(t,e){var r=this.__data__,i=yO(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var _O=wO,xO=nO,EO=uO,$O=gO,SO=bO,IO=_O;function Do(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Do.prototype.clear=xO,Do.prototype.delete=EO,Do.prototype.get=$O,Do.prototype.has=SO,Do.prototype.set=IO;var kl=Do,AO=kl;function MO(){this.__data__=new AO,this.size=0}var PO=MO;function OO(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var CO=OO;function DO(t){return this.__data__.get(t)}var RO=DO;function NO(t){return this.__data__.has(t)}var TO=NO,FO=typeof Ul=="object"&&Ul&&Ul.Object===Object&&Ul,ab=FO,LO=ab,BO=typeof self=="object"&&self&&self.Object===Object&&self,UO=LO||BO||Function("return this")(),Ro=UO,qO=Ro,jO=qO.Symbol,cb=jO,lb=cb,hb=Object.prototype,kO=hb.hasOwnProperty,zO=hb.toString,ic=lb?lb.toStringTag:void 0;function HO(t){var e=kO.call(t,ic),r=t[ic];try{t[ic]=void 0;var i=!0}catch{}var n=zO.call(t);return i&&(e?t[ic]=r:delete t[ic]),n}var WO=HO,VO=Object.prototype,KO=VO.toString;function GO(t){return KO.call(t)}var JO=GO,fb=cb,ZO=WO,YO=JO,XO="[object Null]",QO="[object Undefined]",ub=fb?fb.toStringTag:void 0;function eC(t){return t==null?t===void 0?QO:XO:ub&&ub in Object(t)?ZO(t):YO(t)}var zl=eC;function tC(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Ns=tC,rC=zl,iC=Ns,nC="[object AsyncFunction]",sC="[object Function]",oC="[object GeneratorFunction]",aC="[object Proxy]";function cC(t){if(!iC(t))return!1;var e=rC(t);return e==sC||e==oC||e==nC||e==aC}var Gu=cC,lC=Ro,hC=lC["__core-js_shared__"],fC=hC,Ju=fC,db=function(){var t=/[^.]+$/.exec(Ju&&Ju.keys&&Ju.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function uC(t){return!!db&&db in t}var dC=uC,pC=Function.prototype,gC=pC.toString;function vC(t){if(t!=null){try{return gC.call(t)}catch{}try{return t+""}catch{}}return""}var mC=vC,bC=Gu,yC=dC,wC=Ns,_C=mC,xC=/[\\^$.*+?()[\]{}|]/g,EC=/^\[object .+?Constructor\]$/,$C=Function.prototype,SC=Object.prototype,IC=$C.toString,AC=SC.hasOwnProperty,MC=RegExp("^"+IC.call(AC).replace(xC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function PC(t){if(!wC(t)||yC(t))return!1;var e=bC(t)?MC:EC;return e.test(_C(t))}var OC=PC;function CC(t,e){return t?.[e]}var DC=CC,RC=OC,NC=DC;function TC(t,e){var r=NC(t,e);return RC(r)?r:void 0}var Zu=TC,FC=Zu,LC=Ro,BC=FC(LC,"Map"),pb=BC,UC=Zu,qC=UC(Object,"create"),Hl=qC,gb=Hl;function jC(){this.__data__=gb?gb(null):{},this.size=0}var kC=jC;function zC(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var HC=zC,WC=Hl,VC="__lodash_hash_undefined__",KC=Object.prototype,GC=KC.hasOwnProperty;function JC(t){var e=this.__data__;if(WC){var r=e[t];return r===VC?void 0:r}return GC.call(e,t)?e[t]:void 0}var ZC=JC,YC=Hl,XC=Object.prototype,QC=XC.hasOwnProperty;function eD(t){var e=this.__data__;return YC?e[t]!==void 0:QC.call(e,t)}var tD=eD,rD=Hl,iD="__lodash_hash_undefined__";function nD(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=rD&&e===void 0?iD:e,this}var sD=nD,oD=kC,aD=HC,cD=ZC,lD=tD,hD=sD;function No(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}No.prototype.clear=oD,No.prototype.delete=aD,No.prototype.get=cD,No.prototype.has=lD,No.prototype.set=hD;var fD=No,vb=fD,uD=kl,dD=pb;function pD(){this.size=0,this.__data__={hash:new vb,map:new(dD||uD),string:new vb}}var gD=pD;function vD(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var mD=vD,bD=mD;function yD(t,e){var r=t.__data__;return bD(e)?r[typeof e=="string"?"string":"hash"]:r.map}var Wl=yD,wD=Wl;function _D(t){var e=wD(this,t).delete(t);return this.size-=e?1:0,e}var xD=_D,ED=Wl;function $D(t){return ED(this,t).get(t)}var SD=$D,ID=Wl;function AD(t){return ID(this,t).has(t)}var MD=AD,PD=Wl;function OD(t,e){var r=PD(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var CD=OD,DD=gD,RD=xD,ND=SD,TD=MD,FD=CD;function To(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}To.prototype.clear=DD,To.prototype.delete=RD,To.prototype.get=ND,To.prototype.has=TD,To.prototype.set=FD;var LD=To,BD=kl,UD=pb,qD=LD,jD=200;function kD(t,e){var r=this.__data__;if(r instanceof BD){var i=r.__data__;if(!UD||i.length<jD-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new qD(i)}return r.set(t,e),this.size=r.size,this}var zD=kD,HD=kl,WD=PO,VD=CO,KD=RO,GD=TO,JD=zD;function Fo(t){var e=this.__data__=new HD(t);this.size=e.size}Fo.prototype.clear=WD,Fo.prototype.delete=VD,Fo.prototype.get=KD,Fo.prototype.has=GD,Fo.prototype.set=JD;var ZD=Fo,YD=Zu,XD=function(){try{var t=YD(Object,"defineProperty");return t({},"",{}),t}catch{}}(),mb=XD,bb=mb;function QD(t,e,r){e=="__proto__"&&bb?bb(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Yu=QD,eR=Yu,tR=ql;function rR(t,e,r){(r!==void 0&&!tR(t[e],r)||r===void 0&&!(e in t))&&eR(t,e,r)}var yb=rR;function iR(t){return function(e,r,i){for(var n=-1,s=Object(e),o=i(e),a=o.length;a--;){var c=o[t?a:++n];if(r(s[c],c,s)===!1)break}return e}}var nR=iR,sR=nR,oR=sR(),aR=oR,Xu={exports:{}};(function(t,e){var r=Ro,i=e&&!e.nodeType&&e,n=i&&!0&&t&&!t.nodeType&&t,s=n&&n.exports===i,o=s?r.Buffer:void 0,a=o?o.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var m=l.length,x=a?a(m):new l.constructor(m);return l.copy(x),x}t.exports=c})(Xu,Xu.exports);var cR=Ro,lR=cR.Uint8Array,hR=lR,wb=hR;function fR(t){var e=new t.constructor(t.byteLength);return new wb(e).set(new wb(t)),e}var uR=fR,dR=uR;function pR(t,e){var r=e?dR(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var gR=pR;function vR(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}var mR=vR,bR=Ns,_b=Object.create,yR=function(){function t(){}return function(e){if(!bR(e))return{};if(_b)return _b(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),wR=yR;function _R(t,e){return function(r){return t(e(r))}}var xR=_R,ER=xR,$R=ER(Object.getPrototypeOf,Object),xb=$R,SR=Object.prototype;function IR(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||SR;return t===r}var Eb=IR,AR=wR,MR=xb,PR=Eb;function OR(t){return typeof t.constructor=="function"&&!PR(t)?AR(MR(t)):{}}var CR=OR;function DR(t){return t!=null&&typeof t=="object"}var nc=DR,RR=zl,NR=nc,TR="[object Arguments]";function FR(t){return NR(t)&&RR(t)==TR}var LR=FR,$b=LR,BR=nc,Sb=Object.prototype,UR=Sb.hasOwnProperty,qR=Sb.propertyIsEnumerable,jR=$b(function(){return arguments}())?$b:function(t){return BR(t)&&UR.call(t,"callee")&&!qR.call(t,"callee")},Ib=jR,kR=Array.isArray,Ab=kR,zR=9007199254740991;function HR(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=zR}var Mb=HR,WR=Gu,VR=Mb;function KR(t){return t!=null&&VR(t.length)&&!WR(t)}var Qu=KR,GR=Qu,JR=nc;function ZR(t){return JR(t)&&GR(t)}var YR=ZR,Vl={exports:{}};function XR(){return!1}var QR=XR;(function(t,e){var r=Ro,i=QR,n=e&&!e.nodeType&&e,s=n&&!0&&t&&!t.nodeType&&t,o=s&&s.exports===n,a=o?r.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||i;t.exports=l})(Vl,Vl.exports);var eN=zl,tN=xb,rN=nc,iN="[object Object]",nN=Function.prototype,sN=Object.prototype,Pb=nN.toString,oN=sN.hasOwnProperty,aN=Pb.call(Object);function cN(t){if(!rN(t)||eN(t)!=iN)return!1;var e=tN(t);if(e===null)return!0;var r=oN.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Pb.call(r)==aN}var lN=cN,hN=zl,fN=Mb,uN=nc,dN="[object Arguments]",pN="[object Array]",gN="[object Boolean]",vN="[object Date]",mN="[object Error]",bN="[object Function]",yN="[object Map]",wN="[object Number]",_N="[object Object]",xN="[object RegExp]",EN="[object Set]",$N="[object String]",SN="[object WeakMap]",IN="[object ArrayBuffer]",AN="[object DataView]",MN="[object Float32Array]",PN="[object Float64Array]",ON="[object Int8Array]",CN="[object Int16Array]",DN="[object Int32Array]",RN="[object Uint8Array]",NN="[object Uint8ClampedArray]",TN="[object Uint16Array]",FN="[object Uint32Array]",Mt={};Mt[MN]=Mt[PN]=Mt[ON]=Mt[CN]=Mt[DN]=Mt[RN]=Mt[NN]=Mt[TN]=Mt[FN]=!0,Mt[dN]=Mt[pN]=Mt[IN]=Mt[gN]=Mt[AN]=Mt[vN]=Mt[mN]=Mt[bN]=Mt[yN]=Mt[wN]=Mt[_N]=Mt[xN]=Mt[EN]=Mt[$N]=Mt[SN]=!1;function LN(t){return uN(t)&&fN(t.length)&&!!Mt[hN(t)]}var BN=LN;function UN(t){return function(e){return t(e)}}var qN=UN,ed={exports:{}};(function(t,e){var r=ab,i=e&&!e.nodeType&&e,n=i&&!0&&t&&!t.nodeType&&t,s=n&&n.exports===i,o=s&&r.process,a=function(){try{var c=n&&n.require&&n.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();t.exports=a})(ed,ed.exports);var jN=BN,kN=qN,Ob=ed.exports,Cb=Ob&&Ob.isTypedArray,zN=Cb?kN(Cb):jN,Db=zN;function HN(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var Rb=HN,WN=Yu,VN=ql,KN=Object.prototype,GN=KN.hasOwnProperty;function JN(t,e,r){var i=t[e];(!(GN.call(t,e)&&VN(i,r))||r===void 0&&!(e in t))&&WN(t,e,r)}var ZN=JN,YN=ZN,XN=Yu;function QN(t,e,r,i){var n=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(r[a],t[a],a,r,t):void 0;c===void 0&&(c=t[a]),n?XN(r,a,c):YN(r,a,c)}return r}var eT=QN;function tT(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}var rT=tT,iT=9007199254740991,nT=/^(?:0|[1-9]\d*)$/;function sT(t,e){var r=typeof t;return e=e??iT,!!e&&(r=="number"||r!="symbol"&&nT.test(t))&&t>-1&&t%1==0&&t<e}var Nb=sT,oT=rT,aT=Ib,cT=Ab,lT=Vl.exports,hT=Nb,fT=Db,uT=Object.prototype,dT=uT.hasOwnProperty;function pT(t,e){var r=cT(t),i=!r&&aT(t),n=!r&&!i&&lT(t),s=!r&&!i&&!n&&fT(t),o=r||i||n||s,a=o?oT(t.length,String):[],c=a.length;for(var l in t)(e||dT.call(t,l))&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||hT(l,c)))&&a.push(l);return a}var gT=pT;function vT(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var mT=vT,bT=Ns,yT=Eb,wT=mT,_T=Object.prototype,xT=_T.hasOwnProperty;function ET(t){if(!bT(t))return wT(t);var e=yT(t),r=[];for(var i in t)i=="constructor"&&(e||!xT.call(t,i))||r.push(i);return r}var $T=ET,ST=gT,IT=$T,AT=Qu;function MT(t){return AT(t)?ST(t,!0):IT(t)}var Tb=MT,PT=eT,OT=Tb;function CT(t){return PT(t,OT(t))}var DT=CT,Fb=yb,RT=Xu.exports,NT=gR,TT=mR,FT=CR,Lb=Ib,Bb=Ab,LT=YR,BT=Vl.exports,UT=Gu,qT=Ns,jT=lN,kT=Db,Ub=Rb,zT=DT;function HT(t,e,r,i,n,s,o){var a=Ub(t,r),c=Ub(e,r),l=o.get(c);if(l){Fb(t,r,l);return}var u=s?s(a,c,r+"",t,e,o):void 0,m=u===void 0;if(m){var x=Bb(c),S=!x&&BT(c),E=!x&&!S&&kT(c);u=c,x||S||E?Bb(a)?u=a:LT(a)?u=TT(a):S?(m=!1,u=RT(c,!0)):E?(m=!1,u=NT(c,!0)):u=[]:jT(c)||Lb(c)?(u=a,Lb(a)?u=zT(a):(!qT(a)||UT(a))&&(u=FT(c))):m=!1}m&&(o.set(c,u),n(u,c,i,s,o),o.delete(c)),Fb(t,r,u)}var WT=HT,VT=ZD,KT=yb,GT=aR,JT=WT,ZT=Ns,YT=Tb,XT=Rb;function qb(t,e,r,i,n){t!==e&>(e,function(s,o){if(n||(n=new VT),ZT(s))JT(t,e,o,r,qb,i,n);else{var a=i?i(XT(t,o),s,o+"",t,e,n):void 0;a===void 0&&(a=s),KT(t,o,a)}},YT)}var QT=qb;function eF(t){return t}var jb=eF;function tF(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var rF=tF,iF=rF,kb=Math.max;function nF(t,e,r){return e=kb(e===void 0?t.length-1:e,0),function(){for(var i=arguments,n=-1,s=kb(i.length-e,0),o=Array(s);++n<s;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=r(o),iF(t,this,a)}}var sF=nF;function oF(t){return function(){return t}}var aF=oF,cF=aF,zb=mb,lF=jb,hF=zb?function(t,e){return zb(t,"toString",{configurable:!0,enumerable:!1,value:cF(e),writable:!0})}:lF,fF=hF,uF=800,dF=16,pF=Date.now;function gF(t){var e=0,r=0;return function(){var i=pF(),n=dF-(i-r);if(r=i,n>0){if(++e>=uF)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var vF=gF,mF=fF,bF=vF,yF=bF(mF),wF=yF,_F=jb,xF=sF,EF=wF;function $F(t,e){return EF(xF(t,e,_F),t+"")}var SF=$F,IF=ql,AF=Qu,MF=Nb,PF=Ns;function OF(t,e,r){if(!PF(r))return!1;var i=typeof e;return(i=="number"?AF(r)&&MF(e,r.length):i=="string"&&e in r)?IF(r[e],t):!1}var CF=OF,DF=SF,RF=CF;function NF(t){return DF(function(e,r){var i=-1,n=r.length,s=n>1?r[n-1]:void 0,o=n>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(n--,s):void 0,o&&RF(r[0],r[1],o)&&(s=n<3?void 0:s,n=1),e=Object(e);++i<n;){var a=r[i];a&&t(e,a,i,s)}return e})}var TF=NF,FF=QT,LF=TF,BF=LF(function(t,e,r){FF(t,e,r)}),UF=BF,qF=Object.defineProperty,jF=Object.defineProperties,kF=Object.getOwnPropertyDescriptors,Hb=Object.getOwnPropertySymbols,zF=Object.prototype.hasOwnProperty,HF=Object.prototype.propertyIsEnumerable,Wb=(t,e,r)=>e in t?qF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kl=(t,e)=>{for(var r in e||(e={}))zF.call(e,r)&&Wb(t,r,e[r]);if(Hb)for(var r of Hb(e))HF.call(e,r)&&Wb(t,r,e[r]);return t},WF=(t,e)=>jF(t,kF(e));function Yr(t,e,r){var i;const n=bo(t);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${ob}?chainId=${n.namespace}:${n.reference}&projectId=${r}`}function Ts(t){return t.includes(":")?t.split(":")[1]:t}function Vb(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function VF(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 td(t={},e={}){const r=Kb(t),i=Kb(e);return UF(r,i)}function Kb(t){var e,r,i,n;const s={};if(!za(t))return s;for(const[o,a]of Object.entries(t)){const c=fu(o)?[o]:a.chains,l=a.methods||[],u=a.events||[],m=a.rpcMap||{},x=ka(o);s[x]=WF(Kl(Kl({},s[x]),a),{chains:hl(c,(e=s[x])==null?void 0:e.chains),methods:hl(l,(r=s[x])==null?void 0:r.methods),events:hl(u,(i=s[x])==null?void 0:i.events),rpcMap:Kl(Kl({},m),(n=s[x])==null?void 0:n.rpcMap)})}return s}function KF(t){return t.includes(":")?t.split(":")[2]:t}function Gb(t){const e={};for(const[r,i]of Object.entries(t)){const n=i.methods||[],s=i.events||[],o=i.accounts||[],a=fu(r)?[r]:i.chains?i.chains:Vb(i.accounts);e[r]={chains:a,methods:n,events:s,accounts:o}}return e}function rd(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 Jb={},Je=t=>Jb[t],id=(t,e)=>{Jb[t]=e};var GF=Object.defineProperty,JF=(t,e,r)=>e in t?GF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lo=(t,e,r)=>JF(t,typeof e!="symbol"?e+"":e,r);class ZF{constructor(e){Lo(this,"name","polkadot"),Lo(this,"client"),Lo(this,"httpProviders"),Lo(this,"events"),Lo(this,"namespace"),Lo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var YF=Object.defineProperty,XF=Object.defineProperties,QF=Object.getOwnPropertyDescriptors,Zb=Object.getOwnPropertySymbols,eL=Object.prototype.hasOwnProperty,tL=Object.prototype.propertyIsEnumerable,nd=(t,e,r)=>e in t?YF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yb=(t,e)=>{for(var r in e||(e={}))eL.call(e,r)&&nd(t,r,e[r]);if(Zb)for(var r of Zb(e))tL.call(e,r)&&nd(t,r,e[r]);return t},Xb=(t,e)=>XF(t,QF(e)),Bo=(t,e,r)=>nd(t,typeof e!="symbol"?e+"":e,r);class rL{constructor(e){Bo(this,"name","eip155"),Bo(this,"client"),Bo(this,"chainId"),Bo(this,"namespace"),Bo(this,"httpProviders"),Bo(this,"events"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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||Yr(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("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(Ts(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;const s=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((n=o?.sessionProperties)==null?void 0:n.capabilities)||{};if(a!=null&&a[s])return a?.[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Xb(Yb({},o.sessionProperties||{}),{capabilities:Xb(Yb({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}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(Zn("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`${rO}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var iL=Object.defineProperty,nL=(t,e,r)=>e in t?iL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Uo=(t,e,r)=>nL(t,typeof e!="symbol"?e+"":e,r);class sL{constructor(e){Uo(this,"name","solana"),Uo(this,"client"),Uo(this,"httpProviders"),Uo(this,"events"),Uo(this,"namespace"),Uo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var oL=Object.defineProperty,aL=(t,e,r)=>e in t?oL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qo=(t,e,r)=>aL(t,typeof e!="symbol"?e+"":e,r);class cL{constructor(e){qo(this,"name","cosmos"),qo(this,"client"),qo(this,"httpProviders"),qo(this,"events"),qo(this,"namespace"),qo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var lL=Object.defineProperty,hL=(t,e,r)=>e in t?lL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jo=(t,e,r)=>hL(t,typeof e!="symbol"?e+"":e,r);class fL{constructor(e){jo(this,"name","algorand"),jo(this,"client"),jo(this,"httpProviders"),jo(this,"events"),jo(this,"namespace"),jo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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||Yr(`${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(gi.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||Yr(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new ui(new Ci(i,Je("disableProviderPing")))}}var uL=Object.defineProperty,dL=(t,e,r)=>e in t?uL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ko=(t,e,r)=>dL(t,typeof e!="symbol"?e+"":e,r);class pL{constructor(e){ko(this,"name","cip34"),ko(this,"client"),ko(this,"httpProviders"),ko(this,"events"),ko(this,"namespace"),ko(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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 ui(new Ci(i,Je("disableProviderPing")))}}var gL=Object.defineProperty,vL=(t,e,r)=>e in t?gL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zo=(t,e,r)=>vL(t,typeof e!="symbol"?e+"":e,r);class mL{constructor(e){zo(this,"name","elrond"),zo(this,"client"),zo(this,"httpProviders"),zo(this,"events"),zo(this,"namespace"),zo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var bL=Object.defineProperty,yL=(t,e,r)=>e in t?bL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ho=(t,e,r)=>yL(t,typeof e!="symbol"?e+"":e,r);class wL{constructor(e){Ho(this,"name","multiversx"),Ho(this,"client"),Ho(this,"httpProviders"),Ho(this,"events"),Ho(this,"namespace"),Ho(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=Ts(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var _L=Object.defineProperty,xL=(t,e,r)=>e in t?_L(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wo=(t,e,r)=>xL(t,typeof e!="symbol"?e+"":e,r);class EL{constructor(e){Wo(this,"name","near"),Wo(this,"client"),Wo(this,"httpProviders"),Wo(this,"events"),Wo(this,"namespace"),Wo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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||Yr(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(gi.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||Yr(e,this.namespace);return typeof i>"u"?void 0:new ui(new Ci(i,Je("disableProviderPing")))}}var $L=Object.defineProperty,SL=(t,e,r)=>e in t?$L(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vo=(t,e,r)=>SL(t,typeof e!="symbol"?e+"":e,r);class IL{constructor(e){Vo(this,"name","tezos"),Vo(this,"client"),Vo(this,"httpProviders"),Vo(this,"events"),Vo(this,"namespace"),Vo(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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||Yr(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(gi.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||Yr(e,this.namespace);return typeof i>"u"?void 0:new ui(new Ci(i))}}var AL=Object.defineProperty,ML=(t,e,r)=>e in t?AL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ko=(t,e,r)=>ML(t,typeof e!="symbol"?e+"":e,r);class PL{constructor(e){Ko(this,"name",Co),Ko(this,"client"),Ko(this,"httpProviders"),Ko(this,"events"),Ko(this,"namespace"),Ko(this,"chainId"),this.namespace=e.namespace,this.events=Je("events"),this.client=Je("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(gi.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=bo(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||Yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new ui(new Ci(i,Je("disableProviderPing")))}}var OL=Object.defineProperty,CL=Object.defineProperties,DL=Object.getOwnPropertyDescriptors,Qb=Object.getOwnPropertySymbols,RL=Object.prototype.hasOwnProperty,NL=Object.prototype.propertyIsEnumerable,sd=(t,e,r)=>e in t?OL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gl=(t,e)=>{for(var r in e||(e={}))RL.call(e,r)&&sd(t,r,e[r]);if(Qb)for(var r of Qb(e))NL.call(e,r)&&sd(t,r,e[r]);return t},od=(t,e)=>CL(t,DL(e)),Xr=(t,e,r)=>sd(t,typeof e!="symbol"?e+"":e,r);class ad{constructor(e){Xr(this,"client"),Xr(this,"namespaces"),Xr(this,"optionalNamespaces"),Xr(this,"sessionProperties"),Xr(this,"events",new nr.exports),Xr(this,"rpcProviders",{}),Xr(this,"session"),Xr(this,"providerOpts"),Xr(this,"logger"),Xr(this,"uri"),Xr(this,"shouldAbortPairingAttempt",!1),Xr(this,"maxPairingAttempts",10),Xr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Vi(Ol({level:e?.logger||nb})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new ad(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:Gl({},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,Cl(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}),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:wt("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=Gb(this.session.namespaces);this.namespaces=td(this.namespaces,o),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){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(s=>{this.session=s;const o=Gb(s.namespaces);this.namespaces=td(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==Gm)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,n]=this.validateChain(e),s=this.getProvider(i);s.name===Co?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(Wi(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.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Vu.init({core:this.providerOpts.core,logger:this.providerOpts.logger||nb,relayUrl:this.providerOpts.relayUrl||QP,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>ka(r)))];id("client",this.client),id("events",this.events),id("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=VF(r,this.session),n=Vb(i),s=td(this.namespaces,this.optionalNamespaces),o=od(Gl({},s[r]),{accounts:i,chains:n});switch(r){case"eip155":this.rpcProviders[r]=new rL({namespace:o});break;case"algorand":this.rpcProviders[r]=new fL({namespace:o});break;case"solana":this.rpcProviders[r]=new sL({namespace:o});break;case"cosmos":this.rpcProviders[r]=new cL({namespace:o});break;case"polkadot":this.rpcProviders[r]=new ZF({namespace:o});break;case"cip34":this.rpcProviders[r]=new pL({namespace:o});break;case"elrond":this.rpcProviders[r]=new mL({namespace:o});break;case"multiversx":this.rpcProviders[r]=new wL({namespace:o});break;case"near":this.rpcProviders[r]=new EL({namespace:o});break;case"tezos":this.rpcProviders[r]=new IL({namespace:o});break;default:this.rpcProviders[Co]?this.rpcProviders[Co].updateNamespace(o):this.rpcProviders[Co]=new PL({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:i}=r;if(i.name==="accountsChanged"){const n=i.data;n&&Wi(n)&&this.events.emit("accountsChanged",n.map(KF))}else if(i.name==="chainChanged"){const n=r.chainId,s=r.event.data,o=ka(n),a=rd(n)!==rd(s)?`${o}:${rd(s)}`:n;this.onChainChanged(a)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i;const{namespaces:n}=r,s=(i=this.client)==null?void 0:i.session.get(e);this.session=od(Gl({},s),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",od(Gl({},wt("USER_DISCONNECTED")),{data:e.topic}))}),this.on(gi.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Co]}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}=e;r&&Object.keys(r).length&&(this.namespaces=r),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",r),this.persist("optionalNamespaces",i)}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=>ka(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=ka(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()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(r||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${sb}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${sb}/${e}`)}}const TL=ad,FL="wc",LL="ethereum_provider",BL=`${FL}@2:${LL}:`,UL="https://rpc.walletconnect.org/v1/",Jl=["eth_sendTransaction","personal_sign"],e2=["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"],Zl=["chainChanged","accountsChanged"],t2=["chainChanged","accountsChanged","message","disconnect","connect"];var qL=Object.defineProperty,jL=Object.defineProperties,kL=Object.getOwnPropertyDescriptors,r2=Object.getOwnPropertySymbols,zL=Object.prototype.hasOwnProperty,HL=Object.prototype.propertyIsEnumerable,cd=(t,e,r)=>e in t?qL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Go=(t,e)=>{for(var r in e||(e={}))zL.call(e,r)&&cd(t,r,e[r]);if(r2)for(var r of r2(e))HL.call(e,r)&&cd(t,r,e[r]);return t},ld=(t,e)=>jL(t,kL(e)),Qr=(t,e,r)=>cd(t,typeof e!="symbol"?e+"":e,r);function Yl(t){return Number(t[0].split(":")[1])}function Xl(t){return`0x${t.toString(16)}`}function WL(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=t;if(!Wi(e))throw new Error("Invalid chains");const c={chains:e,methods:i||Jl,events:s||Zl,rpcMap:Go({},e.length?{[Yl(e)]:a[Yl(e)]}:{})},l=s?.filter(S=>!Zl.includes(S)),u=i?.filter(S=>!Jl.includes(S));if(!r&&!o&&!n&&!(l!=null&&l.length)&&!(u!=null&&u.length))return{required:e.length?c:void 0};const m=l?.length&&u?.length||!r,x={chains:[...new Set(m?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(n!=null&&n.length?n:e2))],events:[...new Set(c.events.concat(o!=null&&o.length?o:t2))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?x:void 0}}class Ql{constructor(){Qr(this,"events",new nr.exports.EventEmitter),Qr(this,"namespace","eip155"),Qr(this,"accounts",[]),Qr(this,"signer"),Qr(this,"chainId",1),Qr(this,"modal"),Qr(this,"rpc"),Qr(this,"STORAGE_KEY",BL),Qr(this,"on",(e,r)=>(this.events.on(e,r),this)),Qr(this,"once",(e,r)=>(this.events.once(e,r),this)),Qr(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),Qr(this,"off",(e,r)=>(this.events.off(e,r),this)),Qr(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new Ql;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){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:i}=WL(this.rpc);try{const n=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(ld(Go({namespaces:Go({},r&&{[this.namespace]:r})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e?.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!n)return;const s=mg(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:Xl(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{const i=await new Promise(async(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(ld(Go({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),n=i.session;if(n){const s=mg(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:Xl(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}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("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Xl(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",ld(Go({},wt("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,i;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(i=this.modal)==null||i.openModal({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",Xl(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||Jl:[],c=n.length?e?.events||Zl:[],l=e?.optionalMethods||[],u=e?.optionalEvents||[],m=e?.rpcMap||this.buildRpcMap(o,e.projectId),x=e?.qrModalOptions||void 0;return{chains:n?.map(S=>this.formatChainId(S)),optionalChains:s.map(S=>this.formatChainId(S)),methods:a,events:c,optionalMethods:l,optionalEvents:u,rpcMap:m,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:x,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?Yl(this.rpc.chains):Yl(this.rpc.optionalChains),this.signer=await TL.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{WalletConnectModal:i}=await Promise.resolve().then(function(){return pB});r=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Go({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}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&&Wi(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)})),i&&Wi(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])||`${UL}?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 VL=Ql,KL=Symbol(),i2=Object.getPrototypeOf,hd=new WeakMap,GL=t=>t&&(hd.has(t)?hd.get(t):i2(t)===Object.prototype||i2(t)===Array.prototype),JL=t=>GL(t)&&t[KL]||null,n2=(t,e=!0)=>{hd.set(t,e)},fd=t=>typeof t=="object"&&t!==null,Yn=new WeakMap,eh=new WeakSet,ZL=(t=Object.is,e=(l,u)=>new Proxy(l,u),r=l=>fd(l)&&!eh.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),i=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},n=new WeakMap,s=(l,u,m=i)=>{const x=n.get(l);if(x?.[0]===u)return x[1];const S=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return n2(S,!0),n.set(l,[u,S]),Reflect.ownKeys(l).forEach(E=>{if(Object.getOwnPropertyDescriptor(S,E))return;const A=Reflect.get(l,E),R={value:A,enumerable:!0,configurable:!0};if(eh.has(A))n2(A,!1);else if(A instanceof Promise)delete R.value,R.get=()=>m(A);else if(Yn.has(A)){const[O,C]=Yn.get(A);R.value=s(O,C(),m)}Object.defineProperty(S,E,R)}),Object.preventExtensions(S)},o=new WeakMap,a=[1,1],c=l=>{if(!fd(l))throw new Error("object required");const u=o.get(l);if(u)return u;let m=a[0];const x=new Set,S=(B,K=++a[0])=>{m!==K&&(m=K,x.forEach(M=>M(B,K)))};let E=a[1];const A=(B=++a[1])=>(E!==B&&!x.size&&(E=B,O.forEach(([K])=>{const M=K[1](B);M>m&&(m=M)})),m),R=B=>(K,M)=>{const v=[...K];v[1]=[B,...v[1]],S(v,M)},O=new Map,C=(B,K)=>{if(O.has(B))throw new Error("prop listener already exists");if(x.size){const M=K[3](R(B));O.set(B,[K,M])}else O.set(B,[K])},N=B=>{var K;const M=O.get(B);M&&(O.delete(B),(K=M[1])==null||K.call(M))},T=B=>(x.add(B),x.size===1&&O.forEach(([M,v],g)=>{if(v)throw new Error("remove already exists");const h=M[3](R(g));O.set(g,[M,h])}),()=>{x.delete(B),x.size===0&&O.forEach(([M,v],g)=>{v&&(v(),O.set(g,[M]))})}),U=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),W=e(U,{deleteProperty(B,K){const M=Reflect.get(B,K);N(K);const v=Reflect.deleteProperty(B,K);return v&&S(["delete",[K],M]),v},set(B,K,M,v){const g=Reflect.has(B,K),h=Reflect.get(B,K,v);if(g&&(t(h,M)||o.has(M)&&t(h,o.get(M))))return!0;N(K),fd(M)&&(M=JL(M)||M);let f=M;if(M instanceof Promise)M.then(p=>{M.status="fulfilled",M.value=p,S(["resolve",[K],p])}).catch(p=>{M.status="rejected",M.reason=p,S(["reject",[K],p])});else{!Yn.has(M)&&r(M)&&(f=c(M));const p=!eh.has(f)&&Yn.get(f);p&&C(K,p)}return Reflect.set(B,K,f,v),S(["set",[K],M,h]),!0}});o.set(l,W);const V=[U,A,s,T];return Yn.set(W,V),Reflect.ownKeys(l).forEach(B=>{const K=Object.getOwnPropertyDescriptor(l,B);"value"in K&&(W[B]=l[B],delete K.value,delete K.writable),Object.defineProperty(U,B,K)}),W})=>[c,Yn,eh,t,e,r,i,n,s,o,a],[YL]=ZL();function Xn(t={}){return YL(t)}function Fs(t,e,r){const i=Yn.get(t);i||console.warn("Please use proxy object");let n;const s=[],o=i[3];let a=!1;const l=o(u=>{if(s.push(u),r){e(s.splice(0));return}n||(n=Promise.resolve().then(()=>{n=void 0,a&&e(s.splice(0))}))});return a=!0,()=>{a=!1,l()}}function XL(t,e){const r=Yn.get(t);r||console.warn("Please use proxy object");const[i,n,s]=r;return s(i,n(),e)}const rr=Xn({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),Ot={state:rr,subscribe(t){return Fs(rr,()=>t(rr))},push(t,e){t!==rr.view&&(rr.view=t,e&&(rr.data=e),rr.history.push(t))},reset(t){rr.view=t,rr.history=[t]},replace(t){rr.history.length>1&&(rr.history[rr.history.length-1]=t,rr.view=t)},goBack(){if(rr.history.length>1){rr.history.pop();const[t]=rr.history.slice(-1);rr.view=t}},setData(t){rr.data=t}},se={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return se.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const t=navigator.userAgent.toLowerCase();return se.isMobile()&&(t.includes("iphone")||t.includes("ipad"))},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},isArray(t){return Array.isArray(t)&&t.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(t,e,r){if(se.isHttpUrl(t))return this.formatUniversalUrl(t,e,r);let i=t;i.includes("://")||(i=t.replaceAll("/","").replaceAll(":",""),i=`${i}://`),i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,r);const n=encodeURIComponent(e);return`${i}wc?uri=${n}`},formatUniversalUrl(t,e,r){if(!se.isHttpUrl(t))return this.formatNativeUrl(t,e,r);let i=t;if(i.startsWith("https://t.me")){const s=Buffer.from(e).toString("base64").replace(/[=]/g,"");i.endsWith("/")&&(i=i.slice(0,-1)),this.setWalletConnectDeepLink(i,r);const o=new URL(i);return o.searchParams.set("startapp",s),o.toString()}i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,r);const n=encodeURIComponent(e);return`${i}wc?uri=${n}`},async wait(t){return new Promise(e=>{setTimeout(e,t)})},openHref(t,e){const r=this.isTelegram()?"_blank":e;window.open(t,r,"noreferrer noopener")},setWalletConnectDeepLink(t,e){try{localStorage.setItem(se.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(t){try{const[e]=t.split("?");localStorage.setItem(se.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(se.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(se.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var t;const e=(t=Ot.state.data)==null?void 0:t.Wallet;if(!e)throw new Error('Missing "Wallet" view data');return e}},QL=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),yr=Xn({enabled:QL,userSessionId:"",events:[],connectedWalletId:void 0}),s2={state:yr,subscribe(t){return Fs(yr.events,()=>t(XL(yr.events[yr.events.length-1])))},initialize(){yr.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(yr.userSessionId=crypto.randomUUID())},setConnectedWalletId(t){yr.connectedWalletId=t},click(t){if(yr.enabled){const e={type:"CLICK",name:t.name,userSessionId:yr.userSessionId,timestamp:Date.now(),data:t};yr.events.push(e)}},track(t){if(yr.enabled){const e={type:"TRACK",name:t.name,userSessionId:yr.userSessionId,timestamp:Date.now(),data:t};yr.events.push(e)}},view(t){if(yr.enabled){const e={type:"VIEW",name:t.name,userSessionId:yr.userSessionId,timestamp:Date.now(),data:t};yr.events.push(e)}}},en=Xn({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),qt={state:en,subscribe(t){return Fs(en,()=>t(en))},setChains(t){en.chains=t},setWalletConnectUri(t){en.walletConnectUri=t},setIsCustomDesktop(t){en.isCustomDesktop=t},setIsCustomMobile(t){en.isCustomMobile=t},setIsDataLoaded(t){en.isDataLoaded=t},setIsUiLoaded(t){en.isUiLoaded=t},setIsAuth(t){en.isAuth=t}},th=Xn({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),ei={state:th,subscribe(t){return Fs(th,()=>t(th))},setConfig(t){var e,r;s2.initialize(),qt.setChains(t.chains),qt.setIsAuth(!!t.enableAuthMode),qt.setIsCustomMobile(!!((e=t.mobileWallets)!=null&&e.length)),qt.setIsCustomDesktop(!!((r=t.desktopWallets)!=null&&r.length)),se.setModalVersionInStorage(),Object.assign(th,t)}};var eB=Object.defineProperty,o2=Object.getOwnPropertySymbols,tB=Object.prototype.hasOwnProperty,rB=Object.prototype.propertyIsEnumerable,a2=(t,e,r)=>e in t?eB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iB=(t,e)=>{for(var r in e||(e={}))tB.call(e,r)&&a2(t,r,e[r]);if(o2)for(var r of o2(e))rB.call(e,r)&&a2(t,r,e[r]);return t};const ud="https://explorer-api.walletconnect.com",dd="wcm",pd="js-2.7.0";async function rh(t,e){const r=iB({sdkType:dd,sdkVersion:pd},e),i=new URL(t,ud);return i.searchParams.append("projectId",ei.state.projectId),Object.entries(r).forEach(([s,o])=>{o&&i.searchParams.append(s,String(o))}),(await fetch(i)).json()}const Ls={async getDesktopListings(t){return rh("/w3m/v1/getDesktopListings",t)},async getMobileListings(t){return rh("/w3m/v1/getMobileListings",t)},async getInjectedListings(t){return rh("/w3m/v1/getInjectedListings",t)},async getAllListings(t){return rh("/w3m/v1/getAllListings",t)},getWalletImageUrl(t){return`${ud}/w3m/v1/getWalletImage/${t}?projectId=${ei.state.projectId}&sdkType=${dd}&sdkVersion=${pd}`},getAssetImageUrl(t){return`${ud}/w3m/v1/getAssetImage/${t}?projectId=${ei.state.projectId}&sdkType=${dd}&sdkVersion=${pd}`}};var nB=Object.defineProperty,c2=Object.getOwnPropertySymbols,sB=Object.prototype.hasOwnProperty,oB=Object.prototype.propertyIsEnumerable,l2=(t,e,r)=>e in t?nB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,aB=(t,e)=>{for(var r in e||(e={}))sB.call(e,r)&&l2(t,r,e[r]);if(c2)for(var r of c2(e))oB.call(e,r)&&l2(t,r,e[r]);return t};const h2=se.isMobile(),tn=Xn({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Br={state:tn,async getRecomendedWallets(){const{explorerRecommendedWalletIds:t,explorerExcludedWalletIds:e}=ei.state;if(t==="NONE"||e==="ALL"&&!t)return tn.recomendedWallets;if(se.isArray(t)){const i={recommendedIds:t.join(",")},{listings:n}=await Ls.getAllListings(i),s=Object.values(n);s.sort((o,a)=>{const c=t.indexOf(o.id),l=t.indexOf(a.id);return c-l}),tn.recomendedWallets=s}else{const{chains:r,isAuth:i}=qt.state,n=r?.join(","),s=se.isArray(e),o={page:1,sdks:i?"auth_v1":void 0,entries:se.RECOMMENDED_WALLET_AMOUNT,chains:n,version:2,excludedIds:s?e.join(","):void 0},{listings:a}=h2?await Ls.getMobileListings(o):await Ls.getDesktopListings(o);tn.recomendedWallets=Object.values(a)}return tn.recomendedWallets},async getWallets(t){const e=aB({},t),{explorerRecommendedWalletIds:r,explorerExcludedWalletIds:i}=ei.state,{recomendedWallets:n}=tn;if(i==="ALL")return tn.wallets;n.length?e.excludedIds=n.map(m=>m.id).join(","):se.isArray(r)&&(e.excludedIds=r.join(",")),se.isArray(i)&&(e.excludedIds=[e.excludedIds,i].filter(Boolean).join(",")),qt.state.isAuth&&(e.sdks="auth_v1");const{page:s,search:o}=t,{listings:a,total:c}=h2?await Ls.getMobileListings(e):await Ls.getDesktopListings(e),l=Object.values(a),u=o?"search":"wallets";return tn[u]={listings:[...tn[u].listings,...l],total:c,page:s??1},{listings:l,total:c}},getWalletImageUrl(t){return Ls.getWalletImageUrl(t)},getAssetImageUrl(t){return Ls.getAssetImageUrl(t)},resetSearch(){tn.search={listings:[],total:0,page:1}}},Jo=Xn({open:!1}),Bs={state:Jo,subscribe(t){return Fs(Jo,()=>t(Jo))},async open(t){return new Promise(e=>{const{isUiLoaded:r,isDataLoaded:i}=qt.state;if(se.removeWalletConnectDeepLink(),qt.setWalletConnectUri(t?.uri),qt.setChains(t?.chains),Ot.reset("ConnectWallet"),r&&i)Jo.open=!0,e();else{const n=setInterval(()=>{const s=qt.state;s.isUiLoaded&&s.isDataLoaded&&(clearInterval(n),Jo.open=!0,e())},200)}})},close(){Jo.open=!1}};var cB=Object.defineProperty,f2=Object.getOwnPropertySymbols,lB=Object.prototype.hasOwnProperty,hB=Object.prototype.propertyIsEnumerable,u2=(t,e,r)=>e in t?cB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fB=(t,e)=>{for(var r in e||(e={}))lB.call(e,r)&&u2(t,r,e[r]);if(f2)for(var r of f2(e))hB.call(e,r)&&u2(t,r,e[r]);return t};function uB(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const sc=Xn({themeMode:uB()?"dark":"light"}),Qn={state:sc,subscribe(t){return Fs(sc,()=>t(sc))},setThemeConfig(t){const{themeMode:e,themeVariables:r}=t;e&&(sc.themeMode=e),r&&(sc.themeVariables=fB({},r))}},Us=Xn({open:!1,message:"",variant:"success"}),es={state:Us,subscribe(t){return Fs(Us,()=>t(Us))},openToast(t,e){Us.open=!0,Us.message=t,Us.variant=e},closeToast(){Us.open=!1}};class dB{constructor(e){this.openModal=Bs.open,this.closeModal=Bs.close,this.subscribeModal=Bs.subscribe,this.setTheme=Qn.setThemeConfig,Qn.setThemeConfig(e),ei.setConfig(e),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(function(){return Ek});const e=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",e),qt.setIsUiLoaded(!0)}}}var pB=Object.freeze({__proto__:null,WalletConnectModal:dB});/**
|
|
39
|
+
***************************************************************************** */var Kd=function(t,e){return Kd=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])},Kd(t,e)};function _P(t,e){Kd(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Gd=function(){return Gd=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},Gd.apply(this,arguments)};function xP(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 EP(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 $P(t,e){return function(r,i){e(r,i,t)}}function IP(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function SP(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(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):n(u.value).then(a,c)}l((i=i.apply(t,e||[])).next())})}function AP(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(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function PP(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function OP(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zd(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 sv(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 CP(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(sv(arguments[e]));return t}function DP(){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 Ba(t){return this instanceof Ba?(this.v=t,this):new Ba(t)}function MP(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(p){i[p]&&(n[p]=function(y){return new Promise(function(m,_){s.push([p,y,m,_])>1||a(p,y)})})}function a(p,y){try{c(i[p](y))}catch(m){d(s[0][3],m)}}function c(p){p.value instanceof Ba?Promise.resolve(p.value.v).then(l,u):d(s[0][2],p)}function l(p){a("next",p)}function u(p){a("throw",p)}function d(p,y){p(y),s.shift(),s.length&&a(s[0][0],s[0][1])}}function TP(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:Ba(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function RP(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 Zd=="function"?Zd(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(l){s({value:l,done:a})},o)}}function NP(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function BP(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 LP(t){return t&&t.__esModule?t:{default:t}}function FP(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function UP(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var jP=Object.freeze({__proto__:null,__extends:_P,get __assign(){return Gd},__rest:xP,__decorate:EP,__param:$P,__metadata:IP,__awaiter:SP,__generator:AP,__createBinding:PP,__exportStar:OP,__values:Zd,__read:sv,__spread:CP,__spreadArrays:DP,__await:Ba,__asyncGenerator:MP,__asyncDelegator:TP,__asyncValues:RP,__makeTemplateObject:NP,__importStar:BP,__importDefault:LP,__classPrivateFieldGet:FP,__classPrivateFieldSet:UP}),qP=zu(jP),qi={},ov;function zP(){if(ov)return qi;ov=1,Object.defineProperty(qi,"__esModule",{value:!0}),qi.isBrowserCryptoAvailable=qi.getSubtleCrypto=qi.getBrowerCrypto=void 0;function t(){return wt?.crypto||wt?.msCrypto||{}}qi.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}qi.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return qi.isBrowserCryptoAvailable=r,qi}var zi={},av;function kP(){if(av)return zi;av=1,Object.defineProperty(zi,"__esModule",{value:!0}),zi.isBrowser=zi.isNode=zi.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}zi.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}zi.isNode=e;function r(){return!t()&&!e()}return zi.isBrowser=r,zi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=qP;e.__exportStar(zP(),t),e.__exportStar(kP(),t)})(nv);function bi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function Qn(t=6){return BigInt(bi(t))}function gn(t,e,r){return{id:r||bi(),jsonrpc:"2.0",method:t,params:e}}function Ll(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Fl(t,e,r){return{id:t,jsonrpc:"2.0",error:HP(e,r)}}function HP(t,e){return typeof t>"u"?rv(ev):(typeof t=="string"&&(t=Object.assign(Object.assign({},rv(Vd)),{message:t})),typeof e<"u"&&(t.data=e),yP(t.code)&&(t=wP(t.code)),t)}class WP{}class VP extends WP{constructor(){super()}}class KP extends VP{constructor(e){super()}}const GP="^https?:",ZP="^wss?:";function YP(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function cv(t,e){const r=YP(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function lv(t){return cv(t,GP)}function uv(t){return cv(t,ZP)}function JP(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function hv(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Yd(t){return hv(t)&&"method"in t}function Ul(t){return hv(t)&&(mi(t)||Cr(t))}function mi(t){return"result"in t}function Cr(t){return"error"in t}class Dr extends KP{constructor(e){super(e),this.events=new Lt.exports.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(gn(e.method,e.params||[],e.id||Qn().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=>{Cr(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),Ul(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)}}const QP=()=>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"),XP=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",dv=t=>t.split("?")[0],fv=10,eO=QP();class tO{constructor(e){if(this.url=e,this.events=new Lt.exports.EventEmitter,this.registering=!1,!uv(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(Mi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!uv(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=nv.isReactNative()?void 0:{rejectUnauthorized:!JP(e)},s=new eO(e,[],n);XP()?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"?Fn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Fl(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return iv(e,dv(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>fv&&this.events.setMaxListeners(fv)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${dv(this.url)}`));return this.events.emit("register_error",r),r}}var Jd={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",p="[object Error]",y="[object Function]",m="[object GeneratorFunction]",_="[object Map]",S="[object Number]",E="[object Null]",P="[object Object]",C="[object Promise]",M="[object Proxy]",R="[object RegExp]",L="[object Set]",B="[object String]",F="[object Symbol]",T="[object Undefined]",q="[object WeakMap]",$="[object ArrayBuffer]",h="[object DataView]",b="[object Float32Array]",w="[object Float64Array]",g="[object Int8Array]",v="[object Int16Array]",I="[object Int32Array]",O="[object Uint8Array]",x="[object Uint8ClampedArray]",f="[object Uint16Array]",A="[object Uint32Array]",j=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,k={};k[b]=k[w]=k[g]=k[v]=k[I]=k[O]=k[x]=k[f]=k[A]=!0,k[a]=k[c]=k[$]=k[u]=k[h]=k[d]=k[p]=k[y]=k[_]=k[S]=k[P]=k[R]=k[L]=k[B]=k[q]=!1;var Z=typeof wt=="object"&&wt&&wt.Object===Object&&wt,X=typeof self=="object"&&self&&self.Object===Object&&self,ee=Z||X||Function("return this")(),Q=e&&!e.nodeType&&e,re=Q&&!0&&t&&!t.nodeType&&t,Ze=re&&re.exports===Q,oe=Ze&&Z.process,fe=function(){try{return oe&&oe.binding&&oe.binding("util")}catch{}}(),$t=fe&&fe.isTypedArray;function xe(D,N){for(var H=-1,Y=D==null?0:D.length,je=0,ne=[];++H<Y;){var pt=D[H];N(pt,H,D)&&(ne[je++]=pt)}return ne}function qe(D,N){for(var H=-1,Y=N.length,je=D.length;++H<Y;)D[je+H]=N[H];return D}function Go(D,N){for(var H=-1,Y=D==null?0:D.length;++H<Y;)if(N(D[H],H,D))return!0;return!1}function ze(D,N){for(var H=-1,Y=Array(D);++H<D;)Y[H]=N(H);return Y}function Be(D){return function(N){return D(N)}}function vs(D,N){return D.has(N)}function De(D,N){return D?.[N]}function Le(D){var N=-1,H=Array(D.size);return D.forEach(function(Y,je){H[++N]=[je,Y]}),H}function ys(D,N){return function(H){return D(N(H))}}function Fe(D){var N=-1,H=Array(D.size);return D.forEach(function(Y){H[++N]=Y}),H}var Ue=Array.prototype,ws=Function.prototype,Ae=Object.prototype,Me=ee["__core-js_shared__"],_s=ws.toString,pe=Ae.hasOwnProperty,Ye=function(){var D=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||"");return D?"Symbol(src)_1."+D:""}(),uc=Ae.toString,st=RegExp("^"+_s.call(pe).replace(j,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Je=Ze?ee.Buffer:void 0,xs=ee.Symbol,Qe=ee.Uint8Array,Xe=Ae.propertyIsEnumerable,Mu=Ue.splice,Se=xs?xs.toStringTag:void 0,et=Object.getOwnPropertySymbols,Tu=Je?Je.isBuffer:void 0,ot=ys(Object.keys,Object),ke=Yo(ee,"DataView"),Pn=Yo(ee,"Map"),He=Yo(ee,"Promise"),We=Yo(ee,"Set"),Zo=Yo(ee,"WeakMap"),Te=Yo(Object,"create"),at=Es(ke),Ru=Es(Pn),ct=Es(He),lt=Es(We),Nu=Es(Zo),tt=xs?xs.prototype:void 0,Ve=tt?tt.valueOf:void 0;function Ai(D){var N=-1,H=D==null?0:D.length;for(this.clear();++N<H;){var Y=D[N];this.set(Y[0],Y[1])}}function ut(){this.__data__=Te?Te(null):{},this.size=0}function ht(D){var N=this.has(D)&&delete this.__data__[D];return this.size-=N?1:0,N}function Bu(D){var N=this.__data__;if(Te){var H=N[D];return H===i?void 0:H}return pe.call(N,D)?N[D]:void 0}function dt(D){var N=this.__data__;return Te?N[D]!==void 0:pe.call(N,D)}function ft(D,N){var H=this.__data__;return this.size+=this.has(D)?0:1,H[D]=Te&&N===void 0?i:N,this}Ai.prototype.clear=ut,Ai.prototype.delete=ht,Ai.prototype.get=Bu,Ai.prototype.has=dt,Ai.prototype.set=ft;function Er(D){var N=-1,H=D==null?0:D.length;for(this.clear();++N<H;){var Y=D[N];this.set(Y[0],Y[1])}}function hc(){this.__data__=[],this.size=0}function dc(D){var N=this.__data__,H=Lu(N,D);if(H<0)return!1;var Y=N.length-1;return H==Y?N.pop():Mu.call(N,H,1),--this.size,!0}function fc(D){var N=this.__data__,H=Lu(N,D);return H<0?void 0:N[H][1]}function pc(D){return Lu(this.__data__,D)>-1}function gc(D,N){var H=this.__data__,Y=Lu(H,D);return Y<0?(++this.size,H.push([D,N])):H[Y][1]=N,this}Er.prototype.clear=hc,Er.prototype.delete=dc,Er.prototype.get=fc,Er.prototype.has=pc,Er.prototype.set=gc;function Jr(D){var N=-1,H=D==null?0:D.length;for(this.clear();++N<H;){var Y=D[N];this.set(Y[0],Y[1])}}function bc(){this.size=0,this.__data__={hash:new Ai,map:new(Pn||Er),string:new Ai}}function mc(D){var N=Fu(this,D).delete(D);return this.size-=N?1:0,N}function vc(D){return Fu(this,D).get(D)}function yc(D){return Fu(this,D).has(D)}function wc(D,N){var H=Fu(this,D),Y=H.size;return H.set(D,N),this.size+=H.size==Y?0:1,this}Jr.prototype.clear=bc,Jr.prototype.delete=mc,Jr.prototype.get=vc,Jr.prototype.has=yc,Jr.prototype.set=wc;function On(D){var N=-1,H=D==null?0:D.length;for(this.__data__=new Jr;++N<H;)this.add(D[N])}function _c(D){return this.__data__.set(D,i),this}function xc(D){return this.__data__.has(D)}On.prototype.add=On.prototype.push=_c,On.prototype.has=xc;function Br(D){var N=this.__data__=new Er(D);this.size=N.size}function Ec(){this.__data__=new Er,this.size=0}function $c(D){var N=this.__data__,H=N.delete(D);return this.size=N.size,H}function Ic(D){return this.__data__.get(D)}function fW(D){return this.__data__.has(D)}function pW(D,N){var H=this.__data__;if(H instanceof Er){var Y=H.__data__;if(!Pn||Y.length<r-1)return Y.push([D,N]),this.size=++H.size,this;H=this.__data__=new Jr(Y)}return H.set(D,N),this.size=H.size,this}Br.prototype.clear=Ec,Br.prototype.delete=$c,Br.prototype.get=Ic,Br.prototype.has=fW,Br.prototype.set=pW;function gW(D,N){var H=Uu(D),Y=!H&&CW(D),je=!H&&!Y&&H0(D),ne=!H&&!Y&&!je&&qw(D),pt=H||Y||je||ne,Bt=pt?ze(D.length,String):[],Wt=Bt.length;for(var rt in D)(N||pe.call(D,rt))&&!(pt&&(rt=="length"||je&&(rt=="offset"||rt=="parent")||ne&&(rt=="buffer"||rt=="byteLength"||rt=="byteOffset")||IW(rt,Wt)))&&Bt.push(rt);return Bt}function Lu(D,N){for(var H=D.length;H--;)if(Lw(D[H][0],N))return H;return-1}function bW(D,N,H){var Y=N(D);return Uu(D)?Y:qe(Y,H(D))}function Sc(D){return D==null?D===void 0?T:E:Se&&Se in Object(D)?EW(D):OW(D)}function Tw(D){return Ac(D)&&Sc(D)==a}function Rw(D,N,H,Y,je){return D===N?!0:D==null||N==null||!Ac(D)&&!Ac(N)?D!==D&&N!==N:mW(D,N,H,Y,Rw,je)}function mW(D,N,H,Y,je,ne){var pt=Uu(D),Bt=Uu(N),Wt=pt?c:Cn(D),rt=Bt?c:Cn(N);Wt=Wt==a?P:Wt,rt=rt==a?P:rt;var $r=Wt==P,Qr=rt==P,Jt=Wt==rt;if(Jt&&H0(D)){if(!H0(N))return!1;pt=!0,$r=!1}if(Jt&&!$r)return ne||(ne=new Br),pt||qw(D)?Nw(D,N,H,Y,je,ne):_W(D,N,Wt,H,Y,je,ne);if(!(H&n)){var Lr=$r&&pe.call(D,"__wrapped__"),Fr=Qr&&pe.call(N,"__wrapped__");if(Lr||Fr){var Dn=Lr?D.value():D,Ki=Fr?N.value():N;return ne||(ne=new Br),je(Dn,Ki,H,Y,ne)}}return Jt?(ne||(ne=new Br),xW(D,N,H,Y,je,ne)):!1}function vW(D){if(!jw(D)||AW(D))return!1;var N=Fw(D)?st:z;return N.test(Es(D))}function yW(D){return Ac(D)&&Uw(D.length)&&!!k[Sc(D)]}function wW(D){if(!PW(D))return ot(D);var N=[];for(var H in Object(D))pe.call(D,H)&&H!="constructor"&&N.push(H);return N}function Nw(D,N,H,Y,je,ne){var pt=H&n,Bt=D.length,Wt=N.length;if(Bt!=Wt&&!(pt&&Wt>Bt))return!1;var rt=ne.get(D);if(rt&&ne.get(N))return rt==N;var $r=-1,Qr=!0,Jt=H&s?new On:void 0;for(ne.set(D,N),ne.set(N,D);++$r<Bt;){var Lr=D[$r],Fr=N[$r];if(Y)var Dn=pt?Y(Fr,Lr,$r,N,D,ne):Y(Lr,Fr,$r,D,N,ne);if(Dn!==void 0){if(Dn)continue;Qr=!1;break}if(Jt){if(!Go(N,function(Ki,$s){if(!vs(Jt,$s)&&(Lr===Ki||je(Lr,Ki,H,Y,ne)))return Jt.push($s)})){Qr=!1;break}}else if(!(Lr===Fr||je(Lr,Fr,H,Y,ne))){Qr=!1;break}}return ne.delete(D),ne.delete(N),Qr}function _W(D,N,H,Y,je,ne,pt){switch(H){case h:if(D.byteLength!=N.byteLength||D.byteOffset!=N.byteOffset)return!1;D=D.buffer,N=N.buffer;case $:return!(D.byteLength!=N.byteLength||!ne(new Qe(D),new Qe(N)));case u:case d:case S:return Lw(+D,+N);case p:return D.name==N.name&&D.message==N.message;case R:case B:return D==N+"";case _:var Bt=Le;case L:var Wt=Y&n;if(Bt||(Bt=Fe),D.size!=N.size&&!Wt)return!1;var rt=pt.get(D);if(rt)return rt==N;Y|=s,pt.set(D,N);var $r=Nw(Bt(D),Bt(N),Y,je,ne,pt);return pt.delete(D),$r;case F:if(Ve)return Ve.call(D)==Ve.call(N)}return!1}function xW(D,N,H,Y,je,ne){var pt=H&n,Bt=Bw(D),Wt=Bt.length,rt=Bw(N),$r=rt.length;if(Wt!=$r&&!pt)return!1;for(var Qr=Wt;Qr--;){var Jt=Bt[Qr];if(!(pt?Jt in N:pe.call(N,Jt)))return!1}var Lr=ne.get(D);if(Lr&&ne.get(N))return Lr==N;var Fr=!0;ne.set(D,N),ne.set(N,D);for(var Dn=pt;++Qr<Wt;){Jt=Bt[Qr];var Ki=D[Jt],$s=N[Jt];if(Y)var zw=pt?Y($s,Ki,Jt,N,D,ne):Y(Ki,$s,Jt,D,N,ne);if(!(zw===void 0?Ki===$s||je(Ki,$s,H,Y,ne):zw)){Fr=!1;break}Dn||(Dn=Jt=="constructor")}if(Fr&&!Dn){var ju=D.constructor,qu=N.constructor;ju!=qu&&"constructor"in D&&"constructor"in N&&!(typeof ju=="function"&&ju instanceof ju&&typeof qu=="function"&&qu instanceof qu)&&(Fr=!1)}return ne.delete(D),ne.delete(N),Fr}function Bw(D){return bW(D,TW,$W)}function Fu(D,N){var H=D.__data__;return SW(N)?H[typeof N=="string"?"string":"hash"]:H.map}function Yo(D,N){var H=De(D,N);return vW(H)?H:void 0}function EW(D){var N=pe.call(D,Se),H=D[Se];try{D[Se]=void 0;var Y=!0}catch{}var je=uc.call(D);return Y&&(N?D[Se]=H:delete D[Se]),je}var $W=et?function(D){return D==null?[]:(D=Object(D),xe(et(D),function(N){return Xe.call(D,N)}))}:RW,Cn=Sc;(ke&&Cn(new ke(new ArrayBuffer(1)))!=h||Pn&&Cn(new Pn)!=_||He&&Cn(He.resolve())!=C||We&&Cn(new We)!=L||Zo&&Cn(new Zo)!=q)&&(Cn=function(D){var N=Sc(D),H=N==P?D.constructor:void 0,Y=H?Es(H):"";if(Y)switch(Y){case at:return h;case Ru:return _;case ct:return C;case lt:return L;case Nu:return q}return N});function IW(D,N){return N=N??o,!!N&&(typeof D=="number"||U.test(D))&&D>-1&&D%1==0&&D<N}function SW(D){var N=typeof D;return N=="string"||N=="number"||N=="symbol"||N=="boolean"?D!=="__proto__":D===null}function AW(D){return!!Ye&&Ye in D}function PW(D){var N=D&&D.constructor,H=typeof N=="function"&&N.prototype||Ae;return D===H}function OW(D){return uc.call(D)}function Es(D){if(D!=null){try{return _s.call(D)}catch{}try{return D+""}catch{}}return""}function Lw(D,N){return D===N||D!==D&&N!==N}var CW=Tw(function(){return arguments}())?Tw:function(D){return Ac(D)&&pe.call(D,"callee")&&!Xe.call(D,"callee")},Uu=Array.isArray;function DW(D){return D!=null&&Uw(D.length)&&!Fw(D)}var H0=Tu||NW;function MW(D,N){return Rw(D,N)}function Fw(D){if(!jw(D))return!1;var N=Sc(D);return N==y||N==m||N==l||N==M}function Uw(D){return typeof D=="number"&&D>-1&&D%1==0&&D<=o}function jw(D){var N=typeof D;return D!=null&&(N=="object"||N=="function")}function Ac(D){return D!=null&&typeof D=="object"}var qw=$t?Be($t):yW;function TW(D){return DW(D)?gW(D):wW(D)}function RW(){return[]}function NW(){return!1}t.exports=MW})(Jd,Jd.exports);var rO=Jd.exports,iO=Object.defineProperty,pv=Object.getOwnPropertySymbols,nO=Object.prototype.hasOwnProperty,sO=Object.prototype.propertyIsEnumerable,gv=(t,e,r)=>e in t?iO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rr=(t,e)=>{for(var r in e||(e={}))nO.call(e,r)&&gv(t,r,e[r]);if(pv)for(var r of pv(e))sO.call(e,r)&&gv(t,r,e[r]);return t};const bv="wc",mv=2,jl="core",vi=`${bv}@2:${jl}:`,oO={name:jl,logger:"error"},aO={database:":memory:"},cO="crypto",vv="client_ed25519_seed",lO=V.ONE_DAY,uO="keychain",hO="0.3",dO="messages",fO="0.3",yv=V.SIX_HOURS,pO="publisher",wv="irn",gO="error",_v="wss://relay.walletconnect.org",bO="relayer",Mt={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"},mO="_subscription",Mr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},vO=.1,Qd="2.19.0",Re={link_mode:"link_mode",relay:"relay"},yO="0.3",wO="WALLETCONNECT_CLIENT_ID",xv="WALLETCONNECT_LINK_MODE_APPS",vr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},_O="subscription",xO="0.3",EO=V.FIVE_SECONDS*1e3,$O="pairing",IO="0.3",La={wc_pairingDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:V.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:V.ONE_DAY,prompt:!1,tag:0},res:{ttl:V.ONE_DAY,prompt:!1,tag:0}}},Xn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},SO="history",AO="0.3",PO="expirer",Tr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},OO="0.3",CO="verify-api",DO="https://verify.walletconnect.com",Ev="https://verify.walletconnect.org",Fa=Ev,MO=`${Fa}/v3`,TO=[DO,Ev],RO="echo",NO="https://echo.walletconnect.com",yi={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"},ki={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"},Kr={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"},es={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"},ts={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"},Ua={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"},BO=.1,LO="event-client",FO=86400,UO="https://pulse.walletconnect.org/batch";function jO(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var _=0,S=0,E=0,P=m.length;E!==P&&m[E]===0;)E++,_++;for(var C=(P-E)*u+1>>>0,M=new Uint8Array(C);E!==P;){for(var R=m[E],L=0,B=C-1;(R!==0||L<S)&&B!==-1;B--,L++)R+=256*M[B]>>>0,M[B]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");S=L,E++}for(var F=C-S;F!==C&&M[F]===0;)F++;for(var T=c.repeat(_);F<C;++F)T+=t.charAt(M[F]);return T}function p(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var _=0;if(m[_]!==" "){for(var S=0,E=0;m[_]===c;)S++,_++;for(var P=(m.length-_)*l+1>>>0,C=new Uint8Array(P);m[_];){var M=r[m.charCodeAt(_)];if(M===255)return;for(var R=0,L=P-1;(M!==0||R<E)&&L!==-1;L--,R++)M+=a*C[L]>>>0,C[L]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=R,_++}if(m[_]!==" "){for(var B=P-E;B!==P&&C[B]===0;)B++;for(var F=new Uint8Array(S+(P-B)),T=S;B!==P;)F[T++]=C[B++];return F}}}function y(m){var _=p(m);if(_)return _;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:y}}var qO=jO,zO=qO;const $v=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")},kO=t=>new TextEncoder().encode(t),HO=t=>new TextDecoder().decode(t);class WO{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 VO{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 Iv(this,e)}}class KO{constructor(e){this.decoders=e}or(e){return Iv(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 Iv=(t,e)=>new KO(rr(rr({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class GO{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new WO(e,r,i),this.decoder=new VO(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ql=({name:t,prefix:e,encode:r,decode:i})=>new GO(t,e,r,i),ja=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=zO(r,e);return ql({prefix:t,name:e,encode:i,decode:s=>$v(n(s))})},ZO=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},YO=(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},zt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ql({prefix:e,name:t,encode(n){return YO(n,i,r)},decode(n){return ZO(n,i,r,t)}}),JO=ql({prefix:"\0",name:"identity",encode:t=>HO(t),decode:t=>kO(t)});var QO=Object.freeze({__proto__:null,identity:JO});const XO=zt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var eC=Object.freeze({__proto__:null,base2:XO});const tC=zt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var rC=Object.freeze({__proto__:null,base8:tC});const iC=ja({prefix:"9",name:"base10",alphabet:"0123456789"});var nC=Object.freeze({__proto__:null,base10:iC});const sC=zt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),oC=zt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var aC=Object.freeze({__proto__:null,base16:sC,base16upper:oC});const cC=zt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lC=zt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),uC=zt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hC=zt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),dC=zt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fC=zt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),pC=zt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),gC=zt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),bC=zt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mC=Object.freeze({__proto__:null,base32:cC,base32upper:lC,base32pad:uC,base32padupper:hC,base32hex:dC,base32hexupper:fC,base32hexpad:pC,base32hexpadupper:gC,base32z:bC});const vC=ja({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yC=ja({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wC=Object.freeze({__proto__:null,base36:vC,base36upper:yC});const _C=ja({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xC=ja({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var EC=Object.freeze({__proto__:null,base58btc:_C,base58flickr:xC});const $C=zt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),IC=zt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),SC=zt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),AC=zt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var PC=Object.freeze({__proto__:null,base64:$C,base64pad:IC,base64url:SC,base64urlpad:AC});const Sv=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),OC=Sv.reduce((t,e,r)=>(t[r]=e,t),[]),CC=Sv.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function DC(t){return t.reduce((e,r)=>(e+=OC[r],e),"")}function MC(t){const e=[];for(const r of t){const i=CC[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const TC=ql({prefix:"\u{1F680}",name:"base256emoji",encode:DC,decode:MC});var RC=Object.freeze({__proto__:null,base256emoji:TC}),NC=Pv,Av=128,BC=127,LC=~BC,FC=Math.pow(2,31);function Pv(t,e,r){e=e||[],r=r||0;for(var i=r;t>=FC;)e[r++]=t&255|Av,t/=128;for(;t&LC;)e[r++]=t&255|Av,t>>>=7;return e[r]=t|0,Pv.bytes=r-i+1,e}var UC=Xd,jC=128,Ov=127;function Xd(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Xd.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Ov)<<n:(o&Ov)*Math.pow(2,n),n+=7}while(o>=jC);return Xd.bytes=s-i,r}var qC=Math.pow(2,7),zC=Math.pow(2,14),kC=Math.pow(2,21),HC=Math.pow(2,28),WC=Math.pow(2,35),VC=Math.pow(2,42),KC=Math.pow(2,49),GC=Math.pow(2,56),ZC=Math.pow(2,63),YC=function(t){return t<qC?1:t<zC?2:t<kC?3:t<HC?4:t<WC?5:t<VC?6:t<KC?7:t<GC?8:t<ZC?9:10},JC={encode:NC,decode:UC,encodingLength:YC},Cv=JC;const Dv=(t,e,r=0)=>(Cv.encode(t,e,r),e),Mv=t=>Cv.encodingLength(t),ef=(t,e)=>{const r=e.byteLength,i=Mv(t),n=i+Mv(r),s=new Uint8Array(n+r);return Dv(t,s,0),Dv(r,s,i),s.set(e,n),new QC(t,r,e,s)};class QC{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Tv=({name:t,code:e,encode:r})=>new XC(t,e,r);class XC{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?ef(this.code,r):r.then(i=>ef(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Rv=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),eD=Tv({name:"sha2-256",code:18,encode:Rv("SHA-256")}),tD=Tv({name:"sha2-512",code:19,encode:Rv("SHA-512")});var rD=Object.freeze({__proto__:null,sha256:eD,sha512:tD});const Nv=0,iD="identity",Bv=$v;var nD=Object.freeze({__proto__:null,identity:{code:Nv,name:iD,encode:Bv,digest:t=>ef(Nv,Bv(t))}});new TextEncoder,new TextDecoder;const Lv=rr(rr(rr(rr(rr(rr(rr(rr(rr(rr({},QO),eC),rC),nC),aC),mC),wC),EC),PC),RC);rr(rr({},rD),nD);function sD(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Fv(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Uv=Fv("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),tf=Fv("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=sD(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),oD=rr({utf8:Uv,"utf-8":Uv,hex:Lv.base16,latin1:tf,ascii:tf,binary:tf},Lv);function aD(t,e="utf8"){const r=oD[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 cD=Object.defineProperty,lD=(t,e,r)=>e in t?cD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wi=(t,e,r)=>lD(t,typeof e!="symbol"?e+"":e,r);class uD{constructor(e,r){this.core=e,this.logger=r,wi(this,"keychain",new Map),wi(this,"name",uO),wi(this,"version",hO),wi(this,"initialized",!1),wi(this,"storagePrefix",vi),wi(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),wi(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),wi(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),wi(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=K("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),wi(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=tr(r,this.name)}get context(){return lr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Pb(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ob(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var hD=Object.defineProperty,dD=(t,e,r)=>e in t?hD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r)=>dD(t,typeof e!="symbol"?e+"":e,r);class fD{constructor(e,r,i){this.core=e,this.logger=r,kt(this,"name",cO),kt(this,"keychain"),kt(this,"randomSessionIdentifier",Rd()),kt(this,"initialized",!1),kt(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),kt(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),kt(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=yg(n);return vg(s.publicKey)}),kt(this,"generateKeyPair",()=>{this.isInitialized();const n=WI();return this.setPrivateKey(n.publicKey,n.privateKey)}),kt(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=yg(s),a=this.randomSessionIdentifier;return await e9(a,n,lO,o)}),kt(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=VI(a,s);return this.setSymKey(c,o)}),kt(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||$l(n);return await this.keychain.set(o,n),o}),kt(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),kt(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),kt(this,"encode",async(n,s,o)=>{this.isInitialized();const a=Sm(o),c=Mi(s);if(Pm(a))return ZI(c,o?.encoding);if(Am(a)){const p=a.senderPublicKey,y=a.receiverPublicKey;n=await this.generateSharedKey(p,y)}const l=this.getSymKey(n),{type:u,senderPublicKey:d}=a;return KI({type:u,symKey:l,message:c,senderPublicKey:d,encoding:o?.encoding})}),kt(this,"decode",async(n,s,o)=>{this.isInitialized();const a=JI(s,o);if(Pm(a)){const c=YI(s,o?.encoding);return Fn(c)}if(Am(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;n=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(n),l=GI({symKey:c,encoded:s,encoding:o?.encoding});return Fn(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),kt(this,"getPayloadType",(n,s=pn)=>{const o=Sa({encoded:n,encoding:s});return Zn(o.type)}),kt(this,"getPayloadSenderPublicKey",(n,s=pn)=>{const o=Sa({encoded:n,encoding:s});return o.senderPublicKey?Xt(o.senderPublicKey,Gt):void 0}),this.core=e,this.logger=tr(r,this.name),this.keychain=i||new uD(this.core,this.logger)}get context(){return lr(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(vv)}catch{e=Rd(),await this.keychain.set(vv,e)}return aD(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var pD=Object.defineProperty,gD=(t,e,r)=>e in t?pD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_i=(t,e,r)=>gD(t,typeof e!="symbol"?e+"":e,r);class bD extends tP{constructor(e,r){super(e,r),this.logger=e,this.core=r,_i(this,"messages",new Map),_i(this,"name",dO),_i(this,"version",fO),_i(this,"initialized",!1),_i(this,"storagePrefix",vi),_i(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),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}}}),_i(this,"set",async(i,n)=>{this.isInitialized();const s=ji(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s}),_i(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),_i(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=ji(n);return typeof s[o]<"u"}),_i(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=tr(e,this.name),this.core=r}get context(){return lr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Pb(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ob(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var mD=Object.defineProperty,vD=Object.defineProperties,yD=Object.getOwnPropertyDescriptors,jv=Object.getOwnPropertySymbols,wD=Object.prototype.hasOwnProperty,_D=Object.prototype.propertyIsEnumerable,rf=(t,e,r)=>e in t?mD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zl=(t,e)=>{for(var r in e||(e={}))wD.call(e,r)&&rf(t,r,e[r]);if(jv)for(var r of jv(e))_D.call(e,r)&&rf(t,r,e[r]);return t},nf=(t,e)=>vD(t,yD(e)),Gr=(t,e,r)=>rf(t,typeof e!="symbol"?e+"":e,r);class xD extends rP{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,Gr(this,"events",new Lt.exports.EventEmitter),Gr(this,"name",pO),Gr(this,"queue",new Map),Gr(this,"publishTimeout",V.toMiliseconds(V.ONE_MINUTE)),Gr(this,"initialPublishTimeout",V.toMiliseconds(V.ONE_SECOND*15)),Gr(this,"needsTransportRestart",!1),Gr(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||yv,c=Il(s),l=s?.prompt||!1,u=s?.tag||0,d=s?.id||Qn().toString(),p={topic:i,message:n,opts:{ttl:a,relay:c,prompt:l,tag:u,id:d,attestation:s?.attestation,tvf:s?.tvf}},y=`Failed to publish payload, please try again. id:${d} tag:${u}`;try{const m=new Promise(async _=>{const S=({id:P})=>{p.opts.id===P&&(this.removeRequestFromQueue(P),this.relayer.events.removeListener(Mt.publish,S),_(p))};this.relayer.events.on(Mt.publish,S);const E=ln(new Promise((P,C)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:l,tag:u,id:d,attestation:s?.attestation,tvf:s?.tvf}).then(P).catch(M=>{this.logger.warn(M,M?.message),C(M)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${d} tag:${u}`);try{await E,this.events.removeListener(Mt.publish,S)}catch(P){this.queue.set(d,nf(zl({},p),{attempt:1})),this.logger.warn(P,P?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:d,topic:i,message:n,opts:s}}),await ln(m,this.publishTimeout,y)}catch(m){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(m),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw m}finally{this.queue.delete(d)}}),Gr(this,"on",(i,n)=>{this.events.on(i,n)}),Gr(this,"once",(i,n)=>{this.events.once(i,n)}),Gr(this,"off",(i,n)=>{this.events.off(i,n)}),Gr(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=tr(r,this.name),this.registerEventListeners()}get context(){return lr(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=yv,prompt:l,tag:u,id:d,attestation:p,tvf:y}=e,m={method:Aa(Il().protocol).publish,params:zl({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:p},y),id:d};er((r=m.params)==null?void 0:r.prompt)&&((i=m.params)==null||delete i.prompt),er((n=m.params)==null?void 0:n.tag)&&((s=m.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:m});const _=await this.relayer.request(m);return this.relayer.events.emit(Mt.publish,e),this.logger.debug("Successfully Published Payload"),_}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,nf(zl({},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(nf(zl({},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(ao.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Mt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Mt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var ED=Object.defineProperty,$D=(t,e,r)=>e in t?ED(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,uo=(t,e,r)=>$D(t,typeof e!="symbol"?e+"":e,r);class ID{constructor(){uo(this,"map",new Map),uo(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),uo(this,"get",e=>this.map.get(e)||[]),uo(this,"exists",(e,r)=>this.get(e).includes(r)),uo(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)}),uo(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var SD=Object.defineProperty,AD=Object.defineProperties,PD=Object.getOwnPropertyDescriptors,qv=Object.getOwnPropertySymbols,OD=Object.prototype.hasOwnProperty,CD=Object.prototype.propertyIsEnumerable,sf=(t,e,r)=>e in t?SD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qa=(t,e)=>{for(var r in e||(e={}))OD.call(e,r)&&sf(t,r,e[r]);if(qv)for(var r of qv(e))CD.call(e,r)&&sf(t,r,e[r]);return t},of=(t,e)=>AD(t,PD(e)),Ie=(t,e,r)=>sf(t,typeof e!="symbol"?e+"":e,r);class DD extends sP{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,Ie(this,"subscriptions",new Map),Ie(this,"topicMap",new ID),Ie(this,"events",new Lt.exports.EventEmitter),Ie(this,"name",_O),Ie(this,"version",xO),Ie(this,"pending",new Map),Ie(this,"cached",[]),Ie(this,"initialized",!1),Ie(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),Ie(this,"pollingInterval",20),Ie(this,"storagePrefix",vi),Ie(this,"subscribeTimeout",V.toMiliseconds(V.ONE_MINUTE)),Ie(this,"initialSubscribeTimeout",V.toMiliseconds(V.ONE_SECOND*15)),Ie(this,"clientId"),Ie(this,"batchSubscribeTopicsLimit",500),Ie(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ie(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=Il(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}}),Ie(this,"unsubscribe",async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),Ie(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new V.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(l=>l.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=EO&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),Ie(this,"on",(i,n)=>{this.events.on(i,n)}),Ie(this,"once",(i,n)=>{this.events.once(i,n)}),Ie(this,"off",(i,n)=>{this.events.off(i,n)}),Ie(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),Ie(this,"start",async()=>{await this.onConnect()}),Ie(this,"stop",async()=>{await this.onDisconnect()}),Ie(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Ie(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)}),Ie(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(ao.pulse,async()=>{await this.checkPending()}),this.events.on(vr.created,async i=>{const n=vr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(vr.deleted,async i=>{const n=vr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=tr(r,this.name),this.clientId=""}get context(){return lr(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.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=Il(i);await this.restartToComplete({topic:e,id:r,relay:n}),await this.rpcUnsubscribe(e,r,n);const s=_e("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===Re.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const s={method:Aa(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===Re.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},V.toMiliseconds(V.ONE_SECOND)),a;const c=new Promise(async u=>{const d=p=>{p.topic===e&&(this.events.removeListener(vr.created,d),u(p.id))};this.events.on(vr.created,d);try{const p=await ln(new Promise((y,m)=>{this.relayer.request(s).catch(_=>{this.logger.warn(_,_?.message),m(_)}).then(y)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(vr.created,d),u(p)}catch{}}),l=await ln(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Mt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Aa(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 ln(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(Mt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Aa(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 ln(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(Mt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Aa(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,of(qa({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,qa({},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,qa({},r)),this.topicMap.set(r.topic,e),this.events.emit(vr.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}=K("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(vr.deleted,of(qa({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(vr.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(vr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=K("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=>of(qa({},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 a$(V.toMiliseconds(V.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}=K("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 ji(e+await this.getClientId())}}var MD=Object.defineProperty,zv=Object.getOwnPropertySymbols,TD=Object.prototype.hasOwnProperty,RD=Object.prototype.propertyIsEnumerable,af=(t,e,r)=>e in t?MD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kv=(t,e)=>{for(var r in e||(e={}))TD.call(e,r)&&af(t,r,e[r]);if(zv)for(var r of zv(e))RD.call(e,r)&&af(t,r,e[r]);return t},be=(t,e,r)=>af(t,typeof e!="symbol"?e+"":e,r);class ND extends iP{constructor(e){super(e),be(this,"protocol","wc"),be(this,"version",2),be(this,"core"),be(this,"logger"),be(this,"events",new Lt.exports.EventEmitter),be(this,"provider"),be(this,"messages"),be(this,"subscriber"),be(this,"publisher"),be(this,"name",bO),be(this,"transportExplicitlyClosed",!1),be(this,"initialized",!1),be(this,"connectionAttemptInProgress",!1),be(this,"relayUrl"),be(this,"projectId"),be(this,"packageName"),be(this,"bundleId"),be(this,"hasExperiencedNetworkDisruption",!1),be(this,"pingTimeout"),be(this,"heartBeatTimeout",V.toMiliseconds(V.THIRTY_SECONDS+V.FIVE_SECONDS)),be(this,"reconnectTimeout"),be(this,"connectPromise"),be(this,"reconnectInProgress",!1),be(this,"requestsInFlight",[]),be(this,"connectTimeout",V.toMiliseconds(V.ONE_SECOND*15)),be(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||Qn().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}}),be(this,"resetPingTimeout",()=>{if(gl())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),be(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),be(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Mt.connect)}),be(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()}),be(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(Mt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),be(this,"registerProviderListeners",()=>{this.provider.on(Mr.payload,this.onPayloadHandler),this.provider.on(Mr.connect,this.onConnectHandler),this.provider.on(Mr.disconnect,this.onDisconnectHandler),this.provider.on(Mr.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?tr(e.logger,this.name):pi(Bl({level:e.logger||gO})),this.messages=new bD(this.logger,e.core),this.subscriber=new DD(this,this.logger),this.publisher=new xD(this,this.logger),this.relayUrl=e?.relayUrl||_v,this.projectId=e.projectId,VE()?this.packageName=Ib():KE()&&(this.bundleId=Ib()),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 lr(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:Re.relay})}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 l=u=>{u.topic===e&&(this.subscriber.off(vr.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(vr.created,l)}),new Promise(async(u,d)=>{a=await this.subscriber.subscribe(e,kv({internal:{throwOnFailedPublish:o}},r)).catch(p=>{o&&d(p)})||a,u()})]),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 ln(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 Fm())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=xt(V.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Mt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let 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(Mr.disconnect,s),await ln(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(Mr.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(Mr.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Mr.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,V.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(gl())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 Dr(new tO(JE({sdkVersion:Qd,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}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.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed 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}),Yd(e)){if(!e.method.endsWith(mO))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:Re.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(kv({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Ul(e)&&this.events.emit(Mt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Mt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Ll(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Mr.payload,this.onPayloadHandler),this.provider.off(Mr.connect,this.onConnectHandler),this.provider.off(Mr.disconnect,this.onDisconnectHandler),this.provider.off(Mr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Fm();FS(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))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Mt.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},V.toMiliseconds(vO)))))}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var BD=Object.defineProperty,Hv=Object.getOwnPropertySymbols,LD=Object.prototype.hasOwnProperty,FD=Object.prototype.propertyIsEnumerable,cf=(t,e,r)=>e in t?BD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wv=(t,e)=>{for(var r in e||(e={}))LD.call(e,r)&&cf(t,r,e[r]);if(Hv)for(var r of Hv(e))FD.call(e,r)&&cf(t,r,e[r]);return t},ur=(t,e,r)=>cf(t,typeof e!="symbol"?e+"":e,r);class rs extends nP{constructor(e,r,i,n=vi,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,ur(this,"map",new Map),ur(this,"version",yO),ur(this,"cached",[]),ur(this,"initialized",!1),ur(this,"getKey"),ur(this,"storagePrefix",vi),ur(this,"recentlyDeleted",[]),ur(this,"recentlyDeletedLimit",200),ur(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!er(o)?this.map.set(this.getKey(o),o):gS(o)?this.map.set(o.id,o):bS(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),ur(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())}),ur(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),ur(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>rO(a[c],o[c]))):this.values)),ur(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=Wv(Wv({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),ur(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=tr(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return lr(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}=K("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=K("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}=K("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}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var UD=Object.defineProperty,jD=(t,e,r)=>e in t?UD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,le=(t,e,r)=>jD(t,typeof e!="symbol"?e+"":e,r);class qD{constructor(e,r){this.core=e,this.logger=r,le(this,"name",$O),le(this,"version",IO),le(this,"events",new Lt.exports),le(this,"pairings"),le(this,"initialized",!1),le(this,"storagePrefix",vi),le(this,"ignoredPayloadTypes",[Ui]),le(this,"registeredMethods",[]),le(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),le(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),le(this,"create",async i=>{this.isInitialized();const n=Rd(),s=await this.core.crypto.setSymKey(n),o=xt(V.FIVE_MINUTES),a={protocol:wv},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},l=Cm({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Xn.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:l}}),le(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[yi.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Om(i.uri);n.props.properties.topic=s,n.addTrace(yi.pairing_uri_validation_success),n.addTrace(yi.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(yi.existing_pairing),u.active)throw n.setError(ki.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(yi.pairing_not_expired)}const d=c||xt(V.FIVE_MINUTES),p={topic:s,relay:a,expiry:d,active:!1,methods:l};this.core.expirer.set(s,d),await this.pairings.set(s,p),n.addTrace(yi.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Xn.create,p),n.addTrace(yi.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(yi.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ki.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(y){throw n.setError(ki.subscribe_pairing_topic_failure),y}return n.addTrace(yi.subscribe_pairing_topic_success),p}),le(this,"activate",async({topic:i})=>{this.isInitialized();const n=xt(V.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),le(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}=Kn();this.events.once(ye("pairing_ping",s),({error:l})=>{l?c(l):a()}),await o()}}),le(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),le(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),le(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),le(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",_e("USER_DISCONNECTED")),await this.deletePairing(n))}),le(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return Cm({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),le(this,"sendRequest",async(i,n,s)=>{const o=gn(n,s),a=await this.core.crypto.encode(i,o),c=La[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),le(this,"sendResult",async(i,n,s)=>{const o=Ll(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,l=La[c].res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)}),le(this,"sendError",async(i,n,s)=>{const o=Fl(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,l=La[c]?La[c].res:La.unregistered_method.res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)}),le(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,_e("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),le(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>un(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),le(this,"onRelayEventRequest",i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}}),le(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)}}),le(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Xn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),le(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{mi(n)?this.events.emit(ye("pairing_ping",s),{}):Cr(n)&&this.events.emit(ye("pairing_ping",s),{error:n.error})},500)}),le(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Xn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),le(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=_e("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)}}),le(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(_e("WC_METHOD_UNSUPPORTED",i))}),le(this,"isValidPair",(i,n)=>{var s;if(!ar(i)){const{message:a}=K("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ki.malformed_pairing_uri),new Error(a)}if(!pS(i.uri)){const{message:a}=K("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ki.malformed_pairing_uri),new Error(a)}const o=Om(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=K("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ki.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=K("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ki.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&V.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(ki.pairing_expired);const{message:a}=K("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),le(this,"isValidPing",async i=>{if(!ar(i)){const{message:s}=K("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),le(this,"isValidDisconnect",async i=>{if(!ar(i)){const{message:s}=K("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),le(this,"isValidPairingTopic",async i=>{if(!mt(i,!1)){const{message:n}=K("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=K("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(un(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=K("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=tr(r,this.name),this.pairings=new rs(this.core,this.logger,this.name,this.storagePrefix)}get context(){return lr(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Mt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===Re.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Yd(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Ul(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Tr.expired,async e=>{const{topic:r}=Db(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Xn.expire,{topic:r}))})}}var zD=Object.defineProperty,kD=(t,e,r)=>e in t?zD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ht=(t,e,r)=>kD(t,typeof e!="symbol"?e+"":e,r);class HD extends eP{constructor(e,r){super(e,r),this.core=e,this.logger=r,Ht(this,"records",new Map),Ht(this,"events",new Lt.exports.EventEmitter),Ht(this,"name",SO),Ht(this,"version",AO),Ht(this,"cached",[]),Ht(this,"initialized",!1),Ht(this,"storagePrefix",vi),Ht(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)}),Ht(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:xt(V.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Vr.created,o)}),Ht(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=Cr(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Vr.updated,n))}),Ht(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))),Ht(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(Vr.deleted,s)}}),this.persist()}),Ht(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),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.logger=tr(r,this.name)}get context(){return lr(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:gn(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}=K("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Vr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=K("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(Vr.created,e=>{const r=Vr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Vr.updated,e=>{const r=Vr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Vr.deleted,e=>{const r=Vr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(ao.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{V.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Vr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var WD=Object.defineProperty,VD=(t,e,r)=>e in t?WD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zt=(t,e,r)=>VD(t,typeof e!="symbol"?e+"":e,r);class KD extends oP{constructor(e,r){super(e,r),this.core=e,this.logger=r,Zt(this,"expirations",new Map),Zt(this,"events",new Lt.exports.EventEmitter),Zt(this,"name",PO),Zt(this,"version",OO),Zt(this,"cached",[]),Zt(this,"initialized",!1),Zt(this,"storagePrefix",vi),Zt(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)}),Zt(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),Zt(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(Tr.created,{target:s,expiration:o})}),Zt(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),Zt(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(Tr.deleted,{target:n,expiration:s})}}),Zt(this,"on",(i,n)=>{this.events.on(i,n)}),Zt(this,"once",(i,n)=>{this.events.once(i,n)}),Zt(this,"off",(i,n)=>{this.events.off(i,n)}),Zt(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=tr(r,this.name)}get context(){return lr(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 QE(e);if(typeof e=="number")return XE(e);const{message:r}=K("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(Tr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=K("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}=K("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;V.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Tr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(ao.pulse,()=>this.checkExpirations()),this.events.on(Tr.created,e=>{const r=Tr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Tr.expired,e=>{const r=Tr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Tr.deleted,e=>{const r=Tr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}}var GD=Object.defineProperty,ZD=(t,e,r)=>e in t?GD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yt=(t,e,r)=>ZD(t,typeof e!="symbol"?e+"":e,r);class YD extends aP{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,yt(this,"name",CO),yt(this,"abortController"),yt(this,"isDevEnv"),yt(this,"verifyUrlV3",MO),yt(this,"storagePrefix",vi),yt(this,"version",mv),yt(this,"publicKey"),yt(this,"fetchPromise"),yt(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&V.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),yt(this,"register",async n=>{if(!ba()||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 l=ea(),u=this.startAbortTimer(V.ONE_SECOND*5),d=await new Promise((p,y)=>{const m=()=>{window.removeEventListener("message",S),l.body.removeChild(_),y("attestation aborted")};this.abortController.signal.addEventListener("abort",m);const _=l.createElement("iframe");_.src=c,_.style.display="none",_.addEventListener("error",m,{signal:this.abortController.signal});const S=E=>{if(E.data&&typeof E.data=="string")try{const P=JSON.parse(E.data);if(P.type==="verify_attestation"){if(Gh(P.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(_),this.abortController.signal.removeEventListener("abort",m),window.removeEventListener("message",S),p(P.attestation===null?"":P.attestation)}}catch(P){this.logger.warn(P)}};l.body.appendChild(_),window.addEventListener("message",S,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",d),d}catch(l){this.logger.warn(l)}return""}),yt(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(Gh(s).payload.id!==a)return;const l=await this.isValidJwtAttestation(s);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),yt(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(V.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}),yt(this,"getVerifyUrl",n=>{let s=n||Fa;return TO.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Fa}`),s=Fa),s}),yt(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(V.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)}}),yt(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),yt(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),yt(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")}}),yt(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),yt(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}),yt(this,"validateAttestation",(n,s)=>{const o=tS(n,s.publicKey),a={hasExpired:V.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=tr(r,this.name),this.abortController=new AbortController,this.isDevEnv=gd(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return lr(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),V.toMiliseconds(e))}}var JD=Object.defineProperty,QD=(t,e,r)=>e in t?JD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vv=(t,e,r)=>QD(t,typeof e!="symbol"?e+"":e,r);class XD extends cP{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,Vv(this,"context",RO),Vv(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${NO}/${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=tr(r,this.context)}}var eM=Object.defineProperty,Kv=Object.getOwnPropertySymbols,tM=Object.prototype.hasOwnProperty,rM=Object.prototype.propertyIsEnumerable,lf=(t,e,r)=>e in t?eM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,za=(t,e)=>{for(var r in e||(e={}))tM.call(e,r)&&lf(t,r,e[r]);if(Kv)for(var r of Kv(e))rM.call(e,r)&&lf(t,r,e[r]);return t},Tt=(t,e,r)=>lf(t,typeof e!="symbol"?e+"":e,r);class iM extends lP{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,Tt(this,"context",LO),Tt(this,"storagePrefix",vi),Tt(this,"storageVersion",BO),Tt(this,"events",new Map),Tt(this,"shouldPersist",!1),Tt(this,"init",async()=>{if(!gd())try{const n={eventId:Tb(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Ab(this.core.relayer.protocol,this.core.relayer.version,Qd)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),Tt(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,l=Tb(),u=this.core.projectId||"",d=Date.now(),p=za({eventId:l,timestamp:d,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,p),this.shouldPersist=!0),p}),Tt(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 za(za({},a),this.setMethods(a.eventId))}),Tt(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),Tt(this,"setEventListeners",()=>{this.core.heartbeat.on(ao.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{V.fromMiliseconds(Date.now())-V.fromMiliseconds(n.timestamp)>FO&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),Tt(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),Tt(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)}),Tt(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)}),Tt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Tt(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,za(za({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),Tt(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)}}),Tt(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${UO}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Qd}${s}`,{method:"POST",body:JSON.stringify(n)})}),Tt(this,"getAppDomain",()=>Sb().url),this.logger=tr(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 nM=Object.defineProperty,Gv=Object.getOwnPropertySymbols,sM=Object.prototype.hasOwnProperty,oM=Object.prototype.propertyIsEnumerable,uf=(t,e,r)=>e in t?nM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zv=(t,e)=>{for(var r in e||(e={}))sM.call(e,r)&&uf(t,r,e[r]);if(Gv)for(var r of Gv(e))oM.call(e,r)&&uf(t,r,e[r]);return t},Ce=(t,e,r)=>uf(t,typeof e!="symbol"?e+"":e,r);class hf extends YA{constructor(e){var r;super(e),Ce(this,"protocol",bv),Ce(this,"version",mv),Ce(this,"name",jl),Ce(this,"relayUrl"),Ce(this,"projectId"),Ce(this,"customStoragePrefix"),Ce(this,"events",new Lt.exports.EventEmitter),Ce(this,"logger"),Ce(this,"heartbeat"),Ce(this,"relayer"),Ce(this,"crypto"),Ce(this,"storage"),Ce(this,"history"),Ce(this,"expirer"),Ce(this,"pairing"),Ce(this,"verify"),Ce(this,"echoClient"),Ce(this,"linkModeSupportedApps"),Ce(this,"eventClient"),Ce(this,"initialized",!1),Ce(this,"logChunkController"),Ce(this,"on",(o,a)=>this.events.on(o,a)),Ce(this,"once",(o,a)=>this.events.once(o,a)),Ce(this,"off",(o,a)=>this.events.off(o,a)),Ce(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),Ce(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const l={topic:o,message:a,publishedAt:Date.now(),transportType:Re.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:c})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||_v,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Bl({level:typeof e?.logger=="string"&&e.logger?e.logger:oO.logger,name:jl}),{logger:n,chunkLoggerController:s}=KA({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=tr(n,this.name),this.heartbeat=new Ud,this.crypto=new fD(this,this.logger,e?.keychain),this.history=new HD(this,this.logger),this.expirer=new KD(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new yA(Zv(Zv({},aO),e?.storageOptions)),this.relayer=new ND({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new qD(this,this.logger),this.verify=new YD(this,this.logger,this.storage),this.echoClient=new XD(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new iM(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new hf(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(wO,i),r}get context(){return lr(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(xv,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(xv)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const aM=hf,Yv="wc",Jv=2,Qv="client",df=`${Yv}@${Jv}:${Qv}:`,ff={name:Qv,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Xv="WALLETCONNECT_DEEPLINK_CHOICE",cM="proposal",e2="Proposal expired",lM="session",ho=V.SEVEN_DAYS,uM="engine",Rt={wc_sessionPropose:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1104},res:{ttl:V.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1106},res:{ttl:V.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1112},res:{ttl:V.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1114},res:{ttl:V.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:V.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:V.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1119}}},pf={min:V.FIVE_MINUTES,max:V.SEVEN_DAYS},xi={idle:"IDLE",active:"ACTIVE"},t2={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},hM="request",dM=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],fM="wc",pM="auth",gM="authKeys",bM="pairingTopics",mM="requests",kl=`${fM}@${1.5}:${pM}:`,Hl=`${kl}:PUB_KEY`;var vM=Object.defineProperty,yM=Object.defineProperties,wM=Object.getOwnPropertyDescriptors,r2=Object.getOwnPropertySymbols,_M=Object.prototype.hasOwnProperty,xM=Object.prototype.propertyIsEnumerable,gf=(t,e,r)=>e in t?vM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ke=(t,e)=>{for(var r in e||(e={}))_M.call(e,r)&&gf(t,r,e[r]);if(r2)for(var r of r2(e))xM.call(e,r)&&gf(t,r,e[r]);return t},hr=(t,e)=>yM(t,wM(e)),W=(t,e,r)=>gf(t,typeof e!="symbol"?e+"":e,r);class EM extends fP{constructor(e){super(e),W(this,"name",uM),W(this,"events",new Lt.exports),W(this,"initialized",!1),W(this,"requestQueue",{state:xi.idle,queue:[]}),W(this,"sessionRequestQueue",{state:xi.idle,queue:[]}),W(this,"requestQueueDelay",V.ONE_SECOND),W(this,"expectedPairingMethodMap",new Map),W(this,"recentlyDeletedMap",new Map),W(this,"recentlyDeletedLimit",200),W(this,"relayMessageCache",[]),W(this,"pendingSessions",new Map),W(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(Rt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay)))}),W(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=hr(Ke({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let l=n,u,d=!1;try{if(l){const R=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=R.active}}catch(R){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),R}if(!l||!d){const{topic:R,uri:L}=await this.client.core.pairing.create();l=R,u=L}if(!l){const{message:R}=K("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(R)}const p=await this.client.core.crypto.generateKeyPair(),y=Rt.wc_sessionPropose.req.ttl||V.FIVE_MINUTES,m=xt(y),_=hr(Ke({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:wv}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:m,pairingTopic:l},a&&{sessionProperties:a}),{id:bi()}),S=ye("session_connect",_.id),{reject:E,resolve:P,done:C}=Kn(y,e2),M=({id:R})=>{R===_.id&&(this.client.events.off("proposal_expire",M),this.pendingSessions.delete(_.id),this.events.emit(S,{error:{message:e2,code:0}}))};return this.client.events.on("proposal_expire",M),this.events.once(S,({error:R,session:L})=>{this.client.events.off("proposal_expire",M),R?E(R):L&&P(L)}),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:_,throwOnFailedPublish:!0,clientRpcId:_.id}),await this.setProposal(_.id,_),{uri:u,approval:C}}),W(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}}),W(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:[Kr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(F){throw o.setError(es.no_internet_connection),F}try{await this.isValidProposalId(r?.id)}catch(F){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(es.proposal_not_found),F}try{await this.isValidApprove(r)}catch(F){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(es.session_approve_namespace_validation_failure),F}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,sessionConfig:d}=r,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:y,proposer:m,requiredNamespaces:_,optionalNamespaces:S}=p;let E=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:y});E||(E=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Kr.session_approve_started,properties:{topic:y,trace:[Kr.session_approve_started,Kr.session_namespaces_validation_success]}}));const P=await this.client.core.crypto.generateKeyPair(),C=m.publicKey,M=await this.client.core.crypto.generateSharedKey(P,C),R=Ke(Ke({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:P,metadata:this.client.metadata},expiry:xt(ho)},u&&{sessionProperties:u}),d&&{sessionConfig:d}),L=Re.relay;E.addTrace(Kr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:L})}catch(F){throw E.setError(es.subscribe_session_topic_failure),F}E.addTrace(Kr.subscribe_session_topic_success);const B=hr(Ke({},R),{topic:M,requiredNamespaces:_,optionalNamespaces:S,pairingTopic:y,acknowledged:!1,self:R.controller,peer:{publicKey:m.publicKey,metadata:m.metadata},controller:P,transportType:Re.relay});await this.client.session.set(M,B),E.addTrace(Kr.store_session);try{E.addTrace(Kr.publishing_session_settle),await this.sendRequest({topic:M,method:"wc_sessionSettle",params:R,throwOnFailedPublish:!0}).catch(F=>{throw E?.setError(es.session_settle_publish_failure),F}),E.addTrace(Kr.session_settle_publish_success),E.addTrace(Kr.publishing_session_approve),await this.sendResult({id:a,topic:y,result:{relay:{protocol:c??"irn"},responderPublicKey:P},throwOnFailedPublish:!0}).catch(F=>{throw E?.setError(es.session_approve_publish_failure),F}),E.addTrace(Kr.session_approve_publish_success)}catch(F){throw this.client.logger.error(F),this.client.session.delete(M,_e("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(M),F}return this.client.core.eventClient.deleteEvent({eventId:E.eventId}),await this.client.core.pairing.updateMetadata({topic:y,metadata:m.metadata}),await this.client.proposal.delete(a,_e("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:y}),await this.setExpiry(M,xt(ho)),{topic:M,acknowledged:()=>Promise.resolve(this.client.session.get(M))}}),W(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:Rt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,_e("USER_DISCONNECTED")))}),W(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(d){throw this.client.logger.error("update() -> isValidUpdate() failed"),d}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=Kn(),c=bi(),l=Qn().toString(),u=this.client.session.get(i).namespaces;return this.events.once(ye("session_update",c),({error:d})=>{d?a(d):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:l}).catch(d=>{this.client.logger.error(d),this.client.session.update(i,{namespaces:u}),a(d)}),{acknowledged:s}}),W(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=bi(),{done:s,resolve:o,reject:a}=Kn();return this.events.once(ye("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,xt(ho)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),W(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(E){throw this.client.logger.error("request() -> isValidRequest() failed"),E}const{chainId:i,request:n,topic:s,expiry:o=Rt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===Re.relay&&await this.confirmOnlineStateOrThrow();const c=bi(),l=Qn().toString(),{done:u,resolve:d,reject:p}=Kn(o,"Request expired. Please try again.");this.events.once(ye("session_request",c),({error:E,result:P})=>{E?p(E):d(P)});const y="wc_sessionRequest",m=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:s,method:y,params:{request:hr(Ke({},n),{expiryTimestamp:xt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:m}).catch(E=>p(E)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await u();const _={request:hr(Ke({},n),{expiryTimestamp:xt(o)}),chainId:i},S=this.shouldSetTVF(y,_);return await Promise.all([new Promise(async E=>{await this.sendRequest(Ke({clientRpcId:c,relayRpcId:l,topic:s,method:y,params:_,expiry:o,throwOnFailedPublish:!0},S&&{tvf:this.getTVFParams(c,_)})).catch(P=>p(P)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),E()}),new Promise(async E=>{var P;if(!((P=a.sessionConfig)!=null&&P.disableDeepLink)){const C=await i$(this.client.core.storage,Xv);await e$({id:c,topic:s,wcDeepLink:C})}E()}),u()]).then(E=>E[2])}),W(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===Re.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);mi(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Cr(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),W(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=bi(),s=Qn().toString(),{done:o,resolve:a,reject:c}=Kn();this.events.once(ye("session_ping",n),({error:l})=>{l?c(l):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}))}),W(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=Qn().toString(),a=bi();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),W(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:_e("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}=K("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),W(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>dS(i,r)))),W(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),W(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?Re.link_mode:Re.relay;o===Re.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:d,type:p,exp:y,nbf:m,methods:_=[],expiry:S}=r,E=[...r.resources||[]],{topic:P,uri:C}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:P,uri:C}});const M=await this.client.core.crypto.generateKeyPair(),R=$l(M);if(await Promise.all([this.client.auth.authKeys.set(Hl,{responseTopic:R,publicKey:M}),this.client.auth.pairingTopics.set(R,{topic:R,pairingTopic:P})]),await this.client.core.relayer.subscribe(R,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${P}`),_.length>0){const{namespace:x}=Xs(a[0]);let f=V$(x,"request",_);wl(E)&&(f=G$(f,E.pop())),E.push(f)}const L=S&&S>Rt.wc_sessionAuthenticate.req.ttl?S:Rt.wc_sessionAuthenticate.req.ttl,B={authPayload:{type:p??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:d,iat:new Date().toISOString(),exp:y,nbf:m,resources:E},requester:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:xt(L)},F={eip155:{chains:a,methods:[...new Set(["personal_sign",..._])],events:["chainChanged","accountsChanged"]}},T={requiredNamespaces:{},optionalNamespaces:F,relays:[{protocol:"irn"}],pairingTopic:P,proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:xt(Rt.wc_sessionPropose.req.ttl),id:bi()},{done:q,resolve:$,reject:h}=Kn(L,"Request expired"),b=bi(),w=ye("session_connect",T.id),g=ye("session_request",b),v=async({error:x,session:f})=>{this.events.off(g,I),x?h(x):f&&$({session:f})},I=async x=>{var f,A,j;if(await this.deletePendingAuthRequest(b,{message:"fulfilled",code:0}),x.error){const Q=_e("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return x.error.code===Q.code?void 0:(this.events.off(w,v),h(x.error.message))}await this.deleteProposal(T.id),this.events.off(w,v);const{cacaos:z,responder:U}=x.result,k=[],Z=[];for(const Q of z){await Gb({cacao:Q,projectId:this.client.core.projectId})||(this.client.logger.error(Q,"Signature verification failed"),h(_e("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:re}=Q,Ze=wl(re.resources),oe=[_d(re.iss)],fe=yl(re.iss);if(Ze){const $t=Jb(Ze),xe=Qb(Ze);k.push(...$t),oe.push(...xe)}for(const $t of oe)Z.push(`${$t}:${fe}`)}const X=await this.client.core.crypto.generateSharedKey(M,U.publicKey);let ee;k.length>0&&(ee={topic:X,acknowledged:!0,self:{publicKey:M,metadata:this.client.metadata},peer:U,controller:U.publicKey,expiry:xt(ho),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:P,namespaces:Dm([...new Set(k)],[...new Set(Z)]),transportType:o},await this.client.core.relayer.subscribe(X,{transportType:o}),await this.client.session.set(X,ee),P&&await this.client.core.pairing.updateMetadata({topic:P,metadata:U.metadata}),ee=this.client.session.get(X)),(f=this.client.metadata.redirect)!=null&&f.linkMode&&(A=U.metadata.redirect)!=null&&A.linkMode&&(j=U.metadata.redirect)!=null&&j.universal&&i&&(this.client.core.addLinkModeSupportedApp(U.metadata.redirect.universal),this.client.session.update(X,{transportType:Re.link_mode})),$({auths:z,session:ee})};this.events.once(w,v),this.events.once(g,I);let O;try{if(s){const x=gn("wc_sessionAuthenticate",B,b);this.client.core.history.set(P,x);const f=await this.client.core.crypto.encode("",x,{type:$a,encoding:xa});O=Sl(i,P,f)}else await Promise.all([this.sendRequest({topic:P,method:"wc_sessionAuthenticate",params:B,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:b}),this.sendRequest({topic:P,method:"wc_sessionPropose",params:T,expiry:Rt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:T.id})])}catch(x){throw this.events.off(w,v),this.events.off(g,I),x}return await this.setProposal(T.id,T),await this.setAuthRequest(b,{request:hr(Ke({},B),{verifyContext:{}}),pairingTopic:P,transportType:o}),{uri:O??C,response:q}}),W(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[ts.authenticated_session_approve_started]}});try{this.isInitialized()}catch(S){throw s.setError(Ua.no_internet_connection),S}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ua.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||Re.relay;a===Re.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=$l(c),d={type:Ui,receiverPublicKey:c,senderPublicKey:l},p=[],y=[];for(const S of n){if(!await Gb({cacao:S,projectId:this.client.core.projectId})){s.setError(Ua.invalid_cacao);const R=_e("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:R,encodeOpts:d}),new Error(R.message)}s.addTrace(ts.cacaos_verified);const{p:E}=S,P=wl(E.resources),C=[_d(E.iss)],M=yl(E.iss);if(P){const R=Jb(P),L=Qb(P);p.push(...R),C.push(...L)}for(const R of C)y.push(`${R}:${M}`)}const m=await this.client.core.crypto.generateSharedKey(l,c);s.addTrace(ts.create_authenticated_session_topic);let _;if(p?.length>0){_={topic:m,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:xt(ho),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Dm([...new Set(p)],[...new Set(y)]),transportType:a},s.addTrace(ts.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(m,{transportType:a})}catch(S){throw s.setError(Ua.subscribe_authenticated_session_topic_failure),S}s.addTrace(ts.subscribe_authenticated_session_topic_success),await this.client.session.set(m,_),s.addTrace(ts.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(ts.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:n,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(S){throw s.setError(Ua.authenticated_session_approve_publish_failure),S}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:_}}),W(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===Re.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=$l(o),l={type:Ui,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:l,rpcOpts:Rt.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,_e("USER_DISCONNECTED"))}),W(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return Zb(i,n)}),W(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)}),W(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)}}),W(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,_e("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(Xv).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===n&&this.deletePendingSessionRequest(l.id,_e("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=xi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),W(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r),s=this.client.core.eventClient.getEvent({topic:n.pairingTopic});s?.setError(es.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,_e("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),W(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=xi.idle,this.client.events.emit("session_request_expire",{id:r}))}),W(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)])}),W(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}))}),W(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,xt(Rt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),W(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=Re.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})}),W(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||xt(Rt.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})}),W(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:d}=r,p=gn(n,s,c);let y;const m=!!u;try{const E=m?xa:pn;y=await this.client.core.crypto.encode(i,p,{encoding:E})}catch(E){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),E}let _;if(dM.includes(n)){const E=ji(JSON.stringify(p)),P=ji(y);_=await this.client.core.verify.register({id:P,decryptedId:E})}const S=Rt[n].req;if(S.attestation=_,o&&(S.ttl=o),a&&(S.id=a),this.client.core.history.set(i,p),m){const E=Sl(u,i,y);await global.Linking.openURL(E,this.client.name)}else{const E=Rt[n].req;o&&(E.ttl=o),a&&(E.id=a),E.tvf=hr(Ke({},d),{correlationId:p.id}),l?(E.internal=hr(Ke({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,y,E)):this.client.core.relayer.publish(i,y,E).catch(P=>this.client.logger.error(P))}return p.id}),W(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,l=Ll(i,s);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const m=d?xa:pn;u=await this.client.core.crypto.encode(n,l,hr(Ke({},a||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),m}let p,y;try{p=await this.client.core.history.get(n,i);const m=p.request;try{this.shouldSetTVF(m.method,m.params)&&(y=this.getTVFParams(i,m.params,s))}catch(_){this.client.logger.warn("sendResult() -> getTVFParams() failed",_)}}catch(m){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),m}if(d){const m=Sl(c,n,u);await global.Linking.openURL(m,this.client.name)}else{const m=p.request.method,_=Rt[m].res;_.tvf=hr(Ke({},y),{correlationId:i}),o?(_.internal=hr(Ke({},_.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,u,_)):this.client.core.relayer.publish(n,u,_).catch(S=>this.client.logger.error(S))}await this.client.core.history.resolve(l)}),W(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,l=Fl(i,s);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const y=d?xa:pn;u=await this.client.core.crypto.encode(n,l,hr(Ke({},o||{}),{encoding:y}))}catch(y){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),y}let p;try{p=await this.client.core.history.get(n,i)}catch(y){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),y}if(d){const y=Sl(c,n,u);await global.Linking.openURL(y,this.client.name)}else{const y=p.request.method,m=a||Rt[y].res;this.client.core.relayer.publish(n,u,m)}await this.client.core.history.resolve(l)}),W(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;un(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=>{un(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),W(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),W(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===xi.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=xi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=xi.idle}),W(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}`)}}),W(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}`)}}),W(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=K("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),W(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)}),W(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const l=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l?.setError(ki.proposal_listener_not_found)),this.isValidConnect(Ke({},n.params));const u=a.expiryTimestamp||xt(Rt.wc_sessionPropose.req.ttl),d=Ke({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,d);const p=await this.getVerifyContext({attestationId:s,hash:ji(JSON.stringify(n)),encryptedId:o,metadata:d.proposer.metadata});l?.addTrace(yi.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:p})}catch(l){await this.sendError({id:c,topic:i,error:l,rpcOpts:Rt.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),W(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(mi(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 l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(s,{sessionTopic:u,pairingTopic:r,proposalId:s,publicKey:c});const d=await this.client.core.relayer.subscribe(u,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:r})}else if(Cr(i)){await this.client.proposal.delete(s,_e("USER_DISCONNECTED"));const o=ye("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})}}),W(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,sessionConfig:d}=i.params,p=[...this.pendingSessions.values()].find(_=>_.sessionTopic===r);if(!p)return this.client.logger.error(`Pending session not found for topic ${r}`);const y=this.client.proposal.get(p.proposalId),m=hr(Ke(Ke({topic:r,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:y.requiredNamespaces,optionalNamespaces:y.optionalNamespaces,controller:a.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),d&&{sessionConfig:d}),{transportType:Re.relay});await this.client.session.set(m.topic,m),await this.setExpiry(m.topic,m.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:m.peer.metadata}),this.client.events.emit("session_connect",{session:m}),this.events.emit(ye("session_connect",p.proposalId),{session:m}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(m),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)}}),W(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;mi(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ye("session_approve",n),{})):Cr(i)&&(await this.client.session.delete(r,_e("USER_DISCONNECTED")),this.events.emit(ye("session_approve",n),{error:i.error}))}),W(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Ca.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:_e("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ke({topic:r},n));try{Ca.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 Ca.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)}}),W(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),W(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=ye("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);mi(i)?this.events.emit(ye("session_update",n),{}):Cr(i)&&this.events.emit(ye("session_update",n),{error:i.error})}),W(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,xt(ho)),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)}}),W(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=ye("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);mi(i)?this.events.emit(ye("session_extend",n),{}):Cr(i)&&this.events.emit(ye("session_extend",n),{error:i.error})}),W(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)}}),W(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=ye("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{mi(i)?this.events.emit(ye("session_ping",n),{}):Cr(i)&&this.events.emit(ye("session_ping",n),{error:i.error})},500)}),W(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(Mt.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:_e("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),W(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=r,{id:d,params:p}=a;try{await this.isValidRequest(Ke({topic:o},p));const y=this.client.session.get(o),m=await this.getVerifyContext({attestationId:c,hash:ji(JSON.stringify(gn("wc_sessionRequest",p,d))),encryptedId:l,metadata:y.peer.metadata,transportType:u}),_={id:d,topic:o,params:p,verifyContext:m};await this.setPendingSessionRequest(_),u===Re.link_mode&&(i=y.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=y.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(_):(this.addSessionRequestToSessionRequestQueue(_),this.processSessionRequestQueue())}catch(y){await this.sendError({id:d,topic:o,error:y}),this.client.logger.error(y)}}),W(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=ye("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);mi(i)?this.events.emit(ye("session_request",n),{result:i.result}):Cr(i)&&this.events.emit(ye("session_request",n),{error:i.error})}),W(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Ca.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(Ke({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Ca.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),W(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),mi(i)?this.events.emit(ye("session_request",n),{result:i.result}):Cr(i)&&this.events.emit(ye("session_request",n),{error:i.error})}),W(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:l,authPayload:u,expiryTimestamp:d}=s.params,p=await this.getVerifyContext({attestationId:o,hash:ji(JSON.stringify(s)),encryptedId:a,metadata:l.metadata,transportType:c}),y={requester:l,pairingTopic:n,id:s.id,authPayload:u,verifyContext:p,expiryTimestamp:d};await this.setAuthRequest(s.id,{request:y,pairingTopic:n,transportType:c}),c===Re.link_mode&&(i=l.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:p})}catch(l){this.client.logger.error(l);const u=s.params.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),p=this.getAppLinkIfEnabled(s.params.requester.metadata,c),y={type:Ui,receiverPublicKey:u,senderPublicKey:d};await this.sendError({id:s.id,topic:n,error:l,encodeOpts:y,rpcOpts:Rt.wc_sessionAuthenticate.autoReject,appLink:p})}}),W(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),W(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=xi.idle,this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay))}),W(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=ye("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(ye("session_request",s.request.id),{error:i})})}),W(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===xi.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=xi.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),W(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),W(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:gn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),W(this,"isValidConnect",async r=>{if(!ar(r)){const{message:c}=K("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(er(i)||await this.isValidPairingTopic(i),!$S(a,!0)){const{message:c}=K("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!er(n)&&Oa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!er(s)&&Oa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),er(o)||this.validateSessionProps(o,"sessionProperties")}),W(this,"validateNamespaces",(r,i)=>{const n=ES(r,"connect()",i);if(n)throw new Error(n.message)}),W(this,"isValidApprove",async r=>{if(!ar(r))throw new Error(K("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=Ld(n,"approve()");if(c)throw new Error(c.message);const l=Bm(a.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!mt(s,!0)){const{message:u}=K("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(u)}er(o)||this.validateSessionProps(o,"sessionProperties")}),W(this,"isValidReject",async r=>{if(!ar(r)){const{message:s}=K("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!SS(n)){const{message:s}=K("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),W(this,"isValidSessionSettleRequest",r=>{if(!ar(r)){const{message:l}=K("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Rm(i)){const{message:l}=K("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=mS(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Ld(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(un(o)){const{message:l}=K("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),W(this,"isValidUpdate",async r=>{if(!ar(r)){const{message:c}=K("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=Ld(n,"update()");if(o)throw new Error(o.message);const a=Bm(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),W(this,"isValidExtend",async r=>{if(!ar(r)){const{message:n}=K("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),W(this,"isValidRequest",async r=>{if(!ar(r)){const{message:c}=K("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(!Nm(a,s)){const{message:c}=K("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!AS(n)){const{message:c}=K("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!CS(a,s,n.method)){const{message:c}=K("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!RS(o,pf)){const{message:c}=K("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${pf.min} and ${pf.max}`);throw new Error(c)}}),W(this,"isValidRespond",async r=>{var i;if(!ar(r)){const{message:o}=K("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(!PS(s)){const{message:o}=K("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),W(this,"isValidPing",async r=>{if(!ar(r)){const{message:n}=K("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),W(this,"isValidEmit",async r=>{if(!ar(r)){const{message:a}=K("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(!Nm(o,s)){const{message:a}=K("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!OS(n)){const{message:a}=K("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!DS(o,s,n.name)){const{message:a}=K("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),W(this,"isValidDisconnect",async r=>{if(!ar(r)){const{message:n}=K("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),W(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(!mt(n,!1))throw new Error("uri is required parameter");if(!mt(s,!1))throw new Error("domain is required parameter");if(!mt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Xs(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Xs(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),W(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Fa,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Re.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),W(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach(n=>{if(!mt(n,!1)){const{message:s}=K("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})}),W(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),W(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)}}}),W(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=K("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),W(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,l,u,d,p;return!r||i!==Re.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&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=r?.redirect)==null?void 0:u.universal)!==void 0&&((d=r?.redirect)==null?void 0:d.universal)!==""&&((p=r?.redirect)==null?void 0:p.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),W(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),W(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=Mb(r,"topic")||"",n=decodeURIComponent(Mb(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Re.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),W(this,"registerLinkModeListeners",async()=>{var r;if(gd()||cn()&&(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)}}}),W(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(t2).includes(n.method)}),W(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return hr(Ke({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{}}),W(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}),W(this,"extractTxHashesFromResult",(r,i)=>{try{const n=t2[r];if(typeof i=="string")return[i];const s=i[n.key];if(fi(s))return s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=K("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Mt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Hl)?this.client.auth.authKeys.get(Hl):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===Re.link_mode?xa:pn});try{Yd(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:ji(i)})):Ul(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)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(Tr.expired,async e=>{const{topic:r,id:i}=Db(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,K("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,K("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(Xn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Xn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:r}=K("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}=K("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(un(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=K("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:r}=K("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}=K("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(un(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=K("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=K("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(mt(e,!1)){const{message:r}=K("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=K("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!IS(e)){const{message:r}=K("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=K("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(un(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=K("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class $M extends rs{constructor(e,r){super(e,r,cM,df),this.core=e,this.logger=r}}class IM extends rs{constructor(e,r){super(e,r,lM,df),this.core=e,this.logger=r}}class SM extends rs{constructor(e,r){super(e,r,hM,df,i=>i.id),this.core=e,this.logger=r}}class AM extends rs{constructor(e,r){super(e,r,gM,kl,()=>Hl),this.core=e,this.logger=r}}class PM extends rs{constructor(e,r){super(e,r,bM,kl),this.core=e,this.logger=r}}class OM extends rs{constructor(e,r){super(e,r,mM,kl,i=>i.id),this.core=e,this.logger=r}}var CM=Object.defineProperty,DM=(t,e,r)=>e in t?CM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bf=(t,e,r)=>DM(t,typeof e!="symbol"?e+"":e,r);class MM{constructor(e,r){this.core=e,this.logger=r,bf(this,"authKeys"),bf(this,"pairingTopics"),bf(this,"requests"),this.authKeys=new AM(this.core,this.logger),this.pairingTopics=new PM(this.core,this.logger),this.requests=new OM(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var TM=Object.defineProperty,RM=(t,e,r)=>e in t?TM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ue=(t,e,r)=>RM(t,typeof e!="symbol"?e+"":e,r);class mf extends dP{constructor(e){super(e),ue(this,"protocol",Yv),ue(this,"version",Jv),ue(this,"name",ff.name),ue(this,"metadata"),ue(this,"core"),ue(this,"logger"),ue(this,"events",new Lt.exports.EventEmitter),ue(this,"engine"),ue(this,"session"),ue(this,"proposal"),ue(this,"pendingRequest"),ue(this,"auth"),ue(this,"signConfig"),ue(this,"on",(i,n)=>this.events.on(i,n)),ue(this,"once",(i,n)=>this.events.once(i,n)),ue(this,"off",(i,n)=>this.events.off(i,n)),ue(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),ue(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),ue(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),ue(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),ue(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),ue(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||ff.name,this.metadata=e?.metadata||Sb(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:pi(Bl({level:e?.logger||ff.logger}));this.core=e?.core||new aM(e),this.logger=tr(r,this.name),this.session=new IM(this.core,this.logger),this.proposal=new $M(this.core,this.logger),this.pendingRequest=new SM(this.core,this.logger),this.engine=new EM(this),this.auth=new MM(this.core,this.logger)}static async init(e){const r=new mf(e);return await r.initialize(),r}get context(){return lr(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()},V.toMiliseconds(V.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var vf={exports:{}};(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof wt<"u"&&wt,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 wt<"u"&&wt||{},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 l(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(g){return g&&u.indexOf(Object.prototype.toString.call(g))>-1};function p(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 y(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var v={next:function(){var I=g.shift();return{done:I===void 0,value:I}}};return c.iterable&&(v[Symbol.iterator]=function(){return v}),v}function _(g){this.map={},g instanceof _?g.forEach(function(v,I){this.append(I,v)},this):Array.isArray(g)?g.forEach(function(v){if(v.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+v.length);this.append(v[0],v[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(v){this.append(v,g[v])},this)}_.prototype.append=function(g,v){g=p(g),v=y(v);var I=this.map[g];this.map[g]=I?I+", "+v:v},_.prototype.delete=function(g){delete this.map[p(g)]},_.prototype.get=function(g){return g=p(g),this.has(g)?this.map[g]:null},_.prototype.has=function(g){return this.map.hasOwnProperty(p(g))},_.prototype.set=function(g,v){this.map[p(g)]=y(v)},_.prototype.forEach=function(g,v){for(var I in this.map)this.map.hasOwnProperty(I)&&g.call(v,this.map[I],I,this)},_.prototype.keys=function(){var g=[];return this.forEach(function(v,I){g.push(I)}),m(g)},_.prototype.values=function(){var g=[];return this.forEach(function(v){g.push(v)}),m(g)},_.prototype.entries=function(){var g=[];return this.forEach(function(v,I){g.push([I,v])}),m(g)},c.iterable&&(_.prototype[Symbol.iterator]=_.prototype.entries);function S(g){if(!g._noBody){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}}function E(g){return new Promise(function(v,I){g.onload=function(){v(g.result)},g.onerror=function(){I(g.error)}})}function P(g){var v=new FileReader,I=E(v);return v.readAsArrayBuffer(g),I}function C(g){var v=new FileReader,I=E(v),O=/charset=([A-Za-z0-9_-]+)/.exec(g.type),x=O?O[1]:"utf-8";return v.readAsText(g,x),I}function M(g){for(var v=new Uint8Array(g),I=new Array(v.length),O=0;O<v.length;O++)I[O]=String.fromCharCode(v[O]);return I.join("")}function R(g){if(g.slice)return g.slice(0);var v=new Uint8Array(g.byteLength);return v.set(new Uint8Array(g)),v.buffer}function L(){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&&l(g)?(this._bodyArrayBuffer=R(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||d(g))?this._bodyArrayBuffer=R(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=S(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=S(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(P);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var g=S(this);if(g)return g;if(this._bodyBlob)return C(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(M(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 B=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function F(g){var v=g.toUpperCase();return B.indexOf(v)>-1?v:g}function T(g,v){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');v=v||{};var I=v.body;if(g instanceof T){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,v.headers||(this.headers=new _(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!I&&g._bodyInit!=null&&(I=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new _(v.headers)),this.method=F(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal||function(){if("AbortController"in a){var f=new AbortController;return f.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&I)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(I),(this.method==="GET"||this.method==="HEAD")&&(v.cache==="no-store"||v.cache==="no-cache")){var O=/([?&])_=[^&]*/;if(O.test(this.url))this.url=this.url.replace(O,"$1_="+new Date().getTime());else{var x=/\?/;this.url+=(x.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})};function q(g){var v=new FormData;return g.trim().split("&").forEach(function(I){if(I){var O=I.split("="),x=O.shift().replace(/\+/g," "),f=O.join("=").replace(/\+/g," ");v.append(decodeURIComponent(x),decodeURIComponent(f))}}),v}function $(g){var v=new _,I=g.replace(/\r?\n[\t ]+/g," ");return I.split("\r").map(function(O){return O.indexOf(`
|
|
40
|
+
`)===0?O.substr(1,O.length):O}).forEach(function(O){var x=O.split(":"),f=x.shift().trim();if(f){var A=x.join(":").trim();try{v.append(f,A)}catch(j){console.warn("Response "+j.message)}}}),v}L.call(T.prototype);function h(g,v){if(!(this instanceof h))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(v||(v={}),this.type="default",this.status=v.status===void 0?200:v.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=v.statusText===void 0?"":""+v.statusText,this.headers=new _(v.headers),this.url=v.url||"",this._initBody(g)}L.call(h.prototype),h.prototype.clone=function(){return new h(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new _(this.headers),url:this.url})},h.error=function(){var g=new h(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var b=[301,302,303,307,308];h.redirect=function(g,v){if(b.indexOf(v)===-1)throw new RangeError("Invalid status code");return new h(null,{status:v,headers:{location:g}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(v,I){this.message=v,this.name=I;var O=Error(v);this.stack=O.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function w(g,v){return new Promise(function(I,O){var x=new T(g,v);if(x.signal&&x.signal.aborted)return O(new o.DOMException("Aborted","AbortError"));var f=new XMLHttpRequest;function A(){f.abort()}f.onload=function(){var U={statusText:f.statusText,headers:$(f.getAllResponseHeaders()||"")};x.url.indexOf("file://")===0&&(f.status<200||f.status>599)?U.status=200:U.status=f.status,U.url="responseURL"in f?f.responseURL:U.headers.get("X-Request-URL");var k="response"in f?f.response:f.responseText;setTimeout(function(){I(new h(k,U))},0)},f.onerror=function(){setTimeout(function(){O(new TypeError("Network request failed"))},0)},f.ontimeout=function(){setTimeout(function(){O(new TypeError("Network request timed out"))},0)},f.onabort=function(){setTimeout(function(){O(new o.DOMException("Aborted","AbortError"))},0)};function j(U){try{return U===""&&a.location.href?a.location.href:U}catch{return U}}if(f.open(x.method,j(x.url),!0),x.credentials==="include"?f.withCredentials=!0:x.credentials==="omit"&&(f.withCredentials=!1),"responseType"in f&&(c.blob?f.responseType="blob":c.arrayBuffer&&(f.responseType="arraybuffer")),v&&typeof v.headers=="object"&&!(v.headers instanceof _||a.Headers&&v.headers instanceof a.Headers)){var z=[];Object.getOwnPropertyNames(v.headers).forEach(function(U){z.push(p(U)),f.setRequestHeader(U,y(v.headers[U]))}),x.headers.forEach(function(U,k){z.indexOf(k)===-1&&f.setRequestHeader(k,U)})}else x.headers.forEach(function(U,k){f.setRequestHeader(k,U)});x.signal&&(x.signal.addEventListener("abort",A),f.onreadystatechange=function(){f.readyState===4&&x.signal.removeEventListener("abort",A)}),f.send(typeof x._bodyInit>"u"?null:x._bodyInit)})}return w.polyfill=!0,a.fetch||(a.fetch=w,a.Headers=_,a.Request=T,a.Response=h),o.Headers=_,o.Request=T,o.Response=h,o.fetch=w,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})(vf,vf.exports);var i2=kw(vf.exports),NM=Object.defineProperty,BM=Object.defineProperties,LM=Object.getOwnPropertyDescriptors,n2=Object.getOwnPropertySymbols,FM=Object.prototype.hasOwnProperty,UM=Object.prototype.propertyIsEnumerable,s2=(t,e,r)=>e in t?NM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,o2=(t,e)=>{for(var r in e||(e={}))FM.call(e,r)&&s2(t,r,e[r]);if(n2)for(var r of n2(e))UM.call(e,r)&&s2(t,r,e[r]);return t},a2=(t,e)=>BM(t,LM(e));const jM={Accept:"application/json","Content-Type":"application/json"},qM="POST",c2={headers:jM,method:qM},l2=10;class Zr{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new Lt.exports.EventEmitter,this.isAvailable=!1,this.registering=!1,!lv(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=Mi(e),i=await(await i2(this.url,a2(o2({},c2),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!lv(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=Mi({id:1,jsonrpc:"2.0",method:"test",params:[]});await i2(e,a2(o2({},c2),{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"?Fn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Fl(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return iv(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>l2&&this.events.setMaxListeners(l2)}}const u2="error",zM="wss://relay.walletconnect.org",kM="wc",HM="universal_provider",h2=`${kM}@2:${HM}:`,d2="https://rpc.walletconnect.org/v1/",fo="generic",WM=`${d2}bundler`,Rr={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Wl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function VM(){this.__data__=[],this.size=0}var KM=VM;function GM(t,e){return t===e||t!==t&&e!==e}var Vl=GM,ZM=Vl;function YM(t,e){for(var r=t.length;r--;)if(ZM(t[r][0],e))return r;return-1}var Kl=YM,JM=Kl,QM=Array.prototype,XM=QM.splice;function eT(t){var e=this.__data__,r=JM(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():XM.call(e,r,1),--this.size,!0}var tT=eT,rT=Kl;function iT(t){var e=this.__data__,r=rT(e,t);return r<0?void 0:e[r][1]}var nT=iT,sT=Kl;function oT(t){return sT(this.__data__,t)>-1}var aT=oT,cT=Kl;function lT(t,e){var r=this.__data__,i=cT(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var uT=lT,hT=KM,dT=tT,fT=nT,pT=aT,gT=uT;function po(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}po.prototype.clear=hT,po.prototype.delete=dT,po.prototype.get=fT,po.prototype.has=pT,po.prototype.set=gT;var Gl=po,bT=Gl;function mT(){this.__data__=new bT,this.size=0}var vT=mT;function yT(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var wT=yT;function _T(t){return this.__data__.get(t)}var xT=_T;function ET(t){return this.__data__.has(t)}var $T=ET,IT=typeof Wl=="object"&&Wl&&Wl.Object===Object&&Wl,f2=IT,ST=f2,AT=typeof self=="object"&&self&&self.Object===Object&&self,PT=ST||AT||Function("return this")(),go=PT,OT=go,CT=OT.Symbol,p2=CT,g2=p2,b2=Object.prototype,DT=b2.hasOwnProperty,MT=b2.toString,ka=g2?g2.toStringTag:void 0;function TT(t){var e=DT.call(t,ka),r=t[ka];try{t[ka]=void 0;var i=!0}catch{}var n=MT.call(t);return i&&(e?t[ka]=r:delete t[ka]),n}var RT=TT,NT=Object.prototype,BT=NT.toString;function LT(t){return BT.call(t)}var FT=LT,m2=p2,UT=RT,jT=FT,qT="[object Null]",zT="[object Undefined]",v2=m2?m2.toStringTag:void 0;function kT(t){return t==null?t===void 0?zT:qT:v2&&v2 in Object(t)?UT(t):jT(t)}var Zl=kT;function HT(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var is=HT,WT=Zl,VT=is,KT="[object AsyncFunction]",GT="[object Function]",ZT="[object GeneratorFunction]",YT="[object Proxy]";function JT(t){if(!VT(t))return!1;var e=WT(t);return e==GT||e==ZT||e==KT||e==YT}var yf=JT,QT=go,XT=QT["__core-js_shared__"],eR=XT,wf=eR,y2=function(){var t=/[^.]+$/.exec(wf&&wf.keys&&wf.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function tR(t){return!!y2&&y2 in t}var rR=tR,iR=Function.prototype,nR=iR.toString;function sR(t){if(t!=null){try{return nR.call(t)}catch{}try{return t+""}catch{}}return""}var oR=sR,aR=yf,cR=rR,lR=is,uR=oR,hR=/[\\^$.*+?()[\]{}|]/g,dR=/^\[object .+?Constructor\]$/,fR=Function.prototype,pR=Object.prototype,gR=fR.toString,bR=pR.hasOwnProperty,mR=RegExp("^"+gR.call(bR).replace(hR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vR(t){if(!lR(t)||cR(t))return!1;var e=aR(t)?mR:dR;return e.test(uR(t))}var yR=vR;function wR(t,e){return t?.[e]}var _R=wR,xR=yR,ER=_R;function $R(t,e){var r=ER(t,e);return xR(r)?r:void 0}var _f=$R,IR=_f,SR=go,AR=IR(SR,"Map"),w2=AR,PR=_f,OR=PR(Object,"create"),Yl=OR,_2=Yl;function CR(){this.__data__=_2?_2(null):{},this.size=0}var DR=CR;function MR(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var TR=MR,RR=Yl,NR="__lodash_hash_undefined__",BR=Object.prototype,LR=BR.hasOwnProperty;function FR(t){var e=this.__data__;if(RR){var r=e[t];return r===NR?void 0:r}return LR.call(e,t)?e[t]:void 0}var UR=FR,jR=Yl,qR=Object.prototype,zR=qR.hasOwnProperty;function kR(t){var e=this.__data__;return jR?e[t]!==void 0:zR.call(e,t)}var HR=kR,WR=Yl,VR="__lodash_hash_undefined__";function KR(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=WR&&e===void 0?VR:e,this}var GR=KR,ZR=DR,YR=TR,JR=UR,QR=HR,XR=GR;function bo(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}bo.prototype.clear=ZR,bo.prototype.delete=YR,bo.prototype.get=JR,bo.prototype.has=QR,bo.prototype.set=XR;var eN=bo,x2=eN,tN=Gl,rN=w2;function iN(){this.size=0,this.__data__={hash:new x2,map:new(rN||tN),string:new x2}}var nN=iN;function sN(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var oN=sN,aN=oN;function cN(t,e){var r=t.__data__;return aN(e)?r[typeof e=="string"?"string":"hash"]:r.map}var Jl=cN,lN=Jl;function uN(t){var e=lN(this,t).delete(t);return this.size-=e?1:0,e}var hN=uN,dN=Jl;function fN(t){return dN(this,t).get(t)}var pN=fN,gN=Jl;function bN(t){return gN(this,t).has(t)}var mN=bN,vN=Jl;function yN(t,e){var r=vN(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var wN=yN,_N=nN,xN=hN,EN=pN,$N=mN,IN=wN;function mo(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}mo.prototype.clear=_N,mo.prototype.delete=xN,mo.prototype.get=EN,mo.prototype.has=$N,mo.prototype.set=IN;var SN=mo,AN=Gl,PN=w2,ON=SN,CN=200;function DN(t,e){var r=this.__data__;if(r instanceof AN){var i=r.__data__;if(!PN||i.length<CN-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new ON(i)}return r.set(t,e),this.size=r.size,this}var MN=DN,TN=Gl,RN=vT,NN=wT,BN=xT,LN=$T,FN=MN;function vo(t){var e=this.__data__=new TN(t);this.size=e.size}vo.prototype.clear=RN,vo.prototype.delete=NN,vo.prototype.get=BN,vo.prototype.has=LN,vo.prototype.set=FN;var UN=vo,jN=_f,qN=function(){try{var t=jN(Object,"defineProperty");return t({},"",{}),t}catch{}}(),E2=qN,$2=E2;function zN(t,e,r){e=="__proto__"&&$2?$2(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xf=zN,kN=xf,HN=Vl;function WN(t,e,r){(r!==void 0&&!HN(t[e],r)||r===void 0&&!(e in t))&&kN(t,e,r)}var I2=WN;function VN(t){return function(e,r,i){for(var n=-1,s=Object(e),o=i(e),a=o.length;a--;){var c=o[t?a:++n];if(r(s[c],c,s)===!1)break}return e}}var KN=VN,GN=KN,ZN=GN(),YN=ZN,Ef={exports:{}};(function(t,e){var r=go,i=e&&!e.nodeType&&e,n=i&&!0&&t&&!t.nodeType&&t,s=n&&n.exports===i,o=s?r.Buffer:void 0,a=o?o.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var d=l.length,p=a?a(d):new l.constructor(d);return l.copy(p),p}t.exports=c})(Ef,Ef.exports);var JN=go,QN=JN.Uint8Array,XN=QN,S2=XN;function eB(t){var e=new t.constructor(t.byteLength);return new S2(e).set(new S2(t)),e}var tB=eB,rB=tB;function iB(t,e){var r=e?rB(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var nB=iB;function sB(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}var oB=sB,aB=is,A2=Object.create,cB=function(){function t(){}return function(e){if(!aB(e))return{};if(A2)return A2(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),lB=cB;function uB(t,e){return function(r){return t(e(r))}}var hB=uB,dB=hB,fB=dB(Object.getPrototypeOf,Object),P2=fB,pB=Object.prototype;function gB(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||pB;return t===r}var O2=gB,bB=lB,mB=P2,vB=O2;function yB(t){return typeof t.constructor=="function"&&!vB(t)?bB(mB(t)):{}}var wB=yB;function _B(t){return t!=null&&typeof t=="object"}var Ha=_B,xB=Zl,EB=Ha,$B="[object Arguments]";function IB(t){return EB(t)&&xB(t)==$B}var SB=IB,C2=SB,AB=Ha,D2=Object.prototype,PB=D2.hasOwnProperty,OB=D2.propertyIsEnumerable,CB=C2(function(){return arguments}())?C2:function(t){return AB(t)&&PB.call(t,"callee")&&!OB.call(t,"callee")},M2=CB,DB=Array.isArray,T2=DB,MB=9007199254740991;function TB(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=MB}var R2=TB,RB=yf,NB=R2;function BB(t){return t!=null&&NB(t.length)&&!RB(t)}var $f=BB,LB=$f,FB=Ha;function UB(t){return FB(t)&&LB(t)}var jB=UB,Ql={exports:{}};function qB(){return!1}var zB=qB;(function(t,e){var r=go,i=zB,n=e&&!e.nodeType&&e,s=n&&!0&&t&&!t.nodeType&&t,o=s&&s.exports===n,a=o?r.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||i;t.exports=l})(Ql,Ql.exports);var kB=Zl,HB=P2,WB=Ha,VB="[object Object]",KB=Function.prototype,GB=Object.prototype,N2=KB.toString,ZB=GB.hasOwnProperty,YB=N2.call(Object);function JB(t){if(!WB(t)||kB(t)!=VB)return!1;var e=HB(t);if(e===null)return!0;var r=ZB.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&N2.call(r)==YB}var QB=JB,XB=Zl,eL=R2,tL=Ha,rL="[object Arguments]",iL="[object Array]",nL="[object Boolean]",sL="[object Date]",oL="[object Error]",aL="[object Function]",cL="[object Map]",lL="[object Number]",uL="[object Object]",hL="[object RegExp]",dL="[object Set]",fL="[object String]",pL="[object WeakMap]",gL="[object ArrayBuffer]",bL="[object DataView]",mL="[object Float32Array]",vL="[object Float64Array]",yL="[object Int8Array]",wL="[object Int16Array]",_L="[object Int32Array]",xL="[object Uint8Array]",EL="[object Uint8ClampedArray]",$L="[object Uint16Array]",IL="[object Uint32Array]",Ne={};Ne[mL]=Ne[vL]=Ne[yL]=Ne[wL]=Ne[_L]=Ne[xL]=Ne[EL]=Ne[$L]=Ne[IL]=!0,Ne[rL]=Ne[iL]=Ne[gL]=Ne[nL]=Ne[bL]=Ne[sL]=Ne[oL]=Ne[aL]=Ne[cL]=Ne[lL]=Ne[uL]=Ne[hL]=Ne[dL]=Ne[fL]=Ne[pL]=!1;function SL(t){return tL(t)&&eL(t.length)&&!!Ne[XB(t)]}var AL=SL;function PL(t){return function(e){return t(e)}}var OL=PL,If={exports:{}};(function(t,e){var r=f2,i=e&&!e.nodeType&&e,n=i&&!0&&t&&!t.nodeType&&t,s=n&&n.exports===i,o=s&&r.process,a=function(){try{var c=n&&n.require&&n.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();t.exports=a})(If,If.exports);var CL=AL,DL=OL,B2=If.exports,L2=B2&&B2.isTypedArray,ML=L2?DL(L2):CL,F2=ML;function TL(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var U2=TL,RL=xf,NL=Vl,BL=Object.prototype,LL=BL.hasOwnProperty;function FL(t,e,r){var i=t[e];(!(LL.call(t,e)&&NL(i,r))||r===void 0&&!(e in t))&&RL(t,e,r)}var UL=FL,jL=UL,qL=xf;function zL(t,e,r,i){var n=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(r[a],t[a],a,r,t):void 0;c===void 0&&(c=t[a]),n?qL(r,a,c):jL(r,a,c)}return r}var kL=zL;function HL(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}var WL=HL,VL=9007199254740991,KL=/^(?:0|[1-9]\d*)$/;function GL(t,e){var r=typeof t;return e=e??VL,!!e&&(r=="number"||r!="symbol"&&KL.test(t))&&t>-1&&t%1==0&&t<e}var j2=GL,ZL=WL,YL=M2,JL=T2,QL=Ql.exports,XL=j2,eF=F2,tF=Object.prototype,rF=tF.hasOwnProperty;function iF(t,e){var r=JL(t),i=!r&&YL(t),n=!r&&!i&&QL(t),s=!r&&!i&&!n&&eF(t),o=r||i||n||s,a=o?ZL(t.length,String):[],c=a.length;for(var l in t)(e||rF.call(t,l))&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||XL(l,c)))&&a.push(l);return a}var nF=iF;function sF(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var oF=sF,aF=is,cF=O2,lF=oF,uF=Object.prototype,hF=uF.hasOwnProperty;function dF(t){if(!aF(t))return lF(t);var e=cF(t),r=[];for(var i in t)i=="constructor"&&(e||!hF.call(t,i))||r.push(i);return r}var fF=dF,pF=nF,gF=fF,bF=$f;function mF(t){return bF(t)?pF(t,!0):gF(t)}var q2=mF,vF=kL,yF=q2;function wF(t){return vF(t,yF(t))}var _F=wF,z2=I2,xF=Ef.exports,EF=nB,$F=oB,IF=wB,k2=M2,H2=T2,SF=jB,AF=Ql.exports,PF=yf,OF=is,CF=QB,DF=F2,W2=U2,MF=_F;function TF(t,e,r,i,n,s,o){var a=W2(t,r),c=W2(e,r),l=o.get(c);if(l){z2(t,r,l);return}var u=s?s(a,c,r+"",t,e,o):void 0,d=u===void 0;if(d){var p=H2(c),y=!p&&AF(c),m=!p&&!y&&DF(c);u=c,p||y||m?H2(a)?u=a:SF(a)?u=$F(a):y?(d=!1,u=xF(c,!0)):m?(d=!1,u=EF(c,!0)):u=[]:CF(c)||k2(c)?(u=a,k2(a)?u=MF(a):(!OF(a)||PF(a))&&(u=IF(c))):d=!1}d&&(o.set(c,u),n(u,c,i,s,o),o.delete(c)),z2(t,r,u)}var RF=TF,NF=UN,BF=I2,LF=YN,FF=RF,UF=is,jF=q2,qF=U2;function V2(t,e,r,i,n){t!==e&&LF(e,function(s,o){if(n||(n=new NF),UF(s))FF(t,e,o,r,V2,i,n);else{var a=i?i(qF(t,o),s,o+"",t,e,n):void 0;a===void 0&&(a=s),BF(t,o,a)}},jF)}var zF=V2;function kF(t){return t}var K2=kF;function HF(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var WF=HF,VF=WF,G2=Math.max;function KF(t,e,r){return e=G2(e===void 0?t.length-1:e,0),function(){for(var i=arguments,n=-1,s=G2(i.length-e,0),o=Array(s);++n<s;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=r(o),VF(t,this,a)}}var GF=KF;function ZF(t){return function(){return t}}var YF=ZF,JF=YF,Z2=E2,QF=K2,XF=Z2?function(t,e){return Z2(t,"toString",{configurable:!0,enumerable:!1,value:JF(e),writable:!0})}:QF,eU=XF,tU=800,rU=16,iU=Date.now;function nU(t){var e=0,r=0;return function(){var i=iU(),n=rU-(i-r);if(r=i,n>0){if(++e>=tU)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var sU=nU,oU=eU,aU=sU,cU=aU(oU),lU=cU,uU=K2,hU=GF,dU=lU;function fU(t,e){return dU(hU(t,e,uU),t+"")}var pU=fU,gU=Vl,bU=$f,mU=j2,vU=is;function yU(t,e,r){if(!vU(r))return!1;var i=typeof e;return(i=="number"?bU(r)&&mU(e,r.length):i=="string"&&e in r)?gU(r[e],t):!1}var wU=yU,_U=pU,xU=wU;function EU(t){return _U(function(e,r){var i=-1,n=r.length,s=n>1?r[n-1]:void 0,o=n>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(n--,s):void 0,o&&xU(r[0],r[1],o)&&(s=n<3?void 0:s,n=1),e=Object(e);++i<n;){var a=r[i];a&&t(e,a,i,s)}return e})}var $U=EU,IU=zF,SU=$U,AU=SU(function(t,e,r){IU(t,e,r)}),PU=AU,OU=Object.defineProperty,CU=Object.defineProperties,DU=Object.getOwnPropertyDescriptors,Y2=Object.getOwnPropertySymbols,MU=Object.prototype.hasOwnProperty,TU=Object.prototype.propertyIsEnumerable,J2=(t,e,r)=>e in t?OU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xl=(t,e)=>{for(var r in e||(e={}))MU.call(e,r)&&J2(t,r,e[r]);if(Y2)for(var r of Y2(e))TU.call(e,r)&&J2(t,r,e[r]);return t},RU=(t,e)=>CU(t,DU(e));function yr(t,e,r){var i;const n=Xs(t);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${d2}?chainId=${n.namespace}:${n.reference}&projectId=${r}`}function ns(t){return t.includes(":")?t.split(":")[1]:t}function Q2(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function NU(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 Sf(t={},e={}){const r=X2(t),i=X2(e);return PU(r,i)}function X2(t){var e,r,i,n;const s={};if(!Oa(t))return s;for(const[o,a]of Object.entries(t)){const c=Nd(o)?[o]:a.chains,l=a.methods||[],u=a.events||[],d=a.rpcMap||{},p=Pa(o);s[p]=RU(Xl(Xl({},s[p]),a),{chains:bl(c,(e=s[p])==null?void 0:e.chains),methods:bl(l,(r=s[p])==null?void 0:r.methods),events:bl(u,(i=s[p])==null?void 0:i.events),rpcMap:Xl(Xl({},d),(n=s[p])==null?void 0:n.rpcMap)})}return s}function BU(t){return t.includes(":")?t.split(":")[2]:t}function ey(t){const e={};for(const[r,i]of Object.entries(t)){const n=i.methods||[],s=i.events||[],o=i.accounts||[],a=Nd(r)?[r]:i.chains?i.chains:Q2(i.accounts);e[r]={chains:a,methods:n,events:s,accounts:o}}return e}function Af(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 ty={},me=t=>ty[t],Pf=(t,e)=>{ty[t]=e};var LU=Object.defineProperty,FU=(t,e,r)=>e in t?LU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yo=(t,e,r)=>FU(t,typeof e!="symbol"?e+"":e,r);class UU{constructor(e){yo(this,"name","polkadot"),yo(this,"client"),yo(this,"httpProviders"),yo(this,"events"),yo(this,"namespace"),yo(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var jU=Object.defineProperty,qU=Object.defineProperties,zU=Object.getOwnPropertyDescriptors,ry=Object.getOwnPropertySymbols,kU=Object.prototype.hasOwnProperty,HU=Object.prototype.propertyIsEnumerable,Of=(t,e,r)=>e in t?jU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iy=(t,e)=>{for(var r in e||(e={}))kU.call(e,r)&&Of(t,r,e[r]);if(ry)for(var r of ry(e))HU.call(e,r)&&Of(t,r,e[r]);return t},ny=(t,e)=>qU(t,zU(e)),wo=(t,e,r)=>Of(t,typeof e!="symbol"?e+"":e,r);class WU{constructor(e){wo(this,"name","eip155"),wo(this,"client"),wo(this,"chainId"),wo(this,"namespace"),wo(this,"httpProviders"),wo(this,"events"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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||yr(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("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(ns(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;const s=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((n=o?.sessionProperties)==null?void 0:n.capabilities)||{};if(a!=null&&a[s])return a?.[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:ny(iy({},o.sessionProperties||{}),{capabilities:ny(iy({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}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(gn("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`${WM}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var VU=Object.defineProperty,KU=(t,e,r)=>e in t?VU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_o=(t,e,r)=>KU(t,typeof e!="symbol"?e+"":e,r);class GU{constructor(e){_o(this,"name","solana"),_o(this,"client"),_o(this,"httpProviders"),_o(this,"events"),_o(this,"namespace"),_o(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var ZU=Object.defineProperty,YU=(t,e,r)=>e in t?ZU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xo=(t,e,r)=>YU(t,typeof e!="symbol"?e+"":e,r);class JU{constructor(e){xo(this,"name","cosmos"),xo(this,"client"),xo(this,"httpProviders"),xo(this,"events"),xo(this,"namespace"),xo(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var QU=Object.defineProperty,XU=(t,e,r)=>e in t?QU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Eo=(t,e,r)=>XU(t,typeof e!="symbol"?e+"":e,r);class ej{constructor(e){Eo(this,"name","algorand"),Eo(this,"client"),Eo(this,"httpProviders"),Eo(this,"events"),Eo(this,"namespace"),Eo(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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||yr(`${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(Rr.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||yr(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new Dr(new Zr(i,me("disableProviderPing")))}}var tj=Object.defineProperty,rj=(t,e,r)=>e in t?tj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$o=(t,e,r)=>rj(t,typeof e!="symbol"?e+"":e,r);class ij{constructor(e){$o(this,"name","cip34"),$o(this,"client"),$o(this,"httpProviders"),$o(this,"events"),$o(this,"namespace"),$o(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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 Dr(new Zr(i,me("disableProviderPing")))}}var nj=Object.defineProperty,sj=(t,e,r)=>e in t?nj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Io=(t,e,r)=>sj(t,typeof e!="symbol"?e+"":e,r);class oj{constructor(e){Io(this,"name","elrond"),Io(this,"client"),Io(this,"httpProviders"),Io(this,"events"),Io(this,"namespace"),Io(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var aj=Object.defineProperty,cj=(t,e,r)=>e in t?aj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,So=(t,e,r)=>cj(t,typeof e!="symbol"?e+"":e,r);class lj{constructor(e){So(this,"name","multiversx"),So(this,"client"),So(this,"httpProviders"),So(this,"events"),So(this,"namespace"),So(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=ns(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var uj=Object.defineProperty,hj=(t,e,r)=>e in t?uj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ao=(t,e,r)=>hj(t,typeof e!="symbol"?e+"":e,r);class dj{constructor(e){Ao(this,"name","near"),Ao(this,"client"),Ao(this,"httpProviders"),Ao(this,"events"),Ao(this,"namespace"),Ao(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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||yr(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Rr.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||yr(e,this.namespace);return typeof i>"u"?void 0:new Dr(new Zr(i,me("disableProviderPing")))}}var fj=Object.defineProperty,pj=(t,e,r)=>e in t?fj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Po=(t,e,r)=>pj(t,typeof e!="symbol"?e+"":e,r);class gj{constructor(e){Po(this,"name","tezos"),Po(this,"client"),Po(this,"httpProviders"),Po(this,"events"),Po(this,"namespace"),Po(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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||yr(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Rr.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||yr(e,this.namespace);return typeof i>"u"?void 0:new Dr(new Zr(i))}}var bj=Object.defineProperty,mj=(t,e,r)=>e in t?bj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Oo=(t,e,r)=>mj(t,typeof e!="symbol"?e+"":e,r);class vj{constructor(e){Oo(this,"name",fo),Oo(this,"client"),Oo(this,"httpProviders"),Oo(this,"events"),Oo(this,"namespace"),Oo(this,"chainId"),this.namespace=e.namespace,this.events=me("events"),this.client=me("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(Rr.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=Xs(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||yr(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Zr(i,me("disableProviderPing")))}}var yj=Object.defineProperty,wj=Object.defineProperties,_j=Object.getOwnPropertyDescriptors,sy=Object.getOwnPropertySymbols,xj=Object.prototype.hasOwnProperty,Ej=Object.prototype.propertyIsEnumerable,Cf=(t,e,r)=>e in t?yj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eu=(t,e)=>{for(var r in e||(e={}))xj.call(e,r)&&Cf(t,r,e[r]);if(sy)for(var r of sy(e))Ej.call(e,r)&&Cf(t,r,e[r]);return t},Df=(t,e)=>wj(t,_j(e)),Yr=(t,e,r)=>Cf(t,typeof e!="symbol"?e+"":e,r);class Mf{constructor(e){Yr(this,"client"),Yr(this,"namespaces"),Yr(this,"optionalNamespaces"),Yr(this,"sessionProperties"),Yr(this,"events",new Lt.exports),Yr(this,"rpcProviders",{}),Yr(this,"session"),Yr(this,"providerOpts"),Yr(this,"logger"),Yr(this,"uri"),Yr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:pi(Bl({level:e?.logger||u2})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new Mf(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:eu({},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,Ll(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}),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:_e("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=ey(this.session.namespaces);this.namespaces=Sf(this.namespaces,o),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});r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();this.session=n;const s=ey(n.namespaces);return this.namespaces=Sf(this.namespaces,s),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,n]=this.validateChain(e),s=this.getProvider(i);s.name===fo?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(fi(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(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await mf.init({core:this.providerOpts.core,logger:this.providerOpts.logger||u2,relayUrl:this.providerOpts.relayUrl||zM,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>Pa(r)))];Pf("client",this.client),Pf("events",this.events),Pf("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=NU(r,this.session),n=Q2(i),s=Sf(this.namespaces,this.optionalNamespaces),o=Df(eu({},s[r]),{accounts:i,chains:n});switch(r){case"eip155":this.rpcProviders[r]=new WU({namespace:o});break;case"algorand":this.rpcProviders[r]=new ej({namespace:o});break;case"solana":this.rpcProviders[r]=new GU({namespace:o});break;case"cosmos":this.rpcProviders[r]=new JU({namespace:o});break;case"polkadot":this.rpcProviders[r]=new UU({namespace:o});break;case"cip34":this.rpcProviders[r]=new ij({namespace:o});break;case"elrond":this.rpcProviders[r]=new oj({namespace:o});break;case"multiversx":this.rpcProviders[r]=new lj({namespace:o});break;case"near":this.rpcProviders[r]=new dj({namespace:o});break;case"tezos":this.rpcProviders[r]=new gj({namespace:o});break;default:this.rpcProviders[fo]?this.rpcProviders[fo].updateNamespace(o):this.rpcProviders[fo]=new vj({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:i}=r;if(i.name==="accountsChanged"){const n=i.data;n&&fi(n)&&this.events.emit("accountsChanged",n.map(BU))}else if(i.name==="chainChanged"){const n=r.chainId,s=r.event.data,o=Pa(n),a=Af(n)!==Af(s)?`${o}:${Af(s)}`:n;this.onChainChanged(a)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i;const{namespaces:n}=r,s=(i=this.client)==null?void 0:i.session.get(e);this.session=Df(eu({},s),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Df(eu({},_e("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Rr.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[fo]}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}=e;r&&Object.keys(r).length&&(this.namespaces=r),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",r),this.persist("optionalNamespaces",i)}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=>Pa(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=Pa(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()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(r||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${h2}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${h2}/${e}`)}}const $j=Mf,Ij="wc",Sj="ethereum_provider",Aj=`${Ij}@2:${Sj}:`,Pj="https://rpc.walletconnect.org/v1/",tu=["eth_sendTransaction","personal_sign"],oy=["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"],ru=["chainChanged","accountsChanged"],ay=["chainChanged","accountsChanged","message","disconnect","connect"];var Oj=Object.defineProperty,Cj=Object.defineProperties,Dj=Object.getOwnPropertyDescriptors,cy=Object.getOwnPropertySymbols,Mj=Object.prototype.hasOwnProperty,Tj=Object.prototype.propertyIsEnumerable,Tf=(t,e,r)=>e in t?Oj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Co=(t,e)=>{for(var r in e||(e={}))Mj.call(e,r)&&Tf(t,r,e[r]);if(cy)for(var r of cy(e))Tj.call(e,r)&&Tf(t,r,e[r]);return t},Rf=(t,e)=>Cj(t,Dj(e)),wr=(t,e,r)=>Tf(t,typeof e!="symbol"?e+"":e,r);function iu(t){return Number(t[0].split(":")[1])}function nu(t){return`0x${t.toString(16)}`}function Rj(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=t;if(!fi(e))throw new Error("Invalid chains");const c={chains:e,methods:i||tu,events:s||ru,rpcMap:Co({},e.length?{[iu(e)]:a[iu(e)]}:{})},l=s?.filter(y=>!ru.includes(y)),u=i?.filter(y=>!tu.includes(y));if(!r&&!o&&!n&&!(l!=null&&l.length)&&!(u!=null&&u.length))return{required:e.length?c:void 0};const d=l?.length&&u?.length||!r,p={chains:[...new Set(d?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(n!=null&&n.length?n:oy))],events:[...new Set(c.events.concat(o!=null&&o.length?o:ay))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?p:void 0}}class su{constructor(){wr(this,"events",new Lt.exports.EventEmitter),wr(this,"namespace","eip155"),wr(this,"accounts",[]),wr(this,"signer"),wr(this,"chainId",1),wr(this,"modal"),wr(this,"rpc"),wr(this,"STORAGE_KEY",Aj),wr(this,"on",(e,r)=>(this.events.on(e,r),this)),wr(this,"once",(e,r)=>(this.events.once(e,r),this)),wr(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),wr(this,"off",(e,r)=>(this.events.off(e,r),this)),wr(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new su;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){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:i}=Rj(this.rpc);try{const n=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Rf(Co({namespaces:Co({},r&&{[this.namespace]:r})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e?.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!n)return;const s=Eb(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:nu(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{const i=await new Promise(async(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Rf(Co({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),n=i.session;if(n){const s=Eb(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:nu(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}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("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",nu(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",Rf(Co({},_e("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,i;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(i=this.modal)==null||i.openModal({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",nu(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||tu:[],c=n.length?e?.events||ru:[],l=e?.optionalMethods||[],u=e?.optionalEvents||[],d=e?.rpcMap||this.buildRpcMap(o,e.projectId),p=e?.qrModalOptions||void 0;return{chains:n?.map(y=>this.formatChainId(y)),optionalChains:s.map(y=>this.formatChainId(y)),methods:a,events:c,optionalMethods:l,optionalEvents:u,rpcMap:d,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:p,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?iu(this.rpc.chains):iu(this.rpc.optionalChains),this.signer=await $j.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{WalletConnectModal:i}=await Promise.resolve().then(function(){return iq});r=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Co({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}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&&fi(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)})),i&&fi(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])||`${Pj}?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 Nj=su,Bj=Symbol(),ly=Object.getPrototypeOf,Nf=new WeakMap,Lj=t=>t&&(Nf.has(t)?Nf.get(t):ly(t)===Object.prototype||ly(t)===Array.prototype),Fj=t=>Lj(t)&&t[Bj]||null,uy=(t,e=!0)=>{Nf.set(t,e)},Bf=t=>typeof t=="object"&&t!==null,bn=new WeakMap,ou=new WeakSet,Uj=(t=Object.is,e=(l,u)=>new Proxy(l,u),r=l=>Bf(l)&&!ou.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),i=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},n=new WeakMap,s=(l,u,d=i)=>{const p=n.get(l);if(p?.[0]===u)return p[1];const y=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return uy(y,!0),n.set(l,[u,y]),Reflect.ownKeys(l).forEach(m=>{if(Object.getOwnPropertyDescriptor(y,m))return;const _=Reflect.get(l,m),S={value:_,enumerable:!0,configurable:!0};if(ou.has(_))uy(_,!1);else if(_ instanceof Promise)delete S.value,S.get=()=>d(_);else if(bn.has(_)){const[E,P]=bn.get(_);S.value=s(E,P(),d)}Object.defineProperty(y,m,S)}),Object.preventExtensions(y)},o=new WeakMap,a=[1,1],c=l=>{if(!Bf(l))throw new Error("object required");const u=o.get(l);if(u)return u;let d=a[0];const p=new Set,y=(T,q=++a[0])=>{d!==q&&(d=q,p.forEach($=>$(T,q)))};let m=a[1];const _=(T=++a[1])=>(m!==T&&!p.size&&(m=T,E.forEach(([q])=>{const $=q[1](T);$>d&&(d=$)})),d),S=T=>(q,$)=>{const h=[...q];h[1]=[T,...h[1]],y(h,$)},E=new Map,P=(T,q)=>{if(E.has(T))throw new Error("prop listener already exists");if(p.size){const $=q[3](S(T));E.set(T,[q,$])}else E.set(T,[q])},C=T=>{var q;const $=E.get(T);$&&(E.delete(T),(q=$[1])==null||q.call($))},M=T=>(p.add(T),p.size===1&&E.forEach(([$,h],b)=>{if(h)throw new Error("remove already exists");const w=$[3](S(b));E.set(b,[$,w])}),()=>{p.delete(T),p.size===0&&E.forEach(([$,h],b)=>{h&&(h(),E.set(b,[$]))})}),R=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),B=e(R,{deleteProperty(T,q){const $=Reflect.get(T,q);C(q);const h=Reflect.deleteProperty(T,q);return h&&y(["delete",[q],$]),h},set(T,q,$,h){const b=Reflect.has(T,q),w=Reflect.get(T,q,h);if(b&&(t(w,$)||o.has($)&&t(w,o.get($))))return!0;C(q),Bf($)&&($=Fj($)||$);let g=$;if($ instanceof Promise)$.then(v=>{$.status="fulfilled",$.value=v,y(["resolve",[q],v])}).catch(v=>{$.status="rejected",$.reason=v,y(["reject",[q],v])});else{!bn.has($)&&r($)&&(g=c($));const v=!ou.has(g)&&bn.get(g);v&&P(q,v)}return Reflect.set(T,q,g,h),y(["set",[q],$,w]),!0}});o.set(l,B);const F=[R,_,s,M];return bn.set(B,F),Reflect.ownKeys(l).forEach(T=>{const q=Object.getOwnPropertyDescriptor(l,T);"value"in q&&(B[T]=l[T],delete q.value,delete q.writable),Object.defineProperty(R,T,q)}),B})=>[c,bn,ou,t,e,r,i,n,s,o,a],[jj]=Uj();function mn(t={}){return jj(t)}function ss(t,e,r){const i=bn.get(t);i||console.warn("Please use proxy object");let n;const s=[],o=i[3];let a=!1;const l=o(u=>{if(s.push(u),r){e(s.splice(0));return}n||(n=Promise.resolve().then(()=>{n=void 0,a&&e(s.splice(0))}))});return a=!0,()=>{a=!1,l()}}function qj(t,e){const r=bn.get(t);r||console.warn("Please use proxy object");const[i,n,s]=r;return s(i,n(),e)}const Nt=mn({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),Ge={state:Nt,subscribe(t){return ss(Nt,()=>t(Nt))},push(t,e){t!==Nt.view&&(Nt.view=t,e&&(Nt.data=e),Nt.history.push(t))},reset(t){Nt.view=t,Nt.history=[t]},replace(t){Nt.history.length>1&&(Nt.history[Nt.history.length-1]=t,Nt.view=t)},goBack(){if(Nt.history.length>1){Nt.history.pop();const[t]=Nt.history.slice(-1);Nt.view=t}},setData(t){Nt.data=t}},J={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return J.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const t=navigator.userAgent.toLowerCase();return J.isMobile()&&(t.includes("iphone")||t.includes("ipad"))},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},isArray(t){return Array.isArray(t)&&t.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(t,e,r){if(J.isHttpUrl(t))return this.formatUniversalUrl(t,e,r);let i=t;i.includes("://")||(i=t.replaceAll("/","").replaceAll(":",""),i=`${i}://`),i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,r);const n=encodeURIComponent(e);return`${i}wc?uri=${n}`},formatUniversalUrl(t,e,r){if(!J.isHttpUrl(t))return this.formatNativeUrl(t,e,r);let i=t;if(i.startsWith("https://t.me")){const s=Buffer.from(e).toString("base64").replace(/[=]/g,"");i.endsWith("/")&&(i=i.slice(0,-1)),this.setWalletConnectDeepLink(i,r);const o=new URL(i);return o.searchParams.set("startapp",s),o.toString()}i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,r);const n=encodeURIComponent(e);return`${i}wc?uri=${n}`},async wait(t){return new Promise(e=>{setTimeout(e,t)})},openHref(t,e){const r=this.isTelegram()?"_blank":e;window.open(t,r,"noreferrer noopener")},setWalletConnectDeepLink(t,e){try{localStorage.setItem(J.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(t){try{const[e]=t.split("?");localStorage.setItem(J.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(J.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(J.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var t;const e=(t=Ge.state.data)==null?void 0:t.Wallet;if(!e)throw new Error('Missing "Wallet" view data');return e}},zj=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),Yt=mn({enabled:zj,userSessionId:"",events:[],connectedWalletId:void 0}),hy={state:Yt,subscribe(t){return ss(Yt.events,()=>t(qj(Yt.events[Yt.events.length-1])))},initialize(){Yt.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(Yt.userSessionId=crypto.randomUUID())},setConnectedWalletId(t){Yt.connectedWalletId=t},click(t){if(Yt.enabled){const e={type:"CLICK",name:t.name,userSessionId:Yt.userSessionId,timestamp:Date.now(),data:t};Yt.events.push(e)}},track(t){if(Yt.enabled){const e={type:"TRACK",name:t.name,userSessionId:Yt.userSessionId,timestamp:Date.now(),data:t};Yt.events.push(e)}},view(t){if(Yt.enabled){const e={type:"VIEW",name:t.name,userSessionId:Yt.userSessionId,timestamp:Date.now(),data:t};Yt.events.push(e)}}},Ei=mn({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),vt={state:Ei,subscribe(t){return ss(Ei,()=>t(Ei))},setChains(t){Ei.chains=t},setWalletConnectUri(t){Ei.walletConnectUri=t},setIsCustomDesktop(t){Ei.isCustomDesktop=t},setIsCustomMobile(t){Ei.isCustomMobile=t},setIsDataLoaded(t){Ei.isDataLoaded=t},setIsUiLoaded(t){Ei.isUiLoaded=t},setIsAuth(t){Ei.isAuth=t}},au=mn({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),_r={state:au,subscribe(t){return ss(au,()=>t(au))},setConfig(t){var e,r;hy.initialize(),vt.setChains(t.chains),vt.setIsAuth(!!t.enableAuthMode),vt.setIsCustomMobile(!!((e=t.mobileWallets)!=null&&e.length)),vt.setIsCustomDesktop(!!((r=t.desktopWallets)!=null&&r.length)),J.setModalVersionInStorage(),Object.assign(au,t)}};var kj=Object.defineProperty,dy=Object.getOwnPropertySymbols,Hj=Object.prototype.hasOwnProperty,Wj=Object.prototype.propertyIsEnumerable,fy=(t,e,r)=>e in t?kj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vj=(t,e)=>{for(var r in e||(e={}))Hj.call(e,r)&&fy(t,r,e[r]);if(dy)for(var r of dy(e))Wj.call(e,r)&&fy(t,r,e[r]);return t};const Lf="https://explorer-api.walletconnect.com",Ff="wcm",Uf="js-2.7.0";async function cu(t,e){const r=Vj({sdkType:Ff,sdkVersion:Uf},e),i=new URL(t,Lf);return i.searchParams.append("projectId",_r.state.projectId),Object.entries(r).forEach(([s,o])=>{o&&i.searchParams.append(s,String(o))}),(await fetch(i)).json()}const os={async getDesktopListings(t){return cu("/w3m/v1/getDesktopListings",t)},async getMobileListings(t){return cu("/w3m/v1/getMobileListings",t)},async getInjectedListings(t){return cu("/w3m/v1/getInjectedListings",t)},async getAllListings(t){return cu("/w3m/v1/getAllListings",t)},getWalletImageUrl(t){return`${Lf}/w3m/v1/getWalletImage/${t}?projectId=${_r.state.projectId}&sdkType=${Ff}&sdkVersion=${Uf}`},getAssetImageUrl(t){return`${Lf}/w3m/v1/getAssetImage/${t}?projectId=${_r.state.projectId}&sdkType=${Ff}&sdkVersion=${Uf}`}};var Kj=Object.defineProperty,py=Object.getOwnPropertySymbols,Gj=Object.prototype.hasOwnProperty,Zj=Object.prototype.propertyIsEnumerable,gy=(t,e,r)=>e in t?Kj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yj=(t,e)=>{for(var r in e||(e={}))Gj.call(e,r)&&gy(t,r,e[r]);if(py)for(var r of py(e))Zj.call(e,r)&&gy(t,r,e[r]);return t};const by=J.isMobile(),$i=mn({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),dr={state:$i,async getRecomendedWallets(){const{explorerRecommendedWalletIds:t,explorerExcludedWalletIds:e}=_r.state;if(t==="NONE"||e==="ALL"&&!t)return $i.recomendedWallets;if(J.isArray(t)){const i={recommendedIds:t.join(",")},{listings:n}=await os.getAllListings(i),s=Object.values(n);s.sort((o,a)=>{const c=t.indexOf(o.id),l=t.indexOf(a.id);return c-l}),$i.recomendedWallets=s}else{const{chains:r,isAuth:i}=vt.state,n=r?.join(","),s=J.isArray(e),o={page:1,sdks:i?"auth_v1":void 0,entries:J.RECOMMENDED_WALLET_AMOUNT,chains:n,version:2,excludedIds:s?e.join(","):void 0},{listings:a}=by?await os.getMobileListings(o):await os.getDesktopListings(o);$i.recomendedWallets=Object.values(a)}return $i.recomendedWallets},async getWallets(t){const e=Yj({},t),{explorerRecommendedWalletIds:r,explorerExcludedWalletIds:i}=_r.state,{recomendedWallets:n}=$i;if(i==="ALL")return $i.wallets;n.length?e.excludedIds=n.map(d=>d.id).join(","):J.isArray(r)&&(e.excludedIds=r.join(",")),J.isArray(i)&&(e.excludedIds=[e.excludedIds,i].filter(Boolean).join(",")),vt.state.isAuth&&(e.sdks="auth_v1");const{page:s,search:o}=t,{listings:a,total:c}=by?await os.getMobileListings(e):await os.getDesktopListings(e),l=Object.values(a),u=o?"search":"wallets";return $i[u]={listings:[...$i[u].listings,...l],total:c,page:s??1},{listings:l,total:c}},getWalletImageUrl(t){return os.getWalletImageUrl(t)},getAssetImageUrl(t){return os.getAssetImageUrl(t)},resetSearch(){$i.search={listings:[],total:0,page:1}}},Do=mn({open:!1}),as={state:Do,subscribe(t){return ss(Do,()=>t(Do))},async open(t){return new Promise(e=>{const{isUiLoaded:r,isDataLoaded:i}=vt.state;if(J.removeWalletConnectDeepLink(),vt.setWalletConnectUri(t?.uri),vt.setChains(t?.chains),Ge.reset("ConnectWallet"),r&&i)Do.open=!0,e();else{const n=setInterval(()=>{const s=vt.state;s.isUiLoaded&&s.isDataLoaded&&(clearInterval(n),Do.open=!0,e())},200)}})},close(){Do.open=!1}};var Jj=Object.defineProperty,my=Object.getOwnPropertySymbols,Qj=Object.prototype.hasOwnProperty,Xj=Object.prototype.propertyIsEnumerable,vy=(t,e,r)=>e in t?Jj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eq=(t,e)=>{for(var r in e||(e={}))Qj.call(e,r)&&vy(t,r,e[r]);if(my)for(var r of my(e))Xj.call(e,r)&&vy(t,r,e[r]);return t};function tq(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const Wa=mn({themeMode:tq()?"dark":"light"}),vn={state:Wa,subscribe(t){return ss(Wa,()=>t(Wa))},setThemeConfig(t){const{themeMode:e,themeVariables:r}=t;e&&(Wa.themeMode=e),r&&(Wa.themeVariables=eq({},r))}},cs=mn({open:!1,message:"",variant:"success"}),yn={state:cs,subscribe(t){return ss(cs,()=>t(cs))},openToast(t,e){cs.open=!0,cs.message=t,cs.variant=e},closeToast(){cs.open=!1}};class rq{constructor(e){this.openModal=as.open,this.closeModal=as.close,this.subscribeModal=as.subscribe,this.setTheme=vn.setThemeConfig,vn.setThemeConfig(e),_r.setConfig(e),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(function(){return dW});const e=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",e),vt.setIsUiLoaded(!0)}}}var iq=Object.freeze({__proto__:null,WalletConnectModal:rq});/**
|
|
45
41
|
* @license
|
|
46
42
|
* Copyright 2019 Google LLC
|
|
47
43
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
48
|
-
*/const
|
|
44
|
+
*/const lu=window,jf=lu.ShadowRoot&&(lu.ShadyCSS===void 0||lu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qf=Symbol(),yy=new WeakMap;class wy{constructor(e,r,i){if(this._$cssResult$=!0,i!==qf)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=r}get styleSheet(){let e=this.o;const r=this.t;if(jf&&e===void 0){const i=r!==void 0&&r.length===1;i&&(e=yy.get(r)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&yy.set(r,e))}return e}toString(){return this.cssText}}const nq=t=>new wy(typeof t=="string"?t:t+"",void 0,qf),ve=(t,...e)=>{const r=t.length===1?t[0]:e.reduce((i,n,s)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[s+1],t[0]);return new wy(r,t,qf)},sq=(t,e)=>{jf?t.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):e.forEach(r=>{const i=document.createElement("style"),n=lu.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=r.cssText,t.appendChild(i)})},_y=jf?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const i of e.cssRules)r+=i.cssText;return nq(r)})(t):t;/**
|
|
49
45
|
* @license
|
|
50
46
|
* Copyright 2017 Google LLC
|
|
51
47
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
52
|
-
*/var
|
|
48
|
+
*/var zf;const uu=window,xy=uu.trustedTypes,oq=xy?xy.emptyScript:"",Ey=uu.reactiveElementPolyfillSupport,kf={toAttribute(t,e){switch(e){case Boolean:t=t?oq:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},$y=(t,e)=>e!==t&&(e==e||t==t),Hf={attribute:!0,type:String,converter:kf,reflect:!1,hasChanged:$y},Wf="finalized";class Mo extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var r;this.finalize(),((r=this.h)!==null&&r!==void 0?r:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach((r,i)=>{const n=this._$Ep(i,r);n!==void 0&&(this._$Ev.set(n,i),e.push(n))}),e}static createProperty(e,r=Hf){if(r.state&&(r.attribute=!1),this.finalize(),this.elementProperties.set(e,r),!r.noAccessor&&!this.prototype.hasOwnProperty(e)){const i=typeof e=="symbol"?Symbol():"__"+e,n=this.getPropertyDescriptor(e,i,r);n!==void 0&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,r,i){return{get(){return this[r]},set(n){const s=this[e];this[r]=n,this.requestUpdate(e,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Hf}static finalize(){if(this.hasOwnProperty(Wf))return!1;this[Wf]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const r=this.properties,i=[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)];for(const n of i)this.createProperty(n,r[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const r=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)r.unshift(_y(n))}else e!==void 0&&r.push(_y(e));return r}static _$Ep(e,r){const i=r.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(r=>r(this))}addController(e){var r,i;((r=this._$ES)!==null&&r!==void 0?r:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((i=e.hostConnected)===null||i===void 0||i.call(e))}removeController(e){var r;(r=this._$ES)===null||r===void 0||r.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,r)=>{this.hasOwnProperty(r)&&(this._$Ei.set(r,this[r]),delete this[r])})}createRenderRoot(){var e;const r=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return sq(r,this.constructor.elementStyles),r}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(r=>{var i;return(i=r.hostConnected)===null||i===void 0?void 0:i.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(r=>{var i;return(i=r.hostDisconnected)===null||i===void 0?void 0:i.call(r)})}attributeChangedCallback(e,r,i){this._$AK(e,i)}_$EO(e,r,i=Hf){var n;const s=this.constructor._$Ep(e,i);if(s!==void 0&&i.reflect===!0){const o=(((n=i.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?i.converter:kf).toAttribute(r,i.type);this._$El=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$El=null}}_$AK(e,r){var i;const n=this.constructor,s=n._$Ev.get(e);if(s!==void 0&&this._$El!==s){const o=n.getPropertyOptions(s),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((i=o.converter)===null||i===void 0?void 0:i.fromAttribute)!==void 0?o.converter:kf;this._$El=s,this[s]=a.fromAttribute(r,o.type),this._$El=null}}requestUpdate(e,r,i){let n=!0;e!==void 0&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||$y)(this[e],r)?(this._$AL.has(e)||this._$AL.set(e,r),i.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(r){Promise.reject(r)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,s)=>this[s]=n),this._$Ei=void 0);let r=!1;const i=this._$AL;try{r=this.shouldUpdate(i),r?(this.willUpdate(i),(e=this._$ES)===null||e===void 0||e.forEach(n=>{var s;return(s=n.hostUpdate)===null||s===void 0?void 0:s.call(n)}),this.update(i)):this._$Ek()}catch(n){throw r=!1,this._$Ek(),n}r&&this._$AE(i)}willUpdate(e){}_$AE(e){var r;(r=this._$ES)===null||r===void 0||r.forEach(i=>{var n;return(n=i.hostUpdated)===null||n===void 0?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((r,i)=>this._$EO(i,this[i],r)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}Mo[Wf]=!0,Mo.elementProperties=new Map,Mo.elementStyles=[],Mo.shadowRootOptions={mode:"open"},Ey?.({ReactiveElement:Mo}),((zf=uu.reactiveElementVersions)!==null&&zf!==void 0?zf:uu.reactiveElementVersions=[]).push("1.6.3");/**
|
|
53
49
|
* @license
|
|
54
50
|
* Copyright 2017 Google LLC
|
|
55
51
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
-
*/var
|
|
57
|
-
\f\r]`,
|
|
58
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g")
|
|
52
|
+
*/var Vf;const hu=window,To=hu.trustedTypes,Iy=To?To.createPolicy("lit-html",{createHTML:t=>t}):void 0,Kf="$lit$",wn=`lit$${(Math.random()+"").slice(9)}$`,Sy="?"+wn,aq=`<${Sy}>`,ls=document,Va=()=>ls.createComment(""),Ka=t=>t===null||typeof t!="object"&&typeof t!="function",Ay=Array.isArray,cq=t=>Ay(t)||typeof t?.[Symbol.iterator]=="function",Gf=`[
|
|
53
|
+
\f\r]`,Ga=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Py=/-->/g,Oy=/>/g,us=RegExp(`>|${Gf}(?:([^\\s"'>=/]+)(${Gf}*=${Gf}*(?:[^
|
|
54
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Cy=/'/g,Dy=/"/g,My=/^(?:script|style|textarea|title)$/i,Ty=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),G=Ty(1),nt=Ty(2),hs=Symbol.for("lit-noChange"),Et=Symbol.for("lit-nothing"),Ry=new WeakMap,ds=ls.createTreeWalker(ls,129,null,!1);function Ny(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Iy!==void 0?Iy.createHTML(e):e}const lq=(t,e)=>{const r=t.length-1,i=[];let n,s=e===2?"<svg>":"",o=Ga;for(let a=0;a<r;a++){const c=t[a];let l,u,d=-1,p=0;for(;p<c.length&&(o.lastIndex=p,u=o.exec(c),u!==null);)p=o.lastIndex,o===Ga?u[1]==="!--"?o=Py:u[1]!==void 0?o=Oy:u[2]!==void 0?(My.test(u[2])&&(n=RegExp("</"+u[2],"g")),o=us):u[3]!==void 0&&(o=us):o===us?u[0]===">"?(o=n??Ga,d=-1):u[1]===void 0?d=-2:(d=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?us:u[3]==='"'?Dy:Cy):o===Dy||o===Cy?o=us:o===Py||o===Oy?o=Ga:(o=us,n=void 0);const y=o===us&&t[a+1].startsWith("/>")?" ":"";s+=o===Ga?c+aq:d>=0?(i.push(l),c.slice(0,d)+Kf+c.slice(d)+wn+y):c+wn+(d===-2?(i.push(void 0),a):y)}return[Ny(t,s+(t[r]||"<?>")+(e===2?"</svg>":"")),i]};class Za{constructor({strings:e,_$litType$:r},i){let n;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[l,u]=lq(e,r);if(this.el=Za.createElement(l,i),ds.currentNode=this.el.content,r===2){const d=this.el.content,p=d.firstChild;p.remove(),d.append(...p.childNodes)}for(;(n=ds.nextNode())!==null&&c.length<a;){if(n.nodeType===1){if(n.hasAttributes()){const d=[];for(const p of n.getAttributeNames())if(p.endsWith(Kf)||p.startsWith(wn)){const y=u[o++];if(d.push(p),y!==void 0){const m=n.getAttribute(y.toLowerCase()+Kf).split(wn),_=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:_[2],strings:m,ctor:_[1]==="."?hq:_[1]==="?"?fq:_[1]==="@"?pq:du})}else c.push({type:6,index:s})}for(const p of d)n.removeAttribute(p)}if(My.test(n.tagName)){const d=n.textContent.split(wn),p=d.length-1;if(p>0){n.textContent=To?To.emptyScript:"";for(let y=0;y<p;y++)n.append(d[y],Va()),ds.nextNode(),c.push({type:2,index:++s});n.append(d[p],Va())}}}else if(n.nodeType===8)if(n.data===Sy)c.push({type:2,index:s});else{let d=-1;for(;(d=n.data.indexOf(wn,d+1))!==-1;)c.push({type:7,index:s}),d+=wn.length-1}s++}}static createElement(e,r){const i=ls.createElement("template");return i.innerHTML=e,i}}function Ro(t,e,r=t,i){var n,s,o,a;if(e===hs)return e;let c=i!==void 0?(n=r._$Co)===null||n===void 0?void 0:n[i]:r._$Cl;const l=Ka(e)?void 0:e._$litDirective$;return c?.constructor!==l&&((s=c?._$AO)===null||s===void 0||s.call(c,!1),l===void 0?c=void 0:(c=new l(t),c._$AT(t,r,i)),i!==void 0?((o=(a=r)._$Co)!==null&&o!==void 0?o:a._$Co=[])[i]=c:r._$Cl=c),c!==void 0&&(e=Ro(t,c._$AS(t,e.values),c,i)),e}class uq{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var r;const{el:{content:i},parts:n}=this._$AD,s=((r=e?.creationScope)!==null&&r!==void 0?r:ls).importNode(i,!0);ds.currentNode=s;let o=ds.nextNode(),a=0,c=0,l=n[0];for(;l!==void 0;){if(a===l.index){let u;l.type===2?u=new Ya(o,o.nextSibling,this,e):l.type===1?u=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(u=new gq(o,this,e)),this._$AV.push(u),l=n[++c]}a!==l?.index&&(o=ds.nextNode(),a++)}return ds.currentNode=ls,s}v(e){let r=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,r),r+=i.strings.length-2):i._$AI(e[r])),r++}}class Ya{constructor(e,r,i,n){var s;this.type=2,this._$AH=Et,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=i,this.options=n,this._$Cp=(s=n?.isConnected)===null||s===void 0||s}get _$AU(){var e,r;return(r=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&r!==void 0?r:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&e?.nodeType===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=Ro(this,e,r),Ka(e)?e===Et||e==null||e===""?(this._$AH!==Et&&this._$AR(),this._$AH=Et):e!==this._$AH&&e!==hs&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):cq(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==Et&&Ka(this._$AH)?this._$AA.nextSibling.data=e:this.$(ls.createTextNode(e)),this._$AH=e}g(e){var r;const{values:i,_$litType$:n}=e,s=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Za.createElement(Ny(n.h,n.h[0]),this.options)),n);if(((r=this._$AH)===null||r===void 0?void 0:r._$AD)===s)this._$AH.v(i);else{const o=new uq(s,this),a=o.u(this.options);o.v(i),this.$(a),this._$AH=o}}_$AC(e){let r=Ry.get(e.strings);return r===void 0&&Ry.set(e.strings,r=new Za(e)),r}T(e){Ay(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let i,n=0;for(const s of e)n===r.length?r.push(i=new Ya(this.k(Va()),this.k(Va()),this,this.options)):i=r[n],i._$AI(s),n++;n<r.length&&(this._$AR(i&&i._$AB.nextSibling,n),r.length=n)}_$AR(e=this._$AA.nextSibling,r){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,r);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var r;this._$AM===void 0&&(this._$Cp=e,(r=this._$AP)===null||r===void 0||r.call(this,e))}}class du{constructor(e,r,i,n,s){this.type=1,this._$AH=Et,this._$AN=void 0,this.element=e,this.name=r,this._$AM=n,this.options=s,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Et}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,r=this,i,n){const s=this.strings;let o=!1;if(s===void 0)e=Ro(this,e,r,0),o=!Ka(e)||e!==this._$AH&&e!==hs,o&&(this._$AH=e);else{const a=e;let c,l;for(e=s[0],c=0;c<s.length-1;c++)l=Ro(this,a[i+c],r,c),l===hs&&(l=this._$AH[c]),o||(o=!Ka(l)||l!==this._$AH[c]),l===Et?e=Et:e!==Et&&(e+=(l??"")+s[c+1]),this._$AH[c]=l}o&&!n&&this.j(e)}j(e){e===Et?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class hq extends du{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Et?void 0:e}}const dq=To?To.emptyScript:"";class fq extends du{constructor(){super(...arguments),this.type=4}j(e){e&&e!==Et?this.element.setAttribute(this.name,dq):this.element.removeAttribute(this.name)}}class pq extends du{constructor(e,r,i,n,s){super(e,r,i,n,s),this.type=5}_$AI(e,r=this){var i;if((e=(i=Ro(this,e,r,0))!==null&&i!==void 0?i:Et)===hs)return;const n=this._$AH,s=e===Et&&n!==Et||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,o=e!==Et&&(n===Et||s);s&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var r,i;typeof this._$AH=="function"?this._$AH.call((i=(r=this.options)===null||r===void 0?void 0:r.host)!==null&&i!==void 0?i:this.element,e):this._$AH.handleEvent(e)}}class gq{constructor(e,r,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Ro(this,e)}}const By=hu.litHtmlPolyfillSupport;By?.(Za,Ya),((Vf=hu.litHtmlVersions)!==null&&Vf!==void 0?Vf:hu.litHtmlVersions=[]).push("2.8.0");const bq=(t,e,r)=>{var i,n;const s=(i=r?.renderBefore)!==null&&i!==void 0?i:e;let o=s._$litPart$;if(o===void 0){const a=(n=r?.renderBefore)!==null&&n!==void 0?n:null;s._$litPart$=o=new Ya(e.insertBefore(Va(),a),a,void 0,r??{})}return o._$AI(t),o};/**
|
|
59
55
|
* @license
|
|
60
56
|
* Copyright 2017 Google LLC
|
|
61
57
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
62
|
-
*/var
|
|
58
|
+
*/var Zf,Yf;class ae extends Mo{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,r;const i=super.createRenderRoot();return(e=(r=this.renderOptions).renderBefore)!==null&&e!==void 0||(r.renderBefore=i.firstChild),i}update(e){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=bq(r,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return hs}}ae.finalized=!0,ae._$litElement$=!0,(Zf=globalThis.litElementHydrateSupport)===null||Zf===void 0||Zf.call(globalThis,{LitElement:ae});const Ly=globalThis.litElementPolyfillSupport;Ly?.({LitElement:ae}),((Yf=globalThis.litElementVersions)!==null&&Yf!==void 0?Yf:globalThis.litElementVersions=[]).push("3.3.3");/**
|
|
63
59
|
* @license
|
|
64
60
|
* Copyright 2017 Google LLC
|
|
65
61
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
66
|
-
*/const
|
|
62
|
+
*/const de=t=>e=>typeof e=="function"?((r,i)=>(customElements.define(r,i),i))(t,e):((r,i)=>{const{kind:n,elements:s}=i;return{kind:n,elements:s,finisher(o){customElements.define(r,o)}}})(t,e);/**
|
|
67
63
|
* @license
|
|
68
64
|
* Copyright 2017 Google LLC
|
|
69
65
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
70
|
-
*/const
|
|
66
|
+
*/const mq=(t,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(r){r.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(r){r.createProperty(e.key,t)}},vq=(t,e,r)=>{e.constructor.createProperty(r,t)};function ie(t){return(e,r)=>r!==void 0?vq(t,e,r):mq(t,e)}/**
|
|
71
67
|
* @license
|
|
72
68
|
* Copyright 2017 Google LLC
|
|
73
69
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
74
|
-
*/function
|
|
70
|
+
*/function fr(t){return ie({...t,state:!0})}/**
|
|
75
71
|
* @license
|
|
76
72
|
* Copyright 2021 Google LLC
|
|
77
73
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
78
|
-
*/var
|
|
74
|
+
*/var Jf;((Jf=window.HTMLSlotElement)===null||Jf===void 0?void 0:Jf.prototype.assignedElements)!=null;/**
|
|
79
75
|
* @license
|
|
80
76
|
* Copyright 2017 Google LLC
|
|
81
77
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
82
|
-
*/const
|
|
78
|
+
*/const yq={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},wq=t=>(...e)=>({_$litDirective$:t,values:e});class _q{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,r,i){this._$Ct=e,this._$AM=r,this._$Ci=i}_$AS(e,r){return this.update(e,r)}update(e,r){return this.render(...r)}}/**
|
|
83
79
|
* @license
|
|
84
80
|
* Copyright 2018 Google LLC
|
|
85
81
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
86
|
-
*/const wn=CB(class extends DB{constructor(t){var e;if(super(t),t.type!==OB.ATTRIBUTE||t.name!=="class"||((e=t.strings)===null||e===void 0?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var r,i;if(this.it===void 0){this.it=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!(!((r=this.nt)===null||r===void 0)&&r.has(s))&&this.it.add(s);return this.render(e)}const n=t.element.classList;this.it.forEach(s=>{s in e||(n.remove(s),this.it.delete(s))});for(const s in e){const o=!!e[s];o===this.it.has(s)||!((i=this.nt)===null||i===void 0)&&i.has(s)||(o?(n.add(s),this.it.add(s)):(n.remove(s),this.it.delete(s)))}return ks}});function RB(t,e){t.indexOf(e)===-1&&t.push(e)}const D2=(t,e,r)=>Math.min(Math.max(r,t),e),vi={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},ah=t=>typeof t=="number",Qo=t=>Array.isArray(t)&&!ah(t[0]),NB=(t,e,r)=>{const i=e-t;return((r-t)%i+i)%i+t};function TB(t,e){return Qo(t)?t[NB(0,t.length,e)]:t}const R2=(t,e,r)=>-r*t+r*e+t,N2=()=>{},rs=t=>t,Ad=(t,e,r)=>e-t===0?1:(r-t)/(e-t);function T2(t,e){const r=t[t.length-1];for(let i=1;i<=e;i++){const n=Ad(0,e,i);t.push(R2(r,1,n))}}function FB(t){const e=[0];return T2(e,t-1),e}function LB(t,e=FB(t.length),r=rs){const i=t.length,n=i-e.length;return n>0&&T2(e,n),s=>{let o=0;for(;o<i-2&&!(s<e[o+1]);o++);let a=D2(0,1,Ad(e[o],e[o+1],s));return a=TB(r,o)(a),R2(t[o],t[o+1],a)}}const F2=t=>Array.isArray(t)&&ah(t[0]),Md=t=>typeof t=="object"&&!!t.createAnimation,Hs=t=>typeof t=="function",BB=t=>typeof t=="string",fc={ms:t=>t*1e3,s:t=>t/1e3},L2=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,UB=1e-7,qB=12;function jB(t,e,r,i,n){let s,o,a=0;do o=e+(r-e)/2,s=L2(o,i,n)-t,s>0?r=o:e=o;while(Math.abs(s)>UB&&++a<qB);return o}function uc(t,e,r,i){if(t===e&&r===i)return rs;const n=s=>jB(s,0,1,t,r);return s=>s===0||s===1?s:L2(n(s),e,i)}const kB=(t,e="end")=>r=>{r=e==="end"?Math.min(r,.999):Math.max(r,.001);const i=r*t,n=e==="end"?Math.floor(i):Math.ceil(i);return D2(0,1,n/t)},zB={ease:uc(.25,.1,.25,1),"ease-in":uc(.42,0,1,1),"ease-in-out":uc(.42,0,.58,1),"ease-out":uc(0,0,.58,1)},HB=/\((.*?)\)/;function B2(t){if(Hs(t))return t;if(F2(t))return uc(...t);const e=zB[t];if(e)return e;if(t.startsWith("steps")){const r=HB.exec(t);if(r){const i=r[1].split(",");return kB(parseFloat(i[0]),i[1].trim())}}return rs}class U2{constructor(e,r=[0,1],{easing:i,duration:n=vi.duration,delay:s=vi.delay,endDelay:o=vi.endDelay,repeat:a=vi.repeat,offset:c,direction:l="normal",autoplay:u=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=rs,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((x,S)=>{this.resolve=x,this.reject=S}),i=i||vi.easing,Md(i)){const x=i.createAnimation(r);i=x.easing,r=x.keyframes||r,n=x.duration||n}this.repeat=a,this.easing=Qo(i)?rs:B2(i),this.updateDuration(n);const m=LB(r,c,Qo(i)?i.map(B2):rs);this.tick=x=>{var S;s=s;let E=0;this.pauseTime!==void 0?E=this.pauseTime:E=(x-this.startTime)*this.rate,this.t=E,E/=1e3,E=Math.max(E-s,0),this.playState==="finished"&&this.pauseTime===void 0&&(E=this.totalDuration);const A=E/this.duration;let R=Math.floor(A),O=A%1;!O&&A>=1&&(O=1),O===1&&R--;const C=R%2;(l==="reverse"||l==="alternate"&&C||l==="alternate-reverse"&&!C)&&(O=1-O);const N=E>=this.totalDuration?1:Math.min(O,1),T=m(this.easing(N));e(T),this.pauseTime===void 0&&(this.playState==="finished"||E>=this.totalDuration+o)?(this.playState="finished",(S=this.resolve)===null||S===void 0||S.call(this,T)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},u&&this.play()}play(){const e=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=e-this.pauseTime:this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var e;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(e=this.reject)===null||e===void 0||e.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(e){this.duration=e,this.totalDuration=e*(this.repeat+1)}get currentTime(){return this.t}set currentTime(e){this.pauseTime!==void 0||this.rate===0?this.pauseTime=e:this.startTime=performance.now()-e/this.rate}get playbackRate(){return this.rate}set playbackRate(e){this.rate=e}}var Pd=function(){};process.env.NODE_ENV!=="production"&&(Pd=function(t,e){if(!t)throw new Error(e)});class WB{setAnimation(e){this.animation=e,e?.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}const Od=new WeakMap;function q2(t){return Od.has(t)||Od.set(t,{transforms:[],values:new Map}),Od.get(t)}function VB(t,e){return t.has(e)||t.set(e,new WB),t.get(e)}const KB=["","X","Y","Z"],GB=["translate","scale","rotate","skew"],ch={x:"translateX",y:"translateY",z:"translateZ"},j2={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},JB={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:j2,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:rs},skew:j2},dc=new Map,Cd=t=>`--motion-${t}`,lh=["x","y","z"];GB.forEach(t=>{KB.forEach(e=>{lh.push(t+e),dc.set(Cd(t+e),JB[t])})});const ZB=(t,e)=>lh.indexOf(t)-lh.indexOf(e),YB=new Set(lh),k2=t=>YB.has(t),XB=(t,e)=>{ch[e]&&(e=ch[e]);const{transforms:r}=q2(t);RB(r,e),t.style.transform=QB(r)},QB=t=>t.sort(ZB).reduce(eU,"").trim(),eU=(t,e)=>`${t} ${e}(var(${Cd(e)}))`,Dd=t=>t.startsWith("--"),z2=new Set;function tU(t){if(!z2.has(t)){z2.add(t);try{const{syntax:e,initialValue:r}=dc.has(t)?dc.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:r})}catch{}}}const Rd=(t,e)=>document.createElement("div").animate(t,e),H2={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{Rd({opacity:[1]})}catch{return!1}return!0},finished:()=>!!Rd({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{Rd({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},Nd={},ea={};for(const t in H2)ea[t]=()=>(Nd[t]===void 0&&(Nd[t]=H2[t]()),Nd[t]);const rU=.015,iU=(t,e)=>{let r="";const i=Math.round(e/rU);for(let n=0;n<i;n++)r+=t(Ad(0,i-1,n))+", ";return r.substring(0,r.length-2)},W2=(t,e)=>Hs(t)?ea.linearEasing()?`linear(${iU(t,e)})`:vi.easing:F2(t)?nU(t):t,nU=([t,e,r,i])=>`cubic-bezier(${t}, ${e}, ${r}, ${i})`;function sU(t,e){for(let r=0;r<t.length;r++)t[r]===null&&(t[r]=r?t[r-1]:e());return t}const oU=t=>Array.isArray(t)?t:[t];function Td(t){return ch[t]&&(t=ch[t]),k2(t)?Cd(t):t}const hh={get:(t,e)=>{e=Td(e);let r=Dd(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!r&&r!==0){const i=dc.get(e);i&&(r=i.initialValue)}return r},set:(t,e,r)=>{e=Td(e),Dd(e)?t.style.setProperty(e,r):t.style[e]=r}};function V2(t,e=!0){if(!(!t||t.playState==="finished"))try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch{}}function aU(t,e){var r;let i=e?.toDefaultUnit||rs;const n=t[t.length-1];if(BB(n)){const s=((r=n.match(/(-?[\d.]+)([a-z%]*)/))===null||r===void 0?void 0:r[2])||"";s&&(i=o=>o+s)}return i}function cU(){return window.__MOTION_DEV_TOOLS_RECORD}function lU(t,e,r,i={},n){const s=cU(),o=i.record!==!1&&s;let a,{duration:c=vi.duration,delay:l=vi.delay,endDelay:u=vi.endDelay,repeat:m=vi.repeat,easing:x=vi.easing,persist:S=!1,direction:E,offset:A,allowWebkitAcceleration:R=!1,autoplay:O=!0}=i;const C=q2(t),N=k2(e);let T=ea.waapi();N&&XB(t,e);const U=Td(e),z=VB(C.values,U),W=dc.get(U);return V2(z.animation,!(Md(x)&&z.generator)&&i.record!==!1),()=>{const V=()=>{var M,v;return(v=(M=hh.get(t,U))!==null&&M!==void 0?M:W?.initialValue)!==null&&v!==void 0?v:0};let B=sU(oU(r),V);const K=aU(B,W);if(Md(x)){const M=x.createAnimation(B,e!=="opacity",V,U,z);x=M.easing,B=M.keyframes||B,c=M.duration||c}if(Dd(U)&&(ea.cssRegisterProperty()?tU(U):T=!1),N&&!ea.linearEasing()&&(Hs(x)||Qo(x)&&x.some(Hs))&&(T=!1),T){W&&(B=B.map(g=>ah(g)?W.toDefaultUnit(g):g)),B.length===1&&(!ea.partialKeyframes()||o)&&B.unshift(V());const M={delay:fc.ms(l),duration:fc.ms(c),endDelay:fc.ms(u),easing:Qo(x)?void 0:W2(x,c),direction:E,iterations:m+1,fill:"both"};a=t.animate({[U]:B,offset:A,easing:Qo(x)?x.map(g=>W2(g,c)):void 0},M),a.finished||(a.finished=new Promise((g,h)=>{a.onfinish=g,a.oncancel=h}));const v=B[B.length-1];a.finished.then(()=>{S||(hh.set(t,U,v),a.cancel())}).catch(N2),R||(a.playbackRate=1.000001)}else if(n&&N)B=B.map(M=>typeof M=="string"?parseFloat(M):M),B.length===1&&B.unshift(parseFloat(V())),a=new n(M=>{hh.set(t,U,K?K(M):M)},B,Object.assign(Object.assign({},i),{duration:c,easing:x}));else{const M=B[B.length-1];hh.set(t,U,W&&ah(M)?W.toDefaultUnit(M):M)}return o&&s(t,e,B,{duration:c,delay:l,easing:x,repeat:m,offset:A},"motion-one"),z.setAnimation(a),a&&!O&&a.pause(),a}}const hU=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function K2(t,e){var r;return typeof t=="string"?e?((r=e[t])!==null&&r!==void 0||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t||[])}const fU=t=>t(),G2=(t,e,r=vi.duration)=>new Proxy({animations:t.map(fU).filter(Boolean),duration:r,options:e},dU),uU=t=>t.animations[0],dU={get:(t,e)=>{const r=uU(t);switch(e){case"duration":return t.duration;case"currentTime":return fc.s(r?.[e]||0);case"playbackRate":case"playState":return r?.[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(pU)).catch(N2)),t.finished;case"stop":return()=>{t.animations.forEach(i=>V2(i))};case"forEachNative":return i=>{t.animations.forEach(n=>i(n,t))};default:return typeof r?.[e]>"u"?void 0:()=>t.animations.forEach(i=>i[e]())}},set:(t,e,r)=>{switch(e){case"currentTime":r=fc.ms(r);case"playbackRate":for(let i=0;i<t.animations.length;i++)t.animations[i][e]=r;return!0}return!1}},pU=t=>t.finished;function gU(t,e,r){return Hs(t)?t(e,r):t}function vU(t){return function(r,i,n={}){r=K2(r);const s=r.length;Pd(!!s,"No valid element provided."),Pd(!!i,"No keyframes defined.");const o=[];for(let a=0;a<s;a++){const c=r[a];for(const l in i){const u=hU(n,l);u.delay=gU(u.delay,a,s);const m=lU(c,l,i[l],u,t);o.push(m)}}return G2(o,n,n.duration)}}const mU=vU(U2);function bU(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}typeof SuppressedError=="function"&&SuppressedError;const yU={any:0,all:1};function wU(t,e,{root:r,margin:i,amount:n="any"}={}){if(typeof IntersectionObserver>"u")return()=>{};const s=K2(t),o=new WeakMap,a=l=>{l.forEach(u=>{const m=o.get(u.target);if(u.isIntersecting!==!!m)if(u.isIntersecting){const x=e(u);Hs(x)?o.set(u.target,x):c.unobserve(u.target)}else m&&(m(u),o.delete(u.target))})},c=new IntersectionObserver(a,{root:r,rootMargin:i,threshold:typeof n=="number"?n:yU[n]});return s.forEach(l=>c.observe(l)),()=>c.disconnect()}function Fd(t,e,r){t.dispatchEvent(new CustomEvent(e,{detail:{originalEvent:r}}))}function J2(t,e,r){t.dispatchEvent(new CustomEvent(e,{detail:{originalEntry:r}}))}const _U={isActive:t=>!!t.inView,subscribe:(t,{enable:e,disable:r},{inViewOptions:i={}})=>{const{once:n}=i,s=bU(i,["once"]);return wU(t,o=>{if(e(),J2(t,"viewenter",o),!n)return a=>{r(),J2(t,"viewleave",a)}},s)}},Z2=(t,e,r)=>i=>{i.pointerType&&i.pointerType!=="mouse"||(r(),Fd(t,e,i))};[...Object.keys({inView:_U,hover:{isActive:t=>!!t.hover,subscribe:(t,{enable:e,disable:r})=>{const i=Z2(t,"hoverstart",e),n=Z2(t,"hoverend",r);return t.addEventListener("pointerenter",i),t.addEventListener("pointerleave",n),()=>{t.removeEventListener("pointerenter",i),t.removeEventListener("pointerleave",n)}}},press:{isActive:t=>!!t.press,subscribe:(t,{enable:e,disable:r})=>{const i=s=>{r(),Fd(t,"pressend",s),window.removeEventListener("pointerup",i)},n=s=>{e(),Fd(t,"pressstart",s),window.addEventListener("pointerup",i)};return t.addEventListener("pointerdown",n),()=>{t.removeEventListener("pointerdown",n),window.removeEventListener("pointerup",i)}}}})];function xU(t,e={}){return G2([()=>{const r=new U2(t,[0,1],e);return r.finished.catch(()=>{}),r}],e,e.duration)}function Ws(t,e,r){return(Hs(t)?xU:mU)(t,e,r)}/**
|
|
82
|
+
*/const Hi=wq(class extends _q{constructor(t){var e;if(super(t),t.type!==yq.ATTRIBUTE||t.name!=="class"||((e=t.strings)===null||e===void 0?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var r,i;if(this.it===void 0){this.it=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!(!((r=this.nt)===null||r===void 0)&&r.has(s))&&this.it.add(s);return this.render(e)}const n=t.element.classList;this.it.forEach(s=>{s in e||(n.remove(s),this.it.delete(s))});for(const s in e){const o=!!e[s];o===this.it.has(s)||!((i=this.nt)===null||i===void 0)&&i.has(s)||(o?(n.add(s),this.it.add(s)):(n.remove(s),this.it.delete(s)))}return hs}});function xq(t,e){t.indexOf(e)===-1&&t.push(e)}const Fy=(t,e,r)=>Math.min(Math.max(r,t),e),Nr={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},fu=t=>typeof t=="number",No=t=>Array.isArray(t)&&!fu(t[0]),Eq=(t,e,r)=>{const i=e-t;return((r-t)%i+i)%i+t};function $q(t,e){return No(t)?t[Eq(0,t.length,e)]:t}const Uy=(t,e,r)=>-r*t+r*e+t,jy=()=>{},_n=t=>t,Qf=(t,e,r)=>e-t===0?1:(r-t)/(e-t);function qy(t,e){const r=t[t.length-1];for(let i=1;i<=e;i++){const n=Qf(0,e,i);t.push(Uy(r,1,n))}}function Iq(t){const e=[0];return qy(e,t-1),e}function Sq(t,e=Iq(t.length),r=_n){const i=t.length,n=i-e.length;return n>0&&qy(e,n),s=>{let o=0;for(;o<i-2&&!(s<e[o+1]);o++);let a=Fy(0,1,Qf(e[o],e[o+1],s));return a=$q(r,o)(a),Uy(t[o],t[o+1],a)}}const zy=t=>Array.isArray(t)&&fu(t[0]),Xf=t=>typeof t=="object"&&!!t.createAnimation,fs=t=>typeof t=="function",Aq=t=>typeof t=="string",Ja={ms:t=>t*1e3,s:t=>t/1e3},ky=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,Pq=1e-7,Oq=12;function Cq(t,e,r,i,n){let s,o,a=0;do o=e+(r-e)/2,s=ky(o,i,n)-t,s>0?r=o:e=o;while(Math.abs(s)>Pq&&++a<Oq);return o}function Qa(t,e,r,i){if(t===e&&r===i)return _n;const n=s=>Cq(s,0,1,t,r);return s=>s===0||s===1?s:ky(n(s),e,i)}const Dq=(t,e="end")=>r=>{r=e==="end"?Math.min(r,.999):Math.max(r,.001);const i=r*t,n=e==="end"?Math.floor(i):Math.ceil(i);return Fy(0,1,n/t)},Mq={ease:Qa(.25,.1,.25,1),"ease-in":Qa(.42,0,1,1),"ease-in-out":Qa(.42,0,.58,1),"ease-out":Qa(0,0,.58,1)},Tq=/\((.*?)\)/;function Hy(t){if(fs(t))return t;if(zy(t))return Qa(...t);const e=Mq[t];if(e)return e;if(t.startsWith("steps")){const r=Tq.exec(t);if(r){const i=r[1].split(",");return Dq(parseFloat(i[0]),i[1].trim())}}return _n}class Wy{constructor(e,r=[0,1],{easing:i,duration:n=Nr.duration,delay:s=Nr.delay,endDelay:o=Nr.endDelay,repeat:a=Nr.repeat,offset:c,direction:l="normal",autoplay:u=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=_n,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((p,y)=>{this.resolve=p,this.reject=y}),i=i||Nr.easing,Xf(i)){const p=i.createAnimation(r);i=p.easing,r=p.keyframes||r,n=p.duration||n}this.repeat=a,this.easing=No(i)?_n:Hy(i),this.updateDuration(n);const d=Sq(r,c,No(i)?i.map(Hy):_n);this.tick=p=>{var y;s=s;let m=0;this.pauseTime!==void 0?m=this.pauseTime:m=(p-this.startTime)*this.rate,this.t=m,m/=1e3,m=Math.max(m-s,0),this.playState==="finished"&&this.pauseTime===void 0&&(m=this.totalDuration);const _=m/this.duration;let S=Math.floor(_),E=_%1;!E&&_>=1&&(E=1),E===1&&S--;const P=S%2;(l==="reverse"||l==="alternate"&&P||l==="alternate-reverse"&&!P)&&(E=1-E);const C=m>=this.totalDuration?1:Math.min(E,1),M=d(this.easing(C));e(M),this.pauseTime===void 0&&(this.playState==="finished"||m>=this.totalDuration+o)?(this.playState="finished",(y=this.resolve)===null||y===void 0||y.call(this,M)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},u&&this.play()}play(){const e=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=e-this.pauseTime:this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var e;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(e=this.reject)===null||e===void 0||e.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(e){this.duration=e,this.totalDuration=e*(this.repeat+1)}get currentTime(){return this.t}set currentTime(e){this.pauseTime!==void 0||this.rate===0?this.pauseTime=e:this.startTime=performance.now()-e/this.rate}get playbackRate(){return this.rate}set playbackRate(e){this.rate=e}}var e0=function(){};process.env.NODE_ENV!=="production"&&(e0=function(t,e){if(!t)throw new Error(e)});class Rq{setAnimation(e){this.animation=e,e?.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}const t0=new WeakMap;function Vy(t){return t0.has(t)||t0.set(t,{transforms:[],values:new Map}),t0.get(t)}function Nq(t,e){return t.has(e)||t.set(e,new Rq),t.get(e)}const Bq=["","X","Y","Z"],Lq=["translate","scale","rotate","skew"],pu={x:"translateX",y:"translateY",z:"translateZ"},Ky={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},Fq={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:Ky,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:_n},skew:Ky},Xa=new Map,r0=t=>`--motion-${t}`,gu=["x","y","z"];Lq.forEach(t=>{Bq.forEach(e=>{gu.push(t+e),Xa.set(r0(t+e),Fq[t])})});const Uq=(t,e)=>gu.indexOf(t)-gu.indexOf(e),jq=new Set(gu),Gy=t=>jq.has(t),qq=(t,e)=>{pu[e]&&(e=pu[e]);const{transforms:r}=Vy(t);xq(r,e),t.style.transform=zq(r)},zq=t=>t.sort(Uq).reduce(kq,"").trim(),kq=(t,e)=>`${t} ${e}(var(${r0(e)}))`,i0=t=>t.startsWith("--"),Zy=new Set;function Hq(t){if(!Zy.has(t)){Zy.add(t);try{const{syntax:e,initialValue:r}=Xa.has(t)?Xa.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:r})}catch{}}}const n0=(t,e)=>document.createElement("div").animate(t,e),Yy={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{n0({opacity:[1]})}catch{return!1}return!0},finished:()=>!!n0({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{n0({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},s0={},Bo={};for(const t in Yy)Bo[t]=()=>(s0[t]===void 0&&(s0[t]=Yy[t]()),s0[t]);const Wq=.015,Vq=(t,e)=>{let r="";const i=Math.round(e/Wq);for(let n=0;n<i;n++)r+=t(Qf(0,i-1,n))+", ";return r.substring(0,r.length-2)},Jy=(t,e)=>fs(t)?Bo.linearEasing()?`linear(${Vq(t,e)})`:Nr.easing:zy(t)?Kq(t):t,Kq=([t,e,r,i])=>`cubic-bezier(${t}, ${e}, ${r}, ${i})`;function Gq(t,e){for(let r=0;r<t.length;r++)t[r]===null&&(t[r]=r?t[r-1]:e());return t}const Zq=t=>Array.isArray(t)?t:[t];function o0(t){return pu[t]&&(t=pu[t]),Gy(t)?r0(t):t}const bu={get:(t,e)=>{e=o0(e);let r=i0(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!r&&r!==0){const i=Xa.get(e);i&&(r=i.initialValue)}return r},set:(t,e,r)=>{e=o0(e),i0(e)?t.style.setProperty(e,r):t.style[e]=r}};function Qy(t,e=!0){if(!(!t||t.playState==="finished"))try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch{}}function Yq(t,e){var r;let i=e?.toDefaultUnit||_n;const n=t[t.length-1];if(Aq(n)){const s=((r=n.match(/(-?[\d.]+)([a-z%]*)/))===null||r===void 0?void 0:r[2])||"";s&&(i=o=>o+s)}return i}function Jq(){return window.__MOTION_DEV_TOOLS_RECORD}function Qq(t,e,r,i={},n){const s=Jq(),o=i.record!==!1&&s;let a,{duration:c=Nr.duration,delay:l=Nr.delay,endDelay:u=Nr.endDelay,repeat:d=Nr.repeat,easing:p=Nr.easing,persist:y=!1,direction:m,offset:_,allowWebkitAcceleration:S=!1,autoplay:E=!0}=i;const P=Vy(t),C=Gy(e);let M=Bo.waapi();C&&qq(t,e);const R=o0(e),L=Nq(P.values,R),B=Xa.get(R);return Qy(L.animation,!(Xf(p)&&L.generator)&&i.record!==!1),()=>{const F=()=>{var $,h;return(h=($=bu.get(t,R))!==null&&$!==void 0?$:B?.initialValue)!==null&&h!==void 0?h:0};let T=Gq(Zq(r),F);const q=Yq(T,B);if(Xf(p)){const $=p.createAnimation(T,e!=="opacity",F,R,L);p=$.easing,T=$.keyframes||T,c=$.duration||c}if(i0(R)&&(Bo.cssRegisterProperty()?Hq(R):M=!1),C&&!Bo.linearEasing()&&(fs(p)||No(p)&&p.some(fs))&&(M=!1),M){B&&(T=T.map(b=>fu(b)?B.toDefaultUnit(b):b)),T.length===1&&(!Bo.partialKeyframes()||o)&&T.unshift(F());const $={delay:Ja.ms(l),duration:Ja.ms(c),endDelay:Ja.ms(u),easing:No(p)?void 0:Jy(p,c),direction:m,iterations:d+1,fill:"both"};a=t.animate({[R]:T,offset:_,easing:No(p)?p.map(b=>Jy(b,c)):void 0},$),a.finished||(a.finished=new Promise((b,w)=>{a.onfinish=b,a.oncancel=w}));const h=T[T.length-1];a.finished.then(()=>{y||(bu.set(t,R,h),a.cancel())}).catch(jy),S||(a.playbackRate=1.000001)}else if(n&&C)T=T.map($=>typeof $=="string"?parseFloat($):$),T.length===1&&T.unshift(parseFloat(F())),a=new n($=>{bu.set(t,R,q?q($):$)},T,Object.assign(Object.assign({},i),{duration:c,easing:p}));else{const $=T[T.length-1];bu.set(t,R,B&&fu($)?B.toDefaultUnit($):$)}return o&&s(t,e,T,{duration:c,delay:l,easing:p,repeat:d,offset:_},"motion-one"),L.setAnimation(a),a&&!E&&a.pause(),a}}const Xq=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function Xy(t,e){var r;return typeof t=="string"?e?((r=e[t])!==null&&r!==void 0||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t||[])}const ez=t=>t(),ew=(t,e,r=Nr.duration)=>new Proxy({animations:t.map(ez).filter(Boolean),duration:r,options:e},rz),tz=t=>t.animations[0],rz={get:(t,e)=>{const r=tz(t);switch(e){case"duration":return t.duration;case"currentTime":return Ja.s(r?.[e]||0);case"playbackRate":case"playState":return r?.[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(iz)).catch(jy)),t.finished;case"stop":return()=>{t.animations.forEach(i=>Qy(i))};case"forEachNative":return i=>{t.animations.forEach(n=>i(n,t))};default:return typeof r?.[e]>"u"?void 0:()=>t.animations.forEach(i=>i[e]())}},set:(t,e,r)=>{switch(e){case"currentTime":r=Ja.ms(r);case"playbackRate":for(let i=0;i<t.animations.length;i++)t.animations[i][e]=r;return!0}return!1}},iz=t=>t.finished;function nz(t,e,r){return fs(t)?t(e,r):t}function sz(t){return function(r,i,n={}){r=Xy(r);const s=r.length;e0(!!s,"No valid element provided."),e0(!!i,"No keyframes defined.");const o=[];for(let a=0;a<s;a++){const c=r[a];for(const l in i){const u=Xq(n,l);u.delay=nz(u.delay,a,s);const d=Qq(c,l,i[l],u,t);o.push(d)}}return ew(o,n,n.duration)}}const oz=sz(Wy);function az(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}typeof SuppressedError=="function"&&SuppressedError;const cz={any:0,all:1};function lz(t,e,{root:r,margin:i,amount:n="any"}={}){if(typeof IntersectionObserver>"u")return()=>{};const s=Xy(t),o=new WeakMap,a=l=>{l.forEach(u=>{const d=o.get(u.target);if(u.isIntersecting!==!!d)if(u.isIntersecting){const p=e(u);fs(p)?o.set(u.target,p):c.unobserve(u.target)}else d&&(d(u),o.delete(u.target))})},c=new IntersectionObserver(a,{root:r,rootMargin:i,threshold:typeof n=="number"?n:cz[n]});return s.forEach(l=>c.observe(l)),()=>c.disconnect()}function a0(t,e,r){t.dispatchEvent(new CustomEvent(e,{detail:{originalEvent:r}}))}function tw(t,e,r){t.dispatchEvent(new CustomEvent(e,{detail:{originalEntry:r}}))}const uz={isActive:t=>!!t.inView,subscribe:(t,{enable:e,disable:r},{inViewOptions:i={}})=>{const{once:n}=i,s=az(i,["once"]);return lz(t,o=>{if(e(),tw(t,"viewenter",o),!n)return a=>{r(),tw(t,"viewleave",a)}},s)}},rw=(t,e,r)=>i=>{i.pointerType&&i.pointerType!=="mouse"||(r(),a0(t,e,i))};[...Object.keys({inView:uz,hover:{isActive:t=>!!t.hover,subscribe:(t,{enable:e,disable:r})=>{const i=rw(t,"hoverstart",e),n=rw(t,"hoverend",r);return t.addEventListener("pointerenter",i),t.addEventListener("pointerleave",n),()=>{t.removeEventListener("pointerenter",i),t.removeEventListener("pointerleave",n)}}},press:{isActive:t=>!!t.press,subscribe:(t,{enable:e,disable:r})=>{const i=s=>{r(),a0(t,"pressend",s),window.removeEventListener("pointerup",i)},n=s=>{e(),a0(t,"pressstart",s),window.addEventListener("pointerup",i)};return t.addEventListener("pointerdown",n),()=>{t.removeEventListener("pointerdown",n),window.removeEventListener("pointerup",i)}}}})];function hz(t,e={}){return ew([()=>{const r=new Wy(t,[0,1],e);return r.finished.catch(()=>{}),r}],e,e.duration)}function ps(t,e,r){return(fs(t)?hz:oz)(t,e,r)}/**
|
|
87
83
|
* @license
|
|
88
84
|
* Copyright 2018 Google LLC
|
|
89
85
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
90
|
-
*/const
|
|
91
|
-
]))+`;
|
|
92
|
-
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),t.put(r,13)}};var
|
|
93
|
-
Suggested mode is: `+e.toString(
|
|
86
|
+
*/const ir=t=>t??Et;var ec={},dz=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},iw={},xr={};let c0;const fz=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];xr.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17},xr.getSymbolTotalCodewords=function(e){return fz[e]},xr.getBCHDigit=function(t){let e=0;for(;t!==0;)e++,t>>>=1;return e},xr.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');c0=e},xr.isKanjiModeEnabled=function(){return typeof c0<"u"},xr.toSJIS=function(e){return c0(e)};var mu={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},t.from=function(i,n){if(t.isValid(i))return i;try{return e(i)}catch{return n}}})(mu);function nw(){this.buffer=[],this.length=0}nw.prototype={get:function(t){const e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)===1},put:function(t,e){for(let r=0;r<e;r++)this.putBit((t>>>e-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var pz=nw;function tc(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}tc.prototype.set=function(t,e,r,i){const n=t*this.size+e;this.data[n]=r,i&&(this.reservedBit[n]=!0)},tc.prototype.get=function(t,e){return this.data[t*this.size+e]},tc.prototype.xor=function(t,e,r){this.data[t*this.size+e]^=r},tc.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var gz=tc,sw={};(function(t){const e=xr.getSymbolSize;t.getRowColCoords=function(i){if(i===1)return[];const n=Math.floor(i/7)+2,s=e(i),o=s===145?26:Math.ceil((s-13)/(2*n-2))*2,a=[s-7];for(let c=1;c<n-1;c++)a[c]=a[c-1]-o;return a.push(6),a.reverse()},t.getPositions=function(i){const n=[],s=t.getRowColCoords(i),o=s.length;for(let a=0;a<o;a++)for(let c=0;c<o;c++)a===0&&c===0||a===0&&c===o-1||a===o-1&&c===0||n.push([s[a],s[c]]);return n}})(sw);var ow={};const bz=xr.getSymbolSize,aw=7;ow.getPositions=function(e){const r=bz(e);return[[0,0],[r-aw,0],[0,r-aw]]};var cw={};(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},t.from=function(n){return t.isValid(n)?parseInt(n,10):void 0},t.getPenaltyN1=function(n){const s=n.size;let o=0,a=0,c=0,l=null,u=null;for(let d=0;d<s;d++){a=c=0,l=u=null;for(let p=0;p<s;p++){let y=n.get(d,p);y===l?a++:(a>=5&&(o+=e.N1+(a-5)),l=y,a=1),y=n.get(p,d),y===u?c++:(c>=5&&(o+=e.N1+(c-5)),u=y,c=1)}a>=5&&(o+=e.N1+(a-5)),c>=5&&(o+=e.N1+(c-5))}return o},t.getPenaltyN2=function(n){const s=n.size;let o=0;for(let a=0;a<s-1;a++)for(let c=0;c<s-1;c++){const l=n.get(a,c)+n.get(a,c+1)+n.get(a+1,c)+n.get(a+1,c+1);(l===4||l===0)&&o++}return o*e.N2},t.getPenaltyN3=function(n){const s=n.size;let o=0,a=0,c=0;for(let l=0;l<s;l++){a=c=0;for(let u=0;u<s;u++)a=a<<1&2047|n.get(l,u),u>=10&&(a===1488||a===93)&&o++,c=c<<1&2047|n.get(u,l),u>=10&&(c===1488||c===93)&&o++}return o*e.N3},t.getPenaltyN4=function(n){let s=0;const o=n.data.length;for(let c=0;c<o;c++)s+=n.data[c];return Math.abs(Math.ceil(s*100/o/5)-10)*e.N4};function r(i,n,s){switch(i){case t.Patterns.PATTERN000:return(n+s)%2===0;case t.Patterns.PATTERN001:return n%2===0;case t.Patterns.PATTERN010:return s%3===0;case t.Patterns.PATTERN011:return(n+s)%3===0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(s/3))%2===0;case t.Patterns.PATTERN101:return n*s%2+n*s%3===0;case t.Patterns.PATTERN110:return(n*s%2+n*s%3)%2===0;case t.Patterns.PATTERN111:return(n*s%3+(n+s)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}t.applyMask=function(n,s){const o=s.size;for(let a=0;a<o;a++)for(let c=0;c<o;c++)s.isReserved(c,a)||s.xor(c,a,r(n,c,a))},t.getBestMask=function(n,s){const o=Object.keys(t.Patterns).length;let a=0,c=1/0;for(let l=0;l<o;l++){s(l),t.applyMask(l,n);const u=t.getPenaltyN1(n)+t.getPenaltyN2(n)+t.getPenaltyN3(n)+t.getPenaltyN4(n);t.applyMask(l,n),u<c&&(c=u,a=l)}return a}})(cw);var vu={};const xn=mu,yu=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],wu=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];vu.getBlocksCount=function(e,r){switch(r){case xn.L:return yu[(e-1)*4+0];case xn.M:return yu[(e-1)*4+1];case xn.Q:return yu[(e-1)*4+2];case xn.H:return yu[(e-1)*4+3];default:return}},vu.getTotalCodewordsCount=function(e,r){switch(r){case xn.L:return wu[(e-1)*4+0];case xn.M:return wu[(e-1)*4+1];case xn.Q:return wu[(e-1)*4+2];case xn.H:return wu[(e-1)*4+3];default:return}};var lw={},_u={};const rc=new Uint8Array(512),xu=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)rc[r]=e,xu[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)rc[r]=rc[r-255]})(),_u.log=function(e){if(e<1)throw new Error("log("+e+")");return xu[e]},_u.exp=function(e){return rc[e]},_u.mul=function(e,r){return e===0||r===0?0:rc[xu[e]+xu[r]]},function(t){const e=_u;t.mul=function(i,n){const s=new Uint8Array(i.length+n.length-1);for(let o=0;o<i.length;o++)for(let a=0;a<n.length;a++)s[o+a]^=e.mul(i[o],n[a]);return s},t.mod=function(i,n){let s=new Uint8Array(i);for(;s.length-n.length>=0;){const o=s[0];for(let c=0;c<n.length;c++)s[c]^=e.mul(n[c],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},t.generateECPolynomial=function(i){let n=new Uint8Array([1]);for(let s=0;s<i;s++)n=t.mul(n,new Uint8Array([1,e.exp(s)]));return n}}(lw);const uw=lw;function l0(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}l0.prototype.initialize=function(e){this.degree=e,this.genPoly=uw.generateECPolynomial(this.degree)},l0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(e.length+this.degree);r.set(e);const i=uw.mod(r,this.genPoly),n=this.degree-i.length;if(n>0){const s=new Uint8Array(this.degree);return s.set(i,n),s}return i};var mz=l0,hw={},En={},u0={};u0.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var Ii={};const dw="[0-9]+",vz="[A-Z $%*+\\-./:]+";let ic="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";ic=ic.replace(/u/g,"\\u");const yz="(?:(?![A-Z0-9 $%*+\\-./:]|"+ic+`)(?:.|[\r
|
|
87
|
+
]))+`;Ii.KANJI=new RegExp(ic,"g"),Ii.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ii.BYTE=new RegExp(yz,"g"),Ii.NUMERIC=new RegExp(dw,"g"),Ii.ALPHANUMERIC=new RegExp(vz,"g");const wz=new RegExp("^"+ic+"$"),_z=new RegExp("^"+dw+"$"),xz=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ii.testKanji=function(e){return wz.test(e)},Ii.testNumeric=function(e){return _z.test(e)},Ii.testAlphanumeric=function(e){return xz.test(e)},function(t){const e=u0,r=Ii;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},t.getBestModeForData=function(s){return r.testNumeric(s)?t.NUMERIC:r.testAlphanumeric(s)?t.ALPHANUMERIC:r.testKanji(s)?t.KANJI:t.BYTE},t.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},t.isValid=function(s){return s&&s.bit&&s.ccBits};function i(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+n)}}t.from=function(s,o){if(t.isValid(s))return s;try{return i(s)}catch{return o}}}(En),function(t){const e=xr,r=vu,i=mu,n=En,s=u0,o=7973,a=e.getBCHDigit(o);function c(p,y,m){for(let _=1;_<=40;_++)if(y<=t.getCapacity(_,m,p))return _}function l(p,y){return n.getCharCountIndicator(p,y)+4}function u(p,y){let m=0;return p.forEach(function(_){const S=l(_.mode,y);m+=S+_.getBitsLength()}),m}function d(p,y){for(let m=1;m<=40;m++)if(u(p,m)<=t.getCapacity(m,y,n.MIXED))return m}t.from=function(y,m){return s.isValid(y)?parseInt(y,10):m},t.getCapacity=function(y,m,_){if(!s.isValid(y))throw new Error("Invalid QR Code version");typeof _>"u"&&(_=n.BYTE);const S=e.getSymbolTotalCodewords(y),E=r.getTotalCodewordsCount(y,m),P=(S-E)*8;if(_===n.MIXED)return P;const C=P-l(_,y);switch(_){case n.NUMERIC:return Math.floor(C/10*3);case n.ALPHANUMERIC:return Math.floor(C/11*2);case n.KANJI:return Math.floor(C/13);case n.BYTE:default:return Math.floor(C/8)}},t.getBestVersionForData=function(y,m){let _;const S=i.from(m,i.M);if(Array.isArray(y)){if(y.length>1)return d(y,S);if(y.length===0)return 1;_=y[0]}else _=y;return c(_.mode,_.getLength(),S)},t.getEncodedBits=function(y){if(!s.isValid(y)||y<7)throw new Error("Invalid QR Code version");let m=y<<12;for(;e.getBCHDigit(m)-a>=0;)m^=o<<e.getBCHDigit(m)-a;return y<<12|m}}(hw);var fw={};const h0=xr,pw=1335,Ez=21522,gw=h0.getBCHDigit(pw);fw.getEncodedBits=function(e,r){const i=e.bit<<3|r;let n=i<<10;for(;h0.getBCHDigit(n)-gw>=0;)n^=pw<<h0.getBCHDigit(n)-gw;return(i<<10|n)^Ez};var bw={};const $z=En;function Lo(t){this.mode=$z.NUMERIC,this.data=t.toString()}Lo.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},Lo.prototype.getLength=function(){return this.data.length},Lo.prototype.getBitsLength=function(){return Lo.getBitsLength(this.data.length)},Lo.prototype.write=function(e){let r,i,n;for(r=0;r+3<=this.data.length;r+=3)i=this.data.substr(r,3),n=parseInt(i,10),e.put(n,10);const s=this.data.length-r;s>0&&(i=this.data.substr(r),n=parseInt(i,10),e.put(n,s*3+1))};var Iz=Lo;const Sz=En,d0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Fo(t){this.mode=Sz.ALPHANUMERIC,this.data=t}Fo.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},Fo.prototype.getLength=function(){return this.data.length},Fo.prototype.getBitsLength=function(){return Fo.getBitsLength(this.data.length)},Fo.prototype.write=function(e){let r;for(r=0;r+2<=this.data.length;r+=2){let i=d0.indexOf(this.data[r])*45;i+=d0.indexOf(this.data[r+1]),e.put(i,11)}this.data.length%2&&e.put(d0.indexOf(this.data[r]),6)};var Az=Fo,Pz=function(e){for(var r=[],i=e.length,n=0;n<i;n++){var s=e.charCodeAt(n);if(s>=55296&&s<=56319&&i>n+1){var o=e.charCodeAt(n+1);o>=56320&&o<=57343&&(s=(s-55296)*1024+o-56320+65536,n+=1)}if(s<128){r.push(s);continue}if(s<2048){r.push(s>>6|192),r.push(s&63|128);continue}if(s<55296||s>=57344&&s<65536){r.push(s>>12|224),r.push(s>>6&63|128),r.push(s&63|128);continue}if(s>=65536&&s<=1114111){r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(s&63|128);continue}r.push(239,191,189)}return new Uint8Array(r).buffer};const Oz=Pz,Cz=En;function Uo(t){this.mode=Cz.BYTE,typeof t=="string"&&(t=Oz(t)),this.data=new Uint8Array(t)}Uo.getBitsLength=function(e){return e*8},Uo.prototype.getLength=function(){return this.data.length},Uo.prototype.getBitsLength=function(){return Uo.getBitsLength(this.data.length)},Uo.prototype.write=function(t){for(let e=0,r=this.data.length;e<r;e++)t.put(this.data[e],8)};var Dz=Uo;const Mz=En,Tz=xr;function jo(t){this.mode=Mz.KANJI,this.data=t}jo.getBitsLength=function(e){return e*13},jo.prototype.getLength=function(){return this.data.length},jo.prototype.getBitsLength=function(){return jo.getBitsLength(this.data.length)},jo.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let r=Tz.toSJIS(this.data[e]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
|
|
88
|
+
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),t.put(r,13)}};var Rz=jo,mw={exports:{}};(function(t){var e={single_source_shortest_paths:function(r,i,n){var s={},o={};o[i]=0;var a=e.PriorityQueue.make();a.push(i,0);for(var c,l,u,d,p,y,m,_,S;!a.empty();){c=a.pop(),l=c.value,d=c.cost,p=r[l]||{};for(u in p)p.hasOwnProperty(u)&&(y=p[u],m=d+y,_=o[u],S=typeof o[u]>"u",(S||_>m)&&(o[u]=m,a.push(u,m),s[u]=l))}if(typeof n<"u"&&typeof o[n]>"u"){var E=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(E)}return s},extract_shortest_path_from_predecessor_list:function(r,i){for(var n=[],s=i;s;)n.push(s),r[s],s=r[s];return n.reverse(),n},find_path:function(r,i,n){var s=e.single_source_shortest_paths(r,i,n);return e.extract_shortest_path_from_predecessor_list(s,n)},PriorityQueue:{make:function(r){var i=e.PriorityQueue,n={},s;r=r||{};for(s in i)i.hasOwnProperty(s)&&(n[s]=i[s]);return n.queue=[],n.sorter=r.sorter||i.default_sorter,n},default_sorter:function(r,i){return r.cost-i.cost},push:function(r,i){var n={value:r,cost:i};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(mw),function(t){const e=En,r=Iz,i=Az,n=Dz,s=Rz,o=Ii,a=xr,c=mw.exports;function l(E){return unescape(encodeURIComponent(E)).length}function u(E,P,C){const M=[];let R;for(;(R=E.exec(C))!==null;)M.push({data:R[0],index:R.index,mode:P,length:R[0].length});return M}function d(E){const P=u(o.NUMERIC,e.NUMERIC,E),C=u(o.ALPHANUMERIC,e.ALPHANUMERIC,E);let M,R;return a.isKanjiModeEnabled()?(M=u(o.BYTE,e.BYTE,E),R=u(o.KANJI,e.KANJI,E)):(M=u(o.BYTE_KANJI,e.BYTE,E),R=[]),P.concat(C,M,R).sort(function(B,F){return B.index-F.index}).map(function(B){return{data:B.data,mode:B.mode,length:B.length}})}function p(E,P){switch(P){case e.NUMERIC:return r.getBitsLength(E);case e.ALPHANUMERIC:return i.getBitsLength(E);case e.KANJI:return s.getBitsLength(E);case e.BYTE:return n.getBitsLength(E)}}function y(E){return E.reduce(function(P,C){const M=P.length-1>=0?P[P.length-1]:null;return M&&M.mode===C.mode?(P[P.length-1].data+=C.data,P):(P.push(C),P)},[])}function m(E){const P=[];for(let C=0;C<E.length;C++){const M=E[C];switch(M.mode){case e.NUMERIC:P.push([M,{data:M.data,mode:e.ALPHANUMERIC,length:M.length},{data:M.data,mode:e.BYTE,length:M.length}]);break;case e.ALPHANUMERIC:P.push([M,{data:M.data,mode:e.BYTE,length:M.length}]);break;case e.KANJI:P.push([M,{data:M.data,mode:e.BYTE,length:l(M.data)}]);break;case e.BYTE:P.push([{data:M.data,mode:e.BYTE,length:l(M.data)}])}}return P}function _(E,P){const C={},M={start:{}};let R=["start"];for(let L=0;L<E.length;L++){const B=E[L],F=[];for(let T=0;T<B.length;T++){const q=B[T],$=""+L+T;F.push($),C[$]={node:q,lastCount:0},M[$]={};for(let h=0;h<R.length;h++){const b=R[h];C[b]&&C[b].node.mode===q.mode?(M[b][$]=p(C[b].lastCount+q.length,q.mode)-p(C[b].lastCount,q.mode),C[b].lastCount+=q.length):(C[b]&&(C[b].lastCount=q.length),M[b][$]=p(q.length,q.mode)+4+e.getCharCountIndicator(q.mode,P))}}R=F}for(let L=0;L<R.length;L++)M[R[L]].end=0;return{map:M,table:C}}function S(E,P){let C;const M=e.getBestModeForData(E);if(C=e.from(P,M),C!==e.BYTE&&C.bit<M.bit)throw new Error('"'+E+'" cannot be encoded with mode '+e.toString(C)+`.
|
|
89
|
+
Suggested mode is: `+e.toString(M));switch(C===e.KANJI&&!a.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new r(E);case e.ALPHANUMERIC:return new i(E);case e.KANJI:return new s(E);case e.BYTE:return new n(E)}}t.fromArray=function(P){return P.reduce(function(C,M){return typeof M=="string"?C.push(S(M,null)):M.data&&C.push(S(M.data,M.mode)),C},[])},t.fromString=function(P,C){const M=d(P,a.isKanjiModeEnabled()),R=m(M),L=_(R,C),B=c.find_path(L.map,"start","end"),F=[];for(let T=1;T<B.length-1;T++)F.push(L.table[B[T]].node);return t.fromArray(y(F))},t.rawSplit=function(P){return t.fromArray(d(P,a.isKanjiModeEnabled()))}}(bw);const Eu=xr,f0=mu,Nz=pz,Bz=gz,Lz=sw,Fz=ow,p0=cw,g0=vu,Uz=mz,$u=hw,jz=fw,qz=En,b0=bw;function zz(t,e){const r=t.size,i=Fz.getPositions(e);for(let n=0;n<i.length;n++){const s=i[n][0],o=i[n][1];for(let a=-1;a<=7;a++)if(!(s+a<=-1||r<=s+a))for(let c=-1;c<=7;c++)o+c<=-1||r<=o+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?t.set(s+a,o+c,!0,!0):t.set(s+a,o+c,!1,!0))}}function kz(t){const e=t.size;for(let r=8;r<e-8;r++){const i=r%2===0;t.set(r,6,i,!0),t.set(6,r,i,!0)}}function Hz(t,e){const r=Lz.getPositions(e);for(let i=0;i<r.length;i++){const n=r[i][0],s=r[i][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?t.set(n+o,s+a,!0,!0):t.set(n+o,s+a,!1,!0)}}function Wz(t,e){const r=t.size,i=$u.getEncodedBits(e);let n,s,o;for(let a=0;a<18;a++)n=Math.floor(a/3),s=a%3+r-8-3,o=(i>>a&1)===1,t.set(n,s,o,!0),t.set(s,n,o,!0)}function m0(t,e,r){const i=t.size,n=jz.getEncodedBits(e,r);let s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?t.set(s,8,o,!0):s<8?t.set(s+1,8,o,!0):t.set(i-15+s,8,o,!0),s<8?t.set(8,i-s-1,o,!0):s<9?t.set(8,15-s-1+1,o,!0):t.set(8,15-s-1,o,!0);t.set(i-8,8,1,!0)}function Vz(t,e){const r=t.size;let i=-1,n=r-1,s=7,o=0;for(let a=r-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!t.isReserved(n,a-c)){let l=!1;o<e.length&&(l=(e[o]>>>s&1)===1),t.set(n,a-c,l),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||r<=n){n-=i,i=-i;break}}}function Kz(t,e,r){const i=new Nz;r.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),qz.getCharCountIndicator(c.mode,t)),c.write(i)});const n=Eu.getSymbolTotalCodewords(t),s=g0.getTotalCodewordsCount(t,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);const a=(o-i.getLengthInBits())/8;for(let c=0;c<a;c++)i.put(c%2?17:236,8);return Gz(i,t,e)}function Gz(t,e,r){const i=Eu.getSymbolTotalCodewords(e),n=g0.getTotalCodewordsCount(e,r),s=i-n,o=g0.getBlocksCount(e,r),a=i%o,c=o-a,l=Math.floor(i/o),u=Math.floor(s/o),d=u+1,p=l-u,y=new Uz(p);let m=0;const _=new Array(o),S=new Array(o);let E=0;const P=new Uint8Array(t.buffer);for(let B=0;B<o;B++){const F=B<c?u:d;_[B]=P.slice(m,m+F),S[B]=y.encode(_[B]),m+=F,E=Math.max(E,F)}const C=new Uint8Array(i);let M=0,R,L;for(R=0;R<E;R++)for(L=0;L<o;L++)R<_[L].length&&(C[M++]=_[L][R]);for(R=0;R<p;R++)for(L=0;L<o;L++)C[M++]=S[L][R];return C}function Zz(t,e,r,i){let n;if(Array.isArray(t))n=b0.fromArray(t);else if(typeof t=="string"){let l=e;if(!l){const u=b0.rawSplit(t);l=$u.getBestVersionForData(u,r)}n=b0.fromString(t,l||40)}else throw new Error("Invalid data");const s=$u.getBestVersionForData(n,r);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=s;else if(e<s)throw new Error(`
|
|
94
90
|
The chosen QR Code version cannot contain this amount of data.
|
|
95
91
|
Minimum version required to store current data is: `+s+`.
|
|
96
|
-
`);const o=
|
|
97
|
-
`;return typeof i=="function"&&i(null,x),x};const lq=EU,Jd=Y2,gy=uy,hq=dy;function Zd(t,e,r,i,n){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!lq())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=r,r=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=r,r=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(r=e,e=i=void 0):o===2&&!e.getContext&&(i=r,r=e,e=void 0),new Promise(function(c,l){try{const u=Jd.create(r,i);c(t(u,e,i))}catch(u){l(u)}})}try{const c=Jd.create(r,i);n(null,t(c,e,i))}catch(c){n(c)}}pc.create=Jd.create,pc.toCanvas=Zd.bind(null,gy.render),pc.toDataURL=Zd.bind(null,gy.renderToDataURL),pc.toString=Zd.bind(null,function(t,e,r){return hq.render(t,r)});var fq=Object.defineProperty,vy=Object.getOwnPropertySymbols,uq=Object.prototype.hasOwnProperty,dq=Object.prototype.propertyIsEnumerable,my=(t,e,r)=>e in t?fq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yd=(t,e)=>{for(var r in e||(e={}))uq.call(e,r)&&my(t,r,e[r]);if(vy)for(var r of vy(e))dq.call(e,r)&&my(t,r,e[r]);return t};function pq(){var t;const e=(t=Qn.state.themeMode)!=null?t:"dark",i={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[e];return{"--wcm-color-fg-1":i.foreground[1],"--wcm-color-fg-2":i.foreground[2],"--wcm-color-fg-3":i.foreground[3],"--wcm-color-bg-1":i.background[1],"--wcm-color-bg-2":i.background[2],"--wcm-color-bg-3":i.background[3],"--wcm-color-overlay":i.overlay}}function by(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const Fe={getPreset(t){return by()[t]},setTheme(){const t=document.querySelector(":root"),{themeVariables:e}=Qn.state;if(t){const r=Yd(Yd(Yd({},pq()),by()),e);Object.entries(r).forEach(([i,n])=>t.style.setProperty(i,n))}},globalCss:it`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},gq=it`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var vq=Object.defineProperty,mq=Object.getOwnPropertyDescriptor,sa=(t,e,r,i)=>{for(var n=i>1?void 0:i?mq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&vq(e,r,n),n};let ss=class extends Pe{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const t={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let e="inverse";return this.variant==="ghost"&&(e="secondary"),this.variant==="outline"&&(e="accent"),te`<button class="${wn(t)}" ?disabled="${this.disabled}" @click="${this.onClick}">${this.iconLeft}<wcm-text variant="small-regular" color="${e}"><slot></slot></wcm-text>${this.iconRight}</button>`}};ss.styles=[Fe.globalCss,gq],sa([$e({type:Boolean})],ss.prototype,"disabled",2),sa([$e()],ss.prototype,"iconLeft",2),sa([$e()],ss.prototype,"iconRight",2),sa([$e()],ss.prototype,"onClick",2),sa([$e()],ss.prototype,"variant",2),ss=sa([Le("wcm-button")],ss);const bq=it`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var yq=Object.defineProperty,wq=Object.getOwnPropertyDescriptor,Xd=(t,e,r,i)=>{for(var n=i>1?void 0:i?wq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&yq(e,r,n),n};let bc=class extends Pe{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const t={"wcm-secondary":this.variant==="secondary"};return te`<button ?disabled="${this.disabled}" class="${wn(t)}"><slot></slot></button>`}};bc.styles=[Fe.globalCss,bq],Xd([$e({type:Boolean})],bc.prototype,"disabled",2),Xd([$e()],bc.prototype,"variant",2),bc=Xd([Le("wcm-button-big")],bc);const _q=it`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var xq=Object.defineProperty,Eq=Object.getOwnPropertyDescriptor,$q=(t,e,r,i)=>{for(var n=i>1?void 0:i?Eq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&xq(e,r,n),n};let Qd=class extends Pe{render(){return te`<div><slot></slot></div>`}};Qd.styles=[Fe.globalCss,_q],Qd=$q([Le("wcm-info-footer")],Qd);const ht={CROSS_ICON:Nt`<svg width="12" height="12" viewBox="0 0 12 12"><path d="M9.94 11A.75.75 0 1 0 11 9.94L7.414 6.353a.5.5 0 0 1 0-.708L11 2.061A.75.75 0 1 0 9.94 1L6.353 4.586a.5.5 0 0 1-.708 0L2.061 1A.75.75 0 0 0 1 2.06l3.586 3.586a.5.5 0 0 1 0 .708L1 9.939A.75.75 0 1 0 2.06 11l3.586-3.586a.5.5 0 0 1 .708 0L9.939 11Z" fill="#fff"/></svg>`,WALLET_CONNECT_LOGO:Nt`<svg width="178" height="29" viewBox="0 0 178 29" id="wcm-wc-logo"><path d="M10.683 7.926c5.284-5.17 13.85-5.17 19.134 0l.636.623a.652.652 0 0 1 0 .936l-2.176 2.129a.343.343 0 0 1-.478 0l-.875-.857c-3.686-3.607-9.662-3.607-13.348 0l-.937.918a.343.343 0 0 1-.479 0l-2.175-2.13a.652.652 0 0 1 0-.936l.698-.683Zm23.633 4.403 1.935 1.895a.652.652 0 0 1 0 .936l-8.73 8.543a.687.687 0 0 1-.956 0L20.37 17.64a.172.172 0 0 0-.239 0l-6.195 6.063a.687.687 0 0 1-.957 0l-8.73-8.543a.652.652 0 0 1 0-.936l1.936-1.895a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .239 0l6.195-6.064a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .24 0l6.195-6.064a.687.687 0 0 1 .956 0ZM48.093 20.948l2.338-9.355c.139-.515.258-1.07.416-1.942.12.872.258 1.427.357 1.942l2.022 9.355h4.181l3.528-13.874h-3.21l-1.943 8.523a24.825 24.825 0 0 0-.456 2.457c-.158-.931-.317-1.625-.495-2.438l-1.883-8.542h-4.201l-2.042 8.542a41.204 41.204 0 0 0-.475 2.438 41.208 41.208 0 0 0-.476-2.438l-1.903-8.542h-3.349l3.508 13.874h4.083ZM63.33 21.304c1.585 0 2.596-.654 3.11-1.605-.059.297-.078.595-.078.892v.357h2.655V15.22c0-2.735-1.248-4.32-4.3-4.32-2.636 0-4.36 1.466-4.52 3.487h2.914c.1-.891.734-1.426 1.705-1.426.911 0 1.407.515 1.407 1.11 0 .435-.258.693-1.03.792l-1.388.159c-2.061.257-3.825 1.01-3.825 3.19 0 1.982 1.645 3.092 3.35 3.092Zm.891-2.041c-.773 0-1.348-.436-1.348-1.19 0-.733.655-1.09 1.645-1.268l.674-.119c.575-.118.892-.218 1.09-.396v.912c0 1.228-.892 2.06-2.06 2.06ZM70.398 7.074v13.874h2.874V7.074h-2.874ZM74.934 7.074v13.874h2.874V7.074h-2.874ZM84.08 21.304c2.735 0 4.5-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922H81.92ZM94.92 21.146c.633 0 1.248-.1 1.525-.179v-2.18c-.218.04-.475.06-.693.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.338v-2.24h-2.338V7.788H91.47v3.448H89.37v2.24h2.1v4.201c0 2.3 1.15 3.469 3.45 3.469ZM104.62 21.304c3.924 0 6.302-2.299 6.599-5.608h-3.111c-.238 1.803-1.506 3.032-3.369 3.032-2.2 0-3.746-1.784-3.746-4.796 0-2.953 1.605-4.638 3.805-4.638 1.883 0 2.953 1.15 3.171 2.834h3.191c-.317-3.448-2.854-5.41-6.342-5.41-3.984 0-7.036 2.695-7.036 7.214 0 4.677 2.676 7.372 6.838 7.372ZM117.449 21.304c2.993 0 5.114-1.882 5.114-5.172 0-3.23-2.121-5.233-5.114-5.233-2.972 0-5.093 2.002-5.093 5.233 0 3.29 2.101 5.172 5.093 5.172Zm0-2.22c-1.327 0-2.18-1.09-2.18-2.952 0-1.903.892-2.973 2.18-2.973 1.308 0 2.2 1.07 2.2 2.973 0 1.862-.872 2.953-2.2 2.953ZM126.569 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.229-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM137.464 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.228-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM149.949 21.304c2.735 0 4.499-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922h-3.984ZM160.876 21.304c3.013 0 4.658-1.645 4.975-4.201h-2.874c-.099 1.07-.713 1.982-2.001 1.982-1.309 0-2.2-1.21-2.2-2.993 0-1.942 1.03-2.933 2.259-2.933 1.209 0 1.803.872 1.883 1.882h2.873c-.218-2.358-1.823-4.142-4.776-4.142-2.874 0-5.153 1.903-5.153 5.193 0 3.25 1.923 5.212 5.014 5.212ZM172.067 21.146c.634 0 1.248-.1 1.526-.179v-2.18c-.218.04-.476.06-.694.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.339v-2.24h-2.339V7.788h-2.854v3.448h-2.1v2.24h2.1v4.201c0 2.3 1.15 3.469 3.449 3.469Z" fill="#fff"/></svg>`,WALLET_CONNECT_ICON:Nt`<svg width="28" height="20" viewBox="0 0 28 20"><g clip-path="url(#a)"><path d="M7.386 6.482c3.653-3.576 9.575-3.576 13.228 0l.44.43a.451.451 0 0 1 0 .648L19.55 9.033a.237.237 0 0 1-.33 0l-.606-.592c-2.548-2.496-6.68-2.496-9.228 0l-.648.634a.237.237 0 0 1-.33 0L6.902 7.602a.451.451 0 0 1 0-.647l.483-.473Zm16.338 3.046 1.339 1.31a.451.451 0 0 1 0 .648l-6.035 5.909a.475.475 0 0 1-.662 0L14.083 13.2a.119.119 0 0 0-.166 0l-4.283 4.194a.475.475 0 0 1-.662 0l-6.035-5.91a.451.451 0 0 1 0-.647l1.338-1.31a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0Z" fill="#000000"/></g><defs><clipPath id="a"><path fill="#ffffff" d="M0 0h28v20H0z"/></clipPath></defs></svg>`,WALLET_CONNECT_ICON_COLORED:Nt`<svg width="96" height="96" fill="none"><path fill="#fff" d="M25.322 33.597c12.525-12.263 32.83-12.263 45.355 0l1.507 1.476a1.547 1.547 0 0 1 0 2.22l-5.156 5.048a.814.814 0 0 1-1.134 0l-2.074-2.03c-8.737-8.555-22.903-8.555-31.64 0l-2.222 2.175a.814.814 0 0 1-1.134 0l-5.156-5.049a1.547 1.547 0 0 1 0-2.22l1.654-1.62Zm56.019 10.44 4.589 4.494a1.547 1.547 0 0 1 0 2.22l-20.693 20.26a1.628 1.628 0 0 1-2.267 0L48.283 56.632a.407.407 0 0 0-.567 0L33.03 71.012a1.628 1.628 0 0 1-2.268 0L10.07 50.75a1.547 1.547 0 0 1 0-2.22l4.59-4.494a1.628 1.628 0 0 1 2.267 0l14.687 14.38c.156.153.41.153.567 0l14.685-14.38a1.628 1.628 0 0 1 2.268 0l14.687 14.38c.156.153.41.153.567 0l14.686-14.38a1.628 1.628 0 0 1 2.268 0Z"/><path stroke="#000" d="M25.672 33.954c12.33-12.072 32.325-12.072 44.655 0l1.508 1.476a1.047 1.047 0 0 1 0 1.506l-5.157 5.048a.314.314 0 0 1-.434 0l-2.074-2.03c-8.932-8.746-23.409-8.746-32.34 0l-2.222 2.174a.314.314 0 0 1-.434 0l-5.157-5.048a1.047 1.047 0 0 1 0-1.506l1.655-1.62Zm55.319 10.44 4.59 4.494a1.047 1.047 0 0 1 0 1.506l-20.694 20.26a1.128 1.128 0 0 1-1.568 0l-14.686-14.38a.907.907 0 0 0-1.267 0L32.68 70.655a1.128 1.128 0 0 1-1.568 0L10.42 50.394a1.047 1.047 0 0 1 0-1.506l4.59-4.493a1.128 1.128 0 0 1 1.567 0l14.687 14.379a.907.907 0 0 0 1.266 0l-.35-.357.35.357 14.686-14.38a1.128 1.128 0 0 1 1.568 0l14.687 14.38a.907.907 0 0 0 1.267 0l14.686-14.38a1.128 1.128 0 0 1 1.568 0Z"/></svg>`,BACK_ICON:Nt`<svg width="10" height="18" viewBox="0 0 10 18"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.735.179a.75.75 0 0 1 .087 1.057L2.92 8.192a1.25 1.25 0 0 0 0 1.617l5.902 6.956a.75.75 0 1 1-1.144.97L1.776 10.78a2.75 2.75 0 0 1 0-3.559L7.678.265A.75.75 0 0 1 8.735.18Z" fill="#fff"/></svg>`,COPY_ICON:Nt`<svg width="24" height="24" fill="none"><path fill="#fff" fill-rule="evenodd" d="M7.01 7.01c.03-1.545.138-2.5.535-3.28A5 5 0 0 1 9.73 1.545C10.8 1 12.2 1 15 1c2.8 0 4.2 0 5.27.545a5 5 0 0 1 2.185 2.185C23 4.8 23 6.2 23 9c0 2.8 0 4.2-.545 5.27a5 5 0 0 1-2.185 2.185c-.78.397-1.735.505-3.28.534l-.001.01c-.03 1.54-.138 2.493-.534 3.27a5 5 0 0 1-2.185 2.186C13.2 23 11.8 23 9 23c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C1 19.2 1 17.8 1 15c0-2.8 0-4.2.545-5.27A5 5 0 0 1 3.73 7.545C4.508 7.149 5.46 7.04 7 7.01h.01ZM15 15.5c-1.425 0-2.403-.001-3.162-.063-.74-.06-1.139-.172-1.427-.319a3.5 3.5 0 0 1-1.53-1.529c-.146-.288-.257-.686-.318-1.427C8.501 11.403 8.5 10.425 8.5 9c0-1.425.001-2.403.063-3.162.06-.74.172-1.139.318-1.427a3.5 3.5 0 0 1 1.53-1.53c.288-.146.686-.257 1.427-.318.759-.062 1.737-.063 3.162-.063 1.425 0 2.403.001 3.162.063.74.06 1.139.172 1.427.318a3.5 3.5 0 0 1 1.53 1.53c.146.288.257.686.318 1.427.062.759.063 1.737.063 3.162 0 1.425-.001 2.403-.063 3.162-.06.74-.172 1.139-.319 1.427a3.5 3.5 0 0 1-1.529 1.53c-.288.146-.686.257-1.427.318-.759.062-1.737.063-3.162.063ZM7 8.511c-.444.009-.825.025-1.162.052-.74.06-1.139.172-1.427.318a3.5 3.5 0 0 0-1.53 1.53c-.146.288-.257.686-.318 1.427-.062.759-.063 1.737-.063 3.162 0 1.425.001 2.403.063 3.162.06.74.172 1.139.318 1.427a3.5 3.5 0 0 0 1.53 1.53c.288.146.686.257 1.427.318.759.062 1.737.063 3.162.063 1.425 0 2.403-.001 3.162-.063.74-.06 1.139-.172 1.427-.319a3.5 3.5 0 0 0 1.53-1.53c.146-.287.257-.685.318-1.426.027-.337.043-.718.052-1.162H15c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C7 13.2 7 11.8 7 9v-.489Z" clip-rule="evenodd"/></svg>`,RETRY_ICON:Nt`<svg width="15" height="16" viewBox="0 0 15 16"><path d="M6.464 2.03A.75.75 0 0 0 5.403.97L2.08 4.293a1 1 0 0 0 0 1.414L5.403 9.03a.75.75 0 0 0 1.06-1.06L4.672 6.177a.25.25 0 0 1 .177-.427h2.085a4 4 0 1 1-3.93 4.746c-.077-.407-.405-.746-.82-.746-.414 0-.755.338-.7.748a5.501 5.501 0 1 0 5.45-6.248H4.848a.25.25 0 0 1-.177-.427L6.464 2.03Z" fill="#fff"/></svg>`,DESKTOP_ICON:Nt`<svg width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 5.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C2.204 1 3.13 1 4.98 1h6.04c1.85 0 2.775 0 3.466.394a3 3 0 0 1 1.12 1.12C16 3.204 16 4.13 16 5.98v1.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C13.796 12 12.87 12 11.02 12H4.98c-1.85 0-2.775 0-3.466-.394a3 3 0 0 1-1.12-1.12C0 9.796 0 8.87 0 7.02V5.98ZM4.98 2.5h6.04c.953 0 1.568.001 2.034.043.446.04.608.108.69.154a1.5 1.5 0 0 1 .559.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033v1.04c0 .952-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.046-.243.114-.69.154-.466.042-1.08.043-2.033.043H4.98c-.952 0-1.568-.001-2.034-.043-.446-.04-.608-.108-.69-.154a1.5 1.5 0 0 1-.559-.56c-.046-.08-.114-.243-.154-.69-.042-.465-.043-1.08-.043-2.033V5.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.046.243-.114.69-.154.465-.042 1.08-.043 2.033-.043Z" fill="#fff"/><path d="M4 14.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,MOBILE_ICON:Nt`<svg width="16" height="16" viewBox="0 0 16 16"><path d="M6.75 5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3 4.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C5.204 0 6.136 0 8 0s2.795 0 3.486.394a3 3 0 0 1 1.12 1.12C13 2.204 13 3.13 13 4.98v6.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C10.796 16 9.864 16 8 16s-2.795 0-3.486-.394a3 3 0 0 1-1.12-1.12C3 13.796 3 12.87 3 11.02V4.98Zm8.5 0v6.04c0 .953-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.045-.242.113-.693.154-.47.042-1.091.043-2.05.043-.959 0-1.58-.001-2.05-.043-.45-.04-.613-.109-.693-.154a1.5 1.5 0 0 1-.56-.56c-.046-.08-.114-.243-.154-.69-.042-.466-.043-1.08-.043-2.033V4.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.045.243-.113.693-.154C6.42 1.501 7.041 1.5 8 1.5c.959 0 1.58.001 2.05.043.45.04.613.109.693.154a1.5 1.5 0 0 1 .56.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033Z" fill="#fff"/></svg>`,ARROW_DOWN_ICON:Nt`<svg width="14" height="14" viewBox="0 0 14 14"><path d="M2.28 7.47a.75.75 0 0 0-1.06 1.06l5.25 5.25a.75.75 0 0 0 1.06 0l5.25-5.25a.75.75 0 0 0-1.06-1.06l-3.544 3.543a.25.25 0 0 1-.426-.177V.75a.75.75 0 0 0-1.5 0v10.086a.25.25 0 0 1-.427.176L2.28 7.47Z" fill="#fff"/></svg>`,ARROW_UP_RIGHT_ICON:Nt`<svg width="15" height="14" fill="none"><path d="M4.5 1.75A.75.75 0 0 1 5.25 1H12a1.5 1.5 0 0 1 1.5 1.5v6.75a.75.75 0 0 1-1.5 0V4.164a.25.25 0 0 0-.427-.176L4.061 11.5A.75.75 0 0 1 3 10.44l7.513-7.513a.25.25 0 0 0-.177-.427H5.25a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,ARROW_RIGHT_ICON:Nt`<svg width="6" height="14" viewBox="0 0 6 14"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.181 1.099a.75.75 0 0 1 1.024.279l2.433 4.258a2.75 2.75 0 0 1 0 2.729l-2.433 4.257a.75.75 0 1 1-1.303-.744L4.335 7.62a1.25 1.25 0 0 0 0-1.24L1.902 2.122a.75.75 0 0 1 .28-1.023Z" fill="#fff"/></svg>`,QRCODE_ICON:Nt`<svg width="25" height="24" viewBox="0 0 25 24"><path d="M23.748 9a.748.748 0 0 0 .748-.752c-.018-2.596-.128-4.07-.784-5.22a6 6 0 0 0-2.24-2.24c-1.15-.656-2.624-.766-5.22-.784a.748.748 0 0 0-.752.748c0 .414.335.749.748.752 1.015.007 1.82.028 2.494.088.995.09 1.561.256 1.988.5.7.398 1.28.978 1.679 1.678.243.427.41.993.498 1.988.061.675.082 1.479.09 2.493a.753.753 0 0 0 .75.749ZM3.527.788C4.677.132 6.152.022 8.747.004A.748.748 0 0 1 9.5.752a.753.753 0 0 1-.749.752c-1.014.007-1.818.028-2.493.088-.995.09-1.561.256-1.988.5-.7.398-1.28.978-1.679 1.678-.243.427-.41.993-.499 1.988-.06.675-.081 1.479-.088 2.493A.753.753 0 0 1 1.252 9a.748.748 0 0 1-.748-.752c.018-2.596.128-4.07.784-5.22a6 6 0 0 1 2.24-2.24ZM1.252 15a.748.748 0 0 0-.748.752c.018 2.596.128 4.07.784 5.22a6 6 0 0 0 2.24 2.24c1.15.656 2.624.766 5.22.784a.748.748 0 0 0 .752-.748.753.753 0 0 0-.749-.752c-1.014-.007-1.818-.028-2.493-.089-.995-.089-1.561-.255-1.988-.498a4.5 4.5 0 0 1-1.679-1.68c-.243-.426-.41-.992-.499-1.987-.06-.675-.081-1.479-.088-2.493A.753.753 0 0 0 1.252 15ZM22.996 15.749a.753.753 0 0 1 .752-.749c.415 0 .751.338.748.752-.018 2.596-.128 4.07-.784 5.22a6 6 0 0 1-2.24 2.24c-1.15.656-2.624.766-5.22.784a.748.748 0 0 1-.752-.748c0-.414.335-.749.748-.752 1.015-.007 1.82-.028 2.494-.089.995-.089 1.561-.255 1.988-.498a4.5 4.5 0 0 0 1.679-1.68c.243-.426.41-.992.498-1.987.061-.675.082-1.479.09-2.493Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 4a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 11h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 4H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1ZM13.5 6.5A2.5 2.5 0 0 1 16 4h2a2.5 2.5 0 0 1 2.5 2.5v2A2.5 2.5 0 0 1 18 11h-2a2.5 2.5 0 0 1-2.5-2.5v-2Zm2.5-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1ZM7 13a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 20h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 13H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1Z" fill="#fff"/><path d="M13.5 15.5c0-.465 0-.697.038-.89a2 2 0 0 1 1.572-1.572C15.303 13 15.535 13 16 13v2.5h-2.5ZM18 13c.465 0 .697 0 .89.038a2 2 0 0 1 1.572 1.572c.038.193.038.425.038.89H18V13ZM18 17.5h2.5c0 .465 0 .697-.038.89a2 2 0 0 1-1.572 1.572C18.697 20 18.465 20 18 20v-2.5ZM13.5 17.5H16V20c-.465 0-.697 0-.89-.038a2 2 0 0 1-1.572-1.572c-.038-.193-.038-.425-.038-.89Z" fill="#fff"/></svg>`,SCAN_ICON:Nt`<svg width="16" height="16" fill="none"><path fill="#fff" d="M10 15.216c0 .422.347.763.768.74 1.202-.064 2.025-.222 2.71-.613a5.001 5.001 0 0 0 1.865-1.866c.39-.684.549-1.507.613-2.709a.735.735 0 0 0-.74-.768.768.768 0 0 0-.76.732c-.009.157-.02.306-.032.447-.073.812-.206 1.244-.384 1.555-.31.545-.761.996-1.306 1.306-.311.178-.743.311-1.555.384-.141.013-.29.023-.447.032a.768.768 0 0 0-.732.76ZM10 .784c0 .407.325.737.732.76.157.009.306.02.447.032.812.073 1.244.206 1.555.384a3.5 3.5 0 0 1 1.306 1.306c.178.311.311.743.384 1.555.013.142.023.29.032.447a.768.768 0 0 0 .76.732.734.734 0 0 0 .74-.768c-.064-1.202-.222-2.025-.613-2.71A5 5 0 0 0 13.477.658c-.684-.39-1.507-.549-2.709-.613a.735.735 0 0 0-.768.74ZM5.232.044A.735.735 0 0 1 6 .784a.768.768 0 0 1-.732.76c-.157.009-.305.02-.447.032-.812.073-1.244.206-1.555.384A3.5 3.5 0 0 0 1.96 3.266c-.178.311-.311.743-.384 1.555-.013.142-.023.29-.032.447A.768.768 0 0 1 .784 6a.735.735 0 0 1-.74-.768c.064-1.202.222-2.025.613-2.71A5 5 0 0 1 2.523.658C3.207.267 4.03.108 5.233.044ZM5.268 14.456a.768.768 0 0 1 .732.76.734.734 0 0 1-.768.74c-1.202-.064-2.025-.222-2.71-.613a5 5 0 0 1-1.865-1.866c-.39-.684-.549-1.507-.613-2.709A.735.735 0 0 1 .784 10c.407 0 .737.325.76.732.009.157.02.306.032.447.073.812.206 1.244.384 1.555a3.5 3.5 0 0 0 1.306 1.306c.311.178.743.311 1.555.384.142.013.29.023.447.032Z"/></svg>`,CHECKMARK_ICON:Nt`<svg width="13" height="12" viewBox="0 0 13 12"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.155.132a.75.75 0 0 1 .232 1.035L5.821 11.535a1 1 0 0 1-1.626.09L.665 7.21a.75.75 0 1 1 1.17-.937L4.71 9.867a.25.25 0 0 0 .406-.023L11.12.364a.75.75 0 0 1 1.035-.232Z" fill="#fff"/></svg>`,SEARCH_ICON:Nt`<svg width="20" height="21"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.432 13.992c-.354-.353-.91-.382-1.35-.146a5.5 5.5 0 1 1 2.265-2.265c-.237.441-.208.997.145 1.35l3.296 3.296a.75.75 0 1 1-1.06 1.061l-3.296-3.296Zm.06-5a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z" fill="#949E9E"/></svg>`,WALLET_PLACEHOLDER:Nt`<svg width="60" height="60" fill="none" viewBox="0 0 60 60"><g clip-path="url(#q)"><path id="wallet-placeholder-fill" fill="#fff" d="M0 24.9c0-9.251 0-13.877 1.97-17.332a15 15 0 0 1 5.598-5.597C11.023 0 15.648 0 24.9 0h10.2c9.252 0 13.877 0 17.332 1.97a15 15 0 0 1 5.597 5.598C60 11.023 60 15.648 60 24.9v10.2c0 9.252 0 13.877-1.97 17.332a15.001 15.001 0 0 1-5.598 5.597C48.977 60 44.352 60 35.1 60H24.9c-9.251 0-13.877 0-17.332-1.97a15 15 0 0 1-5.597-5.598C0 48.977 0 44.352 0 35.1V24.9Z"/><path id="wallet-placeholder-dash" stroke="#000" stroke-dasharray="4 4" stroke-width="1.5" d="M.04 41.708a231.598 231.598 0 0 1-.039-4.403l.75-.001L.75 35.1v-2.55H0v-5.1h.75V24.9l.001-2.204h-.75c.003-1.617.011-3.077.039-4.404l.75.016c.034-1.65.099-3.08.218-4.343l-.746-.07c.158-1.678.412-3.083.82-4.316l.713.236c.224-.679.497-1.296.827-1.875a14.25 14.25 0 0 1 1.05-1.585L3.076 5.9A15 15 0 0 1 5.9 3.076l.455.596a14.25 14.25 0 0 1 1.585-1.05c.579-.33 1.196-.603 1.875-.827l-.236-.712C10.812.674 12.217.42 13.895.262l.07.746C15.23.89 16.66.824 18.308.79l-.016-.75C19.62.012 21.08.004 22.695.001l.001.75L24.9.75h2.55V0h5.1v.75h2.55l2.204.001v-.75c1.617.003 3.077.011 4.404.039l-.016.75c1.65.034 3.08.099 4.343.218l.07-.746c1.678.158 3.083.412 4.316.82l-.236.713c.679.224 1.296.497 1.875.827a14.24 14.24 0 0 1 1.585 1.05l.455-.596A14.999 14.999 0 0 1 56.924 5.9l-.596.455c.384.502.735 1.032 1.05 1.585.33.579.602 1.196.827 1.875l.712-.236c.409 1.233.663 2.638.822 4.316l-.747.07c.119 1.264.184 2.694.218 4.343l.75-.016c.028 1.327.036 2.787.039 4.403l-.75.001.001 2.204v2.55H60v5.1h-.75v2.55l-.001 2.204h.75a231.431 231.431 0 0 1-.039 4.404l-.75-.016c-.034 1.65-.099 3.08-.218 4.343l.747.07c-.159 1.678-.413 3.083-.822 4.316l-.712-.236a10.255 10.255 0 0 1-.827 1.875 14.242 14.242 0 0 1-1.05 1.585l.596.455a14.997 14.997 0 0 1-2.824 2.824l-.455-.596c-.502.384-1.032.735-1.585 1.05-.579.33-1.196.602-1.875.827l.236.712c-1.233.409-2.638.663-4.316.822l-.07-.747c-1.264.119-2.694.184-4.343.218l.016.75c-1.327.028-2.787.036-4.403.039l-.001-.75-2.204.001h-2.55V60h-5.1v-.75H24.9l-2.204-.001v.75a231.431 231.431 0 0 1-4.404-.039l.016-.75c-1.65-.034-3.08-.099-4.343-.218l-.07.747c-1.678-.159-3.083-.413-4.316-.822l.236-.712a10.258 10.258 0 0 1-1.875-.827 14.252 14.252 0 0 1-1.585-1.05l-.455.596A14.999 14.999 0 0 1 3.076 54.1l.596-.455a14.24 14.24 0 0 1-1.05-1.585 10.259 10.259 0 0 1-.827-1.875l-.712.236C.674 49.188.42 47.783.262 46.105l.746-.07C.89 44.77.824 43.34.79 41.692l-.75.016Z"/><path fill="#fff" fill-rule="evenodd" d="M35.643 32.145c-.297-.743-.445-1.114-.401-1.275a.42.42 0 0 1 .182-.27c.134-.1.463-.1 1.123-.1.742 0 1.499.046 2.236-.05a6 6 0 0 0 5.166-5.166c.051-.39.051-.855.051-1.784 0-.928 0-1.393-.051-1.783a6 6 0 0 0-5.166-5.165c-.39-.052-.854-.052-1.783-.052h-7.72c-4.934 0-7.401 0-9.244 1.051a8 8 0 0 0-2.985 2.986C16.057 22.28 16.003 24.58 16 29 15.998 31.075 16 33.15 16 35.224A7.778 7.778 0 0 0 23.778 43H28.5c1.394 0 2.09 0 2.67-.116a6 6 0 0 0 4.715-4.714c.115-.58.115-1.301.115-2.744 0-1.31 0-1.964-.114-2.49a4.998 4.998 0 0 0-.243-.792Z" clip-rule="evenodd"/><path fill="#9EA9A9" fill-rule="evenodd" d="M37 18h-7.72c-2.494 0-4.266.002-5.647.126-1.361.122-2.197.354-2.854.728a6.5 6.5 0 0 0-2.425 2.426c-.375.657-.607 1.492-.729 2.853-.11 1.233-.123 2.777-.125 4.867 0 .7 0 1.05.097 1.181.096.13.182.181.343.2.163.02.518-.18 1.229-.581a6.195 6.195 0 0 1 3.053-.8H37c.977 0 1.32-.003 1.587-.038a4.5 4.5 0 0 0 3.874-3.874c.036-.268.039-.611.039-1.588 0-.976-.003-1.319-.038-1.587a4.5 4.5 0 0 0-3.875-3.874C38.32 18.004 37.977 18 37 18Zm-7.364 12.5h-7.414a4.722 4.722 0 0 0-4.722 4.723 6.278 6.278 0 0 0 6.278 6.278H28.5c1.466 0 1.98-.008 2.378-.087a4.5 4.5 0 0 0 3.535-3.536c.08-.397.087-.933.087-2.451 0-1.391-.009-1.843-.08-2.17a3.5 3.5 0 0 0-2.676-2.676c-.328-.072-.762-.08-2.108-.08Z" clip-rule="evenodd"/></g><defs><clipPath id="q"><path fill="#fff" d="M0 0h60v60H0z"/></clipPath></defs></svg>`,GLOBE_ICON:Nt`<svg width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="#fff" fill-rule="evenodd" d="M15.5 8a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Zm-2.113.75c.301 0 .535.264.47.558a6.01 6.01 0 0 1-2.867 3.896c-.203.116-.42-.103-.334-.32.409-1.018.691-2.274.797-3.657a.512.512 0 0 1 .507-.477h1.427Zm.47-2.058c.065.294-.169.558-.47.558H11.96a.512.512 0 0 1-.507-.477c-.106-1.383-.389-2.638-.797-3.656-.087-.217.13-.437.333-.32a6.01 6.01 0 0 1 2.868 3.895Zm-4.402.558c.286 0 .515-.24.49-.525-.121-1.361-.429-2.534-.83-3.393-.279-.6-.549-.93-.753-1.112a.535.535 0 0 0-.724 0c-.204.182-.474.513-.754 1.112-.4.859-.708 2.032-.828 3.393a.486.486 0 0 0 .49.525h2.909Zm-5.415 0c.267 0 .486-.21.507-.477.106-1.383.389-2.638.797-3.656.087-.217-.13-.437-.333-.32a6.01 6.01 0 0 0-2.868 3.895c-.065.294.169.558.47.558H4.04ZM2.143 9.308c-.065-.294.169-.558.47-.558H4.04c.267 0 .486.21.507.477.106 1.383.389 2.639.797 3.657.087.217-.13.436-.333.32a6.01 6.01 0 0 1-2.868-3.896Zm3.913-.033a.486.486 0 0 1 .49-.525h2.909c.286 0 .515.24.49.525-.121 1.361-.428 2.535-.83 3.394-.279.6-.549.93-.753 1.112a.535.535 0 0 1-.724 0c-.204-.182-.474-.513-.754-1.112-.4-.859-.708-2.033-.828-3.394Z" clip-rule="evenodd"/></svg>`},Sq=it`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var Iq=Object.defineProperty,Aq=Object.getOwnPropertyDescriptor,Mq=(t,e,r,i)=>{for(var n=i>1?void 0:i?Aq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Iq(e,r,n),n};let e0=class extends Pe{render(){return te`<div class="wcm-toolbar-placeholder"></div><div class="wcm-toolbar">${ht.WALLET_CONNECT_LOGO} <button @click="${Bs.close}">${ht.CROSS_ICON}</button></div>`}};e0.styles=[Fe.globalCss,Sq],e0=Mq([Le("wcm-modal-backcard")],e0);const Pq=it`main{padding:20px;padding-top:0;width:100%}`;var Oq=Object.defineProperty,Cq=Object.getOwnPropertyDescriptor,Dq=(t,e,r,i)=>{for(var n=i>1?void 0:i?Cq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Oq(e,r,n),n};let t0=class extends Pe{render(){return te`<main><slot></slot></main>`}};t0.styles=[Fe.globalCss,Pq],t0=Dq([Le("wcm-modal-content")],t0);const Rq=it`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var Nq=Object.defineProperty,Tq=Object.getOwnPropertyDescriptor,Fq=(t,e,r,i)=>{for(var n=i>1?void 0:i?Tq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Nq(e,r,n),n};let r0=class extends Pe{render(){return te`<footer><slot></slot></footer>`}};r0.styles=[Fe.globalCss,Rq],r0=Fq([Le("wcm-modal-footer")],r0);const Lq=it`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var Bq=Object.defineProperty,Uq=Object.getOwnPropertyDescriptor,yc=(t,e,r,i)=>{for(var n=i>1?void 0:i?Uq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Bq(e,r,n),n};let Vs=class extends Pe{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return te`<button class="wcm-back-btn" @click="${Ot.goBack}">${ht.BACK_ICON}</button>`}actionBtnTemplate(){return te`<button class="wcm-action-btn" @click="${this.onAction}">${this.actionIcon}</button>`}render(){const t={"wcm-border":this.border},e=Ot.state.history.length>1,r=this.title?te`<wcm-text variant="big-bold">${this.title}</wcm-text>`:te`<slot></slot>`;return te`<header class="${wn(t)}">${e?this.backBtnTemplate():null} ${r} ${this.onAction?this.actionBtnTemplate():null}</header>`}};Vs.styles=[Fe.globalCss,Lq],yc([$e()],Vs.prototype,"title",2),yc([$e()],Vs.prototype,"onAction",2),yc([$e()],Vs.prototype,"actionIcon",2),yc([$e({type:Boolean})],Vs.prototype,"border",2),Vs=yc([Le("wcm-modal-header")],Vs);const xe={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(t,e){const r=t.renderRoot.querySelector(e);if(!r)throw new Error(`${e} not found`);return r},getWalletIcon({id:t,image_id:e}){const{walletImages:r}=ei.state;return r?.[t]?r[t]:e?Br.getWalletImageUrl(e):""},getWalletName(t,e=!1){return e&&t.length>8?`${t.substring(0,8)}..`:t},isMobileAnimation(){return window.innerWidth<=xe.MOBILE_BREAKPOINT},async preloadImage(t){const e=new Promise((r,i)=>{const n=new Image;n.onload=r,n.onerror=i,n.crossOrigin="anonymous",n.src=t});return Promise.race([e,se.wait(3e3)])},getErrorMessage(t){return t instanceof Error?t.message:"Unknown Error"},debounce(t,e=500){let r;return(...i)=>{function n(){t(...i)}r&&clearTimeout(r),r=setTimeout(n,e)}},handleMobileLinking(t,e="_self"){const{walletConnectUri:r}=qt.state,{mobile:i,name:n}=t,s=i?.native,o=i?.universal;xe.setRecentWallet(t);function a(c){if(s){const l=se.formatNativeUrl(s,c,n);se.openHref(l,e)}else if(o){const l=se.formatUniversalUrl(o,c,n);se.openHref(l,e)}}r&&a(r)},handleAndroidLinking(){const{walletConnectUri:t}=qt.state;t&&(se.setWalletConnectAndroidDeepLink(t),se.openHref(t,se.isTelegram()?"_blank":"_self"))},async handleUriCopy(){const{walletConnectUri:t}=qt.state;if(t)try{await navigator.clipboard.writeText(t),es.openToast("Link copied","success")}catch{es.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:t}=ei.state,e=Object.values(t??{});return Object.values(e)},truncate(t,e=8){return t.length<=e?t:`${t.substring(0,4)}...${t.substring(t.length-4)}`},setRecentWallet(t){try{localStorage.setItem(xe.WCM_RECENT_WALLET_DATA,JSON.stringify(t))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const t=localStorage.getItem(xe.WCM_RECENT_WALLET_DATA);return t?JSON.parse(t):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(t,e){return t.toUpperCase().includes(e.toUpperCase())},openWalletExplorerUrl(){se.openHref(xe.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:t,mobile:e}=se.getWalletRouterData(),r=!!t?.native,i=!!t?.universal,n=!!e?.native||!!e?.universal;return{isDesktop:r,isMobile:n,isWeb:i}},goToConnectingView(t){Ot.setData({Wallet:t});const e=se.isMobile(),{isDesktop:r,isWeb:i,isMobile:n}=xe.getCachedRouterWalletPlatforms();e?n?(Ot.push("MobileConnecting"),!se.isAndroid()&&se.isTelegram()&&this.handleMobileLinking(t,"_blank")):i?Ot.push("WebConnecting"):Ot.push("InstallWallet"):r?Ot.push("DesktopConnecting"):i?Ot.push("WebConnecting"):n?Ot.push("MobileQrcodeConnecting"):Ot.push("InstallWallet")}},qq=it`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var jq=Object.defineProperty,kq=Object.getOwnPropertyDescriptor,i0=(t,e,r,i)=>{for(var n=i>1?void 0:i?kq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&jq(e,r,n),n};let wc=class extends Pe{constructor(){super(),this.view=Ot.state.view,this.prevView=Ot.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=Ot.subscribe(t=>{this.view!==t.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([t])=>{const e=`${t.contentRect.height}px`;this.oldHeight!=="0px"&&Ws(this.routerEl,{height:[this.oldHeight,e]},{duration:.2}),this.oldHeight=e}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var t,e;(t=this.unsubscribe)==null||t.call(this),(e=this.resizeObserver)==null||e.disconnect()}get routerEl(){return xe.getShadowRootElement(this,".wcm-router")}get contentEl(){return xe.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return te`<wcm-connect-wallet-view></wcm-connect-wallet-view>`;case"DesktopConnecting":return te`<wcm-desktop-connecting-view></wcm-desktop-connecting-view>`;case"MobileConnecting":return te`<wcm-mobile-connecting-view></wcm-mobile-connecting-view>`;case"WebConnecting":return te`<wcm-web-connecting-view></wcm-web-connecting-view>`;case"MobileQrcodeConnecting":return te`<wcm-mobile-qr-connecting-view></wcm-mobile-qr-connecting-view>`;case"WalletExplorer":return te`<wcm-wallet-explorer-view></wcm-wallet-explorer-view>`;case"Qrcode":return te`<wcm-qrcode-view></wcm-qrcode-view>`;case"InstallWallet":return te`<wcm-install-wallet-view></wcm-install-wallet-view>`;default:return te`<div>Not Found</div>`}}async onChangeRoute(){await Ws(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=Ot.state.view,Ws(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return te`<div class="wcm-router"><div class="wcm-content">${this.viewTemplate()}</div></div>`}};wc.styles=[Fe.globalCss,qq],i0([Ur()],wc.prototype,"view",2),i0([Ur()],wc.prototype,"prevView",2),wc=i0([Le("wcm-modal-router")],wc);const zq=it`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var Hq=Object.defineProperty,Wq=Object.getOwnPropertyDescriptor,yy=(t,e,r,i)=>{for(var n=i>1?void 0:i?Wq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Hq(e,r,n),n};let yh=class extends Pe{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=es.subscribe(t=>{t.open?(this.open=!0,this.timeout=setTimeout(()=>es.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var t;(t=this.unsubscribe)==null||t.call(this),clearTimeout(this.timeout),es.closeToast()}render(){const{message:t,variant:e}=es.state,r={"wcm-success":e==="success","wcm-error":e==="error"};return this.open?te`<div class="${wn(r)}">${e==="success"?ht.CHECKMARK_ICON:null} ${e==="error"?ht.CROSS_ICON:null}<wcm-text variant="small-regular">${t}</wcm-text></div>`:null}};yh.styles=[Fe.globalCss,zq],yy([Ur()],yh.prototype,"open",2),yh=yy([Le("wcm-modal-toast")],yh);const Vq=.1,wy=2.5,_n=7;function n0(t,e,r){return t===e?!1:(t-e<0?e-t:t-e)<=r+Vq}function Kq(t,e){const r=Array.prototype.slice.call(pc.create(t,{errorCorrectionLevel:e}).modules.data,0),i=Math.sqrt(r.length);return r.reduce((n,s,o)=>(o%i===0?n.push([s]):n[n.length-1].push(s))&&n,[])}const Gq={generate(t,e,r){const i="#141414",n="#ffffff",s=[],o=Kq(t,"Q"),a=e/o.length,c=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];c.forEach(({x:E,y:A})=>{const R=(o.length-_n)*a*E,O=(o.length-_n)*a*A,C=.45;for(let N=0;N<c.length;N+=1){const T=a*(_n-N*2);s.push(Nt`<rect fill="${N%2===0?i:n}" height="${T}" rx="${T*C}" ry="${T*C}" width="${T}" x="${R+a*N}" y="${O+a*N}">`)}});const l=Math.floor((r+25)/a),u=o.length/2-l/2,m=o.length/2+l/2-1,x=[];o.forEach((E,A)=>{E.forEach((R,O)=>{if(o[A][O]&&!(A<_n&&O<_n||A>o.length-(_n+1)&&O<_n||A<_n&&O>o.length-(_n+1))&&!(A>u&&A<m&&O>u&&O<m)){const C=A*a+a/2,N=O*a+a/2;x.push([C,N])}})});const S={};return x.forEach(([E,A])=>{S[E]?S[E].push(A):S[E]=[A]}),Object.entries(S).map(([E,A])=>{const R=A.filter(O=>A.every(C=>!n0(O,C,a)));return[Number(E),R]}).forEach(([E,A])=>{A.forEach(R=>{s.push(Nt`<circle cx="${E}" cy="${R}" fill="${i}" r="${a/wy}">`)})}),Object.entries(S).filter(([E,A])=>A.length>1).map(([E,A])=>{const R=A.filter(O=>A.some(C=>n0(O,C,a)));return[Number(E),R]}).map(([E,A])=>{A.sort((O,C)=>O<C?-1:1);const R=[];for(const O of A){const C=R.find(N=>N.some(T=>n0(O,T,a)));C?C.push(O):R.push([O])}return[E,R.map(O=>[O[0],O[O.length-1]])]}).forEach(([E,A])=>{A.forEach(([R,O])=>{s.push(Nt`<line x1="${E}" x2="${E}" y1="${R}" y2="${O}" stroke="${i}" stroke-width="${a/(wy/2)}" stroke-linecap="round">`)})}),s}},Jq=it`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var Zq=Object.defineProperty,Yq=Object.getOwnPropertyDescriptor,oa=(t,e,r,i)=>{for(var n=i>1?void 0:i?Yq(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Zq(e,r,n),n};let xn=class extends Pe{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const e=Qn.state.themeMode==="light"?this.size:this.size-18*2;return Nt`<svg height="${e}" width="${e}">${Gq.generate(this.uri,e,e/4)}</svg>`}render(){const t={"wcm-dark":Qn.state.themeMode==="dark"};return te`<div style="${`width: ${this.size}px`}" class="${wn(t)}">${this.walletId||this.imageUrl?te`<wcm-wallet-image walletId="${Mr(this.walletId)}" imageId="${Mr(this.imageId)}" imageUrl="${Mr(this.imageUrl)}"></wcm-wallet-image>`:ht.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}</div>`}};xn.styles=[Fe.globalCss,Jq],oa([$e()],xn.prototype,"uri",2),oa([$e({type:Number})],xn.prototype,"size",2),oa([$e()],xn.prototype,"imageId",2),oa([$e()],xn.prototype,"walletId",2),oa([$e()],xn.prototype,"imageUrl",2),xn=oa([Le("wcm-qrcode")],xn);const Xq=it`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var Qq=Object.defineProperty,ej=Object.getOwnPropertyDescriptor,_y=(t,e,r,i)=>{for(var n=i>1?void 0:i?ej(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Qq(e,r,n),n};let wh=class extends Pe{constructor(){super(...arguments),this.onChange=()=>null}render(){return te`<input type="text" @input="${this.onChange}" placeholder="Search wallets"> ${ht.SEARCH_ICON}`}};wh.styles=[Fe.globalCss,Xq],_y([$e()],wh.prototype,"onChange",2),wh=_y([Le("wcm-search-input")],wh);const tj=it`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var rj=Object.defineProperty,ij=Object.getOwnPropertyDescriptor,nj=(t,e,r,i)=>{for(var n=i>1?void 0:i?ij(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&rj(e,r,n),n};let s0=class extends Pe{render(){return te`<svg viewBox="0 0 50 50" width="24" height="24"><circle cx="25" cy="25" r="20" fill="none" stroke-width="4" stroke="#fff"/></svg>`}};s0.styles=[Fe.globalCss,tj],s0=nj([Le("wcm-spinner")],s0);const sj=it`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var oj=Object.defineProperty,aj=Object.getOwnPropertyDescriptor,o0=(t,e,r,i)=>{for(var n=i>1?void 0:i?aj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&oj(e,r,n),n};let _c=class extends Pe{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const t={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return te`<span><slot class="${wn(t)}"></slot></span>`}};_c.styles=[Fe.globalCss,sj],o0([$e()],_c.prototype,"variant",2),o0([$e()],_c.prototype,"color",2),_c=o0([Le("wcm-text")],_c);const cj=it`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var lj=Object.defineProperty,hj=Object.getOwnPropertyDescriptor,os=(t,e,r,i)=>{for(var n=i>1?void 0:i?hj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&lj(e,r,n),n};let nn=class extends Pe{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?te`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">RECENT</wcm-text>`:this.installed?te`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">INSTALLED</wcm-text>`:null}handleClick(){s2.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var t;return te`<button @click="${this.handleClick.bind(this)}"><div><wcm-wallet-image walletId="${this.walletId}" imageId="${Mr(this.imageId)}"></wcm-wallet-image><wcm-text variant="xsmall-regular">${(t=this.label)!=null?t:xe.getWalletName(this.name,!0)}</wcm-text>${this.sublabelTemplate()}</div></button>`}};nn.styles=[Fe.globalCss,cj],os([$e()],nn.prototype,"onClick",2),os([$e()],nn.prototype,"name",2),os([$e()],nn.prototype,"walletId",2),os([$e()],nn.prototype,"label",2),os([$e()],nn.prototype,"imageId",2),os([$e({type:Boolean})],nn.prototype,"installed",2),os([$e({type:Boolean})],nn.prototype,"recent",2),nn=os([Le("wcm-wallet-button")],nn);const fj=it`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var uj=Object.defineProperty,dj=Object.getOwnPropertyDescriptor,_h=(t,e,r,i)=>{for(var n=i>1?void 0:i?dj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&uj(e,r,n),n};let aa=class extends Pe{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var t;const e=(t=this.imageUrl)!=null&&t.length?this.imageUrl:xe.getWalletIcon({id:this.walletId,image_id:this.imageId});return te`${e.length?te`<div><img crossorigin="anonymous" src="${e}" alt="${this.id}"></div>`:ht.WALLET_PLACEHOLDER}`}};aa.styles=[Fe.globalCss,fj],_h([$e()],aa.prototype,"walletId",2),_h([$e()],aa.prototype,"imageId",2),_h([$e()],aa.prototype,"imageUrl",2),aa=_h([Le("wcm-wallet-image")],aa);var pj=Object.defineProperty,gj=Object.getOwnPropertyDescriptor,xy=(t,e,r,i)=>{for(var n=i>1?void 0:i?gj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&pj(e,r,n),n};let a0=class extends Pe{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(t){try{t?.length&&await Promise.all(t.map(async e=>xe.preloadImage(e)))}catch{console.info("Unsuccessful attempt at preloading some images",t)}}async preloadListings(){if(ei.state.enableExplorer){await Br.getRecomendedWallets(),qt.setIsDataLoaded(!0);const{recomendedWallets:t}=Br.state,e=t.map(r=>xe.getWalletIcon(r));await this.loadImages(e)}else qt.setIsDataLoaded(!0)}async preloadCustomImages(){const t=xe.getCustomImageUrls();await this.loadImages(t)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(t){console.error(t),es.openToast("Failed preloading","error")}}};xy([Ur()],a0.prototype,"preload",2),a0=xy([Le("wcm-explorer-context")],a0);var vj=Object.defineProperty,mj=Object.getOwnPropertyDescriptor,bj=(t,e,r,i)=>{for(var n=i>1?void 0:i?mj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&vj(e,r,n),n};let Ey=class extends Pe{constructor(){super(),this.unsubscribeTheme=void 0,Fe.setTheme(),this.unsubscribeTheme=Qn.subscribe(Fe.setTheme)}disconnectedCallback(){var t;(t=this.unsubscribeTheme)==null||t.call(this)}};Ey=bj([Le("wcm-theme-context")],Ey);const yj=it`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var wj=Object.defineProperty,_j=Object.getOwnPropertyDescriptor,xj=(t,e,r,i)=>{for(var n=i>1?void 0:i?_j(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&wj(e,r,n),n};let c0=class extends Pe{onGoToQrcode(){Ot.push("Qrcode")}render(){const{recomendedWallets:t}=Br.state,e=[...t,...t],r=se.RECOMMENDED_WALLET_AMOUNT*2;return te`<wcm-modal-header title="Connect your wallet" .onAction="${this.onGoToQrcode}" .actionIcon="${ht.QRCODE_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-title">${ht.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">WalletConnect</wcm-text></div><div class="wcm-slider"><div class="wcm-track">${[...Array(r)].map((i,n)=>{const s=e[n%e.length];return s?te`<wcm-wallet-image walletId="${s.id}" imageId="${s.image_id}"></wcm-wallet-image>`:ht.WALLET_PLACEHOLDER})}</div><wcm-button-big @click="${xe.handleAndroidLinking}"><wcm-text variant="medium-regular" color="inverse">Select Wallet</wcm-text></wcm-button-big></div></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">Choose WalletConnect to see supported apps on your device</wcm-text></wcm-info-footer>`}};c0.styles=[Fe.globalCss,yj],c0=xj([Le("wcm-android-wallet-selection")],c0);const Ej=it`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var $j=Object.defineProperty,Sj=Object.getOwnPropertyDescriptor,ca=(t,e,r,i)=>{for(var n=i>1?void 0:i?Sj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&$j(e,r,n),n};let as=class extends Pe{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var t,e;const s=(e=(t=Qn.state.themeVariables)==null?void 0:t["--wcm-wallet-icon-large-border-radius"])!=null?e:Fe.getPreset("--wcm-wallet-icon-large-border-radius");let o=0;s.includes("%")?o=88/100*parseInt(s,10):o=parseInt(s,10),o*=1.17;const a=317-o*1.57,c=425-o*1.8;return te`<svg viewBox="0 0 110 110" width="110" height="110"><rect id="wcm-loader" x="2" y="2" width="106" height="106" rx="${o}"/><use xlink:href="#wcm-loader" stroke-dasharray="106 ${a}" stroke-dashoffset="${c}"></use></svg>`}render(){const t={"wcm-error":this.isError,"wcm-stale":this.isStale};return te`<div class="${wn(t)}">${this.svgLoaderTemplate()}<wcm-wallet-image walletId="${Mr(this.walletId)}" imageId="${Mr(this.imageId)}"></wcm-wallet-image></div><wcm-text variant="medium-regular" color="${this.isError?"error":"primary"}">${this.isError?"Connection declined":this.label}</wcm-text>`}};as.styles=[Fe.globalCss,Ej],ca([$e()],as.prototype,"walletId",2),ca([$e()],as.prototype,"imageId",2),ca([$e({type:Boolean})],as.prototype,"isError",2),ca([$e({type:Boolean})],as.prototype,"isStale",2),ca([$e()],as.prototype,"label",2),as=ca([Le("wcm-connector-waiting")],as);const la={manualWallets(){var t,e;const{mobileWallets:r,desktopWallets:i}=ei.state,n=(t=la.recentWallet())==null?void 0:t.id,s=se.isMobile()?r:i,o=s?.filter(a=>n!==a.id);return(e=se.isMobile()?o?.map(({id:a,name:c,links:l})=>({id:a,name:c,mobile:l,links:l})):o?.map(({id:a,name:c,links:l})=>({id:a,name:c,desktop:l,links:l})))!=null?e:[]},recentWallet(){return xe.getRecentWallet()},recomendedWallets(t=!1){var e;const r=t||(e=la.recentWallet())==null?void 0:e.id,{recomendedWallets:i}=Br.state;return i.filter(s=>r!==s.id)}},cs={onConnecting(t){xe.goToConnectingView(t)},manualWalletsTemplate(){return la.manualWallets().map(e=>te`<wcm-wallet-button walletId="${e.id}" name="${e.name}" .onClick="${()=>this.onConnecting(e)}"></wcm-wallet-button>`)},recomendedWalletsTemplate(t=!1){return la.recomendedWallets(t).map(r=>te`<wcm-wallet-button name="${r.name}" walletId="${r.id}" imageId="${r.image_id}" .onClick="${()=>this.onConnecting(r)}"></wcm-wallet-button>`)},recentWalletTemplate(){const t=la.recentWallet();if(t)return te`<wcm-wallet-button name="${t.name}" walletId="${t.id}" imageId="${Mr(t.image_id)}" .recent="${!0}" .onClick="${()=>this.onConnecting(t)}"></wcm-wallet-button>`}},Ij=it`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var Aj=Object.defineProperty,Mj=Object.getOwnPropertyDescriptor,Pj=(t,e,r,i)=>{for(var n=i>1?void 0:i?Mj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Aj(e,r,n),n};let l0=class extends Pe{render(){const{explorerExcludedWalletIds:t,enableExplorer:e}=ei.state,r=t!=="ALL"&&e,i=cs.manualWalletsTemplate(),n=cs.recomendedWalletsTemplate();let o=[cs.recentWalletTemplate(),...i,...n];o=o.filter(Boolean);const a=o.length>4||r;let c=[];a?c=o.slice(0,3):c=o;const l=!!c.length;return te`<wcm-modal-header .border="${!0}" title="Connect your wallet" .onAction="${xe.handleUriCopy}" .actionIcon="${ht.COPY_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-mobile-title"><div class="wcm-subtitle">${ht.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">Mobile</wcm-text></div><div class="wcm-subtitle">${ht.SCAN_ICON}<wcm-text variant="small-regular" color="secondary">Scan with your wallet</wcm-text></div></div><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>${l?te`<wcm-modal-footer><div class="wcm-desktop-title">${ht.DESKTOP_ICON}<wcm-text variant="small-regular" color="accent">Desktop</wcm-text></div><div class="wcm-grid">${c} ${a?te`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>`:null}</div></wcm-modal-footer>`:null}`}};l0.styles=[Fe.globalCss,Ij],l0=Pj([Le("wcm-desktop-wallet-selection")],l0);const Oj=it`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var Cj=Object.defineProperty,Dj=Object.getOwnPropertyDescriptor,Rj=(t,e,r,i)=>{for(var n=i>1?void 0:i?Dj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Cj(e,r,n),n};let h0=class extends Pe{render(){const{termsOfServiceUrl:t,privacyPolicyUrl:e}=ei.state;return t??e?te`<div><wcm-text variant="small-regular" color="secondary">By connecting your wallet to this app, you agree to the app's ${t?te`<a href="${t}" target="_blank" rel="noopener noreferrer">Terms of Service</a>`:null} ${t&&e?"and":null} ${e?te`<a href="${e}" target="_blank" rel="noopener noreferrer">Privacy Policy</a>`:null}</wcm-text></div>`:null}};h0.styles=[Fe.globalCss,Oj],h0=Rj([Le("wcm-legal-notice")],h0);const Nj=it`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var Tj=Object.defineProperty,Fj=Object.getOwnPropertyDescriptor,Lj=(t,e,r,i)=>{for(var n=i>1?void 0:i?Fj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Tj(e,r,n),n};let f0=class extends Pe{onQrcode(){Ot.push("Qrcode")}render(){const{explorerExcludedWalletIds:t,enableExplorer:e}=ei.state,r=t!=="ALL"&&e,i=cs.manualWalletsTemplate(),n=cs.recomendedWalletsTemplate();let o=[cs.recentWalletTemplate(),...i,...n];o=o.filter(Boolean);const a=o.length>8||r;let c=[];a?c=o.slice(0,7):c=o;const l=!!c.length;return te`<wcm-modal-header title="Connect your wallet" .onAction="${this.onQrcode}" .actionIcon="${ht.QRCODE_ICON}"></wcm-modal-header>${l?te`<wcm-modal-content><div>${c} ${a?te`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>`:null}</div></wcm-modal-content>`:null}`}};f0.styles=[Fe.globalCss,Nj],f0=Lj([Le("wcm-mobile-wallet-selection")],f0);const Bj=it`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var Uj=Object.defineProperty,qj=Object.getOwnPropertyDescriptor,u0=(t,e,r,i)=>{for(var n=i>1?void 0:i?qj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Uj(e,r,n),n};let ha=class extends Pe{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=Bs.subscribe(t=>{t.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var t;(t=this.unsubscribeModal)==null||t.call(this)}get overlayEl(){return xe.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return xe.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(t){if(document.querySelector("body"))if(t){const r=document.getElementById("wcm-styles");r?.remove()}else document.head.insertAdjacentHTML("beforeend",'<style id="wcm-styles">html,body{touch-action:none;overflow:hidden;overscroll-behavior:contain;}</style>')}onCloseModal(t){t.target===t.currentTarget&&Bs.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const t=xe.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},e=.1,r=.2;await Promise.all([Ws(this.overlayEl,{opacity:[0,1]},{delay:e,duration:r}).finished,Ws(this.containerEl,t,{delay:e,duration:r}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const t=xe.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},e=.2;await Promise.all([Ws(this.overlayEl,{opacity:[1,0]},{duration:e}).finished,Ws(this.containerEl,t,{duration:e}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",t=>{var e;t.key==="Escape"?Bs.close():t.key==="Tab"&&((e=t.target)!=null&&e.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var t;(t=this.abortController)==null||t.abort(),this.abortController=void 0}render(){const t={"wcm-overlay":!0,"wcm-active":this.active};return te`<wcm-explorer-context></wcm-explorer-context><wcm-theme-context></wcm-theme-context><div id="wcm-modal" class="${wn(t)}" @click="${this.onCloseModal}" role="alertdialog" aria-modal="true"><div class="wcm-container" tabindex="0">${this.open?te`<wcm-modal-backcard></wcm-modal-backcard><div class="wcm-card"><wcm-modal-router></wcm-modal-router><wcm-modal-toast></wcm-modal-toast></div>`:null}</div></div>`}};ha.styles=[Fe.globalCss,Bj],u0([Ur()],ha.prototype,"open",2),u0([Ur()],ha.prototype,"active",2),ha=u0([Le("wcm-modal")],ha);const jj=it`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var kj=Object.defineProperty,zj=Object.getOwnPropertyDescriptor,xc=(t,e,r,i)=>{for(var n=i>1?void 0:i?zj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&kj(e,r,n),n};let Ks=class extends Pe{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){se.isMobile()?Ot.replace("MobileConnecting"):Ot.replace("MobileQrcodeConnecting")}onDesktop(){Ot.replace("DesktopConnecting")}onWeb(){Ot.replace("WebConnecting")}render(){return te`<div>${this.isRetry?te`<slot></slot>`:null} ${this.isMobile?te`<wcm-button .onClick="${this.onMobile}" .iconLeft="${ht.MOBILE_ICON}" variant="outline">Mobile</wcm-button>`:null} ${this.isDesktop?te`<wcm-button .onClick="${this.onDesktop}" .iconLeft="${ht.DESKTOP_ICON}" variant="outline">Desktop</wcm-button>`:null} ${this.isWeb?te`<wcm-button .onClick="${this.onWeb}" .iconLeft="${ht.GLOBE_ICON}" variant="outline">Web</wcm-button>`:null}</div>`}};Ks.styles=[Fe.globalCss,jj],xc([$e({type:Boolean})],Ks.prototype,"isMobile",2),xc([$e({type:Boolean})],Ks.prototype,"isDesktop",2),xc([$e({type:Boolean})],Ks.prototype,"isWeb",2),xc([$e({type:Boolean})],Ks.prototype,"isRetry",2),Ks=xc([Le("wcm-platform-selection")],Ks);const Hj=it`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Wj=Object.defineProperty,Vj=Object.getOwnPropertyDescriptor,Kj=(t,e,r,i)=>{for(var n=i>1?void 0:i?Vj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Wj(e,r,n),n};let d0=class extends Pe{onClick(){Ot.push("WalletExplorer")}render(){const{recomendedWallets:t}=Br.state,e=la.manualWallets(),r=[...t,...e].reverse().slice(0,4);return te`<button @click="${this.onClick}"><div class="wcm-icons">${r.map(i=>{const n=xe.getWalletIcon(i);if(n)return te`<img crossorigin="anonymous" src="${n}">`;const s=xe.getWalletIcon({id:i.id});return s?te`<img crossorigin="anonymous" src="${s}">`:ht.WALLET_PLACEHOLDER})} ${[...Array(4-r.length)].map(()=>ht.WALLET_PLACEHOLDER)}</div><wcm-text variant="xsmall-regular">View All</wcm-text></button>`}};d0.styles=[Fe.globalCss,Hj],d0=Kj([Le("wcm-view-all-wallets-button")],d0);const Gj=it`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var Jj=Object.defineProperty,Zj=Object.getOwnPropertyDescriptor,xh=(t,e,r,i)=>{for(var n=i>1?void 0:i?Zj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Jj(e,r,n),n};let fa=class extends Pe{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:t}=qt.state;this.uri=t},0)}get overlayEl(){return xe.getShadowRootElement(this,".wcm-qr-container")}render(){return te`<div class="wcm-qr-container">${this.uri?te`<wcm-qrcode size="${this.overlayEl.offsetWidth}" uri="${this.uri}" walletId="${Mr(this.walletId)}" imageId="${Mr(this.imageId)}"></wcm-qrcode>`:te`<wcm-spinner></wcm-spinner>`}</div>`}};fa.styles=[Fe.globalCss,Gj],xh([$e()],fa.prototype,"walletId",2),xh([$e()],fa.prototype,"imageId",2),xh([Ur()],fa.prototype,"uri",2),fa=xh([Le("wcm-walletconnect-qr")],fa);var Yj=Object.defineProperty,Xj=Object.getOwnPropertyDescriptor,Qj=(t,e,r,i)=>{for(var n=i>1?void 0:i?Xj(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Yj(e,r,n),n};let p0=class extends Pe{viewTemplate(){return se.isAndroid()&&!se.isTelegram()?te`<wcm-android-wallet-selection></wcm-android-wallet-selection>`:se.isMobile()?te`<wcm-mobile-wallet-selection></wcm-mobile-wallet-selection>`:te`<wcm-desktop-wallet-selection></wcm-desktop-wallet-selection>`}render(){return te`${this.viewTemplate()}<wcm-legal-notice></wcm-legal-notice>`}};p0.styles=[Fe.globalCss],p0=Qj([Le("wcm-connect-wallet-view")],p0);const ek=it`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var tk=Object.defineProperty,rk=Object.getOwnPropertyDescriptor,$y=(t,e,r,i)=>{for(var n=i>1?void 0:i?rk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&tk(e,r,n),n};let Eh=class extends Pe{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(t){const{desktop:e,name:r}=se.getWalletRouterData(),i=e?.native,n=e?.universal;if(i){const s=se.formatNativeUrl(i,t,r);se.openHref(s,"_self")}else if(n){const s=se.formatUniversalUrl(n,t,r);se.openHref(s,"_blank")}}openDesktopApp(){const{walletConnectUri:t}=qt.state,e=se.getWalletRouterData();xe.setRecentWallet(e),t&&this.onFormatAndRedirect(t)}render(){const{name:t,id:e,image_id:r}=se.getWalletRouterData(),{isMobile:i,isWeb:n}=xe.getCachedRouterWalletPlatforms();return te`<wcm-modal-header title="${t}" .onAction="${xe.handleUriCopy}" .actionIcon="${ht.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${Mr(r)}" label="${`Continue in ${t}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Connection can continue loading if ${t} is not installed on your device`}</wcm-text><wcm-platform-selection .isMobile="${i}" .isWeb="${n}" .isRetry="${!0}"><wcm-button .onClick="${this.openDesktopApp.bind(this)}" .iconRight="${ht.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};Eh.styles=[Fe.globalCss,ek],$y([Ur()],Eh.prototype,"isError",2),Eh=$y([Le("wcm-desktop-connecting-view")],Eh);const ik=it`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var nk=Object.defineProperty,sk=Object.getOwnPropertyDescriptor,ok=(t,e,r,i)=>{for(var n=i>1?void 0:i?sk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&nk(e,r,n),n};let g0=class extends Pe{onInstall(t){t&&se.openHref(t,"_blank")}render(){const{name:t,id:e,image_id:r,homepage:i}=se.getWalletRouterData();return te`<wcm-modal-header title="${t}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${Mr(r)}" label="Not Detected" .isStale="${!0}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Download ${t} to continue. If multiple browser extensions are installed, disable non ${t} ones and try again`}</wcm-text><wcm-button .onClick="${()=>this.onInstall(i)}" .iconLeft="${ht.ARROW_DOWN_ICON}">Download</wcm-button></wcm-info-footer>`}};g0.styles=[Fe.globalCss,ik],g0=ok([Le("wcm-install-wallet-view")],g0);const ak=it`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var ck=Object.defineProperty,lk=Object.getOwnPropertyDescriptor,Sy=(t,e,r,i)=>{for(var n=i>1?void 0:i?lk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&ck(e,r,n),n};let $h=class extends Pe{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(t,e=!1){const{mobile:r,name:i}=se.getWalletRouterData(),n=r?.native,s=r?.universal,o=se.isTelegram()?"_blank":"_self";if(t=se.isTelegram()&&se.isAndroid()?encodeURIComponent(t):t,n&&!e){const a=se.formatNativeUrl(n,t,i);se.openHref(a,o)}else if(s){const a=se.formatUniversalUrl(s,t,i);se.openHref(a,o)}}openMobileApp(t=!1){const{walletConnectUri:e}=qt.state,r=se.getWalletRouterData();e&&this.onFormatAndRedirect(e,t),xe.setRecentWallet(r)}onGoToAppStore(t){t&&se.openHref(t,"_blank")}render(){const{name:t,id:e,image_id:r,app:i,mobile:n}=se.getWalletRouterData(),{isWeb:s}=xe.getCachedRouterWalletPlatforms(),o=i?.ios,a=n?.universal;return te`<wcm-modal-header title="${t}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${Mr(r)}" label="Tap 'Open' to continue…" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer class="wcm-note"><wcm-platform-selection .isWeb="${s}" .isRetry="${!0}"><wcm-button .onClick="${()=>this.openMobileApp(!1)}" .iconRight="${ht.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection>${a?te`<wcm-text color="secondary" variant="small-thin">Still doesn't work? <span tabindex="0" @click="${()=>this.openMobileApp(!0)}">Try this alternate link</span></wcm-text>`:null}</wcm-info-footer><wcm-info-footer class="wcm-app-store"><div><wcm-wallet-image walletId="${e}" imageId="${Mr(r)}"></wcm-wallet-image><wcm-text>${`Get ${t}`}</wcm-text></div><wcm-button .iconRight="${ht.ARROW_RIGHT_ICON}" .onClick="${()=>this.onGoToAppStore(o)}" variant="ghost">App Store</wcm-button></wcm-info-footer>`}};$h.styles=[Fe.globalCss,ak],Sy([Ur()],$h.prototype,"isError",2),$h=Sy([Le("wcm-mobile-connecting-view")],$h);const hk=it`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var fk=Object.defineProperty,uk=Object.getOwnPropertyDescriptor,dk=(t,e,r,i)=>{for(var n=i>1?void 0:i?uk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&fk(e,r,n),n};let v0=class extends Pe{render(){const{name:t,id:e,image_id:r}=se.getWalletRouterData(),{isDesktop:i,isWeb:n}=xe.getCachedRouterWalletPlatforms();return te`<wcm-modal-header title="${t}" .onAction="${xe.handleUriCopy}" .actionIcon="${ht.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr walletId="${e}" imageId="${Mr(r)}"></wcm-walletconnect-qr></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Scan this QR Code with your phone's camera or inside ${t} app`}</wcm-text><wcm-platform-selection .isDesktop="${i}" .isWeb="${n}"></wcm-platform-selection></wcm-info-footer>`}};v0.styles=[Fe.globalCss,hk],v0=dk([Le("wcm-mobile-qr-connecting-view")],v0);var pk=Object.defineProperty,gk=Object.getOwnPropertyDescriptor,vk=(t,e,r,i)=>{for(var n=i>1?void 0:i?gk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&pk(e,r,n),n};let m0=class extends Pe{render(){return te`<wcm-modal-header title="Scan the code" .onAction="${xe.handleUriCopy}" .actionIcon="${ht.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>`}};m0.styles=[Fe.globalCss],m0=vk([Le("wcm-qrcode-view")],m0);const mk=it`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var bk=Object.defineProperty,yk=Object.getOwnPropertyDescriptor,Ec=(t,e,r,i)=>{for(var n=i>1?void 0:i?yk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&bk(e,r,n),n};const b0=40;let Gs=class extends Pe{constructor(){super(...arguments),this.loading=!Br.state.wallets.listings.length,this.firstFetch=!Br.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=xe.debounce(t=>{t.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=t,Br.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),Br.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var t;(t=this.intersectionObserver)==null||t.disconnect()}get placeholderEl(){return xe.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([t])=>{t.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:t,search:e}=Br.state,{listings:r,total:i}=this.search?e:t;return i<=b0||r.length>=i}async fetchWallets(){var t;const{wallets:e,search:r}=Br.state,{listings:i,total:n,page:s}=this.search?r:e;if(!this.endReached&&(this.firstFetch||n>b0&&i.length<n))try{this.loading=!0;const o=(t=qt.state.chains)==null?void 0:t.join(","),{listings:a}=await Br.getWallets({page:this.firstFetch?1:s+1,entries:b0,search:this.search,version:2,chains:o}),c=a.map(l=>xe.getWalletIcon(l));await Promise.all([...c.map(async l=>xe.preloadImage(l)),se.wait(300)]),this.endReached=this.isLastPage()}catch(o){console.error(o),es.openToast(xe.getErrorMessage(o),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(t){se.isAndroid()?xe.handleMobileLinking(t):xe.goToConnectingView(t)}onSearchChange(t){const{value:e}=t.target;this.searchDebounce(e)}render(){const{wallets:t,search:e}=Br.state,{listings:r}=this.search?e:t,i=this.loading&&!r.length,n=this.search.length>=3;let s=cs.manualWalletsTemplate(),o=cs.recomendedWalletsTemplate(!0);n&&(s=s.filter(({values:l})=>xe.caseSafeIncludes(l[0],this.search)),o=o.filter(({values:l})=>xe.caseSafeIncludes(l[0],this.search)));const a=!this.loading&&!r.length&&!o.length,c={"wcm-loading":i,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":a};return te`<wcm-modal-header><wcm-search-input .onChange="${this.onSearchChange.bind(this)}"></wcm-search-input></wcm-modal-header><wcm-modal-content class="${wn(c)}"><div class="wcm-grid">${i?null:s} ${i?null:o} ${i?null:r.map(l=>te`${l?te`<wcm-wallet-button imageId="${l.image_id}" name="${l.name}" walletId="${l.id}" .onClick="${()=>this.onConnect(l)}"></wcm-wallet-button>`:null}`)}</div><div class="wcm-placeholder-block">${a?te`<wcm-text variant="big-bold" color="secondary">No results found</wcm-text>`:null} ${!a&&this.loading?te`<wcm-spinner></wcm-spinner>`:null}</div></wcm-modal-content>`}};Gs.styles=[Fe.globalCss,mk],Ec([Ur()],Gs.prototype,"loading",2),Ec([Ur()],Gs.prototype,"firstFetch",2),Ec([Ur()],Gs.prototype,"search",2),Ec([Ur()],Gs.prototype,"endReached",2),Gs=Ec([Le("wcm-wallet-explorer-view")],Gs);const wk=it`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var _k=Object.defineProperty,xk=Object.getOwnPropertyDescriptor,Iy=(t,e,r,i)=>{for(var n=i>1?void 0:i?xk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&_k(e,r,n),n};let Sh=class extends Pe{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(t){const{desktop:e,name:r}=se.getWalletRouterData(),i=e?.universal;if(i){const n=se.formatUniversalUrl(i,t,r);se.openHref(n,"_blank")}}openWebWallet(){const{walletConnectUri:t}=qt.state,e=se.getWalletRouterData();xe.setRecentWallet(e),t&&this.onFormatAndRedirect(t)}render(){const{name:t,id:e,image_id:r}=se.getWalletRouterData(),{isMobile:i,isDesktop:n}=xe.getCachedRouterWalletPlatforms(),s=se.isMobile();return te`<wcm-modal-header title="${t}" .onAction="${xe.handleUriCopy}" .actionIcon="${ht.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${Mr(r)}" label="${`Continue in ${t}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`${t} web app has opened in a new tab. Go there, accept the connection, and come back`}</wcm-text><wcm-platform-selection .isMobile="${i}" .isDesktop="${s?!1:n}" .isRetry="${!0}"><wcm-button .onClick="${this.openWebWallet.bind(this)}" .iconRight="${ht.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};Sh.styles=[Fe.globalCss,wk],Iy([Ur()],Sh.prototype,"isError",2),Sh=Iy([Le("wcm-web-connecting-view")],Sh);var Ek=Object.freeze({__proto__:null,get WcmModal(){return ha},get WcmQrCode(){return xn}});wi.EthereumProvider=VL,wi.OPTIONAL_EVENTS=t2,wi.OPTIONAL_METHODS=e2,wi.REQUIRED_EVENTS=Zl,wi.REQUIRED_METHODS=Jl,wi.default=Ql,Object.defineProperty(wi,"__esModule",{value:!0})});
|
|
92
|
+
`);const o=Kz(e,r,n),a=Eu.getSymbolSize(e),c=new Bz(a);return zz(c,e),kz(c),Hz(c,e),m0(c,r,0),e>=7&&Wz(c,e),Vz(c,o),isNaN(i)&&(i=p0.getBestMask(c,m0.bind(null,c,r))),p0.applyMask(i,c),m0(c,r,i),{modules:c,version:e,errorCorrectionLevel:r,maskPattern:i,segments:n}}iw.create=function(e,r){if(typeof e>"u"||e==="")throw new Error("No input text");let i=f0.M,n,s;return typeof r<"u"&&(i=f0.from(r.errorCorrectionLevel,f0.M),n=$u.from(r.version),s=p0.from(r.maskPattern),r.toSJISFunc&&Eu.setToSJISFunction(r.toSJISFunc)),Zz(e,n,i,s)};var vw={},v0={};(function(t){function e(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let i=r.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+r);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(s){return[s,s]}))),i.length===6&&i.push("F","F");const n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}t.getOptions=function(i){i||(i={}),i.color||(i.color={});const n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,s=i.width&&i.width>=21?i.width:void 0,o=i.scale||4;return{width:s,scale:s?4:o,margin:n,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},t.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},t.getImageWidth=function(i,n){const s=t.getScale(i,n);return Math.floor((i+n.margin*2)*s)},t.qrToImageData=function(i,n,s){const o=n.modules.size,a=n.modules.data,c=t.getScale(o,s),l=Math.floor((o+s.margin*2)*c),u=s.margin*c,d=[s.color.light,s.color.dark];for(let p=0;p<l;p++)for(let y=0;y<l;y++){let m=(p*l+y)*4,_=s.color.light;if(p>=u&&y>=u&&p<l-u&&y<l-u){const S=Math.floor((p-u)/c),E=Math.floor((y-u)/c);_=d[a[S*o+E]?1:0]}i[m++]=_.r,i[m++]=_.g,i[m++]=_.b,i[m]=_.a}}})(v0),function(t){const e=v0;function r(n,s,o){n.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(s,o,a){let c=a,l=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(l=i()),c=e.getOptions(c);const u=e.getImageWidth(s.modules.size,c),d=l.getContext("2d"),p=d.createImageData(u,u);return e.qrToImageData(p.data,s,c),r(d,l,u),d.putImageData(p,0,0),l},t.renderToDataURL=function(s,o,a){let c=a;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const l=t.render(s,o,c),u=c.type||"image/png",d=c.rendererOpts||{};return l.toDataURL(u,d.quality)}}(vw);var yw={};const Yz=v0;function ww(t,e){const r=t.a/255,i=e+'="'+t.hex+'"';return r<1?i+" "+e+'-opacity="'+r.toFixed(2).slice(1)+'"':i}function y0(t,e,r){let i=t+e;return typeof r<"u"&&(i+=" "+r),i}function Jz(t,e,r){let i="",n=0,s=!1,o=0;for(let a=0;a<t.length;a++){const c=Math.floor(a%e),l=Math.floor(a/e);!c&&!s&&(s=!0),t[a]?(o++,a>0&&c>0&&t[a-1]||(i+=s?y0("M",c+r,.5+l+r):y0("m",n,0),n=0,s=!1),c+1<e&&t[a+1]||(i+=y0("h",o),o=0)):n++}return i}yw.render=function(e,r,i){const n=Yz.getOptions(r),s=e.modules.size,o=e.modules.data,a=s+n.margin*2,c=n.color.light.a?"<path "+ww(n.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",l="<path "+ww(n.color.dark,"stroke")+' d="'+Jz(o,s,n.margin)+'"/>',u='viewBox="0 0 '+a+" "+a+'"',p='<svg xmlns="http://www.w3.org/2000/svg" '+(n.width?'width="'+n.width+'" height="'+n.width+'" ':"")+u+' shape-rendering="crispEdges">'+c+l+`</svg>
|
|
93
|
+
`;return typeof i=="function"&&i(null,p),p};const Qz=dz,w0=iw,_w=vw,Xz=yw;function _0(t,e,r,i,n){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!Qz())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=r,r=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=r,r=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(r=e,e=i=void 0):o===2&&!e.getContext&&(i=r,r=e,e=void 0),new Promise(function(c,l){try{const u=w0.create(r,i);c(t(u,e,i))}catch(u){l(u)}})}try{const c=w0.create(r,i);n(null,t(c,e,i))}catch(c){n(c)}}ec.create=w0.create,ec.toCanvas=_0.bind(null,_w.render),ec.toDataURL=_0.bind(null,_w.renderToDataURL),ec.toString=_0.bind(null,function(t,e,r){return Xz.render(t,r)});var ek=Object.defineProperty,xw=Object.getOwnPropertySymbols,tk=Object.prototype.hasOwnProperty,rk=Object.prototype.propertyIsEnumerable,Ew=(t,e,r)=>e in t?ek(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x0=(t,e)=>{for(var r in e||(e={}))tk.call(e,r)&&Ew(t,r,e[r]);if(xw)for(var r of xw(e))rk.call(e,r)&&Ew(t,r,e[r]);return t};function ik(){var t;const e=(t=vn.state.themeMode)!=null?t:"dark",i={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[e];return{"--wcm-color-fg-1":i.foreground[1],"--wcm-color-fg-2":i.foreground[2],"--wcm-color-fg-3":i.foreground[3],"--wcm-color-bg-1":i.background[1],"--wcm-color-bg-2":i.background[2],"--wcm-color-bg-3":i.background[3],"--wcm-color-overlay":i.overlay}}function $w(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const he={getPreset(t){return $w()[t]},setTheme(){const t=document.querySelector(":root"),{themeVariables:e}=vn.state;if(t){const r=x0(x0(x0({},ik()),$w()),e);Object.entries(r).forEach(([i,n])=>t.style.setProperty(i,n))}},globalCss:ve`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},nk=ve`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var sk=Object.defineProperty,ok=Object.getOwnPropertyDescriptor,qo=(t,e,r,i)=>{for(var n=i>1?void 0:i?ok(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&sk(e,r,n),n};let $n=class extends ae{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const t={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let e="inverse";return this.variant==="ghost"&&(e="secondary"),this.variant==="outline"&&(e="accent"),G`<button class="${Hi(t)}" ?disabled="${this.disabled}" @click="${this.onClick}">${this.iconLeft}<wcm-text variant="small-regular" color="${e}"><slot></slot></wcm-text>${this.iconRight}</button>`}};$n.styles=[he.globalCss,nk],qo([ie({type:Boolean})],$n.prototype,"disabled",2),qo([ie()],$n.prototype,"iconLeft",2),qo([ie()],$n.prototype,"iconRight",2),qo([ie()],$n.prototype,"onClick",2),qo([ie()],$n.prototype,"variant",2),$n=qo([de("wcm-button")],$n);const ak=ve`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var ck=Object.defineProperty,lk=Object.getOwnPropertyDescriptor,E0=(t,e,r,i)=>{for(var n=i>1?void 0:i?lk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&ck(e,r,n),n};let nc=class extends ae{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const t={"wcm-secondary":this.variant==="secondary"};return G`<button ?disabled="${this.disabled}" class="${Hi(t)}"><slot></slot></button>`}};nc.styles=[he.globalCss,ak],E0([ie({type:Boolean})],nc.prototype,"disabled",2),E0([ie()],nc.prototype,"variant",2),nc=E0([de("wcm-button-big")],nc);const uk=ve`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var hk=Object.defineProperty,dk=Object.getOwnPropertyDescriptor,fk=(t,e,r,i)=>{for(var n=i>1?void 0:i?dk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&hk(e,r,n),n};let $0=class extends ae{render(){return G`<div><slot></slot></div>`}};$0.styles=[he.globalCss,uk],$0=fk([de("wcm-info-footer")],$0);const we={CROSS_ICON:nt`<svg width="12" height="12" viewBox="0 0 12 12"><path d="M9.94 11A.75.75 0 1 0 11 9.94L7.414 6.353a.5.5 0 0 1 0-.708L11 2.061A.75.75 0 1 0 9.94 1L6.353 4.586a.5.5 0 0 1-.708 0L2.061 1A.75.75 0 0 0 1 2.06l3.586 3.586a.5.5 0 0 1 0 .708L1 9.939A.75.75 0 1 0 2.06 11l3.586-3.586a.5.5 0 0 1 .708 0L9.939 11Z" fill="#fff"/></svg>`,WALLET_CONNECT_LOGO:nt`<svg width="178" height="29" viewBox="0 0 178 29" id="wcm-wc-logo"><path d="M10.683 7.926c5.284-5.17 13.85-5.17 19.134 0l.636.623a.652.652 0 0 1 0 .936l-2.176 2.129a.343.343 0 0 1-.478 0l-.875-.857c-3.686-3.607-9.662-3.607-13.348 0l-.937.918a.343.343 0 0 1-.479 0l-2.175-2.13a.652.652 0 0 1 0-.936l.698-.683Zm23.633 4.403 1.935 1.895a.652.652 0 0 1 0 .936l-8.73 8.543a.687.687 0 0 1-.956 0L20.37 17.64a.172.172 0 0 0-.239 0l-6.195 6.063a.687.687 0 0 1-.957 0l-8.73-8.543a.652.652 0 0 1 0-.936l1.936-1.895a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .239 0l6.195-6.064a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .24 0l6.195-6.064a.687.687 0 0 1 .956 0ZM48.093 20.948l2.338-9.355c.139-.515.258-1.07.416-1.942.12.872.258 1.427.357 1.942l2.022 9.355h4.181l3.528-13.874h-3.21l-1.943 8.523a24.825 24.825 0 0 0-.456 2.457c-.158-.931-.317-1.625-.495-2.438l-1.883-8.542h-4.201l-2.042 8.542a41.204 41.204 0 0 0-.475 2.438 41.208 41.208 0 0 0-.476-2.438l-1.903-8.542h-3.349l3.508 13.874h4.083ZM63.33 21.304c1.585 0 2.596-.654 3.11-1.605-.059.297-.078.595-.078.892v.357h2.655V15.22c0-2.735-1.248-4.32-4.3-4.32-2.636 0-4.36 1.466-4.52 3.487h2.914c.1-.891.734-1.426 1.705-1.426.911 0 1.407.515 1.407 1.11 0 .435-.258.693-1.03.792l-1.388.159c-2.061.257-3.825 1.01-3.825 3.19 0 1.982 1.645 3.092 3.35 3.092Zm.891-2.041c-.773 0-1.348-.436-1.348-1.19 0-.733.655-1.09 1.645-1.268l.674-.119c.575-.118.892-.218 1.09-.396v.912c0 1.228-.892 2.06-2.06 2.06ZM70.398 7.074v13.874h2.874V7.074h-2.874ZM74.934 7.074v13.874h2.874V7.074h-2.874ZM84.08 21.304c2.735 0 4.5-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922H81.92ZM94.92 21.146c.633 0 1.248-.1 1.525-.179v-2.18c-.218.04-.475.06-.693.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.338v-2.24h-2.338V7.788H91.47v3.448H89.37v2.24h2.1v4.201c0 2.3 1.15 3.469 3.45 3.469ZM104.62 21.304c3.924 0 6.302-2.299 6.599-5.608h-3.111c-.238 1.803-1.506 3.032-3.369 3.032-2.2 0-3.746-1.784-3.746-4.796 0-2.953 1.605-4.638 3.805-4.638 1.883 0 2.953 1.15 3.171 2.834h3.191c-.317-3.448-2.854-5.41-6.342-5.41-3.984 0-7.036 2.695-7.036 7.214 0 4.677 2.676 7.372 6.838 7.372ZM117.449 21.304c2.993 0 5.114-1.882 5.114-5.172 0-3.23-2.121-5.233-5.114-5.233-2.972 0-5.093 2.002-5.093 5.233 0 3.29 2.101 5.172 5.093 5.172Zm0-2.22c-1.327 0-2.18-1.09-2.18-2.952 0-1.903.892-2.973 2.18-2.973 1.308 0 2.2 1.07 2.2 2.973 0 1.862-.872 2.953-2.2 2.953ZM126.569 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.229-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM137.464 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.228-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM149.949 21.304c2.735 0 4.499-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922h-3.984ZM160.876 21.304c3.013 0 4.658-1.645 4.975-4.201h-2.874c-.099 1.07-.713 1.982-2.001 1.982-1.309 0-2.2-1.21-2.2-2.993 0-1.942 1.03-2.933 2.259-2.933 1.209 0 1.803.872 1.883 1.882h2.873c-.218-2.358-1.823-4.142-4.776-4.142-2.874 0-5.153 1.903-5.153 5.193 0 3.25 1.923 5.212 5.014 5.212ZM172.067 21.146c.634 0 1.248-.1 1.526-.179v-2.18c-.218.04-.476.06-.694.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.339v-2.24h-2.339V7.788h-2.854v3.448h-2.1v2.24h2.1v4.201c0 2.3 1.15 3.469 3.449 3.469Z" fill="#fff"/></svg>`,WALLET_CONNECT_ICON:nt`<svg width="28" height="20" viewBox="0 0 28 20"><g clip-path="url(#a)"><path d="M7.386 6.482c3.653-3.576 9.575-3.576 13.228 0l.44.43a.451.451 0 0 1 0 .648L19.55 9.033a.237.237 0 0 1-.33 0l-.606-.592c-2.548-2.496-6.68-2.496-9.228 0l-.648.634a.237.237 0 0 1-.33 0L6.902 7.602a.451.451 0 0 1 0-.647l.483-.473Zm16.338 3.046 1.339 1.31a.451.451 0 0 1 0 .648l-6.035 5.909a.475.475 0 0 1-.662 0L14.083 13.2a.119.119 0 0 0-.166 0l-4.283 4.194a.475.475 0 0 1-.662 0l-6.035-5.91a.451.451 0 0 1 0-.647l1.338-1.31a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0Z" fill="#000000"/></g><defs><clipPath id="a"><path fill="#ffffff" d="M0 0h28v20H0z"/></clipPath></defs></svg>`,WALLET_CONNECT_ICON_COLORED:nt`<svg width="96" height="96" fill="none"><path fill="#fff" d="M25.322 33.597c12.525-12.263 32.83-12.263 45.355 0l1.507 1.476a1.547 1.547 0 0 1 0 2.22l-5.156 5.048a.814.814 0 0 1-1.134 0l-2.074-2.03c-8.737-8.555-22.903-8.555-31.64 0l-2.222 2.175a.814.814 0 0 1-1.134 0l-5.156-5.049a1.547 1.547 0 0 1 0-2.22l1.654-1.62Zm56.019 10.44 4.589 4.494a1.547 1.547 0 0 1 0 2.22l-20.693 20.26a1.628 1.628 0 0 1-2.267 0L48.283 56.632a.407.407 0 0 0-.567 0L33.03 71.012a1.628 1.628 0 0 1-2.268 0L10.07 50.75a1.547 1.547 0 0 1 0-2.22l4.59-4.494a1.628 1.628 0 0 1 2.267 0l14.687 14.38c.156.153.41.153.567 0l14.685-14.38a1.628 1.628 0 0 1 2.268 0l14.687 14.38c.156.153.41.153.567 0l14.686-14.38a1.628 1.628 0 0 1 2.268 0Z"/><path stroke="#000" d="M25.672 33.954c12.33-12.072 32.325-12.072 44.655 0l1.508 1.476a1.047 1.047 0 0 1 0 1.506l-5.157 5.048a.314.314 0 0 1-.434 0l-2.074-2.03c-8.932-8.746-23.409-8.746-32.34 0l-2.222 2.174a.314.314 0 0 1-.434 0l-5.157-5.048a1.047 1.047 0 0 1 0-1.506l1.655-1.62Zm55.319 10.44 4.59 4.494a1.047 1.047 0 0 1 0 1.506l-20.694 20.26a1.128 1.128 0 0 1-1.568 0l-14.686-14.38a.907.907 0 0 0-1.267 0L32.68 70.655a1.128 1.128 0 0 1-1.568 0L10.42 50.394a1.047 1.047 0 0 1 0-1.506l4.59-4.493a1.128 1.128 0 0 1 1.567 0l14.687 14.379a.907.907 0 0 0 1.266 0l-.35-.357.35.357 14.686-14.38a1.128 1.128 0 0 1 1.568 0l14.687 14.38a.907.907 0 0 0 1.267 0l14.686-14.38a1.128 1.128 0 0 1 1.568 0Z"/></svg>`,BACK_ICON:nt`<svg width="10" height="18" viewBox="0 0 10 18"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.735.179a.75.75 0 0 1 .087 1.057L2.92 8.192a1.25 1.25 0 0 0 0 1.617l5.902 6.956a.75.75 0 1 1-1.144.97L1.776 10.78a2.75 2.75 0 0 1 0-3.559L7.678.265A.75.75 0 0 1 8.735.18Z" fill="#fff"/></svg>`,COPY_ICON:nt`<svg width="24" height="24" fill="none"><path fill="#fff" fill-rule="evenodd" d="M7.01 7.01c.03-1.545.138-2.5.535-3.28A5 5 0 0 1 9.73 1.545C10.8 1 12.2 1 15 1c2.8 0 4.2 0 5.27.545a5 5 0 0 1 2.185 2.185C23 4.8 23 6.2 23 9c0 2.8 0 4.2-.545 5.27a5 5 0 0 1-2.185 2.185c-.78.397-1.735.505-3.28.534l-.001.01c-.03 1.54-.138 2.493-.534 3.27a5 5 0 0 1-2.185 2.186C13.2 23 11.8 23 9 23c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C1 19.2 1 17.8 1 15c0-2.8 0-4.2.545-5.27A5 5 0 0 1 3.73 7.545C4.508 7.149 5.46 7.04 7 7.01h.01ZM15 15.5c-1.425 0-2.403-.001-3.162-.063-.74-.06-1.139-.172-1.427-.319a3.5 3.5 0 0 1-1.53-1.529c-.146-.288-.257-.686-.318-1.427C8.501 11.403 8.5 10.425 8.5 9c0-1.425.001-2.403.063-3.162.06-.74.172-1.139.318-1.427a3.5 3.5 0 0 1 1.53-1.53c.288-.146.686-.257 1.427-.318.759-.062 1.737-.063 3.162-.063 1.425 0 2.403.001 3.162.063.74.06 1.139.172 1.427.318a3.5 3.5 0 0 1 1.53 1.53c.146.288.257.686.318 1.427.062.759.063 1.737.063 3.162 0 1.425-.001 2.403-.063 3.162-.06.74-.172 1.139-.319 1.427a3.5 3.5 0 0 1-1.529 1.53c-.288.146-.686.257-1.427.318-.759.062-1.737.063-3.162.063ZM7 8.511c-.444.009-.825.025-1.162.052-.74.06-1.139.172-1.427.318a3.5 3.5 0 0 0-1.53 1.53c-.146.288-.257.686-.318 1.427-.062.759-.063 1.737-.063 3.162 0 1.425.001 2.403.063 3.162.06.74.172 1.139.318 1.427a3.5 3.5 0 0 0 1.53 1.53c.288.146.686.257 1.427.318.759.062 1.737.063 3.162.063 1.425 0 2.403-.001 3.162-.063.74-.06 1.139-.172 1.427-.319a3.5 3.5 0 0 0 1.53-1.53c.146-.287.257-.685.318-1.426.027-.337.043-.718.052-1.162H15c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C7 13.2 7 11.8 7 9v-.489Z" clip-rule="evenodd"/></svg>`,RETRY_ICON:nt`<svg width="15" height="16" viewBox="0 0 15 16"><path d="M6.464 2.03A.75.75 0 0 0 5.403.97L2.08 4.293a1 1 0 0 0 0 1.414L5.403 9.03a.75.75 0 0 0 1.06-1.06L4.672 6.177a.25.25 0 0 1 .177-.427h2.085a4 4 0 1 1-3.93 4.746c-.077-.407-.405-.746-.82-.746-.414 0-.755.338-.7.748a5.501 5.501 0 1 0 5.45-6.248H4.848a.25.25 0 0 1-.177-.427L6.464 2.03Z" fill="#fff"/></svg>`,DESKTOP_ICON:nt`<svg width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 5.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C2.204 1 3.13 1 4.98 1h6.04c1.85 0 2.775 0 3.466.394a3 3 0 0 1 1.12 1.12C16 3.204 16 4.13 16 5.98v1.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C13.796 12 12.87 12 11.02 12H4.98c-1.85 0-2.775 0-3.466-.394a3 3 0 0 1-1.12-1.12C0 9.796 0 8.87 0 7.02V5.98ZM4.98 2.5h6.04c.953 0 1.568.001 2.034.043.446.04.608.108.69.154a1.5 1.5 0 0 1 .559.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033v1.04c0 .952-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.046-.243.114-.69.154-.466.042-1.08.043-2.033.043H4.98c-.952 0-1.568-.001-2.034-.043-.446-.04-.608-.108-.69-.154a1.5 1.5 0 0 1-.559-.56c-.046-.08-.114-.243-.154-.69-.042-.465-.043-1.08-.043-2.033V5.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.046.243-.114.69-.154.465-.042 1.08-.043 2.033-.043Z" fill="#fff"/><path d="M4 14.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,MOBILE_ICON:nt`<svg width="16" height="16" viewBox="0 0 16 16"><path d="M6.75 5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3 4.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C5.204 0 6.136 0 8 0s2.795 0 3.486.394a3 3 0 0 1 1.12 1.12C13 2.204 13 3.13 13 4.98v6.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C10.796 16 9.864 16 8 16s-2.795 0-3.486-.394a3 3 0 0 1-1.12-1.12C3 13.796 3 12.87 3 11.02V4.98Zm8.5 0v6.04c0 .953-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.045-.242.113-.693.154-.47.042-1.091.043-2.05.043-.959 0-1.58-.001-2.05-.043-.45-.04-.613-.109-.693-.154a1.5 1.5 0 0 1-.56-.56c-.046-.08-.114-.243-.154-.69-.042-.466-.043-1.08-.043-2.033V4.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.045.243-.113.693-.154C6.42 1.501 7.041 1.5 8 1.5c.959 0 1.58.001 2.05.043.45.04.613.109.693.154a1.5 1.5 0 0 1 .56.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033Z" fill="#fff"/></svg>`,ARROW_DOWN_ICON:nt`<svg width="14" height="14" viewBox="0 0 14 14"><path d="M2.28 7.47a.75.75 0 0 0-1.06 1.06l5.25 5.25a.75.75 0 0 0 1.06 0l5.25-5.25a.75.75 0 0 0-1.06-1.06l-3.544 3.543a.25.25 0 0 1-.426-.177V.75a.75.75 0 0 0-1.5 0v10.086a.25.25 0 0 1-.427.176L2.28 7.47Z" fill="#fff"/></svg>`,ARROW_UP_RIGHT_ICON:nt`<svg width="15" height="14" fill="none"><path d="M4.5 1.75A.75.75 0 0 1 5.25 1H12a1.5 1.5 0 0 1 1.5 1.5v6.75a.75.75 0 0 1-1.5 0V4.164a.25.25 0 0 0-.427-.176L4.061 11.5A.75.75 0 0 1 3 10.44l7.513-7.513a.25.25 0 0 0-.177-.427H5.25a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,ARROW_RIGHT_ICON:nt`<svg width="6" height="14" viewBox="0 0 6 14"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.181 1.099a.75.75 0 0 1 1.024.279l2.433 4.258a2.75 2.75 0 0 1 0 2.729l-2.433 4.257a.75.75 0 1 1-1.303-.744L4.335 7.62a1.25 1.25 0 0 0 0-1.24L1.902 2.122a.75.75 0 0 1 .28-1.023Z" fill="#fff"/></svg>`,QRCODE_ICON:nt`<svg width="25" height="24" viewBox="0 0 25 24"><path d="M23.748 9a.748.748 0 0 0 .748-.752c-.018-2.596-.128-4.07-.784-5.22a6 6 0 0 0-2.24-2.24c-1.15-.656-2.624-.766-5.22-.784a.748.748 0 0 0-.752.748c0 .414.335.749.748.752 1.015.007 1.82.028 2.494.088.995.09 1.561.256 1.988.5.7.398 1.28.978 1.679 1.678.243.427.41.993.498 1.988.061.675.082 1.479.09 2.493a.753.753 0 0 0 .75.749ZM3.527.788C4.677.132 6.152.022 8.747.004A.748.748 0 0 1 9.5.752a.753.753 0 0 1-.749.752c-1.014.007-1.818.028-2.493.088-.995.09-1.561.256-1.988.5-.7.398-1.28.978-1.679 1.678-.243.427-.41.993-.499 1.988-.06.675-.081 1.479-.088 2.493A.753.753 0 0 1 1.252 9a.748.748 0 0 1-.748-.752c.018-2.596.128-4.07.784-5.22a6 6 0 0 1 2.24-2.24ZM1.252 15a.748.748 0 0 0-.748.752c.018 2.596.128 4.07.784 5.22a6 6 0 0 0 2.24 2.24c1.15.656 2.624.766 5.22.784a.748.748 0 0 0 .752-.748.753.753 0 0 0-.749-.752c-1.014-.007-1.818-.028-2.493-.089-.995-.089-1.561-.255-1.988-.498a4.5 4.5 0 0 1-1.679-1.68c-.243-.426-.41-.992-.499-1.987-.06-.675-.081-1.479-.088-2.493A.753.753 0 0 0 1.252 15ZM22.996 15.749a.753.753 0 0 1 .752-.749c.415 0 .751.338.748.752-.018 2.596-.128 4.07-.784 5.22a6 6 0 0 1-2.24 2.24c-1.15.656-2.624.766-5.22.784a.748.748 0 0 1-.752-.748c0-.414.335-.749.748-.752 1.015-.007 1.82-.028 2.494-.089.995-.089 1.561-.255 1.988-.498a4.5 4.5 0 0 0 1.679-1.68c.243-.426.41-.992.498-1.987.061-.675.082-1.479.09-2.493Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 4a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 11h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 4H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1ZM13.5 6.5A2.5 2.5 0 0 1 16 4h2a2.5 2.5 0 0 1 2.5 2.5v2A2.5 2.5 0 0 1 18 11h-2a2.5 2.5 0 0 1-2.5-2.5v-2Zm2.5-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1ZM7 13a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 20h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 13H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1Z" fill="#fff"/><path d="M13.5 15.5c0-.465 0-.697.038-.89a2 2 0 0 1 1.572-1.572C15.303 13 15.535 13 16 13v2.5h-2.5ZM18 13c.465 0 .697 0 .89.038a2 2 0 0 1 1.572 1.572c.038.193.038.425.038.89H18V13ZM18 17.5h2.5c0 .465 0 .697-.038.89a2 2 0 0 1-1.572 1.572C18.697 20 18.465 20 18 20v-2.5ZM13.5 17.5H16V20c-.465 0-.697 0-.89-.038a2 2 0 0 1-1.572-1.572c-.038-.193-.038-.425-.038-.89Z" fill="#fff"/></svg>`,SCAN_ICON:nt`<svg width="16" height="16" fill="none"><path fill="#fff" d="M10 15.216c0 .422.347.763.768.74 1.202-.064 2.025-.222 2.71-.613a5.001 5.001 0 0 0 1.865-1.866c.39-.684.549-1.507.613-2.709a.735.735 0 0 0-.74-.768.768.768 0 0 0-.76.732c-.009.157-.02.306-.032.447-.073.812-.206 1.244-.384 1.555-.31.545-.761.996-1.306 1.306-.311.178-.743.311-1.555.384-.141.013-.29.023-.447.032a.768.768 0 0 0-.732.76ZM10 .784c0 .407.325.737.732.76.157.009.306.02.447.032.812.073 1.244.206 1.555.384a3.5 3.5 0 0 1 1.306 1.306c.178.311.311.743.384 1.555.013.142.023.29.032.447a.768.768 0 0 0 .76.732.734.734 0 0 0 .74-.768c-.064-1.202-.222-2.025-.613-2.71A5 5 0 0 0 13.477.658c-.684-.39-1.507-.549-2.709-.613a.735.735 0 0 0-.768.74ZM5.232.044A.735.735 0 0 1 6 .784a.768.768 0 0 1-.732.76c-.157.009-.305.02-.447.032-.812.073-1.244.206-1.555.384A3.5 3.5 0 0 0 1.96 3.266c-.178.311-.311.743-.384 1.555-.013.142-.023.29-.032.447A.768.768 0 0 1 .784 6a.735.735 0 0 1-.74-.768c.064-1.202.222-2.025.613-2.71A5 5 0 0 1 2.523.658C3.207.267 4.03.108 5.233.044ZM5.268 14.456a.768.768 0 0 1 .732.76.734.734 0 0 1-.768.74c-1.202-.064-2.025-.222-2.71-.613a5 5 0 0 1-1.865-1.866c-.39-.684-.549-1.507-.613-2.709A.735.735 0 0 1 .784 10c.407 0 .737.325.76.732.009.157.02.306.032.447.073.812.206 1.244.384 1.555a3.5 3.5 0 0 0 1.306 1.306c.311.178.743.311 1.555.384.142.013.29.023.447.032Z"/></svg>`,CHECKMARK_ICON:nt`<svg width="13" height="12" viewBox="0 0 13 12"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.155.132a.75.75 0 0 1 .232 1.035L5.821 11.535a1 1 0 0 1-1.626.09L.665 7.21a.75.75 0 1 1 1.17-.937L4.71 9.867a.25.25 0 0 0 .406-.023L11.12.364a.75.75 0 0 1 1.035-.232Z" fill="#fff"/></svg>`,SEARCH_ICON:nt`<svg width="20" height="21"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.432 13.992c-.354-.353-.91-.382-1.35-.146a5.5 5.5 0 1 1 2.265-2.265c-.237.441-.208.997.145 1.35l3.296 3.296a.75.75 0 1 1-1.06 1.061l-3.296-3.296Zm.06-5a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z" fill="#949E9E"/></svg>`,WALLET_PLACEHOLDER:nt`<svg width="60" height="60" fill="none" viewBox="0 0 60 60"><g clip-path="url(#q)"><path id="wallet-placeholder-fill" fill="#fff" d="M0 24.9c0-9.251 0-13.877 1.97-17.332a15 15 0 0 1 5.598-5.597C11.023 0 15.648 0 24.9 0h10.2c9.252 0 13.877 0 17.332 1.97a15 15 0 0 1 5.597 5.598C60 11.023 60 15.648 60 24.9v10.2c0 9.252 0 13.877-1.97 17.332a15.001 15.001 0 0 1-5.598 5.597C48.977 60 44.352 60 35.1 60H24.9c-9.251 0-13.877 0-17.332-1.97a15 15 0 0 1-5.597-5.598C0 48.977 0 44.352 0 35.1V24.9Z"/><path id="wallet-placeholder-dash" stroke="#000" stroke-dasharray="4 4" stroke-width="1.5" d="M.04 41.708a231.598 231.598 0 0 1-.039-4.403l.75-.001L.75 35.1v-2.55H0v-5.1h.75V24.9l.001-2.204h-.75c.003-1.617.011-3.077.039-4.404l.75.016c.034-1.65.099-3.08.218-4.343l-.746-.07c.158-1.678.412-3.083.82-4.316l.713.236c.224-.679.497-1.296.827-1.875a14.25 14.25 0 0 1 1.05-1.585L3.076 5.9A15 15 0 0 1 5.9 3.076l.455.596a14.25 14.25 0 0 1 1.585-1.05c.579-.33 1.196-.603 1.875-.827l-.236-.712C10.812.674 12.217.42 13.895.262l.07.746C15.23.89 16.66.824 18.308.79l-.016-.75C19.62.012 21.08.004 22.695.001l.001.75L24.9.75h2.55V0h5.1v.75h2.55l2.204.001v-.75c1.617.003 3.077.011 4.404.039l-.016.75c1.65.034 3.08.099 4.343.218l.07-.746c1.678.158 3.083.412 4.316.82l-.236.713c.679.224 1.296.497 1.875.827a14.24 14.24 0 0 1 1.585 1.05l.455-.596A14.999 14.999 0 0 1 56.924 5.9l-.596.455c.384.502.735 1.032 1.05 1.585.33.579.602 1.196.827 1.875l.712-.236c.409 1.233.663 2.638.822 4.316l-.747.07c.119 1.264.184 2.694.218 4.343l.75-.016c.028 1.327.036 2.787.039 4.403l-.75.001.001 2.204v2.55H60v5.1h-.75v2.55l-.001 2.204h.75a231.431 231.431 0 0 1-.039 4.404l-.75-.016c-.034 1.65-.099 3.08-.218 4.343l.747.07c-.159 1.678-.413 3.083-.822 4.316l-.712-.236a10.255 10.255 0 0 1-.827 1.875 14.242 14.242 0 0 1-1.05 1.585l.596.455a14.997 14.997 0 0 1-2.824 2.824l-.455-.596c-.502.384-1.032.735-1.585 1.05-.579.33-1.196.602-1.875.827l.236.712c-1.233.409-2.638.663-4.316.822l-.07-.747c-1.264.119-2.694.184-4.343.218l.016.75c-1.327.028-2.787.036-4.403.039l-.001-.75-2.204.001h-2.55V60h-5.1v-.75H24.9l-2.204-.001v.75a231.431 231.431 0 0 1-4.404-.039l.016-.75c-1.65-.034-3.08-.099-4.343-.218l-.07.747c-1.678-.159-3.083-.413-4.316-.822l.236-.712a10.258 10.258 0 0 1-1.875-.827 14.252 14.252 0 0 1-1.585-1.05l-.455.596A14.999 14.999 0 0 1 3.076 54.1l.596-.455a14.24 14.24 0 0 1-1.05-1.585 10.259 10.259 0 0 1-.827-1.875l-.712.236C.674 49.188.42 47.783.262 46.105l.746-.07C.89 44.77.824 43.34.79 41.692l-.75.016Z"/><path fill="#fff" fill-rule="evenodd" d="M35.643 32.145c-.297-.743-.445-1.114-.401-1.275a.42.42 0 0 1 .182-.27c.134-.1.463-.1 1.123-.1.742 0 1.499.046 2.236-.05a6 6 0 0 0 5.166-5.166c.051-.39.051-.855.051-1.784 0-.928 0-1.393-.051-1.783a6 6 0 0 0-5.166-5.165c-.39-.052-.854-.052-1.783-.052h-7.72c-4.934 0-7.401 0-9.244 1.051a8 8 0 0 0-2.985 2.986C16.057 22.28 16.003 24.58 16 29 15.998 31.075 16 33.15 16 35.224A7.778 7.778 0 0 0 23.778 43H28.5c1.394 0 2.09 0 2.67-.116a6 6 0 0 0 4.715-4.714c.115-.58.115-1.301.115-2.744 0-1.31 0-1.964-.114-2.49a4.998 4.998 0 0 0-.243-.792Z" clip-rule="evenodd"/><path fill="#9EA9A9" fill-rule="evenodd" d="M37 18h-7.72c-2.494 0-4.266.002-5.647.126-1.361.122-2.197.354-2.854.728a6.5 6.5 0 0 0-2.425 2.426c-.375.657-.607 1.492-.729 2.853-.11 1.233-.123 2.777-.125 4.867 0 .7 0 1.05.097 1.181.096.13.182.181.343.2.163.02.518-.18 1.229-.581a6.195 6.195 0 0 1 3.053-.8H37c.977 0 1.32-.003 1.587-.038a4.5 4.5 0 0 0 3.874-3.874c.036-.268.039-.611.039-1.588 0-.976-.003-1.319-.038-1.587a4.5 4.5 0 0 0-3.875-3.874C38.32 18.004 37.977 18 37 18Zm-7.364 12.5h-7.414a4.722 4.722 0 0 0-4.722 4.723 6.278 6.278 0 0 0 6.278 6.278H28.5c1.466 0 1.98-.008 2.378-.087a4.5 4.5 0 0 0 3.535-3.536c.08-.397.087-.933.087-2.451 0-1.391-.009-1.843-.08-2.17a3.5 3.5 0 0 0-2.676-2.676c-.328-.072-.762-.08-2.108-.08Z" clip-rule="evenodd"/></g><defs><clipPath id="q"><path fill="#fff" d="M0 0h60v60H0z"/></clipPath></defs></svg>`,GLOBE_ICON:nt`<svg width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="#fff" fill-rule="evenodd" d="M15.5 8a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Zm-2.113.75c.301 0 .535.264.47.558a6.01 6.01 0 0 1-2.867 3.896c-.203.116-.42-.103-.334-.32.409-1.018.691-2.274.797-3.657a.512.512 0 0 1 .507-.477h1.427Zm.47-2.058c.065.294-.169.558-.47.558H11.96a.512.512 0 0 1-.507-.477c-.106-1.383-.389-2.638-.797-3.656-.087-.217.13-.437.333-.32a6.01 6.01 0 0 1 2.868 3.895Zm-4.402.558c.286 0 .515-.24.49-.525-.121-1.361-.429-2.534-.83-3.393-.279-.6-.549-.93-.753-1.112a.535.535 0 0 0-.724 0c-.204.182-.474.513-.754 1.112-.4.859-.708 2.032-.828 3.393a.486.486 0 0 0 .49.525h2.909Zm-5.415 0c.267 0 .486-.21.507-.477.106-1.383.389-2.638.797-3.656.087-.217-.13-.437-.333-.32a6.01 6.01 0 0 0-2.868 3.895c-.065.294.169.558.47.558H4.04ZM2.143 9.308c-.065-.294.169-.558.47-.558H4.04c.267 0 .486.21.507.477.106 1.383.389 2.639.797 3.657.087.217-.13.436-.333.32a6.01 6.01 0 0 1-2.868-3.896Zm3.913-.033a.486.486 0 0 1 .49-.525h2.909c.286 0 .515.24.49.525-.121 1.361-.428 2.535-.83 3.394-.279.6-.549.93-.753 1.112a.535.535 0 0 1-.724 0c-.204-.182-.474-.513-.754-1.112-.4-.859-.708-2.033-.828-3.394Z" clip-rule="evenodd"/></svg>`},pk=ve`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var gk=Object.defineProperty,bk=Object.getOwnPropertyDescriptor,mk=(t,e,r,i)=>{for(var n=i>1?void 0:i?bk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&gk(e,r,n),n};let I0=class extends ae{render(){return G`<div class="wcm-toolbar-placeholder"></div><div class="wcm-toolbar">${we.WALLET_CONNECT_LOGO} <button @click="${as.close}">${we.CROSS_ICON}</button></div>`}};I0.styles=[he.globalCss,pk],I0=mk([de("wcm-modal-backcard")],I0);const vk=ve`main{padding:20px;padding-top:0;width:100%}`;var yk=Object.defineProperty,wk=Object.getOwnPropertyDescriptor,_k=(t,e,r,i)=>{for(var n=i>1?void 0:i?wk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&yk(e,r,n),n};let S0=class extends ae{render(){return G`<main><slot></slot></main>`}};S0.styles=[he.globalCss,vk],S0=_k([de("wcm-modal-content")],S0);const xk=ve`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var Ek=Object.defineProperty,$k=Object.getOwnPropertyDescriptor,Ik=(t,e,r,i)=>{for(var n=i>1?void 0:i?$k(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Ek(e,r,n),n};let A0=class extends ae{render(){return G`<footer><slot></slot></footer>`}};A0.styles=[he.globalCss,xk],A0=Ik([de("wcm-modal-footer")],A0);const Sk=ve`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var Ak=Object.defineProperty,Pk=Object.getOwnPropertyDescriptor,sc=(t,e,r,i)=>{for(var n=i>1?void 0:i?Pk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Ak(e,r,n),n};let gs=class extends ae{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return G`<button class="wcm-back-btn" @click="${Ge.goBack}">${we.BACK_ICON}</button>`}actionBtnTemplate(){return G`<button class="wcm-action-btn" @click="${this.onAction}">${this.actionIcon}</button>`}render(){const t={"wcm-border":this.border},e=Ge.state.history.length>1,r=this.title?G`<wcm-text variant="big-bold">${this.title}</wcm-text>`:G`<slot></slot>`;return G`<header class="${Hi(t)}">${e?this.backBtnTemplate():null} ${r} ${this.onAction?this.actionBtnTemplate():null}</header>`}};gs.styles=[he.globalCss,Sk],sc([ie()],gs.prototype,"title",2),sc([ie()],gs.prototype,"onAction",2),sc([ie()],gs.prototype,"actionIcon",2),sc([ie({type:Boolean})],gs.prototype,"border",2),gs=sc([de("wcm-modal-header")],gs);const te={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(t,e){const r=t.renderRoot.querySelector(e);if(!r)throw new Error(`${e} not found`);return r},getWalletIcon({id:t,image_id:e}){const{walletImages:r}=_r.state;return r?.[t]?r[t]:e?dr.getWalletImageUrl(e):""},getWalletName(t,e=!1){return e&&t.length>8?`${t.substring(0,8)}..`:t},isMobileAnimation(){return window.innerWidth<=te.MOBILE_BREAKPOINT},async preloadImage(t){const e=new Promise((r,i)=>{const n=new Image;n.onload=r,n.onerror=i,n.crossOrigin="anonymous",n.src=t});return Promise.race([e,J.wait(3e3)])},getErrorMessage(t){return t instanceof Error?t.message:"Unknown Error"},debounce(t,e=500){let r;return(...i)=>{function n(){t(...i)}r&&clearTimeout(r),r=setTimeout(n,e)}},handleMobileLinking(t,e="_self"){const{walletConnectUri:r}=vt.state,{mobile:i,name:n}=t,s=i?.native,o=i?.universal;te.setRecentWallet(t);function a(c){if(s){const l=J.formatNativeUrl(s,c,n);J.openHref(l,e)}else if(o){const l=J.formatUniversalUrl(o,c,n);J.openHref(l,e)}}r&&a(r)},handleAndroidLinking(){const{walletConnectUri:t}=vt.state;t&&(J.setWalletConnectAndroidDeepLink(t),J.openHref(t,J.isTelegram()?"_blank":"_self"))},async handleUriCopy(){const{walletConnectUri:t}=vt.state;if(t)try{await navigator.clipboard.writeText(t),yn.openToast("Link copied","success")}catch{yn.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:t}=_r.state,e=Object.values(t??{});return Object.values(e)},truncate(t,e=8){return t.length<=e?t:`${t.substring(0,4)}...${t.substring(t.length-4)}`},setRecentWallet(t){try{localStorage.setItem(te.WCM_RECENT_WALLET_DATA,JSON.stringify(t))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const t=localStorage.getItem(te.WCM_RECENT_WALLET_DATA);return t?JSON.parse(t):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(t,e){return t.toUpperCase().includes(e.toUpperCase())},openWalletExplorerUrl(){J.openHref(te.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:t,mobile:e}=J.getWalletRouterData(),r=!!t?.native,i=!!t?.universal,n=!!e?.native||!!e?.universal;return{isDesktop:r,isMobile:n,isWeb:i}},goToConnectingView(t){Ge.setData({Wallet:t});const e=J.isMobile(),{isDesktop:r,isWeb:i,isMobile:n}=te.getCachedRouterWalletPlatforms();e?n?(Ge.push("MobileConnecting"),!J.isAndroid()&&J.isTelegram()&&this.handleMobileLinking(t,"_blank")):i?Ge.push("WebConnecting"):Ge.push("InstallWallet"):r?Ge.push("DesktopConnecting"):i?Ge.push("WebConnecting"):n?Ge.push("MobileQrcodeConnecting"):Ge.push("InstallWallet")}},Ok=ve`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var Ck=Object.defineProperty,Dk=Object.getOwnPropertyDescriptor,P0=(t,e,r,i)=>{for(var n=i>1?void 0:i?Dk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Ck(e,r,n),n};let oc=class extends ae{constructor(){super(),this.view=Ge.state.view,this.prevView=Ge.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=Ge.subscribe(t=>{this.view!==t.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([t])=>{const e=`${t.contentRect.height}px`;this.oldHeight!=="0px"&&ps(this.routerEl,{height:[this.oldHeight,e]},{duration:.2}),this.oldHeight=e}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var t,e;(t=this.unsubscribe)==null||t.call(this),(e=this.resizeObserver)==null||e.disconnect()}get routerEl(){return te.getShadowRootElement(this,".wcm-router")}get contentEl(){return te.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return G`<wcm-connect-wallet-view></wcm-connect-wallet-view>`;case"DesktopConnecting":return G`<wcm-desktop-connecting-view></wcm-desktop-connecting-view>`;case"MobileConnecting":return G`<wcm-mobile-connecting-view></wcm-mobile-connecting-view>`;case"WebConnecting":return G`<wcm-web-connecting-view></wcm-web-connecting-view>`;case"MobileQrcodeConnecting":return G`<wcm-mobile-qr-connecting-view></wcm-mobile-qr-connecting-view>`;case"WalletExplorer":return G`<wcm-wallet-explorer-view></wcm-wallet-explorer-view>`;case"Qrcode":return G`<wcm-qrcode-view></wcm-qrcode-view>`;case"InstallWallet":return G`<wcm-install-wallet-view></wcm-install-wallet-view>`;default:return G`<div>Not Found</div>`}}async onChangeRoute(){await ps(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=Ge.state.view,ps(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return G`<div class="wcm-router"><div class="wcm-content">${this.viewTemplate()}</div></div>`}};oc.styles=[he.globalCss,Ok],P0([fr()],oc.prototype,"view",2),P0([fr()],oc.prototype,"prevView",2),oc=P0([de("wcm-modal-router")],oc);const Mk=ve`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var Tk=Object.defineProperty,Rk=Object.getOwnPropertyDescriptor,Iw=(t,e,r,i)=>{for(var n=i>1?void 0:i?Rk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Tk(e,r,n),n};let Iu=class extends ae{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=yn.subscribe(t=>{t.open?(this.open=!0,this.timeout=setTimeout(()=>yn.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var t;(t=this.unsubscribe)==null||t.call(this),clearTimeout(this.timeout),yn.closeToast()}render(){const{message:t,variant:e}=yn.state,r={"wcm-success":e==="success","wcm-error":e==="error"};return this.open?G`<div class="${Hi(r)}">${e==="success"?we.CHECKMARK_ICON:null} ${e==="error"?we.CROSS_ICON:null}<wcm-text variant="small-regular">${t}</wcm-text></div>`:null}};Iu.styles=[he.globalCss,Mk],Iw([fr()],Iu.prototype,"open",2),Iu=Iw([de("wcm-modal-toast")],Iu);const Nk=.1,Sw=2.5,Wi=7;function O0(t,e,r){return t===e?!1:(t-e<0?e-t:t-e)<=r+Nk}function Bk(t,e){const r=Array.prototype.slice.call(ec.create(t,{errorCorrectionLevel:e}).modules.data,0),i=Math.sqrt(r.length);return r.reduce((n,s,o)=>(o%i===0?n.push([s]):n[n.length-1].push(s))&&n,[])}const Lk={generate(t,e,r){const i="#141414",n="#ffffff",s=[],o=Bk(t,"Q"),a=e/o.length,c=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];c.forEach(({x:m,y:_})=>{const S=(o.length-Wi)*a*m,E=(o.length-Wi)*a*_,P=.45;for(let C=0;C<c.length;C+=1){const M=a*(Wi-C*2);s.push(nt`<rect fill="${C%2===0?i:n}" height="${M}" rx="${M*P}" ry="${M*P}" width="${M}" x="${S+a*C}" y="${E+a*C}">`)}});const l=Math.floor((r+25)/a),u=o.length/2-l/2,d=o.length/2+l/2-1,p=[];o.forEach((m,_)=>{m.forEach((S,E)=>{if(o[_][E]&&!(_<Wi&&E<Wi||_>o.length-(Wi+1)&&E<Wi||_<Wi&&E>o.length-(Wi+1))&&!(_>u&&_<d&&E>u&&E<d)){const P=_*a+a/2,C=E*a+a/2;p.push([P,C])}})});const y={};return p.forEach(([m,_])=>{y[m]?y[m].push(_):y[m]=[_]}),Object.entries(y).map(([m,_])=>{const S=_.filter(E=>_.every(P=>!O0(E,P,a)));return[Number(m),S]}).forEach(([m,_])=>{_.forEach(S=>{s.push(nt`<circle cx="${m}" cy="${S}" fill="${i}" r="${a/Sw}">`)})}),Object.entries(y).filter(([m,_])=>_.length>1).map(([m,_])=>{const S=_.filter(E=>_.some(P=>O0(E,P,a)));return[Number(m),S]}).map(([m,_])=>{_.sort((E,P)=>E<P?-1:1);const S=[];for(const E of _){const P=S.find(C=>C.some(M=>O0(E,M,a)));P?P.push(E):S.push([E])}return[m,S.map(E=>[E[0],E[E.length-1]])]}).forEach(([m,_])=>{_.forEach(([S,E])=>{s.push(nt`<line x1="${m}" x2="${m}" y1="${S}" y2="${E}" stroke="${i}" stroke-width="${a/(Sw/2)}" stroke-linecap="round">`)})}),s}},Fk=ve`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var Uk=Object.defineProperty,jk=Object.getOwnPropertyDescriptor,zo=(t,e,r,i)=>{for(var n=i>1?void 0:i?jk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Uk(e,r,n),n};let Vi=class extends ae{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const e=vn.state.themeMode==="light"?this.size:this.size-18*2;return nt`<svg height="${e}" width="${e}">${Lk.generate(this.uri,e,e/4)}</svg>`}render(){const t={"wcm-dark":vn.state.themeMode==="dark"};return G`<div style="${`width: ${this.size}px`}" class="${Hi(t)}">${this.walletId||this.imageUrl?G`<wcm-wallet-image walletId="${ir(this.walletId)}" imageId="${ir(this.imageId)}" imageUrl="${ir(this.imageUrl)}"></wcm-wallet-image>`:we.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}</div>`}};Vi.styles=[he.globalCss,Fk],zo([ie()],Vi.prototype,"uri",2),zo([ie({type:Number})],Vi.prototype,"size",2),zo([ie()],Vi.prototype,"imageId",2),zo([ie()],Vi.prototype,"walletId",2),zo([ie()],Vi.prototype,"imageUrl",2),Vi=zo([de("wcm-qrcode")],Vi);const qk=ve`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var zk=Object.defineProperty,kk=Object.getOwnPropertyDescriptor,Aw=(t,e,r,i)=>{for(var n=i>1?void 0:i?kk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&zk(e,r,n),n};let Su=class extends ae{constructor(){super(...arguments),this.onChange=()=>null}render(){return G`<input type="text" @input="${this.onChange}" placeholder="Search wallets"> ${we.SEARCH_ICON}`}};Su.styles=[he.globalCss,qk],Aw([ie()],Su.prototype,"onChange",2),Su=Aw([de("wcm-search-input")],Su);const Hk=ve`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var Wk=Object.defineProperty,Vk=Object.getOwnPropertyDescriptor,Kk=(t,e,r,i)=>{for(var n=i>1?void 0:i?Vk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Wk(e,r,n),n};let C0=class extends ae{render(){return G`<svg viewBox="0 0 50 50" width="24" height="24"><circle cx="25" cy="25" r="20" fill="none" stroke-width="4" stroke="#fff"/></svg>`}};C0.styles=[he.globalCss,Hk],C0=Kk([de("wcm-spinner")],C0);const Gk=ve`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var Zk=Object.defineProperty,Yk=Object.getOwnPropertyDescriptor,D0=(t,e,r,i)=>{for(var n=i>1?void 0:i?Yk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Zk(e,r,n),n};let ac=class extends ae{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const t={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return G`<span><slot class="${Hi(t)}"></slot></span>`}};ac.styles=[he.globalCss,Gk],D0([ie()],ac.prototype,"variant",2),D0([ie()],ac.prototype,"color",2),ac=D0([de("wcm-text")],ac);const Jk=ve`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var Qk=Object.defineProperty,Xk=Object.getOwnPropertyDescriptor,In=(t,e,r,i)=>{for(var n=i>1?void 0:i?Xk(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&Qk(e,r,n),n};let Si=class extends ae{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?G`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">RECENT</wcm-text>`:this.installed?G`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">INSTALLED</wcm-text>`:null}handleClick(){hy.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var t;return G`<button @click="${this.handleClick.bind(this)}"><div><wcm-wallet-image walletId="${this.walletId}" imageId="${ir(this.imageId)}"></wcm-wallet-image><wcm-text variant="xsmall-regular">${(t=this.label)!=null?t:te.getWalletName(this.name,!0)}</wcm-text>${this.sublabelTemplate()}</div></button>`}};Si.styles=[he.globalCss,Jk],In([ie()],Si.prototype,"onClick",2),In([ie()],Si.prototype,"name",2),In([ie()],Si.prototype,"walletId",2),In([ie()],Si.prototype,"label",2),In([ie()],Si.prototype,"imageId",2),In([ie({type:Boolean})],Si.prototype,"installed",2),In([ie({type:Boolean})],Si.prototype,"recent",2),Si=In([de("wcm-wallet-button")],Si);const eH=ve`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var tH=Object.defineProperty,rH=Object.getOwnPropertyDescriptor,Au=(t,e,r,i)=>{for(var n=i>1?void 0:i?rH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&tH(e,r,n),n};let ko=class extends ae{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var t;const e=(t=this.imageUrl)!=null&&t.length?this.imageUrl:te.getWalletIcon({id:this.walletId,image_id:this.imageId});return G`${e.length?G`<div><img crossorigin="anonymous" src="${e}" alt="${this.id}"></div>`:we.WALLET_PLACEHOLDER}`}};ko.styles=[he.globalCss,eH],Au([ie()],ko.prototype,"walletId",2),Au([ie()],ko.prototype,"imageId",2),Au([ie()],ko.prototype,"imageUrl",2),ko=Au([de("wcm-wallet-image")],ko);var iH=Object.defineProperty,nH=Object.getOwnPropertyDescriptor,Pw=(t,e,r,i)=>{for(var n=i>1?void 0:i?nH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&iH(e,r,n),n};let M0=class extends ae{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(t){try{t?.length&&await Promise.all(t.map(async e=>te.preloadImage(e)))}catch{console.info("Unsuccessful attempt at preloading some images",t)}}async preloadListings(){if(_r.state.enableExplorer){await dr.getRecomendedWallets(),vt.setIsDataLoaded(!0);const{recomendedWallets:t}=dr.state,e=t.map(r=>te.getWalletIcon(r));await this.loadImages(e)}else vt.setIsDataLoaded(!0)}async preloadCustomImages(){const t=te.getCustomImageUrls();await this.loadImages(t)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(t){console.error(t),yn.openToast("Failed preloading","error")}}};Pw([fr()],M0.prototype,"preload",2),M0=Pw([de("wcm-explorer-context")],M0);var sH=Object.defineProperty,oH=Object.getOwnPropertyDescriptor,aH=(t,e,r,i)=>{for(var n=i>1?void 0:i?oH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&sH(e,r,n),n};let Ow=class extends ae{constructor(){super(),this.unsubscribeTheme=void 0,he.setTheme(),this.unsubscribeTheme=vn.subscribe(he.setTheme)}disconnectedCallback(){var t;(t=this.unsubscribeTheme)==null||t.call(this)}};Ow=aH([de("wcm-theme-context")],Ow);const cH=ve`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var lH=Object.defineProperty,uH=Object.getOwnPropertyDescriptor,hH=(t,e,r,i)=>{for(var n=i>1?void 0:i?uH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&lH(e,r,n),n};let T0=class extends ae{onGoToQrcode(){Ge.push("Qrcode")}render(){const{recomendedWallets:t}=dr.state,e=[...t,...t],r=J.RECOMMENDED_WALLET_AMOUNT*2;return G`<wcm-modal-header title="Connect your wallet" .onAction="${this.onGoToQrcode}" .actionIcon="${we.QRCODE_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-title">${we.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">WalletConnect</wcm-text></div><div class="wcm-slider"><div class="wcm-track">${[...Array(r)].map((i,n)=>{const s=e[n%e.length];return s?G`<wcm-wallet-image walletId="${s.id}" imageId="${s.image_id}"></wcm-wallet-image>`:we.WALLET_PLACEHOLDER})}</div><wcm-button-big @click="${te.handleAndroidLinking}"><wcm-text variant="medium-regular" color="inverse">Select Wallet</wcm-text></wcm-button-big></div></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">Choose WalletConnect to see supported apps on your device</wcm-text></wcm-info-footer>`}};T0.styles=[he.globalCss,cH],T0=hH([de("wcm-android-wallet-selection")],T0);const dH=ve`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var fH=Object.defineProperty,pH=Object.getOwnPropertyDescriptor,Ho=(t,e,r,i)=>{for(var n=i>1?void 0:i?pH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&fH(e,r,n),n};let Sn=class extends ae{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var t,e;const s=(e=(t=vn.state.themeVariables)==null?void 0:t["--wcm-wallet-icon-large-border-radius"])!=null?e:he.getPreset("--wcm-wallet-icon-large-border-radius");let o=0;s.includes("%")?o=88/100*parseInt(s,10):o=parseInt(s,10),o*=1.17;const a=317-o*1.57,c=425-o*1.8;return G`<svg viewBox="0 0 110 110" width="110" height="110"><rect id="wcm-loader" x="2" y="2" width="106" height="106" rx="${o}"/><use xlink:href="#wcm-loader" stroke-dasharray="106 ${a}" stroke-dashoffset="${c}"></use></svg>`}render(){const t={"wcm-error":this.isError,"wcm-stale":this.isStale};return G`<div class="${Hi(t)}">${this.svgLoaderTemplate()}<wcm-wallet-image walletId="${ir(this.walletId)}" imageId="${ir(this.imageId)}"></wcm-wallet-image></div><wcm-text variant="medium-regular" color="${this.isError?"error":"primary"}">${this.isError?"Connection declined":this.label}</wcm-text>`}};Sn.styles=[he.globalCss,dH],Ho([ie()],Sn.prototype,"walletId",2),Ho([ie()],Sn.prototype,"imageId",2),Ho([ie({type:Boolean})],Sn.prototype,"isError",2),Ho([ie({type:Boolean})],Sn.prototype,"isStale",2),Ho([ie()],Sn.prototype,"label",2),Sn=Ho([de("wcm-connector-waiting")],Sn);const Wo={manualWallets(){var t,e;const{mobileWallets:r,desktopWallets:i}=_r.state,n=(t=Wo.recentWallet())==null?void 0:t.id,s=J.isMobile()?r:i,o=s?.filter(a=>n!==a.id);return(e=J.isMobile()?o?.map(({id:a,name:c,links:l})=>({id:a,name:c,mobile:l,links:l})):o?.map(({id:a,name:c,links:l})=>({id:a,name:c,desktop:l,links:l})))!=null?e:[]},recentWallet(){return te.getRecentWallet()},recomendedWallets(t=!1){var e;const r=t||(e=Wo.recentWallet())==null?void 0:e.id,{recomendedWallets:i}=dr.state;return i.filter(s=>r!==s.id)}},An={onConnecting(t){te.goToConnectingView(t)},manualWalletsTemplate(){return Wo.manualWallets().map(e=>G`<wcm-wallet-button walletId="${e.id}" name="${e.name}" .onClick="${()=>this.onConnecting(e)}"></wcm-wallet-button>`)},recomendedWalletsTemplate(t=!1){return Wo.recomendedWallets(t).map(r=>G`<wcm-wallet-button name="${r.name}" walletId="${r.id}" imageId="${r.image_id}" .onClick="${()=>this.onConnecting(r)}"></wcm-wallet-button>`)},recentWalletTemplate(){const t=Wo.recentWallet();if(t)return G`<wcm-wallet-button name="${t.name}" walletId="${t.id}" imageId="${ir(t.image_id)}" .recent="${!0}" .onClick="${()=>this.onConnecting(t)}"></wcm-wallet-button>`}},gH=ve`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var bH=Object.defineProperty,mH=Object.getOwnPropertyDescriptor,vH=(t,e,r,i)=>{for(var n=i>1?void 0:i?mH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&bH(e,r,n),n};let R0=class extends ae{render(){const{explorerExcludedWalletIds:t,enableExplorer:e}=_r.state,r=t!=="ALL"&&e,i=An.manualWalletsTemplate(),n=An.recomendedWalletsTemplate();let o=[An.recentWalletTemplate(),...i,...n];o=o.filter(Boolean);const a=o.length>4||r;let c=[];a?c=o.slice(0,3):c=o;const l=!!c.length;return G`<wcm-modal-header .border="${!0}" title="Connect your wallet" .onAction="${te.handleUriCopy}" .actionIcon="${we.COPY_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-mobile-title"><div class="wcm-subtitle">${we.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">Mobile</wcm-text></div><div class="wcm-subtitle">${we.SCAN_ICON}<wcm-text variant="small-regular" color="secondary">Scan with your wallet</wcm-text></div></div><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>${l?G`<wcm-modal-footer><div class="wcm-desktop-title">${we.DESKTOP_ICON}<wcm-text variant="small-regular" color="accent">Desktop</wcm-text></div><div class="wcm-grid">${c} ${a?G`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>`:null}</div></wcm-modal-footer>`:null}`}};R0.styles=[he.globalCss,gH],R0=vH([de("wcm-desktop-wallet-selection")],R0);const yH=ve`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var wH=Object.defineProperty,_H=Object.getOwnPropertyDescriptor,xH=(t,e,r,i)=>{for(var n=i>1?void 0:i?_H(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&wH(e,r,n),n};let N0=class extends ae{render(){const{termsOfServiceUrl:t,privacyPolicyUrl:e}=_r.state;return t??e?G`<div><wcm-text variant="small-regular" color="secondary">By connecting your wallet to this app, you agree to the app's ${t?G`<a href="${t}" target="_blank" rel="noopener noreferrer">Terms of Service</a>`:null} ${t&&e?"and":null} ${e?G`<a href="${e}" target="_blank" rel="noopener noreferrer">Privacy Policy</a>`:null}</wcm-text></div>`:null}};N0.styles=[he.globalCss,yH],N0=xH([de("wcm-legal-notice")],N0);const EH=ve`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var $H=Object.defineProperty,IH=Object.getOwnPropertyDescriptor,SH=(t,e,r,i)=>{for(var n=i>1?void 0:i?IH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&$H(e,r,n),n};let B0=class extends ae{onQrcode(){Ge.push("Qrcode")}render(){const{explorerExcludedWalletIds:t,enableExplorer:e}=_r.state,r=t!=="ALL"&&e,i=An.manualWalletsTemplate(),n=An.recomendedWalletsTemplate();let o=[An.recentWalletTemplate(),...i,...n];o=o.filter(Boolean);const a=o.length>8||r;let c=[];a?c=o.slice(0,7):c=o;const l=!!c.length;return G`<wcm-modal-header title="Connect your wallet" .onAction="${this.onQrcode}" .actionIcon="${we.QRCODE_ICON}"></wcm-modal-header>${l?G`<wcm-modal-content><div>${c} ${a?G`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>`:null}</div></wcm-modal-content>`:null}`}};B0.styles=[he.globalCss,EH],B0=SH([de("wcm-mobile-wallet-selection")],B0);const AH=ve`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var PH=Object.defineProperty,OH=Object.getOwnPropertyDescriptor,L0=(t,e,r,i)=>{for(var n=i>1?void 0:i?OH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&PH(e,r,n),n};let Vo=class extends ae{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=as.subscribe(t=>{t.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var t;(t=this.unsubscribeModal)==null||t.call(this)}get overlayEl(){return te.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return te.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(t){if(document.querySelector("body"))if(t){const r=document.getElementById("wcm-styles");r?.remove()}else document.head.insertAdjacentHTML("beforeend",'<style id="wcm-styles">html,body{touch-action:none;overflow:hidden;overscroll-behavior:contain;}</style>')}onCloseModal(t){t.target===t.currentTarget&&as.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const t=te.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},e=.1,r=.2;await Promise.all([ps(this.overlayEl,{opacity:[0,1]},{delay:e,duration:r}).finished,ps(this.containerEl,t,{delay:e,duration:r}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const t=te.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},e=.2;await Promise.all([ps(this.overlayEl,{opacity:[1,0]},{duration:e}).finished,ps(this.containerEl,t,{duration:e}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",t=>{var e;t.key==="Escape"?as.close():t.key==="Tab"&&((e=t.target)!=null&&e.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var t;(t=this.abortController)==null||t.abort(),this.abortController=void 0}render(){const t={"wcm-overlay":!0,"wcm-active":this.active};return G`<wcm-explorer-context></wcm-explorer-context><wcm-theme-context></wcm-theme-context><div id="wcm-modal" class="${Hi(t)}" @click="${this.onCloseModal}" role="alertdialog" aria-modal="true"><div class="wcm-container" tabindex="0">${this.open?G`<wcm-modal-backcard></wcm-modal-backcard><div class="wcm-card"><wcm-modal-router></wcm-modal-router><wcm-modal-toast></wcm-modal-toast></div>`:null}</div></div>`}};Vo.styles=[he.globalCss,AH],L0([fr()],Vo.prototype,"open",2),L0([fr()],Vo.prototype,"active",2),Vo=L0([de("wcm-modal")],Vo);const CH=ve`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var DH=Object.defineProperty,MH=Object.getOwnPropertyDescriptor,cc=(t,e,r,i)=>{for(var n=i>1?void 0:i?MH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&DH(e,r,n),n};let bs=class extends ae{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){J.isMobile()?Ge.replace("MobileConnecting"):Ge.replace("MobileQrcodeConnecting")}onDesktop(){Ge.replace("DesktopConnecting")}onWeb(){Ge.replace("WebConnecting")}render(){return G`<div>${this.isRetry?G`<slot></slot>`:null} ${this.isMobile?G`<wcm-button .onClick="${this.onMobile}" .iconLeft="${we.MOBILE_ICON}" variant="outline">Mobile</wcm-button>`:null} ${this.isDesktop?G`<wcm-button .onClick="${this.onDesktop}" .iconLeft="${we.DESKTOP_ICON}" variant="outline">Desktop</wcm-button>`:null} ${this.isWeb?G`<wcm-button .onClick="${this.onWeb}" .iconLeft="${we.GLOBE_ICON}" variant="outline">Web</wcm-button>`:null}</div>`}};bs.styles=[he.globalCss,CH],cc([ie({type:Boolean})],bs.prototype,"isMobile",2),cc([ie({type:Boolean})],bs.prototype,"isDesktop",2),cc([ie({type:Boolean})],bs.prototype,"isWeb",2),cc([ie({type:Boolean})],bs.prototype,"isRetry",2),bs=cc([de("wcm-platform-selection")],bs);const TH=ve`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var RH=Object.defineProperty,NH=Object.getOwnPropertyDescriptor,BH=(t,e,r,i)=>{for(var n=i>1?void 0:i?NH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&RH(e,r,n),n};let F0=class extends ae{onClick(){Ge.push("WalletExplorer")}render(){const{recomendedWallets:t}=dr.state,e=Wo.manualWallets(),r=[...t,...e].reverse().slice(0,4);return G`<button @click="${this.onClick}"><div class="wcm-icons">${r.map(i=>{const n=te.getWalletIcon(i);if(n)return G`<img crossorigin="anonymous" src="${n}">`;const s=te.getWalletIcon({id:i.id});return s?G`<img crossorigin="anonymous" src="${s}">`:we.WALLET_PLACEHOLDER})} ${[...Array(4-r.length)].map(()=>we.WALLET_PLACEHOLDER)}</div><wcm-text variant="xsmall-regular">View All</wcm-text></button>`}};F0.styles=[he.globalCss,TH],F0=BH([de("wcm-view-all-wallets-button")],F0);const LH=ve`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var FH=Object.defineProperty,UH=Object.getOwnPropertyDescriptor,Pu=(t,e,r,i)=>{for(var n=i>1?void 0:i?UH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&FH(e,r,n),n};let Ko=class extends ae{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:t}=vt.state;this.uri=t},0)}get overlayEl(){return te.getShadowRootElement(this,".wcm-qr-container")}render(){return G`<div class="wcm-qr-container">${this.uri?G`<wcm-qrcode size="${this.overlayEl.offsetWidth}" uri="${this.uri}" walletId="${ir(this.walletId)}" imageId="${ir(this.imageId)}"></wcm-qrcode>`:G`<wcm-spinner></wcm-spinner>`}</div>`}};Ko.styles=[he.globalCss,LH],Pu([ie()],Ko.prototype,"walletId",2),Pu([ie()],Ko.prototype,"imageId",2),Pu([fr()],Ko.prototype,"uri",2),Ko=Pu([de("wcm-walletconnect-qr")],Ko);var jH=Object.defineProperty,qH=Object.getOwnPropertyDescriptor,zH=(t,e,r,i)=>{for(var n=i>1?void 0:i?qH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&jH(e,r,n),n};let U0=class extends ae{viewTemplate(){return J.isAndroid()&&!J.isTelegram()?G`<wcm-android-wallet-selection></wcm-android-wallet-selection>`:J.isMobile()?G`<wcm-mobile-wallet-selection></wcm-mobile-wallet-selection>`:G`<wcm-desktop-wallet-selection></wcm-desktop-wallet-selection>`}render(){return G`${this.viewTemplate()}<wcm-legal-notice></wcm-legal-notice>`}};U0.styles=[he.globalCss],U0=zH([de("wcm-connect-wallet-view")],U0);const kH=ve`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var HH=Object.defineProperty,WH=Object.getOwnPropertyDescriptor,Cw=(t,e,r,i)=>{for(var n=i>1?void 0:i?WH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&HH(e,r,n),n};let Ou=class extends ae{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(t){const{desktop:e,name:r}=J.getWalletRouterData(),i=e?.native,n=e?.universal;if(i){const s=J.formatNativeUrl(i,t,r);J.openHref(s,"_self")}else if(n){const s=J.formatUniversalUrl(n,t,r);J.openHref(s,"_blank")}}openDesktopApp(){const{walletConnectUri:t}=vt.state,e=J.getWalletRouterData();te.setRecentWallet(e),t&&this.onFormatAndRedirect(t)}render(){const{name:t,id:e,image_id:r}=J.getWalletRouterData(),{isMobile:i,isWeb:n}=te.getCachedRouterWalletPlatforms();return G`<wcm-modal-header title="${t}" .onAction="${te.handleUriCopy}" .actionIcon="${we.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${ir(r)}" label="${`Continue in ${t}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Connection can continue loading if ${t} is not installed on your device`}</wcm-text><wcm-platform-selection .isMobile="${i}" .isWeb="${n}" .isRetry="${!0}"><wcm-button .onClick="${this.openDesktopApp.bind(this)}" .iconRight="${we.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};Ou.styles=[he.globalCss,kH],Cw([fr()],Ou.prototype,"isError",2),Ou=Cw([de("wcm-desktop-connecting-view")],Ou);const VH=ve`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var KH=Object.defineProperty,GH=Object.getOwnPropertyDescriptor,ZH=(t,e,r,i)=>{for(var n=i>1?void 0:i?GH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&KH(e,r,n),n};let j0=class extends ae{onInstall(t){t&&J.openHref(t,"_blank")}render(){const{name:t,id:e,image_id:r,homepage:i}=J.getWalletRouterData();return G`<wcm-modal-header title="${t}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${ir(r)}" label="Not Detected" .isStale="${!0}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Download ${t} to continue. If multiple browser extensions are installed, disable non ${t} ones and try again`}</wcm-text><wcm-button .onClick="${()=>this.onInstall(i)}" .iconLeft="${we.ARROW_DOWN_ICON}">Download</wcm-button></wcm-info-footer>`}};j0.styles=[he.globalCss,VH],j0=ZH([de("wcm-install-wallet-view")],j0);const YH=ve`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var JH=Object.defineProperty,QH=Object.getOwnPropertyDescriptor,Dw=(t,e,r,i)=>{for(var n=i>1?void 0:i?QH(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&JH(e,r,n),n};let Cu=class extends ae{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(t,e=!1){const{mobile:r,name:i}=J.getWalletRouterData(),n=r?.native,s=r?.universal,o=J.isTelegram()?"_blank":"_self";if(t=J.isTelegram()&&J.isAndroid()?encodeURIComponent(t):t,n&&!e){const a=J.formatNativeUrl(n,t,i);J.openHref(a,o)}else if(s){const a=J.formatUniversalUrl(s,t,i);J.openHref(a,o)}}openMobileApp(t=!1){const{walletConnectUri:e}=vt.state,r=J.getWalletRouterData();e&&this.onFormatAndRedirect(e,t),te.setRecentWallet(r)}onGoToAppStore(t){t&&J.openHref(t,"_blank")}render(){const{name:t,id:e,image_id:r,app:i,mobile:n}=J.getWalletRouterData(),{isWeb:s}=te.getCachedRouterWalletPlatforms(),o=i?.ios,a=n?.universal;return G`<wcm-modal-header title="${t}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${ir(r)}" label="Tap 'Open' to continue…" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer class="wcm-note"><wcm-platform-selection .isWeb="${s}" .isRetry="${!0}"><wcm-button .onClick="${()=>this.openMobileApp(!1)}" .iconRight="${we.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection>${a?G`<wcm-text color="secondary" variant="small-thin">Still doesn't work? <span tabindex="0" @click="${()=>this.openMobileApp(!0)}">Try this alternate link</span></wcm-text>`:null}</wcm-info-footer><wcm-info-footer class="wcm-app-store"><div><wcm-wallet-image walletId="${e}" imageId="${ir(r)}"></wcm-wallet-image><wcm-text>${`Get ${t}`}</wcm-text></div><wcm-button .iconRight="${we.ARROW_RIGHT_ICON}" .onClick="${()=>this.onGoToAppStore(o)}" variant="ghost">App Store</wcm-button></wcm-info-footer>`}};Cu.styles=[he.globalCss,YH],Dw([fr()],Cu.prototype,"isError",2),Cu=Dw([de("wcm-mobile-connecting-view")],Cu);const XH=ve`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var eW=Object.defineProperty,tW=Object.getOwnPropertyDescriptor,rW=(t,e,r,i)=>{for(var n=i>1?void 0:i?tW(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&eW(e,r,n),n};let q0=class extends ae{render(){const{name:t,id:e,image_id:r}=J.getWalletRouterData(),{isDesktop:i,isWeb:n}=te.getCachedRouterWalletPlatforms();return G`<wcm-modal-header title="${t}" .onAction="${te.handleUriCopy}" .actionIcon="${we.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr walletId="${e}" imageId="${ir(r)}"></wcm-walletconnect-qr></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Scan this QR Code with your phone's camera or inside ${t} app`}</wcm-text><wcm-platform-selection .isDesktop="${i}" .isWeb="${n}"></wcm-platform-selection></wcm-info-footer>`}};q0.styles=[he.globalCss,XH],q0=rW([de("wcm-mobile-qr-connecting-view")],q0);var iW=Object.defineProperty,nW=Object.getOwnPropertyDescriptor,sW=(t,e,r,i)=>{for(var n=i>1?void 0:i?nW(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&iW(e,r,n),n};let z0=class extends ae{render(){return G`<wcm-modal-header title="Scan the code" .onAction="${te.handleUriCopy}" .actionIcon="${we.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>`}};z0.styles=[he.globalCss],z0=sW([de("wcm-qrcode-view")],z0);const oW=ve`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var aW=Object.defineProperty,cW=Object.getOwnPropertyDescriptor,lc=(t,e,r,i)=>{for(var n=i>1?void 0:i?cW(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&aW(e,r,n),n};const k0=40;let ms=class extends ae{constructor(){super(...arguments),this.loading=!dr.state.wallets.listings.length,this.firstFetch=!dr.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=te.debounce(t=>{t.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=t,dr.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),dr.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var t;(t=this.intersectionObserver)==null||t.disconnect()}get placeholderEl(){return te.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([t])=>{t.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:t,search:e}=dr.state,{listings:r,total:i}=this.search?e:t;return i<=k0||r.length>=i}async fetchWallets(){var t;const{wallets:e,search:r}=dr.state,{listings:i,total:n,page:s}=this.search?r:e;if(!this.endReached&&(this.firstFetch||n>k0&&i.length<n))try{this.loading=!0;const o=(t=vt.state.chains)==null?void 0:t.join(","),{listings:a}=await dr.getWallets({page:this.firstFetch?1:s+1,entries:k0,search:this.search,version:2,chains:o}),c=a.map(l=>te.getWalletIcon(l));await Promise.all([...c.map(async l=>te.preloadImage(l)),J.wait(300)]),this.endReached=this.isLastPage()}catch(o){console.error(o),yn.openToast(te.getErrorMessage(o),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(t){J.isAndroid()?te.handleMobileLinking(t):te.goToConnectingView(t)}onSearchChange(t){const{value:e}=t.target;this.searchDebounce(e)}render(){const{wallets:t,search:e}=dr.state,{listings:r}=this.search?e:t,i=this.loading&&!r.length,n=this.search.length>=3;let s=An.manualWalletsTemplate(),o=An.recomendedWalletsTemplate(!0);n&&(s=s.filter(({values:l})=>te.caseSafeIncludes(l[0],this.search)),o=o.filter(({values:l})=>te.caseSafeIncludes(l[0],this.search)));const a=!this.loading&&!r.length&&!o.length,c={"wcm-loading":i,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":a};return G`<wcm-modal-header><wcm-search-input .onChange="${this.onSearchChange.bind(this)}"></wcm-search-input></wcm-modal-header><wcm-modal-content class="${Hi(c)}"><div class="wcm-grid">${i?null:s} ${i?null:o} ${i?null:r.map(l=>G`${l?G`<wcm-wallet-button imageId="${l.image_id}" name="${l.name}" walletId="${l.id}" .onClick="${()=>this.onConnect(l)}"></wcm-wallet-button>`:null}`)}</div><div class="wcm-placeholder-block">${a?G`<wcm-text variant="big-bold" color="secondary">No results found</wcm-text>`:null} ${!a&&this.loading?G`<wcm-spinner></wcm-spinner>`:null}</div></wcm-modal-content>`}};ms.styles=[he.globalCss,oW],lc([fr()],ms.prototype,"loading",2),lc([fr()],ms.prototype,"firstFetch",2),lc([fr()],ms.prototype,"search",2),lc([fr()],ms.prototype,"endReached",2),ms=lc([de("wcm-wallet-explorer-view")],ms);const lW=ve`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var uW=Object.defineProperty,hW=Object.getOwnPropertyDescriptor,Mw=(t,e,r,i)=>{for(var n=i>1?void 0:i?hW(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&uW(e,r,n),n};let Du=class extends ae{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(t){const{desktop:e,name:r}=J.getWalletRouterData(),i=e?.universal;if(i){const n=J.formatUniversalUrl(i,t,r);J.openHref(n,"_blank")}}openWebWallet(){const{walletConnectUri:t}=vt.state,e=J.getWalletRouterData();te.setRecentWallet(e),t&&this.onFormatAndRedirect(t)}render(){const{name:t,id:e,image_id:r}=J.getWalletRouterData(),{isMobile:i,isDesktop:n}=te.getCachedRouterWalletPlatforms(),s=J.isMobile();return G`<wcm-modal-header title="${t}" .onAction="${te.handleUriCopy}" .actionIcon="${we.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${e}" imageId="${ir(r)}" label="${`Continue in ${t}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`${t} web app has opened in a new tab. Go there, accept the connection, and come back`}</wcm-text><wcm-platform-selection .isMobile="${i}" .isDesktop="${s?!1:n}" .isRetry="${!0}"><wcm-button .onClick="${this.openWebWallet.bind(this)}" .iconRight="${we.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};Du.styles=[he.globalCss,lW],Mw([fr()],Du.prototype,"isError",2),Du=Mw([de("wcm-web-connecting-view")],Du);var dW=Object.freeze({__proto__:null,get WcmModal(){return Vo},get WcmQrCode(){return Vi}});Ur.EthereumProvider=Nj,Ur.OPTIONAL_EVENTS=ay,Ur.OPTIONAL_METHODS=oy,Ur.REQUIRED_EVENTS=ru,Ur.REQUIRED_METHODS=tu,Ur.default=su,Object.defineProperty(Ur,"__esModule",{value:!0})});
|
|
98
94
|
//# sourceMappingURL=index.umd.js.map
|