@walletconnect/ethereum-provider 2.2.0 → 2.3.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 CHANGED
@@ -1,4 +1,4 @@
1
- (function(St,ke){typeof exports=="object"&&typeof module<"u"?ke(exports):typeof define=="function"&&define.amd?define(["exports"],ke):(St=typeof globalThis<"u"?globalThis:St||self,ke(St["@walletconnect/ethereum-provider"]={}))})(this,function(St){"use strict";var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Zt(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(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Wn={exports:{}},hr=typeof Reflect=="object"?Reflect:null,gs=hr&&typeof hr.apply=="function"?hr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},rn;hr&&typeof hr.ownKeys=="function"?rn=hr.ownKeys:Object.getOwnPropertySymbols?rn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:rn=function(e){return Object.getOwnPropertyNames(e)};function Uu(t){console&&console.warn&&console.warn(t)}var ys=Number.isNaN||function(e){return e!==e};function xe(){xe.init.call(this)}Wn.exports=xe,Wn.exports.once=Ku,xe.EventEmitter=xe,xe.prototype._events=void 0,xe.prototype._eventsCount=0,xe.prototype._maxListeners=void 0;var vs=10;function nn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(xe,"defaultMaxListeners",{enumerable:!0,get:function(){return vs},set:function(t){if(typeof t!="number"||t<0||ys(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");vs=t}}),xe.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},xe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ys(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 _s(t){return t._maxListeners===void 0?xe.defaultMaxListeners:t._maxListeners}xe.prototype.getMaxListeners=function(){return _s(this)},xe.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")gs(h,this,r);else for(var f=h.length,l=Ds(h,f),n=0;n<f;++n)gs(l[n],this,r);return!0};function bs(t,e,r,n){var i,s,o;if(nn(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=_s(t),i>0&&o.length>i&&!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,Uu(a)}return t}xe.prototype.addListener=function(e,r){return bs(this,e,r,!1)},xe.prototype.on=xe.prototype.addListener,xe.prototype.prependListener=function(e,r){return bs(this,e,r,!0)};function ju(){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 ms(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=ju.bind(n);return i.listener=r,n.wrapFn=i,i}xe.prototype.once=function(e,r){return nn(r),this.on(e,ms(this,e,r)),this},xe.prototype.prependOnceListener=function(e,r){return nn(r),this.prependListener(e,ms(this,e,r)),this},xe.prototype.removeListener=function(e,r){var n,i,s,o,a;if(nn(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():Bu(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},xe.prototype.off=xe.prototype.removeListener,xe.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ws(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?zu(i):Ds(i,i.length)}xe.prototype.listeners=function(e){return ws(this,e,!0)},xe.prototype.rawListeners=function(e){return ws(this,e,!1)},xe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Es.call(t,e)},xe.prototype.listenerCount=Es;function Es(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}xe.prototype.eventNames=function(){return this._eventsCount>0?rn(this._events):[]};function Ds(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Bu(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function zu(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ku(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}xs(t,e,s,{once:!0}),e!=="error"&&qu(t,i,{once:!0})})}function qu(t,e,r){typeof t.on=="function"&&xs(t,"error",e,r)}function xs(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}function Ye(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var kn=Ye;Ye.EventEmitter=Ye,Ye.prototype._events=void 0,Ye.prototype._maxListeners=void 0,Ye.defaultMaxListeners=10,Ye.prototype.setMaxListeners=function(t){if(!Hu(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ye.prototype.emit=function(t){var e,r,n,i,s,o;if(this._events||(this._events={}),t==="error"&&(!this._events.error||xr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var a=new Error('Uncaught, unspecified "error" event. ('+e+")");throw a.context=e,a}if(r=this._events[t],Ss(r))return!1;if(Ft(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(xr(r))for(i=Array.prototype.slice.call(arguments,1),o=r.slice(),n=o.length,s=0;s<n;s++)o[s].apply(this,i);return!0},Ye.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?xr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,xr(this._events[t])&&!this._events[t].warned&&(Ss(this._maxListeners)?r=Ye.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ye.prototype.on=Ye.prototype.addListener,Ye.prototype.once=function(t,e){if(!Ft(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ye.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ft(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ft(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(xr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ye.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ft(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ye.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ft(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ye.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},Ye.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function Hu(t){return typeof t=="number"}function xr(t){return typeof t=="object"&&t!==null}function Ss(t){return t===void 0}const Vu="PARSE_ERROR",Gu="INVALID_REQUEST",Wu="METHOD_NOT_FOUND",ku="INVALID_PARAMS",Os="INTERNAL_ERROR",Yn="SERVER_ERROR",Yu=[-32700,-32600,-32601,-32602,-32603],Sr={[Vu]:{code:-32700,message:"Parse error"},[Gu]:{code:-32600,message:"Invalid Request"},[Wu]:{code:-32601,message:"Method not found"},[ku]:{code:-32602,message:"Invalid params"},[Os]:{code:-32603,message:"Internal error"},[Yn]:{code:-32e3,message:"Server error"}},Ls=Yn;function Ju(t){return Yu.includes(t)}function Is(t){return Object.keys(Sr).includes(t)?Sr[t]:Sr[Ls]}function Xu(t){const e=Object.values(Sr).find(r=>r.code===t);return e||Sr[Ls]}function As(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Ts={};/*! *****************************************************************************
1
+ (function(vt,He){typeof exports=="object"&&typeof module<"u"?He(exports):typeof define=="function"&&define.amd?define(["exports"],He):(vt=typeof globalThis<"u"?globalThis:vt||self,He(vt["@walletconnect/ethereum-provider"]={}))})(this,function(vt){"use strict";var He=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Kt(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(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Ze={exports:{}},nr=typeof Reflect=="object"?Reflect:null,qi=nr&&typeof nr.apply=="function"?nr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},qr;nr&&typeof nr.ownKeys=="function"?qr=nr.ownKeys:Object.getOwnPropertySymbols?qr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:qr=function(e){return Object.getOwnPropertyNames(e)};function uc(t){console&&console.warn&&console.warn(t)}var Hi=Number.isNaN||function(e){return e!==e};function Se(){Se.init.call(this)}Ze.exports=Se,Ze.exports.once=dc,Se.EventEmitter=Se,Se.prototype._events=void 0,Se.prototype._eventsCount=0,Se.prototype._maxListeners=void 0;var Ki=10;function Hr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Se,"defaultMaxListeners",{enumerable:!0,get:function(){return Ki},set:function(t){if(typeof t!="number"||t<0||Hi(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ki=t}}),Se.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Se.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Hi(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 Vi(t){return t._maxListeners===void 0?Se.defaultMaxListeners:t._maxListeners}Se.prototype.getMaxListeners=function(){return Vi(this)},Se.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")qi(f,this,r);else for(var h=f.length,l=Ji(f,h),n=0;n<h;++n)qi(l[n],this,r);return!0};function Gi(t,e,r,n){var i,s,o;if(Hr(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=Vi(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,uc(c)}return t}Se.prototype.addListener=function(e,r){return Gi(this,e,r,!1)},Se.prototype.on=Se.prototype.addListener,Se.prototype.prependListener=function(e,r){return Gi(this,e,r,!0)};function hc(){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 Wi(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=hc.bind(n);return i.listener=r,n.wrapFn=i,i}Se.prototype.once=function(e,r){return Hr(r),this.on(e,Wi(this,e,r)),this},Se.prototype.prependOnceListener=function(e,r){return Hr(r),this.prependListener(e,Wi(this,e,r)),this},Se.prototype.removeListener=function(e,r){var n,i,s,o,c;if(Hr(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){c=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():fc(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this},Se.prototype.off=Se.prototype.removeListener,Se.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ki(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?lc(i):Ji(i,i.length)}Se.prototype.listeners=function(e){return ki(this,e,!0)},Se.prototype.rawListeners=function(e){return ki(this,e,!1)},Se.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Yi.call(t,e)},Se.prototype.listenerCount=Yi;function Yi(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Se.prototype.eventNames=function(){return this._eventsCount>0?qr(this._events):[]};function Ji(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function fc(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function lc(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function dc(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Xi(t,e,s,{once:!0}),e!=="error"&&pc(t,i,{once:!0})})}function pc(t,e,r){typeof t.on=="function"&&Xi(t,"error",e,r)}function Xi(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const gc="PARSE_ERROR",yc="INVALID_REQUEST",_c="METHOD_NOT_FOUND",bc="INVALID_PARAMS",Zi="INTERNAL_ERROR",Dn="SERVER_ERROR",vc=[-32700,-32600,-32601,-32602,-32603],fr={[gc]:{code:-32700,message:"Parse error"},[yc]:{code:-32600,message:"Invalid Request"},[_c]:{code:-32601,message:"Method not found"},[bc]:{code:-32602,message:"Invalid params"},[Zi]:{code:-32603,message:"Internal error"},[Dn]:{code:-32e3,message:"Server error"}},Qi=Dn;function wc(t){return vc.includes(t)}function es(t){return Object.keys(fr).includes(t)?fr[t]:fr[Qi]}function mc(t){const e=Object.values(fr).find(r=>r.code===t);return e||fr[Qi]}function ts(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var rs={};/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -11,7 +11,7 @@
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 Jn=function(t,e){return Jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Jn(t,e)};function Zu(t,e){Jn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Xn=function(){return Xn=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Xn.apply(this,arguments)};function Qu(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function ef(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function tf(t,e){return function(r,n){e(r,n,t)}}function rf(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function nf(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{f(n.next(l))}catch(D){o(D)}}function h(l){try{f(n.throw(l))}catch(D){o(D)}}function f(l){l.done?s(l.value):i(l.value).then(a,h)}f((n=n.apply(t,e||[])).next())})}function sf(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(f){return function(l){return h([f,l])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(l){f=[6,l],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function of(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function af(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zn(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Cs(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function cf(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Cs(arguments[e]));return t}function uf(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Or(t){return this instanceof Or?(this.v=t,this):new Or(t)}function ff(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(b){n[b]&&(i[b]=function(m){return new Promise(function(w,N){s.push([b,m,w,N])>1||a(b,m)})})}function a(b,m){try{h(n[b](m))}catch(w){D(s[0][3],w)}}function h(b){b.value instanceof Or?Promise.resolve(b.value.v).then(f,l):D(s[0][2],b)}function f(b){a("next",b)}function l(b){a("throw",b)}function D(b,m){b(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function hf(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Or(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function lf(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 Zn=="function"?Zn(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,h){o=t[s](o),i(a,h,o.done,o.value)})}}function i(s,o,a,h){Promise.resolve(h).then(function(f){s({value:f,done:a})},o)}}function df(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function pf(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 gf(t){return t&&t.__esModule?t:{default:t}}function yf(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function vf(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 _f=Object.freeze({__proto__:null,__extends:Zu,get __assign(){return Xn},__rest:Qu,__decorate:ef,__param:tf,__metadata:rf,__awaiter:nf,__generator:sf,__createBinding:of,__exportStar:af,__values:Zn,__read:Cs,__spread:cf,__spreadArrays:uf,__await:Or,__asyncGenerator:ff,__asyncDelegator:hf,__asyncValues:lf,__makeTemplateObject:df,__importStar:pf,__importDefault:gf,__classPrivateFieldGet:yf,__classPrivateFieldSet:vf}),bf=Zt(_f),Mt={},Rs;function mf(){if(Rs)return Mt;Rs=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.isBrowserCryptoAvailable=Mt.getSubtleCrypto=Mt.getBrowerCrypto=void 0;function t(){return ke?.crypto||ke?.msCrypto||{}}Mt.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Mt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Mt.isBrowserCryptoAvailable=r,Mt}var Ut={},Ps;function wf(){if(Ps)return Ut;Ps=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.isBrowser=Ut.isNode=Ut.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Ut.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Ut.isNode=e;function r(){return!t()&&!e()}return Ut.isBrowser=r,Ut}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=bf;e.__exportStar(mf(),t),e.__exportStar(wf(),t)})(Ts);function Ef(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function sn(t,e,r){return{id:r||Ef(),jsonrpc:"2.0",method:t,params:e}}function on(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Lr(t,e,r){return{id:t,jsonrpc:"2.0",error:Df(e,r)}}function Df(t,e){return typeof t>"u"?Is(Os):(typeof t=="string"&&(t=Object.assign(Object.assign({},Is(Yn)),{message:t})),typeof e<"u"&&(t.data=e),Ju(t.code)&&(t=Xu(t.code)),t)}class Ns{}class xf extends Ns{constructor(e){super()}}class Sf extends Ns{constructor(){super()}}class Of extends Sf{constructor(e){super()}}const Lf="^https?:",If="^wss?:";function Af(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function $s(t,e){const r=Af(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Fs(t){return $s(t,Lf)}function Ms(t){return $s(t,If)}function Tf(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Us(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Qn(t){return Us(t)&&"method"in t}function ei(t){return Us(t)&&(jt(t)||Ot(t))}function jt(t){return"result"in t}function Ot(t){return"error"in t}class ti extends Of{constructor(e){super(e),this.events=new kn.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(sn(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{Ot(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ei(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var ri={exports:{}};(function(t,e){var r=typeof self<"u"?self:ke,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function h(g){return g&&DataView.prototype.isPrototypeOf(g)}if(a.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(g){return g&&f.indexOf(Object.prototype.toString.call(g))>-1};function D(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(g))throw new TypeError("Invalid character in header field name");return g.toLowerCase()}function b(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var v={next:function(){var F=g.shift();return{done:F===void 0,value:F}}};return a.iterable&&(v[Symbol.iterator]=function(){return v}),v}function w(g){this.map={},g instanceof w?g.forEach(function(v,F){this.append(F,v)},this):Array.isArray(g)?g.forEach(function(v){this.append(v[0],v[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(v){this.append(v,g[v])},this)}w.prototype.append=function(g,v){g=D(g),v=b(v);var F=this.map[g];this.map[g]=F?F+", "+v:v},w.prototype.delete=function(g){delete this.map[D(g)]},w.prototype.get=function(g){return g=D(g),this.has(g)?this.map[g]:null},w.prototype.has=function(g){return this.map.hasOwnProperty(D(g))},w.prototype.set=function(g,v){this.map[D(g)]=b(v)},w.prototype.forEach=function(g,v){for(var F in this.map)this.map.hasOwnProperty(F)&&g.call(v,this.map[F],F,this)},w.prototype.keys=function(){var g=[];return this.forEach(function(v,F){g.push(F)}),m(g)},w.prototype.values=function(){var g=[];return this.forEach(function(v){g.push(v)}),m(g)},w.prototype.entries=function(){var g=[];return this.forEach(function(v,F){g.push([F,v])}),m(g)},a.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function N(g){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}function R(g){return new Promise(function(v,F){g.onload=function(){v(g.result)},g.onerror=function(){F(g.error)}})}function B(g){var v=new FileReader,F=R(v);return v.readAsArrayBuffer(g),F}function S(g){var v=new FileReader,F=R(v);return v.readAsText(g),F}function I(g){for(var v=new Uint8Array(g),F=new Array(v.length),M=0;M<v.length;M++)F[M]=String.fromCharCode(v[M]);return F.join("")}function y(g){if(g.slice)return g.slice(0);var v=new Uint8Array(g.byteLength);return v.set(new Uint8Array(g)),v.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(g){this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:a.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:a.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():a.arrayBuffer&&a.blob&&h(g)?(this._bodyArrayBuffer=y(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=y(g):this._bodyText=g=Object.prototype.toString.call(g):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):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var g=N(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(){return this._bodyArrayBuffer?N(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var g=N(this);if(g)return g;if(this._bodyBlob)return S(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(U)}),this.json=function(){return this.text().then(JSON.parse)},this}var E=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function c(g){var v=g.toUpperCase();return E.indexOf(v)>-1?v:g}function d(g,v){v=v||{};var F=v.body;if(g instanceof d){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,v.headers||(this.headers=new w(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!F&&g._bodyInit!=null&&(F=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 w(v.headers)),this.method=c(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&F)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(F)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function U(g){var v=new FormData;return g.trim().split("&").forEach(function(F){if(F){var M=F.split("="),P=M.shift().replace(/\+/g," "),C=M.join("=").replace(/\+/g," ");v.append(decodeURIComponent(P),decodeURIComponent(C))}}),v}function K(g){var v=new w,F=g.replace(/\r?\n[\t ]+/g," ");return F.split(/\r?\n/).forEach(function(M){var P=M.split(":"),C=P.shift().trim();if(C){var j=P.join(":").trim();v.append(C,j)}}),v}x.call(d.prototype);function G(g,v){v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in v?v.statusText:"OK",this.headers=new w(v.headers),this.url=v.url||"",this._initBody(g)}x.call(G.prototype),G.prototype.clone=function(){return new G(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},G.error=function(){var g=new G(null,{status:0,statusText:""});return g.type="error",g};var J=[301,302,303,307,308];G.redirect=function(g,v){if(J.indexOf(v)===-1)throw new RangeError("Invalid status code");return new G(null,{status:v,headers:{location:g}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(v,F){this.message=v,this.name=F;var M=Error(v);this.stack=M.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function X(g,v){return new Promise(function(F,M){var P=new d(g,v);if(P.signal&&P.signal.aborted)return M(new o.DOMException("Aborted","AbortError"));var C=new XMLHttpRequest;function j(){C.abort()}C.onload=function(){var z={status:C.status,statusText:C.statusText,headers:K(C.getAllResponseHeaders()||"")};z.url="responseURL"in C?C.responseURL:z.headers.get("X-Request-URL");var Q="response"in C?C.response:C.responseText;F(new G(Q,z))},C.onerror=function(){M(new TypeError("Network request failed"))},C.ontimeout=function(){M(new TypeError("Network request failed"))},C.onabort=function(){M(new o.DOMException("Aborted","AbortError"))},C.open(P.method,P.url,!0),P.credentials==="include"?C.withCredentials=!0:P.credentials==="omit"&&(C.withCredentials=!1),"responseType"in C&&a.blob&&(C.responseType="blob"),P.headers.forEach(function(z,Q){C.setRequestHeader(Q,z)}),P.signal&&(P.signal.addEventListener("abort",j),C.onreadystatechange=function(){C.readyState===4&&P.signal.removeEventListener("abort",j)}),C.send(typeof P._bodyInit>"u"?null:P._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=w,s.Request=d,s.Response=G),o.Headers=w,o.Request=d,o.Response=G,o.fetch=X,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(ri,ri.exports);var js=Mu(ri.exports);function ni(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function Ir(t){return typeof t=="string"?t:JSON.stringify(t)}const Bs={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},zs=10;class Cf{constructor(e){if(this.url=e,this.events=new kn.EventEmitter,this.isAvailable=!1,this.registering=!1,!Fs(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}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,r){this.isAvailable||await this.register();try{const n=Ir(e),s=await(await js(this.url,Object.assign(Object.assign({},Bs),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!Fs(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((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{const r=Ir({id:1,jsonrpc:"2.0",method:"test",params:[]});await js(e,Object.assign(Object.assign({},Bs),{body:r})),this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}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"?ni(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Lr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return As(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>zs&&this.events.setMaxListeners(zs)}}var ii={},an={},re={},Ks={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(a,h){var f=a>>>16&65535,l=a&65535,D=h>>>16&65535,b=h&65535;return l*b+(f*b+l*D<<16>>>0)|0}t.mul=Math.imul||e;function r(a,h){return a+h|0}t.add=r;function n(a,h){return a-h|0}t.sub=n;function i(a,h){return a<<h|a>>>32-h}t.rotl=i;function s(a,h){return a<<32-h|a>>>h}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(Ks),Object.defineProperty(re,"__esModule",{value:!0});var qs=Ks;function Rf(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=Rf;function Pf(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=Pf;function Nf(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=Nf;function $f(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=$f;function Hs(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=Hs,re.writeInt16BE=Hs;function Vs(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=Vs,re.writeInt16LE=Vs;function si(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=si;function oi(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=oi;function ai(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=ai;function ci(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=ci;function cn(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=cn,re.writeInt32BE=cn;function un(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=un,re.writeInt32LE=un;function Ff(t,e){e===void 0&&(e=0);var r=si(t,e),n=si(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=Ff;function Mf(t,e){e===void 0&&(e=0);var r=oi(t,e),n=oi(t,e+4);return r*4294967296+n}re.readUint64BE=Mf;function Uf(t,e){e===void 0&&(e=0);var r=ai(t,e),n=ai(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=Uf;function jf(t,e){e===void 0&&(e=0);var r=ci(t,e),n=ci(t,e+4);return n*4294967296+r}re.readUint64LE=jf;function Gs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),cn(t/4294967296>>>0,e,r),cn(t>>>0,e,r+4),e}re.writeUint64BE=Gs,re.writeInt64BE=Gs;function Ws(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),un(t>>>0,e,r),un(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=Ws,re.writeInt64LE=Ws;function Bf(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=Bf;function zf(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=zf;function Kf(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!qs.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=Kf;function qf(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!qs.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=qf;function Hf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Hf;function Vf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Vf;function Gf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Gf;function Wf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Wf;function kf(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=kf;function Yf(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=Yf;function Jf(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=Jf;function Xf(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=Xf;var _t={};Object.defineProperty(_t,"__esModule",{value:!0});function Zf(t){for(var e=0;e<t.length;e++)t[e]=0;return t}_t.wipe=Zf,Object.defineProperty(an,"__esModule",{value:!0});var ct=re,ui=_t,Qf=20;function eh(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],h=r[7]<<24|r[6]<<16|r[5]<<8|r[4],f=r[11]<<24|r[10]<<16|r[9]<<8|r[8],l=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],b=r[23]<<24|r[22]<<16|r[21]<<8|r[20],m=r[27]<<24|r[26]<<16|r[25]<<8|r[24],w=r[31]<<24|r[30]<<16|r[29]<<8|r[28],N=e[3]<<24|e[2]<<16|e[1]<<8|e[0],R=e[7]<<24|e[6]<<16|e[5]<<8|e[4],B=e[11]<<24|e[10]<<16|e[9]<<8|e[8],S=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=n,y=i,x=s,E=o,c=a,d=h,U=f,K=l,G=D,J=b,X=m,g=w,v=N,F=R,M=B,P=S,C=0;C<Qf;C+=2)I=I+c|0,v^=I,v=v>>>32-16|v<<16,G=G+v|0,c^=G,c=c>>>32-12|c<<12,y=y+d|0,F^=y,F=F>>>32-16|F<<16,J=J+F|0,d^=J,d=d>>>32-12|d<<12,x=x+U|0,M^=x,M=M>>>32-16|M<<16,X=X+M|0,U^=X,U=U>>>32-12|U<<12,E=E+K|0,P^=E,P=P>>>32-16|P<<16,g=g+P|0,K^=g,K=K>>>32-12|K<<12,x=x+U|0,M^=x,M=M>>>32-8|M<<8,X=X+M|0,U^=X,U=U>>>32-7|U<<7,E=E+K|0,P^=E,P=P>>>32-8|P<<8,g=g+P|0,K^=g,K=K>>>32-7|K<<7,y=y+d|0,F^=y,F=F>>>32-8|F<<8,J=J+F|0,d^=J,d=d>>>32-7|d<<7,I=I+c|0,v^=I,v=v>>>32-8|v<<8,G=G+v|0,c^=G,c=c>>>32-7|c<<7,I=I+d|0,P^=I,P=P>>>32-16|P<<16,X=X+P|0,d^=X,d=d>>>32-12|d<<12,y=y+U|0,v^=y,v=v>>>32-16|v<<16,g=g+v|0,U^=g,U=U>>>32-12|U<<12,x=x+K|0,F^=x,F=F>>>32-16|F<<16,G=G+F|0,K^=G,K=K>>>32-12|K<<12,E=E+c|0,M^=E,M=M>>>32-16|M<<16,J=J+M|0,c^=J,c=c>>>32-12|c<<12,x=x+K|0,F^=x,F=F>>>32-8|F<<8,G=G+F|0,K^=G,K=K>>>32-7|K<<7,E=E+c|0,M^=E,M=M>>>32-8|M<<8,J=J+M|0,c^=J,c=c>>>32-7|c<<7,y=y+U|0,v^=y,v=v>>>32-8|v<<8,g=g+v|0,U^=g,U=U>>>32-7|U<<7,I=I+d|0,P^=I,P=P>>>32-8|P<<8,X=X+P|0,d^=X,d=d>>>32-7|d<<7;ct.writeUint32LE(I+n|0,t,0),ct.writeUint32LE(y+i|0,t,4),ct.writeUint32LE(x+s|0,t,8),ct.writeUint32LE(E+o|0,t,12),ct.writeUint32LE(c+a|0,t,16),ct.writeUint32LE(d+h|0,t,20),ct.writeUint32LE(U+f|0,t,24),ct.writeUint32LE(K+l|0,t,28),ct.writeUint32LE(G+D|0,t,32),ct.writeUint32LE(J+b|0,t,36),ct.writeUint32LE(X+m|0,t,40),ct.writeUint32LE(g+w|0,t,44),ct.writeUint32LE(v+N|0,t,48),ct.writeUint32LE(F+R|0,t,52),ct.writeUint32LE(M+B|0,t,56),ct.writeUint32LE(P+S|0,t,60)}function ks(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}for(var a=new Uint8Array(64),h=0;h<r.length;h+=64){eh(a,s,t);for(var f=h;f<h+64&&f<r.length;f++)n[f]=r[f]^a[f-h];rh(s,0,o)}return ui.wipe(a),i===0&&ui.wipe(s),n}an.streamXOR=ks;function th(t,e,r,n){return n===void 0&&(n=0),ui.wipe(r),ks(t,e,r,r,n)}an.stream=th;function rh(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var Ys={},Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});function nh(t,e,r){return~(t-1)&e|t-1&r}Vt.select=nh;function ih(t,e){return(t|0)-(e|0)-1>>>31&1}Vt.lessOrEqual=ih;function Js(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Vt.compare=Js;function sh(t,e){return t.length===0||e.length===0?!1:Js(t,e)!==0}Vt.equal=sh,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vt,r=_t;t.DIGEST_LENGTH=16;var n=function(){function o(a){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var h=a[0]|a[1]<<8;this._r[0]=h&8191;var f=a[2]|a[3]<<8;this._r[1]=(h>>>13|f<<3)&8191;var l=a[4]|a[5]<<8;this._r[2]=(f>>>10|l<<6)&7939;var D=a[6]|a[7]<<8;this._r[3]=(l>>>7|D<<9)&8191;var b=a[8]|a[9]<<8;this._r[4]=(D>>>4|b<<12)&255,this._r[5]=b>>>1&8190;var m=a[10]|a[11]<<8;this._r[6]=(b>>>14|m<<2)&8191;var w=a[12]|a[13]<<8;this._r[7]=(m>>>11|w<<5)&8065;var N=a[14]|a[15]<<8;this._r[8]=(w>>>8|N<<8)&8191,this._r[9]=N>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,h,f){for(var l=this._fin?0:2048,D=this._h[0],b=this._h[1],m=this._h[2],w=this._h[3],N=this._h[4],R=this._h[5],B=this._h[6],S=this._h[7],I=this._h[8],y=this._h[9],x=this._r[0],E=this._r[1],c=this._r[2],d=this._r[3],U=this._r[4],K=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],g=this._r[9];f>=16;){var v=a[h+0]|a[h+1]<<8;D+=v&8191;var F=a[h+2]|a[h+3]<<8;b+=(v>>>13|F<<3)&8191;var M=a[h+4]|a[h+5]<<8;m+=(F>>>10|M<<6)&8191;var P=a[h+6]|a[h+7]<<8;w+=(M>>>7|P<<9)&8191;var C=a[h+8]|a[h+9]<<8;N+=(P>>>4|C<<12)&8191,R+=C>>>1&8191;var j=a[h+10]|a[h+11]<<8;B+=(C>>>14|j<<2)&8191;var z=a[h+12]|a[h+13]<<8;S+=(j>>>11|z<<5)&8191;var Q=a[h+14]|a[h+15]<<8;I+=(z>>>8|Q<<8)&8191,y+=Q>>>5|l;var q=0,ee=q;ee+=D*x,ee+=b*(5*g),ee+=m*(5*X),ee+=w*(5*J),ee+=N*(5*G),q=ee>>>13,ee&=8191,ee+=R*(5*K),ee+=B*(5*U),ee+=S*(5*d),ee+=I*(5*c),ee+=y*(5*E),q+=ee>>>13,ee&=8191;var Y=q;Y+=D*E,Y+=b*x,Y+=m*(5*g),Y+=w*(5*X),Y+=N*(5*J),q=Y>>>13,Y&=8191,Y+=R*(5*G),Y+=B*(5*K),Y+=S*(5*U),Y+=I*(5*d),Y+=y*(5*c),q+=Y>>>13,Y&=8191;var ae=q;ae+=D*c,ae+=b*E,ae+=m*x,ae+=w*(5*g),ae+=N*(5*X),q=ae>>>13,ae&=8191,ae+=R*(5*J),ae+=B*(5*G),ae+=S*(5*K),ae+=I*(5*U),ae+=y*(5*d),q+=ae>>>13,ae&=8191;var T=q;T+=D*d,T+=b*c,T+=m*E,T+=w*x,T+=N*(5*g),q=T>>>13,T&=8191,T+=R*(5*X),T+=B*(5*J),T+=S*(5*G),T+=I*(5*K),T+=y*(5*U),q+=T>>>13,T&=8191;var A=q;A+=D*U,A+=b*d,A+=m*c,A+=w*E,A+=N*x,q=A>>>13,A&=8191,A+=R*(5*g),A+=B*(5*X),A+=S*(5*J),A+=I*(5*G),A+=y*(5*K),q+=A>>>13,A&=8191;var O=q;O+=D*K,O+=b*U,O+=m*d,O+=w*c,O+=N*E,q=O>>>13,O&=8191,O+=R*x,O+=B*(5*g),O+=S*(5*X),O+=I*(5*J),O+=y*(5*G),q+=O>>>13,O&=8191;var u=q;u+=D*G,u+=b*K,u+=m*U,u+=w*d,u+=N*c,q=u>>>13,u&=8191,u+=R*E,u+=B*x,u+=S*(5*g),u+=I*(5*X),u+=y*(5*J),q+=u>>>13,u&=8191;var _=q;_+=D*J,_+=b*G,_+=m*K,_+=w*U,_+=N*d,q=_>>>13,_&=8191,_+=R*c,_+=B*E,_+=S*x,_+=I*(5*g),_+=y*(5*X),q+=_>>>13,_&=8191;var H=q;H+=D*X,H+=b*J,H+=m*G,H+=w*K,H+=N*U,q=H>>>13,H&=8191,H+=R*d,H+=B*c,H+=S*E,H+=I*x,H+=y*(5*g),q+=H>>>13,H&=8191;var W=q;W+=D*g,W+=b*X,W+=m*J,W+=w*G,W+=N*K,q=W>>>13,W&=8191,W+=R*U,W+=B*d,W+=S*c,W+=I*E,W+=y*x,q+=W>>>13,W&=8191,q=(q<<2)+q|0,q=q+ee|0,ee=q&8191,q=q>>>13,Y+=q,D=ee,b=Y,m=ae,w=T,N=A,R=O,B=u,S=_,I=H,y=W,h+=16,f-=16}this._h[0]=D,this._h[1]=b,this._h[2]=m,this._h[3]=w,this._h[4]=N,this._h[5]=R,this._h[6]=B,this._h[7]=S,this._h[8]=I,this._h[9]=y},o.prototype.finish=function(a,h){h===void 0&&(h=0);var f=new Uint16Array(10),l,D,b,m;if(this._leftover){for(m=this._leftover,this._buffer[m++]=1;m<16;m++)this._buffer[m]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(l=this._h[1]>>>13,this._h[1]&=8191,m=2;m<10;m++)this._h[m]+=l,l=this._h[m]>>>13,this._h[m]&=8191;for(this._h[0]+=l*5,l=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=l,l=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=l,f[0]=this._h[0]+5,l=f[0]>>>13,f[0]&=8191,m=1;m<10;m++)f[m]=this._h[m]+l,l=f[m]>>>13,f[m]&=8191;for(f[9]-=1<<13,D=(l^1)-1,m=0;m<10;m++)f[m]&=D;for(D=~D,m=0;m<10;m++)this._h[m]=this._h[m]&D|f[m];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,b=this._h[0]+this._pad[0],this._h[0]=b&65535,m=1;m<8;m++)b=(this._h[m]+this._pad[m]|0)+(b>>>16)|0,this._h[m]=b&65535;return a[h+0]=this._h[0]>>>0,a[h+1]=this._h[0]>>>8,a[h+2]=this._h[1]>>>0,a[h+3]=this._h[1]>>>8,a[h+4]=this._h[2]>>>0,a[h+5]=this._h[2]>>>8,a[h+6]=this._h[3]>>>0,a[h+7]=this._h[3]>>>8,a[h+8]=this._h[4]>>>0,a[h+9]=this._h[4]>>>8,a[h+10]=this._h[5]>>>0,a[h+11]=this._h[5]>>>8,a[h+12]=this._h[6]>>>0,a[h+13]=this._h[6]>>>8,a[h+14]=this._h[7]>>>0,a[h+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var h=0,f=a.length,l;if(this._leftover){l=16-this._leftover,l>f&&(l=f);for(var D=0;D<l;D++)this._buffer[this._leftover+D]=a[h+D];if(f-=l,h+=l,this._leftover+=l,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(l=f-f%16,this._blocks(a,h,l),h+=l,f-=l),f){for(var D=0;D<f;D++)this._buffer[this._leftover+D]=a[h+D];this._leftover+=f}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var a=new Uint8Array(16);return this.finish(a),a},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=n;function i(o,a){var h=new n(o);h.update(a);var f=h.digest();return h.clean(),f}t.oneTimeAuth=i;function s(o,a){return o.length!==t.DIGEST_LENGTH||a.length!==t.DIGEST_LENGTH?!1:e.equal(o,a)}t.equal=s}(Ys),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=an,r=Ys,n=_t,i=re,s=Vt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),a=function(){function h(f){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,f.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return h.prototype.seal=function(f,l,D,b){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var m=new Uint8Array(16);m.set(f,m.length-f.length);var w=new Uint8Array(32);e.stream(this._key,m,w,4);var N=l.length+this.tagLength,R;if(b){if(b.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");R=b}else R=new Uint8Array(N);return e.streamXOR(this._key,m,l,R,4),this._authenticate(R.subarray(R.length-this.tagLength,R.length),w,R.subarray(0,R.length-this.tagLength),D),n.wipe(m),R},h.prototype.open=function(f,l,D,b){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(l.length<this.tagLength)return null;var m=new Uint8Array(16);m.set(f,m.length-f.length);var w=new Uint8Array(32);e.stream(this._key,m,w,4);var N=new Uint8Array(this.tagLength);if(this._authenticate(N,w,l.subarray(0,l.length-this.tagLength),D),!s.equal(N,l.subarray(l.length-this.tagLength,l.length)))return null;var R=l.length-this.tagLength,B;if(b){if(b.length!==R)throw new Error("ChaCha20Poly1305: incorrect destination length");B=b}else B=new Uint8Array(R);return e.streamXOR(this._key,m,l.subarray(0,l.length-this.tagLength),B,4),n.wipe(m),B},h.prototype.clean=function(){return n.wipe(this._key),this},h.prototype._authenticate=function(f,l,D,b){var m=new r.Poly1305(l);b&&(m.update(b),b.length%16>0&&m.update(o.subarray(b.length%16))),m.update(D),D.length%16>0&&m.update(o.subarray(D.length%16));var w=new Uint8Array(8);b&&i.writeUint64LE(b.length,w),m.update(w),i.writeUint64LE(D.length,w),m.update(w);for(var N=m.digest(),R=0;R<N.length;R++)f[R]=N[R];m.clean(),n.wipe(N),n.wipe(w)},h}();t.ChaCha20Poly1305=a}(ii);var Xs={},Ar={},fi={};Object.defineProperty(fi,"__esModule",{value:!0});function oh(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}fi.isSerializableHash=oh,Object.defineProperty(Ar,"__esModule",{value:!0});var At=fi,ah=Vt,ch=_t,Zs=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),At.isSerializableHash(this._inner)&&At.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),ch.wipe(n)}return t.prototype.reset=function(){if(!At.isSerializableHash(this._inner)||!At.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){At.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),At.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!At.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!At.isSerializableHash(this._inner)||!At.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!At.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();Ar.HMAC=Zs;function uh(t,e,r){var n=new Zs(t,e);n.update(r);var i=n.digest();return n.clean(),i}Ar.hmac=uh,Ar.equal=ah.equal,Object.defineProperty(Xs,"__esModule",{value:!0});var Qs=Ar,eo=_t,fh=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=Qs.hmac(this._hash,n,r);this._hmac=new Qs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),eo.wipe(this._buffer),eo.wipe(this._counter),this._bufpos=0},t}(),hh=Xs.HKDF=fh,lr={},fn={},hn={};Object.defineProperty(hn,"__esModule",{value:!0}),hn.BrowserRandomSource=void 0;const to=65536;class lh{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let n=0;n<r.length;n+=to)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,to)));return r}}hn.BrowserRandomSource=lh;function dh(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ln={},ph={},gh=Object.freeze({__proto__:null,default:ph}),yh=Zt(gh);Object.defineProperty(ln,"__esModule",{value:!0}),ln.NodeRandomSource=void 0;const vh=_t;class _h{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof dh<"u"){const e=yh;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(e);for(let i=0;i<n.length;i++)n[i]=r[i];return(0,vh.wipe)(r),n}}ln.NodeRandomSource=_h,Object.defineProperty(fn,"__esModule",{value:!0}),fn.SystemRandomSource=void 0;const bh=hn,mh=ln;class wh{constructor(){if(this.isAvailable=!1,this.name="",this._source=new bh.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new mh.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}fn.SystemRandomSource=wh,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=fn,r=re,n=_t;t.defaultRandomSource=new e.SystemRandomSource;function i(f,l=t.defaultRandomSource){return l.randomBytes(f)}t.randomBytes=i;function s(f=t.defaultRandomSource){const l=i(4,f),D=(0,r.readUint32LE)(l);return(0,n.wipe)(l),D}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function a(f,l=o,D=t.defaultRandomSource){if(l.length<2)throw new Error("randomString charset is too short");if(l.length>256)throw new Error("randomString charset is too long");let b="";const m=l.length,w=256-256%m;for(;f>0;){const N=i(Math.ceil(f*256/w),D);for(let R=0;R<N.length&&f>0;R++){const B=N[R];B<w&&(b+=l.charAt(B%m),f--)}(0,n.wipe)(N)}return b}t.randomString=a;function h(f,l=o,D=t.defaultRandomSource){const b=Math.ceil(f/(Math.log(l.length)/Math.LN2));return a(b,l,D)}t.randomStringForEntropy=h}(lr);var dn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=_t;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function a(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return a.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},a.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},a.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},a.prototype.update=function(h,f){if(f===void 0&&(f=h.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var l=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=h[l++],f--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(l=s(this._temp,this._state,h,l,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=h[l++],f--;return this},a.prototype.finish=function(h){if(!this._finished){var f=this._bytesHashed,l=this._bufferLength,D=f/536870912|0,b=f<<3,m=f%64<56?64:128;this._buffer[l]=128;for(var w=l+1;w<m-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(b,this._buffer,m-4),s(this._temp,this._state,this._buffer,0,m),this._finished=!0}for(var w=0;w<this.digestLength/4;w++)e.writeUint32BE(this._state[w],h,w*4);return this},a.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},a.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(h){return this._state.set(h.state),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},a}();t.SHA256=n;var i=new Int32Array([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 s(a,h,f,l,D){for(;D>=64;){for(var b=h[0],m=h[1],w=h[2],N=h[3],R=h[4],B=h[5],S=h[6],I=h[7],y=0;y<16;y++){var x=l+y*4;a[y]=e.readUint32BE(f,x)}for(var y=16;y<64;y++){var E=a[y-2],c=(E>>>17|E<<32-17)^(E>>>19|E<<32-19)^E>>>10;E=a[y-15];var d=(E>>>7|E<<32-7)^(E>>>18|E<<32-18)^E>>>3;a[y]=(c+a[y-7]|0)+(d+a[y-16]|0)}for(var y=0;y<64;y++){var c=(((R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7))+(R&B^~R&S)|0)+(I+(i[y]+a[y]|0)|0)|0,d=((b>>>2|b<<32-2)^(b>>>13|b<<32-13)^(b>>>22|b<<32-22))+(b&m^b&w^m&w)|0;I=S,S=B,B=R,R=N+c|0,N=w,w=m,m=b,b=c+d|0}h[0]+=b,h[1]+=m,h[2]+=w,h[3]+=N,h[4]+=R,h[5]+=B,h[6]+=S,h[7]+=I,l+=64,D-=64}return l}function o(a){var h=new n;h.update(a);var f=h.digest();return h.clean(),f}t.hash=o})(dn);var hi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=lr,r=_t;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(y){const x=new Float64Array(16);if(y)for(let E=0;E<y.length;E++)x[E]=y[E];return x}const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(y){let x=1;for(let E=0;E<16;E++){let c=y[E]+x+65535;x=Math.floor(c/65536),y[E]=c-x*65536}y[0]+=x-1+37*(x-1)}function a(y,x,E){const c=~(E-1);for(let d=0;d<16;d++){const U=c&(y[d]^x[d]);y[d]^=U,x[d]^=U}}function h(y,x){const E=n(),c=n();for(let d=0;d<16;d++)c[d]=x[d];o(c),o(c),o(c);for(let d=0;d<2;d++){E[0]=c[0]-65517;for(let K=1;K<15;K++)E[K]=c[K]-65535-(E[K-1]>>16&1),E[K-1]&=65535;E[15]=c[15]-32767-(E[14]>>16&1);const U=E[15]>>16&1;E[14]&=65535,a(c,E,1-U)}for(let d=0;d<16;d++)y[2*d]=c[d]&255,y[2*d+1]=c[d]>>8}function f(y,x){for(let E=0;E<16;E++)y[E]=x[2*E]+(x[2*E+1]<<8);y[15]&=32767}function l(y,x,E){for(let c=0;c<16;c++)y[c]=x[c]+E[c]}function D(y,x,E){for(let c=0;c<16;c++)y[c]=x[c]-E[c]}function b(y,x,E){let c,d,U=0,K=0,G=0,J=0,X=0,g=0,v=0,F=0,M=0,P=0,C=0,j=0,z=0,Q=0,q=0,ee=0,Y=0,ae=0,T=0,A=0,O=0,u=0,_=0,H=0,W=0,he=0,ve=0,de=0,me=0,Be=0,$e=0,ye=E[0],pe=E[1],le=E[2],ue=E[3],ce=E[4],oe=E[5],se=E[6],te=E[7],fe=E[8],ge=E[9],ne=E[10],_e=E[11],be=E[12],Ee=E[13],De=E[14],we=E[15];c=x[0],U+=c*ye,K+=c*pe,G+=c*le,J+=c*ue,X+=c*ce,g+=c*oe,v+=c*se,F+=c*te,M+=c*fe,P+=c*ge,C+=c*ne,j+=c*_e,z+=c*be,Q+=c*Ee,q+=c*De,ee+=c*we,c=x[1],K+=c*ye,G+=c*pe,J+=c*le,X+=c*ue,g+=c*ce,v+=c*oe,F+=c*se,M+=c*te,P+=c*fe,C+=c*ge,j+=c*ne,z+=c*_e,Q+=c*be,q+=c*Ee,ee+=c*De,Y+=c*we,c=x[2],G+=c*ye,J+=c*pe,X+=c*le,g+=c*ue,v+=c*ce,F+=c*oe,M+=c*se,P+=c*te,C+=c*fe,j+=c*ge,z+=c*ne,Q+=c*_e,q+=c*be,ee+=c*Ee,Y+=c*De,ae+=c*we,c=x[3],J+=c*ye,X+=c*pe,g+=c*le,v+=c*ue,F+=c*ce,M+=c*oe,P+=c*se,C+=c*te,j+=c*fe,z+=c*ge,Q+=c*ne,q+=c*_e,ee+=c*be,Y+=c*Ee,ae+=c*De,T+=c*we,c=x[4],X+=c*ye,g+=c*pe,v+=c*le,F+=c*ue,M+=c*ce,P+=c*oe,C+=c*se,j+=c*te,z+=c*fe,Q+=c*ge,q+=c*ne,ee+=c*_e,Y+=c*be,ae+=c*Ee,T+=c*De,A+=c*we,c=x[5],g+=c*ye,v+=c*pe,F+=c*le,M+=c*ue,P+=c*ce,C+=c*oe,j+=c*se,z+=c*te,Q+=c*fe,q+=c*ge,ee+=c*ne,Y+=c*_e,ae+=c*be,T+=c*Ee,A+=c*De,O+=c*we,c=x[6],v+=c*ye,F+=c*pe,M+=c*le,P+=c*ue,C+=c*ce,j+=c*oe,z+=c*se,Q+=c*te,q+=c*fe,ee+=c*ge,Y+=c*ne,ae+=c*_e,T+=c*be,A+=c*Ee,O+=c*De,u+=c*we,c=x[7],F+=c*ye,M+=c*pe,P+=c*le,C+=c*ue,j+=c*ce,z+=c*oe,Q+=c*se,q+=c*te,ee+=c*fe,Y+=c*ge,ae+=c*ne,T+=c*_e,A+=c*be,O+=c*Ee,u+=c*De,_+=c*we,c=x[8],M+=c*ye,P+=c*pe,C+=c*le,j+=c*ue,z+=c*ce,Q+=c*oe,q+=c*se,ee+=c*te,Y+=c*fe,ae+=c*ge,T+=c*ne,A+=c*_e,O+=c*be,u+=c*Ee,_+=c*De,H+=c*we,c=x[9],P+=c*ye,C+=c*pe,j+=c*le,z+=c*ue,Q+=c*ce,q+=c*oe,ee+=c*se,Y+=c*te,ae+=c*fe,T+=c*ge,A+=c*ne,O+=c*_e,u+=c*be,_+=c*Ee,H+=c*De,W+=c*we,c=x[10],C+=c*ye,j+=c*pe,z+=c*le,Q+=c*ue,q+=c*ce,ee+=c*oe,Y+=c*se,ae+=c*te,T+=c*fe,A+=c*ge,O+=c*ne,u+=c*_e,_+=c*be,H+=c*Ee,W+=c*De,he+=c*we,c=x[11],j+=c*ye,z+=c*pe,Q+=c*le,q+=c*ue,ee+=c*ce,Y+=c*oe,ae+=c*se,T+=c*te,A+=c*fe,O+=c*ge,u+=c*ne,_+=c*_e,H+=c*be,W+=c*Ee,he+=c*De,ve+=c*we,c=x[12],z+=c*ye,Q+=c*pe,q+=c*le,ee+=c*ue,Y+=c*ce,ae+=c*oe,T+=c*se,A+=c*te,O+=c*fe,u+=c*ge,_+=c*ne,H+=c*_e,W+=c*be,he+=c*Ee,ve+=c*De,de+=c*we,c=x[13],Q+=c*ye,q+=c*pe,ee+=c*le,Y+=c*ue,ae+=c*ce,T+=c*oe,A+=c*se,O+=c*te,u+=c*fe,_+=c*ge,H+=c*ne,W+=c*_e,he+=c*be,ve+=c*Ee,de+=c*De,me+=c*we,c=x[14],q+=c*ye,ee+=c*pe,Y+=c*le,ae+=c*ue,T+=c*ce,A+=c*oe,O+=c*se,u+=c*te,_+=c*fe,H+=c*ge,W+=c*ne,he+=c*_e,ve+=c*be,de+=c*Ee,me+=c*De,Be+=c*we,c=x[15],ee+=c*ye,Y+=c*pe,ae+=c*le,T+=c*ue,A+=c*ce,O+=c*oe,u+=c*se,_+=c*te,H+=c*fe,W+=c*ge,he+=c*ne,ve+=c*_e,de+=c*be,me+=c*Ee,Be+=c*De,$e+=c*we,U+=38*Y,K+=38*ae,G+=38*T,J+=38*A,X+=38*O,g+=38*u,v+=38*_,F+=38*H,M+=38*W,P+=38*he,C+=38*ve,j+=38*de,z+=38*me,Q+=38*Be,q+=38*$e,d=1,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=K+d+65535,d=Math.floor(c/65536),K=c-d*65536,c=G+d+65535,d=Math.floor(c/65536),G=c-d*65536,c=J+d+65535,d=Math.floor(c/65536),J=c-d*65536,c=X+d+65535,d=Math.floor(c/65536),X=c-d*65536,c=g+d+65535,d=Math.floor(c/65536),g=c-d*65536,c=v+d+65535,d=Math.floor(c/65536),v=c-d*65536,c=F+d+65535,d=Math.floor(c/65536),F=c-d*65536,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=P+d+65535,d=Math.floor(c/65536),P=c-d*65536,c=C+d+65535,d=Math.floor(c/65536),C=c-d*65536,c=j+d+65535,d=Math.floor(c/65536),j=c-d*65536,c=z+d+65535,d=Math.floor(c/65536),z=c-d*65536,c=Q+d+65535,d=Math.floor(c/65536),Q=c-d*65536,c=q+d+65535,d=Math.floor(c/65536),q=c-d*65536,c=ee+d+65535,d=Math.floor(c/65536),ee=c-d*65536,U+=d-1+37*(d-1),d=1,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=K+d+65535,d=Math.floor(c/65536),K=c-d*65536,c=G+d+65535,d=Math.floor(c/65536),G=c-d*65536,c=J+d+65535,d=Math.floor(c/65536),J=c-d*65536,c=X+d+65535,d=Math.floor(c/65536),X=c-d*65536,c=g+d+65535,d=Math.floor(c/65536),g=c-d*65536,c=v+d+65535,d=Math.floor(c/65536),v=c-d*65536,c=F+d+65535,d=Math.floor(c/65536),F=c-d*65536,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=P+d+65535,d=Math.floor(c/65536),P=c-d*65536,c=C+d+65535,d=Math.floor(c/65536),C=c-d*65536,c=j+d+65535,d=Math.floor(c/65536),j=c-d*65536,c=z+d+65535,d=Math.floor(c/65536),z=c-d*65536,c=Q+d+65535,d=Math.floor(c/65536),Q=c-d*65536,c=q+d+65535,d=Math.floor(c/65536),q=c-d*65536,c=ee+d+65535,d=Math.floor(c/65536),ee=c-d*65536,U+=d-1+37*(d-1),y[0]=U,y[1]=K,y[2]=G,y[3]=J,y[4]=X,y[5]=g,y[6]=v,y[7]=F,y[8]=M,y[9]=P,y[10]=C,y[11]=j,y[12]=z,y[13]=Q,y[14]=q,y[15]=ee}function m(y,x){b(y,x,x)}function w(y,x){const E=n();for(let c=0;c<16;c++)E[c]=x[c];for(let c=253;c>=0;c--)m(E,E),c!==2&&c!==4&&b(E,E,x);for(let c=0;c<16;c++)y[c]=E[c]}function N(y,x){const E=new Uint8Array(32),c=new Float64Array(80),d=n(),U=n(),K=n(),G=n(),J=n(),X=n();for(let M=0;M<31;M++)E[M]=y[M];E[31]=y[31]&127|64,E[0]&=248,f(c,x);for(let M=0;M<16;M++)U[M]=c[M];d[0]=G[0]=1;for(let M=254;M>=0;--M){const P=E[M>>>3]>>>(M&7)&1;a(d,U,P),a(K,G,P),l(J,d,K),D(d,d,K),l(K,U,G),D(U,U,G),m(G,J),m(X,d),b(d,K,d),b(K,U,J),l(J,d,K),D(d,d,K),m(U,d),D(K,G,X),b(d,K,s),l(d,d,G),b(K,K,d),b(d,G,X),b(G,U,c),m(U,J),a(d,U,P),a(K,G,P)}for(let M=0;M<16;M++)c[M+16]=d[M],c[M+32]=K[M],c[M+48]=U[M],c[M+64]=G[M];const g=c.subarray(32),v=c.subarray(16);w(g,g),b(v,v,g);const F=new Uint8Array(32);return h(F,v),F}t.scalarMult=N;function R(y){return N(y,i)}t.scalarMultBase=R;function B(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const x=new Uint8Array(y);return{publicKey:R(x),secretKey:x}}t.generateKeyPairFromSeed=B;function S(y){const x=(0,e.randomBytes)(32,y),E=B(x);return(0,r.wipe)(x),E}t.generateKeyPair=S;function I(y,x,E=!1){if(y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(x.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const c=N(y,x);if(E){let d=0;for(let U=0;U<c.length;U++)d|=c[U];if(d===0)throw new Error("X25519: invalid shared key")}return c}t.sharedKey=I})(hi);function ro(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function li(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=ro(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Eh(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,h=t.charAt(0),f=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var N=0,R=0,B=0,S=w.length;B!==S&&w[B]===0;)B++,N++;for(var I=(S-B)*l+1>>>0,y=new Uint8Array(I);B!==S;){for(var x=w[B],E=0,c=I-1;(x!==0||E<R)&&c!==-1;c--,E++)x+=256*y[c]>>>0,y[c]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");R=E,B++}for(var d=I-R;d!==I&&y[d]===0;)d++;for(var U=h.repeat(N);d<I;++d)U+=t.charAt(y[d]);return U}function b(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var N=0;if(w[N]!==" "){for(var R=0,B=0;w[N]===h;)R++,N++;for(var S=(w.length-N)*f+1>>>0,I=new Uint8Array(S);w[N];){var y=r[w.charCodeAt(N)];if(y===255)return;for(var x=0,E=S-1;(y!==0||x<B)&&E!==-1;E--,x++)y+=a*I[E]>>>0,I[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=x,N++}if(w[N]!==" "){for(var c=S-B;c!==S&&I[c]===0;)c++;for(var d=new Uint8Array(R+(S-c)),U=R;c!==S;)d[U++]=I[c++];return d}}}function m(w){var N=b(w);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:b,decode:m}}var Dh=Eh,xh=Dh;const no=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")},Sh=t=>new TextEncoder().encode(t),Oh=t=>new TextDecoder().decode(t);class Lh{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Ih{constructor(e,r,n){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=n}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 io(this,e)}}class Ah{constructor(e){this.decoders=e}or(e){return io(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const io=(t,e)=>new Ah({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Th{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Lh(e,r,n),this.decoder=new Ih(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pn=({name:t,prefix:e,encode:r,decode:n})=>new Th(t,e,r,n),Tr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=xh(r,e);return pn({prefix:t,name:e,encode:n,decode:s=>no(i(s))})},Ch=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,h=0,f=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|D,a+=r,a>=8&&(a-=8,o[f++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},Rh=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let h=0;h<t.length;++h)for(a=a<<8|t[h],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},it=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>pn({prefix:e,name:t,encode(i){return Rh(i,n,r)},decode(i){return Ch(i,n,r,t)}}),Ph=pn({prefix:"\0",name:"identity",encode:t=>Oh(t),decode:t=>Sh(t)});var Nh=Object.freeze({__proto__:null,identity:Ph});const $h=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Fh=Object.freeze({__proto__:null,base2:$h});const Mh=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Uh=Object.freeze({__proto__:null,base8:Mh});const jh=Tr({prefix:"9",name:"base10",alphabet:"0123456789"});var Bh=Object.freeze({__proto__:null,base10:jh});const zh=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kh=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qh=Object.freeze({__proto__:null,base16:zh,base16upper:Kh});const Hh=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vh=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gh=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wh=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kh=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Yh=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jh=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xh=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zh=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Qh=Object.freeze({__proto__:null,base32:Hh,base32upper:Vh,base32pad:Gh,base32padupper:Wh,base32hex:kh,base32hexupper:Yh,base32hexpad:Jh,base32hexpadupper:Xh,base32z:Zh});const el=Tr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tl=Tr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var rl=Object.freeze({__proto__:null,base36:el,base36upper:tl});const nl=Tr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),il=Tr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var sl=Object.freeze({__proto__:null,base58btc:nl,base58flickr:il});const ol=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),al=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),cl=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ul=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fl=Object.freeze({__proto__:null,base64:ol,base64pad:al,base64url:cl,base64urlpad:ul});const so=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}"),hl=so.reduce((t,e,r)=>(t[r]=e,t),[]),ll=so.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function dl(t){return t.reduce((e,r)=>(e+=hl[r],e),"")}function pl(t){const e=[];for(const r of t){const n=ll[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const gl=pn({prefix:"\u{1F680}",name:"base256emoji",encode:dl,decode:pl});var yl=Object.freeze({__proto__:null,base256emoji:gl}),vl=ao,oo=128,_l=127,bl=~_l,ml=Math.pow(2,31);function ao(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ml;)e[r++]=t&255|oo,t/=128;for(;t&bl;)e[r++]=t&255|oo,t>>>=7;return e[r]=t|0,ao.bytes=r-n+1,e}var wl=di,El=128,co=127;function di(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw di.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&co)<<i:(o&co)*Math.pow(2,i),i+=7}while(o>=El);return di.bytes=s-n,r}var Dl=Math.pow(2,7),xl=Math.pow(2,14),Sl=Math.pow(2,21),Ol=Math.pow(2,28),Ll=Math.pow(2,35),Il=Math.pow(2,42),Al=Math.pow(2,49),Tl=Math.pow(2,56),Cl=Math.pow(2,63),Rl=function(t){return t<Dl?1:t<xl?2:t<Sl?3:t<Ol?4:t<Ll?5:t<Il?6:t<Al?7:t<Tl?8:t<Cl?9:10},Pl={encode:vl,decode:wl,encodingLength:Rl},uo=Pl;const fo=(t,e,r=0)=>(uo.encode(t,e,r),e),ho=t=>uo.encodingLength(t),pi=(t,e)=>{const r=e.byteLength,n=ho(t),i=n+ho(r),s=new Uint8Array(i+r);return fo(t,s,0),fo(r,s,n),s.set(e,i),new Nl(t,r,e,s)};class Nl{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const lo=({name:t,code:e,encode:r})=>new $l(t,e,r);class $l{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?pi(this.code,r):r.then(n=>pi(this.code,n))}else throw Error("Unknown type, must be binary type")}}const po=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Fl=lo({name:"sha2-256",code:18,encode:po("SHA-256")}),Ml=lo({name:"sha2-512",code:19,encode:po("SHA-512")});var Ul=Object.freeze({__proto__:null,sha256:Fl,sha512:Ml});const go=0,jl="identity",yo=no;var Bl=Object.freeze({__proto__:null,identity:{code:go,name:jl,encode:yo,digest:t=>pi(go,yo(t))}});new TextEncoder,new TextDecoder;const vo={...Nh,...Fh,...Uh,...Bh,...qh,...Qh,...rl,...sl,...fl,...yl};({...Ul,...Bl});function _o(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const bo=_o("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),gi=_o("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=ro(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),mo={utf8:bo,"utf-8":bo,hex:vo.base16,latin1:gi,ascii:gi,binary:gi,...vo};function lt(t,e="utf8"){const r=mo[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 dt(t,e="utf8"){const r=mo[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 wo=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},zl=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),Kl=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),ql=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),Hl=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Vl=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Gl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Wl=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Eo=3,kl=[["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",Gl]],Do=[["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 Yl(t){return t?xo(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Vl:typeof navigator<"u"?xo(navigator.userAgent):Zl()}function Jl(t){return t!==""&&kl.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function xo(t){var e=Jl(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Hl;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Eo&&(i=wo(wo([],i,!0),Ql(Eo-i.length),!0)):i=[];var s=i.join("."),o=Xl(t),a=Wl.exec(t);return a&&a[1]?new ql(r,s,o,a[1]):new zl(r,s,o)}function Xl(t){for(var e=0,r=Do.length;e<r;e++){var n=Do[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function Zl(){var t=typeof process<"u"&&process.version;return t?new Kl(process.version.slice(1)):null}function Ql(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Z={};/*! *****************************************************************************
14
+ ***************************************************************************** */var Sn=function(t,e){return Sn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Sn(t,e)};function Ec(t,e){Sn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var xn=function(){return xn=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},xn.apply(this,arguments)};function Dc(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Sc(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function xc(t,e){return function(r,n){e(r,n,t)}}function Oc(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ic(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Ac(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Tc(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Pc(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function On(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ns(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Rc(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ns(arguments[e]));return t}function Cc(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function lr(t){return this instanceof lr?(this.v=t,this):new lr(t)}function Nc(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof lr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Fc(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:lr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Lc(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 On=="function"?On(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Uc(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $c(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 Mc(t){return t&&t.__esModule?t:{default:t}}function jc(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Bc(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 zc=Object.freeze({__proto__:null,__extends:Ec,get __assign(){return xn},__rest:Dc,__decorate:Sc,__param:xc,__metadata:Oc,__awaiter:Ic,__generator:Ac,__createBinding:Tc,__exportStar:Pc,__values:On,__read:ns,__spread:Rc,__spreadArrays:Cc,__await:lr,__asyncGenerator:Nc,__asyncDelegator:Fc,__asyncValues:Lc,__makeTemplateObject:Uc,__importStar:$c,__importDefault:Mc,__classPrivateFieldGet:jc,__classPrivateFieldSet:Bc}),qc=Kt(zc),Pt={},is;function Hc(){if(is)return Pt;is=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.isBrowserCryptoAvailable=Pt.getSubtleCrypto=Pt.getBrowerCrypto=void 0;function t(){return He?.crypto||He?.msCrypto||{}}Pt.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Pt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Pt.isBrowserCryptoAvailable=r,Pt}var Rt={},ss;function Kc(){if(ss)return Rt;ss=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.isBrowser=Rt.isNode=Rt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Rt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Rt.isNode=e;function r(){return!t()&&!e()}return Rt.isBrowser=r,Rt}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=qc;e.__exportStar(Hc(),t),e.__exportStar(Kc(),t)})(rs);function Vc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function Kr(t,e,r){return{id:r||Vc(),jsonrpc:"2.0",method:t,params:e}}function Vr(t,e){return{id:t,jsonrpc:"2.0",result:e}}function dr(t,e,r){return{id:t,jsonrpc:"2.0",error:Gc(e,r)}}function Gc(t,e){return typeof t>"u"?es(Zi):(typeof t=="string"&&(t=Object.assign(Object.assign({},es(Dn)),{message:t})),typeof e<"u"&&(t.data=e),wc(t.code)&&(t=mc(t.code)),t)}class os{}class Wc extends os{constructor(e){super()}}class kc extends os{constructor(){super()}}class Yc extends kc{constructor(e){super()}}const Jc="^https?:",Xc="^wss?:";function Zc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function as(t,e){const r=Zc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function cs(t){return as(t,Jc)}function us(t){return as(t,Xc)}function Qc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function hs(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function In(t){return hs(t)&&"method"in t}function An(t){return hs(t)&&(Ct(t)||wt(t))}function Ct(t){return"result"in t}function wt(t){return"error"in t}class Tn extends Yc{constructor(e){super(e),this.events=new Ze.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(Kr(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{wt(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),An(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var Pn={exports:{}};(function(t,e){var r=typeof self<"u"?self:He,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function f(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(g){return g&&h.indexOf(Object.prototype.toString.call(g))>-1};function D(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(g))throw new TypeError("Invalid character in header field name");return g.toLowerCase()}function w(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var _={next:function(){var U=g.shift();return{done:U===void 0,value:U}}};return c.iterable&&(_[Symbol.iterator]=function(){return _}),_}function E(g){this.map={},g instanceof E?g.forEach(function(_,U){this.append(U,_)},this):Array.isArray(g)?g.forEach(function(_){this.append(_[0],_[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(_){this.append(_,g[_])},this)}E.prototype.append=function(g,_){g=D(g),_=w(_);var U=this.map[g];this.map[g]=U?U+", "+_:_},E.prototype.delete=function(g){delete this.map[D(g)]},E.prototype.get=function(g){return g=D(g),this.has(g)?this.map[g]:null},E.prototype.has=function(g){return this.map.hasOwnProperty(D(g))},E.prototype.set=function(g,_){this.map[D(g)]=w(_)},E.prototype.forEach=function(g,_){for(var U in this.map)this.map.hasOwnProperty(U)&&g.call(_,this.map[U],U,this)},E.prototype.keys=function(){var g=[];return this.forEach(function(_,U){g.push(U)}),m(g)},E.prototype.values=function(){var g=[];return this.forEach(function(_){g.push(_)}),m(g)},E.prototype.entries=function(){var g=[];return this.forEach(function(_,U){g.push([U,_])}),m(g)},c.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function F(g){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}function N(g){return new Promise(function(_,U){g.onload=function(){_(g.result)},g.onerror=function(){U(g.error)}})}function B(g){var _=new FileReader,U=N(_);return _.readAsArrayBuffer(g),U}function x(g){var _=new FileReader,U=N(_);return _.readAsText(g),U}function A(g){for(var _=new Uint8Array(g),U=new Array(_.length),$=0;$<_.length;$++)U[$]=String.fromCharCode(_[$]);return U.join("")}function y(g){if(g.slice)return g.slice(0);var _=new Uint8Array(g.byteLength);return _.set(new Uint8Array(g)),_.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(g){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&&f(g)?(this._bodyArrayBuffer=y(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=y(g):this._bodyText=g=Object.prototype.toString.call(g):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=F(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(){return this._bodyArrayBuffer?F(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var g=F(this);if(g)return g;if(this._bodyBlob)return x(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(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(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function a(g){var _=g.toUpperCase();return v.indexOf(_)>-1?_:g}function d(g,_){_=_||{};var U=_.body;if(g instanceof d){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,_.headers||(this.headers=new E(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!U&&g._bodyInit!=null&&(U=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new E(_.headers)),this.method=a(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(U)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function M(g){var _=new FormData;return g.trim().split("&").forEach(function(U){if(U){var $=U.split("="),C=$.shift().replace(/\+/g," "),R=$.join("=").replace(/\+/g," ");_.append(decodeURIComponent(C),decodeURIComponent(R))}}),_}function q(g){var _=new E,U=g.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function($){var C=$.split(":"),R=C.shift().trim();if(R){var j=C.join(":").trim();_.append(R,j)}}),_}S.call(d.prototype);function G(g,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new E(_.headers),this.url=_.url||"",this._initBody(g)}S.call(G.prototype),G.prototype.clone=function(){return new G(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},G.error=function(){var g=new G(null,{status:0,statusText:""});return g.type="error",g};var J=[301,302,303,307,308];G.redirect=function(g,_){if(J.indexOf(_)===-1)throw new RangeError("Invalid status code");return new G(null,{status:_,headers:{location:g}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(_,U){this.message=_,this.name=U;var $=Error(_);this.stack=$.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function X(g,_){return new Promise(function(U,$){var C=new d(g,_);if(C.signal&&C.signal.aborted)return $(new o.DOMException("Aborted","AbortError"));var R=new XMLHttpRequest;function j(){R.abort()}R.onload=function(){var z={status:R.status,statusText:R.statusText,headers:q(R.getAllResponseHeaders()||"")};z.url="responseURL"in R?R.responseURL:z.headers.get("X-Request-URL");var Q="response"in R?R.response:R.responseText;U(new G(Q,z))},R.onerror=function(){$(new TypeError("Network request failed"))},R.ontimeout=function(){$(new TypeError("Network request failed"))},R.onabort=function(){$(new o.DOMException("Aborted","AbortError"))},R.open(C.method,C.url,!0),C.credentials==="include"?R.withCredentials=!0:C.credentials==="omit"&&(R.withCredentials=!1),"responseType"in R&&c.blob&&(R.responseType="blob"),C.headers.forEach(function(z,Q){R.setRequestHeader(Q,z)}),C.signal&&(C.signal.addEventListener("abort",j),R.onreadystatechange=function(){R.readyState===4&&C.signal.removeEventListener("abort",j)}),R.send(typeof C._bodyInit>"u"?null:C._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=E,s.Request=d,s.Response=G),o.Headers=E,o.Request=d,o.Response=G,o.fetch=X,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(Pn,Pn.exports);var fs=cc(Pn.exports);function Rn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function pr(t){return typeof t=="string"?t:JSON.stringify(t)}const ls={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},ds=10;class eu{constructor(e){if(this.url=e,this.events=new Ze.exports.EventEmitter,this.isAvailable=!1,this.registering=!1,!cs(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}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,r){this.isAvailable||await this.register();try{const n=pr(e),s=await(await fs(this.url,Object.assign(Object.assign({},ls),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!cs(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((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{const r=pr({id:1,jsonrpc:"2.0",method:"test",params:[]});await fs(e,Object.assign(Object.assign({},ls),{body:r})),this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}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"?Rn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=dr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ts(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ds&&this.events.setMaxListeners(ds)}}var Cn={},Gr={},re={},ps={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(c,f){var h=c>>>16&65535,l=c&65535,D=f>>>16&65535,w=f&65535;return l*w+(h*w+l*D<<16>>>0)|0}t.mul=Math.imul||e;function r(c,f){return c+f|0}t.add=r;function n(c,f){return c-f|0}t.sub=n;function i(c,f){return c<<f|c>>>32-f}t.rotl=i;function s(c,f){return c<<32-f|c>>>f}t.rotr=s;function o(c){return typeof c=="number"&&isFinite(c)&&Math.floor(c)===c}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(c){return t.isInteger(c)&&c>=-t.MAX_SAFE_INTEGER&&c<=t.MAX_SAFE_INTEGER}})(ps),Object.defineProperty(re,"__esModule",{value:!0});var gs=ps;function tu(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=tu;function ru(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=ru;function nu(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=nu;function iu(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=iu;function ys(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=ys,re.writeInt16BE=ys;function _s(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=_s,re.writeInt16LE=_s;function Nn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Nn;function Fn(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=Fn;function Ln(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Ln;function Un(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=Un;function Wr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=Wr,re.writeInt32BE=Wr;function kr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=kr,re.writeInt32LE=kr;function su(t,e){e===void 0&&(e=0);var r=Nn(t,e),n=Nn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=su;function ou(t,e){e===void 0&&(e=0);var r=Fn(t,e),n=Fn(t,e+4);return r*4294967296+n}re.readUint64BE=ou;function au(t,e){e===void 0&&(e=0);var r=Ln(t,e),n=Ln(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=au;function cu(t,e){e===void 0&&(e=0);var r=Un(t,e),n=Un(t,e+4);return n*4294967296+r}re.readUint64LE=cu;function bs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Wr(t/4294967296>>>0,e,r),Wr(t>>>0,e,r+4),e}re.writeUint64BE=bs,re.writeInt64BE=bs;function vs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),kr(t>>>0,e,r),kr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=vs,re.writeInt64LE=vs;function uu(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=uu;function hu(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=hu;function fu(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!gs.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=fu;function lu(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!gs.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=lu;function du(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=du;function pu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=pu;function gu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=gu;function yu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=yu;function _u(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=_u;function bu(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=bu;function vu(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=vu;function wu(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=wu;var lt={};Object.defineProperty(lt,"__esModule",{value:!0});function mu(t){for(var e=0;e<t.length;e++)t[e]=0;return t}lt.wipe=mu,Object.defineProperty(Gr,"__esModule",{value:!0});var nt=re,$n=lt,Eu=20;function Du(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],f=r[7]<<24|r[6]<<16|r[5]<<8|r[4],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],l=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],w=r[23]<<24|r[22]<<16|r[21]<<8|r[20],m=r[27]<<24|r[26]<<16|r[25]<<8|r[24],E=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],N=e[7]<<24|e[6]<<16|e[5]<<8|e[4],B=e[11]<<24|e[10]<<16|e[9]<<8|e[8],x=e[15]<<24|e[14]<<16|e[13]<<8|e[12],A=n,y=i,S=s,v=o,a=c,d=f,M=h,q=l,G=D,J=w,X=m,g=E,_=F,U=N,$=B,C=x,R=0;R<Eu;R+=2)A=A+a|0,_^=A,_=_>>>32-16|_<<16,G=G+_|0,a^=G,a=a>>>32-12|a<<12,y=y+d|0,U^=y,U=U>>>32-16|U<<16,J=J+U|0,d^=J,d=d>>>32-12|d<<12,S=S+M|0,$^=S,$=$>>>32-16|$<<16,X=X+$|0,M^=X,M=M>>>32-12|M<<12,v=v+q|0,C^=v,C=C>>>32-16|C<<16,g=g+C|0,q^=g,q=q>>>32-12|q<<12,S=S+M|0,$^=S,$=$>>>32-8|$<<8,X=X+$|0,M^=X,M=M>>>32-7|M<<7,v=v+q|0,C^=v,C=C>>>32-8|C<<8,g=g+C|0,q^=g,q=q>>>32-7|q<<7,y=y+d|0,U^=y,U=U>>>32-8|U<<8,J=J+U|0,d^=J,d=d>>>32-7|d<<7,A=A+a|0,_^=A,_=_>>>32-8|_<<8,G=G+_|0,a^=G,a=a>>>32-7|a<<7,A=A+d|0,C^=A,C=C>>>32-16|C<<16,X=X+C|0,d^=X,d=d>>>32-12|d<<12,y=y+M|0,_^=y,_=_>>>32-16|_<<16,g=g+_|0,M^=g,M=M>>>32-12|M<<12,S=S+q|0,U^=S,U=U>>>32-16|U<<16,G=G+U|0,q^=G,q=q>>>32-12|q<<12,v=v+a|0,$^=v,$=$>>>32-16|$<<16,J=J+$|0,a^=J,a=a>>>32-12|a<<12,S=S+q|0,U^=S,U=U>>>32-8|U<<8,G=G+U|0,q^=G,q=q>>>32-7|q<<7,v=v+a|0,$^=v,$=$>>>32-8|$<<8,J=J+$|0,a^=J,a=a>>>32-7|a<<7,y=y+M|0,_^=y,_=_>>>32-8|_<<8,g=g+_|0,M^=g,M=M>>>32-7|M<<7,A=A+d|0,C^=A,C=C>>>32-8|C<<8,X=X+C|0,d^=X,d=d>>>32-7|d<<7;nt.writeUint32LE(A+n|0,t,0),nt.writeUint32LE(y+i|0,t,4),nt.writeUint32LE(S+s|0,t,8),nt.writeUint32LE(v+o|0,t,12),nt.writeUint32LE(a+c|0,t,16),nt.writeUint32LE(d+f|0,t,20),nt.writeUint32LE(M+h|0,t,24),nt.writeUint32LE(q+l|0,t,28),nt.writeUint32LE(G+D|0,t,32),nt.writeUint32LE(J+w|0,t,36),nt.writeUint32LE(X+m|0,t,40),nt.writeUint32LE(g+E|0,t,44),nt.writeUint32LE(_+F|0,t,48),nt.writeUint32LE(U+N|0,t,52),nt.writeUint32LE($+B|0,t,56),nt.writeUint32LE(C+x|0,t,60)}function ws(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}for(var c=new Uint8Array(64),f=0;f<r.length;f+=64){Du(c,s,t);for(var h=f;h<f+64&&h<r.length;h++)n[h]=r[h]^c[h-f];xu(s,0,o)}return $n.wipe(c),i===0&&$n.wipe(s),n}Gr.streamXOR=ws;function Su(t,e,r,n){return n===void 0&&(n=0),$n.wipe(r),ws(t,e,r,r,n)}Gr.stream=Su;function xu(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var ms={},Ut={};Object.defineProperty(Ut,"__esModule",{value:!0});function Ou(t,e,r){return~(t-1)&e|t-1&r}Ut.select=Ou;function Iu(t,e){return(t|0)-(e|0)-1>>>31&1}Ut.lessOrEqual=Iu;function Es(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Ut.compare=Es;function Au(t,e){return t.length===0||e.length===0?!1:Es(t,e)!==0}Ut.equal=Au,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ut,r=lt;t.DIGEST_LENGTH=16;var n=function(){function o(c){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=f&8191;var h=c[2]|c[3]<<8;this._r[1]=(f>>>13|h<<3)&8191;var l=c[4]|c[5]<<8;this._r[2]=(h>>>10|l<<6)&7939;var D=c[6]|c[7]<<8;this._r[3]=(l>>>7|D<<9)&8191;var w=c[8]|c[9]<<8;this._r[4]=(D>>>4|w<<12)&255,this._r[5]=w>>>1&8190;var m=c[10]|c[11]<<8;this._r[6]=(w>>>14|m<<2)&8191;var E=c[12]|c[13]<<8;this._r[7]=(m>>>11|E<<5)&8065;var F=c[14]|c[15]<<8;this._r[8]=(E>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return o.prototype._blocks=function(c,f,h){for(var l=this._fin?0:2048,D=this._h[0],w=this._h[1],m=this._h[2],E=this._h[3],F=this._h[4],N=this._h[5],B=this._h[6],x=this._h[7],A=this._h[8],y=this._h[9],S=this._r[0],v=this._r[1],a=this._r[2],d=this._r[3],M=this._r[4],q=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],g=this._r[9];h>=16;){var _=c[f+0]|c[f+1]<<8;D+=_&8191;var U=c[f+2]|c[f+3]<<8;w+=(_>>>13|U<<3)&8191;var $=c[f+4]|c[f+5]<<8;m+=(U>>>10|$<<6)&8191;var C=c[f+6]|c[f+7]<<8;E+=($>>>7|C<<9)&8191;var R=c[f+8]|c[f+9]<<8;F+=(C>>>4|R<<12)&8191,N+=R>>>1&8191;var j=c[f+10]|c[f+11]<<8;B+=(R>>>14|j<<2)&8191;var z=c[f+12]|c[f+13]<<8;x+=(j>>>11|z<<5)&8191;var Q=c[f+14]|c[f+15]<<8;A+=(z>>>8|Q<<8)&8191,y+=Q>>>5|l;var H=0,ee=H;ee+=D*S,ee+=w*(5*g),ee+=m*(5*X),ee+=E*(5*J),ee+=F*(5*G),H=ee>>>13,ee&=8191,ee+=N*(5*q),ee+=B*(5*M),ee+=x*(5*d),ee+=A*(5*a),ee+=y*(5*v),H+=ee>>>13,ee&=8191;var Y=H;Y+=D*v,Y+=w*S,Y+=m*(5*g),Y+=E*(5*X),Y+=F*(5*J),H=Y>>>13,Y&=8191,Y+=N*(5*G),Y+=B*(5*q),Y+=x*(5*M),Y+=A*(5*d),Y+=y*(5*a),H+=Y>>>13,Y&=8191;var ae=H;ae+=D*a,ae+=w*v,ae+=m*S,ae+=E*(5*g),ae+=F*(5*X),H=ae>>>13,ae&=8191,ae+=N*(5*J),ae+=B*(5*G),ae+=x*(5*q),ae+=A*(5*M),ae+=y*(5*d),H+=ae>>>13,ae&=8191;var P=H;P+=D*d,P+=w*a,P+=m*v,P+=E*S,P+=F*(5*g),H=P>>>13,P&=8191,P+=N*(5*X),P+=B*(5*J),P+=x*(5*G),P+=A*(5*q),P+=y*(5*M),H+=P>>>13,P&=8191;var T=H;T+=D*M,T+=w*d,T+=m*a,T+=E*v,T+=F*S,H=T>>>13,T&=8191,T+=N*(5*g),T+=B*(5*X),T+=x*(5*J),T+=A*(5*G),T+=y*(5*q),H+=T>>>13,T&=8191;var O=H;O+=D*q,O+=w*M,O+=m*d,O+=E*a,O+=F*v,H=O>>>13,O&=8191,O+=N*S,O+=B*(5*g),O+=x*(5*X),O+=A*(5*J),O+=y*(5*G),H+=O>>>13,O&=8191;var u=H;u+=D*G,u+=w*q,u+=m*M,u+=E*d,u+=F*a,H=u>>>13,u&=8191,u+=N*v,u+=B*S,u+=x*(5*g),u+=A*(5*X),u+=y*(5*J),H+=u>>>13,u&=8191;var b=H;b+=D*J,b+=w*G,b+=m*q,b+=E*M,b+=F*d,H=b>>>13,b&=8191,b+=N*a,b+=B*v,b+=x*S,b+=A*(5*g),b+=y*(5*X),H+=b>>>13,b&=8191;var K=H;K+=D*X,K+=w*J,K+=m*G,K+=E*q,K+=F*M,H=K>>>13,K&=8191,K+=N*d,K+=B*a,K+=x*v,K+=A*S,K+=y*(5*g),H+=K>>>13,K&=8191;var W=H;W+=D*g,W+=w*X,W+=m*J,W+=E*G,W+=F*q,H=W>>>13,W&=8191,W+=N*M,W+=B*d,W+=x*a,W+=A*v,W+=y*S,H+=W>>>13,W&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,Y+=H,D=ee,w=Y,m=ae,E=P,F=T,N=O,B=u,x=b,A=K,y=W,f+=16,h-=16}this._h[0]=D,this._h[1]=w,this._h[2]=m,this._h[3]=E,this._h[4]=F,this._h[5]=N,this._h[6]=B,this._h[7]=x,this._h[8]=A,this._h[9]=y},o.prototype.finish=function(c,f){f===void 0&&(f=0);var h=new Uint16Array(10),l,D,w,m;if(this._leftover){for(m=this._leftover,this._buffer[m++]=1;m<16;m++)this._buffer[m]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(l=this._h[1]>>>13,this._h[1]&=8191,m=2;m<10;m++)this._h[m]+=l,l=this._h[m]>>>13,this._h[m]&=8191;for(this._h[0]+=l*5,l=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=l,l=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=l,h[0]=this._h[0]+5,l=h[0]>>>13,h[0]&=8191,m=1;m<10;m++)h[m]=this._h[m]+l,l=h[m]>>>13,h[m]&=8191;for(h[9]-=1<<13,D=(l^1)-1,m=0;m<10;m++)h[m]&=D;for(D=~D,m=0;m<10;m++)this._h[m]=this._h[m]&D|h[m];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,w=this._h[0]+this._pad[0],this._h[0]=w&65535,m=1;m<8;m++)w=(this._h[m]+this._pad[m]|0)+(w>>>16)|0,this._h[m]=w&65535;return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(c){var f=0,h=c.length,l;if(this._leftover){l=16-this._leftover,l>h&&(l=h);for(var D=0;D<l;D++)this._buffer[this._leftover+D]=c[f+D];if(h-=l,f+=l,this._leftover+=l,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(l=h-h%16,this._blocks(c,f,l),f+=l,h-=l),h){for(var D=0;D<h;D++)this._buffer[this._leftover+D]=c[f+D];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=n;function i(o,c){var f=new n(o);f.update(c);var h=f.digest();return f.clean(),h}t.oneTimeAuth=i;function s(o,c){return o.length!==t.DIGEST_LENGTH||c.length!==t.DIGEST_LENGTH?!1:e.equal(o,c)}t.equal=s}(ms),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Gr,r=ms,n=lt,i=re,s=Ut;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),c=function(){function f(h){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,h.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return f.prototype.seal=function(h,l,D,w){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var m=new Uint8Array(16);m.set(h,m.length-h.length);var E=new Uint8Array(32);e.stream(this._key,m,E,4);var F=l.length+this.tagLength,N;if(w){if(w.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");N=w}else N=new Uint8Array(F);return e.streamXOR(this._key,m,l,N,4),this._authenticate(N.subarray(N.length-this.tagLength,N.length),E,N.subarray(0,N.length-this.tagLength),D),n.wipe(m),N},f.prototype.open=function(h,l,D,w){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(l.length<this.tagLength)return null;var m=new Uint8Array(16);m.set(h,m.length-h.length);var E=new Uint8Array(32);e.stream(this._key,m,E,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,E,l.subarray(0,l.length-this.tagLength),D),!s.equal(F,l.subarray(l.length-this.tagLength,l.length)))return null;var N=l.length-this.tagLength,B;if(w){if(w.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");B=w}else B=new Uint8Array(N);return e.streamXOR(this._key,m,l.subarray(0,l.length-this.tagLength),B,4),n.wipe(m),B},f.prototype.clean=function(){return n.wipe(this._key),this},f.prototype._authenticate=function(h,l,D,w){var m=new r.Poly1305(l);w&&(m.update(w),w.length%16>0&&m.update(o.subarray(w.length%16))),m.update(D),D.length%16>0&&m.update(o.subarray(D.length%16));var E=new Uint8Array(8);w&&i.writeUint64LE(w.length,E),m.update(E),i.writeUint64LE(D.length,E),m.update(E);for(var F=m.digest(),N=0;N<F.length;N++)h[N]=F[N];m.clean(),n.wipe(F),n.wipe(E)},f}();t.ChaCha20Poly1305=c}(Cn);var Ds={},gr={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});function Tu(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Mn.isSerializableHash=Tu,Object.defineProperty(gr,"__esModule",{value:!0});var Dt=Mn,Pu=Ut,Ru=lt,Ss=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),Dt.isSerializableHash(this._inner)&&Dt.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Ru.wipe(n)}return t.prototype.reset=function(){if(!Dt.isSerializableHash(this._inner)||!Dt.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Dt.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Dt.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Dt.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Dt.isSerializableHash(this._inner)||!Dt.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Dt.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();gr.HMAC=Ss;function Cu(t,e,r){var n=new Ss(t,e);n.update(r);var i=n.digest();return n.clean(),i}gr.hmac=Cu,gr.equal=Pu.equal,Object.defineProperty(Ds,"__esModule",{value:!0});var xs=gr,Os=lt,Nu=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=xs.hmac(this._hash,n,r);this._hmac=new xs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),Os.wipe(this._buffer),Os.wipe(this._counter),this._bufpos=0},t}(),Fu=Ds.HKDF=Nu,ir={},Yr={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.BrowserRandomSource=void 0;const Is=65536;class Lu{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let n=0;n<r.length;n+=Is)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,Is)));return r}}Jr.BrowserRandomSource=Lu;function Uu(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Xr={},$u={},Mu=Object.freeze({__proto__:null,default:$u}),ju=Kt(Mu);Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.NodeRandomSource=void 0;const Bu=lt;class zu{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Uu<"u"){const e=ju;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(e);for(let i=0;i<n.length;i++)n[i]=r[i];return(0,Bu.wipe)(r),n}}Xr.NodeRandomSource=zu,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.SystemRandomSource=void 0;const qu=Jr,Hu=Xr;class Ku{constructor(){if(this.isAvailable=!1,this.name="",this._source=new qu.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Hu.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}Yr.SystemRandomSource=Ku,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=Yr,r=re,n=lt;t.defaultRandomSource=new e.SystemRandomSource;function i(h,l=t.defaultRandomSource){return l.randomBytes(h)}t.randomBytes=i;function s(h=t.defaultRandomSource){const l=i(4,h),D=(0,r.readUint32LE)(l);return(0,n.wipe)(l),D}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(h,l=o,D=t.defaultRandomSource){if(l.length<2)throw new Error("randomString charset is too short");if(l.length>256)throw new Error("randomString charset is too long");let w="";const m=l.length,E=256-256%m;for(;h>0;){const F=i(Math.ceil(h*256/E),D);for(let N=0;N<F.length&&h>0;N++){const B=F[N];B<E&&(w+=l.charAt(B%m),h--)}(0,n.wipe)(F)}return w}t.randomString=c;function f(h,l=o,D=t.defaultRandomSource){const w=Math.ceil(h/(Math.log(l.length)/Math.LN2));return c(w,l,D)}t.randomStringForEntropy=f}(ir);var Zr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=lt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},c.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._temp,this._state,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},c.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,w=h<<3,m=h%64<56?64:128;this._buffer[l]=128;for(var E=l+1;E<m-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(w,this._buffer,m-4),s(this._temp,this._state,this._buffer,0,m),this._finished=!0}for(var E=0;E<this.digestLength/4;E++)e.writeUint32BE(this._state[E],f,E*4);return this},c.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(f){return this._state.set(f.state),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(f){r.wipe(f.state),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},c}();t.SHA256=n;var i=new Int32Array([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 s(c,f,h,l,D){for(;D>=64;){for(var w=f[0],m=f[1],E=f[2],F=f[3],N=f[4],B=f[5],x=f[6],A=f[7],y=0;y<16;y++){var S=l+y*4;c[y]=e.readUint32BE(h,S)}for(var y=16;y<64;y++){var v=c[y-2],a=(v>>>17|v<<32-17)^(v>>>19|v<<32-19)^v>>>10;v=c[y-15];var d=(v>>>7|v<<32-7)^(v>>>18|v<<32-18)^v>>>3;c[y]=(a+c[y-7]|0)+(d+c[y-16]|0)}for(var y=0;y<64;y++){var a=(((N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7))+(N&B^~N&x)|0)+(A+(i[y]+c[y]|0)|0)|0,d=((w>>>2|w<<32-2)^(w>>>13|w<<32-13)^(w>>>22|w<<32-22))+(w&m^w&E^m&E)|0;A=x,x=B,B=N,N=F+a|0,F=E,E=m,m=w,w=a+d|0}f[0]+=w,f[1]+=m,f[2]+=E,f[3]+=F,f[4]+=N,f[5]+=B,f[6]+=x,f[7]+=A,l+=64,D-=64}return l}function o(c){var f=new n;f.update(c);var h=f.digest();return f.clean(),h}t.hash=o})(Zr);var jn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=ir,r=lt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(y){const S=new Float64Array(16);if(y)for(let v=0;v<y.length;v++)S[v]=y[v];return S}const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(y){let S=1;for(let v=0;v<16;v++){let a=y[v]+S+65535;S=Math.floor(a/65536),y[v]=a-S*65536}y[0]+=S-1+37*(S-1)}function c(y,S,v){const a=~(v-1);for(let d=0;d<16;d++){const M=a&(y[d]^S[d]);y[d]^=M,S[d]^=M}}function f(y,S){const v=n(),a=n();for(let d=0;d<16;d++)a[d]=S[d];o(a),o(a),o(a);for(let d=0;d<2;d++){v[0]=a[0]-65517;for(let q=1;q<15;q++)v[q]=a[q]-65535-(v[q-1]>>16&1),v[q-1]&=65535;v[15]=a[15]-32767-(v[14]>>16&1);const M=v[15]>>16&1;v[14]&=65535,c(a,v,1-M)}for(let d=0;d<16;d++)y[2*d]=a[d]&255,y[2*d+1]=a[d]>>8}function h(y,S){for(let v=0;v<16;v++)y[v]=S[2*v]+(S[2*v+1]<<8);y[15]&=32767}function l(y,S,v){for(let a=0;a<16;a++)y[a]=S[a]+v[a]}function D(y,S,v){for(let a=0;a<16;a++)y[a]=S[a]-v[a]}function w(y,S,v){let a,d,M=0,q=0,G=0,J=0,X=0,g=0,_=0,U=0,$=0,C=0,R=0,j=0,z=0,Q=0,H=0,ee=0,Y=0,ae=0,P=0,T=0,O=0,u=0,b=0,K=0,W=0,fe=0,_e=0,de=0,we=0,Le=0,Pe=0,ye=v[0],pe=v[1],le=v[2],ue=v[3],ce=v[4],oe=v[5],se=v[6],te=v[7],he=v[8],ge=v[9],ne=v[10],be=v[11],ve=v[12],Ee=v[13],De=v[14],me=v[15];a=S[0],M+=a*ye,q+=a*pe,G+=a*le,J+=a*ue,X+=a*ce,g+=a*oe,_+=a*se,U+=a*te,$+=a*he,C+=a*ge,R+=a*ne,j+=a*be,z+=a*ve,Q+=a*Ee,H+=a*De,ee+=a*me,a=S[1],q+=a*ye,G+=a*pe,J+=a*le,X+=a*ue,g+=a*ce,_+=a*oe,U+=a*se,$+=a*te,C+=a*he,R+=a*ge,j+=a*ne,z+=a*be,Q+=a*ve,H+=a*Ee,ee+=a*De,Y+=a*me,a=S[2],G+=a*ye,J+=a*pe,X+=a*le,g+=a*ue,_+=a*ce,U+=a*oe,$+=a*se,C+=a*te,R+=a*he,j+=a*ge,z+=a*ne,Q+=a*be,H+=a*ve,ee+=a*Ee,Y+=a*De,ae+=a*me,a=S[3],J+=a*ye,X+=a*pe,g+=a*le,_+=a*ue,U+=a*ce,$+=a*oe,C+=a*se,R+=a*te,j+=a*he,z+=a*ge,Q+=a*ne,H+=a*be,ee+=a*ve,Y+=a*Ee,ae+=a*De,P+=a*me,a=S[4],X+=a*ye,g+=a*pe,_+=a*le,U+=a*ue,$+=a*ce,C+=a*oe,R+=a*se,j+=a*te,z+=a*he,Q+=a*ge,H+=a*ne,ee+=a*be,Y+=a*ve,ae+=a*Ee,P+=a*De,T+=a*me,a=S[5],g+=a*ye,_+=a*pe,U+=a*le,$+=a*ue,C+=a*ce,R+=a*oe,j+=a*se,z+=a*te,Q+=a*he,H+=a*ge,ee+=a*ne,Y+=a*be,ae+=a*ve,P+=a*Ee,T+=a*De,O+=a*me,a=S[6],_+=a*ye,U+=a*pe,$+=a*le,C+=a*ue,R+=a*ce,j+=a*oe,z+=a*se,Q+=a*te,H+=a*he,ee+=a*ge,Y+=a*ne,ae+=a*be,P+=a*ve,T+=a*Ee,O+=a*De,u+=a*me,a=S[7],U+=a*ye,$+=a*pe,C+=a*le,R+=a*ue,j+=a*ce,z+=a*oe,Q+=a*se,H+=a*te,ee+=a*he,Y+=a*ge,ae+=a*ne,P+=a*be,T+=a*ve,O+=a*Ee,u+=a*De,b+=a*me,a=S[8],$+=a*ye,C+=a*pe,R+=a*le,j+=a*ue,z+=a*ce,Q+=a*oe,H+=a*se,ee+=a*te,Y+=a*he,ae+=a*ge,P+=a*ne,T+=a*be,O+=a*ve,u+=a*Ee,b+=a*De,K+=a*me,a=S[9],C+=a*ye,R+=a*pe,j+=a*le,z+=a*ue,Q+=a*ce,H+=a*oe,ee+=a*se,Y+=a*te,ae+=a*he,P+=a*ge,T+=a*ne,O+=a*be,u+=a*ve,b+=a*Ee,K+=a*De,W+=a*me,a=S[10],R+=a*ye,j+=a*pe,z+=a*le,Q+=a*ue,H+=a*ce,ee+=a*oe,Y+=a*se,ae+=a*te,P+=a*he,T+=a*ge,O+=a*ne,u+=a*be,b+=a*ve,K+=a*Ee,W+=a*De,fe+=a*me,a=S[11],j+=a*ye,z+=a*pe,Q+=a*le,H+=a*ue,ee+=a*ce,Y+=a*oe,ae+=a*se,P+=a*te,T+=a*he,O+=a*ge,u+=a*ne,b+=a*be,K+=a*ve,W+=a*Ee,fe+=a*De,_e+=a*me,a=S[12],z+=a*ye,Q+=a*pe,H+=a*le,ee+=a*ue,Y+=a*ce,ae+=a*oe,P+=a*se,T+=a*te,O+=a*he,u+=a*ge,b+=a*ne,K+=a*be,W+=a*ve,fe+=a*Ee,_e+=a*De,de+=a*me,a=S[13],Q+=a*ye,H+=a*pe,ee+=a*le,Y+=a*ue,ae+=a*ce,P+=a*oe,T+=a*se,O+=a*te,u+=a*he,b+=a*ge,K+=a*ne,W+=a*be,fe+=a*ve,_e+=a*Ee,de+=a*De,we+=a*me,a=S[14],H+=a*ye,ee+=a*pe,Y+=a*le,ae+=a*ue,P+=a*ce,T+=a*oe,O+=a*se,u+=a*te,b+=a*he,K+=a*ge,W+=a*ne,fe+=a*be,_e+=a*ve,de+=a*Ee,we+=a*De,Le+=a*me,a=S[15],ee+=a*ye,Y+=a*pe,ae+=a*le,P+=a*ue,T+=a*ce,O+=a*oe,u+=a*se,b+=a*te,K+=a*he,W+=a*ge,fe+=a*ne,_e+=a*be,de+=a*ve,we+=a*Ee,Le+=a*De,Pe+=a*me,M+=38*Y,q+=38*ae,G+=38*P,J+=38*T,X+=38*O,g+=38*u,_+=38*b,U+=38*K,$+=38*W,C+=38*fe,R+=38*_e,j+=38*de,z+=38*we,Q+=38*Le,H+=38*Pe,d=1,a=M+d+65535,d=Math.floor(a/65536),M=a-d*65536,a=q+d+65535,d=Math.floor(a/65536),q=a-d*65536,a=G+d+65535,d=Math.floor(a/65536),G=a-d*65536,a=J+d+65535,d=Math.floor(a/65536),J=a-d*65536,a=X+d+65535,d=Math.floor(a/65536),X=a-d*65536,a=g+d+65535,d=Math.floor(a/65536),g=a-d*65536,a=_+d+65535,d=Math.floor(a/65536),_=a-d*65536,a=U+d+65535,d=Math.floor(a/65536),U=a-d*65536,a=$+d+65535,d=Math.floor(a/65536),$=a-d*65536,a=C+d+65535,d=Math.floor(a/65536),C=a-d*65536,a=R+d+65535,d=Math.floor(a/65536),R=a-d*65536,a=j+d+65535,d=Math.floor(a/65536),j=a-d*65536,a=z+d+65535,d=Math.floor(a/65536),z=a-d*65536,a=Q+d+65535,d=Math.floor(a/65536),Q=a-d*65536,a=H+d+65535,d=Math.floor(a/65536),H=a-d*65536,a=ee+d+65535,d=Math.floor(a/65536),ee=a-d*65536,M+=d-1+37*(d-1),d=1,a=M+d+65535,d=Math.floor(a/65536),M=a-d*65536,a=q+d+65535,d=Math.floor(a/65536),q=a-d*65536,a=G+d+65535,d=Math.floor(a/65536),G=a-d*65536,a=J+d+65535,d=Math.floor(a/65536),J=a-d*65536,a=X+d+65535,d=Math.floor(a/65536),X=a-d*65536,a=g+d+65535,d=Math.floor(a/65536),g=a-d*65536,a=_+d+65535,d=Math.floor(a/65536),_=a-d*65536,a=U+d+65535,d=Math.floor(a/65536),U=a-d*65536,a=$+d+65535,d=Math.floor(a/65536),$=a-d*65536,a=C+d+65535,d=Math.floor(a/65536),C=a-d*65536,a=R+d+65535,d=Math.floor(a/65536),R=a-d*65536,a=j+d+65535,d=Math.floor(a/65536),j=a-d*65536,a=z+d+65535,d=Math.floor(a/65536),z=a-d*65536,a=Q+d+65535,d=Math.floor(a/65536),Q=a-d*65536,a=H+d+65535,d=Math.floor(a/65536),H=a-d*65536,a=ee+d+65535,d=Math.floor(a/65536),ee=a-d*65536,M+=d-1+37*(d-1),y[0]=M,y[1]=q,y[2]=G,y[3]=J,y[4]=X,y[5]=g,y[6]=_,y[7]=U,y[8]=$,y[9]=C,y[10]=R,y[11]=j,y[12]=z,y[13]=Q,y[14]=H,y[15]=ee}function m(y,S){w(y,S,S)}function E(y,S){const v=n();for(let a=0;a<16;a++)v[a]=S[a];for(let a=253;a>=0;a--)m(v,v),a!==2&&a!==4&&w(v,v,S);for(let a=0;a<16;a++)y[a]=v[a]}function F(y,S){const v=new Uint8Array(32),a=new Float64Array(80),d=n(),M=n(),q=n(),G=n(),J=n(),X=n();for(let $=0;$<31;$++)v[$]=y[$];v[31]=y[31]&127|64,v[0]&=248,h(a,S);for(let $=0;$<16;$++)M[$]=a[$];d[0]=G[0]=1;for(let $=254;$>=0;--$){const C=v[$>>>3]>>>($&7)&1;c(d,M,C),c(q,G,C),l(J,d,q),D(d,d,q),l(q,M,G),D(M,M,G),m(G,J),m(X,d),w(d,q,d),w(q,M,J),l(J,d,q),D(d,d,q),m(M,d),D(q,G,X),w(d,q,s),l(d,d,G),w(q,q,d),w(d,G,X),w(G,M,a),m(M,J),c(d,M,C),c(q,G,C)}for(let $=0;$<16;$++)a[$+16]=d[$],a[$+32]=q[$],a[$+48]=M[$],a[$+64]=G[$];const g=a.subarray(32),_=a.subarray(16);E(g,g),w(_,_,g);const U=new Uint8Array(32);return f(U,_),U}t.scalarMult=F;function N(y){return F(y,i)}t.scalarMultBase=N;function B(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const S=new Uint8Array(y);return{publicKey:N(S),secretKey:S}}t.generateKeyPairFromSeed=B;function x(y){const S=(0,e.randomBytes)(32,y),v=B(S);return(0,r.wipe)(S),v}t.generateKeyPair=x;function A(y,S,v=!1){if(y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const a=F(y,S);if(v){let d=0;for(let M=0;M<a.length;M++)d|=a[M];if(d===0)throw new Error("X25519: invalid shared key")}return a}t.sharedKey=A})(jn);function As(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Bn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=As(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Vu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var c=t.length,f=t.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function D(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 F=0,N=0,B=0,x=E.length;B!==x&&E[B]===0;)B++,F++;for(var A=(x-B)*l+1>>>0,y=new Uint8Array(A);B!==x;){for(var S=E[B],v=0,a=A-1;(S!==0||v<N)&&a!==-1;a--,v++)S+=256*y[a]>>>0,y[a]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=v,B++}for(var d=A-N;d!==A&&y[d]===0;)d++;for(var M=f.repeat(F);d<A;++d)M+=t.charAt(y[d]);return M}function w(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var F=0;if(E[F]!==" "){for(var N=0,B=0;E[F]===f;)N++,F++;for(var x=(E.length-F)*h+1>>>0,A=new Uint8Array(x);E[F];){var y=r[E.charCodeAt(F)];if(y===255)return;for(var S=0,v=x-1;(y!==0||S<B)&&v!==-1;v--,S++)y+=c*A[v]>>>0,A[v]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=S,F++}if(E[F]!==" "){for(var a=x-B;a!==x&&A[a]===0;)a++;for(var d=new Uint8Array(N+(x-a)),M=N;a!==x;)d[M++]=A[a++];return d}}}function m(E){var F=w(E);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:w,decode:m}}var Gu=Vu,Wu=Gu;const Ts=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")},ku=t=>new TextEncoder().encode(t),Yu=t=>new TextDecoder().decode(t);class Ju{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Xu{constructor(e,r,n){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=n}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 Ps(this,e)}}class Zu{constructor(e){this.decoders=e}or(e){return Ps(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ps=(t,e)=>new Zu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Qu{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ju(e,r,n),this.decoder=new Xu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qr=({name:t,prefix:e,encode:r,decode:n})=>new Qu(t,e,r,n),yr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Wu(r,e);return Qr({prefix:t,name:e,encode:n,decode:s=>Ts(i(s))})},eh=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,c+=r,c>=8&&(c-=8,o[h++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return o},th=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],o+=8;o>r;)o-=r,s+=e[i&c>>o];if(o&&(s+=e[i&c<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Qe=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Qr({prefix:e,name:t,encode(i){return th(i,n,r)},decode(i){return eh(i,n,r,t)}}),rh=Qr({prefix:"\0",name:"identity",encode:t=>Yu(t),decode:t=>ku(t)});var nh=Object.freeze({__proto__:null,identity:rh});const ih=Qe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sh=Object.freeze({__proto__:null,base2:ih});const oh=Qe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah=Object.freeze({__proto__:null,base8:oh});const ch=yr({prefix:"9",name:"base10",alphabet:"0123456789"});var uh=Object.freeze({__proto__:null,base10:ch});const hh=Qe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fh=Qe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lh=Object.freeze({__proto__:null,base16:hh,base16upper:fh});const dh=Qe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ph=Qe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gh=Qe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yh=Qe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_h=Qe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bh=Qe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vh=Qe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wh=Qe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),mh=Qe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Eh=Object.freeze({__proto__:null,base32:dh,base32upper:ph,base32pad:gh,base32padupper:yh,base32hex:_h,base32hexupper:bh,base32hexpad:vh,base32hexpadupper:wh,base32z:mh});const Dh=yr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sh=yr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xh=Object.freeze({__proto__:null,base36:Dh,base36upper:Sh});const Oh=yr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ih=yr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ah=Object.freeze({__proto__:null,base58btc:Oh,base58flickr:Ih});const Th=Qe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ph=Qe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rh=Qe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ch=Qe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nh=Object.freeze({__proto__:null,base64:Th,base64pad:Ph,base64url:Rh,base64urlpad:Ch});const Rs=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}"),Fh=Rs.reduce((t,e,r)=>(t[r]=e,t),[]),Lh=Rs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Uh(t){return t.reduce((e,r)=>(e+=Fh[r],e),"")}function $h(t){const e=[];for(const r of t){const n=Lh[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Mh=Qr({prefix:"\u{1F680}",name:"base256emoji",encode:Uh,decode:$h});var jh=Object.freeze({__proto__:null,base256emoji:Mh}),Bh=Ns,Cs=128,zh=127,qh=~zh,Hh=Math.pow(2,31);function Ns(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Hh;)e[r++]=t&255|Cs,t/=128;for(;t&qh;)e[r++]=t&255|Cs,t>>>=7;return e[r]=t|0,Ns.bytes=r-n+1,e}var Kh=zn,Vh=128,Fs=127;function zn(t,n){var r=0,n=n||0,i=0,s=n,o,c=t.length;do{if(s>=c)throw zn.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Fs)<<i:(o&Fs)*Math.pow(2,i),i+=7}while(o>=Vh);return zn.bytes=s-n,r}var Gh=Math.pow(2,7),Wh=Math.pow(2,14),kh=Math.pow(2,21),Yh=Math.pow(2,28),Jh=Math.pow(2,35),Xh=Math.pow(2,42),Zh=Math.pow(2,49),Qh=Math.pow(2,56),ef=Math.pow(2,63),tf=function(t){return t<Gh?1:t<Wh?2:t<kh?3:t<Yh?4:t<Jh?5:t<Xh?6:t<Zh?7:t<Qh?8:t<ef?9:10},rf={encode:Bh,decode:Kh,encodingLength:tf},Ls=rf;const Us=(t,e,r=0)=>(Ls.encode(t,e,r),e),$s=t=>Ls.encodingLength(t),qn=(t,e)=>{const r=e.byteLength,n=$s(t),i=n+$s(r),s=new Uint8Array(i+r);return Us(t,s,0),Us(r,s,n),s.set(e,i),new nf(t,r,e,s)};class nf{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Ms=({name:t,code:e,encode:r})=>new sf(t,e,r);class sf{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?qn(this.code,r):r.then(n=>qn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const js=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),of=Ms({name:"sha2-256",code:18,encode:js("SHA-256")}),af=Ms({name:"sha2-512",code:19,encode:js("SHA-512")});var cf=Object.freeze({__proto__:null,sha256:of,sha512:af});const Bs=0,uf="identity",zs=Ts;var hf=Object.freeze({__proto__:null,identity:{code:Bs,name:uf,encode:zs,digest:t=>qn(Bs,zs(t))}});new TextEncoder,new TextDecoder;const qs={...nh,...sh,...ah,...uh,...lh,...Eh,...xh,...Ah,...Nh,...jh};({...cf,...hf});function Hs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Ks=Hs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Hn=Hs("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=As(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Vs={utf8:Ks,"utf-8":Ks,hex:qs.base16,latin1:Hn,ascii:Hn,binary:Hn,...qs};function ct(t,e="utf8"){const r=Vs[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 ut(t,e="utf8"){const r=Vs[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 Gs=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},ff=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),lf=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),df=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),pf=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),gf=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),yf=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,_f=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ws=3,bf=[["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",yf]],ks=[["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 vf(t){return t?Ys(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new gf:typeof navigator<"u"?Ys(navigator.userAgent):Ef()}function wf(t){return t!==""&&bf.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function Ys(t){var e=wf(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new pf;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Ws&&(i=Gs(Gs([],i,!0),Df(Ws-i.length),!0)):i=[];var s=i.join("."),o=mf(t),c=_f.exec(t);return c&&c[1]?new df(r,s,o,c[1]):new ff(r,s,o)}function mf(t){for(var e=0,r=ks.length;e<r;e++){var n=ks[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function Ef(){var t=typeof process<"u"&&process.version;return t?new lf(process.version.slice(1)):null}function Df(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Z={};/*! *****************************************************************************
15
15
  Copyright (c) Microsoft Corporation.
16
16
 
17
17
  Permission to use, copy, modify, and/or distribute this software for any
@@ -24,7 +24,7 @@
24
24
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
25
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
- ***************************************************************************** */var yi=function(t,e){return yi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},yi(t,e)};function ed(t,e){yi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var vi=function(){return vi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},vi.apply(this,arguments)};function td(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function rd(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function nd(t,e){return function(r,n){e(r,n,t)}}function id(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function sd(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{f(n.next(l))}catch(D){o(D)}}function h(l){try{f(n.throw(l))}catch(D){o(D)}}function f(l){l.done?s(l.value):i(l.value).then(a,h)}f((n=n.apply(t,e||[])).next())})}function od(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(f){return function(l){return h([f,l])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(l){f=[6,l],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function ad(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function cd(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function _i(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function So(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function ud(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(So(arguments[e]));return t}function fd(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Cr(t){return this instanceof Cr?(this.v=t,this):new Cr(t)}function hd(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(b){n[b]&&(i[b]=function(m){return new Promise(function(w,N){s.push([b,m,w,N])>1||a(b,m)})})}function a(b,m){try{h(n[b](m))}catch(w){D(s[0][3],w)}}function h(b){b.value instanceof Cr?Promise.resolve(b.value.v).then(f,l):D(s[0][2],b)}function f(b){a("next",b)}function l(b){a("throw",b)}function D(b,m){b(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ld(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Cr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function dd(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 _i=="function"?_i(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,h){o=t[s](o),i(a,h,o.done,o.value)})}}function i(s,o,a,h){Promise.resolve(h).then(function(f){s({value:f,done:a})},o)}}function pd(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function gd(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 yd(t){return t&&t.__esModule?t:{default:t}}function vd(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function _d(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 bd=Object.freeze({__proto__:null,__extends:ed,get __assign(){return vi},__rest:td,__decorate:rd,__param:nd,__metadata:id,__awaiter:sd,__generator:od,__createBinding:ad,__exportStar:cd,__values:_i,__read:So,__spread:ud,__spreadArrays:fd,__await:Cr,__asyncGenerator:hd,__asyncDelegator:ld,__asyncValues:dd,__makeTemplateObject:pd,__importStar:gd,__importDefault:yd,__classPrivateFieldGet:vd,__classPrivateFieldSet:_d}),gn=Zt(bd),bi={},Rr={},Oo;function md(){if(Oo)return Rr;Oo=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Rr.delay=t,Rr}var Qt={},mi={},er={},Lo;function wd(){return Lo||(Lo=1,Object.defineProperty(er,"__esModule",{value:!0}),er.ONE_THOUSAND=er.ONE_HUNDRED=void 0,er.ONE_HUNDRED=100,er.ONE_THOUSAND=1e3),er}var wi={},Io;function Ed(){return Io||(Io=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}(wi)),wi}var Ao;function To(){return Ao||(Ao=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(wd(),t),e.__exportStar(Ed(),t)}(mi)),mi}var Co;function Dd(){if(Co)return Qt;Co=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.fromMiliseconds=Qt.toMiliseconds=void 0;const t=To();function e(n){return n*t.ONE_THOUSAND}Qt.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Qt.fromMiliseconds=r,Qt}var Ro;function xd(){return Ro||(Ro=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(md(),t),e.__exportStar(Dd(),t)}(bi)),bi}var dr={},Po;function Sd(){if(Po)return dr;Po=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.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 n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return dr.Watch=t,dr.default=t,dr}var Ei={},Pr={},No;function Od(){if(No)return Pr;No=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.IWatch=void 0;class t{}return Pr.IWatch=t,Pr}var $o;function Ld(){return $o||($o=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),gn.__exportStar(Od(),t)}(Ei)),Ei}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(xd(),t),e.__exportStar(Sd(),t),e.__exportStar(Ld(),t),e.__exportStar(To(),t)})(Z);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.getLocalStorage=Ce.getLocalStorageOrThrow=Ce.getCrypto=Ce.getCryptoOrThrow=Mo=Ce.getLocation=Ce.getLocationOrThrow=Di=Ce.getNavigator=Ce.getNavigatorOrThrow=Fo=Ce.getDocument=Ce.getDocumentOrThrow=Ce.getFromWindowOrThrow=Ce.getFromWindow=void 0;function tr(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Ce.getFromWindow=tr;function pr(t){const e=tr(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Ce.getFromWindowOrThrow=pr;function Id(){return pr("document")}Ce.getDocumentOrThrow=Id;function Ad(){return tr("document")}var Fo=Ce.getDocument=Ad;function Td(){return pr("navigator")}Ce.getNavigatorOrThrow=Td;function Cd(){return tr("navigator")}var Di=Ce.getNavigator=Cd;function Rd(){return pr("location")}Ce.getLocationOrThrow=Rd;function Pd(){return tr("location")}var Mo=Ce.getLocation=Pd;function Nd(){return pr("crypto")}Ce.getCryptoOrThrow=Nd;function $d(){return tr("crypto")}Ce.getCrypto=$d;function Fd(){return pr("localStorage")}Ce.getLocalStorageOrThrow=Fd;function Md(){return tr("localStorage")}Ce.getLocalStorage=Md;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});var Uo=xi.getWindowMetadata=void 0;const jo=Ce;function Ud(){let t,e;try{t=jo.getDocumentOrThrow(),e=jo.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),b=[];for(let m=0;m<D.length;m++){const w=D[m],N=w.getAttribute("rel");if(N&&N.toLowerCase().indexOf("icon")>-1){const R=w.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let B=e.protocol+"//"+e.host;if(R.indexOf("/")===0)B+=R;else{const S=e.pathname.split("/");S.pop();const I=S.join("/");B+=I+"/"+R}b.push(B)}else if(R.indexOf("//")===0){const B=e.protocol+R;b.push(B)}else b.push(R)}}return b}function n(...D){const b=t.getElementsByTagName("meta");for(let m=0;m<b.length;m++){const w=b[m],N=["itemprop","property","name"].map(R=>w.getAttribute(R)).filter(R=>R?D.includes(R):!1);if(N.length&&N){const R=w.getAttribute("content");if(R)return R}}return""}function i(){let D=n("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),a=s(),h=e.origin,f=r();return{description:a,url:h,icons:f,name:o}}Uo=xi.getWindowMetadata=Ud;var Nr={},jd=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Bo="%[a-f0-9]{2}",zo=new RegExp(Bo,"gi"),Ko=new RegExp("("+Bo+")+","gi");function Si(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Si(r),Si(n))}function Bd(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(zo),r=1;r<e.length;r++)t=Si(e,r).join(""),e=t.match(zo);return t}}function zd(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Ko.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=Bd(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Ko.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var o=i[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var Kd=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return zd(t)}},qd=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},Hd=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var o=n[s],a=t[o];(i?e.indexOf(o)!==-1:e(o,a,t))&&(r[o]=a)}return r};(function(t){const e=jd,r=Kd,n=qd,i=Hd,s=S=>S==null,o=Symbol("encodeFragmentIdentifier");function a(S){switch(S.arrayFormat){case"index":return I=>(y,x)=>{const E=y.length;return x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),"[",E,"]"].join("")]:[...y,[l(I,S),"[",l(E,S),"]=",l(x,S)].join("")]};case"bracket":return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),"[]"].join("")]:[...y,[l(I,S),"[]=",l(x,S)].join("")];case"colon-list-separator":return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),":list="].join("")]:[...y,[l(I,S),":list=",l(x,S)].join("")];case"comma":case"separator":case"bracket-separator":{const I=S.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(x,E)=>E===void 0||S.skipNull&&E===null||S.skipEmptyString&&E===""?x:(E=E===null?"":E,x.length===0?[[l(y,S),I,l(E,S)].join("")]:[[x,l(E,S)].join(S.arrayFormatSeparator)])}default:return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,l(I,S)]:[...y,[l(I,S),"=",l(x,S)].join("")]}}function h(S){let I;switch(S.arrayFormat){case"index":return(y,x,E)=>{if(I=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!I){E[y]=x;return}E[y]===void 0&&(E[y]={}),E[y][I[1]]=x};case"bracket":return(y,x,E)=>{if(I=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!I){E[y]=x;return}if(E[y]===void 0){E[y]=[x];return}E[y]=[].concat(E[y],x)};case"colon-list-separator":return(y,x,E)=>{if(I=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!I){E[y]=x;return}if(E[y]===void 0){E[y]=[x];return}E[y]=[].concat(E[y],x)};case"comma":case"separator":return(y,x,E)=>{const c=typeof x=="string"&&x.includes(S.arrayFormatSeparator),d=typeof x=="string"&&!c&&D(x,S).includes(S.arrayFormatSeparator);x=d?D(x,S):x;const U=c||d?x.split(S.arrayFormatSeparator).map(K=>D(K,S)):x===null?x:D(x,S);E[y]=U};case"bracket-separator":return(y,x,E)=>{const c=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!c){E[y]=x&&D(x,S);return}const d=x===null?[]:x.split(S.arrayFormatSeparator).map(U=>D(U,S));if(E[y]===void 0){E[y]=d;return}E[y]=[].concat(E[y],d)};default:return(y,x,E)=>{if(E[y]===void 0){E[y]=x;return}E[y]=[].concat(E[y],x)}}}function f(S){if(typeof S!="string"||S.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function l(S,I){return I.encode?I.strict?e(S):encodeURIComponent(S):S}function D(S,I){return I.decode?r(S):S}function b(S){return Array.isArray(S)?S.sort():typeof S=="object"?b(Object.keys(S)).sort((I,y)=>Number(I)-Number(y)).map(I=>S[I]):S}function m(S){const I=S.indexOf("#");return I!==-1&&(S=S.slice(0,I)),S}function w(S){let I="";const y=S.indexOf("#");return y!==-1&&(I=S.slice(y)),I}function N(S){S=m(S);const I=S.indexOf("?");return I===-1?"":S.slice(I+1)}function R(S,I){return I.parseNumbers&&!Number.isNaN(Number(S))&&typeof S=="string"&&S.trim()!==""?S=Number(S):I.parseBooleans&&S!==null&&(S.toLowerCase()==="true"||S.toLowerCase()==="false")&&(S=S.toLowerCase()==="true"),S}function B(S,I){I=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},I),f(I.arrayFormatSeparator);const y=h(I),x=Object.create(null);if(typeof S!="string"||(S=S.trim().replace(/^[?#&]/,""),!S))return x;for(const E of S.split("&")){if(E==="")continue;let[c,d]=n(I.decode?E.replace(/\+/g," "):E,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(I.arrayFormat)?d:D(d,I),y(D(c,I),d,x)}for(const E of Object.keys(x)){const c=x[E];if(typeof c=="object"&&c!==null)for(const d of Object.keys(c))c[d]=R(c[d],I);else x[E]=R(c,I)}return I.sort===!1?x:(I.sort===!0?Object.keys(x).sort():Object.keys(x).sort(I.sort)).reduce((E,c)=>{const d=x[c];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?E[c]=b(d):E[c]=d,E},Object.create(null))}t.extract=N,t.parse=B,t.stringify=(S,I)=>{if(!S)return"";I=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},I),f(I.arrayFormatSeparator);const y=d=>I.skipNull&&s(S[d])||I.skipEmptyString&&S[d]==="",x=a(I),E={};for(const d of Object.keys(S))y(d)||(E[d]=S[d]);const c=Object.keys(E);return I.sort!==!1&&c.sort(I.sort),c.map(d=>{const U=S[d];return U===void 0?"":U===null?l(d,I):Array.isArray(U)?U.length===0&&I.arrayFormat==="bracket-separator"?l(d,I)+"[]":U.reduce(x(d),[]).join("&"):l(d,I)+"="+l(U,I)}).filter(d=>d.length>0).join("&")},t.parseUrl=(S,I)=>{I=Object.assign({decode:!0},I);const[y,x]=n(S,"#");return Object.assign({url:y.split("?")[0]||"",query:B(N(S),I)},I&&I.parseFragmentIdentifier&&x?{fragmentIdentifier:D(x,I)}:{})},t.stringifyUrl=(S,I)=>{I=Object.assign({encode:!0,strict:!0,[o]:!0},I);const y=m(S.url).split("?")[0]||"",x=t.extract(S.url),E=t.parse(x,{sort:!1}),c=Object.assign(E,S.query);let d=t.stringify(c,I);d&&(d=`?${d}`);let U=w(S.url);return S.fragmentIdentifier&&(U=`#${I[o]?l(S.fragmentIdentifier,I):S.fragmentIdentifier}`),`${y}${d}${U}`},t.pick=(S,I,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[o]:!1},y);const{url:x,query:E,fragmentIdentifier:c}=t.parseUrl(S,y);return t.stringifyUrl({url:x,query:i(E,I),fragmentIdentifier:c},y)},t.exclude=(S,I,y)=>{const x=Array.isArray(I)?E=>!I.includes(E):(E,c)=>!I(E,c);return t.pick(S,x,y)}})(Nr);const Vd={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},qo=":";function Gd(t){const{namespace:e,reference:r}=t;return[e,r].join(qo)}function Wd(t){const[e,r,n]=t.split(qo);return{namespace:e,reference:r,address:n}}function kd(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function Yd(t){const{namespace:e,reference:r}=Wd(t);return Gd({namespace:e,reference:r})}function Jd(t){return kd(t,Yd)}function Oi(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function Li(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...Jd(i.accounts))}),r}function Xd(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const Ho="base10",pt="base16",Ii="base64pad",Ai="utf8",Vo=0,rr=1,Zd=0,Go=1,Ti=12,Ci=32;function Qd(){const t=hi.generateKeyPair();return{privateKey:dt(t.secretKey,pt),publicKey:dt(t.publicKey,pt)}}function Ri(){const t=lr.randomBytes(Ci);return dt(t,pt)}function ep(t,e){const r=hi.sharedKey(lt(t,pt),lt(e,pt)),n=new hh(dn.SHA256,r).expand(Ci);return dt(n,pt)}function tp(t){const e=dn.hash(lt(t,pt));return dt(e,pt)}function Pi(t){const e=dn.hash(lt(t,Ai));return dt(e,pt)}function rp(t){return lt(`${t}`,Ho)}function $r(t){return Number(dt(t,Ho))}function np(t){const e=rp(typeof t.type<"u"?t.type:Vo);if($r(e)===rr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?lt(t.senderPublicKey,pt):void 0,n=typeof t.iv<"u"?lt(t.iv,pt):lr.randomBytes(Ti),i=new ii.ChaCha20Poly1305(lt(t.symKey,pt)).seal(n,lt(t.message,Ai));return sp({type:e,sealed:i,iv:n,senderPublicKey:r})}function ip(t){const e=new ii.ChaCha20Poly1305(lt(t.symKey,pt)),{sealed:r,iv:n}=Ni(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return dt(i,Ai)}function sp(t){if($r(t.type)===rr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return dt(li([t.type,t.senderPublicKey,t.iv,t.sealed]),Ii)}return dt(li([t.type,t.iv,t.sealed]),Ii)}function Ni(t){const e=lt(t,Ii),r=e.slice(Zd,Go),n=Go;if($r(r)===rr){const a=n+Ci,h=a+Ti,f=e.slice(n,a),l=e.slice(a,h),D=e.slice(h);return{type:r,sealed:D,iv:l,senderPublicKey:f}}const i=n+Ti,s=e.slice(n,i),o=e.slice(i);return{type:r,sealed:o,iv:s}}function op(t,e){const r=Ni(t);return Wo({type:$r(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?dt(r.senderPublicKey,pt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Wo(t){const e=t?.type||Vo;if(e===rr){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 ko(t){return t.type===rr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var ap=Object.defineProperty,Yo=Object.getOwnPropertySymbols,cp=Object.prototype.hasOwnProperty,up=Object.prototype.propertyIsEnumerable,Jo=(t,e,r)=>e in t?ap(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xo=(t,e)=>{for(var r in e||(e={}))cp.call(e,r)&&Jo(t,r,e[r]);if(Yo)for(var r of Yo(e))up.call(e,r)&&Jo(t,r,e[r]);return t};const fp="ReactNative",Fr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},hp="js";function Zo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function lp(){return!Fo()&&!!Di()&&navigator.product===fp}function dp(){return!Zo()&&!!Di()}function pp(){return lp()?Fr.reactNative:Zo()?Fr.node:dp()?Fr.browser:Fr.unknown}function gp(t,e){let r=Nr.parse(t);return r=Xo(Xo({},r),e),t=Nr.stringify(r),t}function yp(){return Uo()||{name:"",description:"",url:"",icons:[""]}}function vp(){const t=Yl();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 _p(){var t;const e=pp();return e===Fr.browser?[e,((t=Mo())==null?void 0:t.host)||"unknown"].join(":"):e}function bp(t,e,r){const n=vp(),i=_p();return[[t,e].join("-"),[hp,r].join("-"),n,i].join("/")}function mp({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const o=r.split("?"),a=bp(t,e,n),h={auth:i,ua:a,projectId:s},f=gp(o[1]||"",h);return o[0]+"?"+f}function gt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Qo(t){return Object.fromEntries(t.entries())}function ea(t){return new Map(Object.entries(t))}function Bt(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function Gt(t){return Z.fromMiliseconds(Date.now())>=Z.toMiliseconds(t)}function nr(){const t=Z.toMiliseconds(Z.FIVE_MINUTES);let e,r,n;return{resolve:i=>{n&&e&&(clearTimeout(n),e(i))},reject:i=>{n&&r&&(clearTimeout(n),r(i))},done:()=>new Promise((i,s)=>{n=setTimeout(s,t),e=i,r=s})}}function ta(t,e){return new Promise(async(r,n)=>{const i=setTimeout(()=>n(),e),s=await t;clearTimeout(i),r(s)})}function ra(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 wp(t){return ra("topic",t)}function Ep(t){return ra("id",t)}function na(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function je(t,e){return`${t}${e?`:${e}`:""}`}const Dp="irn";function $i(t){return t?.relay||{protocol:Dp}}function Fi(t){const e=Vd[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var xp=Object.defineProperty,ia=Object.getOwnPropertySymbols,Sp=Object.prototype.hasOwnProperty,Op=Object.prototype.propertyIsEnumerable,sa=(t,e,r)=>e in t?xp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lp=(t,e)=>{for(var r in e||(e={}))Sp.call(e,r)&&sa(t,r,e[r]);if(ia)for(var r of ia(e))Op.call(e,r)&&sa(t,r,e[r]);return t};function Ip(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),o=t[i];r[s]=o}}),r}function Ap(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=Nr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:o.symKey,relay:Ip(o)}}function Tp(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function Cp(t){return`${t.protocol}:${t.topic}@${t.version}?`+Nr.stringify(Lp({symKey:t.symKey},Tp(t.relay)))}function Tt(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function Rp(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Tt(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...Tt(n.accounts))})}),e}function Pp(t,e){const r=[];return Object.values(t).forEach(n=>{Tt(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{Tt(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function Np(t,e){const r=[];return Object.values(t).forEach(n=>{Tt(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{Tt(i.accounts).includes(e)&&r.push(...i.events)})}),r}function $p(t,e){const r=vn(t,e);if(r)throw new Error(r.message);const n={};for(const[i,s]of Object.entries(t))n[i]={methods:s.methods,events:s.events,chains:s.accounts.map(o=>`${o.split(":")[0]}:${o.split(":")[1]}`)};return n}const Fp={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}},Mp={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 V(t,e){const{message:r,code:n}=Mp[t];return{message:e?`${r} ${e}`:r,code:n}}function Ge(t,e){const{message:r,code:n}=Fp[t];return{message:e?`${r} ${e}`:r,code:n}}function Mr(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function yn(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function bt(t){return typeof t>"u"}function st(t,e){return e&&bt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function oa(t,e){return e&&bt(t)?!0:typeof t=="number"&&!isNaN(t)}function Up(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return gt(i,n)?(n.forEach(o=>{const{accounts:a,methods:h,events:f,extension:l}=t.namespaces[o],D=Tt(a),b=r[o];(!gt(b.chains,D)||!gt(b.methods,h)||!gt(b.events,f))&&(s=!1),s&&l&&l.forEach(m=>{var w;const{accounts:N,methods:R,events:B}=m,S=Tt(N);(w=b.extension)!=null&&w.find(I=>gt(I.chains,S)&&gt(I.methods,R)&&gt(I.events,B))||(s=!1)})}),s):!1}function Mi(t){return st(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function jp(t){if(st(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Mi(r)}}return!1}function Bp(t){if(st(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function zp(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Kp(t){return t?.topic}function qp(t,e){let r=null;return st(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Ui(t,e){let r=null;return bt(t?.extension)||(!Mr(t.extension)||!t.extension.length)&&(r=V("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function aa(t){let e=!0;return Mr(t)?t.length&&(e=t.every(r=>st(r,!1))):e=!1,e}function ca(t,e,r){let n=null;return Mr(e)?e.forEach(i=>{n||(!Mi(i)||!i.includes(t))&&(n=Ge("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=Ge("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function Hp(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=ca(n,i?.chains,`${e} requiredNamespace`),o=Ui(i,e);s?r=s:o?r=o:i.extension&&i.extension.forEach(a=>{if(r)return;const h=ca(n,a.chains,`${e} extension`);h&&(r=h)})}),r}function ua(t,e){let r=null;return Mr(t)?t.forEach(n=>{r||jp(n)||(r=Ge("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Ge("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Vp(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=ua(n?.accounts,`${e} namespace`),s=Ui(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(o=>{if(r)return;const a=ua(o.accounts,`${e} extension`);a&&(r=a)})}),r}function fa(t,e){let r=null;return aa(t?.methods)?aa(t?.events)||(r=Ge("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Ge("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function ha(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=fa(n,`${e}, namespace`),s=Ui(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(o=>{if(r)return;const a=fa(o,`${e}, extension`);a&&(r=a)})}),r}function Gp(t,e){let r=null;if(t&&yn(t)){const n=ha(t,e);n&&(r=n);const i=Hp(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function vn(t,e){let r=null;if(t&&yn(t)){const n=ha(t,e);n&&(r=n);const i=Vp(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function la(t){return st(t.protocol,!0)}function Wp(t,e){let r=!1;return e&&!t?r=!0:t&&Mr(t)&&t.length&&t.forEach(n=>{r=la(n)}),r}function kp(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function Yp(t){return!(!t||typeof t!="object"||!t.code||!oa(t.code,!1)||!t.message||!st(t.message,!1))}function Jp(t){return!(bt(t)||!st(t.method,!1))}function Xp(t){return!(bt(t)||bt(t.result)&&bt(t.error)||!oa(t.id,!1)||!st(t.jsonrpc,!1))}function Zp(t){return!(bt(t)||!st(t.name,!1))}function da(t,e){return!(!Mi(e)||!Rp(t).includes(e))}function Qp(t,e,r){return st(r,!1)?Pp(t,e).includes(r):!1}function eg(t,e,r){return st(r,!1)?Np(t,e).includes(r):!1}function pa(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return gt(i,s)?i.forEach(o=>{var a;if(n)return;const h=t[o].chains,f=Tt(e[o].accounts);gt(h,f)?gt(t[o].methods,e[o].methods)?gt(t[o].events,e[o].events)?t[o].extension&&!e[o].extension?n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${o}`):t[o].extension&&e[o].extension&&((a=t[o].extension)==null||a.forEach(({methods:l,events:D,chains:b})=>{var m;n||(m=e[o].extension)!=null&&m.find(w=>{const N=Tt(w.accounts);return gt(b,N)&&gt(D,w.events)&&gt(l,w.methods)})||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${o}`))})):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${o}`)}):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function tg(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var rg=ng;function ng(t,e,r){var n=r&&r.stringify||tg,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var a=1;a<s;a++)o[a]=n(e[a]);return o.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var f="",l=1-i,D=-1,b=t&&t.length||0,m=0;m<b;){if(t.charCodeAt(m)===37&&m+1<b){switch(D=D>-1?D:0,t.charCodeAt(m+1)){case 100:case 102:if(l>=h||e[l]==null)break;D<m&&(f+=t.slice(D,m)),f+=Number(e[l]),D=m+2,m++;break;case 105:if(l>=h||e[l]==null)break;D<m&&(f+=t.slice(D,m)),f+=Math.floor(Number(e[l])),D=m+2,m++;break;case 79:case 111:case 106:if(l>=h||e[l]===void 0)break;D<m&&(f+=t.slice(D,m));var w=typeof e[l];if(w==="string"){f+="'"+e[l]+"'",D=m+2,m++;break}if(w==="function"){f+=e[l].name||"<anonymous>",D=m+2,m++;break}f+=n(e[l]),D=m+2,m++;break;case 115:if(l>=h)break;D<m&&(f+=t.slice(D,m)),f+=String(e[l]),D=m+2,m++;break;case 37:D<m&&(f+=t.slice(D,m)),f+="%",D=m+2,m++,l--;break}++l}++m}return D===-1?t:(D<b&&(f+=t.slice(D)),f)}const ga=rg;var _n=Ct;const Ur=dg().console||{},ig={mapHttpRequest:mn,mapHttpResponse:mn,wrapRequestSerializer:Bi,wrapResponseSerializer:Bi,wrapErrorSerializer:Bi,req:mn,res:mn,err:ug};function sg(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Ct(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||Ur;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=sg(t.browser.serialize,n);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",h=Object.create(r);h.log||(h.log=jr),Object.defineProperty(h,"levelVal",{get:l}),Object.defineProperty(h,"level",{get:D,set:b});const f={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:fg(t)};h.levels=Ct.levels,h.level=a,h.setMaxListeners=h.getMaxListeners=h.emit=h.addListener=h.on=h.prependListener=h.once=h.prependOnceListener=h.removeListener=h.removeAllListeners=h.listeners=h.listenerCount=h.eventNames=h.write=h.flush=jr,h.serializers=n,h._serialize=i,h._stdErrSerialize=s,h.child=m,e&&(h._logEvent=ji());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function b(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,gr(f,h,"error","log"),gr(f,h,"fatal","error"),gr(f,h,"warn","error"),gr(f,h,"info","log"),gr(f,h,"debug","log"),gr(f,h,"trace","log")}function m(w,N){if(!w)throw new Error("missing bindings for child Pino");N=N||{},i&&w.serializers&&(N.serializers=w.serializers);const R=N.serializers;if(i&&R){var B=Object.assign({},n,R),S=t.browser.serialize===!0?Object.keys(B):i;delete w.serializers,bn([w],S,B,this._stdErrSerialize)}function I(y){this._childLevel=(y._childLevel|0)+1,this.error=yr(y,w,"error"),this.fatal=yr(y,w,"fatal"),this.warn=yr(y,w,"warn"),this.info=yr(y,w,"info"),this.debug=yr(y,w,"debug"),this.trace=yr(y,w,"trace"),B&&(this.serializers=B,this._serialize=S),e&&(this._logEvent=ji([].concat(y._logEvent.bindings,w)))}return I.prototype=this,new I(this)}return h}Ct.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"}},Ct.stdSerializers=ig,Ct.stdTimeFunctions=Object.assign({},{nullTime:ya,epochTime:va,unixTime:hg,isoTime:lg});function gr(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?jr:i[r]?i[r]:Ur[r]||Ur[n]||jr,og(t,e,r)}function og(t,e,r){!t.transmit&&e[r]===jr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ur?Ur:this;for(var h=0;h<o.length;h++)o[h]=arguments[h];if(t.serialize&&!t.asObject&&bn(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(a,ag(this,r,o,s)):n.apply(a,o),t.transmit){const f=t.transmit.level||e.level,l=Ct.levels.values[f],D=Ct.levels.values[r];if(D<l)return;cg(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:f,transmitValue:Ct.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function ag(t,e,r,n){t._serialize&&bn(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const o={};n&&(o.time=n),o.level=Ct.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof i[0]=="object";)Object.assign(o,i.shift());s=i.length?ga(i.shift(),i):void 0}else typeof s=="string"&&(s=ga(i.shift(),i));return s!==void 0&&(o.msg=s),o}function bn(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=Ct.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(const s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function yr(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function cg(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,h=t._logEvent.bindings;bn(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(f){return h.indexOf(f)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,n(s,t._logEvent,a),t._logEvent=ji(h)}function ji(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function ug(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 fg(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?ya:va}function mn(){return{}}function Bi(t){return t}function jr(){}function ya(){return!1}function va(){return Date.now()}function hg(){return Math.round(Date.now()/1e3)}function lg(){return new Date(Date.now()).toISOString()}function dg(){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)||{}}}var zt={exports:{}},vr=typeof Reflect=="object"?Reflect:null,_a=vr&&typeof vr.apply=="function"?vr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},wn;vr&&typeof vr.ownKeys=="function"?wn=vr.ownKeys:Object.getOwnPropertySymbols?wn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:wn=function(e){return Object.getOwnPropertyNames(e)};function pg(t){console&&console.warn&&console.warn(t)}var ba=Number.isNaN||function(e){return e!==e};function Se(){Se.init.call(this)}zt.exports=Se,zt.exports.once=_g,Se.EventEmitter=Se,Se.prototype._events=void 0,Se.prototype._eventsCount=0,Se.prototype._maxListeners=void 0;var ma=10;function En(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Se,"defaultMaxListeners",{enumerable:!0,get:function(){return ma},set:function(t){if(typeof t!="number"||t<0||ba(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ma=t}}),Se.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Se.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ba(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 wa(t){return t._maxListeners===void 0?Se.defaultMaxListeners:t._maxListeners}Se.prototype.getMaxListeners=function(){return wa(this)},Se.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")_a(h,this,r);else for(var f=h.length,l=Oa(h,f),n=0;n<f;++n)_a(l[n],this,r);return!0};function Ea(t,e,r,n){var i,s,o;if(En(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=wa(t),i>0&&o.length>i&&!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,pg(a)}return t}Se.prototype.addListener=function(e,r){return Ea(this,e,r,!1)},Se.prototype.on=Se.prototype.addListener,Se.prototype.prependListener=function(e,r){return Ea(this,e,r,!0)};function gg(){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 Da(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=gg.bind(n);return i.listener=r,n.wrapFn=i,i}Se.prototype.once=function(e,r){return En(r),this.on(e,Da(this,e,r)),this},Se.prototype.prependOnceListener=function(e,r){return En(r),this.prependListener(e,Da(this,e,r)),this},Se.prototype.removeListener=function(e,r){var n,i,s,o,a;if(En(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():yg(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Se.prototype.off=Se.prototype.removeListener,Se.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function xa(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?vg(i):Oa(i,i.length)}Se.prototype.listeners=function(e){return xa(this,e,!0)},Se.prototype.rawListeners=function(e){return xa(this,e,!1)},Se.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Sa.call(t,e)},Se.prototype.listenerCount=Sa;function Sa(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Se.prototype.eventNames=function(){return this._eventsCount>0?wn(this._events):[]};function Oa(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function yg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function vg(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function _g(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}La(t,e,s,{once:!0}),e!=="error"&&bg(t,i,{once:!0})})}function bg(t,e,r){typeof t.on=="function"&&La(t,"error",e,r)}function La(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Dn={};/*! *****************************************************************************
27
+ ***************************************************************************** */var Kn=function(t,e){return Kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Kn(t,e)};function Sf(t,e){Kn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Vn=function(){return Vn=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Vn.apply(this,arguments)};function xf(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Of(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function If(t,e){return function(r,n){e(r,n,t)}}function Af(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Tf(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Pf(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Rf(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Cf(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Gn(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Js(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Nf(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Js(arguments[e]));return t}function Ff(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function _r(t){return this instanceof _r?(this.v=t,this):new _r(t)}function Lf(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof _r?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Uf(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:_r(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function $f(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 Gn=="function"?Gn(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Mf(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function jf(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 Bf(t){return t&&t.__esModule?t:{default:t}}function zf(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function qf(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 Hf=Object.freeze({__proto__:null,__extends:Sf,get __assign(){return Vn},__rest:xf,__decorate:Of,__param:If,__metadata:Af,__awaiter:Tf,__generator:Pf,__createBinding:Rf,__exportStar:Cf,__values:Gn,__read:Js,__spread:Nf,__spreadArrays:Ff,__await:_r,__asyncGenerator:Lf,__asyncDelegator:Uf,__asyncValues:$f,__makeTemplateObject:Mf,__importStar:jf,__importDefault:Bf,__classPrivateFieldGet:zf,__classPrivateFieldSet:qf}),en=Kt(Hf),Wn={},br={},Xs;function Kf(){if(Xs)return br;Xs=1,Object.defineProperty(br,"__esModule",{value:!0}),br.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return br.delay=t,br}var Vt={},kn={},Gt={},Zs;function Vf(){return Zs||(Zs=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.ONE_THOUSAND=Gt.ONE_HUNDRED=void 0,Gt.ONE_HUNDRED=100,Gt.ONE_THOUSAND=1e3),Gt}var Yn={},Qs;function Gf(){return Qs||(Qs=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}(Yn)),Yn}var eo;function to(){return eo||(eo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(Vf(),t),e.__exportStar(Gf(),t)}(kn)),kn}var ro;function Wf(){if(ro)return Vt;ro=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.fromMiliseconds=Vt.toMiliseconds=void 0;const t=to();function e(n){return n*t.ONE_THOUSAND}Vt.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Vt.fromMiliseconds=r,Vt}var no;function kf(){return no||(no=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(Kf(),t),e.__exportStar(Wf(),t)}(Wn)),Wn}var sr={},io;function Yf(){if(io)return sr;io=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.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 n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return sr.Watch=t,sr.default=t,sr}var Jn={},vr={},so;function Jf(){if(so)return vr;so=1,Object.defineProperty(vr,"__esModule",{value:!0}),vr.IWatch=void 0;class t{}return vr.IWatch=t,vr}var oo;function Xf(){return oo||(oo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),en.__exportStar(Jf(),t)}(Jn)),Jn}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(kf(),t),e.__exportStar(Yf(),t),e.__exportStar(Xf(),t),e.__exportStar(to(),t)})(Z);var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.getLocalStorage=Oe.getLocalStorageOrThrow=Oe.getCrypto=Oe.getCryptoOrThrow=co=Oe.getLocation=Oe.getLocationOrThrow=Xn=Oe.getNavigator=Oe.getNavigatorOrThrow=ao=Oe.getDocument=Oe.getDocumentOrThrow=Oe.getFromWindowOrThrow=Oe.getFromWindow=void 0;function Wt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Oe.getFromWindow=Wt;function or(t){const e=Wt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Oe.getFromWindowOrThrow=or;function Zf(){return or("document")}Oe.getDocumentOrThrow=Zf;function Qf(){return Wt("document")}var ao=Oe.getDocument=Qf;function el(){return or("navigator")}Oe.getNavigatorOrThrow=el;function tl(){return Wt("navigator")}var Xn=Oe.getNavigator=tl;function rl(){return or("location")}Oe.getLocationOrThrow=rl;function nl(){return Wt("location")}var co=Oe.getLocation=nl;function il(){return or("crypto")}Oe.getCryptoOrThrow=il;function sl(){return Wt("crypto")}Oe.getCrypto=sl;function ol(){return or("localStorage")}Oe.getLocalStorageOrThrow=ol;function al(){return Wt("localStorage")}Oe.getLocalStorage=al;var Zn={};Object.defineProperty(Zn,"__esModule",{value:!0});var uo=Zn.getWindowMetadata=void 0;const ho=Oe;function cl(){let t,e;try{t=ho.getDocumentOrThrow(),e=ho.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),w=[];for(let m=0;m<D.length;m++){const E=D[m],F=E.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const N=E.getAttribute("href");if(N)if(N.toLowerCase().indexOf("https:")===-1&&N.toLowerCase().indexOf("http:")===-1&&N.indexOf("//")!==0){let B=e.protocol+"//"+e.host;if(N.indexOf("/")===0)B+=N;else{const x=e.pathname.split("/");x.pop();const A=x.join("/");B+=A+"/"+N}w.push(B)}else if(N.indexOf("//")===0){const B=e.protocol+N;w.push(B)}else w.push(N)}}return w}function n(...D){const w=t.getElementsByTagName("meta");for(let m=0;m<w.length;m++){const E=w[m],F=["itemprop","property","name"].map(N=>E.getAttribute(N)).filter(N=>N?D.includes(N):!1);if(F.length&&F){const N=E.getAttribute("content");if(N)return N}}return""}function i(){let D=n("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),c=s(),f=e.origin,h=r();return{description:c,url:f,icons:h,name:o}}uo=Zn.getWindowMetadata=cl;var wr={},ul=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),fo="%[a-f0-9]{2}",lo=new RegExp("("+fo+")|([^%]+?)","gi"),po=new RegExp("("+fo+")+","gi");function Qn(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Qn(r),Qn(n))}function hl(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(lo)||[],r=1;r<e.length;r++)t=Qn(e,r).join(""),e=t.match(lo)||[];return t}}function fl(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=po.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=hl(r[0]);n!==r[0]&&(e[r[0]]=n)}r=po.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var o=i[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var ll=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return fl(t)}},dl=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},pl=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var o=n[s],c=t[o];(i?e.indexOf(o)!==-1:e(o,c,t))&&(r[o]=c)}return r};(function(t){const e=ul,r=ll,n=dl,i=pl,s=x=>x==null,o=Symbol("encodeFragmentIdentifier");function c(x){switch(x.arrayFormat){case"index":return A=>(y,S)=>{const v=y.length;return S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),"[",v,"]"].join("")]:[...y,[l(A,x),"[",l(v,x),"]=",l(S,x)].join("")]};case"bracket":return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),"[]"].join("")]:[...y,[l(A,x),"[]=",l(S,x)].join("")];case"colon-list-separator":return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),":list="].join("")]:[...y,[l(A,x),":list=",l(S,x)].join("")];case"comma":case"separator":case"bracket-separator":{const A=x.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(S,v)=>v===void 0||x.skipNull&&v===null||x.skipEmptyString&&v===""?S:(v=v===null?"":v,S.length===0?[[l(y,x),A,l(v,x)].join("")]:[[S,l(v,x)].join(x.arrayFormatSeparator)])}default:return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,l(A,x)]:[...y,[l(A,x),"=",l(S,x)].join("")]}}function f(x){let A;switch(x.arrayFormat){case"index":return(y,S,v)=>{if(A=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!A){v[y]=S;return}v[y]===void 0&&(v[y]={}),v[y][A[1]]=S};case"bracket":return(y,S,v)=>{if(A=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!A){v[y]=S;return}if(v[y]===void 0){v[y]=[S];return}v[y]=[].concat(v[y],S)};case"colon-list-separator":return(y,S,v)=>{if(A=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!A){v[y]=S;return}if(v[y]===void 0){v[y]=[S];return}v[y]=[].concat(v[y],S)};case"comma":case"separator":return(y,S,v)=>{const a=typeof S=="string"&&S.includes(x.arrayFormatSeparator),d=typeof S=="string"&&!a&&D(S,x).includes(x.arrayFormatSeparator);S=d?D(S,x):S;const M=a||d?S.split(x.arrayFormatSeparator).map(q=>D(q,x)):S===null?S:D(S,x);v[y]=M};case"bracket-separator":return(y,S,v)=>{const a=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!a){v[y]=S&&D(S,x);return}const d=S===null?[]:S.split(x.arrayFormatSeparator).map(M=>D(M,x));if(v[y]===void 0){v[y]=d;return}v[y]=[].concat(v[y],d)};default:return(y,S,v)=>{if(v[y]===void 0){v[y]=S;return}v[y]=[].concat(v[y],S)}}}function h(x){if(typeof x!="string"||x.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function l(x,A){return A.encode?A.strict?e(x):encodeURIComponent(x):x}function D(x,A){return A.decode?r(x):x}function w(x){return Array.isArray(x)?x.sort():typeof x=="object"?w(Object.keys(x)).sort((A,y)=>Number(A)-Number(y)).map(A=>x[A]):x}function m(x){const A=x.indexOf("#");return A!==-1&&(x=x.slice(0,A)),x}function E(x){let A="";const y=x.indexOf("#");return y!==-1&&(A=x.slice(y)),A}function F(x){x=m(x);const A=x.indexOf("?");return A===-1?"":x.slice(A+1)}function N(x,A){return A.parseNumbers&&!Number.isNaN(Number(x))&&typeof x=="string"&&x.trim()!==""?x=Number(x):A.parseBooleans&&x!==null&&(x.toLowerCase()==="true"||x.toLowerCase()==="false")&&(x=x.toLowerCase()==="true"),x}function B(x,A){A=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},A),h(A.arrayFormatSeparator);const y=f(A),S=Object.create(null);if(typeof x!="string"||(x=x.trim().replace(/^[?#&]/,""),!x))return S;for(const v of x.split("&")){if(v==="")continue;let[a,d]=n(A.decode?v.replace(/\+/g," "):v,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?d:D(d,A),y(D(a,A),d,S)}for(const v of Object.keys(S)){const a=S[v];if(typeof a=="object"&&a!==null)for(const d of Object.keys(a))a[d]=N(a[d],A);else S[v]=N(a,A)}return A.sort===!1?S:(A.sort===!0?Object.keys(S).sort():Object.keys(S).sort(A.sort)).reduce((v,a)=>{const d=S[a];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?v[a]=w(d):v[a]=d,v},Object.create(null))}t.extract=F,t.parse=B,t.stringify=(x,A)=>{if(!x)return"";A=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},A),h(A.arrayFormatSeparator);const y=d=>A.skipNull&&s(x[d])||A.skipEmptyString&&x[d]==="",S=c(A),v={};for(const d of Object.keys(x))y(d)||(v[d]=x[d]);const a=Object.keys(v);return A.sort!==!1&&a.sort(A.sort),a.map(d=>{const M=x[d];return M===void 0?"":M===null?l(d,A):Array.isArray(M)?M.length===0&&A.arrayFormat==="bracket-separator"?l(d,A)+"[]":M.reduce(S(d),[]).join("&"):l(d,A)+"="+l(M,A)}).filter(d=>d.length>0).join("&")},t.parseUrl=(x,A)=>{A=Object.assign({decode:!0},A);const[y,S]=n(x,"#");return Object.assign({url:y.split("?")[0]||"",query:B(F(x),A)},A&&A.parseFragmentIdentifier&&S?{fragmentIdentifier:D(S,A)}:{})},t.stringifyUrl=(x,A)=>{A=Object.assign({encode:!0,strict:!0,[o]:!0},A);const y=m(x.url).split("?")[0]||"",S=t.extract(x.url),v=t.parse(S,{sort:!1}),a=Object.assign(v,x.query);let d=t.stringify(a,A);d&&(d=`?${d}`);let M=E(x.url);return x.fragmentIdentifier&&(M=`#${A[o]?l(x.fragmentIdentifier,A):x.fragmentIdentifier}`),`${y}${d}${M}`},t.pick=(x,A,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[o]:!1},y);const{url:S,query:v,fragmentIdentifier:a}=t.parseUrl(x,y);return t.stringifyUrl({url:S,query:i(v,A),fragmentIdentifier:a},y)},t.exclude=(x,A,y)=>{const S=Array.isArray(A)?v=>!A.includes(v):(v,a)=>!A(v,a);return t.pick(x,S,y)}})(wr);const gl={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},go=":";function yl(t){const{namespace:e,reference:r}=t;return[e,r].join(go)}function _l(t){const[e,r,n]=t.split(go);return{namespace:e,reference:r,address:n}}function bl(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function vl(t){const{namespace:e,reference:r}=_l(t);return yl({namespace:e,reference:r})}function wl(t){return bl(t,vl)}function ei(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function ti(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...wl(i.accounts))}),r}function ml(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const yo="base10",ht="base16",ri="base64pad",ni="utf8",_o=0,kt=1,El=0,bo=1,ii=12,si=32;function Dl(){const t=jn.generateKeyPair();return{privateKey:ut(t.secretKey,ht),publicKey:ut(t.publicKey,ht)}}function oi(){const t=ir.randomBytes(si);return ut(t,ht)}function Sl(t,e){const r=jn.sharedKey(ct(t,ht),ct(e,ht)),n=new Fu(Zr.SHA256,r).expand(si);return ut(n,ht)}function xl(t){const e=Zr.hash(ct(t,ht));return ut(e,ht)}function ai(t){const e=Zr.hash(ct(t,ni));return ut(e,ht)}function Ol(t){return ct(`${t}`,yo)}function mr(t){return Number(ut(t,yo))}function Il(t){const e=Ol(typeof t.type<"u"?t.type:_o);if(mr(e)===kt&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ct(t.senderPublicKey,ht):void 0,n=typeof t.iv<"u"?ct(t.iv,ht):ir.randomBytes(ii),i=new Cn.ChaCha20Poly1305(ct(t.symKey,ht)).seal(n,ct(t.message,ni));return Tl({type:e,sealed:i,iv:n,senderPublicKey:r})}function Al(t){const e=new Cn.ChaCha20Poly1305(ct(t.symKey,ht)),{sealed:r,iv:n}=ci(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ut(i,ni)}function Tl(t){if(mr(t.type)===kt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ut(Bn([t.type,t.senderPublicKey,t.iv,t.sealed]),ri)}return ut(Bn([t.type,t.iv,t.sealed]),ri)}function ci(t){const e=ct(t,ri),r=e.slice(El,bo),n=bo;if(mr(r)===kt){const c=n+si,f=c+ii,h=e.slice(n,c),l=e.slice(c,f),D=e.slice(f);return{type:r,sealed:D,iv:l,senderPublicKey:h}}const i=n+ii,s=e.slice(n,i),o=e.slice(i);return{type:r,sealed:o,iv:s}}function Pl(t,e){const r=ci(t);return vo({type:mr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ut(r.senderPublicKey,ht):void 0,receiverPublicKey:e?.receiverPublicKey})}function vo(t){const e=t?.type||_o;if(e===kt){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 wo(t){return t.type===kt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var Rl=Object.defineProperty,mo=Object.getOwnPropertySymbols,Cl=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,Eo=(t,e,r)=>e in t?Rl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Do=(t,e)=>{for(var r in e||(e={}))Cl.call(e,r)&&Eo(t,r,e[r]);if(mo)for(var r of mo(e))Nl.call(e,r)&&Eo(t,r,e[r]);return t};const Fl="ReactNative",Er={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Ll="js";function So(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ul(){return!ao()&&!!Xn()&&navigator.product===Fl}function $l(){return!So()&&!!Xn()}function Ml(){return Ul()?Er.reactNative:So()?Er.node:$l()?Er.browser:Er.unknown}function jl(t,e){let r=wr.parse(t);return r=Do(Do({},r),e),t=wr.stringify(r),t}function Bl(){return uo()||{name:"",description:"",url:"",icons:[""]}}function zl(){const t=vf();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 ql(){var t;const e=Ml();return e===Er.browser?[e,((t=co())==null?void 0:t.host)||"unknown"].join(":"):e}function Hl(t,e,r){const n=zl(),i=ql();return[[t,e].join("-"),[Ll,r].join("-"),n,i].join("/")}function Kl({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const o=r.split("?"),c=Hl(t,e,n),f={auth:i,ua:c,projectId:s},h=jl(o[1]||"",f);return o[0]+"?"+h}function $t(t,e){return t.filter(r=>e.includes(r)).length===t.length}function xo(t){return Object.fromEntries(t.entries())}function Oo(t){return new Map(Object.entries(t))}function St(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function Mt(t){return Z.fromMiliseconds(Date.now())>=Z.toMiliseconds(t)}function Yt(t){const e=Z.toMiliseconds(t||Z.FIVE_MINUTES);let r,n,i;return{resolve:s=>{i&&r&&(clearTimeout(i),r(s))},reject:s=>{i&&n&&(clearTimeout(i),n(s))},done:()=>new Promise((s,o)=>{i=setTimeout(o,e),r=s,n=o})}}function Io(t,e){return new Promise(async(r,n)=>{const i=setTimeout(()=>n(),e),s=await t;clearTimeout(i),r(s)})}function Ao(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 Vl(t){return Ao("topic",t)}function Gl(t){return Ao("id",t)}function To(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function Fe(t,e){return`${t}${e?`:${e}`:""}`}const Wl="irn";function ui(t){return t?.relay||{protocol:Wl}}function hi(t){const e=gl[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var kl=Object.defineProperty,Po=Object.getOwnPropertySymbols,Yl=Object.prototype.hasOwnProperty,Jl=Object.prototype.propertyIsEnumerable,Ro=(t,e,r)=>e in t?kl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xl=(t,e)=>{for(var r in e||(e={}))Yl.call(e,r)&&Ro(t,r,e[r]);if(Po)for(var r of Po(e))Jl.call(e,r)&&Ro(t,r,e[r]);return t};function Zl(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),o=t[i];r[s]=o}}),r}function Ql(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=wr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:o.symKey,relay:Zl(o)}}function ed(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function td(t){return`${t.protocol}:${t.topic}@${t.version}?`+wr.stringify(Xl({symKey:t.symKey},ed(t.relay)))}function Dr(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function rd(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Dr(r.accounts))}),e}function nd(t,e){const r=[];return Object.values(t).forEach(n=>{Dr(n.accounts).includes(e)&&r.push(...n.methods)}),r}function id(t,e){const r=[];return Object.values(t).forEach(n=>{Dr(n.accounts).includes(e)&&r.push(...n.events)}),r}function sd(t,e){const r=nn(t,e);if(r)throw new Error(r.message);const n={};for(const[i,s]of Object.entries(t))n[i]={methods:s.methods,events:s.events,chains:s.accounts.map(o=>`${o.split(":")[0]}:${o.split(":")[1]}`)};return n}const od={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}},ad={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 V(t,e){const{message:r,code:n}=ad[t];return{message:e?`${r} ${e}`:r,code:n}}function ze(t,e){const{message:r,code:n}=od[t];return{message:e?`${r} ${e}`:r,code:n}}function tn(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function rn(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function gt(t){return typeof t>"u"}function et(t,e){return e&&gt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function fi(t,e){return e&&gt(t)?!0:typeof t=="number"&&!isNaN(t)}function cd(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return $t(i,n)?(n.forEach(o=>{const{accounts:c,methods:f,events:h}=t.namespaces[o],l=Dr(c),D=r[o];(!$t(D.chains,l)||!$t(D.methods,f)||!$t(D.events,h))&&(s=!1)}),s):!1}function li(t){return et(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function ud(t){if(et(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&li(r)}}return!1}function hd(t){if(et(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function fd(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function ld(t){return t?.topic}function dd(t,e){let r=null;return et(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Co(t){let e=!0;return tn(t)?t.length&&(e=t.every(r=>et(r,!1))):e=!1,e}function pd(t,e,r){let n=null;return tn(e)?e.forEach(i=>{n||(!li(i)||!i.includes(t))&&(n=ze("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=ze("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function gd(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=pd(n,i?.chains,`${e} requiredNamespace`);s&&(r=s)}),r}function yd(t,e){let r=null;return tn(t)?t.forEach(n=>{r||ud(n)||(r=ze("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=ze("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function _d(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=yd(n?.accounts,`${e} namespace`);i&&(r=i)}),r}function bd(t,e){let r=null;return Co(t?.methods)?Co(t?.events)||(r=ze("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ze("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function No(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=bd(n,`${e}, namespace`);i&&(r=i)}),r}function vd(t,e){let r=null;if(t&&rn(t)){const n=No(t,e);n&&(r=n);const i=gd(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function nn(t,e){let r=null;if(t&&rn(t)){const n=No(t,e);n&&(r=n);const i=_d(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Fo(t){return et(t.protocol,!0)}function wd(t,e){let r=!1;return e&&!t?r=!0:t&&tn(t)&&t.length&&t.forEach(n=>{r=Fo(n)}),r}function md(t){return typeof t=="number"}function ft(t){return typeof t<"u"&&typeof t!==null}function Ed(t){return!(!t||typeof t!="object"||!t.code||!fi(t.code,!1)||!t.message||!et(t.message,!1))}function Dd(t){return!(gt(t)||!et(t.method,!1))}function Sd(t){return!(gt(t)||gt(t.result)&&gt(t.error)||!fi(t.id,!1)||!et(t.jsonrpc,!1))}function xd(t){return!(gt(t)||!et(t.name,!1))}function Lo(t,e){return!(!li(e)||!rd(t).includes(e))}function Od(t,e,r){return et(r,!1)?nd(t,e).includes(r):!1}function Id(t,e,r){return et(r,!1)?id(t,e).includes(r):!1}function Uo(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return $t(i,s)?i.forEach(o=>{if(n)return;const c=t[o].chains,f=Dr(e[o].accounts);$t(c,f)?$t(t[o].methods,e[o].methods)?$t(t[o].events,e[o].events)||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${o}`)):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${o}`)}):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function Ad(t,e){return fi(t,!1)&&t<=e.max&&t>=e.min}function Td(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Pd=Rd;function Rd(t,e,r){var n=r&&r.stringify||Td,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var c=1;c<s;c++)o[c]=n(e[c]);return o.join(" ")}if(typeof t!="string")return t;var f=e.length;if(f===0)return t;for(var h="",l=1-i,D=-1,w=t&&t.length||0,m=0;m<w;){if(t.charCodeAt(m)===37&&m+1<w){switch(D=D>-1?D:0,t.charCodeAt(m+1)){case 100:case 102:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Number(e[l]),D=m+2,m++;break;case 105:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Math.floor(Number(e[l])),D=m+2,m++;break;case 79:case 111:case 106:if(l>=f||e[l]===void 0)break;D<m&&(h+=t.slice(D,m));var E=typeof e[l];if(E==="string"){h+="'"+e[l]+"'",D=m+2,m++;break}if(E==="function"){h+=e[l].name||"<anonymous>",D=m+2,m++;break}h+=n(e[l]),D=m+2,m++;break;case 115:if(l>=f)break;D<m&&(h+=t.slice(D,m)),h+=String(e[l]),D=m+2,m++;break;case 37:D<m&&(h+=t.slice(D,m)),h+="%",D=m+2,m++,l--;break}++l}++m}return D===-1?t:(D<w&&(h+=t.slice(D)),h)}const $o=Pd;var sn=xt;const Sr=zd().console||{},Cd={mapHttpRequest:an,mapHttpResponse:an,wrapRequestSerializer:pi,wrapResponseSerializer:pi,wrapErrorSerializer:pi,req:an,res:an,err:$d};function Nd(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function xt(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||Sr;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=Nd(t.browser.serialize,n);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 c=t.level||"info",f=Object.create(r);f.log||(f.log=xr),Object.defineProperty(f,"levelVal",{get:l}),Object.defineProperty(f,"level",{get:D,set:w});const h={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:Md(t)};f.levels=xt.levels,f.level=c,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=xr,f.serializers=n,f._serialize=i,f._stdErrSerialize=s,f.child=m,e&&(f._logEvent=di());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function w(E){if(E!=="silent"&&!this.levels.values[E])throw Error("unknown level "+E);this._level=E,ar(h,f,"error","log"),ar(h,f,"fatal","error"),ar(h,f,"warn","error"),ar(h,f,"info","log"),ar(h,f,"debug","log"),ar(h,f,"trace","log")}function m(E,F){if(!E)throw new Error("missing bindings for child Pino");F=F||{},i&&E.serializers&&(F.serializers=E.serializers);const N=F.serializers;if(i&&N){var B=Object.assign({},n,N),x=t.browser.serialize===!0?Object.keys(B):i;delete E.serializers,on([E],x,B,this._stdErrSerialize)}function A(y){this._childLevel=(y._childLevel|0)+1,this.error=cr(y,E,"error"),this.fatal=cr(y,E,"fatal"),this.warn=cr(y,E,"warn"),this.info=cr(y,E,"info"),this.debug=cr(y,E,"debug"),this.trace=cr(y,E,"trace"),B&&(this.serializers=B,this._serialize=x),e&&(this._logEvent=di([].concat(y._logEvent.bindings,E)))}return A.prototype=this,new A(this)}return f}xt.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"}},xt.stdSerializers=Cd,xt.stdTimeFunctions=Object.assign({},{nullTime:Mo,epochTime:jo,unixTime:jd,isoTime:Bd});function ar(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?xr:i[r]?i[r]:Sr[r]||Sr[n]||xr,Fd(t,e,r)}function Fd(t,e,r){!t.transmit&&e[r]===xr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Sr?Sr:this;for(var f=0;f<o.length;f++)o[f]=arguments[f];if(t.serialize&&!t.asObject&&on(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(c,Ld(this,r,o,s)):n.apply(c,o),t.transmit){const h=t.transmit.level||e.level,l=xt.levels.values[h],D=xt.levels.values[r];if(D<l)return;Ud(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:h,transmitValue:xt.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function Ld(t,e,r,n){t._serialize&&on(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const o={};n&&(o.time=n),o.level=xt.levels.values[e];let c=(t._childLevel|0)+1;if(c<1&&(c=1),s!==null&&typeof s=="object"){for(;c--&&typeof i[0]=="object";)Object.assign(o,i.shift());s=i.length?$o(i.shift(),i):void 0}else typeof s=="string"&&(s=$o(i.shift(),i));return s!==void 0&&(o.msg=s),o}function on(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=xt.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(const s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function cr(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function Ud(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,o=e.methodValue,c=e.val,f=t._logEvent.bindings;on(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(h){return f.indexOf(h)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,n(s,t._logEvent,c),t._logEvent=di(f)}function di(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function $d(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 Md(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Mo:jo}function an(){return{}}function pi(t){return t}function xr(){}function Mo(){return!1}function jo(){return Date.now()}function jd(){return Math.round(Date.now()/1e3)}function Bd(){return new Date(Date.now()).toISOString()}function zd(){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)||{}}}var cn={};/*! *****************************************************************************
28
28
  Copyright (c) Microsoft Corporation.
29
29
 
30
30
  Permission to use, copy, modify, and/or distribute this software for any
@@ -37,7 +37,7 @@
37
37
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38
38
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39
39
  PERFORMANCE OF THIS SOFTWARE.
40
- ***************************************************************************** */var zi=function(t,e){return zi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},zi(t,e)};function mg(t,e){zi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Ki=function(){return Ki=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ki.apply(this,arguments)};function wg(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Eg(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Dg(t,e){return function(r,n){e(r,n,t)}}function xg(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Sg(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{f(n.next(l))}catch(D){o(D)}}function h(l){try{f(n.throw(l))}catch(D){o(D)}}function f(l){l.done?s(l.value):i(l.value).then(a,h)}f((n=n.apply(t,e||[])).next())})}function Og(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(f){return function(l){return h([f,l])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(l){f=[6,l],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function Lg(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Ig(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function qi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ia(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Ag(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ia(arguments[e]));return t}function Tg(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Br(t){return this instanceof Br?(this.v=t,this):new Br(t)}function Cg(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(b){n[b]&&(i[b]=function(m){return new Promise(function(w,N){s.push([b,m,w,N])>1||a(b,m)})})}function a(b,m){try{h(n[b](m))}catch(w){D(s[0][3],w)}}function h(b){b.value instanceof Br?Promise.resolve(b.value.v).then(f,l):D(s[0][2],b)}function f(b){a("next",b)}function l(b){a("throw",b)}function D(b,m){b(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Rg(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Br(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Pg(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 qi=="function"?qi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,h){o=t[s](o),i(a,h,o.done,o.value)})}}function i(s,o,a,h){Promise.resolve(h).then(function(f){s({value:f,done:a})},o)}}function Ng(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $g(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 Fg(t){return t&&t.__esModule?t:{default:t}}function Mg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Ug(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 jg=Object.freeze({__proto__:null,__extends:mg,get __assign(){return Ki},__rest:wg,__decorate:Eg,__param:Dg,__metadata:xg,__awaiter:Sg,__generator:Og,__createBinding:Lg,__exportStar:Ig,__values:qi,__read:Ia,__spread:Ag,__spreadArrays:Tg,__await:Br,__asyncGenerator:Cg,__asyncDelegator:Rg,__asyncValues:Pg,__makeTemplateObject:Ng,__importStar:$g,__importDefault:Fg,__classPrivateFieldGet:Mg,__classPrivateFieldSet:Ug}),Aa=Zt(jg),zr={};Object.defineProperty(zr,"__esModule",{value:!0});function Bg(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}zr.safeJsonParse=Bg;function zg(t){return typeof t=="string"?t:JSON.stringify(t,(e,r)=>typeof r>"u"?null:r)}zr.safeJsonStringify=zg;var Kr={exports:{}},Ta;function Kg(){return Ta||(Ta=1,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,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof ke<"u"&&ke.localStorage?Kr.exports=ke.localStorage:typeof window<"u"&&window.localStorage?Kr.exports=window.localStorage:Kr.exports=new e}()),Kr.exports}var Hi={},qr={},Ca;function qg(){if(Ca)return qr;Ca=1,Object.defineProperty(qr,"__esModule",{value:!0}),qr.IKeyValueStorage=void 0;class t{}return qr.IKeyValueStorage=t,qr}var Hr={},Ra;function Hg(){if(Ra)return Hr;Ra=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.parseEntry=void 0;const t=zr;function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Hr.parseEntry=e,Hr}var Pa;function Vg(){return Pa||(Pa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Aa;e.__exportStar(qg(),t),e.__exportStar(Hg(),t)}(Hi)),Hi}Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.KeyValueStorage=void 0;const _r=Aa,Na=zr,Gg=_r.__importDefault(Kg()),Wg=Vg();class $a{constructor(){this.localStorage=Gg.default}getKeys(){return _r.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return _r.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Wg.parseEntry)})}getItem(e){return _r.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Na.safeJsonParse(r)})}setItem(e,r){return _r.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Na.safeJsonStringify(r))})}removeItem(e){return _r.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}Dn.KeyValueStorage=$a;var kg=Dn.default=$a,Vr={};/*! *****************************************************************************
40
+ ***************************************************************************** */var gi=function(t,e){return gi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},gi(t,e)};function qd(t,e){gi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var yi=function(){return yi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},yi.apply(this,arguments)};function Hd(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Kd(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Vd(t,e){return function(r,n){e(r,n,t)}}function Gd(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Wd(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function kd(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Yd(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Jd(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function _i(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Bo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Xd(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Bo(arguments[e]));return t}function Zd(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Or(t){return this instanceof Or?(this.v=t,this):new Or(t)}function Qd(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Or?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function ep(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Or(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function tp(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 _i=="function"?_i(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function rp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function np(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 ip(t){return t&&t.__esModule?t:{default:t}}function sp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function op(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 ap=Object.freeze({__proto__:null,__extends:qd,get __assign(){return yi},__rest:Hd,__decorate:Kd,__param:Vd,__metadata:Gd,__awaiter:Wd,__generator:kd,__createBinding:Yd,__exportStar:Jd,__values:_i,__read:Bo,__spread:Xd,__spreadArrays:Zd,__await:Or,__asyncGenerator:Qd,__asyncDelegator:ep,__asyncValues:tp,__makeTemplateObject:rp,__importStar:np,__importDefault:ip,__classPrivateFieldGet:sp,__classPrivateFieldSet:op}),zo=Kt(ap),Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});function cp(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}Ir.safeJsonParse=cp;function up(t){return typeof t=="string"?t:JSON.stringify(t,(e,r)=>typeof r>"u"?null:r)}Ir.safeJsonStringify=up;var Ar={exports:{}},qo;function hp(){return qo||(qo=1,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,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof He<"u"&&He.localStorage?Ar.exports=He.localStorage:typeof window<"u"&&window.localStorage?Ar.exports=window.localStorage:Ar.exports=new e}()),Ar.exports}var bi={},Tr={},Ho;function fp(){if(Ho)return Tr;Ho=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.IKeyValueStorage=void 0;class t{}return Tr.IKeyValueStorage=t,Tr}var Pr={},Ko;function lp(){if(Ko)return Pr;Ko=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.parseEntry=void 0;const t=Ir;function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Pr.parseEntry=e,Pr}var Vo;function dp(){return Vo||(Vo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=zo;e.__exportStar(fp(),t),e.__exportStar(lp(),t)}(bi)),bi}Object.defineProperty(cn,"__esModule",{value:!0}),cn.KeyValueStorage=void 0;const ur=zo,Go=Ir,pp=ur.__importDefault(hp()),gp=dp();class Wo{constructor(){this.localStorage=pp.default}getKeys(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(gp.parseEntry)})}getItem(e){return ur.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Go.safeJsonParse(r)})}setItem(e,r){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Go.safeJsonStringify(r))})}removeItem(e){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}cn.KeyValueStorage=Wo;var yp=cn.default=Wo,Rr={};/*! *****************************************************************************
41
41
  Copyright (c) Microsoft Corporation.
42
42
 
43
43
  Permission to use, copy, modify, and/or distribute this software for any
@@ -50,7 +50,7 @@
50
50
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
51
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
52
  PERFORMANCE OF THIS SOFTWARE.
53
- ***************************************************************************** */var Vi=function(t,e){return Vi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Vi(t,e)};function Yg(t,e){Vi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Gi=function(){return Gi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Gi.apply(this,arguments)};function Jg(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Xg(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Zg(t,e){return function(r,n){e(r,n,t)}}function Qg(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ey(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{f(n.next(l))}catch(D){o(D)}}function h(l){try{f(n.throw(l))}catch(D){o(D)}}function f(l){l.done?s(l.value):i(l.value).then(a,h)}f((n=n.apply(t,e||[])).next())})}function ty(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(f){return function(l){return h([f,l])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(l){f=[6,l],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function ry(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function ny(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Wi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Fa(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function iy(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Fa(arguments[e]));return t}function sy(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Gr(t){return this instanceof Gr?(this.v=t,this):new Gr(t)}function oy(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(b){n[b]&&(i[b]=function(m){return new Promise(function(w,N){s.push([b,m,w,N])>1||a(b,m)})})}function a(b,m){try{h(n[b](m))}catch(w){D(s[0][3],w)}}function h(b){b.value instanceof Gr?Promise.resolve(b.value.v).then(f,l):D(s[0][2],b)}function f(b){a("next",b)}function l(b){a("throw",b)}function D(b,m){b(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ay(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Gr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function cy(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 Wi=="function"?Wi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,h){o=t[s](o),i(a,h,o.done,o.value)})}}function i(s,o,a,h){Promise.resolve(h).then(function(f){s({value:f,done:a})},o)}}function uy(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function fy(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 hy(t){return t&&t.__esModule?t:{default:t}}function ly(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function dy(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 py=Object.freeze({__proto__:null,__extends:Yg,get __assign(){return Gi},__rest:Jg,__decorate:Xg,__param:Zg,__metadata:Qg,__awaiter:ey,__generator:ty,__createBinding:ry,__exportStar:ny,__values:Wi,__read:Fa,__spread:iy,__spreadArrays:sy,__await:Gr,__asyncGenerator:oy,__asyncDelegator:ay,__asyncValues:cy,__makeTemplateObject:uy,__importStar:fy,__importDefault:hy,__classPrivateFieldGet:ly,__classPrivateFieldSet:dy}),xn=Zt(py),Wr={},ki={},kr={};class ir{}var gy=Object.freeze({__proto__:null,IEvents:ir}),yy=Zt(gy),Ma;function vy(){if(Ma)return kr;Ma=1,Object.defineProperty(kr,"__esModule",{value:!0}),kr.IHeartBeat=void 0;const t=yy;class e extends t.IEvents{constructor(n){super()}}return kr.IHeartBeat=e,kr}var Ua;function ja(){return Ua||(Ua=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),xn.__exportStar(vy(),t)}(ki)),ki}var Yi={},sr={},Ba;function _y(){if(Ba)return sr;Ba=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.HEARTBEAT_EVENTS=sr.HEARTBEAT_INTERVAL=void 0;const t=Z;return sr.HEARTBEAT_INTERVAL=t.FIVE_SECONDS,sr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},sr}var za;function Ka(){return za||(za=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),xn.__exportStar(_y(),t)}(Yi)),Yi}var qa;function by(){if(qa)return Wr;qa=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.HeartBeat=void 0;const t=xn,e=kn,r=Z,n=ja(),i=Ka();class s extends n.IHeartBeat{constructor(a){super(a),this.events=new e.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=a?.interval||i.HEARTBEAT_INTERVAL}static init(a){return t.__awaiter(this,void 0,void 0,function*(){const h=new s(a);return yield h.init(),h})}init(){return t.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}on(a,h){this.events.on(a,h)}once(a,h){this.events.once(a,h)}off(a,h){this.events.off(a,h)}removeListener(a,h){this.events.removeListener(a,h)}initialize(){return t.__awaiter(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(i.HEARTBEAT_EVENTS.pulse)}}return Wr.HeartBeat=s,Wr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=xn;e.__exportStar(by(),t),e.__exportStar(ja(),t),e.__exportStar(Ka(),t)})(Vr);var Oe={};/*! *****************************************************************************
53
+ ***************************************************************************** */var vi=function(t,e){return vi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},vi(t,e)};function _p(t,e){vi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var wi=function(){return wi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},wi.apply(this,arguments)};function bp(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function vp(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function wp(t,e){return function(r,n){e(r,n,t)}}function mp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ep(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Dp(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Sp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function xp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function mi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ko(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Op(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ko(arguments[e]));return t}function Ip(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Cr(t){return this instanceof Cr?(this.v=t,this):new Cr(t)}function Ap(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Cr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Tp(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Cr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Pp(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 mi=="function"?mi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Rp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Cp(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 Np(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 Lp(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 Up=Object.freeze({__proto__:null,__extends:_p,get __assign(){return wi},__rest:bp,__decorate:vp,__param:wp,__metadata:mp,__awaiter:Ep,__generator:Dp,__createBinding:Sp,__exportStar:xp,__values:mi,__read:ko,__spread:Op,__spreadArrays:Ip,__await:Cr,__asyncGenerator:Ap,__asyncDelegator:Tp,__asyncValues:Pp,__makeTemplateObject:Rp,__importStar:Cp,__importDefault:Np,__classPrivateFieldGet:Fp,__classPrivateFieldSet:Lp}),un=Kt(Up),Nr={},Ei={},Fr={};class Jt{}var $p=Object.freeze({__proto__:null,IEvents:Jt}),Mp=Kt($p),Yo;function jp(){if(Yo)return Fr;Yo=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.IHeartBeat=void 0;const t=Mp;class e extends t.IEvents{constructor(n){super()}}return Fr.IHeartBeat=e,Fr}var Jo;function Xo(){return Jo||(Jo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),un.__exportStar(jp(),t)}(Ei)),Ei}var Di={},Xt={},Zo;function Bp(){if(Zo)return Xt;Zo=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.HEARTBEAT_EVENTS=Xt.HEARTBEAT_INTERVAL=void 0;const t=Z;return Xt.HEARTBEAT_INTERVAL=t.FIVE_SECONDS,Xt.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Xt}var Qo;function ea(){return Qo||(Qo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),un.__exportStar(Bp(),t)}(Di)),Di}var ta;function zp(){if(ta)return Nr;ta=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.HeartBeat=void 0;const t=un,e=Ze.exports,r=Z,n=Xo(),i=ea();class s extends n.IHeartBeat{constructor(c){super(c),this.events=new e.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=c?.interval||i.HEARTBEAT_INTERVAL}static init(c){return t.__awaiter(this,void 0,void 0,function*(){const f=new s(c);return yield f.init(),f})}init(){return t.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(c,f){this.events.on(c,f)}once(c,f){this.events.once(c,f)}off(c,f){this.events.off(c,f)}removeListener(c,f){this.events.removeListener(c,f)}initialize(){return t.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(i.HEARTBEAT_EVENTS.pulse)}}return Nr.HeartBeat=s,Nr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=un;e.__exportStar(zp(),t),e.__exportStar(Xo(),t),e.__exportStar(ea(),t)})(Rr);var xe={};/*! *****************************************************************************
54
54
  Copyright (c) Microsoft Corporation.
55
55
 
56
56
  Permission to use, copy, modify, and/or distribute this software for any
@@ -63,5 +63,5 @@
63
63
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
64
64
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65
65
  PERFORMANCE OF THIS SOFTWARE.
66
- ***************************************************************************** */var Ji=function(t,e){return Ji=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Ji(t,e)};function my(t,e){Ji(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Xi=function(){return Xi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Xi.apply(this,arguments)};function wy(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Ey(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Dy(t,e){return function(r,n){e(r,n,t)}}function xy(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Sy(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{f(n.next(l))}catch(D){o(D)}}function h(l){try{f(n.throw(l))}catch(D){o(D)}}function f(l){l.done?s(l.value):i(l.value).then(a,h)}f((n=n.apply(t,e||[])).next())})}function Oy(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(f){return function(l){return h([f,l])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(l){f=[6,l],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function Ly(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Iy(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ha(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Ay(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ha(arguments[e]));return t}function Ty(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Yr(t){return this instanceof Yr?(this.v=t,this):new Yr(t)}function Cy(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(b){n[b]&&(i[b]=function(m){return new Promise(function(w,N){s.push([b,m,w,N])>1||a(b,m)})})}function a(b,m){try{h(n[b](m))}catch(w){D(s[0][3],w)}}function h(b){b.value instanceof Yr?Promise.resolve(b.value.v).then(f,l):D(s[0][2],b)}function f(b){a("next",b)}function l(b){a("throw",b)}function D(b,m){b(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Ry(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Yr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Py(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 Zi=="function"?Zi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,h){o=t[s](o),i(a,h,o.done,o.value)})}}function i(s,o,a,h){Promise.resolve(h).then(function(f){s({value:f,done:a})},o)}}function Ny(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $y(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 Fy(t){return t&&t.__esModule?t:{default:t}}function My(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Uy(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 jy=Object.freeze({__proto__:null,__extends:my,get __assign(){return Xi},__rest:wy,__decorate:Ey,__param:Dy,__metadata:xy,__awaiter:Sy,__generator:Oy,__createBinding:Ly,__exportStar:Iy,__values:Zi,__read:Ha,__spread:Ay,__spreadArrays:Ty,__await:Yr,__asyncGenerator:Cy,__asyncDelegator:Ry,__asyncValues:Py,__makeTemplateObject:Ny,__importStar:$y,__importDefault:Fy,__classPrivateFieldGet:My,__classPrivateFieldSet:Uy}),By=Zt(jy),or={},Va;function Ga(){return Va||(Va=1,Object.defineProperty(or,"__esModule",{value:!0}),or.PINO_CUSTOM_CONTEXT_KEY=or.PINO_LOGGER_DEFAULTS=void 0,or.PINO_LOGGER_DEFAULTS={level:"info"},or.PINO_CUSTOM_CONTEXT_KEY="custom_context"),or}var ft={},Wa;function zy(){if(Wa)return ft;Wa=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.generateChildLogger=ft.formatChildLoggerContext=ft.getLoggerContext=ft.setBrowserLoggerContext=ft.getBrowserLoggerContext=ft.getDefaultLoggerOptions=void 0;const t=Ga();function e(a){return Object.assign(Object.assign({},a),{level:a?.level||t.PINO_LOGGER_DEFAULTS.level})}ft.getDefaultLoggerOptions=e;function r(a,h=t.PINO_CUSTOM_CONTEXT_KEY){return a[h]||""}ft.getBrowserLoggerContext=r;function n(a,h,f=t.PINO_CUSTOM_CONTEXT_KEY){return a[f]=h,a}ft.setBrowserLoggerContext=n;function i(a,h=t.PINO_CUSTOM_CONTEXT_KEY){let f="";return typeof a.bindings>"u"?f=r(a,h):f=a.bindings().context||"",f}ft.getLoggerContext=i;function s(a,h,f=t.PINO_CUSTOM_CONTEXT_KEY){const l=i(a,f);return l.trim()?`${l}/${h}`:h}ft.formatChildLoggerContext=s;function o(a,h,f=t.PINO_CUSTOM_CONTEXT_KEY){const l=s(a,h,f),D=a.child({context:l});return n(D,l,f)}return ft.generateChildLogger=o,ft}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const e=By,r=e.__importDefault(_n);Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(Ga(),t),e.__exportStar(zy(),t)})(Oe);var ka={exports:{}},br=typeof Reflect=="object"?Reflect:null,Ya=br&&typeof br.apply=="function"?br.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Sn;br&&typeof br.ownKeys=="function"?Sn=br.ownKeys:Object.getOwnPropertySymbols?Sn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Sn=function(e){return Object.getOwnPropertyNames(e)};function Ky(t){console&&console.warn&&console.warn(t)}var Ja=Number.isNaN||function(e){return e!==e};function Le(){Le.init.call(this)}ka.exports=Le,ka.exports.once=Gy,Le.EventEmitter=Le,Le.prototype._events=void 0,Le.prototype._eventsCount=0,Le.prototype._maxListeners=void 0;var Xa=10;function On(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return Xa},set:function(t){if(typeof t!="number"||t<0||Ja(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Xa=t}}),Le.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},Le.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ja(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 Za(t){return t._maxListeners===void 0?Le.defaultMaxListeners:t._maxListeners}Le.prototype.getMaxListeners=function(){return Za(this)},Le.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")Ya(h,this,r);else for(var f=h.length,l=nc(h,f),n=0;n<f;++n)Ya(l[n],this,r);return!0};function Qa(t,e,r,n){var i,s,o;if(On(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=Za(t),i>0&&o.length>i&&!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,Ky(a)}return t}Le.prototype.addListener=function(e,r){return Qa(this,e,r,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(e,r){return Qa(this,e,r,!0)};function qy(){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 ec(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=qy.bind(n);return i.listener=r,n.wrapFn=i,i}Le.prototype.once=function(e,r){return On(r),this.on(e,ec(this,e,r)),this},Le.prototype.prependOnceListener=function(e,r){return On(r),this.prependListener(e,ec(this,e,r)),this},Le.prototype.removeListener=function(e,r){var n,i,s,o,a;if(On(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():Hy(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function tc(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?Vy(i):nc(i,i.length)}Le.prototype.listeners=function(e){return tc(this,e,!0)},Le.prototype.rawListeners=function(e){return tc(this,e,!1)},Le.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):rc.call(t,e)},Le.prototype.listenerCount=rc;function rc(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}Le.prototype.eventNames=function(){return this._eventsCount>0?Sn(this._events):[]};function nc(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Hy(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Vy(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Gy(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}ic(t,e,s,{once:!0}),e!=="error"&&Wy(t,i,{once:!0})})}function Wy(t,e,r){typeof t.on=="function"&&ic(t,"error",e,r)}function ic(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class ky extends ir{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Yy extends ir{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class Jy{constructor(e,r){this.logger=e,this.core=r}}class Xy extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Zy extends ir{constructor(e){super()}}class Qy{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class ev extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class tv extends ir{constructor(e,r){super(),this.core=e,this.logger=r}}class rv{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class nv{constructor(e){this.client=e}}var Qi={},sc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=_t;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function a(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return a.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},a.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},a.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},a.prototype.update=function(h,f){if(f===void 0&&(f=h.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var l=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=h[l++],f--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(l=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,l,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=h[l++],f--;return this},a.prototype.finish=function(h){if(!this._finished){var f=this._bytesHashed,l=this._bufferLength,D=f/536870912|0,b=f<<3,m=f%128<112?128:256;this._buffer[l]=128;for(var w=l+1;w<m-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(b,this._buffer,m-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,m),this._finished=!0}for(var w=0;w<this.digestLength/8;w++)e.writeUint32BE(this._stateHi[w],h,w*8),e.writeUint32BE(this._stateLo[w],h,w*8+4);return this},a.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},a.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(h){return this._stateHi.set(h.stateHi),this._stateLo.set(h.stateLo),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},a}();t.SHA512=n;var i=new Int32Array([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 s(a,h,f,l,D,b,m){for(var w=f[0],N=f[1],R=f[2],B=f[3],S=f[4],I=f[5],y=f[6],x=f[7],E=l[0],c=l[1],d=l[2],U=l[3],K=l[4],G=l[5],J=l[6],X=l[7],g,v,F,M,P,C,j,z;m>=128;){for(var Q=0;Q<16;Q++){var q=8*Q+b;a[Q]=e.readUint32BE(D,q),h[Q]=e.readUint32BE(D,q+4)}for(var Q=0;Q<80;Q++){var ee=w,Y=N,ae=R,T=B,A=S,O=I,u=y,_=x,H=E,W=c,he=d,ve=U,de=K,me=G,Be=J,$e=X;if(g=x,v=X,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=(S>>>14|K<<32-14)^(S>>>18|K<<32-18)^(K>>>41-32|S<<32-(41-32)),v=(K>>>14|S<<32-14)^(K>>>18|S<<32-18)^(S>>>41-32|K<<32-(41-32)),P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,g=S&I^~S&y,v=K&G^~K&J,P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,g=i[Q*2],v=i[Q*2+1],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,g=a[Q%16],v=h[Q%16],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,F=j&65535|z<<16,M=P&65535|C<<16,g=F,v=M,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=(w>>>28|E<<32-28)^(E>>>34-32|w<<32-(34-32))^(E>>>39-32|w<<32-(39-32)),v=(E>>>28|w<<32-28)^(w>>>34-32|E<<32-(34-32))^(w>>>39-32|E<<32-(39-32)),P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,g=w&N^w&R^N&R,v=E&c^E&d^c&d,P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,_=j&65535|z<<16,$e=P&65535|C<<16,g=T,v=ve,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=F,v=M,P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,T=j&65535|z<<16,ve=P&65535|C<<16,N=ee,R=Y,B=ae,S=T,I=A,y=O,x=u,w=_,c=H,d=W,U=he,K=ve,G=de,J=me,X=Be,E=$e,Q%16===15)for(var q=0;q<16;q++)g=a[q],v=h[q],P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=a[(q+9)%16],v=h[(q+9)%16],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,F=a[(q+1)%16],M=h[(q+1)%16],g=(F>>>1|M<<32-1)^(F>>>8|M<<32-8)^F>>>7,v=(M>>>1|F<<32-1)^(M>>>8|F<<32-8)^(M>>>7|F<<32-7),P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,F=a[(q+14)%16],M=h[(q+14)%16],g=(F>>>19|M<<32-19)^(M>>>61-32|F<<32-(61-32))^F>>>6,v=(M>>>19|F<<32-19)^(F>>>61-32|M<<32-(61-32))^(M>>>6|F<<32-6),P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,a[q]=j&65535|z<<16,h[q]=P&65535|C<<16}g=w,v=E,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[0],v=l[0],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[0]=w=j&65535|z<<16,l[0]=E=P&65535|C<<16,g=N,v=c,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[1],v=l[1],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[1]=N=j&65535|z<<16,l[1]=c=P&65535|C<<16,g=R,v=d,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[2],v=l[2],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[2]=R=j&65535|z<<16,l[2]=d=P&65535|C<<16,g=B,v=U,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[3],v=l[3],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[3]=B=j&65535|z<<16,l[3]=U=P&65535|C<<16,g=S,v=K,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[4],v=l[4],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[4]=S=j&65535|z<<16,l[4]=K=P&65535|C<<16,g=I,v=G,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[5],v=l[5],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[5]=I=j&65535|z<<16,l[5]=G=P&65535|C<<16,g=y,v=J,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[6],v=l[6],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[6]=y=j&65535|z<<16,l[6]=J=P&65535|C<<16,g=x,v=X,P=v&65535,C=v>>>16,j=g&65535,z=g>>>16,g=f[7],v=l[7],P+=v&65535,C+=v>>>16,j+=g&65535,z+=g>>>16,C+=P>>>16,j+=C>>>16,z+=j>>>16,f[7]=x=j&65535|z<<16,l[7]=X=P&65535|C<<16,b+=128,m-=128}return b}function o(a){var h=new n;h.update(a);var f=h.digest();return h.clean(),f}t.hash=o})(sc),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=lr,r=sc,n=_t;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(T){const A=new Float64Array(16);if(T)for(let O=0;O<T.length;O++)A[O]=T[O];return A}const s=new Uint8Array(32);s[0]=9;const o=i(),a=i([1]),h=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),b=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(T,A){for(let O=0;O<16;O++)T[O]=A[O]|0}function w(T){let A=1;for(let O=0;O<16;O++){let u=T[O]+A+65535;A=Math.floor(u/65536),T[O]=u-A*65536}T[0]+=A-1+37*(A-1)}function N(T,A,O){const u=~(O-1);for(let _=0;_<16;_++){const H=u&(T[_]^A[_]);T[_]^=H,A[_]^=H}}function R(T,A){const O=i(),u=i();for(let _=0;_<16;_++)u[_]=A[_];w(u),w(u),w(u);for(let _=0;_<2;_++){O[0]=u[0]-65517;for(let W=1;W<15;W++)O[W]=u[W]-65535-(O[W-1]>>16&1),O[W-1]&=65535;O[15]=u[15]-32767-(O[14]>>16&1);const H=O[15]>>16&1;O[14]&=65535,N(u,O,1-H)}for(let _=0;_<16;_++)T[2*_]=u[_]&255,T[2*_+1]=u[_]>>8}function B(T,A){let O=0;for(let u=0;u<32;u++)O|=T[u]^A[u];return(1&O-1>>>8)-1}function S(T,A){const O=new Uint8Array(32),u=new Uint8Array(32);return R(O,T),R(u,A),B(O,u)}function I(T){const A=new Uint8Array(32);return R(A,T),A[0]&1}function y(T,A){for(let O=0;O<16;O++)T[O]=A[2*O]+(A[2*O+1]<<8);T[15]&=32767}function x(T,A,O){for(let u=0;u<16;u++)T[u]=A[u]+O[u]}function E(T,A,O){for(let u=0;u<16;u++)T[u]=A[u]-O[u]}function c(T,A,O){let u,_,H=0,W=0,he=0,ve=0,de=0,me=0,Be=0,$e=0,ye=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,fe=0,ge=0,ne=0,_e=0,be=0,Ee=0,De=0,we=0,Lt=0,$t=0,kt=0,mt=0,ar=0,Qr=0,Bn=0,ze=O[0],Fe=O[1],Ke=O[2],qe=O[3],He=O[4],Me=O[5],Je=O[6],Xe=O[7],Ze=O[8],Qe=O[9],et=O[10],We=O[11],Ve=O[12],Pe=O[13],tt=O[14],rt=O[15];u=A[0],H+=u*ze,W+=u*Fe,he+=u*Ke,ve+=u*qe,de+=u*He,me+=u*Me,Be+=u*Je,$e+=u*Xe,ye+=u*Ze,pe+=u*Qe,le+=u*et,ue+=u*We,ce+=u*Ve,oe+=u*Pe,se+=u*tt,te+=u*rt,u=A[1],W+=u*ze,he+=u*Fe,ve+=u*Ke,de+=u*qe,me+=u*He,Be+=u*Me,$e+=u*Je,ye+=u*Xe,pe+=u*Ze,le+=u*Qe,ue+=u*et,ce+=u*We,oe+=u*Ve,se+=u*Pe,te+=u*tt,fe+=u*rt,u=A[2],he+=u*ze,ve+=u*Fe,de+=u*Ke,me+=u*qe,Be+=u*He,$e+=u*Me,ye+=u*Je,pe+=u*Xe,le+=u*Ze,ue+=u*Qe,ce+=u*et,oe+=u*We,se+=u*Ve,te+=u*Pe,fe+=u*tt,ge+=u*rt,u=A[3],ve+=u*ze,de+=u*Fe,me+=u*Ke,Be+=u*qe,$e+=u*He,ye+=u*Me,pe+=u*Je,le+=u*Xe,ue+=u*Ze,ce+=u*Qe,oe+=u*et,se+=u*We,te+=u*Ve,fe+=u*Pe,ge+=u*tt,ne+=u*rt,u=A[4],de+=u*ze,me+=u*Fe,Be+=u*Ke,$e+=u*qe,ye+=u*He,pe+=u*Me,le+=u*Je,ue+=u*Xe,ce+=u*Ze,oe+=u*Qe,se+=u*et,te+=u*We,fe+=u*Ve,ge+=u*Pe,ne+=u*tt,_e+=u*rt,u=A[5],me+=u*ze,Be+=u*Fe,$e+=u*Ke,ye+=u*qe,pe+=u*He,le+=u*Me,ue+=u*Je,ce+=u*Xe,oe+=u*Ze,se+=u*Qe,te+=u*et,fe+=u*We,ge+=u*Ve,ne+=u*Pe,_e+=u*tt,be+=u*rt,u=A[6],Be+=u*ze,$e+=u*Fe,ye+=u*Ke,pe+=u*qe,le+=u*He,ue+=u*Me,ce+=u*Je,oe+=u*Xe,se+=u*Ze,te+=u*Qe,fe+=u*et,ge+=u*We,ne+=u*Ve,_e+=u*Pe,be+=u*tt,Ee+=u*rt,u=A[7],$e+=u*ze,ye+=u*Fe,pe+=u*Ke,le+=u*qe,ue+=u*He,ce+=u*Me,oe+=u*Je,se+=u*Xe,te+=u*Ze,fe+=u*Qe,ge+=u*et,ne+=u*We,_e+=u*Ve,be+=u*Pe,Ee+=u*tt,De+=u*rt,u=A[8],ye+=u*ze,pe+=u*Fe,le+=u*Ke,ue+=u*qe,ce+=u*He,oe+=u*Me,se+=u*Je,te+=u*Xe,fe+=u*Ze,ge+=u*Qe,ne+=u*et,_e+=u*We,be+=u*Ve,Ee+=u*Pe,De+=u*tt,we+=u*rt,u=A[9],pe+=u*ze,le+=u*Fe,ue+=u*Ke,ce+=u*qe,oe+=u*He,se+=u*Me,te+=u*Je,fe+=u*Xe,ge+=u*Ze,ne+=u*Qe,_e+=u*et,be+=u*We,Ee+=u*Ve,De+=u*Pe,we+=u*tt,Lt+=u*rt,u=A[10],le+=u*ze,ue+=u*Fe,ce+=u*Ke,oe+=u*qe,se+=u*He,te+=u*Me,fe+=u*Je,ge+=u*Xe,ne+=u*Ze,_e+=u*Qe,be+=u*et,Ee+=u*We,De+=u*Ve,we+=u*Pe,Lt+=u*tt,$t+=u*rt,u=A[11],ue+=u*ze,ce+=u*Fe,oe+=u*Ke,se+=u*qe,te+=u*He,fe+=u*Me,ge+=u*Je,ne+=u*Xe,_e+=u*Ze,be+=u*Qe,Ee+=u*et,De+=u*We,we+=u*Ve,Lt+=u*Pe,$t+=u*tt,kt+=u*rt,u=A[12],ce+=u*ze,oe+=u*Fe,se+=u*Ke,te+=u*qe,fe+=u*He,ge+=u*Me,ne+=u*Je,_e+=u*Xe,be+=u*Ze,Ee+=u*Qe,De+=u*et,we+=u*We,Lt+=u*Ve,$t+=u*Pe,kt+=u*tt,mt+=u*rt,u=A[13],oe+=u*ze,se+=u*Fe,te+=u*Ke,fe+=u*qe,ge+=u*He,ne+=u*Me,_e+=u*Je,be+=u*Xe,Ee+=u*Ze,De+=u*Qe,we+=u*et,Lt+=u*We,$t+=u*Ve,kt+=u*Pe,mt+=u*tt,ar+=u*rt,u=A[14],se+=u*ze,te+=u*Fe,fe+=u*Ke,ge+=u*qe,ne+=u*He,_e+=u*Me,be+=u*Je,Ee+=u*Xe,De+=u*Ze,we+=u*Qe,Lt+=u*et,$t+=u*We,kt+=u*Ve,mt+=u*Pe,ar+=u*tt,Qr+=u*rt,u=A[15],te+=u*ze,fe+=u*Fe,ge+=u*Ke,ne+=u*qe,_e+=u*He,be+=u*Me,Ee+=u*Je,De+=u*Xe,we+=u*Ze,Lt+=u*Qe,$t+=u*et,kt+=u*We,mt+=u*Ve,ar+=u*Pe,Qr+=u*tt,Bn+=u*rt,H+=38*fe,W+=38*ge,he+=38*ne,ve+=38*_e,de+=38*be,me+=38*Ee,Be+=38*De,$e+=38*we,ye+=38*Lt,pe+=38*$t,le+=38*kt,ue+=38*mt,ce+=38*ar,oe+=38*Qr,se+=38*Bn,_=1,u=H+_+65535,_=Math.floor(u/65536),H=u-_*65536,u=W+_+65535,_=Math.floor(u/65536),W=u-_*65536,u=he+_+65535,_=Math.floor(u/65536),he=u-_*65536,u=ve+_+65535,_=Math.floor(u/65536),ve=u-_*65536,u=de+_+65535,_=Math.floor(u/65536),de=u-_*65536,u=me+_+65535,_=Math.floor(u/65536),me=u-_*65536,u=Be+_+65535,_=Math.floor(u/65536),Be=u-_*65536,u=$e+_+65535,_=Math.floor(u/65536),$e=u-_*65536,u=ye+_+65535,_=Math.floor(u/65536),ye=u-_*65536,u=pe+_+65535,_=Math.floor(u/65536),pe=u-_*65536,u=le+_+65535,_=Math.floor(u/65536),le=u-_*65536,u=ue+_+65535,_=Math.floor(u/65536),ue=u-_*65536,u=ce+_+65535,_=Math.floor(u/65536),ce=u-_*65536,u=oe+_+65535,_=Math.floor(u/65536),oe=u-_*65536,u=se+_+65535,_=Math.floor(u/65536),se=u-_*65536,u=te+_+65535,_=Math.floor(u/65536),te=u-_*65536,H+=_-1+37*(_-1),_=1,u=H+_+65535,_=Math.floor(u/65536),H=u-_*65536,u=W+_+65535,_=Math.floor(u/65536),W=u-_*65536,u=he+_+65535,_=Math.floor(u/65536),he=u-_*65536,u=ve+_+65535,_=Math.floor(u/65536),ve=u-_*65536,u=de+_+65535,_=Math.floor(u/65536),de=u-_*65536,u=me+_+65535,_=Math.floor(u/65536),me=u-_*65536,u=Be+_+65535,_=Math.floor(u/65536),Be=u-_*65536,u=$e+_+65535,_=Math.floor(u/65536),$e=u-_*65536,u=ye+_+65535,_=Math.floor(u/65536),ye=u-_*65536,u=pe+_+65535,_=Math.floor(u/65536),pe=u-_*65536,u=le+_+65535,_=Math.floor(u/65536),le=u-_*65536,u=ue+_+65535,_=Math.floor(u/65536),ue=u-_*65536,u=ce+_+65535,_=Math.floor(u/65536),ce=u-_*65536,u=oe+_+65535,_=Math.floor(u/65536),oe=u-_*65536,u=se+_+65535,_=Math.floor(u/65536),se=u-_*65536,u=te+_+65535,_=Math.floor(u/65536),te=u-_*65536,H+=_-1+37*(_-1),T[0]=H,T[1]=W,T[2]=he,T[3]=ve,T[4]=de,T[5]=me,T[6]=Be,T[7]=$e,T[8]=ye,T[9]=pe,T[10]=le,T[11]=ue,T[12]=ce,T[13]=oe,T[14]=se,T[15]=te}function d(T,A){c(T,A,A)}function U(T,A){const O=i();let u;for(u=0;u<16;u++)O[u]=A[u];for(u=253;u>=0;u--)d(O,O),u!==2&&u!==4&&c(O,O,A);for(u=0;u<16;u++)T[u]=O[u]}function K(T,A){const O=i();let u;for(u=0;u<16;u++)O[u]=A[u];for(u=250;u>=0;u--)d(O,O),u!==1&&c(O,O,A);for(u=0;u<16;u++)T[u]=O[u]}function G(T,A){const O=i(),u=i(),_=i(),H=i(),W=i(),he=i(),ve=i(),de=i(),me=i();E(O,T[1],T[0]),E(me,A[1],A[0]),c(O,O,me),x(u,T[0],T[1]),x(me,A[0],A[1]),c(u,u,me),c(_,T[3],A[3]),c(_,_,f),c(H,T[2],A[2]),x(H,H,H),E(W,u,O),E(he,H,_),x(ve,H,_),x(de,u,O),c(T[0],W,he),c(T[1],de,ve),c(T[2],ve,he),c(T[3],W,de)}function J(T,A,O){for(let u=0;u<4;u++)N(T[u],A[u],O)}function X(T,A){const O=i(),u=i(),_=i();U(_,A[2]),c(O,A[0],_),c(u,A[1],_),R(T,u),T[31]^=I(O)<<7}function g(T,A,O){m(T[0],o),m(T[1],a),m(T[2],a),m(T[3],o);for(let u=255;u>=0;--u){const _=O[u/8|0]>>(u&7)&1;J(T,A,_),G(A,T),G(T,T),J(T,A,_)}}function v(T,A){const O=[i(),i(),i(),i()];m(O[0],l),m(O[1],D),m(O[2],a),c(O[3],l,D),g(T,O,A)}function F(T){if(T.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const A=(0,r.hash)(T);A[0]&=248,A[31]&=127,A[31]|=64;const O=new Uint8Array(32),u=[i(),i(),i(),i()];v(u,A),X(O,u);const _=new Uint8Array(64);return _.set(T),_.set(O,32),{publicKey:O,secretKey:_}}t.generateKeyPairFromSeed=F;function M(T){const A=(0,e.randomBytes)(32,T),O=F(A);return(0,n.wipe)(A),O}t.generateKeyPair=M;function P(T){if(T.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(T.subarray(32))}t.extractPublicKeyFromSecretKey=P;const C=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(T,A){let O,u,_,H;for(u=63;u>=32;--u){for(O=0,_=u-32,H=u-12;_<H;++_)A[_]+=O-16*A[u]*C[_-(u-32)],O=Math.floor((A[_]+128)/256),A[_]-=O*256;A[_]+=O,A[u]=0}for(O=0,_=0;_<32;_++)A[_]+=O-(A[31]>>4)*C[_],O=A[_]>>8,A[_]&=255;for(_=0;_<32;_++)A[_]-=O*C[_];for(u=0;u<32;u++)A[u+1]+=A[u]>>8,T[u]=A[u]&255}function z(T){const A=new Float64Array(64);for(let O=0;O<64;O++)A[O]=T[O];for(let O=0;O<64;O++)T[O]=0;j(T,A)}function Q(T,A){const O=new Float64Array(64),u=[i(),i(),i(),i()],_=(0,r.hash)(T.subarray(0,32));_[0]&=248,_[31]&=127,_[31]|=64;const H=new Uint8Array(64);H.set(_.subarray(32),32);const W=new r.SHA512;W.update(H.subarray(32)),W.update(A);const he=W.digest();W.clean(),z(he),v(u,he),X(H,u),W.reset(),W.update(H.subarray(0,32)),W.update(T.subarray(32)),W.update(A);const ve=W.digest();z(ve);for(let de=0;de<32;de++)O[de]=he[de];for(let de=0;de<32;de++)for(let me=0;me<32;me++)O[de+me]+=ve[de]*_[me];return j(H.subarray(32),O),H}t.sign=Q;function q(T,A){const O=i(),u=i(),_=i(),H=i(),W=i(),he=i(),ve=i();return m(T[2],a),y(T[1],A),d(_,T[1]),c(H,_,h),E(_,_,T[2]),x(H,T[2],H),d(W,H),d(he,W),c(ve,he,W),c(O,ve,_),c(O,O,H),K(O,O),c(O,O,_),c(O,O,H),c(O,O,H),c(T[0],O,H),d(u,T[0]),c(u,u,H),S(u,_)&&c(T[0],T[0],b),d(u,T[0]),c(u,u,H),S(u,_)?-1:(I(T[0])===A[31]>>7&&E(T[0],o,T[0]),c(T[3],T[0],T[1]),0)}function ee(T,A,O){const u=new Uint8Array(32),_=[i(),i(),i(),i()],H=[i(),i(),i(),i()];if(O.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(q(H,T))return!1;const W=new r.SHA512;W.update(O.subarray(0,32)),W.update(T),W.update(A);const he=W.digest();return z(he),g(_,H,he),v(H,O.subarray(32)),G(_,H),X(u,_),!B(O,u)}t.verify=ee;function Y(T){let A=[i(),i(),i(),i()];if(q(A,T))throw new Error("Ed25519: invalid public key");let O=i(),u=i(),_=A[1];x(O,a,_),E(u,a,_),U(u,u),c(O,O,u);let H=new Uint8Array(32);return R(H,O),H}t.convertPublicKeyToX25519=Y;function ae(T){const A=(0,r.hash)(T.subarray(0,32));A[0]&=248,A[31]&=127,A[31]|=64;const O=new Uint8Array(A.subarray(0,32));return(0,n.wipe)(A),O}t.convertSecretKeyToX25519=ae}(Qi);const iv="EdDSA",sv="JWT",oc=".",ac="base64url",ov="utf8",av="utf8",cv=":",uv="did",fv="key",cc="base58btc",hv="z",lv="K36",dv=32;function Ln(t){return dt(lt(Ir(t),ov),ac)}function uc(t){const e=lt(lv,cc),r=hv+dt(li([e,t]),cc);return[uv,fv,r].join(cv)}function pv(t){return dt(t,ac)}function gv(t){return lt([Ln(t.header),Ln(t.payload)].join(oc),av)}function yv(t){return[Ln(t.header),Ln(t.payload),pv(t.signature)].join(oc)}function fc(t=lr.randomBytes(dv)){return Qi.generateKeyPairFromSeed(t)}async function vv(t,e,r,n,i=Z.fromMiliseconds(Date.now())){const s={alg:iv,typ:sv},o=uc(n.publicKey),a=i+r,h={iss:o,sub:t,aud:e,iat:i,exp:a},f=gv({header:s,payload:h}),l=Qi.sign(n.secretKey,f);return yv({header:s,payload:h,signature:l})}var es={exports:{}},mr=typeof Reflect=="object"?Reflect:null,hc=mr&&typeof mr.apply=="function"?mr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},In;mr&&typeof mr.ownKeys=="function"?In=mr.ownKeys:Object.getOwnPropertySymbols?In=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:In=function(e){return Object.getOwnPropertyNames(e)};function _v(t){console&&console.warn&&console.warn(t)}var lc=Number.isNaN||function(e){return e!==e};function Ie(){Ie.init.call(this)}es.exports=Ie,es.exports.once=Ev,Ie.EventEmitter=Ie,Ie.prototype._events=void 0,Ie.prototype._eventsCount=0,Ie.prototype._maxListeners=void 0;var dc=10;function An(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ie,"defaultMaxListeners",{enumerable:!0,get:function(){return dc},set:function(t){if(typeof t!="number"||t<0||lc(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");dc=t}}),Ie.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ie.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||lc(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 pc(t){return t._maxListeners===void 0?Ie.defaultMaxListeners:t._maxListeners}Ie.prototype.getMaxListeners=function(){return pc(this)},Ie.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")hc(h,this,r);else for(var f=h.length,l=bc(h,f),n=0;n<f;++n)hc(l[n],this,r);return!0};function gc(t,e,r,n){var i,s,o;if(An(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=pc(t),i>0&&o.length>i&&!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,_v(a)}return t}Ie.prototype.addListener=function(e,r){return gc(this,e,r,!1)},Ie.prototype.on=Ie.prototype.addListener,Ie.prototype.prependListener=function(e,r){return gc(this,e,r,!0)};function bv(){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 yc(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=bv.bind(n);return i.listener=r,n.wrapFn=i,i}Ie.prototype.once=function(e,r){return An(r),this.on(e,yc(this,e,r)),this},Ie.prototype.prependOnceListener=function(e,r){return An(r),this.prependListener(e,yc(this,e,r)),this},Ie.prototype.removeListener=function(e,r){var n,i,s,o,a;if(An(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():mv(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Ie.prototype.off=Ie.prototype.removeListener,Ie.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function vc(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?wv(i):bc(i,i.length)}Ie.prototype.listeners=function(e){return vc(this,e,!0)},Ie.prototype.rawListeners=function(e){return vc(this,e,!1)},Ie.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):_c.call(t,e)},Ie.prototype.listenerCount=_c;function _c(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ie.prototype.eventNames=function(){return this._eventsCount>0?In(this._events):[]};function bc(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function mv(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function wv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ev(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}mc(t,e,s,{once:!0}),e!=="error"&&Dv(t,i,{once:!0})})}function Dv(t,e,r){typeof t.on=="function"&&mc(t,"error",e,r)}function mc(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const wc=10,xv=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),Sv=()=>typeof window<"u",Ov=xv();class Lv{constructor(e){if(this.url=e,this.events=new es.exports.EventEmitter,this.registering=!1,!Ms(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(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ir(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!Ms(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((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=Ts.isReactNative()?void 0:{rejectUnauthorized:!Tf(e)},s=new Ov(e,[],i);Sv()?s.onerror=o=>{const a=o;n(this.emitError(a.error))}:s.on("error",o=>{n(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?ni(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Lr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return As(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>wc&&this.events.setMaxListeners(wc)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for URL: ${this.url}`));return this.events.emit("register_error",r),r}}var ts={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",h="[object Array]",f="[object AsyncFunction]",l="[object Boolean]",D="[object Date]",b="[object Error]",m="[object Function]",w="[object GeneratorFunction]",N="[object Map]",R="[object Number]",B="[object Null]",S="[object Object]",I="[object Promise]",y="[object Proxy]",x="[object RegExp]",E="[object Set]",c="[object String]",d="[object Symbol]",U="[object Undefined]",K="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",g="[object Float64Array]",v="[object Int8Array]",F="[object Int16Array]",M="[object Int32Array]",P="[object Uint8Array]",C="[object Uint8ClampedArray]",j="[object Uint16Array]",z="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,q=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[g]=Y[v]=Y[F]=Y[M]=Y[P]=Y[C]=Y[j]=Y[z]=!0,Y[a]=Y[h]=Y[G]=Y[l]=Y[J]=Y[D]=Y[b]=Y[m]=Y[N]=Y[R]=Y[S]=Y[x]=Y[E]=Y[c]=Y[K]=!1;var ae=typeof ke=="object"&&ke&&ke.Object===Object&&ke,T=typeof self=="object"&&self&&self.Object===Object&&self,A=ae||T||Function("return this")(),O=e&&!e.nodeType&&e,u=O&&!0&&t&&!t.nodeType&&t,_=u&&u.exports===O,H=_&&ae.process,W=function(){try{return H&&H.binding&&H.binding("util")}catch{}}(),he=W&&W.isTypedArray;function ve(p,L){for(var $=-1,k=p==null?0:p.length,Re=0,ie=[];++$<k;){var Ue=p[$];L(Ue,$,p)&&(ie[Re++]=Ue)}return ie}function de(p,L){for(var $=-1,k=L.length,Re=p.length;++$<k;)p[Re+$]=L[$];return p}function me(p,L){for(var $=-1,k=p==null?0:p.length;++$<k;)if(L(p[$],$,p))return!0;return!1}function Be(p,L){for(var $=-1,k=Array(p);++$<p;)k[$]=L($);return k}function $e(p){return function(L){return p(L)}}function ye(p,L){return p.has(L)}function pe(p,L){return p?.[L]}function le(p){var L=-1,$=Array(p.size);return p.forEach(function(k,Re){$[++L]=[Re,k]}),$}function ue(p,L){return function($){return p(L($))}}function ce(p){var L=-1,$=Array(p.size);return p.forEach(function(k){$[++L]=k}),$}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,fe=A["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,_e=function(){var p=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=_?A.Buffer:void 0,we=A.Symbol,Lt=A.Uint8Array,$t=te.propertyIsEnumerable,kt=oe.splice,mt=we?we.toStringTag:void 0,ar=Object.getOwnPropertySymbols,Qr=De?De.isBuffer:void 0,Bn=ue(Object.keys,Object),ze=Dr(A,"DataView"),Fe=Dr(A,"Map"),Ke=Dr(A,"Promise"),qe=Dr(A,"Set"),He=Dr(A,"WeakMap"),Me=Dr(Object,"create"),Je=ur(ze),Xe=ur(Fe),Ze=ur(Ke),Qe=ur(qe),et=ur(He),We=we?we.prototype:void 0,Ve=We?We.valueOf:void 0;function Pe(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function tt(){this.__data__=Me?Me(null):{},this.size=0}function rt(p){var L=this.has(p)&&delete this.__data__[p];return this.size-=L?1:0,L}function Ib(p){var L=this.__data__;if(Me){var $=L[p];return $===n?void 0:$}return ne.call(L,p)?L[p]:void 0}function Ab(p){var L=this.__data__;return Me?L[p]!==void 0:ne.call(L,p)}function Tb(p,L){var $=this.__data__;return this.size+=this.has(p)?0:1,$[p]=Me&&L===void 0?n:L,this}Pe.prototype.clear=tt,Pe.prototype.delete=rt,Pe.prototype.get=Ib,Pe.prototype.has=Ab,Pe.prototype.set=Tb;function qt(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function Cb(){this.__data__=[],this.size=0}function Rb(p){var L=this.__data__,$=Kn(L,p);if($<0)return!1;var k=L.length-1;return $==k?L.pop():kt.call(L,$,1),--this.size,!0}function Pb(p){var L=this.__data__,$=Kn(L,p);return $<0?void 0:L[$][1]}function Nb(p){return Kn(this.__data__,p)>-1}function $b(p,L){var $=this.__data__,k=Kn($,p);return k<0?(++this.size,$.push([p,L])):$[k][1]=L,this}qt.prototype.clear=Cb,qt.prototype.delete=Rb,qt.prototype.get=Pb,qt.prototype.has=Nb,qt.prototype.set=$b;function cr(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function Fb(){this.size=0,this.__data__={hash:new Pe,map:new(Fe||qt),string:new Pe}}function Mb(p){var L=qn(this,p).delete(p);return this.size-=L?1:0,L}function Ub(p){return qn(this,p).get(p)}function jb(p){return qn(this,p).has(p)}function Bb(p,L){var $=qn(this,p),k=$.size;return $.set(p,L),this.size+=$.size==k?0:1,this}cr.prototype.clear=Fb,cr.prototype.delete=Mb,cr.prototype.get=Ub,cr.prototype.has=jb,cr.prototype.set=Bb;function zn(p){var L=-1,$=p==null?0:p.length;for(this.__data__=new cr;++L<$;)this.add(p[L])}function zb(p){return this.__data__.set(p,n),this}function Kb(p){return this.__data__.has(p)}zn.prototype.add=zn.prototype.push=zb,zn.prototype.has=Kb;function Yt(p){var L=this.__data__=new qt(p);this.size=L.size}function qb(){this.__data__=new qt,this.size=0}function Hb(p){var L=this.__data__,$=L.delete(p);return this.size=L.size,$}function Vb(p){return this.__data__.get(p)}function Gb(p){return this.__data__.has(p)}function Wb(p,L){var $=this.__data__;if($ instanceof qt){var k=$.__data__;if(!Fe||k.length<r-1)return k.push([p,L]),this.size=++$.size,this;$=this.__data__=new cr(k)}return $.set(p,L),this.size=$.size,this}Yt.prototype.clear=qb,Yt.prototype.delete=Hb,Yt.prototype.get=Vb,Yt.prototype.has=Gb,Yt.prototype.set=Wb;function kb(p,L){var $=Hn(p),k=!$&&u1(p),Re=!$&&!k&&ps(p),ie=!$&&!k&&!Re&&$u(p),Ue=$||k||Re||ie,nt=Ue?Be(p.length,String):[],at=nt.length;for(var Ne in p)(L||ne.call(p,Ne))&&!(Ue&&(Ne=="length"||Re&&(Ne=="offset"||Ne=="parent")||ie&&(Ne=="buffer"||Ne=="byteLength"||Ne=="byteOffset")||i1(Ne,at)))&&nt.push(Ne);return nt}function Kn(p,L){for(var $=p.length;$--;)if(Cu(p[$][0],L))return $;return-1}function Yb(p,L,$){var k=L(p);return Hn(p)?k:de(k,$(p))}function en(p){return p==null?p===void 0?U:B:mt&&mt in Object(p)?r1(p):c1(p)}function Lu(p){return tn(p)&&en(p)==a}function Iu(p,L,$,k,Re){return p===L?!0:p==null||L==null||!tn(p)&&!tn(L)?p!==p&&L!==L:Jb(p,L,$,k,Iu,Re)}function Jb(p,L,$,k,Re,ie){var Ue=Hn(p),nt=Hn(L),at=Ue?h:Jt(p),Ne=nt?h:Jt(L);at=at==a?S:at,Ne=Ne==a?S:Ne;var wt=at==S,It=Ne==S,ut=at==Ne;if(ut&&ps(p)){if(!ps(L))return!1;Ue=!0,wt=!1}if(ut&&!wt)return ie||(ie=new Yt),Ue||$u(p)?Au(p,L,$,k,Re,ie):e1(p,L,at,$,k,Re,ie);if(!($&i)){var Dt=wt&&ne.call(p,"__wrapped__"),xt=It&&ne.call(L,"__wrapped__");if(Dt||xt){var Xt=Dt?p.value():p,Ht=xt?L.value():L;return ie||(ie=new Yt),Re(Xt,Ht,$,k,ie)}}return ut?(ie||(ie=new Yt),t1(p,L,$,k,Re,ie)):!1}function Xb(p){if(!Nu(p)||o1(p))return!1;var L=Ru(p)?Ee:q;return L.test(ur(p))}function Zb(p){return tn(p)&&Pu(p.length)&&!!Y[en(p)]}function Qb(p){if(!a1(p))return Bn(p);var L=[];for(var $ in Object(p))ne.call(p,$)&&$!="constructor"&&L.push($);return L}function Au(p,L,$,k,Re,ie){var Ue=$&i,nt=p.length,at=L.length;if(nt!=at&&!(Ue&&at>nt))return!1;var Ne=ie.get(p);if(Ne&&ie.get(L))return Ne==L;var wt=-1,It=!0,ut=$&s?new zn:void 0;for(ie.set(p,L),ie.set(L,p);++wt<nt;){var Dt=p[wt],xt=L[wt];if(k)var Xt=Ue?k(xt,Dt,wt,L,p,ie):k(Dt,xt,wt,p,L,ie);if(Xt!==void 0){if(Xt)continue;It=!1;break}if(ut){if(!me(L,function(Ht,fr){if(!ye(ut,fr)&&(Dt===Ht||Re(Dt,Ht,$,k,ie)))return ut.push(fr)})){It=!1;break}}else if(!(Dt===xt||Re(Dt,xt,$,k,ie))){It=!1;break}}return ie.delete(p),ie.delete(L),It}function e1(p,L,$,k,Re,ie,Ue){switch($){case J:if(p.byteLength!=L.byteLength||p.byteOffset!=L.byteOffset)return!1;p=p.buffer,L=L.buffer;case G:return!(p.byteLength!=L.byteLength||!ie(new Lt(p),new Lt(L)));case l:case D:case R:return Cu(+p,+L);case b:return p.name==L.name&&p.message==L.message;case x:case c:return p==L+"";case N:var nt=le;case E:var at=k&i;if(nt||(nt=ce),p.size!=L.size&&!at)return!1;var Ne=Ue.get(p);if(Ne)return Ne==L;k|=s,Ue.set(p,L);var wt=Au(nt(p),nt(L),k,Re,ie,Ue);return Ue.delete(p),wt;case d:if(Ve)return Ve.call(p)==Ve.call(L)}return!1}function t1(p,L,$,k,Re,ie){var Ue=$&i,nt=Tu(p),at=nt.length,Ne=Tu(L),wt=Ne.length;if(at!=wt&&!Ue)return!1;for(var It=at;It--;){var ut=nt[It];if(!(Ue?ut in L:ne.call(L,ut)))return!1}var Dt=ie.get(p);if(Dt&&ie.get(L))return Dt==L;var xt=!0;ie.set(p,L),ie.set(L,p);for(var Xt=Ue;++It<at;){ut=nt[It];var Ht=p[ut],fr=L[ut];if(k)var Fu=Ue?k(fr,Ht,ut,L,p,ie):k(Ht,fr,ut,p,L,ie);if(!(Fu===void 0?Ht===fr||Re(Ht,fr,$,k,ie):Fu)){xt=!1;break}Xt||(Xt=ut=="constructor")}if(xt&&!Xt){var Vn=p.constructor,Gn=L.constructor;Vn!=Gn&&"constructor"in p&&"constructor"in L&&!(typeof Vn=="function"&&Vn instanceof Vn&&typeof Gn=="function"&&Gn instanceof Gn)&&(xt=!1)}return ie.delete(p),ie.delete(L),xt}function Tu(p){return Yb(p,l1,n1)}function qn(p,L){var $=p.__data__;return s1(L)?$[typeof L=="string"?"string":"hash"]:$.map}function Dr(p,L){var $=pe(p,L);return Xb($)?$:void 0}function r1(p){var L=ne.call(p,mt),$=p[mt];try{p[mt]=void 0;var k=!0}catch{}var Re=be.call(p);return k&&(L?p[mt]=$:delete p[mt]),Re}var n1=ar?function(p){return p==null?[]:(p=Object(p),ve(ar(p),function(L){return $t.call(p,L)}))}:d1,Jt=en;(ze&&Jt(new ze(new ArrayBuffer(1)))!=J||Fe&&Jt(new Fe)!=N||Ke&&Jt(Ke.resolve())!=I||qe&&Jt(new qe)!=E||He&&Jt(new He)!=K)&&(Jt=function(p){var L=en(p),$=L==S?p.constructor:void 0,k=$?ur($):"";if(k)switch(k){case Je:return J;case Xe:return N;case Ze:return I;case Qe:return E;case et:return K}return L});function i1(p,L){return L=L??o,!!L&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<L}function s1(p){var L=typeof p;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?p!=="__proto__":p===null}function o1(p){return!!_e&&_e in p}function a1(p){var L=p&&p.constructor,$=typeof L=="function"&&L.prototype||te;return p===$}function c1(p){return be.call(p)}function ur(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function Cu(p,L){return p===L||p!==p&&L!==L}var u1=Lu(function(){return arguments}())?Lu:function(p){return tn(p)&&ne.call(p,"callee")&&!$t.call(p,"callee")},Hn=Array.isArray;function f1(p){return p!=null&&Pu(p.length)&&!Ru(p)}var ps=Qr||p1;function h1(p,L){return Iu(p,L)}function Ru(p){if(!Nu(p))return!1;var L=en(p);return L==m||L==w||L==f||L==y}function Pu(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=o}function Nu(p){var L=typeof p;return p!=null&&(L=="object"||L=="function")}function tn(p){return p!=null&&typeof p=="object"}var $u=he?$e(he):Zb;function l1(p){return f1(p)?kb(p):Qb(p)}function d1(){return[]}function p1(){return!1}t.exports=h1})(ts,ts.exports);var Iv=ts.exports,Av=Object.defineProperty,Ec=Object.getOwnPropertySymbols,Tv=Object.prototype.hasOwnProperty,Cv=Object.prototype.propertyIsEnumerable,Dc=(t,e,r)=>e in t?Av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e)=>{for(var r in e||(e={}))Tv.call(e,r)&&Dc(t,r,e[r]);if(Ec)for(var r of Ec(e))Cv.call(e,r)&&Dc(t,r,e[r]);return t};function Rv(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,h=t.charAt(0),f=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var N=0,R=0,B=0,S=w.length;B!==S&&w[B]===0;)B++,N++;for(var I=(S-B)*l+1>>>0,y=new Uint8Array(I);B!==S;){for(var x=w[B],E=0,c=I-1;(x!==0||E<R)&&c!==-1;c--,E++)x+=256*y[c]>>>0,y[c]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");R=E,B++}for(var d=I-R;d!==I&&y[d]===0;)d++;for(var U=h.repeat(N);d<I;++d)U+=t.charAt(y[d]);return U}function b(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var N=0;if(w[N]!==" "){for(var R=0,B=0;w[N]===h;)R++,N++;for(var S=(w.length-N)*f+1>>>0,I=new Uint8Array(S);w[N];){var y=r[w.charCodeAt(N)];if(y===255)return;for(var x=0,E=S-1;(y!==0||x<B)&&E!==-1;E--,x++)y+=a*I[E]>>>0,I[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=x,N++}if(w[N]!==" "){for(var c=S-B;c!==S&&I[c]===0;)c++;for(var d=new Uint8Array(R+(S-c)),U=R;c!==S;)d[U++]=I[c++];return d}}}function m(w){var N=b(w);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:b,decode:m}}var Pv=Rv,Nv=Pv;const xc=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")},$v=t=>new TextEncoder().encode(t),Fv=t=>new TextDecoder().decode(t);class Mv{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Uv{constructor(e,r,n){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=n}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 Sc(this,e)}}class jv{constructor(e){this.decoders=e}or(e){return Sc(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Sc=(t,e)=>new jv(ht(ht({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Bv{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Mv(e,r,n),this.decoder=new Uv(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Tn=({name:t,prefix:e,encode:r,decode:n})=>new Bv(t,e,r,n),Jr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Nv(r,e);return Tn({prefix:t,name:e,encode:n,decode:s=>xc(i(s))})},zv=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,h=0,f=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|D,a+=r,a>=8&&(a-=8,o[f++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},Kv=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let h=0;h<t.length;++h)for(a=a<<8|t[h],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ot=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Tn({prefix:e,name:t,encode(i){return Kv(i,n,r)},decode(i){return zv(i,n,r,t)}}),qv=Tn({prefix:"\0",name:"identity",encode:t=>Fv(t),decode:t=>$v(t)});var Hv=Object.freeze({__proto__:null,identity:qv});const Vv=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gv=Object.freeze({__proto__:null,base2:Vv});const Wv=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kv=Object.freeze({__proto__:null,base8:Wv});const Yv=Jr({prefix:"9",name:"base10",alphabet:"0123456789"});var Jv=Object.freeze({__proto__:null,base10:Yv});const Xv=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zv=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qv=Object.freeze({__proto__:null,base16:Xv,base16upper:Zv});const e0=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),t0=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),r0=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),n0=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),i0=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),s0=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),o0=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),a0=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),c0=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var u0=Object.freeze({__proto__:null,base32:e0,base32upper:t0,base32pad:r0,base32padupper:n0,base32hex:i0,base32hexupper:s0,base32hexpad:o0,base32hexpadupper:a0,base32z:c0});const f0=Jr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),h0=Jr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var l0=Object.freeze({__proto__:null,base36:f0,base36upper:h0});const d0=Jr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),p0=Jr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var g0=Object.freeze({__proto__:null,base58btc:d0,base58flickr:p0});const y0=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),v0=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_0=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),b0=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var m0=Object.freeze({__proto__:null,base64:y0,base64pad:v0,base64url:_0,base64urlpad:b0});const Oc=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}"),w0=Oc.reduce((t,e,r)=>(t[r]=e,t),[]),E0=Oc.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function D0(t){return t.reduce((e,r)=>(e+=w0[r],e),"")}function x0(t){const e=[];for(const r of t){const n=E0[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const S0=Tn({prefix:"\u{1F680}",name:"base256emoji",encode:D0,decode:x0});var O0=Object.freeze({__proto__:null,base256emoji:S0}),L0=Ic,Lc=128,I0=127,A0=~I0,T0=Math.pow(2,31);function Ic(t,e,r){e=e||[],r=r||0;for(var n=r;t>=T0;)e[r++]=t&255|Lc,t/=128;for(;t&A0;)e[r++]=t&255|Lc,t>>>=7;return e[r]=t|0,Ic.bytes=r-n+1,e}var C0=rs,R0=128,Ac=127;function rs(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw rs.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Ac)<<i:(o&Ac)*Math.pow(2,i),i+=7}while(o>=R0);return rs.bytes=s-n,r}var P0=Math.pow(2,7),N0=Math.pow(2,14),$0=Math.pow(2,21),F0=Math.pow(2,28),M0=Math.pow(2,35),U0=Math.pow(2,42),j0=Math.pow(2,49),B0=Math.pow(2,56),z0=Math.pow(2,63),K0=function(t){return t<P0?1:t<N0?2:t<$0?3:t<F0?4:t<M0?5:t<U0?6:t<j0?7:t<B0?8:t<z0?9:10},q0={encode:L0,decode:C0,encodingLength:K0},Tc=q0;const Cc=(t,e,r=0)=>(Tc.encode(t,e,r),e),Rc=t=>Tc.encodingLength(t),ns=(t,e)=>{const r=e.byteLength,n=Rc(t),i=n+Rc(r),s=new Uint8Array(i+r);return Cc(t,s,0),Cc(r,s,n),s.set(e,i),new H0(t,r,e,s)};class H0{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Pc=({name:t,code:e,encode:r})=>new V0(t,e,r);class V0{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?ns(this.code,r):r.then(n=>ns(this.code,n))}else throw Error("Unknown type, must be binary type")}}const Nc=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),G0=Pc({name:"sha2-256",code:18,encode:Nc("SHA-256")}),W0=Pc({name:"sha2-512",code:19,encode:Nc("SHA-512")});var k0=Object.freeze({__proto__:null,sha256:G0,sha512:W0});const $c=0,Y0="identity",Fc=xc;var J0=Object.freeze({__proto__:null,identity:{code:$c,name:Y0,encode:Fc,digest:t=>ns($c,Fc(t))}});new TextEncoder,new TextDecoder;const Mc=ht(ht(ht(ht(ht(ht(ht(ht(ht(ht({},Hv),Gv),kv),Jv),Qv),u0),l0),g0),m0),O0);ht(ht({},k0),J0);function X0(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Uc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const jc=Uc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),is=Uc("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=X0(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Z0=ht({utf8:jc,"utf-8":jc,hex:Mc.base16,latin1:is,ascii:is,binary:is},Mc);function Q0(t,e="utf8"){const r=Z0[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}`)}const Bc="wc",e_=2,ss="core",Wt=`${Bc}@${2}:${ss}:`,t_={name:ss,logger:"error"},r_={database:":memory:"},n_="crypto",zc="client_ed25519_seed",i_=Z.ONE_DAY,s_="keychain",o_="0.3",a_="messages",c_="0.3",u_=Z.SIX_HOURS,f_="publisher",Kc="irn",h_="error",l_="wss://relay.walletconnect.com",d_="relayer",vt={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed"},p_="_subscription",Cn={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},qc=Z.ONE_SECOND,g_="2.2.0",y_="0.3",Rt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},v_="subscription",__="0.3",b_=Z.FIVE_SECONDS*1e3,m_="pairing",w_="0.3",Xr={wc_pairingDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:0},res:{ttl:Z.ONE_DAY,prompt:!1,tag:0}}},Pt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},E_="history",D_="0.3",x_="expirer",Et={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},S_="0.3";class O_{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=s_,this.version=o_,this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Qo(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ea(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class L_{constructor(e,r,n){this.core=e,this.logger=r,this.name=n_,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=fc(i);return uc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=Qd();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=fc(s),a=Ri();return await vv(a,i,i_,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const a=this.getPrivateKey(i),h=ep(a,s);return this.setSymKey(h,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||tp(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const a=Wo(o),h=Ir(s);if(ko(a)){const b=a.senderPublicKey,m=a.receiverPublicKey;i=await this.generateSharedKey(b,m)}const f=this.getSymKey(i),{type:l,senderPublicKey:D}=a;return np({type:l,symKey:f,message:h,senderPublicKey:D})},this.decode=async(i,s,o)=>{this.isInitialized();const a=op(s,o);if(ko(a)){const l=a.receiverPublicKey,D=a.senderPublicKey;i=await this.generateSharedKey(l,D)}const h=this.getSymKey(i),f=ip({symKey:h,encoded:s});return ni(f)},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.keychain=n||new O_(this.core,this.logger)}get context(){return Oe.getLoggerContext(this.logger)}getPayloadType(e){const r=Ni(e);return $r(r.type)}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(zc)}catch{e=Ri(),await this.keychain.set(zc,e)}return Q0(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class I_ extends Jy{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=a_,this.version=c_,this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Pi(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=Pi(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Oe.generateChildLogger(e,this.name),this.core=r}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Qo(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ea(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class A_ extends Xy{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new zt.exports.EventEmitter,this.name=f_,this.queue=new Map,this.publishTimeout=1e4,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const o=s?.ttl||u_,a=$i(s),h=s?.prompt||!1,f=s?.tag||0,l={topic:n,message:i,opts:{ttl:o,relay:a,prompt:h,tag:f}},D=Pi(i);this.queue.set(D,l);try{await await ta(this.rpcPublish(n,i,o,a,h,f),this.publishTimeout)}catch{this.logger.debug("Publishing Payload stalled"),this.relayer.events.emit(vt.connection_stalled);return}this.onPublish(D,l),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(o){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(o),o}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Oe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,o){var a,h,f,l;const D={method:Fi(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o}};return bt((a=D.params)==null?void 0:a.prompt)&&((h=D.params)==null||delete h.prompt),bt((f=D.params)==null?void 0:f.tag)&&((l=D.params)==null||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class T_{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var C_=Object.defineProperty,R_=Object.defineProperties,P_=Object.getOwnPropertyDescriptors,Hc=Object.getOwnPropertySymbols,N_=Object.prototype.hasOwnProperty,$_=Object.prototype.propertyIsEnumerable,Vc=(t,e,r)=>e in t?C_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rn=(t,e)=>{for(var r in e||(e={}))N_.call(e,r)&&Vc(t,r,e[r]);if(Hc)for(var r of Hc(e))$_.call(e,r)&&Vc(t,r,e[r]);return t},os=(t,e)=>R_(t,P_(e));class F_ extends ev{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new T_,this.events=new zt.exports.EventEmitter,this.name=v_,this.version=__,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Wt,this.subscribeTimeout=1e4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=$i(i),o={topic:n,relay:s};this.pending.set(n,o);const a=await this.rpcSubscribe(n,s);return this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const o=new Z.Watch;o.start(this.pendingSubscriptionWatchLabel);const a=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(a),o.stop(this.pendingSubscriptionWatchLabel),i(!0)),o.elapsed(this.pendingSubscriptionWatchLabel)>=b_&&(clearInterval(a),o.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.restart=async()=>{await this.restore(),await this.reset()},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=$i(n);await this.rpcUnsubscribe(e,r,i);const s=Ge("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:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r){const n={method:Fi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await ta(this.relayer.provider.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(vt.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:Fi(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,os(Rn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,os(Rn({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(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,Rn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Rt.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:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Rt.deleted,os(Rn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Rt.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(Rt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),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 resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.relayer.transportExplicitlyClosed||this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.on(vt.connect,async()=>{await this.onConnect()}),this.relayer.on(vt.disconnect,()=>{this.onDisconnect()}),this.events.on(Rt.created,async e=>{const r=Rt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Rt.deleted,async e=>{const r=Rt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var M_=Object.defineProperty,Gc=Object.getOwnPropertySymbols,U_=Object.prototype.hasOwnProperty,j_=Object.prototype.propertyIsEnumerable,Wc=(t,e,r)=>e in t?M_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,B_=(t,e)=>{for(var r in e||(e={}))U_.call(e,r)&&Wc(t,r,e[r]);if(Gc)for(var r of Gc(e))j_.call(e,r)&&Wc(t,r,e[r]);return t};class z_ extends Zy{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new zt.exports.EventEmitter,this.name=d_,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Oe.generateChildLogger(e.logger,this.name):_n(Oe.getDefaultLoggerOptions({level:e.logger||h_})),this.messages=new I_(this.logger,e.core),this.subscriber=new F_(this,this.logger),this.publisher=new A_(this,this.logger),this.relayUrl=e?.relayUrl||l_,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.transportOpen(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Oe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){this.isInitialized();let n="";return await Promise.all([new Promise(i=>{this.subscriber.once(Rt.created,s=>{s.topic===e&&i()})}),new Promise(async i=>{n=await this.subscriber.subscribe(e,r),i()})]),n}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 transportClose(){this.transportExplicitlyClosed=!0,this.connected&&await this.provider.disconnect(),this.events.emit(vt.transport_closed)}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1;try{await Promise.all([new Promise(r=>{this.initialized||r(),this.subscriber.once(Rt.resubscribed,()=>{r()})}),await Promise.race([this.provider.connect(),new Promise((r,n)=>this.once(vt.transport_closed,()=>{n()}))])])}catch(r){const n=r;if(!/socket hang up/i.test(n.message))throw new Error(n.message);this.logger.error(n),this.events.emit(vt.transport_closed)}}async restartTransport(e){await this.transportClose(),await new Promise(r=>setTimeout(r,qc)),await this.transportOpen(e)}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new ti(new Lv(mp({sdkVersion:g_,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Qn(e)){if(!e.method.endsWith(p_))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(B_({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(vt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=on(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(Cn.payload,e=>this.onProviderPayload(e)),this.provider.on(Cn.connect,()=>{this.events.emit(vt.connect)}),this.provider.on(Cn.disconnect,()=>{this.events.emit(vt.disconnect),this.attemptToReconnect()}),this.provider.on(Cn.error,e=>this.events.emit(vt.error,e)),this.events.on(vt.connection_stalled,async()=>{await this.restartTransport()})}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.transportOpen()},Z.toMiliseconds(qc))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var K_=Object.defineProperty,kc=Object.getOwnPropertySymbols,q_=Object.prototype.hasOwnProperty,H_=Object.prototype.propertyIsEnumerable,Yc=(t,e,r)=>e in t?K_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jc=(t,e)=>{for(var r in e||(e={}))q_.call(e,r)&&Yc(t,r,e[r]);if(kc)for(var r of kc(e))H_.call(e,r)&&Yc(t,r,e[r]);return t};class Pn extends Qy{constructor(e,r,n,i=Wt,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=y_,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{zp(o)?this.map.set(o.id,o):Kp(o)?this.map.set(o.topic,o):this.getKey&&o!==null&&!bt(o)&&this.map.set(this.getKey(o),o)}),this.cached=[],this.initialized=!0)},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())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(h=>Iv(a[h],o[h]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const h=Jc(Jc({},this.getData(o)),a);this.map.set(o,h),await this.persist()},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),await this.persist())},this.logger=Oe.generateChildLogger(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}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){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}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}=V("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}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class V_{constructor(e,r){this.core=e,this.logger=r,this.name=m_,this.version=w_,this.events=new zt.exports,this.initialized=!1,this.storagePrefix=Wt,this.ignoredPayloadTypes=[rr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=Ri(),i=await this.core.crypto.setSymKey(n),s=Bt(Z.FIVE_MINUTES),o={protocol:Kc},a={topic:i,expiry:s,relay:o,active:!1},h=Cp({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:o});return await this.pairings.set(i,a),await this.core.relayer.subscribe(i),this.core.expirer.set(i,s),{topic:i,uri:h}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:i,symKey:s,relay:o}=Ap(n.uri),a=Bt(Z.FIVE_MINUTES),h={topic:i,relay:o,expiry:a,active:!1};return await this.pairings.set(i,h),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:o}),this.core.expirer.set(i,a),n.activatePairing&&await this.activate({topic:i}),h},this.activate=async({topic:n})=>{this.isInitialized();const i=Bt(Z.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:i}),this.core.expirer.set(n,i)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:h}=nr();this.events.once(je("pairing_ping",s),({error:f})=>{f?h(f):a()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Ge("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const o=sn(i,s),a=await this.core.crypto.encode(n,o),h=Xr[i].req;return this.core.history.set(n,o),await this.core.relayer.publish(n,a,h),o.id},this.sendResult=async(n,i,s)=>{const o=on(n,s),a=await this.core.crypto.encode(i,o),h=await this.core.history.get(i,n),f=Xr[h.request.method].res;await this.core.relayer.publish(i,a,f),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=Lr(n,s),a=await this.core.crypto.encode(i,o),h=await this.core.history.get(i,n),f=Xr[h.request.method]?Xr[h.request.method].res:Xr.unregistered_method.res;await this.core.relayer.publish(i,a,f),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Ge("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>Gt(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit("pairing_ping",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{jt(i)?this.events.emit(je("pairing_ping",s),{}):Ot(i)&&this.events.emit(je("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.sendResult(s,n,!0),await this.deletePairing(n),this.events.emit("pairing_delete",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Ge("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,a),this.logger.error(a)}catch(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Ge("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!yt(n)){const{message:i}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!Bp(n.uri)){const{message:i}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!yt(n)){const{message:s}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!yt(n)){const{message:s}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!st(n,!1)){const{message:i}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(Gt(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.pairings=new Pn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Oe.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(vt.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const i=await this.core.crypto.decode(r,n);Qn(i)?(this.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):ei(i)&&(await this.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.core.expirer.on(Et.expired,async e=>{const{topic:r}=na(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class G_ extends Yy{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new zt.exports.EventEmitter,this.name=E_,this.version=D_,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(o.id,o),this.events.emit(Pt.created,o)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=Ot(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Pt.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Pt.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 n={topic:r.topic,request:sn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Pt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=V("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(Pt.created,e=>{const r=Pt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Pt.updated,e=>{const r=Pt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Pt.deleted,e=>{const r=Pt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class W_ extends tv{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new zt.exports.EventEmitter,this.name=x_,this.version=S_,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Et.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{this.isInitialized();const i=this.formatTarget(n);if(this.has(i)){const s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Et.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 wp(e);if(typeof e=="number")return Ep(e);const{message:r}=V("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(Et.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=V("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:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Z.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Et.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Et.created,e=>{const r=Et.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Et.expired,e=>{const r=Et.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Et.deleted,e=>{const r=Et.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var k_=Object.defineProperty,Xc=Object.getOwnPropertySymbols,Y_=Object.prototype.hasOwnProperty,J_=Object.prototype.propertyIsEnumerable,Zc=(t,e,r)=>e in t?k_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qc=(t,e)=>{for(var r in e||(e={}))Y_.call(e,r)&&Zc(t,r,e[r]);if(Xc)for(var r of Xc(e))J_.call(e,r)&&Zc(t,r,e[r]);return t};class as extends ky{constructor(e){super(e),this.protocol=Bc,this.version=e_,this.name=ss,this.events=new zt.exports.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:_n(Oe.getDefaultLoggerOptions({level:e?.logger||t_.logger}));this.logger=Oe.generateChildLogger(r,this.name),this.heartbeat=new Vr.HeartBeat,this.crypto=new L_(this,this.logger,e?.keychain),this.history=new G_(this,this.logger),this.expirer=new W_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new kg(Qc(Qc({},r_),e?.storageOptions)),this.relayer=new z_({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new V_(this,this.logger)}static async init(e){const r=new as(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}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.initialized=!0,this.logger.info("Core Initilization Success")}catch(e){throw this.logger.warn(`Core Initilization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const X_=as;var Nn={exports:{}},wr=typeof Reflect=="object"?Reflect:null,eu=wr&&typeof wr.apply=="function"?wr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},$n;wr&&typeof wr.ownKeys=="function"?$n=wr.ownKeys:Object.getOwnPropertySymbols?$n=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:$n=function(e){return Object.getOwnPropertyNames(e)};function Z_(t){console&&console.warn&&console.warn(t)}var tu=Number.isNaN||function(e){return e!==e};function Ae(){Ae.init.call(this)}Nn.exports=Ae,Nn.exports.once=rb,Ae.EventEmitter=Ae,Ae.prototype._events=void 0,Ae.prototype._eventsCount=0,Ae.prototype._maxListeners=void 0;var ru=10;function Fn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ae,"defaultMaxListeners",{enumerable:!0,get:function(){return ru},set:function(t){if(typeof t!="number"||t<0||tu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ru=t}}),Ae.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},Ae.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||tu(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 nu(t){return t._maxListeners===void 0?Ae.defaultMaxListeners:t._maxListeners}Ae.prototype.getMaxListeners=function(){return nu(this)},Ae.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")eu(h,this,r);else for(var f=h.length,l=cu(h,f),n=0;n<f;++n)eu(l[n],this,r);return!0};function iu(t,e,r,n){var i,s,o;if(Fn(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=nu(t),i>0&&o.length>i&&!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,Z_(a)}return t}Ae.prototype.addListener=function(e,r){return iu(this,e,r,!1)},Ae.prototype.on=Ae.prototype.addListener,Ae.prototype.prependListener=function(e,r){return iu(this,e,r,!0)};function Q_(){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 su(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Q_.bind(n);return i.listener=r,n.wrapFn=i,i}Ae.prototype.once=function(e,r){return Fn(r),this.on(e,su(this,e,r)),this},Ae.prototype.prependOnceListener=function(e,r){return Fn(r),this.prependListener(e,su(this,e,r)),this},Ae.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Fn(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():eb(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Ae.prototype.off=Ae.prototype.removeListener,Ae.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function ou(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?tb(i):cu(i,i.length)}Ae.prototype.listeners=function(e){return ou(this,e,!0)},Ae.prototype.rawListeners=function(e){return ou(this,e,!1)},Ae.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):au.call(t,e)},Ae.prototype.listenerCount=au;function au(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}Ae.prototype.eventNames=function(){return this._eventsCount>0?$n(this._events):[]};function cu(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function eb(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function tb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function rb(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}uu(t,e,s,{once:!0}),e!=="error"&&nb(t,i,{once:!0})})}function nb(t,e,r){typeof t.on=="function"&&uu(t,"error",e,r)}function uu(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const fu="wc",hu=2,lu="client",cs=`${fu}@${hu}:${lu}:`,us={name:lu,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},ib="proposal",sb="session",Mn=Z.SEVEN_DAYS,ob="engine",Zr={wc_sessionPropose:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1115}}},ab="request";var cb=Object.defineProperty,ub=Object.defineProperties,fb=Object.getOwnPropertyDescriptors,du=Object.getOwnPropertySymbols,hb=Object.prototype.hasOwnProperty,lb=Object.prototype.propertyIsEnumerable,pu=(t,e,r)=>e in t?cb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e)=>{for(var r in e||(e={}))hb.call(e,r)&&pu(t,r,e[r]);if(du)for(var r of du(e))lb.call(e,r)&&pu(t,r,e[r]);return t},fs=(t,e)=>ub(t,fb(e));class db extends nv{constructor(e){super(e),this.name=ob,this.events=new Nn.exports,this.initialized=!1,this.ignoredPayloadTypes=[rr],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Zr)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let o=n,a,h=!1;if(o&&(h=this.client.core.pairing.pairings.get(o).active),!o||!h){const{topic:R,uri:B}=await this.client.core.pairing.create();o=R,a=B}const f=await this.client.core.crypto.generateKeyPair(),l={requiredNamespaces:i,relays:s??[{protocol:Kc}],proposer:{publicKey:f,metadata:this.client.metadata}},{reject:D,resolve:b,done:m}=nr();if(this.events.once(je("session_connect"),async({error:R,session:B})=>{if(R)D(R);else if(B){B.self.publicKey=f;const S=fs(Kt({},B),{requiredNamespaces:B.requiredNamespaces});await this.client.session.set(B.topic,S),await this.setExpiry(B.topic,B.expiry),o&&await this.client.core.pairing.updateMetadata({topic:o,metadata:B.peer.metadata}),b(S)}}),!o){const{message:R}=V("NO_MATCHING_KEY",`connect() pairing topic: ${o}`);throw new Error(R)}const w=await this.sendRequest(o,"wc_sessionPropose",l),N=Bt(Z.FIVE_MINUTES);return await this.setProposal(w,Kt({id:w,expiry:N},l)),{uri:a,approval:m}},this.pair=async r=>(this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,o=this.client.proposal.get(n);let{pairingTopic:a,proposer:h,requiredNamespaces:f}=o;yn(f)||(f=$p(s,"approve()"),this.client.proposal.set(n,fs(Kt({},o),{requiredNamespaces:f})));const l=await this.client.core.crypto.generateKeyPair(),D=h.publicKey,b=await this.client.core.crypto.generateSharedKey(l,D),m={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:f,controller:{publicKey:l,metadata:this.client.metadata},expiry:Bt(Mn)};await this.client.core.relayer.subscribe(b);const w=await this.sendRequest(b,"wc_sessionSettle",m),{done:N,resolve:R,reject:B}=nr();this.events.once(je("session_approve",w),({error:I})=>{I?B(I):R(this.client.session.get(b))});const S=fs(Kt({},m),{topic:b,acknowledged:!1,self:m.controller,peer:{publicKey:h.publicKey,metadata:h.metadata},controller:l});return await this.client.session.set(b,S),await this.setExpiry(b,Bt(Mn)),a&&await this.client.core.pairing.updateMetadata({topic:a,metadata:S.peer.metadata}),a&&n&&(await this.sendResult(n,a,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,Ge("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a})),{topic:b,acknowledged:N}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,Ge("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:o,resolve:a,reject:h}=nr();return this.events.once(je("session_update",s),({error:f})=>{f?h(f):a()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:o}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:o,reject:a}=nr();return this.events.once(je("session_extend",i),({error:h})=>{h?a(h):o()}),await this.setExpiry(n,Bt(Mn)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s}=r,o=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n}),{done:a,resolve:h,reject:f}=nr();return this.events.once(je("session_request",o),({error:l,result:D})=>{l?f(l):h(D)}),await a()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;jt(i)?await this.sendResult(s,n,i.result):Ot(i)&&await this.sendError(s,n,i.error),this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0})},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:o,reject:a}=nr();this.events.once(je("session_ping",i),({error:h})=>{h?a(h):o()}),await s()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",Ge("USER_DISCONNECTED")),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>Up(n,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.deleteSession=async(r,n)=>{const{self:i}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await Promise.all([this.client.session.delete(r,Ge("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.deleteSymKey(r),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deleteProposal=async(r,n)=>{await Promise.all([this.client.proposal.delete(r,Ge("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.core.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.core.expirer.set(r,n.expiry)},this.setPendingSessionRequest=async r=>{const n=Zr.wc_sessionRequest.req.ttl,{id:i,topic:s,params:o}=r;await this.client.pendingRequest.set(i,{id:i,topic:s,params:o}),n&&this.client.core.expirer.set(i,n)},this.sendRequest=async(r,n,i)=>{const s=sn(n,i),o=await this.client.core.crypto.encode(r,s),a=Zr[n].req;return this.client.core.history.set(r,s),this.client.core.relayer.publish(r,o,a),s.id},this.sendResult=async(r,n,i)=>{const s=on(r,i),o=await this.client.core.crypto.encode(n,s),a=await this.client.core.history.get(n,r),h=Zr[a.request.method].res;this.client.core.relayer.publish(n,o,h),await this.client.core.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=Lr(r,i),o=await this.client.core.crypto.encode(n,s),a=await this.client.core.history.get(n,r),h=Zr[a.request.method].res;this.client.core.relayer.publish(n,o,h),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{Gt(i.expiry)&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Gt(i.expiry)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession(i)),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.core.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Kt({},n.params));const o=Bt(Z.FIVE_MINUTES),a=Kt({id:s,pairingTopic:r,expiry:o},i);await this.setProposal(s,a),this.client.events.emit("session_proposal",{id:s,params:a})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(jt(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const o=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:o});const a=o.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:a});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const f=await this.client.core.crypto.generateSharedKey(a,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const l=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else Ot(n)&&(await this.client.proposal.delete(i,Ge("USER_DISCONNECTED")),this.events.emit(je("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:h,namespaces:f,requiredNamespaces:l}=n.params,D={topic:r,relay:o,expiry:h,namespaces:f,acknowledged:!0,requiredNamespaces:l,controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(je("session_connect"),{session:D})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;jt(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(je("session_approve",i),{})):Ot(n)&&(await this.client.session.delete(r,Ge("USER_DISCONNECTED")),this.events.emit(je("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Kt({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;jt(n)?this.events.emit(je("session_update",i),{}):Ot(n)&&this.events.emit(je("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Bt(Mn)),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;jt(n)?this.events.emit(je("session_extend",i),{}):Ot(n)&&this.events.emit(je("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;setTimeout(()=>{jt(n)?this.events.emit(je("session_ping",i),{}):Ot(n)&&this.events.emit(je("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Kt({topic:r},s)),await this.setPendingSessionRequest({id:i,topic:r,params:s}),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;jt(n)?this.events.emit(je("session_request",i),{result:n.result}):Ot(n)&&this.events.emit(je("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Kt({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:a}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(a)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;if(bt(n)||await this.isValidPairingTopic(n),!bt(i)&&yn(i)===0)return;const o=Gp(i,"connect()");if(o)throw new Error(o.message);if(!Wp(s,!0)){const{message:a}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(a)}},this.isValidApprove=async r=>{if(!yt(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const o=this.client.proposal.get(n),a=vn(i,"approve()");if(a)throw new Error(a.message);const h=pa(o.requiredNamespaces,i,"update()");if(h)throw new Error(h.message);if(!st(s,!0)){const{message:f}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(f)}},this.isValidReject=async r=>{if(!yt(r)){const{message:s}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!Yp(i)){const{message:s}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!yt(r)){const{message:f}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(f)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!la(n)){const{message:f}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const a=qp(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const h=vn(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(Gt(o)){const{message:f}=V("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async r=>{if(!yt(r)){const{message:h}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(h)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=vn(i,"update()");if(o)throw new Error(o.message);const a=pa(s.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!yt(r)){const{message:i}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!yt(r)){const{message:a}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(a)}const{topic:n,request:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!da(o,s)){const{message:a}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(a)}if(!Jp(i)){const{message:a}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(a)}if(!Qp(o,s,i.method)){const{message:a}=V("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(a)}},this.isValidRespond=async r=>{if(!yt(r)){const{message:s}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!Xp(i)){const{message:s}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!yt(r)){const{message:i}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!yt(r)){const{message:a}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!da(o,s)){const{message:a}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Zp(i)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!eg(o,s,i.name)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!yt(r)){const{message:i}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(vt.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const i=await this.client.core.crypto.decode(r,n);Qn(i)?(this.client.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):ei(i)&&(await this.client.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.core.expirer.on(Et.expired,async e=>{const{topic:r,id:n}=na(e.target);if(n&&this.getPendingSessionRequests()[n])return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):n&&await this.deleteProposal(n,!0)})}isValidPairingTopic(e){if(!st(e,!1)){const{message:r}=V("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}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!st(e,!1)){const{message:r}=V("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=V("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(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(st(e,!1)){const{message:r}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!kp(e)){const{message:r}=V("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class pb extends Pn{constructor(e,r){super(e,r,ib,cs),this.core=e,this.logger=r}}class gb extends Pn{constructor(e,r){super(e,r,sb,cs),this.core=e,this.logger=r}}class yb extends Pn{constructor(e,r){super(e,r,ab,cs),this.core=e,this.logger=r}}class hs extends rv{constructor(e){super(e),this.protocol=fu,this.version=hu,this.name=us.name,this.events=new Nn.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||us.name,this.metadata=e?.metadata||yp();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:_n(Oe.getDefaultLoggerOptions({level:e?.logger||us.logger}));this.core=e?.core||new X_(e),this.logger=Oe.generateChildLogger(r,this.name),this.session=new gb(this.core,this.logger),this.proposal=new pb(this.core,this.logger),this.pendingRequest=new yb(this.core,this.logger),this.engine=new db(this)}static async init(e){const r=new hs(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(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.engine.init(),this.logger.info("SignClient Initilization Success")}catch(e){throw this.logger.info("SignClient Initilization Failure"),this.logger.error(e.message),e}}}var ls={exports:{}},Er=typeof Reflect=="object"?Reflect:null,gu=Er&&typeof Er.apply=="function"?Er.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Un;Er&&typeof Er.ownKeys=="function"?Un=Er.ownKeys:Object.getOwnPropertySymbols?Un=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Un=function(e){return Object.getOwnPropertyNames(e)};function vb(t){console&&console.warn&&console.warn(t)}var yu=Number.isNaN||function(e){return e!==e};function Te(){Te.init.call(this)}ls.exports=Te,ls.exports.once=wb,Te.EventEmitter=Te,Te.prototype._events=void 0,Te.prototype._eventsCount=0,Te.prototype._maxListeners=void 0;var vu=10;function jn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Te,"defaultMaxListeners",{enumerable:!0,get:function(){return vu},set:function(t){if(typeof t!="number"||t<0||yu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");vu=t}}),Te.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},Te.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||yu(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 _u(t){return t._maxListeners===void 0?Te.defaultMaxListeners:t._maxListeners}Te.prototype.getMaxListeners=function(){return _u(this)},Te.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){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 h=s[e];if(h===void 0)return!1;if(typeof h=="function")gu(h,this,r);else for(var f=h.length,l=Du(h,f),n=0;n<f;++n)gu(l[n],this,r);return!0};function bu(t,e,r,n){var i,s,o;if(jn(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]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=_u(t),i>0&&o.length>i&&!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,vb(a)}return t}Te.prototype.addListener=function(e,r){return bu(this,e,r,!1)},Te.prototype.on=Te.prototype.addListener,Te.prototype.prependListener=function(e,r){return bu(this,e,r,!0)};function _b(){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 mu(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=_b.bind(n);return i.listener=r,n.wrapFn=i,i}Te.prototype.once=function(e,r){return jn(r),this.on(e,mu(this,e,r)),this},Te.prototype.prependOnceListener=function(e,r){return jn(r),this.prependListener(e,mu(this,e,r)),this},Te.prototype.removeListener=function(e,r){var n,i,s,o,a;if(jn(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():bb(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Te.prototype.off=Te.prototype.removeListener,Te.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function wu(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?mb(i):Du(i,i.length)}Te.prototype.listeners=function(e){return wu(this,e,!0)},Te.prototype.rawListeners=function(e){return wu(this,e,!1)},Te.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Eu.call(t,e)},Te.prototype.listenerCount=Eu;function Eu(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}Te.prototype.eventNames=function(){return this._eventsCount>0?Un(this._events):[]};function Du(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function bb(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function mb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function wb(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}xu(t,e,s,{once:!0}),e!=="error"&&Eb(t,i,{once:!0})})}function Eb(t,e,r){typeof t.on=="function"&&xu(t,"error",e,r)}function xu(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}function Db(t){return typeof t<"u"&&typeof t.context<"u"}const Nt={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class xb extends xf{constructor(e){super(),this.events=new ls.exports.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?Li(this.session.namespaces):Xd(this.requiredNamespaces)}get accounts(){return this.session?Oi(this.session.namespaces):[]}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(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(Nt.uri,{uri:n}),this.session=await i(),this.events.emit(Nt.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:Ge("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",on(e.id,n))).catch(n=>this.events.emit("payload",Lr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(Nt.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(Db(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await hs.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Nt.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(Nt.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(Nt.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(Nt.deleted,this.session),this.session=void 0)}))}}const Sb=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],Ob=["chainChanged","accountsChanged"];function Su(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Ou(t,e){let r;return e.rpcMap&&(r=e.rpcMap[ds([t])]),r}function ds(t){return Number(t[0].split(":")[1])}class Lb{constructor(e){this.events=new Wn.exports.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Su(e),this.signer=this.setSignerProvider(e?.client),this.chainId=ds(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}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}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(Nt.created,e=>{const r=Li(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Oi(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(Nt.updated,e=>{const r=Li(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Oi(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(Nt.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new xb({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new ti(r)}setHttpProvider(e){const r=Ou(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new ti(new Cf(r))}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(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}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)}}St.default=Lb,St.getEthereumChainId=ds,St.getRpcConfig=Su,St.getRpcUrl=Ou,St.signerEvents=Ob,St.signerMethods=Sb,Object.defineProperty(St,"__esModule",{value:!0})});
66
+ ***************************************************************************** */var Si=function(t,e){return Si=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Si(t,e)};function qp(t,e){Si(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var xi=function(){return xi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},xi.apply(this,arguments)};function Hp(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Kp(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Vp(t,e){return function(r,n){e(r,n,t)}}function Gp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Wp(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function kp(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Yp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Jp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Oi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ra(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Xp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ra(arguments[e]));return t}function Zp(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Lr(t){return this instanceof Lr?(this.v=t,this):new Lr(t)}function Qp(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Lr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function eg(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Lr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function tg(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 Oi=="function"?Oi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function rg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ng(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 ig(t){return t&&t.__esModule?t:{default:t}}function sg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function og(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 ag=Object.freeze({__proto__:null,__extends:qp,get __assign(){return xi},__rest:Hp,__decorate:Kp,__param:Vp,__metadata:Gp,__awaiter:Wp,__generator:kp,__createBinding:Yp,__exportStar:Jp,__values:Oi,__read:ra,__spread:Xp,__spreadArrays:Zp,__await:Lr,__asyncGenerator:Qp,__asyncDelegator:eg,__asyncValues:tg,__makeTemplateObject:rg,__importStar:ng,__importDefault:ig,__classPrivateFieldGet:sg,__classPrivateFieldSet:og}),cg=Kt(ag),Zt={},na;function ia(){return na||(na=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.PINO_CUSTOM_CONTEXT_KEY=Zt.PINO_LOGGER_DEFAULTS=void 0,Zt.PINO_LOGGER_DEFAULTS={level:"info"},Zt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Zt}var st={},sa;function ug(){if(sa)return st;sa=1,Object.defineProperty(st,"__esModule",{value:!0}),st.generateChildLogger=st.formatChildLoggerContext=st.getLoggerContext=st.setBrowserLoggerContext=st.getBrowserLoggerContext=st.getDefaultLoggerOptions=void 0;const t=ia();function e(c){return Object.assign(Object.assign({},c),{level:c?.level||t.PINO_LOGGER_DEFAULTS.level})}st.getDefaultLoggerOptions=e;function r(c,f=t.PINO_CUSTOM_CONTEXT_KEY){return c[f]||""}st.getBrowserLoggerContext=r;function n(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){return c[h]=f,c}st.setBrowserLoggerContext=n;function i(c,f=t.PINO_CUSTOM_CONTEXT_KEY){let h="";return typeof c.bindings>"u"?h=r(c,f):h=c.bindings().context||"",h}st.getLoggerContext=i;function s(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=i(c,h);return l.trim()?`${l}/${f}`:f}st.formatChildLoggerContext=s;function o(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=s(c,f,h),D=c.child({context:l});return n(D,l,h)}return st.generateChildLogger=o,st}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const e=cg,r=e.__importDefault(sn);Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(ia(),t),e.__exportStar(ug(),t)})(xe);class hg extends Jt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class fg extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class lg{constructor(e,r){this.logger=e,this.core=r}}class dg extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pg extends Jt{constructor(e){super()}}class gg{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class yg extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class _g extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}class bg{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class vg{constructor(e){this.client=e}}var Ii={},oa={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=lt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},c.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},c.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,w=h<<3,m=h%128<112?128:256;this._buffer[l]=128;for(var E=l+1;E<m-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(w,this._buffer,m-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,m),this._finished=!0}for(var E=0;E<this.digestLength/8;E++)e.writeUint32BE(this._stateHi[E],f,E*8),e.writeUint32BE(this._stateLo[E],f,E*8+4);return this},c.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(f){return this._stateHi.set(f.stateHi),this._stateLo.set(f.stateLo),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(f){r.wipe(f.stateHi),r.wipe(f.stateLo),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},c}();t.SHA512=n;var i=new Int32Array([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 s(c,f,h,l,D,w,m){for(var E=h[0],F=h[1],N=h[2],B=h[3],x=h[4],A=h[5],y=h[6],S=h[7],v=l[0],a=l[1],d=l[2],M=l[3],q=l[4],G=l[5],J=l[6],X=l[7],g,_,U,$,C,R,j,z;m>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+w;c[Q]=e.readUint32BE(D,H),f[Q]=e.readUint32BE(D,H+4)}for(var Q=0;Q<80;Q++){var ee=E,Y=F,ae=N,P=B,T=x,O=A,u=y,b=S,K=v,W=a,fe=d,_e=M,de=q,we=G,Le=J,Pe=X;if(g=S,_=X,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=(x>>>14|q<<32-14)^(x>>>18|q<<32-18)^(q>>>41-32|x<<32-(41-32)),_=(q>>>14|x<<32-14)^(q>>>18|x<<32-18)^(x>>>41-32|q<<32-(41-32)),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=x&A^~x&y,_=q&G^~q&J,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=i[Q*2],_=i[Q*2+1],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=c[Q%16],_=f[Q%16],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,U=j&65535|z<<16,$=C&65535|R<<16,g=U,_=$,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=(E>>>28|v<<32-28)^(v>>>34-32|E<<32-(34-32))^(v>>>39-32|E<<32-(39-32)),_=(v>>>28|E<<32-28)^(E>>>34-32|v<<32-(34-32))^(E>>>39-32|v<<32-(39-32)),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=E&F^E&N^F&N,_=v&a^v&d^a&d,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,b=j&65535|z<<16,Pe=C&65535|R<<16,g=P,_=_e,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=U,_=$,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,P=j&65535|z<<16,_e=C&65535|R<<16,F=ee,N=Y,B=ae,x=P,A=T,y=O,S=u,E=b,a=K,d=W,M=fe,q=_e,G=de,J=we,X=Le,v=Pe,Q%16===15)for(var H=0;H<16;H++)g=c[H],_=f[H],C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=c[(H+9)%16],_=f[(H+9)%16],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,U=c[(H+1)%16],$=f[(H+1)%16],g=(U>>>1|$<<32-1)^(U>>>8|$<<32-8)^U>>>7,_=($>>>1|U<<32-1)^($>>>8|U<<32-8)^($>>>7|U<<32-7),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,U=c[(H+14)%16],$=f[(H+14)%16],g=(U>>>19|$<<32-19)^($>>>61-32|U<<32-(61-32))^U>>>6,_=($>>>19|U<<32-19)^(U>>>61-32|$<<32-(61-32))^($>>>6|U<<32-6),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,c[H]=j&65535|z<<16,f[H]=C&65535|R<<16}g=E,_=v,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[0],_=l[0],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[0]=E=j&65535|z<<16,l[0]=v=C&65535|R<<16,g=F,_=a,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[1],_=l[1],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[1]=F=j&65535|z<<16,l[1]=a=C&65535|R<<16,g=N,_=d,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[2],_=l[2],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[2]=N=j&65535|z<<16,l[2]=d=C&65535|R<<16,g=B,_=M,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[3],_=l[3],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[3]=B=j&65535|z<<16,l[3]=M=C&65535|R<<16,g=x,_=q,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[4],_=l[4],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[4]=x=j&65535|z<<16,l[4]=q=C&65535|R<<16,g=A,_=G,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[5],_=l[5],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[5]=A=j&65535|z<<16,l[5]=G=C&65535|R<<16,g=y,_=J,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[6],_=l[6],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[6]=y=j&65535|z<<16,l[6]=J=C&65535|R<<16,g=S,_=X,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[7],_=l[7],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[7]=S=j&65535|z<<16,l[7]=X=C&65535|R<<16,w+=128,m-=128}return w}function o(c){var f=new n;f.update(c);var h=f.digest();return f.clean(),h}t.hash=o})(oa),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=ir,r=oa,n=lt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(P){const T=new Float64Array(16);if(P)for(let O=0;O<P.length;O++)T[O]=P[O];return T}const s=new Uint8Array(32);s[0]=9;const o=i(),c=i([1]),f=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),w=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(P,T){for(let O=0;O<16;O++)P[O]=T[O]|0}function E(P){let T=1;for(let O=0;O<16;O++){let u=P[O]+T+65535;T=Math.floor(u/65536),P[O]=u-T*65536}P[0]+=T-1+37*(T-1)}function F(P,T,O){const u=~(O-1);for(let b=0;b<16;b++){const K=u&(P[b]^T[b]);P[b]^=K,T[b]^=K}}function N(P,T){const O=i(),u=i();for(let b=0;b<16;b++)u[b]=T[b];E(u),E(u),E(u);for(let b=0;b<2;b++){O[0]=u[0]-65517;for(let W=1;W<15;W++)O[W]=u[W]-65535-(O[W-1]>>16&1),O[W-1]&=65535;O[15]=u[15]-32767-(O[14]>>16&1);const K=O[15]>>16&1;O[14]&=65535,F(u,O,1-K)}for(let b=0;b<16;b++)P[2*b]=u[b]&255,P[2*b+1]=u[b]>>8}function B(P,T){let O=0;for(let u=0;u<32;u++)O|=P[u]^T[u];return(1&O-1>>>8)-1}function x(P,T){const O=new Uint8Array(32),u=new Uint8Array(32);return N(O,P),N(u,T),B(O,u)}function A(P){const T=new Uint8Array(32);return N(T,P),T[0]&1}function y(P,T){for(let O=0;O<16;O++)P[O]=T[2*O]+(T[2*O+1]<<8);P[15]&=32767}function S(P,T,O){for(let u=0;u<16;u++)P[u]=T[u]+O[u]}function v(P,T,O){for(let u=0;u<16;u++)P[u]=T[u]-O[u]}function a(P,T,O){let u,b,K=0,W=0,fe=0,_e=0,de=0,we=0,Le=0,Pe=0,ye=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,be=0,ve=0,Ee=0,De=0,me=0,mt=0,Tt=0,Bt=0,dt=0,Qt=0,jr=0,yn=0,Ue=O[0],Re=O[1],$e=O[2],Me=O[3],je=O[4],Ce=O[5],Ke=O[6],Ve=O[7],Ge=O[8],We=O[9],ke=O[10],qe=O[11],Be=O[12],Ae=O[13],Ye=O[14],Je=O[15];u=T[0],K+=u*Ue,W+=u*Re,fe+=u*$e,_e+=u*Me,de+=u*je,we+=u*Ce,Le+=u*Ke,Pe+=u*Ve,ye+=u*Ge,pe+=u*We,le+=u*ke,ue+=u*qe,ce+=u*Be,oe+=u*Ae,se+=u*Ye,te+=u*Je,u=T[1],W+=u*Ue,fe+=u*Re,_e+=u*$e,de+=u*Me,we+=u*je,Le+=u*Ce,Pe+=u*Ke,ye+=u*Ve,pe+=u*Ge,le+=u*We,ue+=u*ke,ce+=u*qe,oe+=u*Be,se+=u*Ae,te+=u*Ye,he+=u*Je,u=T[2],fe+=u*Ue,_e+=u*Re,de+=u*$e,we+=u*Me,Le+=u*je,Pe+=u*Ce,ye+=u*Ke,pe+=u*Ve,le+=u*Ge,ue+=u*We,ce+=u*ke,oe+=u*qe,se+=u*Be,te+=u*Ae,he+=u*Ye,ge+=u*Je,u=T[3],_e+=u*Ue,de+=u*Re,we+=u*$e,Le+=u*Me,Pe+=u*je,ye+=u*Ce,pe+=u*Ke,le+=u*Ve,ue+=u*Ge,ce+=u*We,oe+=u*ke,se+=u*qe,te+=u*Be,he+=u*Ae,ge+=u*Ye,ne+=u*Je,u=T[4],de+=u*Ue,we+=u*Re,Le+=u*$e,Pe+=u*Me,ye+=u*je,pe+=u*Ce,le+=u*Ke,ue+=u*Ve,ce+=u*Ge,oe+=u*We,se+=u*ke,te+=u*qe,he+=u*Be,ge+=u*Ae,ne+=u*Ye,be+=u*Je,u=T[5],we+=u*Ue,Le+=u*Re,Pe+=u*$e,ye+=u*Me,pe+=u*je,le+=u*Ce,ue+=u*Ke,ce+=u*Ve,oe+=u*Ge,se+=u*We,te+=u*ke,he+=u*qe,ge+=u*Be,ne+=u*Ae,be+=u*Ye,ve+=u*Je,u=T[6],Le+=u*Ue,Pe+=u*Re,ye+=u*$e,pe+=u*Me,le+=u*je,ue+=u*Ce,ce+=u*Ke,oe+=u*Ve,se+=u*Ge,te+=u*We,he+=u*ke,ge+=u*qe,ne+=u*Be,be+=u*Ae,ve+=u*Ye,Ee+=u*Je,u=T[7],Pe+=u*Ue,ye+=u*Re,pe+=u*$e,le+=u*Me,ue+=u*je,ce+=u*Ce,oe+=u*Ke,se+=u*Ve,te+=u*Ge,he+=u*We,ge+=u*ke,ne+=u*qe,be+=u*Be,ve+=u*Ae,Ee+=u*Ye,De+=u*Je,u=T[8],ye+=u*Ue,pe+=u*Re,le+=u*$e,ue+=u*Me,ce+=u*je,oe+=u*Ce,se+=u*Ke,te+=u*Ve,he+=u*Ge,ge+=u*We,ne+=u*ke,be+=u*qe,ve+=u*Be,Ee+=u*Ae,De+=u*Ye,me+=u*Je,u=T[9],pe+=u*Ue,le+=u*Re,ue+=u*$e,ce+=u*Me,oe+=u*je,se+=u*Ce,te+=u*Ke,he+=u*Ve,ge+=u*Ge,ne+=u*We,be+=u*ke,ve+=u*qe,Ee+=u*Be,De+=u*Ae,me+=u*Ye,mt+=u*Je,u=T[10],le+=u*Ue,ue+=u*Re,ce+=u*$e,oe+=u*Me,se+=u*je,te+=u*Ce,he+=u*Ke,ge+=u*Ve,ne+=u*Ge,be+=u*We,ve+=u*ke,Ee+=u*qe,De+=u*Be,me+=u*Ae,mt+=u*Ye,Tt+=u*Je,u=T[11],ue+=u*Ue,ce+=u*Re,oe+=u*$e,se+=u*Me,te+=u*je,he+=u*Ce,ge+=u*Ke,ne+=u*Ve,be+=u*Ge,ve+=u*We,Ee+=u*ke,De+=u*qe,me+=u*Be,mt+=u*Ae,Tt+=u*Ye,Bt+=u*Je,u=T[12],ce+=u*Ue,oe+=u*Re,se+=u*$e,te+=u*Me,he+=u*je,ge+=u*Ce,ne+=u*Ke,be+=u*Ve,ve+=u*Ge,Ee+=u*We,De+=u*ke,me+=u*qe,mt+=u*Be,Tt+=u*Ae,Bt+=u*Ye,dt+=u*Je,u=T[13],oe+=u*Ue,se+=u*Re,te+=u*$e,he+=u*Me,ge+=u*je,ne+=u*Ce,be+=u*Ke,ve+=u*Ve,Ee+=u*Ge,De+=u*We,me+=u*ke,mt+=u*qe,Tt+=u*Be,Bt+=u*Ae,dt+=u*Ye,Qt+=u*Je,u=T[14],se+=u*Ue,te+=u*Re,he+=u*$e,ge+=u*Me,ne+=u*je,be+=u*Ce,ve+=u*Ke,Ee+=u*Ve,De+=u*Ge,me+=u*We,mt+=u*ke,Tt+=u*qe,Bt+=u*Be,dt+=u*Ae,Qt+=u*Ye,jr+=u*Je,u=T[15],te+=u*Ue,he+=u*Re,ge+=u*$e,ne+=u*Me,be+=u*je,ve+=u*Ce,Ee+=u*Ke,De+=u*Ve,me+=u*Ge,mt+=u*We,Tt+=u*ke,Bt+=u*qe,dt+=u*Be,Qt+=u*Ae,jr+=u*Ye,yn+=u*Je,K+=38*he,W+=38*ge,fe+=38*ne,_e+=38*be,de+=38*ve,we+=38*Ee,Le+=38*De,Pe+=38*me,ye+=38*mt,pe+=38*Tt,le+=38*Bt,ue+=38*dt,ce+=38*Qt,oe+=38*jr,se+=38*yn,b=1,u=K+b+65535,b=Math.floor(u/65536),K=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=fe+b+65535,b=Math.floor(u/65536),fe=u-b*65536,u=_e+b+65535,b=Math.floor(u/65536),_e=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=we+b+65535,b=Math.floor(u/65536),we=u-b*65536,u=Le+b+65535,b=Math.floor(u/65536),Le=u-b*65536,u=Pe+b+65535,b=Math.floor(u/65536),Pe=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,K+=b-1+37*(b-1),b=1,u=K+b+65535,b=Math.floor(u/65536),K=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=fe+b+65535,b=Math.floor(u/65536),fe=u-b*65536,u=_e+b+65535,b=Math.floor(u/65536),_e=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=we+b+65535,b=Math.floor(u/65536),we=u-b*65536,u=Le+b+65535,b=Math.floor(u/65536),Le=u-b*65536,u=Pe+b+65535,b=Math.floor(u/65536),Pe=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,K+=b-1+37*(b-1),P[0]=K,P[1]=W,P[2]=fe,P[3]=_e,P[4]=de,P[5]=we,P[6]=Le,P[7]=Pe,P[8]=ye,P[9]=pe,P[10]=le,P[11]=ue,P[12]=ce,P[13]=oe,P[14]=se,P[15]=te}function d(P,T){a(P,T,T)}function M(P,T){const O=i();let u;for(u=0;u<16;u++)O[u]=T[u];for(u=253;u>=0;u--)d(O,O),u!==2&&u!==4&&a(O,O,T);for(u=0;u<16;u++)P[u]=O[u]}function q(P,T){const O=i();let u;for(u=0;u<16;u++)O[u]=T[u];for(u=250;u>=0;u--)d(O,O),u!==1&&a(O,O,T);for(u=0;u<16;u++)P[u]=O[u]}function G(P,T){const O=i(),u=i(),b=i(),K=i(),W=i(),fe=i(),_e=i(),de=i(),we=i();v(O,P[1],P[0]),v(we,T[1],T[0]),a(O,O,we),S(u,P[0],P[1]),S(we,T[0],T[1]),a(u,u,we),a(b,P[3],T[3]),a(b,b,h),a(K,P[2],T[2]),S(K,K,K),v(W,u,O),v(fe,K,b),S(_e,K,b),S(de,u,O),a(P[0],W,fe),a(P[1],de,_e),a(P[2],_e,fe),a(P[3],W,de)}function J(P,T,O){for(let u=0;u<4;u++)F(P[u],T[u],O)}function X(P,T){const O=i(),u=i(),b=i();M(b,T[2]),a(O,T[0],b),a(u,T[1],b),N(P,u),P[31]^=A(O)<<7}function g(P,T,O){m(P[0],o),m(P[1],c),m(P[2],c),m(P[3],o);for(let u=255;u>=0;--u){const b=O[u/8|0]>>(u&7)&1;J(P,T,b),G(T,P),G(P,P),J(P,T,b)}}function _(P,T){const O=[i(),i(),i(),i()];m(O[0],l),m(O[1],D),m(O[2],c),a(O[3],l,D),g(P,O,T)}function U(P){if(P.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const T=(0,r.hash)(P);T[0]&=248,T[31]&=127,T[31]|=64;const O=new Uint8Array(32),u=[i(),i(),i(),i()];_(u,T),X(O,u);const b=new Uint8Array(64);return b.set(P),b.set(O,32),{publicKey:O,secretKey:b}}t.generateKeyPairFromSeed=U;function $(P){const T=(0,e.randomBytes)(32,P),O=U(T);return(0,n.wipe)(T),O}t.generateKeyPair=$;function C(P){if(P.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(P.subarray(32))}t.extractPublicKeyFromSecretKey=C;const R=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(P,T){let O,u,b,K;for(u=63;u>=32;--u){for(O=0,b=u-32,K=u-12;b<K;++b)T[b]+=O-16*T[u]*R[b-(u-32)],O=Math.floor((T[b]+128)/256),T[b]-=O*256;T[b]+=O,T[u]=0}for(O=0,b=0;b<32;b++)T[b]+=O-(T[31]>>4)*R[b],O=T[b]>>8,T[b]&=255;for(b=0;b<32;b++)T[b]-=O*R[b];for(u=0;u<32;u++)T[u+1]+=T[u]>>8,P[u]=T[u]&255}function z(P){const T=new Float64Array(64);for(let O=0;O<64;O++)T[O]=P[O];for(let O=0;O<64;O++)P[O]=0;j(P,T)}function Q(P,T){const O=new Float64Array(64),u=[i(),i(),i(),i()],b=(0,r.hash)(P.subarray(0,32));b[0]&=248,b[31]&=127,b[31]|=64;const K=new Uint8Array(64);K.set(b.subarray(32),32);const W=new r.SHA512;W.update(K.subarray(32)),W.update(T);const fe=W.digest();W.clean(),z(fe),_(u,fe),X(K,u),W.reset(),W.update(K.subarray(0,32)),W.update(P.subarray(32)),W.update(T);const _e=W.digest();z(_e);for(let de=0;de<32;de++)O[de]=fe[de];for(let de=0;de<32;de++)for(let we=0;we<32;we++)O[de+we]+=_e[de]*b[we];return j(K.subarray(32),O),K}t.sign=Q;function H(P,T){const O=i(),u=i(),b=i(),K=i(),W=i(),fe=i(),_e=i();return m(P[2],c),y(P[1],T),d(b,P[1]),a(K,b,f),v(b,b,P[2]),S(K,P[2],K),d(W,K),d(fe,W),a(_e,fe,W),a(O,_e,b),a(O,O,K),q(O,O),a(O,O,b),a(O,O,K),a(O,O,K),a(P[0],O,K),d(u,P[0]),a(u,u,K),x(u,b)&&a(P[0],P[0],w),d(u,P[0]),a(u,u,K),x(u,b)?-1:(A(P[0])===T[31]>>7&&v(P[0],o,P[0]),a(P[3],P[0],P[1]),0)}function ee(P,T,O){const u=new Uint8Array(32),b=[i(),i(),i(),i()],K=[i(),i(),i(),i()];if(O.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(H(K,P))return!1;const W=new r.SHA512;W.update(O.subarray(0,32)),W.update(P),W.update(T);const fe=W.digest();return z(fe),g(b,K,fe),_(K,O.subarray(32)),G(b,K),X(u,b),!B(O,u)}t.verify=ee;function Y(P){let T=[i(),i(),i(),i()];if(H(T,P))throw new Error("Ed25519: invalid public key");let O=i(),u=i(),b=T[1];S(O,c,b),v(u,c,b),M(u,u),a(O,O,u);let K=new Uint8Array(32);return N(K,O),K}t.convertPublicKeyToX25519=Y;function ae(P){const T=(0,r.hash)(P.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const O=new Uint8Array(T.subarray(0,32));return(0,n.wipe)(T),O}t.convertSecretKeyToX25519=ae}(Ii);const wg="EdDSA",mg="JWT",aa=".",ca="base64url",Eg="utf8",Dg="utf8",Sg=":",xg="did",Og="key",ua="base58btc",Ig="z",Ag="K36",Tg=32;function hn(t){return ut(ct(pr(t),Eg),ca)}function ha(t){const e=ct(Ag,ua),r=Ig+ut(Bn([e,t]),ua);return[xg,Og,r].join(Sg)}function Pg(t){return ut(t,ca)}function Rg(t){return ct([hn(t.header),hn(t.payload)].join(aa),Dg)}function Cg(t){return[hn(t.header),hn(t.payload),Pg(t.signature)].join(aa)}function fa(t=ir.randomBytes(Tg)){return Ii.generateKeyPairFromSeed(t)}async function Ng(t,e,r,n,i=Z.fromMiliseconds(Date.now())){const s={alg:wg,typ:mg},o=ha(n.publicKey),c=i+r,f={iss:o,sub:t,aud:e,iat:i,exp:c},h=Rg({header:s,payload:f}),l=Ii.sign(n.secretKey,h);return Cg({header:s,payload:f,signature:l})}const la=10,Fg=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),Lg=()=>typeof window<"u",Ug=Fg();class $g{constructor(e){if(this.url=e,this.events=new Ze.exports.EventEmitter,this.registering=!1,!us(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(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(pr(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!us(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((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=rs.isReactNative()?void 0:{rejectUnauthorized:!Qc(e)},s=new Ug(e,[],i);Lg()?s.onerror=o=>{const c=o;n(this.emitError(c.error))}:s.on("error",o=>{n(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Rn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=dr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ts(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>la&&this.events.setMaxListeners(la)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for URL: ${this.url}`));return this.events.emit("register_error",r),r}}var Ai={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,c="[object Arguments]",f="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",D="[object Date]",w="[object Error]",m="[object Function]",E="[object GeneratorFunction]",F="[object Map]",N="[object Number]",B="[object Null]",x="[object Object]",A="[object Promise]",y="[object Proxy]",S="[object RegExp]",v="[object Set]",a="[object String]",d="[object Symbol]",M="[object Undefined]",q="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",g="[object Float64Array]",_="[object Int8Array]",U="[object Int16Array]",$="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",j="[object Uint16Array]",z="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[g]=Y[_]=Y[U]=Y[$]=Y[C]=Y[R]=Y[j]=Y[z]=!0,Y[c]=Y[f]=Y[G]=Y[l]=Y[J]=Y[D]=Y[w]=Y[m]=Y[F]=Y[N]=Y[x]=Y[S]=Y[v]=Y[a]=Y[q]=!1;var ae=typeof He=="object"&&He&&He.Object===Object&&He,P=typeof self=="object"&&self&&self.Object===Object&&self,T=ae||P||Function("return this")(),O=e&&!e.nodeType&&e,u=O&&!0&&t&&!t.nodeType&&t,b=u&&u.exports===O,K=b&&ae.process,W=function(){try{return K&&K.binding&&K.binding("util")}catch{}}(),fe=W&&W.isTypedArray;function _e(p,I){for(var L=-1,k=p==null?0:p.length,Ie=0,ie=[];++L<k;){var Ne=p[L];I(Ne,L,p)&&(ie[Ie++]=Ne)}return ie}function de(p,I){for(var L=-1,k=I.length,Ie=p.length;++L<k;)p[Ie+L]=I[L];return p}function we(p,I){for(var L=-1,k=p==null?0:p.length;++L<k;)if(I(p[L],L,p))return!0;return!1}function Le(p,I){for(var L=-1,k=Array(p);++L<p;)k[L]=I(L);return k}function Pe(p){return function(I){return p(I)}}function ye(p,I){return p.has(I)}function pe(p,I){return p?.[I]}function le(p){var I=-1,L=Array(p.size);return p.forEach(function(k,Ie){L[++I]=[Ie,k]}),L}function ue(p,I){return function(L){return p(I(L))}}function ce(p){var I=-1,L=Array(p.size);return p.forEach(function(k){L[++I]=k}),L}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=T["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,be=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),ve=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=b?T.Buffer:void 0,me=T.Symbol,mt=T.Uint8Array,Tt=te.propertyIsEnumerable,Bt=oe.splice,dt=me?me.toStringTag:void 0,Qt=Object.getOwnPropertySymbols,jr=De?De.isBuffer:void 0,yn=ue(Object.keys,Object),Ue=hr(T,"DataView"),Re=hr(T,"Map"),$e=hr(T,"Promise"),Me=hr(T,"Set"),je=hr(T,"WeakMap"),Ce=hr(Object,"create"),Ke=tr(Ue),Ve=tr(Re),Ge=tr($e),We=tr(Me),ke=tr(je),qe=me?me.prototype:void 0,Be=qe?qe.valueOf:void 0;function Ae(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function Ye(){this.__data__=Ce?Ce(null):{},this.size=0}function Je(p){var I=this.has(p)&&delete this.__data__[p];return this.size-=I?1:0,I}function O_(p){var I=this.__data__;if(Ce){var L=I[p];return L===n?void 0:L}return ne.call(I,p)?I[p]:void 0}function I_(p){var I=this.__data__;return Ce?I[p]!==void 0:ne.call(I,p)}function A_(p,I){var L=this.__data__;return this.size+=this.has(p)?0:1,L[p]=Ce&&I===void 0?n:I,this}Ae.prototype.clear=Ye,Ae.prototype.delete=Je,Ae.prototype.get=O_,Ae.prototype.has=I_,Ae.prototype.set=A_;function Ft(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function T_(){this.__data__=[],this.size=0}function P_(p){var I=this.__data__,L=bn(I,p);if(L<0)return!1;var k=I.length-1;return L==k?I.pop():Bt.call(I,L,1),--this.size,!0}function R_(p){var I=this.__data__,L=bn(I,p);return L<0?void 0:I[L][1]}function C_(p){return bn(this.__data__,p)>-1}function N_(p,I){var L=this.__data__,k=bn(L,p);return k<0?(++this.size,L.push([p,I])):L[k][1]=I,this}Ft.prototype.clear=T_,Ft.prototype.delete=P_,Ft.prototype.get=R_,Ft.prototype.has=C_,Ft.prototype.set=N_;function er(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function F_(){this.size=0,this.__data__={hash:new Ae,map:new(Re||Ft),string:new Ae}}function L_(p){var I=vn(this,p).delete(p);return this.size-=I?1:0,I}function U_(p){return vn(this,p).get(p)}function $_(p){return vn(this,p).has(p)}function M_(p,I){var L=vn(this,p),k=L.size;return L.set(p,I),this.size+=L.size==k?0:1,this}er.prototype.clear=F_,er.prototype.delete=L_,er.prototype.get=U_,er.prototype.has=$_,er.prototype.set=M_;function _n(p){var I=-1,L=p==null?0:p.length;for(this.__data__=new er;++I<L;)this.add(p[I])}function j_(p){return this.__data__.set(p,n),this}function B_(p){return this.__data__.has(p)}_n.prototype.add=_n.prototype.push=j_,_n.prototype.has=B_;function zt(p){var I=this.__data__=new Ft(p);this.size=I.size}function z_(){this.__data__=new Ft,this.size=0}function q_(p){var I=this.__data__,L=I.delete(p);return this.size=I.size,L}function H_(p){return this.__data__.get(p)}function K_(p){return this.__data__.has(p)}function V_(p,I){var L=this.__data__;if(L instanceof Ft){var k=L.__data__;if(!Re||k.length<r-1)return k.push([p,I]),this.size=++L.size,this;L=this.__data__=new er(k)}return L.set(p,I),this.size=L.size,this}zt.prototype.clear=z_,zt.prototype.delete=q_,zt.prototype.get=H_,zt.prototype.has=K_,zt.prototype.set=V_;function G_(p,I){var L=wn(p),k=!L&&a1(p),Ie=!L&&!k&&zi(p),ie=!L&&!k&&!Ie&&oc(p),Ne=L||k||Ie||ie,Xe=Ne?Le(p.length,String):[],rt=Xe.length;for(var Te in p)(I||ne.call(p,Te))&&!(Ne&&(Te=="length"||Ie&&(Te=="offset"||Te=="parent")||ie&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||r1(Te,rt)))&&Xe.push(Te);return Xe}function bn(p,I){for(var L=p.length;L--;)if(rc(p[L][0],I))return L;return-1}function W_(p,I,L){var k=I(p);return wn(p)?k:de(k,L(p))}function Br(p){return p==null?p===void 0?M:B:dt&&dt in Object(p)?e1(p):o1(p)}function Za(p){return zr(p)&&Br(p)==c}function Qa(p,I,L,k,Ie){return p===I?!0:p==null||I==null||!zr(p)&&!zr(I)?p!==p&&I!==I:k_(p,I,L,k,Qa,Ie)}function k_(p,I,L,k,Ie,ie){var Ne=wn(p),Xe=wn(I),rt=Ne?f:qt(p),Te=Xe?f:qt(I);rt=rt==c?x:rt,Te=Te==c?x:Te;var pt=rt==x,Et=Te==x,it=rt==Te;if(it&&zi(p)){if(!zi(I))return!1;Ne=!0,pt=!1}if(it&&!pt)return ie||(ie=new zt),Ne||oc(p)?ec(p,I,L,k,Ie,ie):Z_(p,I,rt,L,k,Ie,ie);if(!(L&i)){var _t=pt&&ne.call(p,"__wrapped__"),bt=Et&&ne.call(I,"__wrapped__");if(_t||bt){var Ht=_t?p.value():p,Lt=bt?I.value():I;return ie||(ie=new zt),Ie(Ht,Lt,L,k,ie)}}return it?(ie||(ie=new zt),Q_(p,I,L,k,Ie,ie)):!1}function Y_(p){if(!sc(p)||i1(p))return!1;var I=nc(p)?Ee:H;return I.test(tr(p))}function J_(p){return zr(p)&&ic(p.length)&&!!Y[Br(p)]}function X_(p){if(!s1(p))return yn(p);var I=[];for(var L in Object(p))ne.call(p,L)&&L!="constructor"&&I.push(L);return I}function ec(p,I,L,k,Ie,ie){var Ne=L&i,Xe=p.length,rt=I.length;if(Xe!=rt&&!(Ne&&rt>Xe))return!1;var Te=ie.get(p);if(Te&&ie.get(I))return Te==I;var pt=-1,Et=!0,it=L&s?new _n:void 0;for(ie.set(p,I),ie.set(I,p);++pt<Xe;){var _t=p[pt],bt=I[pt];if(k)var Ht=Ne?k(bt,_t,pt,I,p,ie):k(_t,bt,pt,p,I,ie);if(Ht!==void 0){if(Ht)continue;Et=!1;break}if(it){if(!we(I,function(Lt,rr){if(!ye(it,rr)&&(_t===Lt||Ie(_t,Lt,L,k,ie)))return it.push(rr)})){Et=!1;break}}else if(!(_t===bt||Ie(_t,bt,L,k,ie))){Et=!1;break}}return ie.delete(p),ie.delete(I),Et}function Z_(p,I,L,k,Ie,ie,Ne){switch(L){case J:if(p.byteLength!=I.byteLength||p.byteOffset!=I.byteOffset)return!1;p=p.buffer,I=I.buffer;case G:return!(p.byteLength!=I.byteLength||!ie(new mt(p),new mt(I)));case l:case D:case N:return rc(+p,+I);case w:return p.name==I.name&&p.message==I.message;case S:case a:return p==I+"";case F:var Xe=le;case v:var rt=k&i;if(Xe||(Xe=ce),p.size!=I.size&&!rt)return!1;var Te=Ne.get(p);if(Te)return Te==I;k|=s,Ne.set(p,I);var pt=ec(Xe(p),Xe(I),k,Ie,ie,Ne);return Ne.delete(p),pt;case d:if(Be)return Be.call(p)==Be.call(I)}return!1}function Q_(p,I,L,k,Ie,ie){var Ne=L&i,Xe=tc(p),rt=Xe.length,Te=tc(I),pt=Te.length;if(rt!=pt&&!Ne)return!1;for(var Et=rt;Et--;){var it=Xe[Et];if(!(Ne?it in I:ne.call(I,it)))return!1}var _t=ie.get(p);if(_t&&ie.get(I))return _t==I;var bt=!0;ie.set(p,I),ie.set(I,p);for(var Ht=Ne;++Et<rt;){it=Xe[Et];var Lt=p[it],rr=I[it];if(k)var ac=Ne?k(rr,Lt,it,I,p,ie):k(Lt,rr,it,p,I,ie);if(!(ac===void 0?Lt===rr||Ie(Lt,rr,L,k,ie):ac)){bt=!1;break}Ht||(Ht=it=="constructor")}if(bt&&!Ht){var mn=p.constructor,En=I.constructor;mn!=En&&"constructor"in p&&"constructor"in I&&!(typeof mn=="function"&&mn instanceof mn&&typeof En=="function"&&En instanceof En)&&(bt=!1)}return ie.delete(p),ie.delete(I),bt}function tc(p){return W_(p,h1,t1)}function vn(p,I){var L=p.__data__;return n1(I)?L[typeof I=="string"?"string":"hash"]:L.map}function hr(p,I){var L=pe(p,I);return Y_(L)?L:void 0}function e1(p){var I=ne.call(p,dt),L=p[dt];try{p[dt]=void 0;var k=!0}catch{}var Ie=ve.call(p);return k&&(I?p[dt]=L:delete p[dt]),Ie}var t1=Qt?function(p){return p==null?[]:(p=Object(p),_e(Qt(p),function(I){return Tt.call(p,I)}))}:f1,qt=Br;(Ue&&qt(new Ue(new ArrayBuffer(1)))!=J||Re&&qt(new Re)!=F||$e&&qt($e.resolve())!=A||Me&&qt(new Me)!=v||je&&qt(new je)!=q)&&(qt=function(p){var I=Br(p),L=I==x?p.constructor:void 0,k=L?tr(L):"";if(k)switch(k){case Ke:return J;case Ve:return F;case Ge:return A;case We:return v;case ke:return q}return I});function r1(p,I){return I=I??o,!!I&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<I}function n1(p){var I=typeof p;return I=="string"||I=="number"||I=="symbol"||I=="boolean"?p!=="__proto__":p===null}function i1(p){return!!be&&be in p}function s1(p){var I=p&&p.constructor,L=typeof I=="function"&&I.prototype||te;return p===L}function o1(p){return ve.call(p)}function tr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function rc(p,I){return p===I||p!==p&&I!==I}var a1=Za(function(){return arguments}())?Za:function(p){return zr(p)&&ne.call(p,"callee")&&!Tt.call(p,"callee")},wn=Array.isArray;function c1(p){return p!=null&&ic(p.length)&&!nc(p)}var zi=jr||l1;function u1(p,I){return Qa(p,I)}function nc(p){if(!sc(p))return!1;var I=Br(p);return I==m||I==E||I==h||I==y}function ic(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=o}function sc(p){var I=typeof p;return p!=null&&(I=="object"||I=="function")}function zr(p){return p!=null&&typeof p=="object"}var oc=fe?Pe(fe):J_;function h1(p){return c1(p)?G_(p):X_(p)}function f1(){return[]}function l1(){return!1}t.exports=u1})(Ai,Ai.exports);var Mg=Ai.exports,jg=Object.defineProperty,da=Object.getOwnPropertySymbols,Bg=Object.prototype.hasOwnProperty,zg=Object.prototype.propertyIsEnumerable,pa=(t,e,r)=>e in t?jg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ot=(t,e)=>{for(var r in e||(e={}))Bg.call(e,r)&&pa(t,r,e[r]);if(da)for(var r of da(e))zg.call(e,r)&&pa(t,r,e[r]);return t};function qg(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var c=t.length,f=t.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function D(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 F=0,N=0,B=0,x=E.length;B!==x&&E[B]===0;)B++,F++;for(var A=(x-B)*l+1>>>0,y=new Uint8Array(A);B!==x;){for(var S=E[B],v=0,a=A-1;(S!==0||v<N)&&a!==-1;a--,v++)S+=256*y[a]>>>0,y[a]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=v,B++}for(var d=A-N;d!==A&&y[d]===0;)d++;for(var M=f.repeat(F);d<A;++d)M+=t.charAt(y[d]);return M}function w(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var F=0;if(E[F]!==" "){for(var N=0,B=0;E[F]===f;)N++,F++;for(var x=(E.length-F)*h+1>>>0,A=new Uint8Array(x);E[F];){var y=r[E.charCodeAt(F)];if(y===255)return;for(var S=0,v=x-1;(y!==0||S<B)&&v!==-1;v--,S++)y+=c*A[v]>>>0,A[v]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=S,F++}if(E[F]!==" "){for(var a=x-B;a!==x&&A[a]===0;)a++;for(var d=new Uint8Array(N+(x-a)),M=N;a!==x;)d[M++]=A[a++];return d}}}function m(E){var F=w(E);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:w,decode:m}}var Hg=qg,Kg=Hg;const ga=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")},Vg=t=>new TextEncoder().encode(t),Gg=t=>new TextDecoder().decode(t);class Wg{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class kg{constructor(e,r,n){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=n}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 ya(this,e)}}class Yg{constructor(e){this.decoders=e}or(e){return ya(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ya=(t,e)=>new Yg(ot(ot({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Jg{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Wg(e,r,n),this.decoder=new kg(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const fn=({name:t,prefix:e,encode:r,decode:n})=>new Jg(t,e,r,n),Ur=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Kg(r,e);return fn({prefix:t,name:e,encode:n,decode:s=>ga(i(s))})},Xg=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,c+=r,c>=8&&(c-=8,o[h++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return o},Zg=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],o+=8;o>r;)o-=r,s+=e[i&c>>o];if(o&&(s+=e[i&c<<r-o]),n)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>fn({prefix:e,name:t,encode(i){return Zg(i,n,r)},decode(i){return Xg(i,n,r,t)}}),Qg=fn({prefix:"\0",name:"identity",encode:t=>Gg(t),decode:t=>Vg(t)});var ey=Object.freeze({__proto__:null,identity:Qg});const ty=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ry=Object.freeze({__proto__:null,base2:ty});const ny=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var iy=Object.freeze({__proto__:null,base8:ny});const sy=Ur({prefix:"9",name:"base10",alphabet:"0123456789"});var oy=Object.freeze({__proto__:null,base10:sy});const ay=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),cy=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var uy=Object.freeze({__proto__:null,base16:ay,base16upper:cy});const hy=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fy=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ly=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),dy=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),py=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gy=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yy=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_y=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),by=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vy=Object.freeze({__proto__:null,base32:hy,base32upper:fy,base32pad:ly,base32padupper:dy,base32hex:py,base32hexupper:gy,base32hexpad:yy,base32hexpadupper:_y,base32z:by});const wy=Ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),my=Ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ey=Object.freeze({__proto__:null,base36:wy,base36upper:my});const Dy=Ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sy=Ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xy=Object.freeze({__proto__:null,base58btc:Dy,base58flickr:Sy});const Oy=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Iy=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ay=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ty=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Py=Object.freeze({__proto__:null,base64:Oy,base64pad:Iy,base64url:Ay,base64urlpad:Ty});const _a=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}"),Ry=_a.reduce((t,e,r)=>(t[r]=e,t),[]),Cy=_a.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ny(t){return t.reduce((e,r)=>(e+=Ry[r],e),"")}function Fy(t){const e=[];for(const r of t){const n=Cy[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Ly=fn({prefix:"\u{1F680}",name:"base256emoji",encode:Ny,decode:Fy});var Uy=Object.freeze({__proto__:null,base256emoji:Ly}),$y=va,ba=128,My=127,jy=~My,By=Math.pow(2,31);function va(t,e,r){e=e||[],r=r||0;for(var n=r;t>=By;)e[r++]=t&255|ba,t/=128;for(;t&jy;)e[r++]=t&255|ba,t>>>=7;return e[r]=t|0,va.bytes=r-n+1,e}var zy=Ti,qy=128,wa=127;function Ti(t,n){var r=0,n=n||0,i=0,s=n,o,c=t.length;do{if(s>=c)throw Ti.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&wa)<<i:(o&wa)*Math.pow(2,i),i+=7}while(o>=qy);return Ti.bytes=s-n,r}var Hy=Math.pow(2,7),Ky=Math.pow(2,14),Vy=Math.pow(2,21),Gy=Math.pow(2,28),Wy=Math.pow(2,35),ky=Math.pow(2,42),Yy=Math.pow(2,49),Jy=Math.pow(2,56),Xy=Math.pow(2,63),Zy=function(t){return t<Hy?1:t<Ky?2:t<Vy?3:t<Gy?4:t<Wy?5:t<ky?6:t<Yy?7:t<Jy?8:t<Xy?9:10},Qy={encode:$y,decode:zy,encodingLength:Zy},ma=Qy;const Ea=(t,e,r=0)=>(ma.encode(t,e,r),e),Da=t=>ma.encodingLength(t),Pi=(t,e)=>{const r=e.byteLength,n=Da(t),i=n+Da(r),s=new Uint8Array(i+r);return Ea(t,s,0),Ea(r,s,n),s.set(e,i),new e0(t,r,e,s)};class e0{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Sa=({name:t,code:e,encode:r})=>new t0(t,e,r);class t0{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Pi(this.code,r):r.then(n=>Pi(this.code,n))}else throw Error("Unknown type, must be binary type")}}const xa=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),r0=Sa({name:"sha2-256",code:18,encode:xa("SHA-256")}),n0=Sa({name:"sha2-512",code:19,encode:xa("SHA-512")});var i0=Object.freeze({__proto__:null,sha256:r0,sha512:n0});const Oa=0,s0="identity",Ia=ga;var o0=Object.freeze({__proto__:null,identity:{code:Oa,name:s0,encode:Ia,digest:t=>Pi(Oa,Ia(t))}});new TextEncoder,new TextDecoder;const Aa=ot(ot(ot(ot(ot(ot(ot(ot(ot(ot({},ey),ry),iy),oy),uy),vy),Ey),xy),Py),Uy);ot(ot({},i0),o0);function a0(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ta(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Pa=Ta("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ri=Ta("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=a0(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),c0=ot({utf8:Pa,"utf-8":Pa,hex:Aa.base16,latin1:Ri,ascii:Ri,binary:Ri},Aa);function u0(t,e="utf8"){const r=c0[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}`)}const Ra="wc",h0=2,Ci="core",jt=`${Ra}@${2}:${Ci}:`,f0={name:Ci,logger:"error"},l0={database:":memory:"},d0="crypto",Ca="client_ed25519_seed",p0=Z.ONE_DAY,g0="keychain",y0="0.3",_0="messages",b0="0.3",v0=Z.SIX_HOURS,w0="publisher",Na="irn",m0="error",E0="wss://relay.walletconnect.com",D0="relayer",at={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},S0="_subscription",ln={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Fa=Z.ONE_SECOND,x0="2.3.0",O0="0.3",Ot={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},I0="subscription",A0="0.3",T0=Z.FIVE_SECONDS*1e3,P0="pairing",R0="0.3",$r={wc_pairingDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:0},res:{ttl:Z.ONE_DAY,prompt:!1,tag:0}}},It={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},C0="history",N0="0.3",F0="expirer",yt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},L0="0.3";class U0{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=g0,this.version=y0,this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,xo(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $0{constructor(e,r,n){this.core=e,this.logger=r,this.name=d0,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=fa(i);return ha(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=Dl();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=fa(s),c=oi();return await Ng(c,i,p0,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const c=this.getPrivateKey(i),f=Sl(c,s);return this.setSymKey(f,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||xl(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const c=vo(o),f=pr(s);if(wo(c)){const w=c.senderPublicKey,m=c.receiverPublicKey;i=await this.generateSharedKey(w,m)}const h=this.getSymKey(i),{type:l,senderPublicKey:D}=c;return Il({type:l,symKey:h,message:f,senderPublicKey:D})},this.decode=async(i,s,o)=>{this.isInitialized();const c=Pl(s,o);if(wo(c)){const l=c.receiverPublicKey,D=c.senderPublicKey;i=await this.generateSharedKey(l,D)}const f=this.getSymKey(i),h=Al({symKey:f,encoded:s});return Rn(h)},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.keychain=n||new U0(this.core,this.logger)}get context(){return xe.getLoggerContext(this.logger)}getPayloadType(e){const r=ci(e);return mr(r.type)}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(Ca)}catch{e=oi(),await this.keychain.set(Ca,e)}return u0(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class M0 extends lg{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=_0,this.version=b0,this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=ai(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=ai(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=xe.generateChildLogger(e,this.name),this.core=r}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,xo(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class j0 extends dg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Ze.exports.EventEmitter,this.name=w0,this.queue=new Map,this.publishTimeout=1e4,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const o=s?.ttl||v0,c=ui(s),f=s?.prompt||!1,h=s?.tag||0,l={topic:n,message:i,opts:{ttl:o,relay:c,prompt:f,tag:h}},D=ai(i);this.queue.set(D,l);try{await await Io(this.rpcPublish(n,i,o,c,f,h),this.publishTimeout),this.relayer.events.emit(at.publish,l)}catch{this.logger.debug("Publishing Payload stalled"),this.relayer.events.emit(at.connection_stalled);return}this.onPublish(D,l),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(o){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(o),o}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=xe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return xe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,o){var c,f,h,l;const D={method:hi(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o}};return gt((c=D.params)==null?void 0:c.prompt)&&((f=D.params)==null||delete f.prompt),gt((h=D.params)==null?void 0:h.tag)&&((l=D.params)==null||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class B0{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var z0=Object.defineProperty,q0=Object.defineProperties,H0=Object.getOwnPropertyDescriptors,La=Object.getOwnPropertySymbols,K0=Object.prototype.hasOwnProperty,V0=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?z0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dn=(t,e)=>{for(var r in e||(e={}))K0.call(e,r)&&Ua(t,r,e[r]);if(La)for(var r of La(e))V0.call(e,r)&&Ua(t,r,e[r]);return t},Ni=(t,e)=>q0(t,H0(e));class G0 extends yg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new B0,this.events=new Ze.exports.EventEmitter,this.name=I0,this.version=A0,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=jt,this.subscribeTimeout=1e4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=ui(i),o={topic:n,relay:s};this.pending.set(n,o);const c=await this.rpcSubscribe(n,s);return this.onSubscribe(c,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),c}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const o=new Z.Watch;o.start(this.pendingSubscriptionWatchLabel);const c=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(c),o.stop(this.pendingSubscriptionWatchLabel),i(!0)),o.elapsed(this.pendingSubscriptionWatchLabel)>=T0&&(clearInterval(c),o.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.restart=async()=>{await this.restore(),await this.reset()},this.relayer=e,this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=ui(n);await this.rpcUnsubscribe(e,r,i);const s=ze("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:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r){const n={method:hi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await Io(this.relayer.provider.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(at.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:hi(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,Ni(dn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Ni(dn({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(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,dn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ot.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:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ot.deleted,Ni(dn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ot.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(Ot.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),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 resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.relayer.transportExplicitlyClosed||this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.on(at.connect,async()=>{await this.onConnect()}),this.relayer.on(at.disconnect,()=>{this.onDisconnect()}),this.events.on(Ot.created,async e=>{const r=Ot.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Ot.deleted,async e=>{const r=Ot.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var W0=Object.defineProperty,$a=Object.getOwnPropertySymbols,k0=Object.prototype.hasOwnProperty,Y0=Object.prototype.propertyIsEnumerable,Ma=(t,e,r)=>e in t?W0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,J0=(t,e)=>{for(var r in e||(e={}))k0.call(e,r)&&Ma(t,r,e[r]);if($a)for(var r of $a(e))Y0.call(e,r)&&Ma(t,r,e[r]);return t};class X0 extends pg{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ze.exports.EventEmitter,this.name=D0,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?xe.generateChildLogger(e.logger,this.name):sn(xe.getDefaultLoggerOptions({level:e.logger||m0})),this.messages=new M0(this.logger,e.core),this.subscriber=new G0(this,this.logger),this.publisher=new j0(this,this.logger),this.relayUrl=e?.relayUrl||E0,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.transportOpen(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return xe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){this.isInitialized();let n="";return await Promise.all([new Promise(i=>{this.subscriber.once(Ot.created,s=>{s.topic===e&&i()})}),new Promise(async i=>{n=await this.subscriber.subscribe(e,r),i()})]),n}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 transportClose(){this.transportExplicitlyClosed=!0,this.connected&&await this.provider.disconnect(),this.events.emit(at.transport_closed)}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1;try{await Promise.all([new Promise(r=>{this.initialized||r(),this.subscriber.once(Ot.resubscribed,()=>{r()})}),await Promise.race([this.provider.connect(),new Promise((r,n)=>this.once(at.transport_closed,()=>{n(new Error("closeTransport called before connection was established"))}))])])}catch(r){const n=r;if(!/socket hang up/i.test(n.message))throw new Error(n.message);this.logger.error(n),this.events.emit(at.transport_closed)}}async restartTransport(e){await this.transportClose(),await new Promise(r=>setTimeout(r,Fa)),await this.transportOpen(e)}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new Tn(new $g(Kl({sdkVersion:x0,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),In(e)){if(!e.method.endsWith(S0))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(J0({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(at.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Vr(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(ln.payload,e=>this.onProviderPayload(e)),this.provider.on(ln.connect,()=>{this.events.emit(at.connect)}),this.provider.on(ln.disconnect,()=>{this.events.emit(at.disconnect),this.attemptToReconnect()}),this.provider.on(ln.error,e=>this.events.emit(at.error,e)),this.events.on(at.connection_stalled,async()=>{await this.restartTransport()})}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.transportOpen()},Z.toMiliseconds(Fa))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Z0=Object.defineProperty,ja=Object.getOwnPropertySymbols,Q0=Object.prototype.hasOwnProperty,e_=Object.prototype.propertyIsEnumerable,Ba=(t,e,r)=>e in t?Z0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,za=(t,e)=>{for(var r in e||(e={}))Q0.call(e,r)&&Ba(t,r,e[r]);if(ja)for(var r of ja(e))e_.call(e,r)&&Ba(t,r,e[r]);return t};class pn extends gg{constructor(e,r,n,i=jt,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=O0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{fd(o)?this.map.set(o.id,o):ld(o)?this.map.set(o.topic,o):this.getKey&&o!==null&&!gt(o)&&this.map.set(this.getKey(o),o)}),this.cached=[],this.initialized=!0)},this.set=async(o,c)=>{this.isInitialized(),this.map.has(o)?await this.update(o,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:c}),this.map.set(o,c),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(c=>Object.keys(o).every(f=>Mg(c[f],o[f]))):this.values),this.update=async(o,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:c});const f=za(za({},this.getData(o)),c);this.map.set(o,f),await this.persist()},this.delete=async(o,c)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:c}),this.map.delete(o),await this.persist())},this.logger=xe.generateChildLogger(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}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){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}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}=V("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}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class t_{constructor(e,r){this.core=e,this.logger=r,this.name=P0,this.version=R0,this.events=new Ze.exports,this.initialized=!1,this.storagePrefix=jt,this.ignoredPayloadTypes=[kt],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=oi(),i=await this.core.crypto.setSymKey(n),s=St(Z.FIVE_MINUTES),o={protocol:Na},c={topic:i,expiry:s,relay:o,active:!1},f=td({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:o});return await this.pairings.set(i,c),await this.core.relayer.subscribe(i),this.core.expirer.set(i,s),{topic:i,uri:f}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:i,symKey:s,relay:o}=Ql(n.uri),c=St(Z.FIVE_MINUTES),f={topic:i,relay:o,expiry:c,active:!1};return await this.pairings.set(i,f),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:o}),this.core.expirer.set(i,c),n.activatePairing&&await this.activate({topic:i}),f},this.activate=async({topic:n})=>{this.isInitialized();const i=St(Z.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:i}),this.core.expirer.set(n,i)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:c,reject:f}=Yt();this.events.once(Fe("pairing_ping",s),({error:h})=>{h?f(h):c()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",ze("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const o=Kr(i,s),c=await this.core.crypto.encode(n,o),f=$r[i].req;return this.core.history.set(n,o),await this.core.relayer.publish(n,c,f),o.id},this.sendResult=async(n,i,s)=>{const o=Vr(n,s),c=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=$r[f.request.method].res;await this.core.relayer.publish(i,c,h),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=dr(n,s),c=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=$r[f.request.method]?$r[f.request.method].res:$r.unregistered_method.res;await this.core.relayer.publish(i,c,h),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,ze("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>Mt(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n,o=s.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit("pairing_ping",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Ct(i)?this.events.emit(Fe("pairing_ping",s),{}):wt(i)&&this.events.emit(Fe("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.sendResult(s,n,!0),await this.deletePairing(n),this.events.emit("pairing_delete",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const c=ze("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,c),this.logger.error(c)}catch(c){await this.sendError(s,n,c),this.logger.error(c)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(ze("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!ft(n)){const{message:i}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!hd(n.uri)){const{message:i}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!ft(n)){const{message:s}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!ft(n)){const{message:s}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!et(n,!1)){const{message:i}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(Mt(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.pairings=new pn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return xe.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(at.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const i=await this.core.crypto.decode(r,n);In(i)?(this.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):An(i)&&(await this.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.core.expirer.on(yt.expired,async e=>{const{topic:r}=To(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class r_ extends fg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Ze.exports.EventEmitter,this.name=C0,this.version=N0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(o.id,o),this.events.emit(It.created,o)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=wt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(It.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(It.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 n={topic:r.topic,request:Kr(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(It.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=V("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(It.created,e=>{const r=It.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(It.updated,e=>{const r=It.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(It.deleted,e=>{const r=It.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class n_ extends _g{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Ze.exports.EventEmitter,this.name=F0,this.version=L0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(yt.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(yt.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 Vl(e);if(typeof e=="number")return Gl(e);const{message:r}=V("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(yt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=V("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:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Z.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(yt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(yt.created,e=>{const r=yt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(yt.expired,e=>{const r=yt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(yt.deleted,e=>{const r=yt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var i_=Object.defineProperty,qa=Object.getOwnPropertySymbols,s_=Object.prototype.hasOwnProperty,o_=Object.prototype.propertyIsEnumerable,Ha=(t,e,r)=>e in t?i_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ka=(t,e)=>{for(var r in e||(e={}))s_.call(e,r)&&Ha(t,r,e[r]);if(qa)for(var r of qa(e))o_.call(e,r)&&Ha(t,r,e[r]);return t};class Fi extends hg{constructor(e){super(e),this.protocol=Ra,this.version=h0,this.name=Ci,this.events=new Ze.exports.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(xe.getDefaultLoggerOptions({level:e?.logger||f0.logger}));this.logger=xe.generateChildLogger(r,this.name),this.heartbeat=new Rr.HeartBeat,this.crypto=new $0(this,this.logger,e?.keychain),this.history=new r_(this,this.logger),this.expirer=new n_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new yp(Ka(Ka({},l0),e?.storageOptions)),this.relayer=new X0({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new t_(this,this.logger)}static async init(e){const r=new Fi(e);return await r.initialize(),r}get context(){return xe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}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.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 a_=Fi,Va="wc",Ga=2,Wa="client",Li=`${Va}@${Ga}:${Wa}:`,Ui={name:Wa,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},c_="proposal",u_="session",gn=Z.SEVEN_DAYS,h_="engine",Mr={wc_sessionPropose:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1115}}},$i={min:Z.FIVE_MINUTES,max:Z.SEVEN_DAYS},f_="request";var l_=Object.defineProperty,d_=Object.defineProperties,p_=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,g_=Object.prototype.hasOwnProperty,y_=Object.prototype.propertyIsEnumerable,Ya=(t,e,r)=>e in t?l_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nt=(t,e)=>{for(var r in e||(e={}))g_.call(e,r)&&Ya(t,r,e[r]);if(ka)for(var r of ka(e))y_.call(e,r)&&Ya(t,r,e[r]);return t},Mi=(t,e)=>d_(t,p_(e));class __ extends vg{constructor(e){super(e),this.name=h_,this.events=new Ze.exports,this.initialized=!1,this.ignoredPayloadTypes=[kt],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Mr)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let o=n,c,f=!1;if(o&&(f=this.client.core.pairing.pairings.get(o).active),!o||!f){const{topic:N,uri:B}=await this.client.core.pairing.create();o=N,c=B}const h=await this.client.core.crypto.generateKeyPair(),l={requiredNamespaces:i,relays:s??[{protocol:Na}],proposer:{publicKey:h,metadata:this.client.metadata}},{reject:D,resolve:w,done:m}=Yt();if(this.events.once(Fe("session_connect"),async({error:N,session:B})=>{if(N)D(N);else if(B){B.self.publicKey=h;const x=Mi(Nt({},B),{requiredNamespaces:B.requiredNamespaces});await this.client.session.set(B.topic,x),await this.setExpiry(B.topic,B.expiry),o&&await this.client.core.pairing.updateMetadata({topic:o,metadata:B.peer.metadata}),w(x)}}),!o){const{message:N}=V("NO_MATCHING_KEY",`connect() pairing topic: ${o}`);throw new Error(N)}const E=await this.sendRequest(o,"wc_sessionPropose",l),F=St(Z.FIVE_MINUTES);return await this.setProposal(E,Nt({id:E,expiry:F},l)),{uri:c,approval:m}},this.pair=async r=>(this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,o=this.client.proposal.get(n);let{pairingTopic:c,proposer:f,requiredNamespaces:h}=o;rn(h)||(h=sd(s,"approve()"),this.client.proposal.set(n,Mi(Nt({},o),{requiredNamespaces:h})));const l=await this.client.core.crypto.generateKeyPair(),D=f.publicKey,w=await this.client.core.crypto.generateSharedKey(l,D),m={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:St(gn)};await this.client.core.relayer.subscribe(w);const E=await this.sendRequest(w,"wc_sessionSettle",m),{done:F,resolve:N,reject:B}=Yt();this.events.once(Fe("session_approve",E),({error:A})=>{A?B(A):N(this.client.session.get(w))});const x=Mi(Nt({},m),{topic:w,acknowledged:!1,self:m.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:l});return await this.client.session.set(w,x),await this.setExpiry(w,St(gn)),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:x.peer.metadata}),c&&n&&(await this.sendResult(n,c,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,ze("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:c})),{topic:w,acknowledged:F}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,ze("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:o,resolve:c,reject:f}=Yt();return this.events.once(Fe("session_update",s),({error:h})=>{h?f(h):c()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:o}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:o,reject:c}=Yt();return this.events.once(Fe("session_extend",i),({error:f})=>{f?c(f):o()}),await this.setExpiry(n,St(gn)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s,expiry:o}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n},o),{done:f,resolve:h,reject:l}=Yt(o);return this.events.once(Fe("session_request",c),({error:D,result:w})=>{D?l(D):h(w)}),await f()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Ct(i)?await this.sendResult(s,n,i.result):wt(i)&&await this.sendError(s,n,i.error),this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0})},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:o,reject:c}=Yt();this.events.once(Fe("session_ping",i),({error:f})=>{f?c(f):o()}),await s()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",ze("USER_DISCONNECTED")),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>cd(n,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.deleteSession=async(r,n)=>{const{self:i}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await Promise.all([this.client.session.delete(r,ze("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.deleteSymKey(r),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deleteProposal=async(r,n)=>{await Promise.all([this.client.proposal.delete(r,ze("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.core.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.core.expirer.set(r,n.expiry)},this.setPendingSessionRequest=async r=>{const n=Mr.wc_sessionRequest.req.ttl,{id:i,topic:s,params:o}=r;await this.client.pendingRequest.set(i,{id:i,topic:s,params:o}),n&&this.client.core.expirer.set(i,St(n))},this.sendRequest=async(r,n,i,s)=>{const o=Kr(n,i),c=await this.client.core.crypto.encode(r,o),f=Mr[n].req;return s&&(f.ttl=s),this.client.core.history.set(r,o),this.client.core.relayer.publish(r,c,f),o.id},this.sendResult=async(r,n,i)=>{const s=Vr(r,i),o=await this.client.core.crypto.encode(n,s),c=await this.client.core.history.get(n,r),f=Mr[c.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=dr(r,i),o=await this.client.core.crypto.encode(n,s),c=await this.client.core.history.get(n,r),f=Mr[c.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{Mt(i.expiry)&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Mt(i.expiry)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession(i)),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.core.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Nt({},n.params));const o=St(Z.FIVE_MINUTES),c=Nt({id:s,pairingTopic:r,expiry:o},i);await this.setProposal(s,c),this.client.events.emit("session_proposal",{id:s,params:c})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Ct(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const o=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:o});const c=o.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const f=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const h=await this.client.core.crypto.generateSharedKey(c,f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:h});const l=await this.client.core.relayer.subscribe(h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else wt(n)&&(await this.client.proposal.delete(i,ze("USER_DISCONNECTED")),this.events.emit(Fe("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:c,expiry:f,namespaces:h,requiredNamespaces:l}=n.params,D={topic:r,relay:o,expiry:f,namespaces:h,acknowledged:!0,requiredNamespaces:l,controller:c.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:c.publicKey,metadata:c.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Fe("session_connect"),{session:D})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Ct(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Fe("session_approve",i),{})):wt(n)&&(await this.client.session.delete(r,ze("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Nt({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_update",i),{}):wt(n)&&this.events.emit(Fe("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,St(gn)),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_extend",i),{}):wt(n)&&this.events.emit(Fe("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;setTimeout(()=>{Ct(n)?this.events.emit(Fe("session_ping",i),{}):wt(n)&&this.events.emit(Fe("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Nt({topic:r},s)),await this.setPendingSessionRequest({id:i,topic:r,params:s}),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_request",i),{result:n.result}):wt(n)&&this.events.emit(Fe("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Nt({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.isValidConnect=async r=>{if(!ft(r)){const{message:c}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;if(gt(n)||await this.isValidPairingTopic(n),!gt(i)&&rn(i)===0)return;const o=vd(i,"connect()");if(o)throw new Error(o.message);if(!wd(s,!0)){const{message:c}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(c)}},this.isValidApprove=async r=>{if(!ft(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const o=this.client.proposal.get(n),c=nn(i,"approve()");if(c)throw new Error(c.message);const f=Uo(o.requiredNamespaces,i,"update()");if(f)throw new Error(f.message);if(!et(s,!0)){const{message:h}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}},this.isValidReject=async r=>{if(!ft(r)){const{message:s}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!Ed(i)){const{message:s}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!ft(r)){const{message:h}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!Fo(n)){const{message:h}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const c=dd(i,"onSessionSettleRequest()");if(c)throw new Error(c.message);const f=nn(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(Mt(o)){const{message:h}=V("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!ft(r)){const{message:f}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(f)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=nn(i,"update()");if(o)throw new Error(o.message);const c=Uo(s.requiredNamespaces,i,"update()");if(c)throw new Error(c.message)},this.isValidExtend=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!ft(r)){const{message:f}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(f)}const{topic:n,request:i,chainId:s,expiry:o}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!Lo(c,s)){const{message:f}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Dd(i)){const{message:f}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(f)}if(!Od(c,s,i.method)){const{message:f}=V("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(f)}if(o&&!Ad(o,$i)){const{message:f}=V("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${$i.min} and ${$i.max}`);throw new Error(f)}},this.isValidRespond=async r=>{if(!ft(r)){const{message:s}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!Sd(i)){const{message:s}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!ft(r)){const{message:c}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(c)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!Lo(o,s)){const{message:c}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(c)}if(!xd(i)){const{message:c}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(c)}if(!Id(o,s,i.name)){const{message:c}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(c)}},this.isValidDisconnect=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(at.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const i=await this.client.core.crypto.decode(r,n);In(i)?(this.client.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):An(i)&&(await this.client.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.core.expirer.on(yt.expired,async e=>{const{topic:r,id:n}=To(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):n&&await this.deleteProposal(n,!0)})}isValidPairingTopic(e){if(!et(e,!1)){const{message:r}=V("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}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!et(e,!1)){const{message:r}=V("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=V("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(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(et(e,!1)){const{message:r}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!md(e)){const{message:r}=V("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class b_ extends pn{constructor(e,r){super(e,r,c_,Li),this.core=e,this.logger=r}}class v_ extends pn{constructor(e,r){super(e,r,u_,Li),this.core=e,this.logger=r}}class w_ extends pn{constructor(e,r){super(e,r,f_,Li),this.core=e,this.logger=r}}class ji extends bg{constructor(e){super(e),this.protocol=Va,this.version=Ga,this.name=Ui.name,this.events=new Ze.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||Ui.name,this.metadata=e?.metadata||Bl();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(xe.getDefaultLoggerOptions({level:e?.logger||Ui.logger}));this.core=e?.core||new a_(e),this.logger=xe.generateChildLogger(r,this.name),this.session=new v_(this.core,this.logger),this.proposal=new b_(this.core,this.logger),this.pendingRequest=new w_(this.core,this.logger),this.engine=new __(this)}static async init(e){const r=new ji(e);return await r.initialize(),r}get context(){return xe.getLoggerContext(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.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}function m_(t){return typeof t<"u"&&typeof t.context<"u"}const At={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class E_ extends Wc{constructor(e){super(),this.events=new Ze.exports.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?ti(this.session.namespaces):ml(this.requiredNamespaces)}get accounts(){return this.session?ei(this.session.namespaces):[]}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(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(At.uri,{uri:n}),this.session=await i(),this.events.emit(At.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:ze("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",Vr(e.id,n))).catch(n=>this.events.emit("payload",dr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(At.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(m_(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await ji.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(At.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(At.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(At.updated,this.session)))}),this.client.on("session_delete",e=>{var r;this.session&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(At.deleted,this.session),this.session=void 0))}))}}const D_=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],S_=["chainChanged","accountsChanged"];function Ja(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Xa(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Bi([t])]),r}function Bi(t){return Number(t[0].split(":")[1])}class x_{constructor(e){this.events=new Ze.exports.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Ja(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Bi(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}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}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(At.created,e=>{const r=ti(e.namespaces,[this.namespace]);this.setChainIds(r);const n=ei(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(At.updated,e=>{const r=ti(e.namespaces,[this.namespace]);this.setChainIds(r);const n=ei(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(At.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new E_({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new Tn(r)}setHttpProvider(e){const r=Xa(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new Tn(new eu(r))}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(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}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)}}vt.default=x_,vt.getEthereumChainId=Bi,vt.getRpcConfig=Ja,vt.getRpcUrl=Xa,vt.signerEvents=S_,vt.signerMethods=D_,Object.defineProperty(vt,"__esModule",{value:!0})});
67
67
  //# sourceMappingURL=index.umd.js.map