UNPKG

starknetkit

Version:

<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>

35 lines 436 kB
"use strict";var jl=Object.defineProperty;var zl=(t,e,r)=>e in t?jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Te=(t,e,r)=>(zl(t,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xt=require("./connector-391e8980.cjs"),kl=require("./___vite-browser-external_commonjs-proxy-1b5efd4f.cjs"),ur=require("./Modal-47eb0709.cjs"),Dr=require("starknet"),pc=require("./index-d90e48e0.cjs");require("./trpc-6791c117.cjs");require("./lastConnected-2e5632be.cjs");require("./argentX.cjs");require("./index-aa5c5f7b.cjs");require("./braavos.cjs");require("./core-aa9478e0.cjs");var qo={exports:{}},xi=typeof Reflect=="object"?Reflect:null,Ea=xi&&typeof xi.apply=="function"?xi.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Qn;xi&&typeof xi.ownKeys=="function"?Qn=xi.ownKeys:Object.getOwnPropertySymbols?Qn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Qn=function(e){return Object.getOwnPropertyNames(e)};function $l(t){console&&console.warn&&console.warn(t)}var gc=Number.isNaN||function(e){return e!==e};function Ye(){Ye.init.call(this)}qo.exports=Ye;qo.exports.once=Gl;Ye.EventEmitter=Ye;Ye.prototype._events=void 0;Ye.prototype._eventsCount=0;Ye.prototype._maxListeners=void 0;var _a=10;function ws(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ye,"defaultMaxListeners",{enumerable:!0,get:function(){return _a},set:function(t){if(typeof t!="number"||t<0||gc(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");_a=t}});Ye.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};Ye.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||gc(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 mc(t){return t._maxListeners===void 0?Ye.defaultMaxListeners:t._maxListeners}Ye.prototype.getMaxListeners=function(){return mc(this)};Ye.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var h=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw h.context=o,h}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")Ea(l,this,r);else for(var c=l.length,g=Ec(l,c),i=0;i<c;++i)Ea(g[i],this,r);return!0};function yc(t,e,r,i){var n,s,o;if(ws(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=mc(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,$l(h)}return t}Ye.prototype.addListener=function(e,r){return yc(this,e,r,!1)};Ye.prototype.on=Ye.prototype.addListener;Ye.prototype.prependListener=function(e,r){return yc(this,e,r,!0)};function Kl(){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 wc(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Kl.bind(i);return n.listener=r,i.wrapFn=n,n}Ye.prototype.once=function(e,r){return ws(r),this.on(e,wc(this,e,r)),this};Ye.prototype.prependOnceListener=function(e,r){return ws(r),this.prependListener(e,wc(this,e,r)),this};Ye.prototype.removeListener=function(e,r){var i,n,s,o,h;if(ws(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){h=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Hl(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,h||r)}return this};Ye.prototype.off=Ye.prototype.removeListener;Ye.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function vc(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?Vl(n):Ec(n,n.length)}Ye.prototype.listeners=function(e){return vc(this,e,!0)};Ye.prototype.rawListeners=function(e){return vc(this,e,!1)};Ye.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):bc.call(t,e)};Ye.prototype.listenerCount=bc;function bc(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}Ye.prototype.eventNames=function(){return this._eventsCount>0?Qn(this._events):[]};function Ec(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Hl(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Vl(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Gl(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}_c(t,e,s,{once:!0}),e!=="error"&&Ql(t,n,{once:!0})})}function Ql(t,e,r){typeof t.on=="function"&&_c(t,"error",e,r)}function _c(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Gt=qo.exports;const Ac=xt.getDefaultExportFromCjs(Gt),Yl=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Wl=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Jl=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Xl(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Zl(t);return}return e}function Zl(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function jn(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!Jl.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Yl.test(t)||Wl.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Xl)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function ef(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function gt(t,...e){try{return ef(t(...e))}catch(r){return Promise.reject(r)}}function tf(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function rf(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Yn(t){if(tf(t))return String(t);if(rf(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Yn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Sc(){if(typeof Buffer===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const go="base64:";function nf(t){if(typeof t=="string")return t;Sc();const e=Buffer.from(t).toString("base64");return go+e}function sf(t){return typeof t!="string"||!t.startsWith(go)?t:(Sc(),Buffer.from(t.slice(go.length),"base64"))}function Lt(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function of(...t){return Lt(t.join(":"))}function zn(t){return t=Lt(t),t?t+":":""}const af="memory",hf=()=>{const t=new Map;return{name:af,options:{},hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return Array.from(t.keys())},clear(){t.clear()},dispose(){t.clear()}}};function cf(t={}){const e={mounts:{"":t.driver||hf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=c=>{for(const g of e.mountpoints)if(c.startsWith(g))return{base:g,relativeKey:c.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,g)=>e.mountpoints.filter(w=>w.startsWith(c)||g&&c.startsWith(w)).map(w=>({relativeBase:c.length>w.length?c.slice(w.length):void 0,mountpoint:w,driver:e.mounts[w]})),n=(c,g)=>{if(e.watching){g=Lt(g);for(const w of e.watchListeners)w(c,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await Aa(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},h=(c,g,w)=>{const E=new Map,b=S=>{let B=E.get(S.base);return B||(B={driver:S.driver,base:S.base,items:[]},E.set(S.base,B)),B};for(const S of c){const B=typeof S=="string",j=Lt(B?S:S.key),$=B?void 0:S.value,U=B||!S.options?g:{...g,...S.options},q=r(j);b(q).items.push({key:j,value:$,relativeKey:q.relativeKey,options:U})}return Promise.all([...E.values()].map(S=>w(S))).then(S=>S.flat())},l={hasItem(c,g={}){c=Lt(c);const{relativeKey:w,driver:E}=r(c);return gt(E.hasItem,w,g)},getItem(c,g={}){c=Lt(c);const{relativeKey:w,driver:E}=r(c);return gt(E.getItem,w,g).then(b=>jn(b))},getItems(c,g){return h(c,g,w=>w.driver.getItems?gt(w.driver.getItems,w.items.map(E=>({key:E.relativeKey,options:E.options})),g).then(E=>E.map(b=>({key:of(w.base,b.key),value:jn(b.value)}))):Promise.all(w.items.map(E=>gt(w.driver.getItem,E.relativeKey,E.options).then(b=>({key:E.key,value:jn(b)})))))},getItemRaw(c,g={}){c=Lt(c);const{relativeKey:w,driver:E}=r(c);return E.getItemRaw?gt(E.getItemRaw,w,g):gt(E.getItem,w,g).then(b=>sf(b))},async setItem(c,g,w={}){if(g===void 0)return l.removeItem(c);c=Lt(c);const{relativeKey:E,driver:b}=r(c);b.setItem&&(await gt(b.setItem,E,Yn(g),w),b.watch||n("update",c))},async setItems(c,g){await h(c,g,async w=>{if(w.driver.setItems)return gt(w.driver.setItems,w.items.map(E=>({key:E.relativeKey,value:Yn(E.value),options:E.options})),g);w.driver.setItem&&await Promise.all(w.items.map(E=>gt(w.driver.setItem,E.relativeKey,Yn(E.value),E.options)))})},async setItemRaw(c,g,w={}){if(g===void 0)return l.removeItem(c,w);c=Lt(c);const{relativeKey:E,driver:b}=r(c);if(b.setItemRaw)await gt(b.setItemRaw,E,g,w);else if(b.setItem)await gt(b.setItem,E,nf(g),w);else return;b.watch||n("update",c)},async removeItem(c,g={}){typeof g=="boolean"&&(g={removeMeta:g}),c=Lt(c);const{relativeKey:w,driver:E}=r(c);E.removeItem&&(await gt(E.removeItem,w,g),(g.removeMeta||g.removeMata)&&await gt(E.removeItem,w+"$",g),E.watch||n("remove",c))},async getMeta(c,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),c=Lt(c);const{relativeKey:w,driver:E}=r(c),b=Object.create(null);if(E.getMeta&&Object.assign(b,await gt(E.getMeta,w,g)),!g.nativeOnly){const S=await gt(E.getItem,w+"$",g).then(B=>jn(B));S&&typeof S=="object"&&(typeof S.atime=="string"&&(S.atime=new Date(S.atime)),typeof S.mtime=="string"&&(S.mtime=new Date(S.mtime)),Object.assign(b,S))}return b},setMeta(c,g,w={}){return this.setItem(c+"$",g,w)},removeMeta(c,g={}){return this.removeItem(c+"$",g)},async getKeys(c,g={}){c=zn(c);const w=i(c,!0);let E=[];const b=[];for(const S of w){const j=(await gt(S.driver.getKeys,S.relativeBase,g)).map($=>S.mountpoint+Lt($)).filter($=>!E.some(U=>$.startsWith(U)));b.push(...j),E=[S.mountpoint,...E.filter($=>!$.startsWith(S.mountpoint))]}return c?b.filter(S=>S.startsWith(c)&&!S.endsWith("$")):b.filter(S=>!S.endsWith("$"))},async clear(c,g={}){c=zn(c),await Promise.all(i(c,!1).map(async w=>{if(w.driver.clear)return gt(w.driver.clear,w.relativeBase,g);if(w.driver.removeItem){const E=await w.driver.getKeys(w.relativeBase||"",g);return Promise.all(E.map(b=>w.driver.removeItem(b,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>Sa(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,g){if(c=zn(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((w,E)=>E.length-w.length)),e.mounts[c]=g,e.watching&&Promise.resolve(Aa(g,n,c)).then(w=>{e.unwatch[c]=w}).catch(console.error),l},async unmount(c,g=!0){c=zn(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c](),delete e.unwatch[c]),g&&await Sa(e.mounts[c]),e.mountpoints=e.mountpoints.filter(w=>w!==c),delete e.mounts[c])},getMount(c=""){c=Lt(c)+":";const g=r(c);return{driver:g.driver,base:g.base}},getMounts(c="",g={}){return c=Lt(c),i(c,g.parents).map(E=>({driver:E.driver,base:E.mountpoint}))}};return l}function Aa(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Sa(t){typeof t.dispose=="function"&&await gt(t.dispose)}function pi(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ic(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=pi(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Ls;function Sn(){return Ls||(Ls=Ic("keyval-store","keyval")),Ls}function Ia(t,e=Sn()){return e("readonly",r=>pi(r.get(t)))}function uf(t,e,r=Sn()){return r("readwrite",i=>(i.put(e,t),pi(i.transaction)))}function lf(t,e=Sn()){return e("readwrite",r=>(r.delete(t),pi(r.transaction)))}function ff(t=Sn()){return t("readwrite",e=>(e.clear(),pi(e.transaction)))}function df(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},pi(t.transaction)}function pf(t=Sn()){return t("readonly",e=>{if(e.getAllKeys)return pi(e.getAllKeys());const r=[];return df(e,i=>r.push(i.key)).then(()=>r)})}const gf=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),mf=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function vs(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return mf(t)}catch{return t}}function fi(t){return typeof t=="string"?t:gf(t)||""}const yf="idb-keyval";var wf=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Ic(t.dbName,t.storeName)),{name:yf,options:t,async hasItem(n){return!(typeof await Ia(r(n),i)>"u")},async getItem(n){return await Ia(r(n),i)??null},setItem(n,s){return uf(r(n),s,i)},removeItem(n){return lf(r(n),i)},getKeys(){return pf(i)},clear(){return ff(i)}}};const vf="WALLET_CONNECT_V2_INDEXED_DB",bf="keyvaluestorage";let Ef=class{constructor(){this.indexedDb=cf({driver:wf({dbName:vf,storeName:bf})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,fi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Wn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Us<"u"&&Us.localStorage?Wn.exports=Us.localStorage:typeof window<"u"&&window.localStorage?Wn.exports=window.localStorage:Wn.exports=new e})();function _f(t){var e;return[t[0],vs((e=t[1])!=null?e:"")]}let Af=class{constructor(){this.localStorage=Wn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(_f)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return vs(r)}async setItem(e,r){this.localStorage.setItem(e,fi(r))}async removeItem(e){this.localStorage.removeItem(e)}};const Sf="wc_storage_version",Da=1,If=async(t,e,r)=>{const i=Sf,n=await e.getItem(i);if(n&&n>=Da){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const h=s.shift();if(!h)continue;const l=h.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const c=await t.getItem(h);await e.setItem(h,c),o.push(h)}}await e.setItem(i,Da),r(e),Df(t,o)},Df=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let xf=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new Af;this.storage=e;try{const r=new Ef;If(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};var te={};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var mo=function(t,e){return mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},mo(t,e)};function Mf(t,e){mo(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var yo=function(){return yo=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},yo.apply(this,arguments)};function Nf(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Cf(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Of(t,e){return function(r,i){e(r,i,t)}}function Rf(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Pf(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function h(g){try{c(i.next(g))}catch(w){o(w)}}function l(g){try{c(i.throw(g))}catch(w){o(w)}}function c(g){g.done?s(g.value):n(g.value).then(h,l)}c((i=i.apply(t,e||[])).next())})}function Tf(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function h(c){return function(g){return l([c,g])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=c[0]&2?n.return:c[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,c[1])).done)return s;switch(n=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){r.label=c[1];break}if(c[0]===6&&r.label<s[1]){r.label=s[1],s=c;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(c);break}s[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(g){c=[6,g],n=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ff(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Lf(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function wo(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Dc(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(h){o={error:h}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function Uf(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Dc(arguments[e]));return t}function Bf(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,h=s.length;o<h;o++,n++)i[n]=s[o];return i}function yn(t){return this instanceof yn?(this.v=t,this):new yn(t)}function qf(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(E){i[E]&&(n[E]=function(b){return new Promise(function(S,B){s.push([E,b,S,B])>1||h(E,b)})})}function h(E,b){try{l(i[E](b))}catch(S){w(s[0][3],S)}}function l(E){E.value instanceof yn?Promise.resolve(E.value.v).then(c,g):w(s[0][2],E)}function c(E){h("next",E)}function g(E){h("throw",E)}function w(E,b){E(b),s.shift(),s.length&&h(s[0][0],s[0][1])}}function jf(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:yn(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function zf(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 wo=="function"?wo(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(h,l){o=t[s](o),n(h,l,o.done,o.value)})}}function n(s,o,h,l){Promise.resolve(l).then(function(c){s({value:c,done:h})},o)}}function kf(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $f(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 Kf(t){return t&&t.__esModule?t:{default:t}}function Hf(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}const Gf=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return yo},__asyncDelegator:jf,__asyncGenerator:qf,__asyncValues:zf,__await:yn,__awaiter:Pf,__classPrivateFieldGet:Hf,__classPrivateFieldSet:Vf,__createBinding:Ff,__decorate:Cf,__exportStar:Lf,__extends:Mf,__generator:Tf,__importDefault:Kf,__importStar:$f,__makeTemplateObject:kf,__metadata:Rf,__param:Of,__read:Dc,__rest:Nf,__spread:Uf,__spreadArrays:Bf,__values:wo},Symbol.toStringTag,{value:"Module"})),In=xt.getAugmentedNamespace(Gf);var Bs={},rn={},xa;function Qf(){if(xa)return rn;xa=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return rn.delay=t,rn}var ni={},qs={},si={},Ma;function Yf(){return Ma||(Ma=1,Object.defineProperty(si,"__esModule",{value:!0}),si.ONE_THOUSAND=si.ONE_HUNDRED=void 0,si.ONE_HUNDRED=100,si.ONE_THOUSAND=1e3),si}var js={},Na;function Wf(){return Na||(Na=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}(js)),js}var Ca;function xc(){return Ca||(Ca=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=In;e.__exportStar(Yf(),t),e.__exportStar(Wf(),t)}(qs)),qs}var Oa;function Jf(){if(Oa)return ni;Oa=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.fromMiliseconds=ni.toMiliseconds=void 0;const t=xc();function e(i){return i*t.ONE_THOUSAND}ni.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return ni.fromMiliseconds=r,ni}var Ra;function Xf(){return Ra||(Ra=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=In;e.__exportStar(Qf(),t),e.__exportStar(Jf(),t)}(Bs)),Bs}var bi={},Pa;function Zf(){if(Pa)return bi;Pa=1,Object.defineProperty(bi,"__esModule",{value:!0}),bi.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return bi.Watch=t,bi.default=t,bi}var zs={},nn={},Ta;function ed(){if(Ta)return nn;Ta=1,Object.defineProperty(nn,"__esModule",{value:!0}),nn.IWatch=void 0;class t{}return nn.IWatch=t,nn}var Fa;function td(){return Fa||(Fa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),In.__exportStar(ed(),t)}(zs)),zs}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=In;e.__exportStar(Xf(),t),e.__exportStar(Zf(),t),e.__exportStar(td(),t),e.__exportStar(xc(),t)})(te);class gi{}let rd=class extends gi{constructor(e){super()}};const La=te.FIVE_SECONDS,Dn={pulse:"heartbeat_pulse"};let id=class Mc extends rd{constructor(e){super(e),this.events=new Gt.EventEmitter,this.interval=La,this.interval=e?.interval||La}static async init(e){const r=new Mc(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),te.toMiliseconds(this.interval))}pulse(){this.events.emit(Dn.pulse)}};function nd(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var sd=od;function od(t,e,r){var i=r&&r.stringify||nd,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var h=1;h<s;h++)o[h]=i(e[h]);return o.join(" ")}if(typeof t!="string")return t;var l=e.length;if(l===0)return t;for(var c="",g=1-n,w=-1,E=t&&t.length||0,b=0;b<E;){if(t.charCodeAt(b)===37&&b+1<E){switch(w=w>-1?w:0,t.charCodeAt(b+1)){case 100:case 102:if(g>=l||e[g]==null)break;w<b&&(c+=t.slice(w,b)),c+=Number(e[g]),w=b+2,b++;break;case 105:if(g>=l||e[g]==null)break;w<b&&(c+=t.slice(w,b)),c+=Math.floor(Number(e[g])),w=b+2,b++;break;case 79:case 111:case 106:if(g>=l||e[g]===void 0)break;w<b&&(c+=t.slice(w,b));var S=typeof e[g];if(S==="string"){c+="'"+e[g]+"'",w=b+2,b++;break}if(S==="function"){c+=e[g].name||"<anonymous>",w=b+2,b++;break}c+=i(e[g]),w=b+2,b++;break;case 115:if(g>=l)break;w<b&&(c+=t.slice(w,b)),c+=String(e[g]),w=b+2,b++;break;case 37:w<b&&(c+=t.slice(w,b)),c+="%",w=b+2,b++,g--;break}++g}++b}return w===-1?t:(w<E&&(c+=t.slice(w)),c)}const Ua=sd;var Si=Or;const wn=md().console||{},ad={mapHttpRequest:kn,mapHttpResponse:kn,wrapRequestSerializer:ks,wrapResponseSerializer:ks,wrapErrorSerializer:ks,req:kn,res:kn,err:fd};function hd(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Or(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||wn;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=hd(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const h=t.level||"info",l=Object.create(r);l.log||(l.log=vn),Object.defineProperty(l,"levelVal",{get:g}),Object.defineProperty(l,"level",{get:w,set:E});const c={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:dd(t)};l.levels=Or.levels,l.level=h,l.setMaxListeners=l.getMaxListeners=l.emit=l.addListener=l.on=l.prependListener=l.once=l.prependOnceListener=l.removeListener=l.removeAllListeners=l.listeners=l.listenerCount=l.eventNames=l.write=l.flush=vn,l.serializers=i,l._serialize=n,l._stdErrSerialize=s,l.child=b,e&&(l._logEvent=vo());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function w(){return this._level}function E(S){if(S!=="silent"&&!this.levels.values[S])throw Error("unknown level "+S);this._level=S,Ei(c,l,"error","log"),Ei(c,l,"fatal","error"),Ei(c,l,"warn","error"),Ei(c,l,"info","log"),Ei(c,l,"debug","log"),Ei(c,l,"trace","log")}function b(S,B){if(!S)throw new Error("missing bindings for child Pino");B=B||{},n&&S.serializers&&(B.serializers=S.serializers);const j=B.serializers;if(n&&j){var $=Object.assign({},i,j),U=t.browser.serialize===!0?Object.keys($):n;delete S.serializers,bs([S],U,$,this._stdErrSerialize)}function q(C){this._childLevel=(C._childLevel|0)+1,this.error=_i(C,S,"error"),this.fatal=_i(C,S,"fatal"),this.warn=_i(C,S,"warn"),this.info=_i(C,S,"info"),this.debug=_i(C,S,"debug"),this.trace=_i(C,S,"trace"),$&&(this.serializers=$,this._serialize=U),e&&(this._logEvent=vo([].concat(C._logEvent.bindings,S)))}return q.prototype=this,new q(this)}return l}Or.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"}};Or.stdSerializers=ad;Or.stdTimeFunctions=Object.assign({},{nullTime:Nc,epochTime:Cc,unixTime:pd,isoTime:gd});function Ei(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?vn:n[r]?n[r]:wn[r]||wn[i]||vn,cd(t,e,r)}function cd(t,e,r){!t.transmit&&e[r]===vn||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),h=Object.getPrototypeOf&&Object.getPrototypeOf(this)===wn?wn:this;for(var l=0;l<o.length;l++)o[l]=arguments[l];if(t.serialize&&!t.asObject&&bs(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(h,ud(this,r,o,s)):i.apply(h,o),t.transmit){const c=t.transmit.level||e.level,g=Or.levels.values[c],w=Or.levels.values[r];if(w<g)return;ld(this,{ts:s,methodLevel:r,methodValue:w,transmitLevel:c,transmitValue:Or.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function ud(t,e,r,i){t._serialize&&bs(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Or.levels.values[e];let h=(t._childLevel|0)+1;if(h<1&&(h=1),s!==null&&typeof s=="object"){for(;h--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Ua(n.shift(),n):void 0}else typeof s=="string"&&(s=Ua(n.shift(),n));return s!==void 0&&(o.msg=s),o}function bs(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Or.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function _i(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function ld(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,h=e.val,l=t._logEvent.bindings;bs(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(c){return l.indexOf(c)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,h),t._logEvent=vo(l)}function vo(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function fd(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 dd(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Nc:Cc}function kn(){return{}}function ks(t){return t}function vn(){}function Nc(){return!1}function Cc(){return Date.now()}function pd(){return Math.round(Date.now()/1e3)}function gd(){return new Date(Date.now()).toISOString()}function md(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const Es=xt.getDefaultExportFromCjs(Si),yd={level:"info"},xn="custom_context",jo=1e3*1024;class wd{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}let Ba=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new wd(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}},Oc=class{constructor(e,r=jo){this.level=e??"error",this.levelValue=Si.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Ba(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Si.levels.values.error?console.error(e):r===Si.levels.values.warn?console.warn(e):r===Si.levels.values.debug?console.debug(e):r===Si.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(fi({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Ba(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(fi({extraMetadata:e})),new Blob(r,{type:"application/json"})}},vd=class{constructor(e,r=jo){this.baseChunkLogger=new Oc(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}},bd=class{constructor(e,r=jo){this.baseChunkLogger=new Oc(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var Ed=Object.defineProperty,_d=Object.defineProperties,Ad=Object.getOwnPropertyDescriptors,qa=Object.getOwnPropertySymbols,Sd=Object.prototype.hasOwnProperty,Id=Object.prototype.propertyIsEnumerable,ja=(t,e,r)=>e in t?Ed(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,is=(t,e)=>{for(var r in e||(e={}))Sd.call(e,r)&&ja(t,r,e[r]);if(qa)for(var r of qa(e))Id.call(e,r)&&ja(t,r,e[r]);return t},ns=(t,e)=>_d(t,Ad(e));function zo(t){return ns(is({},t),{level:t?.level||yd.level})}function Dd(t,e=xn){return t[e]||""}function xd(t,e,r=xn){return t[r]=e,t}function zt(t,e=xn){let r="";return typeof t.bindings>"u"?r=Dd(t,e):r=t.bindings().context||"",r}function Md(t,e,r=xn){const i=zt(t,r);return i.trim()?`${i}/${e}`:e}function kt(t,e,r=xn){const i=Md(t,e,r),n=t.child({context:i});return xd(n,i,r)}function Nd(t){var e,r;const i=new vd((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Es(ns(is({},t.opts),{level:"trace",browser:ns(is({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function Cd(t){var e;const r=new bd((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Es(ns(is({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function Od(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Nd(t):Cd(t)}let Rd=class extends gi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},Pd=class extends gi{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}},Td=class{constructor(e,r){this.logger=e,this.core=r}};class Fd extends gi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Ld extends gi{constructor(e){super()}}class Ud{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Bd extends gi{constructor(e,r){super(),this.relayer=e,this.logger=r}}let qd=class extends gi{constructor(e,r){super(),this.core=e,this.logger=r}},jd=class{constructor(e,r){this.projectId=e,this.logger=r}},zd=class{constructor(e,r){this.projectId=e,this.logger=r}},kd=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},$d=class{constructor(e){this.client=e}};var ko={},Ti={},_s={},As={};Object.defineProperty(As,"__esModule",{value:!0});As.BrowserRandomSource=void 0;const za=65536;class Kd{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 i=0;i<r.length;i+=za)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,za)));return r}}As.BrowserRandomSource=Kd;function Hd(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 Ss={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0});function Vd(t){for(var e=0;e<t.length;e++)t[e]=0;return t}Qt.wipe=Vd;Object.defineProperty(Ss,"__esModule",{value:!0});Ss.NodeRandomSource=void 0;const Gd=Qt;class Qd{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Hd<"u"){const e=kl.require$$1;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 i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=r[n];return(0,Gd.wipe)(r),i}}Ss.NodeRandomSource=Qd;Object.defineProperty(_s,"__esModule",{value:!0});_s.SystemRandomSource=void 0;const Yd=As,Wd=Ss;class Jd{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Yd.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Wd.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)}}_s.SystemRandomSource=Jd;var Fe={},Rc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(h,l){var c=h>>>16&65535,g=h&65535,w=l>>>16&65535,E=l&65535;return g*E+(c*E+g*w<<16>>>0)|0}t.mul=Math.imul||e;function r(h,l){return h+l|0}t.add=r;function i(h,l){return h-l|0}t.sub=i;function n(h,l){return h<<l|h>>>32-l}t.rotl=n;function s(h,l){return h<<32-l|h>>>l}t.rotr=s;function o(h){return typeof h=="number"&&isFinite(h)&&Math.floor(h)===h}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(h){return t.isInteger(h)&&h>=-t.MAX_SAFE_INTEGER&&h<=t.MAX_SAFE_INTEGER}})(Rc);Object.defineProperty(Fe,"__esModule",{value:!0});var Pc=Rc;function Xd(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}Fe.readInt16BE=Xd;function Zd(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}Fe.readUint16BE=Zd;function e0(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}Fe.readInt16LE=e0;function t0(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}Fe.readUint16LE=t0;function Tc(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}Fe.writeUint16BE=Tc;Fe.writeInt16BE=Tc;function Fc(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}Fe.writeUint16LE=Fc;Fe.writeInt16LE=Fc;function bo(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}Fe.readInt32BE=bo;function Eo(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}Fe.readUint32BE=Eo;function _o(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}Fe.readInt32LE=_o;function Ao(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}Fe.readUint32LE=Ao;function ss(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}Fe.writeUint32BE=ss;Fe.writeInt32BE=ss;function os(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}Fe.writeUint32LE=os;Fe.writeInt32LE=os;function r0(t,e){e===void 0&&(e=0);var r=bo(t,e),i=bo(t,e+4);return r*4294967296+i-(i>>31)*4294967296}Fe.readInt64BE=r0;function i0(t,e){e===void 0&&(e=0);var r=Eo(t,e),i=Eo(t,e+4);return r*4294967296+i}Fe.readUint64BE=i0;function n0(t,e){e===void 0&&(e=0);var r=_o(t,e),i=_o(t,e+4);return i*4294967296+r-(r>>31)*4294967296}Fe.readInt64LE=n0;function s0(t,e){e===void 0&&(e=0);var r=Ao(t,e),i=Ao(t,e+4);return i*4294967296+r}Fe.readUint64LE=s0;function Lc(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ss(t/4294967296>>>0,e,r),ss(t>>>0,e,r+4),e}Fe.writeUint64BE=Lc;Fe.writeInt64BE=Lc;function Uc(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),os(t>>>0,e,r),os(t/4294967296>>>0,e,r+4),e}Fe.writeUint64LE=Uc;Fe.writeInt64LE=Uc;function o0(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 i=0,n=1,s=t/8+r-1;s>=r;s--)i+=e[s]*n,n*=256;return i}Fe.readUintBE=o0;function a0(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 i=0,n=1,s=r;s<r+t/8;s++)i+=e[s]*n,n*=256;return i}Fe.readUintLE=a0;function h0(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Pc.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=t/8+i-1;s>=i;s--)r[s]=e/n&255,n*=256;return r}Fe.writeUintBE=h0;function c0(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Pc.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+t/8;s++)r[s]=e/n&255,n*=256;return r}Fe.writeUintLE=c0;function u0(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}Fe.readFloat32BE=u0;function l0(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}Fe.readFloat32LE=l0;function f0(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}Fe.readFloat64BE=f0;function d0(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}Fe.readFloat64LE=d0;function p0(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t),e}Fe.writeFloat32BE=p0;function g0(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t,!0),e}Fe.writeFloat32LE=g0;function m0(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t),e}Fe.writeFloat64BE=m0;function y0(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t,!0),e}Fe.writeFloat64LE=y0;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=_s,r=Fe,i=Qt;t.defaultRandomSource=new e.SystemRandomSource;function n(c,g=t.defaultRandomSource){return g.randomBytes(c)}t.randomBytes=n;function s(c=t.defaultRandomSource){const g=n(4,c),w=(0,r.readUint32LE)(g);return(0,i.wipe)(g),w}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(c,g=o,w=t.defaultRandomSource){if(g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");let E="";const b=g.length,S=256-256%b;for(;c>0;){const B=n(Math.ceil(c*256/S),w);for(let j=0;j<B.length&&c>0;j++){const $=B[j];$<S&&(E+=g.charAt($%b),c--)}(0,i.wipe)(B)}return E}t.randomString=h;function l(c,g=o,w=t.defaultRandomSource){const E=Math.ceil(c/(Math.log(g.length)/Math.LN2));return h(E,g,w)}t.randomStringForEntropy=l})(Ti);var Bc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Fe,r=Qt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var i=function(){function h(){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 h.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},h.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},h.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},h.prototype.update=function(l,c){if(c===void 0&&(c=l.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=c,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&c>0;)this._buffer[this._bufferLength++]=l[g++],c--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(c>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,l,g,c),c%=this.blockSize);c>0;)this._buffer[this._bufferLength++]=l[g++],c--;return this},h.prototype.finish=function(l){if(!this._finished){var c=this._bytesHashed,g=this._bufferLength,w=c/536870912|0,E=c<<3,b=c%128<112?128:256;this._buffer[g]=128;for(var S=g+1;S<b-8;S++)this._buffer[S]=0;e.writeUint32BE(w,this._buffer,b-8),e.writeUint32BE(E,this._buffer,b-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,b),this._finished=!0}for(var S=0;S<this.digestLength/8;S++)e.writeUint32BE(this._stateHi[S],l,S*8),e.writeUint32BE(this._stateLo[S],l,S*8+4);return this},h.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},h.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}},h.prototype.restoreState=function(l){return this._stateHi.set(l.stateHi),this._stateLo.set(l.stateLo),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(l){r.wipe(l.stateHi),r.wipe(l.stateLo),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},h}();t.SHA512=i;var n=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(h,l,c,g,w,E,b){for(var S=c[0],B=c[1],j=c[2],$=c[3],U=c[4],q=c[5],C=c[6],F=c[7],T=g[0],p=g[1],x=g[2],V=g[3],J=g[4],X=g[5],ee=g[6],a=g[7],d,m,_,A,D,R,v,f;b>=128;){for(var I=0;I<16;I++){var H=8*I+E;h[I]=e.readUint32BE(w,H),l[I]=e.readUint32BE(w,H+4)}for(var I=0;I<80;I++){var Y=S,y=B,k=j,N=$,P=U,L=q,u=C,M=F,K=T,G=p,W=x,le=V,he=J,pe=X,Ge=ee,be=a;if(d=F,m=a,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=(U>>>14|J<<32-14)^(U>>>18|J<<32-18)^(J>>>41-32|U<<32-(41-32)),m=(J>>>14|U<<32-14)^(J>>>18|U<<32-18)^(U>>>41-32|J<<32-(41-32)),D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,d=U&q^~U&C,m=J&X^~J&ee,D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,d=n[I*2],m=n[I*2+1],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,d=h[I%16],m=l[I%16],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,_=v&65535|f<<16,A=D&65535|R<<16,d=_,m=A,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=(S>>>28|T<<32-28)^(T>>>34-32|S<<32-(34-32))^(T>>>39-32|S<<32-(39-32)),m=(T>>>28|S<<32-28)^(S>>>34-32|T<<32-(34-32))^(S>>>39-32|T<<32-(39-32)),D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,d=S&B^S&j^B&j,m=T&p^T&x^p&x,D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,M=v&65535|f<<16,be=D&65535|R<<16,d=N,m=le,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=_,m=A,D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,N=v&65535|f<<16,le=D&65535|R<<16,B=Y,j=y,$=k,U=N,q=P,C=L,F=u,S=M,p=K,x=G,V=W,J=le,X=he,ee=pe,a=Ge,T=be,I%16===15)for(var H=0;H<16;H++)d=h[H],m=l[H],D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=h[(H+9)%16],m=l[(H+9)%16],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,_=h[(H+1)%16],A=l[(H+1)%16],d=(_>>>1|A<<32-1)^(_>>>8|A<<32-8)^_>>>7,m=(A>>>1|_<<32-1)^(A>>>8|_<<32-8)^(A>>>7|_<<32-7),D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,_=h[(H+14)%16],A=l[(H+14)%16],d=(_>>>19|A<<32-19)^(A>>>61-32|_<<32-(61-32))^_>>>6,m=(A>>>19|_<<32-19)^(_>>>61-32|A<<32-(61-32))^(A>>>6|_<<32-6),D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,h[H]=v&65535|f<<16,l[H]=D&65535|R<<16}d=S,m=T,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[0],m=g[0],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[0]=S=v&65535|f<<16,g[0]=T=D&65535|R<<16,d=B,m=p,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[1],m=g[1],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[1]=B=v&65535|f<<16,g[1]=p=D&65535|R<<16,d=j,m=x,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[2],m=g[2],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[2]=j=v&65535|f<<16,g[2]=x=D&65535|R<<16,d=$,m=V,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[3],m=g[3],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[3]=$=v&65535|f<<16,g[3]=V=D&65535|R<<16,d=U,m=J,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[4],m=g[4],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[4]=U=v&65535|f<<16,g[4]=J=D&65535|R<<16,d=q,m=X,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[5],m=g[5],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[5]=q=v&65535|f<<16,g[5]=X=D&65535|R<<16,d=C,m=ee,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[6],m=g[6],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[6]=C=v&65535|f<<16,g[6]=ee=D&65535|R<<16,d=F,m=a,D=m&65535,R=m>>>16,v=d&65535,f=d>>>16,d=c[7],m=g[7],D+=m&65535,R+=m>>>16,v+=d&65535,f+=d>>>16,R+=D>>>16,v+=R>>>16,f+=v>>>16,c[7]=F=v&65535|f<<16,g[7]=a=D&65535|R<<16,E+=128,b-=128}return E}function o(h){var l=new i;l.update(h);var c=l.digest();return l.clean(),c}t.hash=o})(Bc);(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=Ti,r=Bc,i=Qt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(N){const P=new Float64Array(16);if(N)for(let L=0;L<N.length;L++)P[L]=N[L];return P}const s=new Uint8Array(32);s[0]=9;const o=n(),h=n([1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),w=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),E=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function b(N,P){for(let L=0;L<16;L++)N[L]=P[L]|0}function S(N){let P=1;for(let L=0;L<16;L++){let u=N[L]+P+65535;P=Math.floor(u/65536),N[L]=u-P*65536}N[0]+=P-1+37*(P-1)}function B(N,P,L){const u=~(L-1);for(let M=0;M<16;M++){const K=u&(N[M]^P[M]);N[M]^=K,P[M]^=K}}function j(N,P){const L=n(),u=n();for(let M=0;M<16;M++)u[M]=P[M];S(u),S(u),S(u);for(let M=0;M<2;M++){L[0]=u[0]-65517;for(let G=1;G<15;G++)L[G]=u[G]-65535-(L[G-1]>>16&1),L[G-1]&=65535;L[15]=u[15]-32767-(L[14]>>16&1);const K=L[15]>>16&1;L[14]&=65535,B(u,L,1-K)}for(let M=0;M<16;M++)N[2*M]=u[M]&255,N[2*M+1]=u[M]>>8}function $(N,P){let L=0;for(let u=0;u<32;u++)L|=N[u]^P[u];return(1&L-1>>>8)-1}function U(N,P){const L=new Uint8Array(32),u=new Uint8Array(32);return j(L,N),j(u,P),$(L,u)}function q(N){const P=new Uint8Array(32);return j(P,N),P[0]&1}function C(N,P){for(let L=0;L<16;L++)N[L]=P[2*L]+(P[2*L+1]<<8);N[15]&=32767}function F(N,P,L){for(let u=0;u<16;u++)N[u]=P[u]+L[u]}function T(N,P,L){for(let u=0;u<16;u++)N[u]=P[u]-L[u]}function p(N,P,L){let u,M,K=0,G=0,W=0,le=0,he=0,pe=0,Ge=0,be=0,ue=0,Re=0,ae=0,se=0,_e=0,ne=0,re=0,ye=0,oe=0,ce=0,we=0,fe=0,de=0,Ue=0,me=0,ge=0,ut=0,qe=0,$e=0,at=0,Ke=0,He=0,Yt=0,Ae=L[0],Ee=L[1],Qe=L[2],Se=L[3],Ie=L[4],Ve=L[5],xe=L[6],Me=L[7],et=L[8],Ne=L[9],Ce=L[10],We=L[11],De=L[12],ve=L[13],tt=L[14],Oe=L[15];u=P[0],K+=u*Ae,G+=u*Ee,W+=u*Qe,le+=u*Se,he+=u*Ie,pe+=u*Ve,Ge+=u*xe,be+=u*Me,ue+=u*et,Re+=u*Ne,ae+=u*Ce,se+=u*We,_e+=u*De,ne+=u*ve,re+=u*tt,ye+=u*Oe,u=P[1],G+=u*Ae,W+=u*Ee,le+=u*Qe,he+=u*Se,pe+=u*Ie,Ge+=u*Ve,be+=u*xe,ue+=u*Me,Re+=u*et,ae+=u*Ne,se+=u*Ce,_e+=u*We,ne+=u*De,re+=u*ve,ye+=u*tt,oe+=u*Oe,u=P[2],W+=u*Ae,le+=u*Ee,he+=u*Qe,pe+=u*Se,Ge+=u*Ie,be+=u*Ve,ue+=u*xe,Re+=u*Me,ae+=u*et,se+=u*Ne,_e+=u*Ce,ne+=u*We,re+=u*De,ye+=u*ve,oe+=u*tt,ce+=u*Oe,u=P[3],le+=u*Ae,he+=u*Ee,pe+=u*Qe,Ge+=u*Se,be+=u*Ie,ue+=u*Ve,Re+=u*xe,ae+=u*Me,se+=u*et,_e+=u*Ne,ne+=u*Ce,re+=u*We,ye+=u*De,oe+=u*ve,ce+=u*tt,we+=u*Oe,u=P[4],he+=u*Ae,pe+=u*Ee,Ge+=u*Qe,be+=u*Se,ue+=u*Ie,Re+=u*Ve,ae+=u*xe,se+=u*Me,_e+=u*et,ne+=u*Ne,re+=u*Ce,ye+=u*We,oe+=u*De,ce+=u*ve,we+=u*tt,fe+=u*Oe,u=P[5],pe+=u*Ae,Ge+=u*Ee,be+=u*Qe,ue+=u*Se,Re+=u*Ie,ae+=u*Ve,se+=u*xe,_e+=u*Me,ne+=u*et,re+=u*Ne,ye+=u*Ce,oe+=u*We,ce+=u*De,we+=u*ve,fe+=u*tt,de+=u*Oe,u=P[6],Ge+=u*Ae,be+=u*Ee,ue+=u*Qe,Re+=u*Se,ae+=u*Ie,se+=u*Ve,_e+=u*xe,ne+=u*Me,re+=u*et,ye+=u*Ne,oe+=u*Ce,ce+=u*We,we+=u*De,fe+=u*ve,de+=u*tt,Ue+=u*Oe,u=P[7],be+=u*Ae,ue+=u*Ee,Re+=u*Qe,ae+=u*Se,se+=u*Ie,_e+=u*Ve,ne+=u*xe,re+=u*Me,ye+=u*et,oe+=u*Ne,ce+=u*Ce,we+=u*We,fe+=u*De,de+=u*ve,Ue+=u*tt,me+=u*Oe,u=P[8],ue+=u*Ae,Re+=u*Ee,ae+=u*Qe,se+=u*Se,_e+=u*Ie,ne+=u*Ve,re+=u*xe,ye+=u*Me,oe+=u*et,ce+=u*Ne,we+=u*Ce,fe+=u*We,de+=u*De,Ue+=u*ve,me+=u*tt,ge+=u*Oe,u=P[9],Re+=u*Ae,ae+=u*Ee,se+=u*Qe,_e+=u*Se,ne+=u*Ie,re+=u*Ve,ye+=u*xe,oe+=u*Me,ce+=u*et,we+=u*Ne,fe+=u*Ce,de+=u*We,Ue+=u*De,me+=u*ve,ge+=u*tt,ut+=u*Oe,u=P[10],ae+=u*Ae,se+=u*Ee,_e+=u*Qe,ne+=u*Se,re+=u*Ie,ye+=u*Ve,oe+=u*xe,ce+=u*Me,we+=u*et,fe+=u*Ne,de+=u*Ce,Ue+=u*We,me+=u*De,ge+=u*ve,ut+=u*tt,qe+=u*Oe,u=P[11],se+=u*Ae,_e+=u*Ee,ne+=u*Qe,re+=u*Se,ye+=u*Ie,oe+=u*Ve,ce+=u*xe,we+=u*Me,fe+=u*et,de+=u*Ne,Ue+=u*Ce,me+=u*We,ge+=u*De,ut+=u*ve,qe+=u*tt,$e+=u*Oe,u=P[12],_e+=u*Ae,ne+=u*Ee,re+=u*Qe,ye+=u*Se,oe+=u*Ie,ce+=u*Ve,we+=u*xe,fe+=u*Me,de+=u*et,Ue+=u*Ne,me+=u*Ce,ge+=u*We,ut+=u*De,qe+=u*ve,$e+=u*tt,at+=u*Oe,u=P[13],ne+=u*Ae,re+=u*Ee,ye+=u*Qe,oe+=u*Se,ce+=u*Ie,we+=u*Ve,fe+=u*xe,de+=u*Me,Ue+=u*et,me+=u*Ne,ge+=u*Ce,ut+=u*We,qe+=u*De,$e+=u*ve,at+=u*tt,Ke+=u*Oe,u=P[14],re+=u*Ae,ye+=u*Ee,oe+=u*Qe,ce+=u*Se,we+=u*Ie,fe+=u*Ve,de+=u*xe,Ue+=u*Me,me+=u*et,ge+=u*Ne,ut+=u*Ce,qe+=u*We,$e+=u*De,at+=u*ve,Ke+=u*tt,He+=u*Oe,u=P[15],ye+=u*Ae,oe+=u*Ee,ce+=u*Qe,we+=u*Se,fe+=u*Ie,de+=u*Ve,Ue+=u*xe,me+=u*Me,ge+=u*et,ut+=u*Ne,qe+=u*Ce,$e+=u*We,at+=u*De,Ke+=u*ve,He+=u*tt,Yt+=u*Oe,K+=38*oe,G+=38*ce,W+=38*we,le+=38*fe,he+=38*de,pe+=38*Ue,Ge+=38*me,be+=38*ge,ue+=38*ut,Re+=38*qe,ae+=38*$e,se+=38*at,_e+=38*Ke,ne+=38*He,re+=38*Yt,M=1,u=K+M+65535,M=Math.floor(u/65536),K=u-M*65536,u=G+M+65535,M=Math.floor(u/65536),G=u-M*65536,u=W+M+65535,M=Math.floor(u/65536),W=u-M*65536,u=le+M+65535,M=Math.floor(u/65536),le=u-M*65536,u=he+M+65535,M=Math.floor(u/65536),he=u-M*65536,u=pe+M+65535,M=Math.floor(u/65536),pe=u-M*65536,u=Ge+M+65535,M=Math.floor(u/65536),Ge=u-M*65536,u=be+M+65535,M=Math.floor(u/65536),be=u-M*65536,u=ue+M+65535,M=Math.floor(u/65536),ue=u-M*65536,u=Re+M+65535,M=Math.floor(u/65536),Re=u-M*65536,u=ae+M+65535,M=Math.floor(u/65536),ae=u-M*65536,u=se+M+65535,M=Math.floor(u/65536),se=u-M*65536,u=_e+M+65535,M=Math.floor(u/65536),_e=u-M*65536,u=ne+M+65535,M=Math.floor(u/65536),ne=u-M*65536,u=re+M+65535,M=Math.floor(u/65536),re=u-M*65536,u=ye+M+65535,M=Math.floor(u/65536),ye=u-M*65536,K+=M-1+37*(M-1),M=1,u=K+M+65535,M=Math.floor(u/65536),K=u-M*65536,u=G+M+65535,M=Math.floor(u/65536),G=u-M*65536,u=W+M+65535,M=Math.floor(u/65536),W=u-M*65536,u=le+M+65535,M=Math.floor(u/65536),le=u-M*65536,u=he+M+65535,M=Math.floor(u/65536),he=u-M*65536,u=pe+M+65535,M=Math.floor(u/65536),pe=u-M*65536,u=Ge+M+65535,M=Math.floor(u/65536),Ge=u-M*65536,u=be+M+65535,M=Math.floor(u/65536),be=u-M*65536,u=ue+M+65535,M=Math.floor(u/65536),ue=u-M*65536,u=Re+M+65535,M=Math.floor(u/65536),Re=u-M*65536,u=ae+M+65535,M=Math.floor(u/65536),ae=u-M*65536,u=se+M+65535,M=Math.floor(u/65536),se=u-M*65536,u=_e+M+65535,M=Math.floor(u/65536),_e=u-M*65536,u=ne+M+65535,M=Math.floor(u/65536),ne=u-M*65536,u=re+M+65535,M=Math.floor(u/65536),re=u-M*65536,u=ye+M+65535,M=Math.floor(u/65536),ye=u-M*65536,K+=M-1+37*(M-1),N[0]=K,N[1]=G,N[2]=W,N[3]=le,N[4]=he,N[5]=pe,N[6]=Ge,N[7]=be,N[8]=ue,N[9]=Re,N[10]=ae,N[11]=se,N[12]=_e,N[13]=ne,N[14]=re,N[15]=ye}function x(N,P){p(N,P,P)}function V(N,P){const L=n();let u;for(u=0;u<16;u++)L[u]=P[u];for(u=253;u>=0;u--)x(L,L),u!==2&&u!==4&&p(L,L,P);for(u=0;u<16;u++)N[u]=L[u]}function J(N,P){const L=n();let u;for(u=0;u<16;u++)L[u]=P[u];for(u=250;u>=0;u--)x(L,L),u!==1&&p(L,L,P);for(u=0;u<16;u++)N[u]=L[u]}function X(N,P){const L=n(),u=n(),M=n(),K=n(),G=n(),W=n(),le=n(),he=n(),pe=n();T(L,N[1],N[0]),T(pe,P[1],P[0]),p(L,L,pe),F(u,N[0],N[1]),F(pe,P[0],P[1]),p(u,u,pe),p(M,N[3],P[3]),p(M,M,c),p(K,N[2],P[2]),F(K,K,K),T(G,u,L),T(W,K,M),F(le,K,M),F(he,u,L),p(N[0],G,W),p(N[1],he,le),p(N[2],le,W),p(N[3],G,he)}function ee(N,P,L){for(let u=0;u<4;u++)B(N[u],P[u],L)}function a(N,P){const L=n(),u=n(),M=n();V(M,P[2]),p(L,P[0],M),p(u,P[1],M),j(N,u),N[31]^=q(L)<<7}function d(N,P,L){b(N[0],o),b(N[1],h),b(N[2],h),b(N[3],o);for(let u=255;u>=0;--u){const M=L[u/8|0]>>(u&7)&1;ee(N,P,M),X(P,N),X(N,N),ee(N,P,M)}}function m(N,P){const L=[n(),n(),n(),n()];b(L[0],g),b(L[1],w),b(L[2],h),p(L[3],g,w),d(N,L,P)}function _(N){if(N.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const P=(0,r.hash)(N);P[0]&=248,P[31]&=127,P[31]|=64;const L=new Uint8Array(32),u=[n(),n(),n(),n()];m(u,P),a(L,u);const M=new Uint8Array(64);return M.set(N),M.set(L,32),{publicKey:L,secretKey:M}}t.generateKeyPairFromSeed=_;function A(N){const P=(0,e.randomBytes)(32,N),L=_(P);return(0,i.wipe)(P),L}t.generateKeyPair=A;function D(N){if(N.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(N.subarray(32))}t.extractPublicKeyFromSecretKey=D;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 v(N,P){let L,u,M,K;for(u=63;u>=32;--u){for(L=0,M=u-32,K=u-12;M<K;++M)P[M]+=L-16*P[u]*R[M-(u-32)],L=Math.floor((P[M]+128)/256),P[M]-=L*256;P[M]+=L,P[u]=0}for(L=0,M=0;M<32;M++)P[M]+=L-(P[31]>>4)*R[M],L=P[M]>>8,P[M]&=255;for(M=0;M<32;M++)P[M]-=L*R[M];for(u=0;u<32;u++)P[u+1]+=P[u]>>8,N[u]=P[u]&255}function f(N){const P=new Float64Array(64);for(let L=0;L<64;L++)P[L]=N[L];for(let L=0;L<64;L++)N[L]=0;v(N,P)}function I(N,P){const L=new Float64Array(64),u=[n(),n(),n(),n()],M=(0,r.hash)(N.subarray(0,32));M[0]&=248,M[31]&=127,M[31]|=64;const K=new Uint8Array(64);K.set(M.subarray(32),32);const G=new r.SHA512;G.update(K.subarray(32)),G.update(P);const W=G.digest();G.clean(),f(W),m(u,W),a(K,u),G.reset(),G.update(K.subarray(0,32)),G.update(N.subarray(32)),G.update(P);const le=G.digest();f(le);for(let he=0;he<32;he++)L[he]=W[he];for(let he=0;he<32;he++)for(let pe=0;pe<32;pe++)L[he+pe]+=le[he]*M[pe];return v(K.subarray(32),L),K}t.sign=I;function H(N,P){const L=n(),u=n(),M=n(),K=n(),G=n(),W=n(),le=n();return b(N[2],h),C(N[1],P),x(M,N[1]),p(K,M,l),T(M,M,N[2]),F(K,N[2],K),x(G,K),x(W,G),p(le,W,G),p(L,le,M),p(L,L,K),J(L,L),p(L,L,M),p(L,L,K),p(L,L,K),p(N[0],L,K),x(u,N[0]),p(u,u,K),U(u,M)&&p(N[0],N[0],E),x(u,N[0]),p(u,u,K),U(u,M)?-1:(q(N[0])===P[31]>>7&&T(N[0],o,N[0]),p(N[3],N[0],N[1]),0)}function Y(N,P,L){const u=new Uint8Array(32),M=[n(),n(),n(),n()],K=[n(),n(),n(),n()];if(L.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(H(K,N))return!1;const G=new r.SHA512;G.update(L.subarray(0,32)),G.update(N),G.update(P);const W=G.digest();return f(W),d(M,K,W),m(K,L.subarray(32)),X(M,K),a(u,M),!$(L,u)}t.verify=Y;function y(N){let P=[n(),n(),n(),n()];if(H(P,N))throw new Error("Ed25519: invalid public key");let L=n(),u=n(),M=P[1];F(L,h,M),T(u,h,M),V(u,u),p(L,L,u);let K=new Uint8Array(32);return j(K,L),K}t.convertPublicKeyToX25519=y;function k(N){const P=(0,r.hash)(N.subarray(0,32));P[0]&=248,P[31]&=127,P[31]|=64;const L=new Uint8Array(P.subarray(0,32));return(0,i.wipe)(P),L}t.convertSecretKeyToX25519=k})(ko);const w0="EdDSA",v0="JWT",qc=".",jc="base64url",b0="utf8",E0="utf8",_0=":",A0="did",S0="key",ka="base58btc",I0="z",D0="K36",x0=32;function zc(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function So(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=zc(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function M0(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var h=t.length,l=t.charAt(0),c=Math.log(h)/Math.log(256),g=Math.log(256)/Math.log(h);function w(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var B=0,j=0,$=0,U=S.length;$!==U&&S[$]===0;)$++,B++;for(var q=(U-$)*g+1>>>0,C=new Uint8Array(q);$!==U;){for(var F=S[$],T=0,p=q-1;(F!==0||T<j)&&p!==-1;p--,T++)F+=256*C[p]>>>0,C[p]=F%h>>>0,F=F/h>>>0;if(F!==0)throw new Error("Non-zero carry");j=T,$++}for(var x=q-j;x!==q&&C[x]===0;)x++;for(var V=l.repeat(B);x<q;++x)V+=t.charAt(C[x]);return V}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var B=0;if(S[B]!==" "){for(var j=0,$=0;S[B]===l;)j++,B++;for(var U=(S.length-B)*c+1>>>0,q=new Uint8Array(U);S[B];){var C=r[S.charCodeAt(B)];if(C===255)return;for(var F=0,T=U-1;(C!==0||F<$)&&T!==-1;T--,F++)C+=h*q[T]>>>0,q[T]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");$=F,B++}if(S[B]!==" "){for(var p=U-$;p!==U&&q[p]===0;)p++;for(var x=new Uint8Array(j+(U-p)),V=j;p!==U;)x[V++]=q[p++];return x}}}function b(S){var B=E(S);if(B)return B;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:E,decode:b}}var N0=M0,C0=N0;const O0=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")},R0=t=>new TextEncoder().encode(t),P0=t=>new TextDecoder().decode(t);class T0{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class F0{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return kc(this,e)}}class L0{constructor(e){this.decoders=e}or(e){return kc(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const kc=(t,e)=>new L0({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class U0{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new T0(e,r,i),this.decoder=new F0(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Is=({name:t,prefix:e,encode:r,decode:i})=>new U0(t,e,r,i),Mn=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=C0(r,e);return Is({prefix:t,name:e,encode:i,decode:s=>O0(n(s))})},B0=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let h=0,l=0,c=0;for(let g=0;g<s;++g){const w=n[t[g]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|w,h+=r,h>=8&&(h-=8,o[c++]=255&l>>h)}if(h>=r||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return o},q0=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,h=0;for(let l=0;l<t.length;++l)for(h=h<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&h>>o];if(o&&(s+=e[n&h<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Et=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Is({prefix:e,name:t,encode(n){return q0(n,i,r)},decode(n){return B0(n,i,r,t)}}),j0=Is({prefix:"\0",name:"identity",encode:t=>P0(t),decode:t=>R0(t)}),z0=Object.freeze(Object.defineProperty({__proto__:null,identity:j0},Symbol.toStringTag,{value:"Module"})),k0=Et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$0=Object.freeze(Object.defineProperty({__proto__:null,base2:k0},Symbol.toStringTag,{value:"Module"})),K0=Et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),H0=Object.freeze(Object.defineProperty({__proto__:null,base8:K0},Symbol.toStringTag,{value:"Module"})),V0=Mn({prefix:"9",name:"base10",alphabet:"0123456789"}),G0=Object.freeze(Object.defineProperty({__proto__:null,base10:V0},Symbol.toStringTag,{value:"Module"})),Q0=Et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y0=Et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),W0=Object.freeze(Object.defineProperty({__proto__:null,base16:Q0,base16upper:Y0},Symbol.toStringTag,{value:"Module"})),J0=Et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X0=Et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z0=Et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ep=Et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tp=Et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rp=Et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ip=Et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),np=Et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sp=Et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),op=Object.freeze(Object.defineProperty({__proto__:null,base32:J0,base32hex:tp,base32hexpad:ip,base32hexpadupper:np,base32hexupper:rp,base32pad:Z0,base32padupper:ep,base32upper:X0,base32z:sp},Symbol.toStringTag,{value:"Module"})),ap=Mn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hp=Mn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),cp=Object.freeze(Object.defineProperty({__proto__:null,base36:ap,base36upper:hp},Symbol.toStringTag,{value:"Module"})),up=Mn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lp=Mn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),fp=Object.freeze(Object.defineProperty({__proto__:null,base58btc:up,base58flickr:lp},Symbol.toStringTag,{value:"Module"})),dp=Et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pp=Et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gp=Et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mp=Et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yp=Object.freeze(Object.defineProperty({__proto__:null,base64:dp,base64pad:pp,base64url:gp,base64urlpad:mp},Symbol.toStringTag,{value:"Module"})),$c=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),wp=$c.reduce((t,e,r)=>(t[r]=e,t),[]),vp=$c.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function bp(t){return t.reduce((e,r)=>(e+=wp[r],e),"")}function Ep(t){const e=[];for(const r of t){const i=vp[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const _p=Is({prefix:"🚀",name:"base256emoji",encode:bp,decode:Ep}),Ap=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:_p},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const $a={...z0,...$0,...H0,...G0,...W0,...op,...cp,...fp,...yp,...Ap};function Kc(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Ka=Kc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$s=Kc("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=zc(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Hc={utf8:Ka,"utf-8":Ka,hex:$a.base16,latin1:$s,ascii:$s,binary:$s,...$a};function Pt(t,e="utf8"){const r=Hc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function qt(t,e="utf8"){const r=Hc[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 as(t){return Pt(qt(fi(t),b0),jc)}function Vc(t){const e=qt(D0,ka),r=I0+Pt(So([e,t]),ka);return[A0,S0,r].join(_0)}function Sp(t){return Pt(t,jc)}function Ip(t){return qt([as(t.header),as(t.payload)].join(qc),E0)}function Dp(t){return[as(t.header),as(t.payload),Sp(t.signature)].join(qc)}function Ha(t=Ti.randomBytes(x0)){return ko.generateKeyPairFromSeed(t)}async function xp(t,e,r,i,n=te.fromMiliseconds(Date.now())){const s={alg:w0,typ:v0},o=Vc(i.publicKey),h=n+r,l={iss:o,sub:t,aud:e,iat:n,exp:h},c=Ip({header:s,payload:l}),g=ko.sign(i.secretKey,c);return Dp({header:s,payload:l,signature:g})}var rt={};Object.defineProperty(rt,"__esModule",{value:!0});rt.getLocalStorage=rt.getLocalStorageOrThrow=rt.getCrypto=rt.getCryptoOrThrow=Gc=rt.getLocation=rt.getLocationOrThrow=Ko=rt.getNavigator=rt.getNavigatorOrThrow=$o=rt.getDocument=rt.getDocumentOrThrow=rt.getFromWindowOrThrow=rt.getFromWindow=void 0;function mi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}rt.getFromWindow=mi;function Fi(t){const e=mi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}rt.getFromWindowOrThrow=Fi;function Mp(){return Fi("document")}rt.getDocumentOrThrow=Mp;function Np(){return mi("document")}var $o=rt.getDocument=Np;function Cp(){return Fi("navigator")}rt.getNavigatorOrThrow=Cp;function Op(){return mi("navigator")}var Ko=rt.getNavigator=Op;function Rp(){return Fi("location")}rt.getLocationOrThrow=Rp;function Pp(){return mi("location")}var Gc=rt.getLocation=Pp;function Tp(){return Fi("crypto")}rt.getCryptoOrThrow=Tp;function Fp(){return mi("crypto")}rt.getCrypto=Fp;function Lp(){return Fi("localStorage")}rt.getLocalStorageOrThrow=Lp;function Up(){return mi("localStorage")}rt.getLocalStorage=Up;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});var Qc=Ho.getWindowMetadata=void 0;const Va=rt;function Bp(){let t,e;try{t=Va.getDocumentOrThrow(),e=Va.getLocationOrThrow()}catch{return null}function r(){const w=t.getElementsByTagName("link"),E=[];for(let b=0;b<w.length;b++){const S=w[b],B=S.getAttribute("rel");if(B&&B.toLowerCase().indexOf("icon")>-1){const j=S.getAttribute("href");if(j)if(j.toLowerCase().indexOf("https:")===-1&&j.toLowerCase().indexOf("http:")===-1&&j.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(j.indexOf("/")===0)$+=j;else{const U=e.pathname.split("/");U.pop();const q=U.join("/");$+=q+"/"+j}E.push($)}else if(j.indexOf("//")===0){const $=e.protocol+j;E.push($)}else E.push(j)}}return E}function i(...w){const E=t.getElementsByTagName("meta");for(let b=0;b<E.length;b++){const S=E[b],B=["itemprop","property","name"].map(j=>S.getAttribute(j)).filter(j=>j?w.includes(j):!1);if(B.length&&B){const j=S.getAttribute("content");if(j)return j}}return""}function n(){let w=i("name","og:site_name","og:title","twitter:title");return w||(w=t.title),w}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),h=s(),l=e.origin,c=r();return{description:h,url:l,icons:c,name:o}}Qc=Ho.getWindowMetadata=Bp;var bn={},qp=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Yc="%[a-f0-9]{2}",Ga=new RegExp("("+Yc+")|([^%]+?)","gi"),Qa=new RegExp("("+Yc+")+","gi");function Io(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],Io(r),Io(i))}function jp(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Ga)||[],r=1;r<e.length;r++)t=Io(e,r).join(""),e=t.match(Ga)||[];return t}}function zp(t){for(var e={"%FE%FF":"��","%FF%FE":"��"},r=Qa.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=jp(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Qa.exec(t)}e["%C2"]="�";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var kp=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 zp(t)}},$p=(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)]},Kp=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],h=t[o];(n?e.indexOf(o)!==-1:e(o,h,t))&&(r[o]=h)}return r};(function(t){const e=qp,r=kp,i=$p,n=Kp,s=U=>U==null,o=Symbol("encodeFragmentIdentifier");function h(U){switch(U.arrayFormat){case"index":return q=>(C,F)=>{const T=C.length;return F===void 0||U.skipNull&&F===null||U.skipEmptyString&&F===""?C:F===null?[...C,[g(q,U),"[",T,"]"].join("")]:[...C,[g(q,U),"[",g(T,U),"]=",g(F,U)].join("")]};case"bracket":return q=>(C,F)=>F===void 0||U.skipNull&&F===null||U.skipEmptyString&&F===""?C:F===null?[...C,[g(q,U),"[]"].join("")]:[...C,[g(q,U),"[]=",g(F,U)].join("")];case"colon-list-separator":return q=>(C,F)=>F===void 0||U.skipNull&&F===null||U.skipEmptyString&&F===""?C:F===null?[...C,[g(q,U),":list="].join("")]:[...C,[g(q,U),":list=",g(F,U)].join("")];case"comma":case"separator":case"bracket-separator":{const q=U.arrayFormat==="bracket-separator"?"[]=":"=";return C=>(F,T)=>T===void 0||U.skipNull&&T===null||U.skipEmptyString&&T===""?F:(T=T===null?"":T,F.length===0?[[g(C,U),q,g(T,U)].join("")]:[[F,g(T,U)].join(U.arrayFormatSeparator)])}default:return q=>(C,F)=>F===void 0||U.skipNull&&F===null||U.skipEmptyString&&F===""?C:F===null?[...C,g(q,U)]:[...C,[g(q,U),"=",g(F,U)].join("")]}}function l(U){let q;switch(U.arrayFormat){case"index":return(C,F,T)=>{if(q=/\[(\d*)\]$/.exec(C),C=C.replace(/\[\d*\]$/,""),!q){T[C]=F;return}T[C]===void 0&&(T[C]={}),T[C][q[1]]=F};case"bracket":return(C,F,T)=>{if(q=/(\[\])$/.exec(C),C=C.replace(/\[\]$/,""),!q){T[C]=F;return}if(T[C]===void 0){T[C]=[F];return}T[C]=[].concat(T[C],F)};case"colon-list-separator":return(C,F,T)=>{if(q=/(:list)$/.exec(C),C=C.replace(/:list$/,""),!q){T[C]=F;return}if(T[C]===void 0){T[C]=[F];return}T[C]=[].concat(T[C],F)};case"comma":case"separator":return(C,F,T)=>{const p=typeof F=="string"&&F.includes(U.arrayFormatSeparator),x=typeof F=="string"&&!p&&w(F,U).includes(U.arrayFormatSeparator);F=x?w(F,U):F;const V=p||x?F.split(U.arrayFormatSeparator).map(J=>w(J,U)):F===null?F:w(F,U);T[C]=V};case"bracket-separator":return(C,F,T)=>{const p=/(\[\])$/.test(C);if(C=C.replace(/\[\]$/,""),!p){T[C]=F&&w(F,U);return}const x=F===null?[]:F.split(U.arrayFormatSeparator).map(V=>w(V,U));if(T[C]===void 0){T[C]=x;return}T[C]=[].concat(T[C],x)};default:return(C,F,T)=>{if(T[C]===void 0){T[C]=F;return}T[C]=[].concat(T[C],F)}}}function c(U){if(typeof U!="string"||U.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(U,q){return q.encode?q.strict?e(U):encodeURIComponent(U):U}function w(U,q){return q.decode?r(U):U}function E(U){return Array.isArray(U)?U.sort():typeof U=="object"?E(Object.keys(U)).sort((q,C)=>Number(q)-Number(C)).map(q=>U[q]):U}function b(U){const q=U.indexOf("#");return q!==-1&&(U=U.slice(0,q)),U}function S(U){let q="";const C=U.indexOf("#");return C!==-1&&(q=U.slice(C)),q}function B(U){U=b(U);const q=U.indexOf("?");return q===-1?"":U.slice(q+1)}function j(U,q){return q.parseNumbers&&!Number.isNaN(Number(U))&&typeof U=="string"&&U.trim()!==""?U=Number(U):q.parseBooleans&&U!==null&&(U.toLowerCase()==="true"||U.toLowerCase()==="false")&&(U=U.toLowerCase()==="true"),U}function $(U,q){q=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},q),c(q.arrayFormatSeparator);const C=l(q),F=Object.create(null);if(typeof U!="string"||(U=U.trim().replace(/^[?#&]/,""),!U))return F;for(const T of U.split("&")){if(T==="")continue;let[p,x]=i(q.decode?T.replace(/\+/g," "):T,"=");x=x===void 0?null:["comma","separator","bracket-separator"].includes(q.arrayFormat)?x:w(x,q),C(w(p,q),x,F)}for(const T of Object.keys(F)){const p=F[T];if(typeof p=="object"&&p!==null)for(const x of Object.keys(p))p[x]=j(p[x],q);else F[T]=j(p,q)}return q.sort===!1?F:(q.sort===!0?Object.keys(F).sort():Object.keys(F).sort(q.sort)).reduce((T,p)=>{const x=F[p];return x&&typeof x=="object"&&!Array.isArray(x)?T[p]=E(x):T[p]=x,T},Object.create(null))}t.extract=B,t.parse=$,t.stringify=(U,q)=>{if(!U)return"";q=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},q),c(q.arrayFormatSeparator);const C=x=>q.skipNull&&s(U[x])||q.skipEmptyString&&U[x]==="",F=h(q),T={};for(const x of Object.keys(U))C(x)||(T[x]=U[x]);const p=Object.keys(T);return q.sort!==!1&&p.sort(q.sort),p.map(x=>{const V=U[x];return V===void 0?"":V===null?g(x,q):Array.isArray(V)?V.length===0&&q.arrayFormat==="bracket-separator"?g(x,q)+"[]":V.reduce(F(x),[]).join("&"):g(x,q)+"="+g(V,q)}).filter(x=>x.length>0).join("&")},t.parseUrl=(U,q)=>{q=Object.assign({decode:!0},q);const[C,F]=i(U,"#");return Object.assign({url:C.split("?")[0]||"",query:$(B(U),q)},q&&q.parseFragmentIdentifier&&F?{fragmentIdentifier:w(F,q)}:{})},t.stringifyUrl=(U,q)=>{q=Object.assign({encode:!0,strict:!0,[o]:!0},q);const C=b(U.url).split("?")[0]||"",F=t.extract(U.url),T=t.parse(F,{sort:!1}),p=Object.assign(T,U.query);let x=t.stringify(p,q);x&&(x=`?${x}`);let V=S(U.url);return U.fragmentIdentifier&&(V=`#${q[o]?g(U.fragmentIdentifier,q):U.fragmentIdentifier}`),`${C}${x}${V}`},t.pick=(U,q,C)=>{C=Object.assign({parseFragmentIdentifier:!0,[o]:!1},C);const{url:F,query:T,fragmentIdentifier:p}=t.parseUrl(U,C);return t.stringifyUrl({url:F,query:n(T,q),fragmentIdentifier:p},C)},t.exclude=(U,q,C)=>{const F=Array.isArray(q)?T=>!q.includes(T):(T,p)=>!q(T,p);return t.pick(U,F,C)}})(bn);var Vo={},Ds={};Object.defineProperty(Ds,"__esModule",{value:!0});var It=Fe,Do=Qt,Hp=20;function Vp(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,h=r[3]<<24|r[2]<<16|r[1]<<8|r[0],l=r[7]<<24|r[6]<<16|r[5]<<8|r[4],c=r[11]<<24|r[10]<<16|r[9]<<8|r[8],g=r[15]<<24|r[14]<<16|r[13]<<8|r[12],w=r[19]<<24|r[18]<<16|r[17]<<8|r[16],E=r[23]<<24|r[22]<<16|r[21]<<8|r[20],b=r[27]<<24|r[26]<<16|r[25]<<8|r[24],S=r[31]<<24|r[30]<<16|r[29]<<8|r[28],B=e[3]<<24|e[2]<<16|e[1]<<8|e[0],j=e[7]<<24|e[6]<<16|e[5]<<8|e[4],$=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],q=i,C=n,F=s,T=o,p=h,x=l,V=c,J=g,X=w,ee=E,a=b,d=S,m=B,_=j,A=$,D=U,R=0;R<Hp;R+=2)q=q+p|0,m^=q,m=m>>>32-16|m<<16,X=X+m|0,p^=X,p=p>>>32-12|p<<12,C=C+x|0,_^=C,_=_>>>32-16|_<<16,ee=ee+_|0,x^=ee,x=x>>>32-12|x<<12,F=F+V|0,A^=F,A=A>>>32-16|A<<16,a=a+A|0,V^=a,V=V>>>32-12|V<<12,T=T+J|0,D^=T,D=D>>>32-16|D<<16,d=d+D|0,J^=d,J=J>>>32-12|J<<12,F=F+V|0,A^=F,A=A>>>32-8|A<<8,a=a+A|0,V^=a,V=V>>>32-7|V<<7,T=T+J|0,D^=T,D=D>>>32-8|D<<8,d=d+D|0,J^=d,J=J>>>32-7|J<<7,C=C+x|0,_^=C,_=_>>>32-8|_<<8,ee=ee+_|0,x^=ee,x=x>>>32-7|x<<7,q=q+p|0,m^=q,m=m>>>32-8|m<<8,X=X+m|0,p^=X,p=p>>>32-7|p<<7,q=q+x|0,D^=q,D=D>>>32-16|D<<16,a=a+D|0,x^=a,x=x>>>32-12|x<<12,C=C+V|0,m^=C,m=m>>>32-16|m<<16,d=d+m|0,V^=d,V=V>>>32-12|V<<12,F=F+J|0,_^=F,_=_>>>32-16|_<<16,X=X+_|0,J^=X,J=J>>>32-12|J<<12,T=T+p|0,A^=T,A=A>>>32-16|A<<16,ee=ee+A|0,p^=ee,p=p>>>32-12|p<<12,F=F+J|0,_^=F,_=_>>>32-8|_<<8,X=X+_|0,J^=X,J=J>>>32-7|J<<7,T=T+p|0,A^=T,A=A>>>32-8|A<<8,ee=ee+A|0,p^=ee,p=p>>>32-7|p<<7,C=C+V|0,m^=C,m=m>>>32-8|m<<8,d=d+m|0,V^=d,V=V>>>32-7|V<<7,q=q+x|0,D^=q,D=D>>>32-8|D<<8,a=a+D|0,x^=a,x=x>>>32-7|x<<7;It.writeUint32LE(q+i|0,t,0),It.writeUint32LE(C+n|0,t,4),It.writeUint32LE(F+s|0,t,8),It.writeUint32LE(T+o|0,t,12),It.writeUint32LE(p+h|0,t,16),It.writeUint32LE(x+l|0,t,20),It.writeUint32LE(V+c|0,t,24),It.writeUint32LE(J+g|0,t,28),It.writeUint32LE(X+w|0,t,32),It.writeUint32LE(ee+E|0,t,36),It.writeUint32LE(a+b|0,t,40),It.writeUint32LE(d+S|0,t,44),It.writeUint32LE(m+B|0,t,48),It.writeUint32LE(_+j|0,t,52),It.writeUint32LE(A+$|0,t,56),It.writeUint32LE(D+U|0,t,60)}function Wc(t,e,r,i,n){if(n===void 0&&(n=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===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=n}for(var h=new Uint8Array(64),l=0;l<r.length;l+=64){Vp(h,s,t);for(var c=l;c<l+64&&c<r.length;c++)i[c]=r[c]^h[c-l];Qp(s,0,o)}return Do.wipe(h),n===0&&Do.wipe(s),i}Ds.streamXOR=Wc;function Gp(t,e,r,i){return i===void 0&&(i=0),Do.wipe(r),Wc(t,e,r,r,i)}Ds.stream=Gp;function Qp(t,e,r){for(var i=1;r--;)i=i+(t[e]&255)|0,t[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var Jc={},ti={};Object.defineProperty(ti,"__esModule",{value:!0});function Yp(t,e,r){return~(t-1)&e|t-1&r}ti.select=Yp;function Wp(t,e){return(t|0)-(e|0)-1>>>31&1}ti.lessOrEqual=Wp;function Xc(t,e){if(t.length!==e.length)return 0;for(var r=0,i=0;i<t.length;i++)r|=t[i]^e[i];return 1&r-1>>>8}ti.compare=Xc;function Jp(t,e){return t.length===0||e.length===0?!1:Xc(t,e)!==0}ti.equal=Jp;(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=ti,r=Qt;t.DIGEST_LENGTH=16;var i=function(){function o(h){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 l=h[0]|h[1]<<8;this._r[0]=l&8191;var c=h[2]|h[3]<<8;this._r[1]=(l>>>13|c<<3)&8191;var g=h[4]|h[5]<<8;this._r[2]=(c>>>10|g<<6)&7939;var w=h[6]|h[7]<<8;this._r[3]=(g>>>7|w<<9)&8191;var E=h[8]|h[9]<<8;this._r[4]=(w>>>4|E<<12)&255,this._r[5]=E>>>1&8190;var b=h[10]|h[11]<<8;this._r[6]=(E>>>14|b<<2)&8191;var S=h[12]|h[13]<<8;this._r[7]=(b>>>11|S<<5)&8065;var B=h[14]|h[15]<<8;this._r[8]=(S>>>8|B<<8)&8191,this._r[9]=B>>>5&127,this._pad[0]=h[16]|h[17]<<8,this._pad[1]=h[18]|h[19]<<8,this._pad[2]=h[20]|h[21]<<8,this._pad[3]=h[22]|h[23]<<8,this._pad[4]=h[24]|h[25]<<8,this._pad[5]=h[26]|h[27]<<8,this._pad[6]=h[28]|h[29]<<8,this._pad[7]=h[30]|h[31]<<8}return o.prototype._blocks=function(h,l,c){for(var g=this._fin?0:2048,w=this._h[0],E=this._h[1],b=this._h[2],S=this._h[3],B=this._h[4],j=this._h[5],$=this._h[6],U=this._h[7],q=this._h[8],C=this._h[9],F=this._r[0],T=this._r[1],p=this._r[2],x=this._r[3],V=this._r[4],J=this._r[5],X=this._r[6],ee=this._r[7],a=this._r[8],d=this._r[9];c>=16;){var m=h[l+0]|h[l+1]<<8;w+=m&8191;var _=h[l+2]|h[l+3]<<8;E+=(m>>>13|_<<3)&8191;var A=h[l+4]|h[l+5]<<8;b+=(_>>>10|A<<6)&8191;var D=h[l+6]|h[l+7]<<8;S+=(A>>>7|D<<9)&8191;var R=h[l+8]|h[l+9]<<8;B+=(D>>>4|R<<12)&8191,j+=R>>>1&8191;var v=h[l+10]|h[l+11]<<8;$+=(R>>>14|v<<2)&8191;var f=h[l+12]|h[l+13]<<8;U+=(v>>>11|f<<5)&8191;var I=h[l+14]|h[l+15]<<8;q+=(f>>>8|I<<8)&8191,C+=I>>>5|g;var H=0,Y=H;Y+=w*F,Y+=E*(5*d),Y+=b*(5*a),Y+=S*(5*ee),Y+=B*(5*X),H=Y>>>13,Y&=8191,Y+=j*(5*J),Y+=$*(5*V),Y+=U*(5*x),Y+=q*(5*p),Y+=C*(5*T),H+=Y>>>13,Y&=8191;var y=H;y+=w*T,y+=E*F,y+=b*(5*d),y+=S*(5*a),y+=B*(5*ee),H=y>>>13,y&=8191,y+=j*(5*X),y+=$*(5*J),y+=U*(5*V),y+=q*(5*x),y+=C*(5*p),H+=y>>>13,y&=8191;var k=H;k+=w*p,k+=E*T,k+=b*F,k+=S*(5*d),k+=B*(5*a),H=k>>>13,k&=8191,k+=j*(5*ee),k+=$*(5*X),k+=U*(5*J),k+=q*(5*V),k+=C*(5*x),H+=k>>>13,k&=8191;var N=H;N+=w*x,N+=E*p,N+=b*T,N+=S*F,N+=B*(5*d),H=N>>>13,N&=8191,N+=j*(5*a),N+=$*(5*ee),N+=U*(5*X),N+=q*(5*J),N+=C*(5*V),H+=N>>>13,N&=8191;var P=H;P+=w*V,P+=E*x,P+=b*p,P+=S*T,P+=B*F,H=P>>>13,P&=8191,P+=j*(5*d),P+=$*(5*a),P+=U*(5*ee),P+=q*(5*X),P+=C*(5*J),H+=P>>>13,P&=8191;var L=H;L+=w*J,L+=E*V,L+=b*x,L+=S*p,L+=B*T,H=L>>>13,L&=8191,L+=j*F,L+=$*(5*d),L+=U*(5*a),L+=q*(5*ee),L+=C*(5*X),H+=L>>>13,L&=8191;var u=H;u+=w*X,u+=E*J,u+=b*V,u+=S*x,u+=B*p,H=u>>>13,u&=8191,u+=j*T,u+=$*F,u+=U*(5*d),u+=q*(5*a),u+=C*(5*ee),H+=u>>>13,u&=8191;var M=H;M+=w*ee,M+=E*X,M+=b*J,M+=S*V,M+=B*x,H=M>>>13,M&=8191,M+=j*p,M+=$*T,M+=U*F,M+=q*(5*d),M+=C*(5*a),H+=M>>>13,M&=8191;var K=H;K+=w*a,K+=E*ee,K+=b*X,K+=S*J,K+=B*V,H=K>>>13,K&=8191,K+=j*x,K+=$*p,K+=U*T,K+=q*F,K+=C*(5*d),H+=K>>>13,K&=8191;var G=H;G+=w*d,G+=E*a,G+=b*ee,G+=S*X,G+=B*J,H=G>>>13,G&=8191,G+=j*V,G+=$*x,G+=U*p,G+=q*T,G+=C*F,H+=G>>>13,G&=8191,H=(H<<2)+H|0,H=H+Y|0,Y=H&8191,H=H>>>13,y+=H,w=Y,E=y,b=k,S=N,B=P,j=L,$=u,U=M,q=K,C=G,l+=16,c-=16}this._h[0]=w,this._h[1]=E,this._h[2]=b,this._h[3]=S,this._h[4]=B,this._h[5]=j,this._h[6]=$,this._h[7]=U,this._h[8]=q,this._h[9]=C},o.prototype.finish=function(h,l){l===void 0&&(l=0);var c=new Uint16Array(10),g,w,E,b;if(this._leftover){for(b=this._leftover,this._buffer[b++]=1;b<16;b++)this._buffer[b]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,b=2;b<10;b++)this._h[b]+=g,g=this._h[b]>>>13,this._h[b]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,c[0]=this._h[0]+5,g=c[0]>>>13,c[0]&=8191,b=1;b<10;b++)c[b]=this._h[b]+g,g=c[b]>>>13,c[b]&=8191;for(c[9]-=8192,w=(g^1)-1,b=0;b<10;b++)c[b]&=w;for(w=~w,b=0;b<10;b++)this._h[b]=this._h[b]&w|c[b];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,E=this._h[0]+this._pad[0],this._h[0]=E&65535,b=1;b<8;b++)E=(this._h[b]+this._pad[b]|0)+(E>>>16)|0,this._h[b]=E&65535;return h[l+0]=this._h[0]>>>0,h[l+1]=this._h[0]>>>8,h[l+2]=this._h[1]>>>0,h[l+3]=this._h[1]>>>8,h[l+4]=this._h[2]>>>0,h[l+5]=this._h[2]>>>8,h[l+6]=this._h[3]>>>0,h[l+7]=this._h[3]>>>8,h[l+8]=this._h[4]>>>0,h[l+9]=this._h[4]>>>8,h[l+10]=this._h[5]>>>0,h[l+11]=this._h[5]>>>8,h[l+12]=this._h[6]>>>0,h[l+13]=this._h[6]>>>8,h[l+14]=this._h[7]>>>0,h[l+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(h){var l=0,c=h.length,g;if(this._leftover){g=16-this._leftover,g>c&&(g=c);for(var w=0;w<g;w++)this._buffer[this._leftover+w]=h[l+w];if(c-=g,l+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(c>=16&&(g=c-c%16,this._blocks(h,l,g),l+=g,c-=g),c){for(var w=0;w<c;w++)this._buffer[this._leftover+w]=h[l+w];this._leftover+=c}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var h=new Uint8Array(16);return this.finish(h),h},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=i;function n(o,h){var l=new i(o);l.update(h);var c=l.digest();return l.clean(),c}t.oneTimeAuth=n;function s(o,h){return o.length!==t.DIGEST_LENGTH||h.length!==t.DIGEST_LENGTH?!1:e.equal(o,h)}t.equal=s})(Jc);(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ds,r=Jc,i=Qt,n=Fe,s=ti;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),h=function(){function l(c){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,c.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(c)}return l.prototype.seal=function(c,g,w,E){if(c.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var b=new Uint8Array(16);b.set(c,b.length-c.length);var S=new Uint8Array(32);e.stream(this._key,b,S,4);var B=g.length+this.tagLength,j;if(E){if(E.length!==B)throw new Error("ChaCha20Poly1305: incorrect destination length");j=E}else j=new Uint8Array(B);return e.streamXOR(this._key,b,g,j,4),this._authenticate(j.subarray(j.length-this.tagLength,j.length),S,j.subarray(0,j.length-this.tagLength),w),i.wipe(b),j},l.prototype.open=function(c,g,w,E){if(c.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var b=new Uint8Array(16);b.set(c,b.length-c.length);var S=new Uint8Array(32);e.stream(this._key,b,S,4);var B=new Uint8Array(this.tagLength);if(this._authenticate(B,S,g.subarray(0,g.length-this.tagLength),w),!s.equal(B,g.subarray(g.length-this.tagLength,g.length)))return null;var j=g.length-this.tagLength,$;if(E){if(E.length!==j)throw new Error("ChaCha20Poly1305: incorrect destination length");$=E}else $=new Uint8Array(j);return e.streamXOR(this._key,b,g.subarray(0,g.length-this.tagLength),$,4),i.wipe(b),$},l.prototype.clean=function(){return i.wipe(this._key),this},l.prototype._authenticate=function(c,g,w,E){var b=new r.Poly1305(g);E&&(b.update(E),E.length%16>0&&b.update(o.subarray(E.length%16))),b.update(w),w.length%16>0&&b.update(o.subarray(w.length%16));var S=new Uint8Array(8);E&&n.writeUint64LE(E.length,S),b.update(S),n.writeUint64LE(w.length,S),b.update(S);for(var B=b.digest(),j=0;j<B.length;j++)c[j]=B[j];b.clean(),i.wipe(B),i.wipe(S)},l}();t.ChaCha20Poly1305=h})(Vo);var Zc={},Nn={},Go={};Object.defineProperty(Go,"__esModule",{value:!0});function Xp(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Go.isSerializableHash=Xp;Object.defineProperty(Nn,"__esModule",{value:!0});var br=Go,Zp=ti,e1=Qt,eu=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 i=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(i).clean():i.set(r);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),br.isSerializableHash(this._inner)&&br.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),e1.wipe(i)}return t.prototype.reset=function(){if(!br.isSerializableHash(this._inner)||!br.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(){br.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),br.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(!br.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(!br.isSerializableHash(this._inner)||!br.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(!br.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();Nn.HMAC=eu;function t1(t,e,r){var i=new eu(t,e);i.update(r);var n=i.digest();return i.clean(),n}Nn.hmac=t1;Nn.equal=Zp.equal;Object.defineProperty(Zc,"__esModule",{value:!0});var Ya=Nn,Wa=Qt,r1=function(){function t(e,r,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Ya.hmac(this._hash,i,r);this._hmac=new Ya.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),i=0;i<r.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[i]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),Wa.wipe(this._buffer),Wa.wipe(this._counter),this._bufpos=0},t}(),i1=Zc.HKDF=r1,xs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Fe,r=Qt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var i=function(){function h(){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 h.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},h.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},h.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},h.prototype.update=function(l,c){if(c===void 0&&(c=l.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=c,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&c>0;)this._buffer[this._bufferLength++]=l[g++],c--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(c>=this.blockSize&&(g=s(this._temp,this._state,l,g,c),c%=this.blockSize);c>0;)this._buffer[this._bufferLength++]=l[g++],c--;return this},h.prototype.finish=function(l){if(!this._finished){var c=this._bytesHashed,g=this._bufferLength,w=c/536870912|0,E=c<<3,b=c%64<56?64:128;this._buffer[g]=128;for(var S=g+1;S<b-8;S++)this._buffer[S]=0;e.writeUint32BE(w,this._buffer,b-8),e.writeUint32BE(E,this._buffer,b-4),s(this._temp,this._state,this._buffer,0,b),this._finished=!0}for(var S=0;S<this.digestLength/4;S++)e.writeUint32BE(this._state[S],l,S*4);return this},h.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},h.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}},h.prototype.restoreState=function(l){return this._state.set(l.state),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(l){r.wipe(l.state),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},h}();t.SHA256=i;var n=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(h,l,c,g,w){for(;w>=64;){for(var E=l[0],b=l[1],S=l[2],B=l[3],j=l[4],$=l[5],U=l[6],q=l[7],C=0;C<16;C++){var F=g+C*4;h[C]=e.readUint32BE(c,F)}for(var C=16;C<64;C++){var T=h[C-2],p=(T>>>17|T<<32-17)^(T>>>19|T<<32-19)^T>>>10;T=h[C-15];var x=(T>>>7|T<<32-7)^(T>>>18|T<<32-18)^T>>>3;h[C]=(p+h[C-7]|0)+(x+h[C-16]|0)}for(var C=0;C<64;C++){var p=(((j>>>6|j<<26)^(j>>>11|j<<21)^(j>>>25|j<<7))+(j&$^~j&U)|0)+(q+(n[C]+h[C]|0)|0)|0,x=((E>>>2|E<<32-2)^(E>>>13|E<<32-13)^(E>>>22|E<<32-22))+(E&b^E&S^b&S)|0;q=U,U=$,$=j,j=B+p|0,B=S,S=b,b=E,E=p+x|0}l[0]+=E,l[1]+=b,l[2]+=S,l[3]+=B,l[4]+=j,l[5]+=$,l[6]+=U,l[7]+=q,g+=64,w-=64}return g}function o(h){var l=new i;l.update(h);var c=l.digest();return l.clean(),c}t.hash=o})(xs);var Qo={};(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=Ti,r=Qt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(C){const F=new Float64Array(16);if(C)for(let T=0;T<C.length;T++)F[T]=C[T];return F}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(C){let F=1;for(let T=0;T<16;T++){let p=C[T]+F+65535;F=Math.floor(p/65536),C[T]=p-F*65536}C[0]+=F-1+37*(F-1)}function h(C,F,T){const p=~(T-1);for(let x=0;x<16;x++){const V=p&(C[x]^F[x]);C[x]^=V,F[x]^=V}}function l(C,F){const T=i(),p=i();for(let x=0;x<16;x++)p[x]=F[x];o(p),o(p),o(p);for(let x=0;x<2;x++){T[0]=p[0]-65517;for(let J=1;J<15;J++)T[J]=p[J]-65535-(T[J-1]>>16&1),T[J-1]&=65535;T[15]=p[15]-32767-(T[14]>>16&1);const V=T[15]>>16&1;T[14]&=65535,h(p,T,1-V)}for(let x=0;x<16;x++)C[2*x]=p[x]&255,C[2*x+1]=p[x]>>8}function c(C,F){for(let T=0;T<16;T++)C[T]=F[2*T]+(F[2*T+1]<<8);C[15]&=32767}function g(C,F,T){for(let p=0;p<16;p++)C[p]=F[p]+T[p]}function w(C,F,T){for(let p=0;p<16;p++)C[p]=F[p]-T[p]}function E(C,F,T){let p,x,V=0,J=0,X=0,ee=0,a=0,d=0,m=0,_=0,A=0,D=0,R=0,v=0,f=0,I=0,H=0,Y=0,y=0,k=0,N=0,P=0,L=0,u=0,M=0,K=0,G=0,W=0,le=0,he=0,pe=0,Ge=0,be=0,ue=T[0],Re=T[1],ae=T[2],se=T[3],_e=T[4],ne=T[5],re=T[6],ye=T[7],oe=T[8],ce=T[9],we=T[10],fe=T[11],de=T[12],Ue=T[13],me=T[14],ge=T[15];p=F[0],V+=p*ue,J+=p*Re,X+=p*ae,ee+=p*se,a+=p*_e,d+=p*ne,m+=p*re,_+=p*ye,A+=p*oe,D+=p*ce,R+=p*we,v+=p*fe,f+=p*de,I+=p*Ue,H+=p*me,Y+=p*ge,p=F[1],J+=p*ue,X+=p*Re,ee+=p*ae,a+=p*se,d+=p*_e,m+=p*ne,_+=p*re,A+=p*ye,D+=p*oe,R+=p*ce,v+=p*we,f+=p*fe,I+=p*de,H+=p*Ue,Y+=p*me,y+=p*ge,p=F[2],X+=p*ue,ee+=p*Re,a+=p*ae,d+=p*se,m+=p*_e,_+=p*ne,A+=p*re,D+=p*ye,R+=p*oe,v+=p*ce,f+=p*we,I+=p*fe,H+=p*de,Y+=p*Ue,y+=p*me,k+=p*ge,p=F[3],ee+=p*ue,a+=p*Re,d+=p*ae,m+=p*se,_+=p*_e,A+=p*ne,D+=p*re,R+=p*ye,v+=p*oe,f+=p*ce,I+=p*we,H+=p*fe,Y+=p*de,y+=p*Ue,k+=p*me,N+=p*ge,p=F[4],a+=p*ue,d+=p*Re,m+=p*ae,_+=p*se,A+=p*_e,D+=p*ne,R+=p*re,v+=p*ye,f+=p*oe,I+=p*ce,H+=p*we,Y+=p*fe,y+=p*de,k+=p*Ue,N+=p*me,P+=p*ge,p=F[5],d+=p*ue,m+=p*Re,_+=p*ae,A+=p*se,D+=p*_e,R+=p*ne,v+=p*re,f+=p*ye,I+=p*oe,H+=p*ce,Y+=p*we,y+=p*fe,k+=p*de,N+=p*Ue,P+=p*me,L+=p*ge,p=F[6],m+=p*ue,_+=p*Re,A+=p*ae,D+=p*se,R+=p*_e,v+=p*ne,f+=p*re,I+=p*ye,H+=p*oe,Y+=p*ce,y+=p*we,k+=p*fe,N+=p*de,P+=p*Ue,L+=p*me,u+=p*ge,p=F[7],_+=p*ue,A+=p*Re,D+=p*ae,R+=p*se,v+=p*_e,f+=p*ne,I+=p*re,H+=p*ye,Y+=p*oe,y+=p*ce,k+=p*we,N+=p*fe,P+=p*de,L+=p*Ue,u+=p*me,M+=p*ge,p=F[8],A+=p*ue,D+=p*Re,R+=p*ae,v+=p*se,f+=p*_e,I+=p*ne,H+=p*re,Y+=p*ye,y+=p*oe,k+=p*ce,N+=p*we,P+=p*fe,L+=p*de,u+=p*Ue,M+=p*me,K+=p*ge,p=F[9],D+=p*ue,R+=p*Re,v+=p*ae,f+=p*se,I+=p*_e,H+=p*ne,Y+=p*re,y+=p*ye,k+=p*oe,N+=p*ce,P+=p*we,L+=p*fe,u+=p*de,M+=p*Ue,K+=p*me,G+=p*ge,p=F[10],R+=p*ue,v+=p*Re,f+=p*ae,I+=p*se,H+=p*_e,Y+=p*ne,y+=p*re,k+=p*ye,N+=p*oe,P+=p*ce,L+=p*we,u+=p*fe,M+=p*de,K+=p*Ue,G+=p*me,W+=p*ge,p=F[11],v+=p*ue,f+=p*Re,I+=p*ae,H+=p*se,Y+=p*_e,y+=p*ne,k+=p*re,N+=p*ye,P+=p*oe,L+=p*ce,u+=p*we,M+=p*fe,K+=p*de,G+=p*Ue,W+=p*me,le+=p*ge,p=F[12],f+=p*ue,I+=p*Re,H+=p*ae,Y+=p*se,y+=p*_e,k+=p*ne,N+=p*re,P+=p*ye,L+=p*oe,u+=p*ce,M+=p*we,K+=p*fe,G+=p*de,W+=p*Ue,le+=p*me,he+=p*ge,p=F[13],I+=p*ue,H+=p*Re,Y+=p*ae,y+=p*se,k+=p*_e,N+=p*ne,P+=p*re,L+=p*ye,u+=p*oe,M+=p*ce,K+=p*we,G+=p*fe,W+=p*de,le+=p*Ue,he+=p*me,pe+=p*ge,p=F[14],H+=p*ue,Y+=p*Re,y+=p*ae,k+=p*se,N+=p*_e,P+=p*ne,L+=p*re,u+=p*ye,M+=p*oe,K+=p*ce,G+=p*we,W+=p*fe,le+=p*de,he+=p*Ue,pe+=p*me,Ge+=p*ge,p=F[15],Y+=p*ue,y+=p*Re,k+=p*ae,N+=p*se,P+=p*_e,L+=p*ne,u+=p*re,M+=p*ye,K+=p*oe,G+=p*ce,W+=p*we,le+=p*fe,he+=p*de,pe+=p*Ue,Ge+=p*me,be+=p*ge,V+=38*y,J+=38*k,X+=38*N,ee+=38*P,a+=38*L,d+=38*u,m+=38*M,_+=38*K,A+=38*G,D+=38*W,R+=38*le,v+=38*he,f+=38*pe,I+=38*Ge,H+=38*be,x=1,p=V+x+65535,x=Math.floor(p/65536),V=p-x*65536,p=J+x+65535,x=Math.floor(p/65536),J=p-x*65536,p=X+x+65535,x=Math.floor(p/65536),X=p-x*65536,p=ee+x+65535,x=Math.floor(p/65536),ee=p-x*65536,p=a+x+65535,x=Math.floor(p/65536),a=p-x*65536,p=d+x+65535,x=Math.floor(p/65536),d=p-x*65536,p=m+x+65535,x=Math.floor(p/65536),m=p-x*65536,p=_+x+65535,x=Math.floor(p/65536),_=p-x*65536,p=A+x+65535,x=Math.floor(p/65536),A=p-x*65536,p=D+x+65535,x=Math.floor(p/65536),D=p-x*65536,p=R+x+65535,x=Math.floor(p/65536),R=p-x*65536,p=v+x+65535,x=Math.floor(p/65536),v=p-x*65536,p=f+x+65535,x=Math.floor(p/65536),f=p-x*65536,p=I+x+65535,x=Math.floor(p/65536),I=p-x*65536,p=H+x+65535,x=Math.floor(p/65536),H=p-x*65536,p=Y+x+65535,x=Math.floor(p/65536),Y=p-x*65536,V+=x-1+37*(x-1),x=1,p=V+x+65535,x=Math.floor(p/65536),V=p-x*65536,p=J+x+65535,x=Math.floor(p/65536),J=p-x*65536,p=X+x+65535,x=Math.floor(p/65536),X=p-x*65536,p=ee+x+65535,x=Math.floor(p/65536),ee=p-x*65536,p=a+x+65535,x=Math.floor(p/65536),a=p-x*65536,p=d+x+65535,x=Math.floor(p/65536),d=p-x*65536,p=m+x+65535,x=Math.floor(p/65536),m=p-x*65536,p=_+x+65535,x=Math.floor(p/65536),_=p-x*65536,p=A+x+65535,x=Math.floor(p/65536),A=p-x*65536,p=D+x+65535,x=Math.floor(p/65536),D=p-x*65536,p=R+x+65535,x=Math.floor(p/65536),R=p-x*65536,p=v+x+65535,x=Math.floor(p/65536),v=p-x*65536,p=f+x+65535,x=Math.floor(p/65536),f=p-x*65536,p=I+x+65535,x=Math.floor(p/65536),I=p-x*65536,p=H+x+65535,x=Math.floor(p/65536),H=p-x*65536,p=Y+x+65535,x=Math.floor(p/65536),Y=p-x*65536,V+=x-1+37*(x-1),C[0]=V,C[1]=J,C[2]=X,C[3]=ee,C[4]=a,C[5]=d,C[6]=m,C[7]=_,C[8]=A,C[9]=D,C[10]=R,C[11]=v,C[12]=f,C[13]=I,C[14]=H,C[15]=Y}function b(C,F){E(C,F,F)}function S(C,F){const T=i();for(let p=0;p<16;p++)T[p]=F[p];for(let p=253;p>=0;p--)b(T,T),p!==2&&p!==4&&E(T,T,F);for(let p=0;p<16;p++)C[p]=T[p]}function B(C,F){const T=new Uint8Array(32),p=new Float64Array(80),x=i(),V=i(),J=i(),X=i(),ee=i(),a=i();for(let A=0;A<31;A++)T[A]=C[A];T[31]=C[31]&127|64,T[0]&=248,c(p,F);for(let A=0;A<16;A++)V[A]=p[A];x[0]=X[0]=1;for(let A=254;A>=0;--A){const D=T[A>>>3]>>>(A&7)&1;h(x,V,D),h(J,X,D),g(ee,x,J),w(x,x,J),g(J,V,X),w(V,V,X),b(X,ee),b(a,x),E(x,J,x),E(J,V,ee),g(ee,x,J),w(x,x,J),b(V,x),w(J,X,a),E(x,J,s),g(x,x,X),E(J,J,x),E(x,X,a),E(X,V,p),b(V,ee),h(x,V,D),h(J,X,D)}for(let A=0;A<16;A++)p[A+16]=x[A],p[A+32]=J[A],p[A+48]=V[A],p[A+64]=X[A];const d=p.subarray(32),m=p.subarray(16);S(d,d),E(m,m,d);const _=new Uint8Array(32);return l(_,m),_}t.scalarMult=B;function j(C){return B(C,n)}t.scalarMultBase=j;function $(C){if(C.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const F=new Uint8Array(C);return{publicKey:j(F),secretKey:F}}t.generateKeyPairFromSeed=$;function U(C){const F=(0,e.randomBytes)(32,C),T=$(F);return(0,r.wipe)(F),T}t.generateKeyPair=U;function q(C,F,T=!1){if(C.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(F.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const p=B(C,F);if(T){let x=0;for(let V=0;V<p.length;V++)x|=p[V];if(x===0)throw new Error("X25519: invalid shared key")}return p}t.sharedKey=q})(Qo);const n1={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},Yo=":";function Ks(t){const[e,r]=t.split(Yo);return{namespace:e,reference:r}}function s1(t){const{namespace:e,reference:r}=t;return[e,r].join(Yo)}function o1(t){const[e,r,i]=t.split(Yo);return{namespace:e,reference:r,address:i}}function a1(t,e){const r=[];return t.forEach(i=>{const n=e(i);r.includes(n)||r.push(n)}),r}function h1(t){const{namespace:e,reference:r}=o1(t);return s1({namespace:e,reference:r})}function c1(t){return a1(t,h1)}function tu(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.accounts)}),r}function ru(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...c1(n.accounts))}),r}function u1(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...Wo(i,n))}),r}function Wo(t,e){return t.includes(":")?[t]:e.chains||[]}var l1=Object.defineProperty,Ja=Object.getOwnPropertySymbols,f1=Object.prototype.hasOwnProperty,d1=Object.prototype.propertyIsEnumerable,Xa=(t,e,r)=>e in t?l1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Za=(t,e)=>{for(var r in e||(e={}))f1.call(e,r)&&Xa(t,r,e[r]);if(Ja)for(var r of Ja(e))d1.call(e,r)&&Xa(t,r,e[r]);return t};const p1="ReactNative",Kt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},g1="js";function En(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Li(){return!$o()&&!!Ko()&&navigator.product===p1}function Ui(){return!En()&&!!Ko()&&!!$o()}function Cn(){return Li()?Kt.reactNative:En()?Kt.node:Ui()?Kt.browser:Kt.unknown}function m1(){var t;try{return Li()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function y1(t,e){let r=bn.parse(t);return r=Za(Za({},r),e),t=bn.stringify(r),t}function w1(){return Qc()||{name:"",description:"",url:"",icons:[""]}}function v1(){if(Cn()===Kt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=ur.detect();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 b1(){var t;const e=Cn();return e===Kt.browser?[e,((t=Gc())==null?void 0:t.host)||"unknown"].join(":"):e}function E1(t,e,r){const i=v1(),n=b1();return[[t,e].join("-"),[g1,r].join("-"),i,n].join("/")}function _1({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:h}){const l=r.split("?"),c=E1(t,e,i),g={auth:n,ua:c,projectId:s,useOnCloseEvent:o||void 0,origin:h||void 0},w=y1(l[1]||"",g);return l[0]+"?"+w}function hi(t,e){return t.filter(r=>e.includes(r)).length===t.length}function iu(t){return Object.fromEntries(t.entries())}function nu(t){return new Map(Object.entries(t))}function ai(t=te.FIVE_MINUTES,e){const r=te.toMiliseconds(t||te.FIVE_MINUTES);let i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,h)=>{s=setTimeout(()=>{h(new Error(e))},r),i=o,n=h})}}function Mi(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function su(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 A1(t){return su("topic",t)}function S1(t){return su("id",t)}function ou(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function vt(t,e){return te.fromMiliseconds((e||Date.now())+te.toMiliseconds(t))}function Wr(t){return Date.now()>=te.toMiliseconds(t)}function Be(t,e){return`${t}${e?`:${e}`:""}`}function I1(t=[],e=[]){return[...new Set([...t,...e])]}async function D1({id:t,topic:e,wcDeepLink:r}){try{if(!r)return;let n=(typeof r=="string"?JSON.parse(r):r)?.href;if(typeof n!="string")return;n.endsWith("/")&&(n=n.slice(0,-1));const s=`${n}/wc?requestId=${t}&sessionTopic=${e}`,o=Cn();o===Kt.browser?s.startsWith("https://")||s.startsWith("http://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):o===Kt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(i){console.error(i)}}async function x1(t,e){try{return await t.getItem(e)||(Ui()?localStorage.getItem(e):void 0)}catch(r){console.error(r)}}var au=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function M1(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var hu={exports:{}};/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/(function(t){(function(){var e="input is invalid type",r="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=au:s&&(n=self);var h=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,l=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],w=[4,1024,262144,67108864],E=[1,256,65536,16777216],b=[6,1536,393216,100663296],S=[0,8,16,24],B=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],j=[224,256,384,512],$=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],q={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(y){return Object.prototype.toString.call(y)==="[object Array]"}),l&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(y){return typeof y=="object"&&y.buffer&&y.buffer.constructor===ArrayBuffer});for(var C=function(y,k,N){return function(P){return new I(y,k,y).update(P)[N]()}},F=function(y,k,N){return function(P,L){return new I(y,k,L).update(P)[N]()}},T=function(y,k,N){return function(P,L,u,M){return d["cshake"+y].update(P,L,u,M)[N]()}},p=function(y,k,N){return function(P,L,u,M){return d["kmac"+y].update(P,L,u,M)[N]()}},x=function(y,k,N,P){for(var L=0;L<U.length;++L){var u=U[L];y[u]=k(N,P,u)}return y},V=function(y,k){var N=C(y,k,"hex");return N.create=function(){return new I(y,k,y)},N.update=function(P){return N.create().update(P)},x(N,C,y,k)},J=function(y,k){var N=F(y,k,"hex");return N.create=function(P){return new I(y,k,P)},N.update=function(P,L){return N.create(L).update(P)},x(N,F,y,k)},X=function(y,k){var N=q[y],P=T(y,k,"hex");return P.create=function(L,u,M){return!u&&!M?d["shake"+y].create(L):new I(y,k,L).bytepad([u,M],N)},P.update=function(L,u,M,K){return P.create(u,M,K).update(L)},x(P,T,y,k)},ee=function(y,k){var N=q[y],P=p(y,k,"hex");return P.create=function(L,u,M){return new H(y,k,u).bytepad(["KMAC",M],N).bytepad([L],N)},P.update=function(L,u,M,K){return P.create(L,M,K).update(u)},x(P,p,y,k)},a=[{name:"keccak",padding:E,bits:j,createMethod:V},{name:"sha3",padding:b,bits:j,createMethod:V},{name:"shake",padding:g,bits:$,createMethod:J},{name:"cshake",padding:w,bits:$,createMethod:X},{name:"kmac",padding:w,bits:$,createMethod:ee}],d={},m=[],_=0;_<a.length;++_)for(var A=a[_],D=A.bits,R=0;R<D.length;++R){var v=A.name+"_"+D[R];if(m.push(v),d[v]=A.createMethod(D[R],A.padding),A.name!=="sha3"){var f=A.name+D[R];m.push(f),d[f]=d[v]}}function I(y,k,N){this.blocks=[],this.s=[],this.padding=k,this.outputBits=N,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(y<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=N>>5,this.extraBytes=(N&31)>>3;for(var P=0;P<50;++P)this.s[P]=0}I.prototype.update=function(y){if(this.finalized)throw new Error(r);var k,N=typeof y;if(N!=="string"){if(N==="object"){if(y===null)throw new Error(e);if(l&&y.constructor===ArrayBuffer)y=new Uint8Array(y);else if(!Array.isArray(y)&&(!l||!ArrayBuffer.isView(y)))throw new Error(e)}else throw new Error(e);k=!0}for(var P=this.blocks,L=this.byteCount,u=y.length,M=this.blockCount,K=0,G=this.s,W,le;K<u;){if(this.reset)for(this.reset=!1,P[0]=this.block,W=1;W<M+1;++W)P[W]=0;if(k)for(W=this.start;K<u&&W<L;++K)P[W>>2]|=y[K]<<S[W++&3];else for(W=this.start;K<u&&W<L;++K)le=y.charCodeAt(K),le<128?P[W>>2]|=le<<S[W++&3]:le<2048?(P[W>>2]|=(192|le>>6)<<S[W++&3],P[W>>2]|=(128|le&63)<<S[W++&3]):le<55296||le>=57344?(P[W>>2]|=(224|le>>12)<<S[W++&3],P[W>>2]|=(128|le>>6&63)<<S[W++&3],P[W>>2]|=(128|le&63)<<S[W++&3]):(le=65536+((le&1023)<<10|y.charCodeAt(++K)&1023),P[W>>2]|=(240|le>>18)<<S[W++&3],P[W>>2]|=(128|le>>12&63)<<S[W++&3],P[W>>2]|=(128|le>>6&63)<<S[W++&3],P[W>>2]|=(128|le&63)<<S[W++&3]);if(this.lastByteIndex=W,W>=L){for(this.start=W-L,this.block=P[M],W=0;W<M;++W)G[W]^=P[W];Y(G),this.reset=!0}else this.start=W}return this},I.prototype.encode=function(y,k){var N=y&255,P=1,L=[N];for(y=y>>8,N=y&255;N>0;)L.unshift(N),y=y>>8,N=y&255,++P;return k?L.push(P):L.unshift(P),this.update(L),L.length},I.prototype.encodeString=function(y){var k,N=typeof y;if(N!=="string"){if(N==="object"){if(y===null)throw new Error(e);if(l&&y.constructor===ArrayBuffer)y=new Uint8Array(y);else if(!Array.isArray(y)&&(!l||!ArrayBuffer.isView(y)))throw new Error(e)}else throw new Error(e);k=!0}var P=0,L=y.length;if(k)P=L;else for(var u=0;u<y.length;++u){var M=y.charCodeAt(u);M<128?P+=1:M<2048?P+=2:M<55296||M>=57344?P+=3:(M=65536+((M&1023)<<10|y.charCodeAt(++u)&1023),P+=4)}return P+=this.encode(P*8),this.update(y),P},I.prototype.bytepad=function(y,k){for(var N=this.encode(k),P=0;P<y.length;++P)N+=this.encodeString(y[P]);var L=k-N%k,u=[];return u.length=L,this.update(u),this},I.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var y=this.blocks,k=this.lastByteIndex,N=this.blockCount,P=this.s;if(y[k>>2]|=this.padding[k&3],this.lastByteIndex===this.byteCount)for(y[0]=y[N],k=1;k<N+1;++k)y[k]=0;for(y[N-1]|=2147483648,k=0;k<N;++k)P[k]^=y[k];Y(P)}},I.prototype.toString=I.prototype.hex=function(){this.finalize();for(var y=this.blockCount,k=this.s,N=this.outputBlocks,P=this.extraBytes,L=0,u=0,M="",K;u<N;){for(L=0;L<y&&u<N;++L,++u)K=k[L],M+=c[K>>4&15]+c[K&15]+c[K>>12&15]+c[K>>8&15]+c[K>>20&15]+c[K>>16&15]+c[K>>28&15]+c[K>>24&15];u%y===0&&(Y(k),L=0)}return P&&(K=k[L],M+=c[K>>4&15]+c[K&15],P>1&&(M+=c[K>>12&15]+c[K>>8&15]),P>2&&(M+=c[K>>20&15]+c[K>>16&15])),M},I.prototype.arrayBuffer=function(){this.finalize();var y=this.blockCount,k=this.s,N=this.outputBlocks,P=this.extraBytes,L=0,u=0,M=this.outputBits>>3,K;P?K=new ArrayBuffer(N+1<<2):K=new ArrayBuffer(M);for(var G=new Uint32Array(K);u<N;){for(L=0;L<y&&u<N;++L,++u)G[u]=k[L];u%y===0&&Y(k)}return P&&(G[L]=k[L],K=K.slice(0,M)),K},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.digest=I.prototype.array=function(){this.finalize();for(var y=this.blockCount,k=this.s,N=this.outputBlocks,P=this.extraBytes,L=0,u=0,M=[],K,G;u<N;){for(L=0;L<y&&u<N;++L,++u)K=u<<2,G=k[L],M[K]=G&255,M[K+1]=G>>8&255,M[K+2]=G>>16&255,M[K+3]=G>>24&255;u%y===0&&Y(k)}return P&&(K=u<<2,G=k[L],M[K]=G&255,P>1&&(M[K+1]=G>>8&255),P>2&&(M[K+2]=G>>16&255)),M};function H(y,k,N){I.call(this,y,k,N)}H.prototype=new I,H.prototype.finalize=function(){return this.encode(this.outputBits,!0),I.prototype.finalize.call(this)};var Y=function(y){var k,N,P,L,u,M,K,G,W,le,he,pe,Ge,be,ue,Re,ae,se,_e,ne,re,ye,oe,ce,we,fe,de,Ue,me,ge,ut,qe,$e,at,Ke,He,Yt,Ae,Ee,Qe,Se,Ie,Ve,xe,Me,et,Ne,Ce,We,De,ve,tt,Oe,Je,Ur,Xe,ke,gr,mr,yr,wr,vr,At;for(P=0;P<48;P+=2)L=y[0]^y[10]^y[20]^y[30]^y[40],u=y[1]^y[11]^y[21]^y[31]^y[41],M=y[2]^y[12]^y[22]^y[32]^y[42],K=y[3]^y[13]^y[23]^y[33]^y[43],G=y[4]^y[14]^y[24]^y[34]^y[44],W=y[5]^y[15]^y[25]^y[35]^y[45],le=y[6]^y[16]^y[26]^y[36]^y[46],he=y[7]^y[17]^y[27]^y[37]^y[47],pe=y[8]^y[18]^y[28]^y[38]^y[48],Ge=y[9]^y[19]^y[29]^y[39]^y[49],k=pe^(M<<1|K>>>31),N=Ge^(K<<1|M>>>31),y[0]^=k,y[1]^=N,y[10]^=k,y[11]^=N,y[20]^=k,y[21]^=N,y[30]^=k,y[31]^=N,y[40]^=k,y[41]^=N,k=L^(G<<1|W>>>31),N=u^(W<<1|G>>>31),y[2]^=k,y[3]^=N,y[12]^=k,y[13]^=N,y[22]^=k,y[23]^=N,y[32]^=k,y[33]^=N,y[42]^=k,y[43]^=N,k=M^(le<<1|he>>>31),N=K^(he<<1|le>>>31),y[4]^=k,y[5]^=N,y[14]^=k,y[15]^=N,y[24]^=k,y[25]^=N,y[34]^=k,y[35]^=N,y[44]^=k,y[45]^=N,k=G^(pe<<1|Ge>>>31),N=W^(Ge<<1|pe>>>31),y[6]^=k,y[7]^=N,y[16]^=k,y[17]^=N,y[26]^=k,y[27]^=N,y[36]^=k,y[37]^=N,y[46]^=k,y[47]^=N,k=le^(L<<1|u>>>31),N=he^(u<<1|L>>>31),y[8]^=k,y[9]^=N,y[18]^=k,y[19]^=N,y[28]^=k,y[29]^=N,y[38]^=k,y[39]^=N,y[48]^=k,y[49]^=N,be=y[0],ue=y[1],et=y[11]<<4|y[10]>>>28,Ne=y[10]<<4|y[11]>>>28,Ue=y[20]<<3|y[21]>>>29,me=y[21]<<3|y[20]>>>29,yr=y[31]<<9|y[30]>>>23,wr=y[30]<<9|y[31]>>>23,Ie=y[40]<<18|y[41]>>>14,Ve=y[41]<<18|y[40]>>>14,at=y[2]<<1|y[3]>>>31,Ke=y[3]<<1|y[2]>>>31,Re=y[13]<<12|y[12]>>>20,ae=y[12]<<12|y[13]>>>20,Ce=y[22]<<10|y[23]>>>22,We=y[23]<<10|y[22]>>>22,ge=y[33]<<13|y[32]>>>19,ut=y[32]<<13|y[33]>>>19,vr=y[42]<<2|y[43]>>>30,At=y[43]<<2|y[42]>>>30,Je=y[5]<<30|y[4]>>>2,Ur=y[4]<<30|y[5]>>>2,He=y[14]<<6|y[15]>>>26,Yt=y[15]<<6|y[14]>>>26,se=y[25]<<11|y[24]>>>21,_e=y[24]<<11|y[25]>>>21,De=y[34]<<15|y[35]>>>17,ve=y[35]<<15|y[34]>>>17,qe=y[45]<<29|y[44]>>>3,$e=y[44]<<29|y[45]>>>3,ce=y[6]<<28|y[7]>>>4,we=y[7]<<28|y[6]>>>4,Xe=y[17]<<23|y[16]>>>9,ke=y[16]<<23|y[17]>>>9,Ae=y[26]<<25|y[27]>>>7,Ee=y[27]<<25|y[26]>>>7,ne=y[36]<<21|y[37]>>>11,re=y[37]<<21|y[36]>>>11,tt=y[47]<<24|y[46]>>>8,Oe=y[46]<<24|y[47]>>>8,xe=y[8]<<27|y[9]>>>5,Me=y[9]<<27|y[8]>>>5,fe=y[18]<<20|y[19]>>>12,de=y[19]<<20|y[18]>>>12,gr=y[29]<<7|y[28]>>>25,mr=y[28]<<7|y[29]>>>25,Qe=y[38]<<8|y[39]>>>24,Se=y[39]<<8|y[38]>>>24,ye=y[48]<<14|y[49]>>>18,oe=y[49]<<14|y[48]>>>18,y[0]=be^~Re&se,y[1]=ue^~ae&_e,y[10]=ce^~fe&Ue,y[11]=we^~de&me,y[20]=at^~He&Ae,y[21]=Ke^~Yt&Ee,y[30]=xe^~et&Ce,y[31]=Me^~Ne&We,y[40]=Je^~Xe&gr,y[41]=Ur^~ke&mr,y[2]=Re^~se&ne,y[3]=ae^~_e&re,y[12]=fe^~Ue&ge,y[13]=de^~me&ut,y[22]=He^~Ae&Qe,y[23]=Yt^~Ee&Se,y[32]=et^~Ce&De,y[33]=Ne^~We&ve,y[42]=Xe^~gr&yr,y[43]=ke^~mr&wr,y[4]=se^~ne&ye,y[5]=_e^~re&oe,y[14]=Ue^~ge&qe,y[15]=me^~ut&$e,y[24]=Ae^~Qe&Ie,y[25]=Ee^~Se&Ve,y[34]=Ce^~De&tt,y[35]=We^~ve&Oe,y[44]=gr^~yr&vr,y[45]=mr^~wr&At,y[6]=ne^~ye&be,y[7]=re^~oe&ue,y[16]=ge^~qe&ce,y[17]=ut^~$e&we,y[26]=Qe^~Ie&at,y[27]=Se^~Ve&Ke,y[36]=De^~tt&xe,y[37]=ve^~Oe&Me,y[46]=yr^~vr&Je,y[47]=wr^~At&Ur,y[8]=ye^~be&Re,y[9]=oe^~ue&ae,y[18]=qe^~ce&fe,y[19]=$e^~we&de,y[28]=Ie^~at&He,y[29]=Ve^~Ke&Yt,y[38]=tt^~xe&et,y[39]=Oe^~Me&Ne,y[48]=vr^~Je&Xe,y[49]=At^~Ur&ke,y[0]^=B[P],y[1]^=B[P+1]};if(h)t.exports=d;else for(_=0;_<m.length;++_)n[m[_]]=d[m[_]]})()})(hu);var N1=hu.exports;const C1="logger/5.7.0";let eh=!1,th=!1;const Jn={debug:1,default:2,info:2,warning:3,error:4,off:5};let rh=Jn.default,Hs=null;function O1(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}const ih=O1();var xo;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(xo||(xo={}));var lr;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(lr||(lr={}));const nh="0123456789abcdef";let bt=class ft{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();Jn[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(rh>Jn[i])&&console.log.apply(console,r)}debug(...e){this._log(ft.levels.DEBUG,e)}info(...e){this._log(ft.levels.INFO,e)}warn(...e){this._log(ft.levels.WARNING,e)}makeError(e,r,i){if(th)return this.makeError("censored error",r,{});r||(r=ft.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(l=>{const c=i[l];try{if(c instanceof Uint8Array){let g="";for(let w=0;w<c.length;w++)g+=nh[c[w]>>4],g+=nh[c[w]&15];n.push(l+"=Uint8Array(0x"+g+")")}else n.push(l+"="+JSON.stringify(c))}catch{n.push(l+"="+JSON.stringify(i[l].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case lr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const l=e;switch(l){case"overflow":case"underflow":case"division-by-zero":o+="-"+l;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case lr.CALL_EXCEPTION:case lr.INSUFFICIENT_FUNDS:case lr.MISSING_NEW:case lr.NONCE_EXPIRED:case lr.REPLACEMENT_UNDERPRICED:case lr.TRANSACTION_REPLACED:case lr.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const h=new Error(e);return h.reason=s,h.code=r,Object.keys(i).forEach(function(l){h[l]=i[l]}),h}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,ft.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n)}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n)}checkNormalize(e){ih&&this.throwError("platform missing String.prototype.normalize",ft.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ih})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,ft.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,ft.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,ft.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,ft.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",ft.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",ft.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",ft.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return Hs||(Hs=new ft(C1)),Hs}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",ft.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),eh){if(!e)return;this.globalLogger().throwError("error censorship permanent",ft.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}th=!!e,eh=!!r}static setLogLevel(e){const r=Jn[e.toLowerCase()];if(r==null){ft.globalLogger().warn("invalid log level - "+e);return}rh=r}static from(e){return new ft(e)}};bt.errors=lr,bt.levels=xo;const R1="bytes/5.7.0",ht=new bt(R1);function cu(t){return!!t.toHexString}function Ni(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Ni(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function P1(t){return Ht(t)&&!(t.length%2)||Bi(t)}function sh(t){return typeof t=="number"&&t==t&&t%1===0}function Bi(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!sh(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!sh(r)||r<0||r>=256)return!1}return!0}function ot(t,e){if(e||(e={}),typeof t=="number"){ht.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Ni(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),cu(t)&&(t=t.toHexString()),Ht(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":ht.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return Ni(new Uint8Array(i))}return Bi(t)?Ni(new Uint8Array(t)):ht.throwArgumentError("invalid arrayify value","value",t)}function T1(t){const e=t.map(n=>ot(n)),r=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(r);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),Ni(i)}function F1(t,e){t=ot(t),t.length>e&&ht.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),Ni(r)}function Ht(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const Vs="0123456789abcdef";function Nt(t,e){if(e||(e={}),typeof t=="number"){ht.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=Vs[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),cu(t))return t.toHexString();if(Ht(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":ht.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Bi(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=Vs[(n&240)>>4]+Vs[n&15]}return r}return ht.throwArgumentError("invalid hexlify value","value",t)}function L1(t){if(typeof t!="string")t=Nt(t);else if(!Ht(t)||t.length%2)return null;return(t.length-2)/2}function oh(t,e,r){return typeof t!="string"?t=Nt(t):(!Ht(t)||t.length%2)&&ht.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Rr(t,e){for(typeof t!="string"?t=Nt(t):Ht(t)||ht.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&ht.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function uu(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(P1(t)){let r=ot(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Nt(r.slice(0,32)),e.s=Nt(r.slice(32,64))):r.length===65?(e.r=Nt(r.slice(0,32)),e.s=Nt(r.slice(32,64)),e.v=r[64]):ht.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:ht.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Nt(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const n=F1(ot(e._vs),32);e._vs=Nt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&ht.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=Nt(n);e.s==null?e.s=o:e.s!==o&&ht.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?ht.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&ht.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Ht(e.r)?ht.throwArgumentError("signature missing or invalid r","signature",t):e.r=Rr(e.r,32),e.s==null||!Ht(e.s)?ht.throwArgumentError("signature missing or invalid s","signature",t):e.s=Rr(e.s,32);const r=ot(e.s);r[0]>=128&&ht.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Nt(r);e._vs&&(Ht(e._vs)||ht.throwArgumentError("signature invalid _vs","signature",t),e._vs=Rr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&ht.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Jo(t){return"0x"+N1.keccak_256(ot(t))}var lu={exports:{}},U1={},B1=Object.freeze({__proto__:null,default:U1}),q1=M1(B1);(function(t){(function(e,r){function i(a,d){if(!a)throw new Error(d||"Assertion failed")}function n(a,d){a.super_=d;var m=function(){};m.prototype=d.prototype,a.prototype=new m,a.prototype.constructor=a}function s(a,d,m){if(s.isBN(a))return a;this.negative=0,this.words=null,this.length=0,this.red=null,a!==null&&((d==="le"||d==="be")&&(m=d,d=10),this._init(a||0,d||10,m||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=q1.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,d){return a.cmp(d)>0?a:d},s.min=function(a,d){return a.cmp(d)<0?a:d},s.prototype._init=function(a,d,m){if(typeof a=="number")return this._initNumber(a,d,m);if(typeof a=="object")return this._initArray(a,d,m);d==="hex"&&(d=16),i(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_<a.length&&(d===16?this._parseHex(a,_,m):(this._parseBase(a,d,_),m==="le"&&this._initArray(this.toArray(),d,m)))},s.prototype._initNumber=function(a,d,m){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),d,m)},s.prototype._initArray=function(a,d,m){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var A,D,R=0;if(m==="be")for(_=a.length-1,A=0;_>=0;_-=3)D=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[A]|=D<<R&67108863,this.words[A+1]=D>>>26-R&67108863,R+=24,R>=26&&(R-=26,A++);else if(m==="le")for(_=0,A=0;_<a.length;_+=3)D=a[_]|a[_+1]<<8|a[_+2]<<16,this.words[A]|=D<<R&67108863,this.words[A+1]=D>>>26-R&67108863,R+=24,R>=26&&(R-=26,A++);return this._strip()};function h(a,d){var m=a.charCodeAt(d);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;i(!1,"Invalid character in "+a)}function l(a,d,m){var _=h(a,m);return m-1>=d&&(_|=h(a,m-1)<<4),_}s.prototype._parseHex=function(a,d,m){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var A=0,D=0,R;if(m==="be")for(_=a.length-1;_>=d;_-=2)R=l(a,d,_)<<A,this.words[D]|=R&67108863,A>=18?(A-=18,D+=1,this.words[D]|=R>>>26):A+=8;else{var v=a.length-d;for(_=v%2===0?d+1:d;_<a.length;_+=2)R=l(a,d,_)<<A,this.words[D]|=R&67108863,A>=18?(A-=18,D+=1,this.words[D]|=R>>>26):A+=8}this._strip()};function c(a,d,m,_){for(var A=0,D=0,R=Math.min(a.length,m),v=d;v<R;v++){var f=a.charCodeAt(v)-48;A*=_,f>=49?D=f-49+10:f>=17?D=f-17+10:D=f,i(f>=0&&D<_,"Invalid character"),A+=D}return A}s.prototype._parseBase=function(a,d,m){this.words=[0],this.length=1;for(var _=0,A=1;A<=67108863;A*=d)_++;_--,A=A/d|0;for(var D=a.length-m,R=D%_,v=Math.min(D,D-R)+m,f=0,I=m;I<v;I+=_)f=c(a,I,I+_,d),this.imuln(A),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(R!==0){var H=1;for(f=c(a,I,a.length,d),I=0;I<R;I++)H*=d;this.imuln(H),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var d=0;d<this.length;d++)a.words[d]=this.words[d];a.length=this.length,a.negative=this.negative,a.red=this.red};function g(a,d){a.words=d.words,a.length=d.length,a.negative=d.negative,a.red=d.red}if(s.prototype._move=function(a){g(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=w}catch{s.prototype.inspect=w}else s.prototype.inspect=w;function w(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var E=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(a,d){a=a||10,d=d|0||1;var m;if(a===16||a==="hex"){m="";for(var _=0,A=0,D=0;D<this.length;D++){var R=this.words[D],v=((R<<_|A)&16777215).toString(16);A=R>>>24-_&16777215,_+=2,_>=26&&(_-=26,D--),A!==0||D!==this.length-1?m=E[6-v.length]+v+m:m=v+m}for(A!==0&&(m=A.toString(16)+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var f=b[a],I=S[a];m="";var H=this.clone();for(H.negative=0;!H.isZero();){var Y=H.modrn(I).toString(a);H=H.idivn(I),H.isZero()?m=Y+m:m=E[f-Y.length]+Y+m}for(this.isZero()&&(m="0"+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,d){return this.toArrayLike(o,a,d)}),s.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var B=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};s.prototype.toArrayLike=function(a,d,m){this._strip();var _=this.byteLength(),A=m||Math.max(1,_);i(_<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var D=B(a,A),R=d==="le"?"LE":"BE";return this["_toArrayLike"+R](D,_),D},s.prototype._toArrayLikeLE=function(a,d){for(var m=0,_=0,A=0,D=0;A<this.length;A++){var R=this.words[A]<<D|_;a[m++]=R&255,m<a.length&&(a[m++]=R>>8&255),m<a.length&&(a[m++]=R>>16&255),D===6?(m<a.length&&(a[m++]=R>>24&255),_=0,D=0):(_=R>>>24,D+=2)}if(m<a.length)for(a[m++]=_;m<a.length;)a[m++]=0},s.prototype._toArrayLikeBE=function(a,d){for(var m=a.length-1,_=0,A=0,D=0;A<this.length;A++){var R=this.words[A]<<D|_;a[m--]=R&255,m>=0&&(a[m--]=R>>8&255),m>=0&&(a[m--]=R>>16&255),D===6?(m>=0&&(a[m--]=R>>24&255),_=0,D=0):(_=R>>>24,D+=2)}if(m>=0)for(a[m--]=_;m>=0;)a[m--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var d=a,m=0;return d>=4096&&(m+=13,d>>>=13),d>=64&&(m+=7,d>>>=7),d>=8&&(m+=4,d>>>=4),d>=2&&(m+=2,d>>>=2),m+d},s.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,m=0;return d&8191||(m+=13,d>>>=13),d&127||(m+=7,d>>>=7),d&15||(m+=4,d>>>=4),d&3||(m+=2,d>>>=2),d&1||m++,m},s.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function j(a){for(var d=new Array(a.bitLength()),m=0;m<d.length;m++){var _=m/26|0,A=m%26;d[m]=a.words[_]>>>A&1}return d}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;d<this.length;d++){var m=this._zeroBits(this.words[d]);if(a+=m,m!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var d=0;d<a.length;d++)this.words[d]=this.words[d]|a.words[d];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var m=0;m<d.length;m++)this.words[m]=this.words[m]&a.words[m];return this.length=d.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var d,m;this.length>a.length?(d=this,m=a):(d=a,m=this);for(var _=0;_<m.length;_++)this.words[_]=d.words[_]^m.words[_];if(this!==d)for(;_<d.length;_++)this.words[_]=d.words[_];return this.length=d.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,m=a%26;this._expand(d),m>0&&d--;for(var _=0;_<d;_++)this.words[_]=~this.words[_]&67108863;return m>0&&(this.words[_]=~this.words[_]&67108863>>26-m),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,d){i(typeof a=="number"&&a>=0);var m=a/26|0,_=a%26;return this._expand(m+1),d?this.words[m]=this.words[m]|1<<_:this.words[m]=this.words[m]&~(1<<_),this._strip()},s.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var m,_;this.length>a.length?(m=this,_=a):(m=a,_=this);for(var A=0,D=0;D<_.length;D++)d=(m.words[D]|0)+(_.words[D]|0)+A,this.words[D]=d&67108863,A=d>>>26;for(;A!==0&&D<m.length;D++)d=(m.words[D]|0)+A,this.words[D]=d&67108863,A=d>>>26;if(this.length=m.length,A!==0)this.words[this.length]=A,this.length++;else if(m!==this)for(;D<m.length;D++)this.words[D]=m.words[D];return this},s.prototype.add=function(a){var d;return a.negative!==0&&this.negative===0?(a.negative=0,d=this.sub(a),a.negative^=1,d):a.negative===0&&this.negative!==0?(this.negative=0,d=a.sub(this),this.negative=1,d):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,A;m>0?(_=this,A=a):(_=a,A=this);for(var D=0,R=0;R<A.length;R++)d=(_.words[R]|0)-(A.words[R]|0)+D,D=d>>26,this.words[R]=d&67108863;for(;D!==0&&R<_.length;R++)d=(_.words[R]|0)+D,D=d>>26,this.words[R]=d&67108863;if(D===0&&R<_.length&&_!==this)for(;R<_.length;R++)this.words[R]=_.words[R];return this.length=Math.max(this.length,R),_!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function $(a,d,m){m.negative=d.negative^a.negative;var _=a.length+d.length|0;m.length=_,_=_-1|0;var A=a.words[0]|0,D=d.words[0]|0,R=A*D,v=R&67108863,f=R/67108864|0;m.words[0]=v;for(var I=1;I<_;I++){for(var H=f>>>26,Y=f&67108863,y=Math.min(I,d.length-1),k=Math.max(0,I-a.length+1);k<=y;k++){var N=I-k|0;A=a.words[N]|0,D=d.words[k]|0,R=A*D+Y,H+=R/67108864|0,Y=R&67108863}m.words[I]=Y|0,f=H|0}return f!==0?m.words[I]=f|0:m.length--,m._strip()}var U=function(a,d,m){var _=a.words,A=d.words,D=m.words,R=0,v,f,I,H=_[0]|0,Y=H&8191,y=H>>>13,k=_[1]|0,N=k&8191,P=k>>>13,L=_[2]|0,u=L&8191,M=L>>>13,K=_[3]|0,G=K&8191,W=K>>>13,le=_[4]|0,he=le&8191,pe=le>>>13,Ge=_[5]|0,be=Ge&8191,ue=Ge>>>13,Re=_[6]|0,ae=Re&8191,se=Re>>>13,_e=_[7]|0,ne=_e&8191,re=_e>>>13,ye=_[8]|0,oe=ye&8191,ce=ye>>>13,we=_[9]|0,fe=we&8191,de=we>>>13,Ue=A[0]|0,me=Ue&8191,ge=Ue>>>13,ut=A[1]|0,qe=ut&8191,$e=ut>>>13,at=A[2]|0,Ke=at&8191,He=at>>>13,Yt=A[3]|0,Ae=Yt&8191,Ee=Yt>>>13,Qe=A[4]|0,Se=Qe&8191,Ie=Qe>>>13,Ve=A[5]|0,xe=Ve&8191,Me=Ve>>>13,et=A[6]|0,Ne=et&8191,Ce=et>>>13,We=A[7]|0,De=We&8191,ve=We>>>13,tt=A[8]|0,Oe=tt&8191,Je=tt>>>13,Ur=A[9]|0,Xe=Ur&8191,ke=Ur>>>13;m.negative=a.negative^d.negative,m.length=19,v=Math.imul(Y,me),f=Math.imul(Y,ge),f=f+Math.imul(y,me)|0,I=Math.imul(y,ge);var gr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(gr>>>26)|0,gr&=67108863,v=Math.imul(N,me),f=Math.imul(N,ge),f=f+Math.imul(P,me)|0,I=Math.imul(P,ge),v=v+Math.imul(Y,qe)|0,f=f+Math.imul(Y,$e)|0,f=f+Math.imul(y,qe)|0,I=I+Math.imul(y,$e)|0;var mr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(mr>>>26)|0,mr&=67108863,v=Math.imul(u,me),f=Math.imul(u,ge),f=f+Math.imul(M,me)|0,I=Math.imul(M,ge),v=v+Math.imul(N,qe)|0,f=f+Math.imul(N,$e)|0,f=f+Math.imul(P,qe)|0,I=I+Math.imul(P,$e)|0,v=v+Math.imul(Y,Ke)|0,f=f+Math.imul(Y,He)|0,f=f+Math.imul(y,Ke)|0,I=I+Math.imul(y,He)|0;var yr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(yr>>>26)|0,yr&=67108863,v=Math.imul(G,me),f=Math.imul(G,ge),f=f+Math.imul(W,me)|0,I=Math.imul(W,ge),v=v+Math.imul(u,qe)|0,f=f+Math.imul(u,$e)|0,f=f+Math.imul(M,qe)|0,I=I+Math.imul(M,$e)|0,v=v+Math.imul(N,Ke)|0,f=f+Math.imul(N,He)|0,f=f+Math.imul(P,Ke)|0,I=I+Math.imul(P,He)|0,v=v+Math.imul(Y,Ae)|0,f=f+Math.imul(Y,Ee)|0,f=f+Math.imul(y,Ae)|0,I=I+Math.imul(y,Ee)|0;var wr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(wr>>>26)|0,wr&=67108863,v=Math.imul(he,me),f=Math.imul(he,ge),f=f+Math.imul(pe,me)|0,I=Math.imul(pe,ge),v=v+Math.imul(G,qe)|0,f=f+Math.imul(G,$e)|0,f=f+Math.imul(W,qe)|0,I=I+Math.imul(W,$e)|0,v=v+Math.imul(u,Ke)|0,f=f+Math.imul(u,He)|0,f=f+Math.imul(M,Ke)|0,I=I+Math.imul(M,He)|0,v=v+Math.imul(N,Ae)|0,f=f+Math.imul(N,Ee)|0,f=f+Math.imul(P,Ae)|0,I=I+Math.imul(P,Ee)|0,v=v+Math.imul(Y,Se)|0,f=f+Math.imul(Y,Ie)|0,f=f+Math.imul(y,Se)|0,I=I+Math.imul(y,Ie)|0;var vr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(vr>>>26)|0,vr&=67108863,v=Math.imul(be,me),f=Math.imul(be,ge),f=f+Math.imul(ue,me)|0,I=Math.imul(ue,ge),v=v+Math.imul(he,qe)|0,f=f+Math.imul(he,$e)|0,f=f+Math.imul(pe,qe)|0,I=I+Math.imul(pe,$e)|0,v=v+Math.imul(G,Ke)|0,f=f+Math.imul(G,He)|0,f=f+Math.imul(W,Ke)|0,I=I+Math.imul(W,He)|0,v=v+Math.imul(u,Ae)|0,f=f+Math.imul(u,Ee)|0,f=f+Math.imul(M,Ae)|0,I=I+Math.imul(M,Ee)|0,v=v+Math.imul(N,Se)|0,f=f+Math.imul(N,Ie)|0,f=f+Math.imul(P,Se)|0,I=I+Math.imul(P,Ie)|0,v=v+Math.imul(Y,xe)|0,f=f+Math.imul(Y,Me)|0,f=f+Math.imul(y,xe)|0,I=I+Math.imul(y,Me)|0;var At=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(At>>>26)|0,At&=67108863,v=Math.imul(ae,me),f=Math.imul(ae,ge),f=f+Math.imul(se,me)|0,I=Math.imul(se,ge),v=v+Math.imul(be,qe)|0,f=f+Math.imul(be,$e)|0,f=f+Math.imul(ue,qe)|0,I=I+Math.imul(ue,$e)|0,v=v+Math.imul(he,Ke)|0,f=f+Math.imul(he,He)|0,f=f+Math.imul(pe,Ke)|0,I=I+Math.imul(pe,He)|0,v=v+Math.imul(G,Ae)|0,f=f+Math.imul(G,Ee)|0,f=f+Math.imul(W,Ae)|0,I=I+Math.imul(W,Ee)|0,v=v+Math.imul(u,Se)|0,f=f+Math.imul(u,Ie)|0,f=f+Math.imul(M,Se)|0,I=I+Math.imul(M,Ie)|0,v=v+Math.imul(N,xe)|0,f=f+Math.imul(N,Me)|0,f=f+Math.imul(P,xe)|0,I=I+Math.imul(P,Me)|0,v=v+Math.imul(Y,Ne)|0,f=f+Math.imul(Y,Ce)|0,f=f+Math.imul(y,Ne)|0,I=I+Math.imul(y,Ce)|0;var $i=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+($i>>>26)|0,$i&=67108863,v=Math.imul(ne,me),f=Math.imul(ne,ge),f=f+Math.imul(re,me)|0,I=Math.imul(re,ge),v=v+Math.imul(ae,qe)|0,f=f+Math.imul(ae,$e)|0,f=f+Math.imul(se,qe)|0,I=I+Math.imul(se,$e)|0,v=v+Math.imul(be,Ke)|0,f=f+Math.imul(be,He)|0,f=f+Math.imul(ue,Ke)|0,I=I+Math.imul(ue,He)|0,v=v+Math.imul(he,Ae)|0,f=f+Math.imul(he,Ee)|0,f=f+Math.imul(pe,Ae)|0,I=I+Math.imul(pe,Ee)|0,v=v+Math.imul(G,Se)|0,f=f+Math.imul(G,Ie)|0,f=f+Math.imul(W,Se)|0,I=I+Math.imul(W,Ie)|0,v=v+Math.imul(u,xe)|0,f=f+Math.imul(u,Me)|0,f=f+Math.imul(M,xe)|0,I=I+Math.imul(M,Me)|0,v=v+Math.imul(N,Ne)|0,f=f+Math.imul(N,Ce)|0,f=f+Math.imul(P,Ne)|0,I=I+Math.imul(P,Ce)|0,v=v+Math.imul(Y,De)|0,f=f+Math.imul(Y,ve)|0,f=f+Math.imul(y,De)|0,I=I+Math.imul(y,ve)|0;var Ki=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,v=Math.imul(oe,me),f=Math.imul(oe,ge),f=f+Math.imul(ce,me)|0,I=Math.imul(ce,ge),v=v+Math.imul(ne,qe)|0,f=f+Math.imul(ne,$e)|0,f=f+Math.imul(re,qe)|0,I=I+Math.imul(re,$e)|0,v=v+Math.imul(ae,Ke)|0,f=f+Math.imul(ae,He)|0,f=f+Math.imul(se,Ke)|0,I=I+Math.imul(se,He)|0,v=v+Math.imul(be,Ae)|0,f=f+Math.imul(be,Ee)|0,f=f+Math.imul(ue,Ae)|0,I=I+Math.imul(ue,Ee)|0,v=v+Math.imul(he,Se)|0,f=f+Math.imul(he,Ie)|0,f=f+Math.imul(pe,Se)|0,I=I+Math.imul(pe,Ie)|0,v=v+Math.imul(G,xe)|0,f=f+Math.imul(G,Me)|0,f=f+Math.imul(W,xe)|0,I=I+Math.imul(W,Me)|0,v=v+Math.imul(u,Ne)|0,f=f+Math.imul(u,Ce)|0,f=f+Math.imul(M,Ne)|0,I=I+Math.imul(M,Ce)|0,v=v+Math.imul(N,De)|0,f=f+Math.imul(N,ve)|0,f=f+Math.imul(P,De)|0,I=I+Math.imul(P,ve)|0,v=v+Math.imul(Y,Oe)|0,f=f+Math.imul(Y,Je)|0,f=f+Math.imul(y,Oe)|0,I=I+Math.imul(y,Je)|0;var Hi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,v=Math.imul(fe,me),f=Math.imul(fe,ge),f=f+Math.imul(de,me)|0,I=Math.imul(de,ge),v=v+Math.imul(oe,qe)|0,f=f+Math.imul(oe,$e)|0,f=f+Math.imul(ce,qe)|0,I=I+Math.imul(ce,$e)|0,v=v+Math.imul(ne,Ke)|0,f=f+Math.imul(ne,He)|0,f=f+Math.imul(re,Ke)|0,I=I+Math.imul(re,He)|0,v=v+Math.imul(ae,Ae)|0,f=f+Math.imul(ae,Ee)|0,f=f+Math.imul(se,Ae)|0,I=I+Math.imul(se,Ee)|0,v=v+Math.imul(be,Se)|0,f=f+Math.imul(be,Ie)|0,f=f+Math.imul(ue,Se)|0,I=I+Math.imul(ue,Ie)|0,v=v+Math.imul(he,xe)|0,f=f+Math.imul(he,Me)|0,f=f+Math.imul(pe,xe)|0,I=I+Math.imul(pe,Me)|0,v=v+Math.imul(G,Ne)|0,f=f+Math.imul(G,Ce)|0,f=f+Math.imul(W,Ne)|0,I=I+Math.imul(W,Ce)|0,v=v+Math.imul(u,De)|0,f=f+Math.imul(u,ve)|0,f=f+Math.imul(M,De)|0,I=I+Math.imul(M,ve)|0,v=v+Math.imul(N,Oe)|0,f=f+Math.imul(N,Je)|0,f=f+Math.imul(P,Oe)|0,I=I+Math.imul(P,Je)|0,v=v+Math.imul(Y,Xe)|0,f=f+Math.imul(Y,ke)|0,f=f+Math.imul(y,Xe)|0,I=I+Math.imul(y,ke)|0;var Vi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,v=Math.imul(fe,qe),f=Math.imul(fe,$e),f=f+Math.imul(de,qe)|0,I=Math.imul(de,$e),v=v+Math.imul(oe,Ke)|0,f=f+Math.imul(oe,He)|0,f=f+Math.imul(ce,Ke)|0,I=I+Math.imul(ce,He)|0,v=v+Math.imul(ne,Ae)|0,f=f+Math.imul(ne,Ee)|0,f=f+Math.imul(re,Ae)|0,I=I+Math.imul(re,Ee)|0,v=v+Math.imul(ae,Se)|0,f=f+Math.imul(ae,Ie)|0,f=f+Math.imul(se,Se)|0,I=I+Math.imul(se,Ie)|0,v=v+Math.imul(be,xe)|0,f=f+Math.imul(be,Me)|0,f=f+Math.imul(ue,xe)|0,I=I+Math.imul(ue,Me)|0,v=v+Math.imul(he,Ne)|0,f=f+Math.imul(he,Ce)|0,f=f+Math.imul(pe,Ne)|0,I=I+Math.imul(pe,Ce)|0,v=v+Math.imul(G,De)|0,f=f+Math.imul(G,ve)|0,f=f+Math.imul(W,De)|0,I=I+Math.imul(W,ve)|0,v=v+Math.imul(u,Oe)|0,f=f+Math.imul(u,Je)|0,f=f+Math.imul(M,Oe)|0,I=I+Math.imul(M,Je)|0,v=v+Math.imul(N,Xe)|0,f=f+Math.imul(N,ke)|0,f=f+Math.imul(P,Xe)|0,I=I+Math.imul(P,ke)|0;var Gi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,v=Math.imul(fe,Ke),f=Math.imul(fe,He),f=f+Math.imul(de,Ke)|0,I=Math.imul(de,He),v=v+Math.imul(oe,Ae)|0,f=f+Math.imul(oe,Ee)|0,f=f+Math.imul(ce,Ae)|0,I=I+Math.imul(ce,Ee)|0,v=v+Math.imul(ne,Se)|0,f=f+Math.imul(ne,Ie)|0,f=f+Math.imul(re,Se)|0,I=I+Math.imul(re,Ie)|0,v=v+Math.imul(ae,xe)|0,f=f+Math.imul(ae,Me)|0,f=f+Math.imul(se,xe)|0,I=I+Math.imul(se,Me)|0,v=v+Math.imul(be,Ne)|0,f=f+Math.imul(be,Ce)|0,f=f+Math.imul(ue,Ne)|0,I=I+Math.imul(ue,Ce)|0,v=v+Math.imul(he,De)|0,f=f+Math.imul(he,ve)|0,f=f+Math.imul(pe,De)|0,I=I+Math.imul(pe,ve)|0,v=v+Math.imul(G,Oe)|0,f=f+Math.imul(G,Je)|0,f=f+Math.imul(W,Oe)|0,I=I+Math.imul(W,Je)|0,v=v+Math.imul(u,Xe)|0,f=f+Math.imul(u,ke)|0,f=f+Math.imul(M,Xe)|0,I=I+Math.imul(M,ke)|0;var Vr=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Vr>>>26)|0,Vr&=67108863,v=Math.imul(fe,Ae),f=Math.imul(fe,Ee),f=f+Math.imul(de,Ae)|0,I=Math.imul(de,Ee),v=v+Math.imul(oe,Se)|0,f=f+Math.imul(oe,Ie)|0,f=f+Math.imul(ce,Se)|0,I=I+Math.imul(ce,Ie)|0,v=v+Math.imul(ne,xe)|0,f=f+Math.imul(ne,Me)|0,f=f+Math.imul(re,xe)|0,I=I+Math.imul(re,Me)|0,v=v+Math.imul(ae,Ne)|0,f=f+Math.imul(ae,Ce)|0,f=f+Math.imul(se,Ne)|0,I=I+Math.imul(se,Ce)|0,v=v+Math.imul(be,De)|0,f=f+Math.imul(be,ve)|0,f=f+Math.imul(ue,De)|0,I=I+Math.imul(ue,ve)|0,v=v+Math.imul(he,Oe)|0,f=f+Math.imul(he,Je)|0,f=f+Math.imul(pe,Oe)|0,I=I+Math.imul(pe,Je)|0,v=v+Math.imul(G,Xe)|0,f=f+Math.imul(G,ke)|0,f=f+Math.imul(W,Xe)|0,I=I+Math.imul(W,ke)|0;var Qi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,v=Math.imul(fe,Se),f=Math.imul(fe,Ie),f=f+Math.imul(de,Se)|0,I=Math.imul(de,Ie),v=v+Math.imul(oe,xe)|0,f=f+Math.imul(oe,Me)|0,f=f+Math.imul(ce,xe)|0,I=I+Math.imul(ce,Me)|0,v=v+Math.imul(ne,Ne)|0,f=f+Math.imul(ne,Ce)|0,f=f+Math.imul(re,Ne)|0,I=I+Math.imul(re,Ce)|0,v=v+Math.imul(ae,De)|0,f=f+Math.imul(ae,ve)|0,f=f+Math.imul(se,De)|0,I=I+Math.imul(se,ve)|0,v=v+Math.imul(be,Oe)|0,f=f+Math.imul(be,Je)|0,f=f+Math.imul(ue,Oe)|0,I=I+Math.imul(ue,Je)|0,v=v+Math.imul(he,Xe)|0,f=f+Math.imul(he,ke)|0,f=f+Math.imul(pe,Xe)|0,I=I+Math.imul(pe,ke)|0;var Yi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,v=Math.imul(fe,xe),f=Math.imul(fe,Me),f=f+Math.imul(de,xe)|0,I=Math.imul(de,Me),v=v+Math.imul(oe,Ne)|0,f=f+Math.imul(oe,Ce)|0,f=f+Math.imul(ce,Ne)|0,I=I+Math.imul(ce,Ce)|0,v=v+Math.imul(ne,De)|0,f=f+Math.imul(ne,ve)|0,f=f+Math.imul(re,De)|0,I=I+Math.imul(re,ve)|0,v=v+Math.imul(ae,Oe)|0,f=f+Math.imul(ae,Je)|0,f=f+Math.imul(se,Oe)|0,I=I+Math.imul(se,Je)|0,v=v+Math.imul(be,Xe)|0,f=f+Math.imul(be,ke)|0,f=f+Math.imul(ue,Xe)|0,I=I+Math.imul(ue,ke)|0;var Wt=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,v=Math.imul(fe,Ne),f=Math.imul(fe,Ce),f=f+Math.imul(de,Ne)|0,I=Math.imul(de,Ce),v=v+Math.imul(oe,De)|0,f=f+Math.imul(oe,ve)|0,f=f+Math.imul(ce,De)|0,I=I+Math.imul(ce,ve)|0,v=v+Math.imul(ne,Oe)|0,f=f+Math.imul(ne,Je)|0,f=f+Math.imul(re,Oe)|0,I=I+Math.imul(re,Je)|0,v=v+Math.imul(ae,Xe)|0,f=f+Math.imul(ae,ke)|0,f=f+Math.imul(se,Xe)|0,I=I+Math.imul(se,ke)|0;var Wi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,v=Math.imul(fe,De),f=Math.imul(fe,ve),f=f+Math.imul(de,De)|0,I=Math.imul(de,ve),v=v+Math.imul(oe,Oe)|0,f=f+Math.imul(oe,Je)|0,f=f+Math.imul(ce,Oe)|0,I=I+Math.imul(ce,Je)|0,v=v+Math.imul(ne,Xe)|0,f=f+Math.imul(ne,ke)|0,f=f+Math.imul(re,Xe)|0,I=I+Math.imul(re,ke)|0;var Ji=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,v=Math.imul(fe,Oe),f=Math.imul(fe,Je),f=f+Math.imul(de,Oe)|0,I=Math.imul(de,Je),v=v+Math.imul(oe,Xe)|0,f=f+Math.imul(oe,ke)|0,f=f+Math.imul(ce,Xe)|0,I=I+Math.imul(ce,ke)|0;var Xi=(R+v|0)+((f&8191)<<13)|0;R=(I+(f>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,v=Math.imul(fe,Xe),f=Math.imul(fe,ke),f=f+Math.imul(de,Xe)|0,I=Math.imul(de,ke);var Zi=(R+v|0)+((f&8191)<<13)|0;return R=(I+(f>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,D[0]=gr,D[1]=mr,D[2]=yr,D[3]=wr,D[4]=vr,D[5]=At,D[6]=$i,D[7]=Ki,D[8]=Hi,D[9]=Vi,D[10]=Gi,D[11]=Vr,D[12]=Qi,D[13]=Yi,D[14]=Wt,D[15]=Wi,D[16]=Ji,D[17]=Xi,D[18]=Zi,R!==0&&(D[19]=R,m.length++),m};Math.imul||(U=$);function q(a,d,m){m.negative=d.negative^a.negative,m.length=a.length+d.length;for(var _=0,A=0,D=0;D<m.length-1;D++){var R=A;A=0;for(var v=_&67108863,f=Math.min(D,d.length-1),I=Math.max(0,D-a.length+1);I<=f;I++){var H=D-I,Y=a.words[H]|0,y=d.words[I]|0,k=Y*y,N=k&67108863;R=R+(k/67108864|0)|0,N=N+v|0,v=N&67108863,R=R+(N>>>26)|0,A+=R>>>26,R&=67108863}m.words[D]=v,_=R,R=A}return _!==0?m.words[D]=_:m.length--,m._strip()}function C(a,d,m){return q(a,d,m)}s.prototype.mulTo=function(a,d){var m,_=this.length+a.length;return this.length===10&&a.length===10?m=U(this,a,d):_<63?m=$(this,a,d):_<1024?m=q(this,a,d):m=C(this,a,d),m},s.prototype.mul=function(a){var d=new s(null);return d.words=new Array(this.length+a.length),this.mulTo(a,d)},s.prototype.mulf=function(a){var d=new s(null);return d.words=new Array(this.length+a.length),C(this,a,d)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var d=a<0;d&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var m=0,_=0;_<this.length;_++){var A=(this.words[_]|0)*a,D=(A&67108863)+(m&67108863);m>>=26,m+=A/67108864|0,m+=D>>>26,this.words[_]=D&67108863}return m!==0&&(this.words[_]=m,this.length++),d?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var d=j(a);if(d.length===0)return new s(1);for(var m=this,_=0;_<d.length&&d[_]===0;_++,m=m.sqr());if(++_<d.length)for(var A=m.sqr();_<d.length;_++,A=A.sqr())d[_]!==0&&(m=m.mul(A));return m},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=67108863>>>26-d<<26-d,A;if(d!==0){var D=0;for(A=0;A<this.length;A++){var R=this.words[A]&_,v=(this.words[A]|0)-R<<d;this.words[A]=v|D,D=R>>>26-d}D&&(this.words[A]=D,this.length++)}if(m!==0){for(A=this.length-1;A>=0;A--)this.words[A+m]=this.words[A];for(A=0;A<m;A++)this.words[A]=0;this.length+=m}return this._strip()},s.prototype.ishln=function(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,d,m){i(typeof a=="number"&&a>=0);var _;d?_=(d-d%26)/26:_=0;var A=a%26,D=Math.min((a-A)/26,this.length),R=67108863^67108863>>>A<<A,v=m;if(_-=D,_=Math.max(0,_),v){for(var f=0;f<D;f++)v.words[f]=this.words[f];v.length=D}if(D!==0)if(this.length>D)for(this.length-=D,f=0;f<this.length;f++)this.words[f]=this.words[f+D];else this.words[0]=0,this.length=1;var I=0;for(f=this.length-1;f>=0&&(I!==0||f>=_);f--){var H=this.words[f]|0;this.words[f]=I<<26-A|H>>>A,I=H&R}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,d,m){return i(this.negative===0),this.iushrn(a,d,m)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=1<<d;if(this.length<=m)return!1;var A=this.words[m];return!!(A&_)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(d!==0&&m++,this.length=Math.min(m,this.length),d!==0){var _=67108863^67108863>>>d<<d;this.words[this.length-1]&=_}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var d=0;d<this.length&&this.words[d]>=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d<this.length&&this.words[d]<0;d++)this.words[d]+=67108864,this.words[d+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,d,m){var _=a.length+m,A;this._expand(_);var D,R=0;for(A=0;A<a.length;A++){D=(this.words[A+m]|0)+R;var v=(a.words[A]|0)*d;D-=v&67108863,R=(D>>26)-(v/67108864|0),this.words[A+m]=D&67108863}for(;A<this.length-m;A++)D=(this.words[A+m]|0)+R,R=D>>26,this.words[A+m]=D&67108863;if(R===0)return this._strip();for(i(R===-1),R=0,A=0;A<this.length;A++)D=-(this.words[A]|0)+R,R=D>>26,this.words[A]=D&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,d){var m=this.length-a.length,_=this.clone(),A=a,D=A.words[A.length-1]|0,R=this._countBits(D);m=26-R,m!==0&&(A=A.ushln(m),_.iushln(m),D=A.words[A.length-1]|0);var v=_.length-A.length,f;if(d!=="mod"){f=new s(null),f.length=v+1,f.words=new Array(f.length);for(var I=0;I<f.length;I++)f.words[I]=0}var H=_.clone()._ishlnsubmul(A,1,v);H.negative===0&&(_=H,f&&(f.words[v]=1));for(var Y=v-1;Y>=0;Y--){var y=(_.words[A.length+Y]|0)*67108864+(_.words[A.length+Y-1]|0);for(y=Math.min(y/D|0,67108863),_._ishlnsubmul(A,y,Y);_.negative!==0;)y--,_.negative=0,_._ishlnsubmul(A,1,Y),_.isZero()||(_.negative^=1);f&&(f.words[Y]=y)}return f&&f._strip(),_._strip(),d!=="div"&&m!==0&&_.iushrn(m),{div:f||null,mod:_}},s.prototype.divmod=function(a,d,m){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var _,A,D;return this.negative!==0&&a.negative===0?(D=this.neg().divmod(a,d),d!=="mod"&&(_=D.div.neg()),d!=="div"&&(A=D.mod.neg(),m&&A.negative!==0&&A.iadd(a)),{div:_,mod:A}):this.negative===0&&a.negative!==0?(D=this.divmod(a.neg(),d),d!=="mod"&&(_=D.div.neg()),{div:_,mod:D.mod}):this.negative&a.negative?(D=this.neg().divmod(a.neg(),d),d!=="div"&&(A=D.mod.neg(),m&&A.negative!==0&&A.isub(a)),{div:D.div,mod:A}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,d)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var m=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),A=a.andln(1),D=m.cmp(_);return D<0||A===1&&D===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},s.prototype.modrn=function(a){var d=a<0;d&&(a=-a),i(a<=67108863);for(var m=(1<<26)%a,_=0,A=this.length-1;A>=0;A--)_=(m*_+(this.words[A]|0))%a;return d?-_:_},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var d=a<0;d&&(a=-a),i(a<=67108863);for(var m=0,_=this.length-1;_>=0;_--){var A=(this.words[_]|0)+m*67108864;this.words[_]=A/a|0,m=A%a}return this._strip(),d?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new s(1),A=new s(0),D=new s(0),R=new s(1),v=0;d.isEven()&&m.isEven();)d.iushrn(1),m.iushrn(1),++v;for(var f=m.clone(),I=d.clone();!d.isZero();){for(var H=0,Y=1;!(d.words[0]&Y)&&H<26;++H,Y<<=1);if(H>0)for(d.iushrn(H);H-- >0;)(_.isOdd()||A.isOdd())&&(_.iadd(f),A.isub(I)),_.iushrn(1),A.iushrn(1);for(var y=0,k=1;!(m.words[0]&k)&&y<26;++y,k<<=1);if(y>0)for(m.iushrn(y);y-- >0;)(D.isOdd()||R.isOdd())&&(D.iadd(f),R.isub(I)),D.iushrn(1),R.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(D),A.isub(R)):(m.isub(d),D.isub(_),R.isub(A))}return{a:D,b:R,gcd:m.iushln(v)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new s(1),A=new s(0),D=m.clone();d.cmpn(1)>0&&m.cmpn(1)>0;){for(var R=0,v=1;!(d.words[0]&v)&&R<26;++R,v<<=1);if(R>0)for(d.iushrn(R);R-- >0;)_.isOdd()&&_.iadd(D),_.iushrn(1);for(var f=0,I=1;!(m.words[0]&I)&&f<26;++f,I<<=1);if(f>0)for(m.iushrn(f);f-- >0;)A.isOdd()&&A.iadd(D),A.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(A)):(m.isub(d),A.isub(_))}var H;return d.cmpn(1)===0?H=_:H=A,H.cmpn(0)<0&&H.iadd(a),H},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),m=a.clone();d.negative=0,m.negative=0;for(var _=0;d.isEven()&&m.isEven();_++)d.iushrn(1),m.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;m.isEven();)m.iushrn(1);var A=d.cmp(m);if(A<0){var D=d;d=m,m=D}else if(A===0||m.cmpn(1)===0)break;d.isub(m)}while(!0);return m.iushln(_)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var d=a%26,m=(a-d)/26,_=1<<d;if(this.length<=m)return this._expand(m+1),this.words[m]|=_,this;for(var A=_,D=m;A!==0&&D<this.length;D++){var R=this.words[D]|0;R+=A,A=R>>>26,R&=67108863,this.words[D]=R}return A!==0&&(this.words[D]=A,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var m;if(this.length>1)m=1;else{d&&(a=-a),i(a<=67108863,"Number is too big");var _=this.words[0]|0;m=_===a?0:_<a?-1:1}return this.negative!==0?-m|0:m},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var d=this.ucmp(a);return this.negative!==0?-d|0:d},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var d=0,m=this.length-1;m>=0;m--){var _=this.words[m]|0,A=a.words[m]|0;if(_!==A){_<A?d=-1:_>A&&(d=1);break}}return d},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new X(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var F={k256:null,p224:null,p192:null,p25519:null};function T(a,d){this.name=a,this.p=new s(d,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}T.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},T.prototype.ireduce=function(a){var d=a,m;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),m=d.bitLength();while(m>this.n);var _=m<this.n?-1:d.ucmp(this.p);return _===0?(d.words[0]=0,d.length=1):_>0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},T.prototype.split=function(a,d){a.iushrn(this.n,0,d)},T.prototype.imulK=function(a){return a.imul(this.k)};function p(){T.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(p,T),p.prototype.split=function(a,d){for(var m=4194303,_=Math.min(a.length,9),A=0;A<_;A++)d.words[A]=a.words[A];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var D=a.words[9];for(d.words[d.length++]=D&m,A=10;A<a.length;A++){var R=a.words[A]|0;a.words[A-10]=(R&m)<<4|D>>>22,D=R}D>>>=22,a.words[A-10]=D,D===0&&a.length>10?a.length-=10:a.length-=9},p.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,m=0;m<a.length;m++){var _=a.words[m]|0;d+=_*977,a.words[m]=d&67108863,d=_*64+(d/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function x(){T.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(x,T);function V(){T.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(V,T);function J(){T.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(J,T),J.prototype.imulK=function(a){for(var d=0,m=0;m<a.length;m++){var _=(a.words[m]|0)*19+d,A=_&67108863;_>>>=26,a.words[m]=A,d=_}return d!==0&&(a.words[a.length++]=d),a},s._prime=function(a){if(F[a])return F[a];var d;if(a==="k256")d=new p;else if(a==="p224")d=new x;else if(a==="p192")d=new V;else if(a==="p25519")d=new J;else throw new Error("Unknown prime "+a);return F[a]=d,d};function X(a){if(typeof a=="string"){var d=s._prime(a);this.m=d.p,this.prime=d}else i(a.gtn(1),"modulus must be greater than 1"),this.m=a,this.prime=null}X.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},X.prototype._verify2=function(a,d){i((a.negative|d.negative)===0,"red works only with positives"),i(a.red&&a.red===d.red,"red works only with red numbers")},X.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(g(a,a.umod(this.m)._forceRed(this)),a)},X.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},X.prototype.add=function(a,d){this._verify2(a,d);var m=a.add(d);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},X.prototype.iadd=function(a,d){this._verify2(a,d);var m=a.iadd(d);return m.cmp(this.m)>=0&&m.isub(this.m),m},X.prototype.sub=function(a,d){this._verify2(a,d);var m=a.sub(d);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},X.prototype.isub=function(a,d){this._verify2(a,d);var m=a.isub(d);return m.cmpn(0)<0&&m.iadd(this.m),m},X.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},X.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},X.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},X.prototype.isqr=function(a){return this.imul(a,a.clone())},X.prototype.sqr=function(a){return this.mul(a,a)},X.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(i(d%2===1),d===3){var m=this.m.add(new s(1)).iushrn(2);return this.pow(a,m)}for(var _=this.m.subn(1),A=0;!_.isZero()&&_.andln(1)===0;)A++,_.iushrn(1);i(!_.isZero());var D=new s(1).toRed(this),R=D.redNeg(),v=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);this.pow(f,v).cmp(R)!==0;)f.redIAdd(R);for(var I=this.pow(f,_),H=this.pow(a,_.addn(1).iushrn(1)),Y=this.pow(a,_),y=A;Y.cmp(D)!==0;){for(var k=Y,N=0;k.cmp(D)!==0;N++)k=k.redSqr();i(N<y);var P=this.pow(I,new s(1).iushln(y-N-1));H=H.redMul(P),I=P.redSqr(),Y=Y.redMul(I),y=N}return H},X.prototype.invm=function(a){var d=a._invmp(this.m);return d.negative!==0?(d.negative=0,this.imod(d).redNeg()):this.imod(d)},X.prototype.pow=function(a,d){if(d.isZero())return new s(1).toRed(this);if(d.cmpn(1)===0)return a.clone();var m=4,_=new Array(1<<m);_[0]=new s(1).toRed(this),_[1]=a;for(var A=2;A<_.length;A++)_[A]=this.mul(_[A-1],a);var D=_[0],R=0,v=0,f=d.bitLength()%26;for(f===0&&(f=26),A=d.length-1;A>=0;A--){for(var I=d.words[A],H=f-1;H>=0;H--){var Y=I>>H&1;if(D!==_[0]&&(D=this.sqr(D)),Y===0&&R===0){v=0;continue}R<<=1,R|=Y,v++,!(v!==m&&(A!==0||H!==0))&&(D=this.mul(D,_[R]),v=0,R=0)}f=26}return D},X.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},X.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},s.mont=function(a){return new ee(a)};function ee(a){X.call(this,a),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(ee,X),ee.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},ee.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},ee.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=m.isub(_).iushrn(this.shift),D=A;return A.cmp(this.m)>=0?D=A.isub(this.m):A.cmpn(0)<0&&(D=A.iadd(this.m)),D._forceRed(this)},ee.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new s(0)._forceRed(this);var m=a.mul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=m.isub(_).iushrn(this.shift),D=A;return A.cmp(this.m)>=0?D=A.isub(this.m):A.cmpn(0)<0&&(D=A.iadd(this.m)),D._forceRed(this)},ee.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(t,au)})(lu);var Pe=lu.exports;const fu="bignumber/5.7.0";var hs=Pe.BN;const kr=new bt(fu),Gs={},ah=9007199254740991;function j1(t){return t!=null&&(Tt.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||Ht(t)||typeof t=="bigint"||Bi(t))}let hh=!1,Tt=class cr{constructor(e,r){e!==Gs&&kr.throwError("cannot call constructor directly; use BigNumber.from",bt.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Ft(je(this).fromTwos(e))}toTwos(e){return Ft(je(this).toTwos(e))}abs(){return this._hex[0]==="-"?cr.from(this._hex.substring(1)):this}add(e){return Ft(je(this).add(je(e)))}sub(e){return Ft(je(this).sub(je(e)))}div(e){return cr.from(e).isZero()&&Zt("division-by-zero","div"),Ft(je(this).div(je(e)))}mul(e){return Ft(je(this).mul(je(e)))}mod(e){const r=je(e);return r.isNeg()&&Zt("division-by-zero","mod"),Ft(je(this).umod(r))}pow(e){const r=je(e);return r.isNeg()&&Zt("negative-power","pow"),Ft(je(this).pow(r))}and(e){const r=je(e);return(this.isNegative()||r.isNeg())&&Zt("unbound-bitwise-result","and"),Ft(je(this).and(r))}or(e){const r=je(e);return(this.isNegative()||r.isNeg())&&Zt("unbound-bitwise-result","or"),Ft(je(this).or(r))}xor(e){const r=je(e);return(this.isNegative()||r.isNeg())&&Zt("unbound-bitwise-result","xor"),Ft(je(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&Zt("negative-width","mask"),Ft(je(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Zt("negative-width","shl"),Ft(je(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Zt("negative-width","shr"),Ft(je(this).shrn(e))}eq(e){return je(this).eq(je(e))}lt(e){return je(this).lt(je(e))}lte(e){return je(this).lte(je(e))}gt(e){return je(this).gt(je(e))}gte(e){return je(this).gte(je(e))}isNegative(){return this._hex[0]==="-"}isZero(){return je(this).isZero()}toNumber(){try{return je(this).toNumber()}catch{Zt("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return kr.throwError("this platform does not support BigInt",bt.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?hh||(hh=!0,kr.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?kr.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",bt.errors.UNEXPECTED_ARGUMENT,{}):kr.throwError("BigNumber.toString does not accept parameters",bt.errors.UNEXPECTED_ARGUMENT,{})),je(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof cr)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new cr(Gs,_n(e)):e.match(/^-?[0-9]+$/)?new cr(Gs,_n(new hs(e))):kr.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Zt("underflow","BigNumber.from",e),(e>=ah||e<=-ah)&&Zt("overflow","BigNumber.from",e),cr.from(String(e));const r=e;if(typeof r=="bigint")return cr.from(r.toString());if(Bi(r))return cr.from(Nt(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return cr.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(Ht(i)||i[0]==="-"&&Ht(i.substring(1))))return cr.from(i)}return kr.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}};function _n(t){if(typeof t!="string")return _n(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&kr.throwArgumentError("invalid hex","value",t),t=_n(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function Ft(t){return Tt.from(_n(t))}function je(t){const e=Tt.from(t).toHexString();return e[0]==="-"?new hs("-"+e.substring(3),16):new hs(e.substring(2),16)}function Zt(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),kr.throwError(t,bt.errors.NUMERIC_FAULT,i)}function z1(t){return new hs(t,36).toString(16)}const Ct=new bt(fu),pn={},du=Tt.from(0),pu=Tt.from(-1);function gu(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Ct.throwError(t,bt.errors.NUMERIC_FAULT,n)}let gn="0";for(;gn.length<256;)gn+=gn;function Xo(t){if(typeof t!="number")try{t=Tt.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+gn.substring(0,t):Ct.throwArgumentError("invalid decimal size","decimals",t)}function Qs(t,e){e==null&&(e=0);const r=Xo(e);t=Tt.from(t);const i=t.lt(du);i&&(t=t.mul(pu));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=t.div(r).toString();return r.length===1?t=s:t=s+"."+n,i&&(t="-"+t),t}function qr(t,e){e==null&&(e=0);const r=Xo(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Ct.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Ct.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Ct.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>r.length-1&&gu("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const h=Tt.from(s),l=Tt.from(o);let c=h.mul(r).add(l);return i&&(c=c.mul(pu)),c}let Ys=class Mo{constructor(e,r,i,n){e!==pn&&Ct.throwError("cannot use FixedFormat constructor; use FixedFormat.from",bt.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=r,this.width=i,this.decimals=n,this.name=(r?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=Xo(n),Object.freeze(this)}static from(e){if(e instanceof Mo)return e;typeof e=="number"&&(e=`fixed128x${e}`);let r=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")r=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Ct.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,h,l)=>e[o]==null?l:(typeof e[o]!==h&&Ct.throwArgumentError("invalid fixed format ("+o+" not "+h+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Ct.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Ct.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Mo(pn,r,i,n)}},mu=class Mt{constructor(e,r,i,n){e!==pn&&Ct.throwError("cannot use FixedNumber constructor; use FixedNumber.from",bt.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=r,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Ct.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=qr(this._value,this.format.decimals),i=qr(e._value,e.format.decimals);return Mt.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=qr(this._value,this.format.decimals),i=qr(e._value,e.format.decimals);return Mt.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=qr(this._value,this.format.decimals),i=qr(e._value,e.format.decimals);return Mt.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=qr(this._value,this.format.decimals),i=qr(e._value,e.format.decimals);return Mt.fromValue(r.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Mt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(ch.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Mt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(ch.toFormat(r.format))),r}round(e){e==null&&(e=0);const r=this.toString().split(".");if(r.length===1&&r.push("0"),(e<0||e>80||e%1)&&Ct.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=Mt.from("1"+gn.substring(0,e),this.format),n=k1.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Ct.throwArgumentError("invalid byte width","width",e);const r=Tt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Rr(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Mt.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!j1(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),Mt.fromString(Qs(e,r),Ys.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Ys.from(r),n=qr(e,i.decimals);!i.signed&&n.lt(du)&&gu("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Rr(s,i.width/8));const o=Qs(n,i.decimals);return new Mt(pn,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Ys.from(r);if(ot(e).length>i.width/8)throw new Error("overflow");let n=Tt.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=Qs(n,i.decimals);return new Mt(pn,s,o,i)}static from(e,r){if(typeof e=="string")return Mt.fromString(e,r);if(Bi(e))return Mt.fromBytes(e,r);try{return Mt.fromValue(e,0,r)}catch(i){if(i.code!==bt.errors.INVALID_ARGUMENT)throw i}return Ct.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}};const ch=mu.from(1),k1=mu.from("0.5"),$1="strings/5.7.0",K1=new bt($1);var cs;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(cs||(cs={}));var uh;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})(uh||(uh={}));function Ws(t,e=cs.current){e!=cs.current&&(K1.checkNormalize(),t=t.normalize(e));let r=[];for(let i=0;i<t.length;i++){const n=t.charCodeAt(i);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(n&63|128);else if((n&64512)==55296){i++;const s=t.charCodeAt(i);if(i>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(n&63|128)}return ot(r)}function H1(t){if(t.length%4!==0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e}function Js(t,e){e||(e=function(n){return[parseInt(n,16)]});let r=0,i={};return t.split(",").forEach(n=>{let s=n.split(":");r+=parseInt(s[0],16),i[r]=e(s[1])}),i}function lh(t){let e=0;return t.split(",").map(r=>{let i=r.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}lh("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Js("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Js("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Js("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",H1),lh("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function V1(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return ot(e)}function yu(t,e){e==null&&(e=1);const r=[],i=r.forEach,n=function(s,o){i.call(s,function(h){o>0&&Array.isArray(h)?n(h,o-1):r.push(h)})};return n(t,e),r}function G1(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}return e}function Q1(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let F=1;F<i;F++)s.push(n+=r());let o=r(),h=e;e+=o;let l=0,c=0;function g(){return l==0&&(c=c<<8|t[e++],l=8),c>>--l&1}const w=31,E=Math.pow(2,w),b=E>>>1,S=b>>1,B=E-1;let j=0;for(let F=0;F<w;F++)j=j<<1|g();let $=[],U=0,q=E;for(;;){let F=Math.floor(((j-U+1)*n-1)/q),T=0,p=i;for(;p-T>1;){let J=T+p>>>1;F<s[J]?p=J:T=J}if(T==0)break;$.push(T);let x=U+Math.floor(q*s[T]/n),V=U+Math.floor(q*s[T+1]/n)-1;for(;!((x^V)&b);)j=j<<1&B|g(),x=x<<1&B,V=V<<1&B|1;for(;x&~V&S;)j=j&b|j<<1&B>>>1|g(),x=x<<1^b,V=(V^b)<<1|b|1;U=x,q=1+V-x}let C=i-4;return $.map(F=>{switch(F-C){case 3:return C+65792+(t[h++]<<16|t[h++]<<8|t[h++]);case 2:return C+256+(t[h++]<<8|t[h++]);case 1:return C+t[h++];default:return F-1}})}function Y1(t){let e=0;return()=>t[e++]}function W1(t){return Y1(Q1(t))}function J1(t){return t&1?~t>>1:t>>1}function X1(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}function fh(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function Z1(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=J1(e());return r}function us(t,e){let r=fh(t(),t),i=t(),n=fh(i,t),s=X1(i,t);for(let o=0;o<i;o++)for(let h=0;h<s[o];h++)r.push(n[o]+h);return e?r.map(o=>e[o]):r}function eg(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(rg(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(ig(r,t))}return G1(yu(e))}function tg(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(r)}return e}function wu(t,e,r){let i=Array(t).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)Z1(t,r).forEach((s,o)=>i[o].push(s));return i}function rg(t,e){let r=1+e(),i=e(),n=tg(e),s=wu(n.length,1+t,e);return yu(s.map((o,h)=>{const l=o[0],c=o.slice(1);return Array(n[h]).fill(void 0).map((g,w)=>{let E=w*i;return[l+w*r,c.map(b=>b+E)]})}))}function ig(t,e){let r=1+e();return wu(r,1+t,e).map(i=>[i[0],i.slice(1)])}function ng(t){let e=us(t).sort((i,n)=>i-n);return r();function r(){let i=[];for(;;){let c=us(t,e);if(c.length==0)break;i.push({set:new Set(c),node:r()})}i.sort((c,g)=>g.set.size-c.set.size);let n=t(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let h=n==1,l=n==2;return{branches:i,valid:s,fe0f:o,save:h,check:l}}}function sg(){return W1(V1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const $n=sg();new Set(us($n)),new Set(us($n)),eg($n),ng($n);const og=new Uint8Array(32);og.fill(0);const ag=`Ethereum Signed Message:
`;function vu(t){return typeof t=="string"&&(t=Ws(t)),Jo(T1([Ws(ag),Ws(String(t.length)),t]))}const hg="address/5.7.0",ln=new bt(hg);function dh(t){Ht(t,20)||ln.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);const i=ot(Jo(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const cg=9007199254740991;function ug(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const Zo={};for(let t=0;t<10;t++)Zo[String(t)]=String(t);for(let t=0;t<26;t++)Zo[String.fromCharCode(65+t)]=String(10+t);const ph=Math.floor(ug(cg));function lg(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>Zo[i]).join("");for(;e.length>=ph;){let i=e.substring(0,ph);e=parseInt(i,10)%97+e.substring(i.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function fg(t){let e=null;if(typeof t!="string"&&ln.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=dh(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ln.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==lg(t)&&ln.throwArgumentError("bad icap checksum","address",t),e=z1(t.substring(4));e.length<40;)e="0"+e;e=dh("0x"+e)}else ln.throwArgumentError("invalid address","address",t);return e}function sn(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}const dg=new Uint8Array(32);dg.fill(0),Tt.from(-1);const pg=Tt.from(0),gg=Tt.from(1);Tt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Rr(gg.toHexString(),32),Rr(pg.toHexString(),32);var _r={},ze={},On=bu;function bu(t,e){if(!t)throw new Error(e||"Assertion failed")}bu.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var No={exports:{}};typeof Object.create=="function"?No.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:No.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var mg=On,yg=No.exports;ze.inherits=yg;function wg(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function vg(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):wg(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}ze.toArray=vg;function bg(t){for(var e="",r=0;r<t.length;r++)e+=_u(t[r].toString(16));return e}ze.toHex=bg;function Eu(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}ze.htonl=Eu;function Eg(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=Eu(n)),r+=Au(n.toString(16))}return r}ze.toHex32=Eg;function _u(t){return t.length===1?"0"+t:t}ze.zero2=_u;function Au(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}ze.zero8=Au;function _g(t,e,r,i){var n=r-e;mg(n%4===0);for(var s=new Array(n/4),o=0,h=e;o<s.length;o++,h+=4){var l;i==="big"?l=t[h]<<24|t[h+1]<<16|t[h+2]<<8|t[h+3]:l=t[h+3]<<24|t[h+2]<<16|t[h+1]<<8|t[h],s[o]=l>>>0}return s}ze.join32=_g;function Ag(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}ze.split32=Ag;function Sg(t,e){return t>>>e|t<<32-e}ze.rotr32=Sg;function Ig(t,e){return t<<e|t>>>32-e}ze.rotl32=Ig;function Dg(t,e){return t+e>>>0}ze.sum32=Dg;function xg(t,e,r){return t+e+r>>>0}ze.sum32_3=xg;function Mg(t,e,r,i){return t+e+r+i>>>0}ze.sum32_4=Mg;function Ng(t,e,r,i,n){return t+e+r+i+n>>>0}ze.sum32_5=Ng;function Cg(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,h=(o<i?1:0)+r+n;t[e]=h>>>0,t[e+1]=o}ze.sum64=Cg;function Og(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}ze.sum64_hi=Og;function Rg(t,e,r,i){var n=e+i;return n>>>0}ze.sum64_lo=Rg;function Pg(t,e,r,i,n,s,o,h){var l=0,c=e;c=c+i>>>0,l+=c<e?1:0,c=c+s>>>0,l+=c<s?1:0,c=c+h>>>0,l+=c<h?1:0;var g=t+r+n+o+l;return g>>>0}ze.sum64_4_hi=Pg;function Tg(t,e,r,i,n,s,o,h){var l=e+i+s+h;return l>>>0}ze.sum64_4_lo=Tg;function Fg(t,e,r,i,n,s,o,h,l,c){var g=0,w=e;w=w+i>>>0,g+=w<e?1:0,w=w+s>>>0,g+=w<s?1:0,w=w+h>>>0,g+=w<h?1:0,w=w+c>>>0,g+=w<c?1:0;var E=t+r+n+o+l+g;return E>>>0}ze.sum64_5_hi=Fg;function Lg(t,e,r,i,n,s,o,h,l,c){var g=e+i+s+h+c;return g>>>0}ze.sum64_5_lo=Lg;function Ug(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}ze.rotr64_hi=Ug;function Bg(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ze.rotr64_lo=Bg;function qg(t,e,r){return t>>>r}ze.shr64_hi=qg;function jg(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ze.shr64_lo=jg;var qi={},gh=ze,zg=On;function Kn(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}qi.BlockHash=Kn,Kn.prototype.update=function(t,e){if(t=gh.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var r=t.length%this._delta8;this.pending=t.slice(t.length-r,t.length),this.pending.length===0&&(this.pending=null),t=gh.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},Kn.prototype.digest=function(t){return this.update(this._pad()),zg(this.pending===null),this._digest(t)},Kn.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,this.endian==="big"){for(var s=8;s<this.padLength;s++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=t&255}else for(i[n++]=t&255,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s<this.padLength;s++)i[n++]=0;return i};var Ii={},Lr={},kg=ze,Pr=kg.rotr32;function $g(t,e,r,i){if(t===0)return Su(e,r,i);if(t===1||t===3)return Du(e,r,i);if(t===2)return Iu(e,r,i)}Lr.ft_1=$g;function Su(t,e,r){return t&e^~t&r}Lr.ch32=Su;function Iu(t,e,r){return t&e^t&r^e&r}Lr.maj32=Iu;function Du(t,e,r){return t^e^r}Lr.p32=Du;function Kg(t){return Pr(t,2)^Pr(t,13)^Pr(t,22)}Lr.s0_256=Kg;function Hg(t){return Pr(t,6)^Pr(t,11)^Pr(t,25)}Lr.s1_256=Hg;function Vg(t){return Pr(t,7)^Pr(t,18)^t>>>3}Lr.g0_256=Vg;function Gg(t){return Pr(t,17)^Pr(t,19)^t>>>10}Lr.g1_256=Gg;var Ri=ze,Qg=qi,Yg=Lr,Xs=Ri.rotl32,on=Ri.sum32,Wg=Ri.sum32_5,Jg=Yg.ft_1,xu=Qg.BlockHash,Xg=[1518500249,1859775393,2400959708,3395469782];function Mr(){if(!(this instanceof Mr))return new Mr;xu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ri.inherits(Mr,xu);var Zg=Mr;Mr.blockSize=512,Mr.outSize=160,Mr.hmacStrength=80,Mr.padLength=64,Mr.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=Xs(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],s=this.h[1],o=this.h[2],h=this.h[3],l=this.h[4];for(i=0;i<r.length;i++){var c=~~(i/20),g=Wg(Xs(n,5),Jg(c,s,o,h),l,r[i],Xg[c]);l=h,h=o,o=Xs(s,30),s=n,n=g}this.h[0]=on(this.h[0],n),this.h[1]=on(this.h[1],s),this.h[2]=on(this.h[2],o),this.h[3]=on(this.h[3],h),this.h[4]=on(this.h[4],l)},Mr.prototype._digest=function(t){return t==="hex"?Ri.toHex32(this.h,"big"):Ri.split32(this.h,"big")};var Pi=ze,em=qi,ji=Lr,tm=On,ar=Pi.sum32,rm=Pi.sum32_4,im=Pi.sum32_5,nm=ji.ch32,sm=ji.maj32,om=ji.s0_256,am=ji.s1_256,hm=ji.g0_256,cm=ji.g1_256,Mu=em.BlockHash,um=[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 Nr(){if(!(this instanceof Nr))return new Nr;Mu.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=um,this.W=new Array(64)}Pi.inherits(Nr,Mu);var Nu=Nr;Nr.blockSize=512,Nr.outSize=256,Nr.hmacStrength=192,Nr.padLength=64,Nr.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=rm(cm(r[i-2]),r[i-7],hm(r[i-15]),r[i-16]);var n=this.h[0],s=this.h[1],o=this.h[2],h=this.h[3],l=this.h[4],c=this.h[5],g=this.h[6],w=this.h[7];for(tm(this.k.length===r.length),i=0;i<r.length;i++){var E=im(w,am(l),nm(l,c,g),this.k[i],r[i]),b=ar(om(n),sm(n,s,o));w=g,g=c,c=l,l=ar(h,E),h=o,o=s,s=n,n=ar(E,b)}this.h[0]=ar(this.h[0],n),this.h[1]=ar(this.h[1],s),this.h[2]=ar(this.h[2],o),this.h[3]=ar(this.h[3],h),this.h[4]=ar(this.h[4],l),this.h[5]=ar(this.h[5],c),this.h[6]=ar(this.h[6],g),this.h[7]=ar(this.h[7],w)},Nr.prototype._digest=function(t){return t==="hex"?Pi.toHex32(this.h,"big"):Pi.split32(this.h,"big")};var Co=ze,Cu=Nu;function $r(){if(!(this instanceof $r))return new $r;Cu.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Co.inherits($r,Cu);var lm=$r;$r.blockSize=512,$r.outSize=224,$r.hmacStrength=192,$r.padLength=64,$r.prototype._digest=function(t){return t==="hex"?Co.toHex32(this.h.slice(0,7),"big"):Co.split32(this.h.slice(0,7),"big")};var jt=ze,fm=qi,dm=On,Tr=jt.rotr64_hi,Fr=jt.rotr64_lo,Ou=jt.shr64_hi,Ru=jt.shr64_lo,Yr=jt.sum64,Zs=jt.sum64_hi,eo=jt.sum64_lo,pm=jt.sum64_4_hi,gm=jt.sum64_4_lo,mm=jt.sum64_5_hi,ym=jt.sum64_5_lo,Pu=fm.BlockHash,wm=[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 dr(){if(!(this instanceof dr))return new dr;Pu.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=wm,this.W=new Array(160)}jt.inherits(dr,Pu);var Tu=dr;dr.blockSize=1024,dr.outSize=512,dr.hmacStrength=192,dr.padLength=128,dr.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=Nm(r[i-4],r[i-3]),s=Cm(r[i-4],r[i-3]),o=r[i-14],h=r[i-13],l=xm(r[i-30],r[i-29]),c=Mm(r[i-30],r[i-29]),g=r[i-32],w=r[i-31];r[i]=pm(n,s,o,h,l,c,g,w),r[i+1]=gm(n,s,o,h,l,c,g,w)}},dr.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],h=this.h[4],l=this.h[5],c=this.h[6],g=this.h[7],w=this.h[8],E=this.h[9],b=this.h[10],S=this.h[11],B=this.h[12],j=this.h[13],$=this.h[14],U=this.h[15];dm(this.k.length===r.length);for(var q=0;q<r.length;q+=2){var C=$,F=U,T=Im(w,E),p=Dm(w,E),x=vm(w,E,b,S,B),V=bm(w,E,b,S,B,j),J=this.k[q],X=this.k[q+1],ee=r[q],a=r[q+1],d=mm(C,F,T,p,x,V,J,X,ee,a),m=ym(C,F,T,p,x,V,J,X,ee,a);C=Am(i,n),F=Sm(i,n),T=Em(i,n,s,o,h),p=_m(i,n,s,o,h,l);var _=Zs(C,F,T,p),A=eo(C,F,T,p);$=B,U=j,B=b,j=S,b=w,S=E,w=Zs(c,g,d,m),E=eo(g,g,d,m),c=h,g=l,h=s,l=o,s=i,o=n,i=Zs(d,m,_,A),n=eo(d,m,_,A)}Yr(this.h,0,i,n),Yr(this.h,2,s,o),Yr(this.h,4,h,l),Yr(this.h,6,c,g),Yr(this.h,8,w,E),Yr(this.h,10,b,S),Yr(this.h,12,B,j),Yr(this.h,14,$,U)},dr.prototype._digest=function(t){return t==="hex"?jt.toHex32(this.h,"big"):jt.split32(this.h,"big")};function vm(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function bm(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function Em(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function _m(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function Am(t,e){var r=Tr(t,e,28),i=Tr(e,t,2),n=Tr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function Sm(t,e){var r=Fr(t,e,28),i=Fr(e,t,2),n=Fr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function Im(t,e){var r=Tr(t,e,14),i=Tr(t,e,18),n=Tr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function Dm(t,e){var r=Fr(t,e,14),i=Fr(t,e,18),n=Fr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function xm(t,e){var r=Tr(t,e,1),i=Tr(t,e,8),n=Ou(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function Mm(t,e){var r=Fr(t,e,1),i=Fr(t,e,8),n=Ru(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function Nm(t,e){var r=Tr(t,e,19),i=Tr(e,t,29),n=Ou(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function Cm(t,e){var r=Fr(t,e,19),i=Fr(e,t,29),n=Ru(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Oo=ze,Fu=Tu;function Kr(){if(!(this instanceof Kr))return new Kr;Fu.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Oo.inherits(Kr,Fu);var Om=Kr;Kr.blockSize=1024,Kr.outSize=384,Kr.hmacStrength=192,Kr.padLength=128,Kr.prototype._digest=function(t){return t==="hex"?Oo.toHex32(this.h.slice(0,12),"big"):Oo.split32(this.h.slice(0,12),"big")},Ii.sha1=Zg,Ii.sha224=lm,Ii.sha256=Nu,Ii.sha384=Om,Ii.sha512=Tu;var Lu={},li=ze,Rm=qi,Hn=li.rotl32,mh=li.sum32,an=li.sum32_3,yh=li.sum32_4,Uu=Rm.BlockHash;function Ar(){if(!(this instanceof Ar))return new Ar;Uu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}li.inherits(Ar,Uu),Lu.ripemd160=Ar,Ar.blockSize=512,Ar.outSize=160,Ar.hmacStrength=192,Ar.padLength=64,Ar.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],s=this.h[3],o=this.h[4],h=r,l=i,c=n,g=s,w=o,E=0;E<80;E++){var b=mh(Hn(yh(r,wh(E,i,n,s),t[Fm[E]+e],Pm(E)),Um[E]),o);r=o,o=s,s=Hn(n,10),n=i,i=b,b=mh(Hn(yh(h,wh(79-E,l,c,g),t[Lm[E]+e],Tm(E)),Bm[E]),w),h=w,w=g,g=Hn(c,10),c=l,l=b}b=an(this.h[1],n,g),this.h[1]=an(this.h[2],s,w),this.h[2]=an(this.h[3],o,h),this.h[3]=an(this.h[4],r,l),this.h[4]=an(this.h[0],i,c),this.h[0]=b},Ar.prototype._digest=function(t){return t==="hex"?li.toHex32(this.h,"little"):li.split32(this.h,"little")};function wh(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function Pm(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function Tm(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var Fm=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Lm=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Um=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Bm=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],qm=ze,jm=On;function Ci(t,e,r){if(!(this instanceof Ci))return new Ci(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(qm.toArray(e,r))}var zm=Ci;Ci.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),jm(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=new this.Hash().update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=new this.Hash().update(t)},Ci.prototype.update=function(t,e){return this.inner.update(t,e),this},Ci.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=t;e.utils=ze,e.common=qi,e.sha=Ii,e.ripemd=Lu,e.hmac=zm,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(_r);function zi(t,e,r){return r={path:e,exports:{},require:function(i,n){return km(i,n??r.path)}},t(r,r.exports),r.exports}function km(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var ea=Bu;function Bu(t,e){if(!t)throw new Error(e||"Assertion failed")}Bu.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var pr=zi(function(t,e){var r=e;function i(o,h){if(Array.isArray(o))return o.slice();if(!o)return[];var l=[];if(typeof o!="string"){for(var c=0;c<o.length;c++)l[c]=o[c]|0;return l}if(h==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var c=0;c<o.length;c+=2)l.push(parseInt(o[c]+o[c+1],16))}else for(var c=0;c<o.length;c++){var g=o.charCodeAt(c),w=g>>8,E=g&255;w?l.push(w,E):l.push(E)}return l}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var h="",l=0;l<o.length;l++)h+=n(o[l].toString(16));return h}r.toHex=s,r.encode=function(o,h){return h==="hex"?s(o):o}}),Vt=zi(function(t,e){var r=e;r.assert=ea,r.toArray=pr.toArray,r.zero2=pr.zero2,r.toHex=pr.toHex,r.encode=pr.encode;function i(l,c,g){var w=new Array(Math.max(l.bitLength(),g)+1);w.fill(0);for(var E=1<<c+1,b=l.clone(),S=0;S<w.length;S++){var B,j=b.andln(E-1);b.isOdd()?(j>(E>>1)-1?B=(E>>1)-j:B=j,b.isubn(B)):B=0,w[S]=B,b.iushrn(1)}return w}r.getNAF=i;function n(l,c){var g=[[],[]];l=l.clone(),c=c.clone();for(var w=0,E=0,b;l.cmpn(-w)>0||c.cmpn(-E)>0;){var S=l.andln(3)+w&3,B=c.andln(3)+E&3;S===3&&(S=-1),B===3&&(B=-1);var j;S&1?(b=l.andln(7)+w&7,(b===3||b===5)&&B===2?j=-S:j=S):j=0,g[0].push(j);var $;B&1?(b=c.andln(7)+E&7,(b===3||b===5)&&S===2?$=-B:$=B):$=0,g[1].push($),2*w===j+1&&(w=1-w),2*E===$+1&&(E=1-E),l.iushrn(1),c.iushrn(1)}return g}r.getJSF=n;function s(l,c,g){var w="_"+c;l.prototype[c]=function(){return this[w]!==void 0?this[w]:this[w]=g.call(this)}}r.cachedProperty=s;function o(l){return typeof l=="string"?r.toArray(l,"hex"):l}r.parseBytes=o;function h(l){return new Pe(l,"hex","le")}r.intFromLE=h}),Vn=Vt.getNAF,$m=Vt.getJSF,ls=Vt.assert;function Xr(t,e){this.type=t,this.p=new Pe(e.p,16),this.red=e.prime?Pe.red(e.prime):Pe.mont(this.p),this.zero=new Pe(0).toRed(this.red),this.one=new Pe(1).toRed(this.red),this.two=new Pe(2).toRed(this.red),this.n=e.n&&new Pe(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var yi=Xr;Xr.prototype.point=function(){throw new Error("Not implemented")},Xr.prototype.validate=function(){throw new Error("Not implemented")},Xr.prototype._fixedNafMul=function(t,e){ls(t.precomputed);var r=t._getDoubles(),i=Vn(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2===0?2:1);n/=3;var s=[],o,h;for(o=0;o<i.length;o+=r.step){h=0;for(var l=o+r.step-1;l>=o;l--)h=(h<<1)+i[l];s.push(h)}for(var c=this.jpoint(null,null,null),g=this.jpoint(null,null,null),w=n;w>0;w--){for(o=0;o<s.length;o++)h=s[o],h===w?g=g.mixedAdd(r.points[o]):h===-w&&(g=g.mixedAdd(r.points[o].neg()));c=c.add(g)}return c.toP()},Xr.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=Vn(e,r,this._bitLength),o=this.jpoint(null,null,null),h=s.length-1;h>=0;h--){for(var l=0;h>=0&&s[h]===0;h--)l++;if(h>=0&&l++,o=o.dblp(l),h<0)break;var c=s[h];ls(c!==0),t.type==="affine"?c>0?o=o.mixedAdd(n[c-1>>1]):o=o.mixedAdd(n[-c-1>>1].neg()):c>0?o=o.add(n[c-1>>1]):o=o.add(n[-c-1>>1].neg())}return t.type==="affine"?o.toP():o},Xr.prototype._wnafMulAdd=function(t,e,r,i,n){var s=this._wnafT1,o=this._wnafT2,h=this._wnafT3,l=0,c,g,w;for(c=0;c<i;c++){w=e[c];var E=w._getNAFPoints(t);s[c]=E.wnd,o[c]=E.points}for(c=i-1;c>=1;c-=2){var b=c-1,S=c;if(s[b]!==1||s[S]!==1){h[b]=Vn(r[b],s[b],this._bitLength),h[S]=Vn(r[S],s[S],this._bitLength),l=Math.max(h[b].length,l),l=Math.max(h[S].length,l);continue}var B=[e[b],null,null,e[S]];e[b].y.cmp(e[S].y)===0?(B[1]=e[b].add(e[S]),B[2]=e[b].toJ().mixedAdd(e[S].neg())):e[b].y.cmp(e[S].y.redNeg())===0?(B[1]=e[b].toJ().mixedAdd(e[S]),B[2]=e[b].add(e[S].neg())):(B[1]=e[b].toJ().mixedAdd(e[S]),B[2]=e[b].toJ().mixedAdd(e[S].neg()));var j=[-3,-1,-5,-7,0,7,5,1,3],$=$m(r[b],r[S]);for(l=Math.max($[0].length,l),h[b]=new Array(l),h[S]=new Array(l),g=0;g<l;g++){var U=$[0][g]|0,q=$[1][g]|0;h[b][g]=j[(U+1)*3+(q+1)],h[S][g]=0,o[b]=B}}var C=this.jpoint(null,null,null),F=this._wnafT4;for(c=l;c>=0;c--){for(var T=0;c>=0;){var p=!0;for(g=0;g<i;g++)F[g]=h[g][c]|0,F[g]!==0&&(p=!1);if(!p)break;T++,c--}if(c>=0&&T++,C=C.dblp(T),c<0)break;for(g=0;g<i;g++){var x=F[g];x!==0&&(x>0?w=o[g][x-1>>1]:x<0&&(w=o[g][-x-1>>1].neg()),w.type==="affine"?C=C.mixedAdd(w):C=C.add(w))}}for(c=0;c<i;c++)o[c]=null;return n?C:C.toP()};function er(t,e){this.curve=t,this.type=e,this.precomputed=null}Xr.BasePoint=er,er.prototype.eq=function(){throw new Error("Not implemented")},er.prototype.validate=function(){return this.curve.validate(this)},Xr.prototype.decodePoint=function(t,e){t=Vt.toArray(t,e);var r=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*r){t[0]===6?ls(t[t.length-1]%2===0):t[0]===7&&ls(t[t.length-1]%2===1);var i=this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));return i}else if((t[0]===2||t[0]===3)&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),t[0]===3);throw new Error("Unknown point format")},er.prototype.encodeCompressed=function(t){return this.encode(t,!0)},er.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},er.prototype.encode=function(t,e){return Vt.encode(this._encode(e),t)},er.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},er.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((t.bitLength()+1)/e.step):!1},er.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},er.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=r===1?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},er.prototype._getBeta=function(){return null},er.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var ta=zi(function(t){typeof Object.create=="function"?t.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}}),Km=Vt.assert;function sr(t){yi.call(this,"short",t),this.a=new Pe(t.a,16).toRed(this.red),this.b=new Pe(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}ta(sr,yi);var Hm=sr;sr.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,r;if(t.beta)e=new Pe(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=i[0].cmp(i[1])<0?i[0]:i[1],e=e.toRed(this.red)}if(t.lambda)r=new Pe(t.lambda,16);else{var n=this._getEndoRoots(this.n);this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))===0?r=n[0]:(r=n[1],Km(this.g.mul(r).x.cmp(this.g.x.redMul(e))===0))}var s;return t.basis?s=t.basis.map(function(o){return{a:new Pe(o.a,16),b:new Pe(o.b,16)}}):s=this._getEndoBasis(r),{beta:e,lambda:r,basis:s}}},sr.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:Pe.mont(t),r=new Pe(2).toRed(e).redInvm(),i=r.redNeg(),n=new Pe(3).toRed(e).redNeg().redSqrt().redMul(r),s=i.redAdd(n).fromRed(),o=i.redSub(n).fromRed();return[s,o]},sr.prototype._getEndoBasis=function(t){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),r=t,i=this.n.clone(),n=new Pe(1),s=new Pe(0),o=new Pe(0),h=new Pe(1),l,c,g,w,E,b,S,B=0,j,$;r.cmpn(0)!==0;){var U=i.div(r);j=i.sub(U.mul(r)),$=o.sub(U.mul(n));var q=h.sub(U.mul(s));if(!g&&j.cmp(e)<0)l=S.neg(),c=n,g=j.neg(),w=$;else if(g&&++B===2)break;S=j,i=r,r=j,o=n,n=$,h=s,s=q}E=j.neg(),b=$;var C=g.sqr().add(w.sqr()),F=E.sqr().add(b.sqr());return F.cmp(C)>=0&&(E=l,b=c),g.negative&&(g=g.neg(),w=w.neg()),E.negative&&(E=E.neg(),b=b.neg()),[{a:g,b:w},{a:E,b}]},sr.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),h=s.mul(i.a),l=n.mul(r.b),c=s.mul(i.b),g=t.sub(o).sub(h),w=l.add(c).neg();return{k1:g,k2:w}},sr.prototype.pointFromX=function(t,e){t=new Pe(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(i.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},sr.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return r.redSqr().redISub(n).cmpn(0)===0},sr.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),h=t[s],l=h._getBeta();o.k1.negative&&(o.k1.ineg(),h=h.neg(!0)),o.k2.negative&&(o.k2.ineg(),l=l.neg(!0)),i[s*2]=h,i[s*2+1]=l,n[s*2]=o.k1,n[s*2+1]=o.k2}for(var c=this._wnafMulAdd(1,i,n,s*2,r),g=0;g<s*2;g++)i[g]=null,n[g]=null;return c};function pt(t,e,r,i){yi.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Pe(e,16),this.y=new Pe(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}ta(pt,yi.BasePoint),sr.prototype.point=function(t,e,r){return new pt(this,t,e,r)},sr.prototype.pointFromJSON=function(t,e){return pt.fromJSON(this,t,e)},pt.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(n){return r.point(n.x.redMul(r.endo.beta),n.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},pt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},pt.fromJSON=function(t,e,r){typeof e=="string"&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(o){return t.point(o[0],o[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},pt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},pt.prototype.isInfinity=function(){return this.inf},pt.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(this.x.cmp(t.x)===0)return this.curve.point(null,null);var e=this.y.redSub(t.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},pt.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},pt.prototype.getX=function(){return this.x.fromRed()},pt.prototype.getY=function(){return this.y.fromRed()},pt.prototype.mul=function(t){return t=new Pe(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},pt.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},pt.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},pt.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)},pt.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(n){return n.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},pt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function yt(t,e,r,i){yi.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Pe(0)):(this.x=new Pe(e,16),this.y=new Pe(r,16),this.z=new Pe(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}ta(yt,yi.BasePoint),sr.prototype.jpoint=function(t,e,r){return new yt(this,t,e,r)},yt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},yt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),h=i.redSub(n),l=s.redSub(o);if(h.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=h.redSqr(),g=c.redMul(h),w=i.redMul(c),E=l.redSqr().redIAdd(g).redISub(w).redISub(w),b=l.redMul(w.redISub(E)).redISub(s.redMul(g)),S=this.z.redMul(t.z).redMul(h);return this.curve.jpoint(E,b,S)},yt.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),h=n.redSub(s);if(o.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=o.redSqr(),c=l.redMul(o),g=r.redMul(l),w=h.redSqr().redIAdd(c).redISub(g).redISub(g),E=h.redMul(g.redISub(w)).redISub(n.redMul(c)),b=this.z.redMul(o);return this.curve.jpoint(w,E,b)},yt.prototype.dblp=function(t){if(t===0)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,h=this.z,l=h.redSqr().redSqr(),c=o.redAdd(o);for(e=0;e<t;e++){var g=s.redSqr(),w=c.redSqr(),E=w.redSqr(),b=g.redAdd(g).redIAdd(g).redIAdd(i.redMul(l)),S=s.redMul(w),B=b.redSqr().redISub(S.redAdd(S)),j=S.redISub(B),$=b.redMul(j);$=$.redIAdd($).redISub(E);var U=c.redMul(h);e+1<t&&(l=l.redMul(E)),s=B,h=U,c=$}return this.curve.jpoint(s,c.redMul(n),h)},yt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},yt.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var h=i.redAdd(i).redIAdd(i),l=h.redSqr().redISub(o).redISub(o),c=s.redIAdd(s);c=c.redIAdd(c),c=c.redIAdd(c),t=l,e=h.redMul(o.redISub(l)).redISub(c),r=this.y.redAdd(this.y)}else{var g=this.x.redSqr(),w=this.y.redSqr(),E=w.redSqr(),b=this.x.redAdd(w).redSqr().redISub(g).redISub(E);b=b.redIAdd(b);var S=g.redAdd(g).redIAdd(g),B=S.redSqr(),j=E.redIAdd(E);j=j.redIAdd(j),j=j.redIAdd(j),t=B.redISub(b).redISub(b),e=S.redMul(b.redISub(t)).redISub(j),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)},yt.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var h=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),l=h.redSqr().redISub(o).redISub(o);t=l;var c=s.redIAdd(s);c=c.redIAdd(c),c=c.redIAdd(c),e=h.redMul(o.redISub(l)).redISub(c),r=this.y.redAdd(this.y)}else{var g=this.z.redSqr(),w=this.y.redSqr(),E=this.x.redMul(w),b=this.x.redSub(g).redMul(this.x.redAdd(g));b=b.redAdd(b).redIAdd(b);var S=E.redIAdd(E);S=S.redIAdd(S);var B=S.redAdd(S);t=b.redSqr().redISub(B),r=this.y.redAdd(this.z).redSqr().redISub(w).redISub(g);var j=w.redSqr();j=j.redIAdd(j),j=j.redIAdd(j),j=j.redIAdd(j),e=b.redMul(S.redISub(t)).redISub(j)}return this.curve.jpoint(t,e,r)},yt.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),h=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),l=e.redAdd(e);l=l.redIAdd(l);var c=l.redMul(o),g=h.redSqr().redISub(c.redAdd(c)),w=c.redISub(g),E=o.redSqr();E=E.redIAdd(E),E=E.redIAdd(E),E=E.redIAdd(E);var b=h.redMul(w).redISub(E),S=r.redAdd(r).redMul(i);return this.curve.jpoint(g,b,S)},yt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(s);var h=o.redSqr(),l=i.redIAdd(i);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var c=n.redIAdd(o).redSqr().redISub(s).redISub(h).redISub(l),g=e.redMul(c);g=g.redIAdd(g),g=g.redIAdd(g);var w=this.x.redMul(h).redISub(g);w=w.redIAdd(w),w=w.redIAdd(w);var E=this.y.redMul(c.redMul(l.redISub(c)).redISub(o.redMul(h)));E=E.redIAdd(E),E=E.redIAdd(E),E=E.redIAdd(E);var b=this.z.redAdd(o).redSqr().redISub(r).redISub(h);return this.curve.jpoint(w,E,b)},yt.prototype.mul=function(t,e){return t=new Pe(t,e),this.curve._wnafMul(this,t)},yt.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0)!==0)return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)===0},yt.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(this.x.cmp(r)===0)return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},yt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},yt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Xn=zi(function(t,e){var r=e;r.base=yi,r.short=Hm,r.mont=null,r.edwards=null}),Zn=zi(function(t,e){var r=e,i=Vt.assert;function n(h){h.type==="short"?this.curve=new Xn.short(h):h.type==="edwards"?this.curve=new Xn.edwards(h):this.curve=new Xn.mont(h),this.g=this.curve.g,this.n=this.curve.n,this.hash=h.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(h,l){Object.defineProperty(r,h,{configurable:!0,enumerable:!0,get:function(){var c=new n(l);return Object.defineProperty(r,h,{configurable:!0,enumerable:!0,value:c}),c}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:_r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:_r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:_r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:_r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:_r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:_r.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:_r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:_r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Zr(t){if(!(this instanceof Zr))return new Zr(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=pr.toArray(t.entropy,t.entropyEnc||"hex"),r=pr.toArray(t.nonce,t.nonceEnc||"hex"),i=pr.toArray(t.pers,t.persEnc||"hex");ea(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var vh=Zr;Zr.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},Zr.prototype._hmac=function(){return new _r.hmac(this.hash,this.K)},Zr.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Zr.prototype.reseed=function(t,e,r,i){typeof e!="string"&&(i=r,r=e,e=null),t=pr.toArray(t,e),r=pr.toArray(r,i),ea(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Zr.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=r,r=e,e=null),r&&(r=pr.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var s=n.slice(0,t);return this._update(r),this._reseed++,pr.encode(s,e)};var to=Vt.assert;function Dt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var ro=Dt;Dt.fromPublic=function(t,e,r){return e instanceof Dt?e:new Dt(t,{pub:e,pubEnc:r})},Dt.fromPrivate=function(t,e,r){return e instanceof Dt?e:new Dt(t,{priv:e,privEnc:r})},Dt.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Dt.prototype.getPublic=function(t,e){return typeof t=="string"&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Dt.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv},Dt.prototype._importPrivate=function(t,e){this.priv=new Pe(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Dt.prototype._importPublic=function(t,e){if(t.x||t.y){this.ec.curve.type==="mont"?to(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&to(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,e)},Dt.prototype.derive=function(t){return t.validate()||to(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Dt.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Dt.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Dt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Vm=Vt.assert;function Ms(t,e){if(t instanceof Ms)return t;this._importDER(t,e)||(Vm(t.r&&t.s,"Signature without r or s"),this.r=new Pe(t.r,16),this.s=new Pe(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Gn=Ms;function Gm(){this.place=0}function io(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function bh(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}Ms.prototype._importDER=function(t,e){t=Vt.toArray(t,e);var r=new Gm;if(t[r.place++]!==48)return!1;var i=io(t,r);if(i===!1||i+r.place!==t.length||t[r.place++]!==2)return!1;var n=io(t,r);if(n===!1)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,t[r.place++]!==2)return!1;var o=io(t,r);if(o===!1||t.length!==o+r.place)return!1;var h=t.slice(r.place,o+r.place);if(s[0]===0)if(s[1]&128)s=s.slice(1);else return!1;if(h[0]===0)if(h[1]&128)h=h.slice(1);else return!1;return this.r=new Pe(s),this.s=new Pe(h),this.recoveryParam=null,!0};function no(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Ms.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),r[0]&128&&(r=[0].concat(r)),e=bh(e),r=bh(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var i=[2];no(i,e.length),i=i.concat(e),i.push(2),no(i,r.length);var n=i.concat(r),s=[48];return no(s,n.length),s=s.concat(n),Vt.encode(s,t)};var Qm=function(){throw new Error("unsupported")},qu=Vt.assert;function ir(t){if(!(this instanceof ir))return new ir(t);typeof t=="string"&&(qu(Object.prototype.hasOwnProperty.call(Zn,t),"Unknown curve "+t),t=Zn[t]),t instanceof Zn.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Ym=ir;ir.prototype.keyPair=function(t){return new ro(this,t)},ir.prototype.keyFromPrivate=function(t,e){return ro.fromPrivate(this,t,e)},ir.prototype.keyFromPublic=function(t,e){return ro.fromPublic(this,t,e)},ir.prototype.genKeyPair=function(t){t||(t={});for(var e=new vh({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Qm(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new Pe(2));;){var n=new Pe(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},ir.prototype._truncateToN=function(t,e){var r=t.byteLength()*8-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},ir.prototype.sign=function(t,e,r,i){typeof r=="object"&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new Pe(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),h=new vh({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),l=this.n.sub(new Pe(1)),c=0;;c++){var g=i.k?i.k(c):new Pe(h.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(l)>=0)){var w=this.g.mul(g);if(!w.isInfinity()){var E=w.getX(),b=E.umod(this.n);if(b.cmpn(0)!==0){var S=g.invm(this.n).mul(b.mul(e.getPrivate()).iadd(t));if(S=S.umod(this.n),S.cmpn(0)!==0){var B=(w.getY().isOdd()?1:0)|(E.cmp(b)!==0?2:0);return i.canonical&&S.cmp(this.nh)>0&&(S=this.n.sub(S),B^=1),new Gn({r:b,s:S,recoveryParam:B})}}}}}},ir.prototype.verify=function(t,e,r,i){t=this._truncateToN(new Pe(t,16)),r=this.keyFromPublic(r,i),e=new Gn(e,"hex");var n=e.r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o=s.invm(this.n),h=o.mul(t).umod(this.n),l=o.mul(n).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(h,r.getPublic(),l),c.isInfinity()?!1:c.eqXToP(n)):(c=this.g.mulAdd(h,r.getPublic(),l),c.isInfinity()?!1:c.getX().umod(this.n).cmp(n)===0)},ir.prototype.recoverPubKey=function(t,e,r,i){qu((3&r)===r,"The recovery param is more than two bits"),e=new Gn(e,i);var n=this.n,s=new Pe(t),o=e.r,h=e.s,l=r&1,c=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var g=e.r.invm(n),w=n.sub(s).mul(g).umod(n),E=h.mul(g).umod(n);return this.g.mulAdd(w,o,E)},ir.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Gn(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Wm=zi(function(t,e){var r=e;r.version="6.5.4",r.utils=Vt,r.rand=function(){throw new Error("unsupported")},r.curve=Xn,r.curves=Zn,r.ec=Ym,r.eddsa=null}),Jm=Wm.ec;const Xm="signing-key/5.7.0",Ro=new bt(Xm);let so=null;function Cr(){return so||(so=new Jm("secp256k1")),so}class Zm{constructor(e){sn(this,"curve","secp256k1"),sn(this,"privateKey",Nt(e)),L1(this.privateKey)!==32&&Ro.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=Cr().keyFromPrivate(ot(this.privateKey));sn(this,"publicKey","0x"+r.getPublic(!1,"hex")),sn(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),sn(this,"_isSigningKey",!0)}_addPoint(e){const r=Cr().keyFromPublic(ot(this.publicKey)),i=Cr().keyFromPublic(ot(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=Cr().keyFromPrivate(ot(this.privateKey)),i=ot(e);i.length!==32&&Ro.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return uu({recoveryParam:n.recoveryParam,r:Rr("0x"+n.r.toString(16),32),s:Rr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=Cr().keyFromPrivate(ot(this.privateKey)),i=Cr().keyFromPublic(ot(ju(e)));return Rr("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function ey(t,e){const r=uu(e),i={r:ot(r.r),s:ot(r.s)};return"0x"+Cr().recoverPubKey(ot(t),i,r.recoveryParam).encode("hex",!1)}function ju(t,e){const r=ot(t);if(r.length===32){const i=new Zm(r);return e?"0x"+Cr().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?Nt(r):"0x"+Cr().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+Cr().keyFromPublic(r).getPublic(!0,"hex"):Nt(r)}return Ro.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Eh;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(Eh||(Eh={}));function ty(t){const e=ju(t);return fg(oh(Jo(oh(e,1)),12))}function ry(t,e){return ty(ey(ot(t),e))}const iy="https://rpc.walletconnect.com/v1";async function ny(t,e,r,i,n,s){switch(r.t){case"eip191":return sy(t,e,r.s);case"eip1271":return await oy(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function sy(t,e,r){return ry(vu(e),r).toLowerCase()===t.toLowerCase()}async function oy(t,e,r,i,n,s){try{const o="0x1626ba7e",h="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",c=r.substring(2),g=vu(e).substring(2),w=o+g+h+l+c,E=await fetch(`${s||iy}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:ay(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:w},"latest"]})}),{result:b}=await E.json();return b?b.slice(0,o.length).toLowerCase()===o.toLowerCase():!1}catch(o){return console.error("isValidEip1271Signature: ",o),!1}}function ay(){return Date.now()+Math.floor(Math.random()*1e3)}var hy=Object.defineProperty,cy=Object.defineProperties,uy=Object.getOwnPropertyDescriptors,_h=Object.getOwnPropertySymbols,ly=Object.prototype.hasOwnProperty,fy=Object.prototype.propertyIsEnumerable,Ah=(t,e,r)=>e in t?hy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dy=(t,e)=>{for(var r in e||(e={}))ly.call(e,r)&&Ah(t,r,e[r]);if(_h)for(var r of _h(e))fy.call(e,r)&&Ah(t,r,e[r]);return t},py=(t,e)=>cy(t,uy(e));const gy="did:pkh:",ra=t=>t?.split(":"),zu=t=>{const e=t&&ra(t);if(e)return t.includes(gy)?e[3]:e[1]},Sh=t=>{const e=t&&ra(t);if(e)return e[2]+":"+e[3]},fs=t=>{const e=t&&ra(t);if(e)return e.pop()};async function Ih(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=ku(n,n.iss),o=fs(n.iss);return await ny(o,s,i,zu(n.iss),r)}const ku=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=fs(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,h=`Chain ID: ${zu(e)}`,l=`Nonce: ${t.nonce}`,c=`Issued At: ${t.iat}`,g=t.exp?`Expiration Time: ${t.exp}`:void 0,w=t.nbf?`Not Before: ${t.nbf}`:void 0,E=t.requestId?`Request ID: ${t.requestId}`:void 0,b=t.resources?`Resources:${t.resources.map(B=>`
- ${B}`).join("")}`:void 0,S=es(t.resources);if(S){const B=An(S);n=Sy(n,B)}return[r,i,"",n,"",s,o,h,l,c,g,w,E,b].filter(B=>B!=null).join(`
`)};function my(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function yy(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function di(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function wy(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:vy(e,r,i)}}}function vy(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function $u(t){return di(t),`urn:recap:${my(t).replace(/=/g,"")}`}function An(t){const e=yy(t.replace("urn:recap:",""));return di(e),e}function by(t,e,r){const i=wy(t,e,r);return $u(i)}function Ey(t){return t&&t.includes("urn:recap:")}function _y(t,e){const r=An(t),i=An(e),n=Ay(r,i);return $u(n)}function Ay(t,e){di(t),di(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((h,l)=>h.localeCompare(l)).forEach(h=>{var l,c;i.att[n]=py(dy({},i.att[n]),{[h]:((l=t.att[n])==null?void 0:l[h])||((c=e.att[n])==null?void 0:c[h])})})}),i}function Sy(t="",e){di(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(h=>{const l=Object.keys(e.att[h]).map(w=>({ability:w.split("/")[0],action:w.split("/")[1]}));l.sort((w,E)=>w.action.localeCompare(E.action));const c={};l.forEach(w=>{c[w.ability]||(c[w.ability]=[]),c[w.ability].push(w.action)});const g=Object.keys(c).map(w=>(n++,`(${n}) '${w}': '${c[w].join("', '")}' for '${h}'.`));i.push(g.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Dh(t){var e;const r=An(t);di(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function xh(t){const e=An(t);di(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function es(t){if(!t)return;const e=t?.[t.length-1];return Ey(e)?e:void 0}const Ku="base10",Rt="base16",Po="base64pad",ia="utf8",Hu=0,Hr=1,Iy=0,Mh=1,To=12,na=32;function Dy(){const t=Qo.generateKeyPair();return{privateKey:Pt(t.secretKey,Rt),publicKey:Pt(t.publicKey,Rt)}}function Fo(){const t=Ti.randomBytes(na);return Pt(t,Rt)}function xy(t,e){const r=Qo.sharedKey(qt(t,Rt),qt(e,Rt),!0),i=new i1(xs.SHA256,r).expand(na);return Pt(i,Rt)}function ts(t){const e=xs.hash(qt(t,Rt));return Pt(e,Rt)}function ci(t){const e=xs.hash(qt(t,ia));return Pt(e,Rt)}function My(t){return qt(`${t}`,Ku)}function Rn(t){return Number(Pt(t,Ku))}function Ny(t){const e=My(typeof t.type<"u"?t.type:Hu);if(Rn(e)===Hr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?qt(t.senderPublicKey,Rt):void 0,i=typeof t.iv<"u"?qt(t.iv,Rt):Ti.randomBytes(To),n=new Vo.ChaCha20Poly1305(qt(t.symKey,Rt)).seal(i,qt(t.message,ia));return Oy({type:e,sealed:n,iv:i,senderPublicKey:r})}function Cy(t){const e=new Vo.ChaCha20Poly1305(qt(t.symKey,Rt)),{sealed:r,iv:i}=ds(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return Pt(n,ia)}function Oy(t){if(Rn(t.type)===Hr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Pt(So([t.type,t.senderPublicKey,t.iv,t.sealed]),Po)}return Pt(So([t.type,t.iv,t.sealed]),Po)}function ds(t){const e=qt(t,Po),r=e.slice(Iy,Mh),i=Mh;if(Rn(r)===Hr){const h=i+na,l=h+To,c=e.slice(i,h),g=e.slice(h,l),w=e.slice(l);return{type:r,sealed:w,iv:g,senderPublicKey:c}}const n=i+To,s=e.slice(i,n),o=e.slice(n);return{type:r,sealed:o,iv:s}}function Ry(t,e){const r=ds(t);return Vu({type:Rn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Pt(r.senderPublicKey,Rt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Vu(t){const e=t?.type||Hu;if(e===Hr){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 Nh(t){return t.type===Hr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}const Py="irn";function Lo(t){return t?.relay||{protocol:Py}}function fn(t){const e=n1[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Ty=Object.defineProperty,Fy=Object.defineProperties,Ly=Object.getOwnPropertyDescriptors,Ch=Object.getOwnPropertySymbols,Uy=Object.prototype.hasOwnProperty,By=Object.prototype.propertyIsEnumerable,Oh=(t,e,r)=>e in t?Ty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rh=(t,e)=>{for(var r in e||(e={}))Uy.call(e,r)&&Oh(t,r,e[r]);if(Ch)for(var r of Ch(e))By.call(e,r)&&Oh(t,r,e[r]);return t},qy=(t,e)=>Fy(t,Ly(e));function jy(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function Ph(t){t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=bn.parse(s),h=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:zy(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:jy(o),methods:h,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function zy(t){return t.startsWith("//")?t.substring(2):t}function ky(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=r+e+n;t[n]&&(i[s]=t[n])}),i}function $y(t){return`${t.protocol}:${t.topic}@${t.version}?`+bn.stringify(Rh(qy(Rh({symKey:t.symKey},ky(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function ki(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Ky(t){const e=[];return Object.values(t).forEach(r=>{e.push(...ki(r.accounts))}),e}function Hy(t,e){const r=[];return Object.values(t).forEach(i=>{ki(i.accounts).includes(e)&&r.push(...i.methods)}),r}function Vy(t,e){const r=[];return Object.values(t).forEach(i=>{ki(i.accounts).includes(e)&&r.push(...i.events)}),r}function Gy(t){const e={};return t?.forEach(r=>{const[i,n]=r.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(r),e[i].chains.push(`${i}:${n}`)}),e}function Th(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=Gy(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=I1(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const Qy={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}},Yy={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 Z(t,e){const{message:r,code:i}=Yy[t];return{message:e?`${r} ${e}`:r,code:i}}function Ze(t,e){const{message:r,code:i}=Qy[t];return{message:e?`${r} ${e}`:r,code:i}}function Pn(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function ps(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ot(t){return typeof t>"u"}function ct(t,e){return e&&Ot(t)?!0:typeof t=="string"&&!!t.trim().length}function sa(t,e){return e&&Ot(t)?!0:typeof t=="number"&&!isNaN(t)}function Wy(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return hi(n,i)?(i.forEach(o=>{const{accounts:h,methods:l,events:c}=t.namespaces[o],g=ki(h),w=r[o];(!hi(Wo(o,w),g)||!hi(w.methods,l)||!hi(w.events,c))&&(s=!1)}),s):!1}function gs(t){return ct(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Jy(t){if(ct(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&gs(r)}}return!1}function Xy(t){if(ct(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function Zy(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function ew(t){return t?.topic}function tw(t,e){let r=null;return ct(t?.publicKey,!1)||(r=Z("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Fh(t){let e=!0;return Pn(t)?t.length&&(e=t.every(r=>ct(r,!1))):e=!1,e}function rw(t,e,r){let i=null;return Pn(e)&&e.length?e.forEach(n=>{i||gs(n)||(i=Ze("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):gs(t)||(i=Ze("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function iw(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=rw(n,Wo(n,s),`${e} ${r}`);o&&(i=o)}),i}function nw(t,e){let r=null;return Pn(t)?t.forEach(i=>{r||Jy(i)||(r=Ze("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} 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 sw(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=nw(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function ow(t,e){let r=null;return Fh(t?.methods)?Fh(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 Gu(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=ow(i,`${e}, namespace`);n&&(r=n)}),r}function aw(t,e,r){let i=null;if(t&&ps(t)){const n=Gu(t,e);n&&(i=n);const s=iw(t,e,r);s&&(i=s)}else i=Z("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function oo(t,e){let r=null;if(t&&ps(t)){const i=Gu(t,e);i&&(r=i);const n=sw(t,e);n&&(r=n)}else r=Z("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Qu(t){return ct(t.protocol,!0)}function hw(t,e){let r=!1;return e&&!t?r=!0:t&&Pn(t)&&t.length&&t.forEach(i=>{r=Qu(i)}),r}function cw(t){return typeof t=="number"}function Ut(t){return typeof t<"u"&&typeof t!==null}function uw(t){return!(!t||typeof t!="object"||!t.code||!sa(t.code,!1)||!t.message||!ct(t.message,!1))}function lw(t){return!(Ot(t)||!ct(t.method,!1))}function fw(t){return!(Ot(t)||Ot(t.result)&&Ot(t.error)||!sa(t.id,!1)||!ct(t.jsonrpc,!1))}function dw(t){return!(Ot(t)||!ct(t.name,!1))}function Lh(t,e){return!(!gs(e)||!Ky(t).includes(e))}function pw(t,e,r){return ct(r,!1)?Hy(t,e).includes(r):!1}function gw(t,e,r){return ct(r,!1)?Vy(t,e).includes(r):!1}function Uh(t,e,r){let i=null;const n=mw(t),s=yw(e),o=Object.keys(n),h=Object.keys(s),l=Bh(Object.keys(t)),c=Bh(Object.keys(e)),g=l.filter(w=>!c.includes(w));return g.length&&(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
      Required: ${g.toString()}
      Received: ${Object.keys(e).toString()}`)),hi(o,h)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
      Required: ${o.toString()}
      Approved: ${h.toString()}`)),Object.keys(e).forEach(w=>{if(!w.includes(":")||i)return;const E=ki(e[w].accounts);E.includes(w)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${w}
        Required: ${w}
        Approved: ${E.toString()}`))}),o.forEach(w=>{i||(hi(n[w].methods,s[w].methods)?hi(n[w].events,s[w].events)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${w}`)):i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${w}`))}),i}function mw(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function Bh(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function yw(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:ki(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function ww(t,e){return sa(t,!1)&&t<=e.max&&t>=e.min}function qh(){const t=Cn();return new Promise(e=>{switch(t){case Kt.browser:e(vw());break;case Kt.reactNative:e(bw());break;case Kt.node:e(Ew());break;default:e(!0)}})}function vw(){return Ui()&&navigator?.onLine}async function bw(){return Li()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function Ew(){return!0}function _w(t){switch(Cn()){case Kt.browser:Aw(t);break;case Kt.reactNative:Sw(t);break}}function Aw(t){!Li()&&Ui()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function Sw(t){Li()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const ao={};class hn{static get(e){return ao[e]}static set(e,r){ao[e]=r}static delete(e){delete ao[e]}}const Iw="PARSE_ERROR",Dw="INVALID_REQUEST",xw="METHOD_NOT_FOUND",Mw="INVALID_PARAMS",Yu="INTERNAL_ERROR",oa="SERVER_ERROR",Nw=[-32700,-32600,-32601,-32602,-32603],mn={[Iw]:{code:-32700,message:"Parse error"},[Dw]:{code:-32600,message:"Invalid Request"},[xw]:{code:-32601,message:"Method not found"},[Mw]:{code:-32602,message:"Invalid params"},[Yu]:{code:-32603,message:"Internal error"},[oa]:{code:-32e3,message:"Server error"}},Wu=oa;function Cw(t){return Nw.includes(t)}function jh(t){return Object.keys(mn).includes(t)?mn[t]:mn[Wu]}function Ow(t){const e=Object.values(mn).find(r=>r.code===t);return e||mn[Wu]}function Rw(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Ju={},jr={},zh;function Pw(){if(zh)return jr;zh=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.isBrowserCryptoAvailable=jr.getSubtleCrypto=jr.getBrowerCrypto=void 0;function t(){return(xt.commonjsGlobal===null||xt.commonjsGlobal===void 0?void 0:xt.commonjsGlobal.crypto)||(xt.commonjsGlobal===null||xt.commonjsGlobal===void 0?void 0:xt.commonjsGlobal.msCrypto)||{}}jr.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}jr.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return jr.isBrowserCryptoAvailable=r,jr}var zr={},kh;function Tw(){if(kh)return zr;kh=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.isBrowser=zr.isNode=zr.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}zr.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}zr.isNode=e;function r(){return!t()&&!e()}return zr.isBrowser=r,zr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=In;e.__exportStar(Pw(),t),e.__exportStar(Tw(),t)})(Ju);function Jr(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function ui(t=6){return BigInt(Jr(t))}function Oi(t,e,r){return{id:r||Jr(),jsonrpc:"2.0",method:t,params:e}}function Ns(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Cs(t,e,r){return{id:t,jsonrpc:"2.0",error:Fw(e,r)}}function Fw(t,e){return typeof t>"u"?jh(Yu):(typeof t=="string"&&(t=Object.assign(Object.assign({},jh(oa)),{message:t})),typeof e<"u"&&(t.data=e),Cw(t.code)&&(t=Ow(t.code)),t)}class Xu{}let Lw=class extends Xu{constructor(e){super()}};class Uw extends Xu{constructor(){super()}}let Bw=class extends Uw{constructor(e){super()}};const qw="^wss?:";function jw(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function zw(t,e){const r=jw(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function $h(t){return zw(t,qw)}function kw(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Zu(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function aa(t){return Zu(t)&&"method"in t}function Os(t){return Zu(t)&&(Sr(t)||nr(t))}function Sr(t){return"result"in t}function nr(t){return"error"in t}class el extends Bw{constructor(e){super(e),this.events=new Gt.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(Oi(e.method,e.params||[],e.id||ui().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{nr(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Os(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const $w=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),Kw=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Kh=t=>t.split("?")[0],Hh=10,Hw=$w();let Vw=class{constructor(e){if(this.url=e,this.events=new Gt.EventEmitter,this.registering=!1,!$h(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(fi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!$h(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=new URLSearchParams(e).get("origin"),s=Ju.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!kw(e)},o=new Hw(e,[],s);Kw()?o.onerror=h=>{const l=h;i(this.emitError(l.error))}:o.on("error",h=>{i(this.emitError(h))}),o.onopen=()=>{this.onOpen(o),r(o)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?vs(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Cs(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Rw(e,Kh(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Hh&&this.events.setMaxListeners(Hh)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Kh(this.url)}`));return this.events.emit("register_error",r),r}};var ms={exports:{}};ms.exports;(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,h="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",g="[object Boolean]",w="[object Date]",E="[object Error]",b="[object Function]",S="[object GeneratorFunction]",B="[object Map]",j="[object Number]",$="[object Null]",U="[object Object]",q="[object Promise]",C="[object Proxy]",F="[object RegExp]",T="[object Set]",p="[object String]",x="[object Symbol]",V="[object Undefined]",J="[object WeakMap]",X="[object ArrayBuffer]",ee="[object DataView]",a="[object Float32Array]",d="[object Float64Array]",m="[object Int8Array]",_="[object Int16Array]",A="[object Int32Array]",D="[object Uint8Array]",R="[object Uint8ClampedArray]",v="[object Uint16Array]",f="[object Uint32Array]",I=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,Y=/^(?:0|[1-9]\d*)$/,y={};y[a]=y[d]=y[m]=y[_]=y[A]=y[D]=y[R]=y[v]=y[f]=!0,y[h]=y[l]=y[X]=y[g]=y[ee]=y[w]=y[E]=y[b]=y[B]=y[j]=y[U]=y[F]=y[T]=y[p]=y[J]=!1;var k=typeof xt.commonjsGlobal=="object"&&xt.commonjsGlobal&&xt.commonjsGlobal.Object===Object&&xt.commonjsGlobal,N=typeof self=="object"&&self&&self.Object===Object&&self,P=k||N||Function("return this")(),L=e&&!e.nodeType&&e,u=L&&!0&&t&&!t.nodeType&&t,M=u&&u.exports===L,K=M&&k.process,G=function(){try{return K&&K.binding&&K.binding("util")}catch{}}(),W=G&&G.isTypedArray;function le(O,z){for(var Q=-1,ie=O==null?0:O.length,it=0,Le=[];++Q<ie;){var st=O[Q];z(st,Q,O)&&(Le[it++]=st)}return Le}function he(O,z){for(var Q=-1,ie=z.length,it=O.length;++Q<ie;)O[it+Q]=z[Q];return O}function pe(O,z){for(var Q=-1,ie=O==null?0:O.length;++Q<ie;)if(z(O[Q],Q,O))return!0;return!1}function Ge(O,z){for(var Q=-1,ie=Array(O);++Q<O;)ie[Q]=z(Q);return ie}function be(O){return function(z){return O(z)}}function ue(O,z){return O.has(z)}function Re(O,z){return O?.[z]}function ae(O){var z=-1,Q=Array(O.size);return O.forEach(function(ie,it){Q[++z]=[it,ie]}),Q}function se(O,z){return function(Q){return O(z(Q))}}function _e(O){var z=-1,Q=Array(O.size);return O.forEach(function(ie){Q[++z]=ie}),Q}var ne=Array.prototype,re=Function.prototype,ye=Object.prototype,oe=P["__core-js_shared__"],ce=re.toString,we=ye.hasOwnProperty,fe=function(){var O=/[^.]+$/.exec(oe&&oe.keys&&oe.keys.IE_PROTO||"");return O?"Symbol(src)_1."+O:""}(),de=ye.toString,Ue=RegExp("^"+ce.call(we).replace(I,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),me=M?P.Buffer:void 0,ge=P.Symbol,ut=P.Uint8Array,qe=ye.propertyIsEnumerable,$e=ne.splice,at=ge?ge.toStringTag:void 0,Ke=Object.getOwnPropertySymbols,He=me?me.isBuffer:void 0,Yt=se(Object.keys,Object),Ae=vi(P,"DataView"),Ee=vi(P,"Map"),Qe=vi(P,"Promise"),Se=vi(P,"Set"),Ie=vi(P,"WeakMap"),Ve=vi(Object,"create"),xe=ri(Ae),Me=ri(Ee),et=ri(Qe),Ne=ri(Se),Ce=ri(Ie),We=ge?ge.prototype:void 0,De=We?We.valueOf:void 0;function ve(O){var z=-1,Q=O==null?0:O.length;for(this.clear();++z<Q;){var ie=O[z];this.set(ie[0],ie[1])}}function tt(){this.__data__=Ve?Ve(null):{},this.size=0}function Oe(O){var z=this.has(O)&&delete this.__data__[O];return this.size-=z?1:0,z}function Je(O){var z=this.__data__;if(Ve){var Q=z[O];return Q===i?void 0:Q}return we.call(z,O)?z[O]:void 0}function Ur(O){var z=this.__data__;return Ve?z[O]!==void 0:we.call(z,O)}function Xe(O,z){var Q=this.__data__;return this.size+=this.has(O)?0:1,Q[O]=Ve&&z===void 0?i:z,this}ve.prototype.clear=tt,ve.prototype.delete=Oe,ve.prototype.get=Je,ve.prototype.has=Ur,ve.prototype.set=Xe;function ke(O){var z=-1,Q=O==null?0:O.length;for(this.clear();++z<Q;){var ie=O[z];this.set(ie[0],ie[1])}}function gr(){this.__data__=[],this.size=0}function mr(O){var z=this.__data__,Q=Fn(z,O);if(Q<0)return!1;var ie=z.length-1;return Q==ie?z.pop():$e.call(z,Q,1),--this.size,!0}function yr(O){var z=this.__data__,Q=Fn(z,O);return Q<0?void 0:z[Q][1]}function wr(O){return Fn(this.__data__,O)>-1}function vr(O,z){var Q=this.__data__,ie=Fn(Q,O);return ie<0?(++this.size,Q.push([O,z])):Q[ie][1]=z,this}ke.prototype.clear=gr,ke.prototype.delete=mr,ke.prototype.get=yr,ke.prototype.has=wr,ke.prototype.set=vr;function At(O){var z=-1,Q=O==null?0:O.length;for(this.clear();++z<Q;){var ie=O[z];this.set(ie[0],ie[1])}}function $i(){this.size=0,this.__data__={hash:new ve,map:new(Ee||ke),string:new ve}}function Ki(O){var z=Ln(this,O).delete(O);return this.size-=z?1:0,z}function Hi(O){return Ln(this,O).get(O)}function Vi(O){return Ln(this,O).has(O)}function Gi(O,z){var Q=Ln(this,O),ie=Q.size;return Q.set(O,z),this.size+=Q.size==ie?0:1,this}At.prototype.clear=$i,At.prototype.delete=Ki,At.prototype.get=Hi,At.prototype.has=Vi,At.prototype.set=Gi;function Vr(O){var z=-1,Q=O==null?0:O.length;for(this.__data__=new At;++z<Q;)this.add(O[z])}function Qi(O){return this.__data__.set(O,i),this}function Yi(O){return this.__data__.has(O)}Vr.prototype.add=Vr.prototype.push=Qi,Vr.prototype.has=Yi;function Wt(O){var z=this.__data__=new ke(O);this.size=z.size}function Wi(){this.__data__=new ke,this.size=0}function Ji(O){var z=this.__data__,Q=z.delete(O);return this.size=z.size,Q}function Xi(O){return this.__data__.get(O)}function Zi(O){return this.__data__.has(O)}function wl(O,z){var Q=this.__data__;if(Q instanceof ke){var ie=Q.__data__;if(!Ee||ie.length<r-1)return ie.push([O,z]),this.size=++Q.size,this;Q=this.__data__=new At(ie)}return Q.set(O,z),this.size=Q.size,this}Wt.prototype.clear=Wi,Wt.prototype.delete=Ji,Wt.prototype.get=Xi,Wt.prototype.has=Zi,Wt.prototype.set=wl;function vl(O,z){var Q=Un(O),ie=!Q&&Tl(O),it=!Q&&!ie&&Fs(O),Le=!Q&&!ie&&!it&&va(O),st=Q||ie||it||Le,dt=st?Ge(O.length,String):[],mt=dt.length;for(var nt in O)(z||we.call(O,nt))&&!(st&&(nt=="length"||it&&(nt=="offset"||nt=="parent")||Le&&(nt=="buffer"||nt=="byteLength"||nt=="byteOffset")||Nl(nt,mt)))&&dt.push(nt);return dt}function Fn(O,z){for(var Q=O.length;Q--;)if(ga(O[Q][0],z))return Q;return-1}function bl(O,z,Q){var ie=z(O);return Un(O)?ie:he(ie,Q(O))}function en(O){return O==null?O===void 0?V:$:at&&at in Object(O)?xl(O):Pl(O)}function la(O){return tn(O)&&en(O)==h}function fa(O,z,Q,ie,it){return O===z?!0:O==null||z==null||!tn(O)&&!tn(z)?O!==O&&z!==z:El(O,z,Q,ie,fa,it)}function El(O,z,Q,ie,it,Le){var st=Un(O),dt=Un(z),mt=st?l:Gr(O),nt=dt?l:Gr(z);mt=mt==h?U:mt,nt=nt==h?U:nt;var $t=mt==U,or=nt==U,St=mt==nt;if(St&&Fs(O)){if(!Fs(z))return!1;st=!0,$t=!1}if(St&&!$t)return Le||(Le=new Wt),st||va(O)?da(O,z,Q,ie,it,Le):Il(O,z,mt,Q,ie,it,Le);if(!(Q&n)){var Jt=$t&&we.call(O,"__wrapped__"),Xt=or&&we.call(z,"__wrapped__");if(Jt||Xt){var Qr=Jt?O.value():O,Br=Xt?z.value():z;return Le||(Le=new Wt),it(Qr,Br,Q,ie,Le)}}return St?(Le||(Le=new Wt),Dl(O,z,Q,ie,it,Le)):!1}function _l(O){if(!wa(O)||Ol(O))return!1;var z=ma(O)?Ue:H;return z.test(ri(O))}function Al(O){return tn(O)&&ya(O.length)&&!!y[en(O)]}function Sl(O){if(!Rl(O))return Yt(O);var z=[];for(var Q in Object(O))we.call(O,Q)&&Q!="constructor"&&z.push(Q);return z}function da(O,z,Q,ie,it,Le){var st=Q&n,dt=O.length,mt=z.length;if(dt!=mt&&!(st&&mt>dt))return!1;var nt=Le.get(O);if(nt&&Le.get(z))return nt==z;var $t=-1,or=!0,St=Q&s?new Vr:void 0;for(Le.set(O,z),Le.set(z,O);++$t<dt;){var Jt=O[$t],Xt=z[$t];if(ie)var Qr=st?ie(Xt,Jt,$t,z,O,Le):ie(Jt,Xt,$t,O,z,Le);if(Qr!==void 0){if(Qr)continue;or=!1;break}if(St){if(!pe(z,function(Br,ii){if(!ue(St,ii)&&(Jt===Br||it(Jt,Br,Q,ie,Le)))return St.push(ii)})){or=!1;break}}else if(!(Jt===Xt||it(Jt,Xt,Q,ie,Le))){or=!1;break}}return Le.delete(O),Le.delete(z),or}function Il(O,z,Q,ie,it,Le,st){switch(Q){case ee:if(O.byteLength!=z.byteLength||O.byteOffset!=z.byteOffset)return!1;O=O.buffer,z=z.buffer;case X:return!(O.byteLength!=z.byteLength||!Le(new ut(O),new ut(z)));case g:case w:case j:return ga(+O,+z);case E:return O.name==z.name&&O.message==z.message;case F:case p:return O==z+"";case B:var dt=ae;case T:var mt=ie&n;if(dt||(dt=_e),O.size!=z.size&&!mt)return!1;var nt=st.get(O);if(nt)return nt==z;ie|=s,st.set(O,z);var $t=da(dt(O),dt(z),ie,it,Le,st);return st.delete(O),$t;case x:if(De)return De.call(O)==De.call(z)}return!1}function Dl(O,z,Q,ie,it,Le){var st=Q&n,dt=pa(O),mt=dt.length,nt=pa(z),$t=nt.length;if(mt!=$t&&!st)return!1;for(var or=mt;or--;){var St=dt[or];if(!(st?St in z:we.call(z,St)))return!1}var Jt=Le.get(O);if(Jt&&Le.get(z))return Jt==z;var Xt=!0;Le.set(O,z),Le.set(z,O);for(var Qr=st;++or<mt;){St=dt[or];var Br=O[St],ii=z[St];if(ie)var ba=st?ie(ii,Br,St,z,O,Le):ie(Br,ii,St,O,z,Le);if(!(ba===void 0?Br===ii||it(Br,ii,Q,ie,Le):ba)){Xt=!1;break}Qr||(Qr=St=="constructor")}if(Xt&&!Qr){var Bn=O.constructor,qn=z.constructor;Bn!=qn&&"constructor"in O&&"constructor"in z&&!(typeof Bn=="function"&&Bn instanceof Bn&&typeof qn=="function"&&qn instanceof qn)&&(Xt=!1)}return Le.delete(O),Le.delete(z),Xt}function pa(O){return bl(O,Ul,Ml)}function Ln(O,z){var Q=O.__data__;return Cl(z)?Q[typeof z=="string"?"string":"hash"]:Q.map}function vi(O,z){var Q=Re(O,z);return _l(Q)?Q:void 0}function xl(O){var z=we.call(O,at),Q=O[at];try{O[at]=void 0;var ie=!0}catch{}var it=de.call(O);return ie&&(z?O[at]=Q:delete O[at]),it}var Ml=Ke?function(O){return O==null?[]:(O=Object(O),le(Ke(O),function(z){return qe.call(O,z)}))}:Bl,Gr=en;(Ae&&Gr(new Ae(new ArrayBuffer(1)))!=ee||Ee&&Gr(new Ee)!=B||Qe&&Gr(Qe.resolve())!=q||Se&&Gr(new Se)!=T||Ie&&Gr(new Ie)!=J)&&(Gr=function(O){var z=en(O),Q=z==U?O.constructor:void 0,ie=Q?ri(Q):"";if(ie)switch(ie){case xe:return ee;case Me:return B;case et:return q;case Ne:return T;case Ce:return J}return z});function Nl(O,z){return z=z??o,!!z&&(typeof O=="number"||Y.test(O))&&O>-1&&O%1==0&&O<z}function Cl(O){var z=typeof O;return z=="string"||z=="number"||z=="symbol"||z=="boolean"?O!=="__proto__":O===null}function Ol(O){return!!fe&&fe in O}function Rl(O){var z=O&&O.constructor,Q=typeof z=="function"&&z.prototype||ye;return O===Q}function Pl(O){return de.call(O)}function ri(O){if(O!=null){try{return ce.call(O)}catch{}try{return O+""}catch{}}return""}function ga(O,z){return O===z||O!==O&&z!==z}var Tl=la(function(){return arguments}())?la:function(O){return tn(O)&&we.call(O,"callee")&&!qe.call(O,"callee")},Un=Array.isArray;function Fl(O){return O!=null&&ya(O.length)&&!ma(O)}var Fs=He||ql;function Ll(O,z){return fa(O,z)}function ma(O){if(!wa(O))return!1;var z=en(O);return z==b||z==S||z==c||z==C}function ya(O){return typeof O=="number"&&O>-1&&O%1==0&&O<=o}function wa(O){var z=typeof O;return O!=null&&(z=="object"||z=="function")}function tn(O){return O!=null&&typeof O=="object"}var va=W?be(W):Al;function Ul(O){return Fl(O)?vl(O):Sl(O)}function Bl(){return[]}function ql(){return!1}t.exports=Ll})(ms,ms.exports);var Gw=ms.exports;const Qw=xt.getDefaultExportFromCjs(Gw);function Yw(t,e){return e=e||{},new Promise(function(r,i){var n=new XMLHttpRequest,s=[],o=[],h={},l=function(){return{ok:(n.status/100|0)==2,statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:l,headers:{keys:function(){return s},entries:function(){return o},get:function(g){return h[g.toLowerCase()]},has:function(g){return g.toLowerCase()in h}}}};for(var c in n.open(e.method||"get",t,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(g,w,E){s.push(w=w.toLowerCase()),o.push([w,E]),h[w]=h[w]?h[w]+","+E:E}),r(l())},n.onerror=i,n.withCredentials=e.credentials=="include",e.headers)n.setRequestHeader(c,e.headers[c]);n.send(e.body||null)})}const Ww=Object.freeze(Object.defineProperty({__proto__:null,default:Yw},Symbol.toStringTag,{value:"Module"})),Vh=xt.getAugmentedNamespace(Ww);var Jw=self.fetch||(self.fetch=Vh.default||Vh);const Xw=xt.getDefaultExportFromCjs(Jw);function Zw(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var h=t.length,l=t.charAt(0),c=Math.log(h)/Math.log(256),g=Math.log(256)/Math.log(h);function w(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var B=0,j=0,$=0,U=S.length;$!==U&&S[$]===0;)$++,B++;for(var q=(U-$)*g+1>>>0,C=new Uint8Array(q);$!==U;){for(var F=S[$],T=0,p=q-1;(F!==0||T<j)&&p!==-1;p--,T++)F+=256*C[p]>>>0,C[p]=F%h>>>0,F=F/h>>>0;if(F!==0)throw new Error("Non-zero carry");j=T,$++}for(var x=q-j;x!==q&&C[x]===0;)x++;for(var V=l.repeat(B);x<q;++x)V+=t.charAt(C[x]);return V}function E(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var B=0;if(S[B]!==" "){for(var j=0,$=0;S[B]===l;)j++,B++;for(var U=(S.length-B)*c+1>>>0,q=new Uint8Array(U);S[B];){var C=r[S.charCodeAt(B)];if(C===255)return;for(var F=0,T=U-1;(C!==0||F<$)&&T!==-1;T--,F++)C+=h*q[T]>>>0,q[T]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");$=F,B++}if(S[B]!==" "){for(var p=U-$;p!==U&&q[p]===0;)p++;for(var x=new Uint8Array(j+(U-p)),V=j;p!==U;)x[V++]=q[p++];return x}}}function b(S){var B=E(S);if(B)return B;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:E,decode:b}}var ev=Zw,tv=ev;const tl=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")},rv=t=>new TextEncoder().encode(t),iv=t=>new TextDecoder().decode(t);class nv{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class sv{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return rl(this,e)}}let ov=class{constructor(e){this.decoders=e}or(e){return rl(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const rl=(t,e)=>new ov({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let av=class{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new nv(e,r,i),this.decoder=new sv(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Rs=({name:t,prefix:e,encode:r,decode:i})=>new av(t,e,r,i),Tn=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=tv(r,e);return Rs({prefix:t,name:e,encode:i,decode:s=>tl(n(s))})},hv=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let h=0,l=0,c=0;for(let g=0;g<s;++g){const w=n[t[g]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|w,h+=r,h>=8&&(h-=8,o[c++]=255&l>>h)}if(h>=r||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return o},cv=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,h=0;for(let l=0;l<t.length;++l)for(h=h<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&h>>o];if(o&&(s+=e[n&h<<r-o]),i)for(;s.length*r&7;)s+="=";return s},_t=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Rs({prefix:e,name:t,encode(n){return cv(n,i,r)},decode(n){return hv(n,i,r,t)}}),uv=Rs({prefix:"\0",name:"identity",encode:t=>iv(t),decode:t=>rv(t)});var lv=Object.freeze({__proto__:null,identity:uv});const fv=_t({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dv=Object.freeze({__proto__:null,base2:fv});const pv=_t({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gv=Object.freeze({__proto__:null,base8:pv});const mv=Tn({prefix:"9",name:"base10",alphabet:"0123456789"});var yv=Object.freeze({__proto__:null,base10:mv});const wv=_t({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vv=_t({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bv=Object.freeze({__proto__:null,base16:wv,base16upper:vv});const Ev=_t({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_v=_t({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Av=_t({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Sv=_t({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Iv=_t({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Dv=_t({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xv=_t({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mv=_t({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Nv=_t({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Cv=Object.freeze({__proto__:null,base32:Ev,base32upper:_v,base32pad:Av,base32padupper:Sv,base32hex:Iv,base32hexupper:Dv,base32hexpad:xv,base32hexpadupper:Mv,base32z:Nv});const Ov=Tn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Rv=Tn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Pv=Object.freeze({__proto__:null,base36:Ov,base36upper:Rv});const Tv=Tn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fv=Tn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lv=Object.freeze({__proto__:null,base58btc:Tv,base58flickr:Fv});const Uv=_t({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bv=_t({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qv=_t({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),jv=_t({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zv=Object.freeze({__proto__:null,base64:Uv,base64pad:Bv,base64url:qv,base64urlpad:jv});const il=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),kv=il.reduce((t,e,r)=>(t[r]=e,t),[]),$v=il.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Kv(t){return t.reduce((e,r)=>(e+=kv[r],e),"")}function Hv(t){const e=[];for(const r of t){const i=$v[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Vv=Rs({prefix:"🚀",name:"base256emoji",encode:Kv,decode:Hv});var Gv=Object.freeze({__proto__:null,base256emoji:Vv}),Qv=nl,Gh=128,Yv=127,Wv=~Yv,Jv=Math.pow(2,31);function nl(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Jv;)e[r++]=t&255|Gh,t/=128;for(;t&Wv;)e[r++]=t&255|Gh,t>>>=7;return e[r]=t|0,nl.bytes=r-i+1,e}var Xv=Uo,Zv=128,Qh=127;function Uo(t,i){var r=0,i=i||0,n=0,s=i,o,h=t.length;do{if(s>=h)throw Uo.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Qh)<<n:(o&Qh)*Math.pow(2,n),n+=7}while(o>=Zv);return Uo.bytes=s-i,r}var eb=Math.pow(2,7),tb=Math.pow(2,14),rb=Math.pow(2,21),ib=Math.pow(2,28),nb=Math.pow(2,35),sb=Math.pow(2,42),ob=Math.pow(2,49),ab=Math.pow(2,56),hb=Math.pow(2,63),cb=function(t){return t<eb?1:t<tb?2:t<rb?3:t<ib?4:t<nb?5:t<sb?6:t<ob?7:t<ab?8:t<hb?9:10},ub={encode:Qv,decode:Xv,encodingLength:cb},sl=ub;const Yh=(t,e,r=0)=>(sl.encode(t,e,r),e),Wh=t=>sl.encodingLength(t),Bo=(t,e)=>{const r=e.byteLength,i=Wh(t),n=i+Wh(r),s=new Uint8Array(n+r);return Yh(t,s,0),Yh(r,s,i),s.set(e,n),new lb(t,r,e,s)};class lb{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const ol=({name:t,code:e,encode:r})=>new fb(t,e,r);class fb{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Bo(this.code,r):r.then(i=>Bo(this.code,i))}else throw Error("Unknown type, must be binary type")}}const al=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),db=ol({name:"sha2-256",code:18,encode:al("SHA-256")}),pb=ol({name:"sha2-512",code:19,encode:al("SHA-512")});var gb=Object.freeze({__proto__:null,sha256:db,sha512:pb});const hl=0,mb="identity",cl=tl,yb=t=>Bo(hl,cl(t)),wb={code:hl,name:mb,encode:cl,digest:yb};var vb=Object.freeze({__proto__:null,identity:wb});new TextEncoder,new TextDecoder;const Jh={...lv,...dv,...gv,...yv,...bv,...Cv,...Pv,...Lv,...zv,...Gv};({...gb,...vb});function bb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ul(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Xh=ul("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ho=ul("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=bb(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Eb={utf8:Xh,"utf-8":Xh,hex:Jh.base16,latin1:ho,ascii:ho,binary:ho,...Jh};function _b(t,e="utf8"){const r=Eb[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 ll="wc",Ab=2,ha="core",ei=`${ll}@2:${ha}:`,Sb={name:ha,logger:"error"},Ib={database:":memory:"},Db="crypto",Zh="client_ed25519_seed",xb=te.ONE_DAY,Mb="keychain",Nb="0.3",Cb="messages",Ob="0.3",Rb=te.SIX_HOURS,Pb="publisher",fl="irn",Tb="error",dl="wss://relay.walletconnect.org",Fb="relayer",Bt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Lb="_subscription",tr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Ub=.1,Bb="2.14.0",qb=1e4,jb="0.3",zb="WALLETCONNECT_CLIENT_ID",Ir={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},kb="subscription",$b="0.3",Kb=te.FIVE_SECONDS*1e3,Hb="pairing",Vb="0.3",cn={wc_pairingDelete:{req:{ttl:te.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:te.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:te.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:te.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:te.ONE_DAY,prompt:!1,tag:0},res:{ttl:te.ONE_DAY,prompt:!1,tag:0}}},Di={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},hr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Gb="history",Qb="0.3",Yb="expirer",rr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Wb="0.3",co="verify-api",Jb="https://verify.walletconnect.com",pl="https://verify.walletconnect.org",dn=pl,Xb=[Jb,pl],Zb="echo",e2="https://echo.walletconnect.com";class t2{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=Mb,this.version=Nb,this.initialized=!1,this.storagePrefix=ei,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=Z("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=kt(r,this.name)}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,iu(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?nu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class r2{constructor(e,r,i){this.core=e,this.logger=r,this.name=Db,this.randomSessionIdentifier=Fo(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Ha(n);return Vc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=Dy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Ha(s),h=this.randomSessionIdentifier;return await xp(h,n,xb,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const h=this.getPrivateKey(n),l=xy(h,s);return this.setSymKey(l,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||ts(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const h=Vu(o),l=fi(s);if(Nh(h)){const E=h.senderPublicKey,b=h.receiverPublicKey;n=await this.generateSharedKey(E,b)}const c=this.getSymKey(n),{type:g,senderPublicKey:w}=h;return Ny({type:g,symKey:c,message:l,senderPublicKey:w})},this.decode=async(n,s,o)=>{this.isInitialized();const h=Ry(s,o);if(Nh(h)){const l=h.receiverPublicKey,c=h.senderPublicKey;n=await this.generateSharedKey(l,c)}try{const l=this.getSymKey(n),c=Cy({symKey:l,encoded:s});return vs(c)}catch(l){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(l)}},this.getPayloadType=n=>{const s=ds(n);return Rn(s.type)},this.getPayloadSenderPublicKey=n=>{const s=ds(n);return s.senderPublicKey?Pt(s.senderPublicKey,Rt):void 0},this.core=e,this.logger=kt(r,this.name),this.keychain=i||new t2(this.core,this.logger)}get context(){return zt(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Zh)}catch{e=Fo(),await this.keychain.set(Zh,e)}return _b(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class i2 extends Td{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Cb,this.version=Ob,this.initialized=!1,this.storagePrefix=ei,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=ci(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=ci(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=kt(e,this.name),this.core=r}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,iu(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?nu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class n2 extends Fd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Gt.EventEmitter,this.name=Pb,this.queue=new Map,this.publishTimeout=te.toMiliseconds(te.ONE_MINUTE),this.failedPublishTimeout=te.toMiliseconds(te.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const h=s?.ttl||Rb,l=Lo(s),c=s?.prompt||!1,g=s?.tag||0,w=s?.id||ui().toString(),E={topic:i,message:n,opts:{ttl:h,relay:l,prompt:c,tag:g,id:w}},b=`Failed to publish payload, please try again. id:${w} tag:${g}`,S=Date.now();let B,j=1;try{for(;B===void 0;){if(Date.now()-S>this.publishTimeout)throw new Error(b);this.logger.trace({id:w,attempts:j},`publisher.publish - attempt ${j}`),B=await await Mi(this.rpcPublish(i,n,h,l,c,g,w).catch($=>this.logger.warn($)),this.publishTimeout,b),j++,B||await new Promise($=>setTimeout($,this.failedPublishTimeout))}this.relayer.events.emit(Bt.publish,E),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:w,topic:i,message:n,opts:s}})}catch($){if(this.logger.debug("Failed to Publish Payload"),this.logger.error($),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw $;this.queue.set(w,E)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=kt(r,this.name),this.registerEventListeners()}get context(){return zt(this.logger)}rpcPublish(e,r,i,n,s,o,h){var l,c,g,w;const E={method:fn(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:o},id:h};return Ot((l=E.params)==null?void 0:l.prompt)&&((c=E.params)==null||delete c.prompt),Ot((g=E.params)==null?void 0:g.tag)&&((w=E.params)==null||delete w.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:E}),this.relayer.request(E)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:i,opts:n}=e;await this.publish(r,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(Dn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Bt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Bt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class s2{constructor(){this.map=new Map,this.set=(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,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 i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var o2=Object.defineProperty,a2=Object.defineProperties,h2=Object.getOwnPropertyDescriptors,ec=Object.getOwnPropertySymbols,c2=Object.prototype.hasOwnProperty,u2=Object.prototype.propertyIsEnumerable,tc=(t,e,r)=>e in t?o2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,un=(t,e)=>{for(var r in e||(e={}))c2.call(e,r)&&tc(t,r,e[r]);if(ec)for(var r of ec(e))u2.call(e,r)&&tc(t,r,e[r]);return t},uo=(t,e)=>a2(t,h2(e));class l2 extends Bd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new s2,this.events=new Gt.EventEmitter,this.name=kb,this.version=$b,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ei,this.subscribeTimeout=te.toMiliseconds(te.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=Lo(n),o={topic:i,relay:s};this.pending.set(i,o);const h=await this.rpcSubscribe(i,s);return typeof h=="string"&&(this.onSubscribe(h,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),h}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const h=new te.Watch;h.start(n);const l=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(l),h.stop(n),s(!0)),h.elapsed(n)>=Kb&&(clearInterval(l),h.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=kt(r,this.name),this.clientId=""}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=Lo(i);await this.rpcUnsubscribe(e,r,n);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:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r){const i={method:fn(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Mi(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)?ci(e+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Bt.connection_stalled)}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:fn(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Mi(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Bt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:fn(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Mi(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Bt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:fn(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,uo(un({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,un({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,un({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ir.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Ir.deleted,uo(un({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ir.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<e;r++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(Ir.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const r=await this.rpcBatchSubscribe(e);Pn(r)&&this.onBatchSubscribe(r.map((i,n)=>uo(un({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Dn.pulse,async()=>{await this.checkPending()}),this.events.on(Ir.created,async e=>{const r=Ir.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Ir.deleted,async e=>{const r=Ir.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}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var f2=Object.defineProperty,rc=Object.getOwnPropertySymbols,d2=Object.prototype.hasOwnProperty,p2=Object.prototype.propertyIsEnumerable,ic=(t,e,r)=>e in t?f2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g2=(t,e)=>{for(var r in e||(e={}))d2.call(e,r)&&ic(t,r,e[r]);if(rc)for(var r of rc(e))p2.call(e,r)&&ic(t,r,e[r]);return t};class m2 extends Ld{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Gt.EventEmitter,this.name=Fb,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=te.toMiliseconds(te.THIRTY_SECONDS+te.ONE_SECOND),this.request=async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||ui().toString();await this.toEstablishConnection();try{const o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const h=await new Promise(async(l,c)=>{const g=()=>{c(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(tr.disconnect,g);const w=await o;this.provider.off(tr.disconnect,g),l(w)});return this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - published"),h}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(En())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Bt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Bt.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(tr.payload,this.onPayloadHandler),this.provider.on(tr.connect,this.onConnectHandler),this.provider.on(tr.disconnect,this.onDisconnectHandler),this.provider.on(tr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?kt(e.logger,this.name):Es(zo({level:e.logger||Tb})),this.messages=new i2(this.logger,e.core),this.subscriber=new l2(this,this.logger),this.publisher=new n2(this,this.logger),this.relayUrl=e?.relayUrl||dl,this.projectId=e.projectId,this.bundleId=m1(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),await this.transportOpen(),this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&this.subscriber.pending.size===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},qb)}get context(){return zt(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now()})}async subscribe(e,r){var i;this.isInitialized();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",s;const o=h=>{h.topic===e&&(this.subscriber.off(Ir.created,o),s())};return await Promise.all([new Promise(h=>{s=h,this.subscriber.on(Ir.created,o)}),new Promise(async h=>{n=await this.subscriber.subscribe(e,r)||n,h()})]),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 transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Mi(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(r,i)=>{const n=()=>{this.provider.off(tr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(tr.disconnect,n),await Mi(this.provider.connect(),te.toMiliseconds(te.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);const i=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw r}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await qh())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${r.length} message events processed`)}startPingTimeout(){var e,r,i,n,s;if(En())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new el(new Vw(_1({sdkVersion:Bb,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),aa(e)){if(!e.method.endsWith(Lb))return;const r=e.params,{topic:i,message:n,publishedAt:s}=r.data,o={topic:i,message:n,publishedAt:s};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(g2({type:"event",event:r.id},o)),this.events.emit(r.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else Os(e)&&this.events.emit(Bt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Bt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Ns(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(tr.payload,this.onPayloadHandler),this.provider.off(tr.connect,this.onConnectHandler),this.provider.off(tr.disconnect,this.onDisconnectHandler),this.provider.off(tr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await qh();_w(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Bt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},te.toMiliseconds(Ub))}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var y2=Object.defineProperty,nc=Object.getOwnPropertySymbols,w2=Object.prototype.hasOwnProperty,v2=Object.prototype.propertyIsEnumerable,sc=(t,e,r)=>e in t?y2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oc=(t,e)=>{for(var r in e||(e={}))w2.call(e,r)&&sc(t,r,e[r]);if(nc)for(var r of nc(e))v2.call(e,r)&&sc(t,r,e[r]);return t};class wi extends Ud{constructor(e,r,i,n=ei,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=jb,this.cached=[],this.initialized=!1,this.storagePrefix=ei,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ot(o)?this.map.set(this.getKey(o),o):Zy(o)?this.map.set(o.id,o):ew(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,h)=>{this.isInitialized(),this.map.has(o)?await this.update(o,h):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:h}),this.map.set(o,h),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(h=>Object.keys(o).every(l=>Qw(h[l],o[l]))):this.values),this.update=async(o,h)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:h});const l=oc(oc({},this.getData(o)),h);this.map.set(o,l),await this.persist()},this.delete=async(o,h)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:h}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=kt(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=Z("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}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class b2{constructor(e,r){this.core=e,this.logger=r,this.name=Hb,this.version=Vb,this.events=new Ac,this.initialized=!1,this.storagePrefix=ei,this.ignoredPayloadTypes=[Hr],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:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=Fo(),s=await this.core.crypto.setSymKey(n),o=vt(te.FIVE_MINUTES),h={protocol:fl},l={topic:s,expiry:o,relay:h,active:!1},c=$y({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:h,expiryTimestamp:o,methods:i?.methods});return this.core.expirer.set(s,o),await this.pairings.set(s,l),await this.core.relayer.subscribe(s),{topic:s,uri:c}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:n,symKey:s,relay:o,expiryTimestamp:h,methods:l}=Ph(i.uri);let c;if(this.pairings.keys.includes(n)&&(c=this.pairings.get(n),c.active))throw new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);const g=h||vt(te.FIVE_MINUTES),w={topic:n,relay:o,expiry:g,active:!1,methods:l};return this.core.expirer.set(n,g),await this.pairings.set(n,w),i.activatePairing&&await this.activate({topic:n}),this.events.emit(Di.create,w),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(s,n),await this.core.relayer.subscribe(n,{relay:o}),w},this.activate=async({topic:i})=>{this.isInitialized();const n=vt(te.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:h,reject:l}=ai();this.events.once(Be("pairing_ping",s),({error:c})=>{c?l(c):h()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ze("USER_DISCONNECTED")),await this.deletePairing(n))},this.sendRequest=async(i,n,s)=>{const o=Oi(n,s),h=await this.core.crypto.encode(i,o),l=cn[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,h,l),o.id},this.sendResult=async(i,n,s)=>{const o=Ns(i,s),h=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),c=cn[l.request.method].res;await this.core.relayer.publish(n,h,c),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=Cs(i,s),h=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),c=cn[l.request.method]?cn[l.request.method].res:cn.unregistered_method.res;await this.core.relayer.publish(n,h,c),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ze("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Wr(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Di.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Sr(n)?this.events.emit(Be("pairing_ping",s),{}):nr(n)&&this.events.emit(Be("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Di.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const h=Ze("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,h),this.logger.error(h)}catch(h){await this.sendError(s,i,h),this.logger.error(h)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ze("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=i=>{var n;if(!Ut(i)){const{message:o}=Z("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(o)}if(!Xy(i.uri)){const{message:o}=Z("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(o)}const s=Ph(i.uri);if(!((n=s?.relay)!=null&&n.protocol)){const{message:o}=Z("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(o)}if(!(s!=null&&s.symKey)){const{message:o}=Z("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(o)}if(s!=null&&s.expiryTimestamp&&te.toMiliseconds(s?.expiryTimestamp)<Date.now()){const{message:o}=Z("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(o)}},this.isValidPing=async i=>{if(!Ut(i)){const{message:s}=Z("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Ut(i)){const{message:s}=Z("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!ct(i,!1)){const{message:n}=Z("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Wr(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Z("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=kt(r,this.name),this.pairings=new wi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return zt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Bt.message,async e=>{const{topic:r,message:i}=e;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const n=await this.core.crypto.decode(r,i);try{aa(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Os(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id))}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(rr.expired,async e=>{const{topic:r}=ou(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Di.expire,{topic:r}))})}}class E2 extends Pd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Gt.EventEmitter,this.name=Gb,this.version=Qb,this.cached=[],this.initialized=!1,this.storagePrefix=ei,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:vt(te.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(hr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=nr(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(hr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(hr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=kt(r,this.name)}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:Oi(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(hr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=Z("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(hr.created,e=>{const r=hr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(hr.updated,e=>{const r=hr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(hr.deleted,e=>{const r=hr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Dn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{te.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(hr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class _2 extends qd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Gt.EventEmitter,this.name=Yb,this.version=Wb,this.cached=[],this.initialized=!1,this.storagePrefix=ei,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(rr.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(rr.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=kt(r,this.name)}get context(){return zt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return A1(e);if(typeof e=="number")return S1(e);const{message:r}=Z("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(rr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;te.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(rr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Dn.pulse,()=>this.checkExpirations()),this.events.on(rr.created,e=>{const r=rr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(rr.expired,e=>{const r=rr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(rr.deleted,e=>{const r=rr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class A2 extends jd{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.name=co,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||Li()||!Ui())return;const n=this.getVerifyUrl(i?.verifyUrl);this.verifyUrl!==n&&this.removeIframe(),this.verifyUrl=n;try{await this.createIframe()}catch(s){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(s),this.verifyDisabled=!0}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init())},this.resolve=async i=>{if(this.isDevEnv)return"";const n=this.getVerifyUrl(i?.verifyUrl);return this.fetchAttestation(i.attestationId,n)},this.fetchAttestation=async(i,n)=>{this.logger.info(`resolving attestation: ${i} from url: ${n}`);const s=this.startAbortTimer(te.ONE_SECOND*5),o=await fetch(`${n}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(s),o.status===200?await o.json():void 0},this.addToQueue=i=>{this.queue.push(i)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[])},this.sendPost=i=>{var n;try{if(!this.iframe)return;(n=this.iframe.contentWindow)==null||n.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let i;const n=s=>{s.data==="verify_ready"&&(this.onInit(),window.removeEventListener("message",n),i())};await Promise.race([new Promise(s=>{const o=document.getElementById(co);if(o)return this.iframe=o,this.onInit(),s();window.addEventListener("message",n);const h=document.createElement("iframe");h.id=co,h.src=`${this.verifyUrl}/${this.projectId}`,h.style.display="none",document.body.append(h),this.iframe=h,i=s}),new Promise((s,o)=>setTimeout(()=>{window.removeEventListener("message",n),o("verify iframe load timeout")},te.toMiliseconds(te.FIVE_SECONDS)))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=i=>{let n=i||dn;return Xb.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${dn}`),n=dn),n},this.logger=kt(r,this.name),this.verifyUrl=dn,this.abortController=new AbortController,this.isDevEnv=En()&&process.env.IS_VITEST}get context(){return zt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),te.toMiliseconds(e))}}class S2 extends zd{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=Zb,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:h=!1}=i,l=`${e2}/${this.projectId}/clients`;await Xw(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:h})})},this.logger=kt(r,this.context)}}var I2=Object.defineProperty,ac=Object.getOwnPropertySymbols,D2=Object.prototype.hasOwnProperty,x2=Object.prototype.propertyIsEnumerable,hc=(t,e,r)=>e in t?I2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cc=(t,e)=>{for(var r in e||(e={}))D2.call(e,r)&&hc(t,r,e[r]);if(ac)for(var r of ac(e))x2.call(e,r)&&hc(t,r,e[r]);return t};class ca extends Rd{constructor(e){var r;super(e),this.protocol=ll,this.version=Ab,this.name=ha,this.events=new Gt.EventEmitter,this.initialized=!1,this.on=(o,h)=>this.events.on(o,h),this.once=(o,h)=>this.events.once(o,h),this.off=(o,h)=>this.events.off(o,h),this.removeListener=(o,h)=>this.events.removeListener(o,h),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||dl,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=zo({level:typeof e?.logger=="string"&&e.logger?e.logger:Sb.logger}),{logger:n,chunkLoggerController:s}=Od({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,h;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((h=this.logChunkController)==null||h.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=kt(n,this.name),this.heartbeat=new id,this.crypto=new r2(this,this.logger,e?.keychain),this.history=new E2(this,this.logger),this.expirer=new _2(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new xf(cc(cc({},Ib),e?.storageOptions)),this.relayer=new m2({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new b2(this,this.logger),this.verify=new A2(this.projectId||"",this.logger),this.echoClient=new S2(this.projectId||"",this.logger)}static async init(e){const r=new ca(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(zb,i),r}get context(){return zt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async 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 M2=ca,gl="wc",ml=2,yl="client",ua=`${gl}@${ml}:${yl}:`,lo={name:yl,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},uc="WALLETCONNECT_DEEPLINK_CHOICE",N2="proposal",C2="Proposal expired",O2="session",Ai=te.SEVEN_DAYS,R2="engine",wt={wc_sessionPropose:{req:{ttl:te.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:te.ONE_DAY,prompt:!1,tag:1104},res:{ttl:te.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:te.ONE_DAY,prompt:!1,tag:1106},res:{ttl:te.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:te.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:te.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:te.ONE_DAY,prompt:!1,tag:1112},res:{ttl:te.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:te.ONE_DAY,prompt:!1,tag:1114},res:{ttl:te.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:te.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:te.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:te.FIVE_MINUTES,prompt:!1,tag:1119}}},fo={min:te.FIVE_MINUTES,max:te.SEVEN_DAYS},Er={idle:"IDLE",active:"ACTIVE"},P2="request",T2=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],F2="wc",L2="auth",U2="authKeys",B2="pairingTopics",q2="requests",Ps=`${F2}@${1.5}:${L2}:`,rs=`${Ps}:PUB_KEY`;var j2=Object.defineProperty,z2=Object.defineProperties,k2=Object.getOwnPropertyDescriptors,lc=Object.getOwnPropertySymbols,$2=Object.prototype.hasOwnProperty,K2=Object.prototype.propertyIsEnumerable,fc=(t,e,r)=>e in t?j2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lt=(t,e)=>{for(var r in e||(e={}))$2.call(e,r)&&fc(t,r,e[r]);if(lc)for(var r of lc(e))K2.call(e,r)&&fc(t,r,e[r]);return t},oi=(t,e)=>z2(t,k2(e));class H2 extends $d{constructor(e){super(e),this.name=R2,this.events=new Ac,this.initialized=!1,this.requestQueue={state:Er.idle,queue:[]},this.sessionRequestQueue={state:Er.idle,queue:[]},this.requestQueueDelay=te.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(wt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},te.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const i=oi(lt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:h,relays:l}=i;let c=n,g,w=!1;try{c&&(w=this.client.core.pairing.pairings.get(c).active)}catch(C){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),C}if(!c||!w){const{topic:C,uri:F}=await this.client.core.pairing.create();c=C,g=F}if(!c){const{message:C}=Z("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(C)}const E=await this.client.core.crypto.generateKeyPair(),b=wt.wc_sessionPropose.req.ttl||te.FIVE_MINUTES,S=vt(b),B=lt({requiredNamespaces:s,optionalNamespaces:o,relays:l??[{protocol:fl}],proposer:{publicKey:E,metadata:this.client.metadata},expiryTimestamp:S,pairingTopic:c},h&&{sessionProperties:h}),{reject:j,resolve:$,done:U}=ai(b,C2);this.events.once(Be("session_connect"),async({error:C,session:F})=>{if(C)j(C);else if(F){F.self.publicKey=E;const T=oi(lt({},F),{pairingTopic:B.pairingTopic,requiredNamespaces:B.requiredNamespaces,optionalNamespaces:B.optionalNamespaces});await this.client.session.set(F.topic,T),await this.setExpiry(F.topic,F.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:F.peer.metadata}),this.cleanupDuplicatePairings(T),$(T)}});const q=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:B,throwOnFailedPublish:!0});return await this.setProposal(q,lt({id:q},B)),{uri:g,approval:U}},this.pair=async r=>{await this.isInitialized();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async r=>{await this.isInitialized();try{await this.isValidApprove(r)}catch(U){throw this.client.logger.error("approve() -> isValidApprove() failed"),U}const{id:i,relayProtocol:n,namespaces:s,sessionProperties:o,sessionConfig:h}=r;let l;try{l=this.client.proposal.get(i)}catch(U){throw this.client.logger.error(`approve() -> proposal.get(${i}) failed`),U}const{pairingTopic:c,proposer:g,requiredNamespaces:w,optionalNamespaces:E}=l,b=await this.client.core.crypto.generateKeyPair(),S=g.publicKey,B=await this.client.core.crypto.generateSharedKey(b,S),j=lt(lt({relay:{protocol:n??"irn"},namespaces:s,controller:{publicKey:b,metadata:this.client.metadata},expiry:vt(Ai)},o&&{sessionProperties:o}),h&&{sessionConfig:h});await this.client.core.relayer.subscribe(B);const $=oi(lt({},j),{topic:B,requiredNamespaces:w,optionalNamespaces:E,pairingTopic:c,acknowledged:!1,self:j.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:b});await this.client.session.set(B,$);try{await this.sendResult({id:i,topic:c,result:{relay:{protocol:n??"irn"},responderPublicKey:b},throwOnFailedPublish:!0}),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0})}catch(U){throw this.client.logger.error(U),this.client.session.delete(B,Ze("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),U}return await this.client.core.pairing.updateMetadata({topic:c,metadata:g.metadata}),await this.client.proposal.delete(i,Ze("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:c}),await this.setExpiry(B,vt(Ai)),{topic:B,acknowledged:()=>new Promise(U=>setTimeout(()=>U(this.client.session.get(B)),500))}},this.reject=async r=>{await this.isInitialized();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:wt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ze("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized();try{await this.isValidUpdate(r)}catch(w){throw this.client.logger.error("update() -> isValidUpdate() failed"),w}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:h}=ai(),l=Jr(),c=ui().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Be("session_update",l),({error:w})=>{w?h(w):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:l,relayRpcId:c}).catch(w=>{this.client.logger.error(w),this.client.session.update(i,{namespaces:g}),h(w)}),{acknowledged:s}},this.extend=async r=>{await this.isInitialized();try{await this.isValidExtend(r)}catch(l){throw this.client.logger.error("extend() -> isValidExtend() failed"),l}const{topic:i}=r,n=Jr(),{done:s,resolve:o,reject:h}=ai();return this.events.once(Be("session_extend",n),({error:l})=>{l?h(l):o()}),await this.setExpiry(i,vt(Ai)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(l=>{h(l)}),{acknowledged:s}},this.request=async r=>{await this.isInitialized();try{await this.isValidRequest(r)}catch(b){throw this.client.logger.error("request() -> isValidRequest() failed"),b}const{chainId:i,request:n,topic:s,expiry:o=wt.wc_sessionRequest.req.ttl}=r,h=this.client.session.get(s),l=Jr(),c=ui().toString(),{done:g,resolve:w,reject:E}=ai(o,"Request expired. Please try again.");return this.events.once(Be("session_request",l),({error:b,result:S})=>{b?E(b):w(S)}),await Promise.all([new Promise(async b=>{await this.sendRequest({clientRpcId:l,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:oi(lt({},n),{expiryTimestamp:vt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(S=>E(S)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),b()}),new Promise(async b=>{var S;if(!((S=h.sessionConfig)!=null&&S.disableDeepLink)){const B=await x1(this.client.core.storage,uc);D1({id:l,topic:s,wcDeepLink:B})}b()}),g()]).then(b=>b[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n;Sr(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0}):nr(n)&&await this.sendError({id:s,topic:i,error:n.error}),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=Jr(),s=ui().toString(),{done:o,resolve:h,reject:l}=ai();this.events.once(Be("session_ping",n),({error:c})=>{c?l(c):h()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=ui().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ze("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=Z("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wy(i,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async r=>{this.isInitialized(),this.isValidAuthenticate(r);const{chains:i,statement:n="",uri:s,domain:o,nonce:h,type:l,exp:c,nbf:g,methods:w=[],expiry:E}=r,b=[...r.resources||[]],{topic:S,uri:B}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"]});this.client.logger.info({message:"Generated new pairing",pairing:{topic:S,uri:B}});const j=await this.client.core.crypto.generateKeyPair(),$=ts(j);if(await Promise.all([this.client.auth.authKeys.set(rs,{responseTopic:$,publicKey:j}),this.client.auth.pairingTopics.set($,{topic:$,pairingTopic:S})]),await this.client.core.relayer.subscribe($),this.client.logger.info(`sending request to new pairing topic: ${S}`),w.length>0){const{namespace:a}=Ks(i[0]);let d=by(a,"request",w);es(b)&&(d=_y(d,b.pop())),b.push(d)}const U=E&&E>wt.wc_sessionAuthenticate.req.ttl?E:wt.wc_sessionAuthenticate.req.ttl,q={authPayload:{type:l??"caip122",chains:i,statement:n,aud:s,domain:o,version:"1",nonce:h,iat:new Date().toISOString(),exp:c,nbf:g,resources:b},requester:{publicKey:j,metadata:this.client.metadata},expiryTimestamp:vt(U)},C={eip155:{chains:i,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},F={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:S,proposer:{publicKey:j,metadata:this.client.metadata},expiryTimestamp:vt(wt.wc_sessionPropose.req.ttl)},{done:T,resolve:p,reject:x}=ai(U,"Request expired"),V=async({error:a,session:d})=>{if(this.events.off(Be("session_request",X),J),a)x(a);else if(d){d.self.publicKey=j,await this.client.session.set(d.topic,d),await this.setExpiry(d.topic,d.expiry),S&&await this.client.core.pairing.updateMetadata({topic:S,metadata:d.peer.metadata});const m=this.client.session.get(d.topic);await this.deleteProposal(ee),p({session:m})}},J=async a=>{if(await this.deletePendingAuthRequest(X,{message:"fulfilled",code:0}),a.error){const v=Ze("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return a.error.code===v.code?void 0:(this.events.off(Be("session_connect"),V),x(a.error.message))}await this.deleteProposal(ee),this.events.off(Be("session_connect"),V);const{cacaos:d,responder:m}=a.result,_=[],A=[];for(const v of d){await Ih({cacao:v,projectId:this.client.core.projectId})||(this.client.logger.error(v,"Signature verification failed"),x(Ze("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:f}=v,I=es(f.resources),H=[Sh(f.iss)],Y=fs(f.iss);if(I){const y=Dh(I),k=xh(I);_.push(...y),H.push(...k)}for(const y of H)A.push(`${y}:${Y}`)}const D=await this.client.core.crypto.generateSharedKey(j,m.publicKey);let R;_.length>0&&(R={topic:D,acknowledged:!0,self:{publicKey:j,metadata:this.client.metadata},peer:m,controller:m.publicKey,expiry:vt(Ai),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:S,namespaces:Th([...new Set(_)],[...new Set(A)])},await this.client.core.relayer.subscribe(D),await this.client.session.set(D,R),S&&await this.client.core.pairing.updateMetadata({topic:S,metadata:m.metadata}),R=this.client.session.get(D)),p({auths:d,session:R})},X=Jr(),ee=Jr();this.events.once(Be("session_connect"),V),this.events.once(Be("session_request",X),J);try{await Promise.all([this.sendRequest({topic:S,method:"wc_sessionAuthenticate",params:q,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:X}),this.sendRequest({topic:S,method:"wc_sessionPropose",params:F,expiry:wt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:ee})])}catch(a){throw this.events.off(Be("session_connect"),V),this.events.off(Be("session_request",X),J),a}return await this.setProposal(ee,lt({id:ee},F)),await this.setAuthRequest(X,{request:oi(lt({},q),{verifyContext:{}}),pairingTopic:S}),{uri:B,response:T}},this.approveSessionAuthenticate=async r=>{this.isInitialized();const{id:i,auths:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);const o=s.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=ts(o),c={type:Hr,receiverPublicKey:o,senderPublicKey:h},g=[],w=[];for(const S of n){if(!await Ih({cacao:S,projectId:this.client.core.projectId})){const q=Ze("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:q,encodeOpts:c}),new Error(q.message)}const{p:B}=S,j=es(B.resources),$=[Sh(B.iss)],U=fs(B.iss);if(j){const q=Dh(j),C=xh(j);g.push(...q),$.push(...C)}for(const q of $)w.push(`${q}:${U}`)}const E=await this.client.core.crypto.generateSharedKey(h,o);let b;return g?.length>0&&(b={topic:E,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:o,metadata:s.requester.metadata},controller:o,expiry:vt(Ai),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:s.pairingTopic,namespaces:Th([...new Set(g)],[...new Set(w)])},await this.client.core.relayer.subscribe(E),await this.client.session.set(E,b),await this.client.core.pairing.updateMetadata({topic:s.pairingTopic,metadata:s.requester.metadata})),await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:c,throwOnFailedPublish:!0}),await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:s.pairingTopic}),{session:b}},this.rejectSessionAuthenticate=async r=>{await this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);const o=s.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=ts(o),c={type:Hr,receiverPublicKey:o,senderPublicKey:h};await this.sendError({id:i,topic:l,error:n,encodeOpts:c,rpcOpts:wt.wc_sessionAuthenticate.reject}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ze("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:i,iss:n}=r;return ku(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)},this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,h;return((o=s.peerMetadata)==null?void 0:o.url)&&((h=s.peerMetadata)==null?void 0:h.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:h=0}=r,{self:l}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ze("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(uc).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===n&&this.deletePendingSessionRequest(c.id,Ze("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Er.idle),o&&this.client.events.emit("session_delete",{id:h,topic:n})},this.deleteProposal=async(r,i)=>{await Promise.all([this.client.proposal.delete(r,Ze("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=Er.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))},this.setProposal=async(r,i)=>{this.client.core.expirer.set(r,vt(wt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)},this.setAuthRequest=async(r,i)=>{const{request:n,pairingTopic:s}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext})},this.setPendingSessionRequest=async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,h=s.request.expiryTimestamp||vt(wt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,h),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:h,clientRpcId:l,throwOnFailedPublish:c}=r,g=Oi(n,s,l);if(Ui()&&T2.includes(n)){const b=ci(JSON.stringify(g));this.client.core.verify.register({attestationId:b})}let w;try{w=await this.client.core.crypto.encode(i,g)}catch(b){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),b}const E=wt[n].req;return o&&(E.ttl=o),h&&(E.id=h),this.client.core.history.set(i,g),c?(E.internal=oi(lt({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,w,E)):this.client.core.relayer.publish(i,w,E).catch(b=>this.client.logger.error(b)),g.id},this.sendResult=async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:h}=r,l=Ns(i,s);let c;try{c=await this.client.core.crypto.encode(n,l,h)}catch(E){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),E}let g;try{g=await this.client.core.history.get(n,i)}catch(E){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),E}const w=wt[g.request.method].res;o?(w.internal=oi(lt({},w.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,c,w)):this.client.core.relayer.publish(n,c,w).catch(E=>this.client.logger.error(E)),await this.client.core.history.resolve(l)},this.sendError=async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:h}=r,l=Cs(i,s);let c;try{c=await this.client.core.crypto.encode(n,l,o)}catch(E){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),E}let g;try{g=await this.client.core.history.get(n,i)}catch(E){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),E}const w=h||wt[g.request.method].res;this.client.core.relayer.publish(n,c,w),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Wr(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Wr(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Er.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Er.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Er.idle},this.processRequest=async r=>{const{topic:i,payload:n}=r,s=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:s}))switch(s){case"wc_sessionPropose":return await this.onSessionProposeRequest(i,n);case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest(i,n);case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest(i,n);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:i,payload:n}=r,s=(await this.client.core.history.get(i,n.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:i}=r,{message:n}=Z("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async(r,i)=>{const{params:n,id:s}=i;try{this.isValidConnect(lt({},i.params));const o=n.expiryTimestamp||vt(wt.wc_sessionPropose.req.ttl),h=lt({id:s,pairingTopic:r,expiryTimestamp:o},n);await this.setProposal(s,h);const l=ci(JSON.stringify(i)),c=await this.getVerifyContext(l,h.proposer.metadata);this.client.events.emit("session_proposal",{id:s,params:h,verifyContext:c})}catch(o){await this.sendError({id:s,topic:r,error:o,rpcOpts:wt.wc_sessionPropose.autoReject}),this.client.logger.error(o)}},this.onSessionProposeResponse=async(r,i)=>{const{id:n}=i;if(Sr(i)){const{result:s}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const o=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:o});const h=o.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:h});const l=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const c=await this.client.core.crypto.generateSharedKey(h,l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const g=await this.client.core.relayer.subscribe(c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.client.core.pairing.activate({topic:r})}else if(nr(i)){await this.client.proposal.delete(n,Ze("USER_DISCONNECTED"));const s=Be("session_connect");if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners, 954`);this.events.emit(Be("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:h,expiry:l,namespaces:c,sessionProperties:g,sessionConfig:w}=i.params,E=lt(lt({topic:r,relay:o,expiry:l,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:h.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:h.publicKey,metadata:h.metadata}},g&&{sessionProperties:g}),w&&{sessionConfig:w});await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0});const b=Be("session_connect");if(this.events.listenerCount(b)===0)throw new Error(`emitting ${b} without any listeners 997`);this.events.emit(Be("session_connect"),{session:E})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;Sr(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Be("session_approve",n),{})):nr(i)&&(await this.client.session.delete(r,Ze("USER_DISCONNECTED")),this.events.emit(Be("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,h=hn.get(o);if(h&&this.isRequestOutOfSync(h,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:Ze("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(lt({topic:r},n));try{hn.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(l){throw hn.delete(o),l}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i,s=Be("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Sr(i)?this.events.emit(Be("session_update",n),{}):nr(i)&&this.events.emit(Be("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,vt(Ai)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,i)=>{const{id:n}=i,s=Be("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Sr(i)?this.events.emit(Be("session_extend",n),{}):nr(i)&&this.events.emit(Be("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(r,i)=>{const{id:n}=i,s=Be("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Sr(i)?this.events.emit(Be("session_ping",n),{}):nr(i)&&this.events.emit(Be("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),await Promise.all([new Promise(s=>{this.client.core.relayer.once(Bt.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Ze("USER_DISCONNECTED")})])}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async(r,i)=>{var n;const{id:s,params:o}=i;try{await this.isValidRequest(lt({topic:r},o));const h=ci(JSON.stringify(Oi("wc_sessionRequest",o,s))),l=this.client.session.get(r),c=await this.getVerifyContext(h,l.peer.metadata),g={id:s,topic:r,params:o,verifyContext:c};await this.setPendingSessionRequest(g),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(h){await this.sendError({id:s,topic:r,error:h}),this.client.logger.error(h)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i,s=Be("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Sr(i)?this.events.emit(Be("session_request",n),{result:i.result}):nr(i)&&this.events.emit(Be("session_request",n),{error:i.error})},this.onSessionEventRequest=async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,h=hn.get(o);if(h&&this.isRequestOutOfSync(h,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(lt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),hn.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),Sr(i)?this.events.emit(Be("session_request",n),{result:i.result}):nr(i)&&this.events.emit(Be("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async(r,i)=>{try{const{requester:n,authPayload:s,expiryTimestamp:o}=i.params,h=ci(JSON.stringify(i)),l=await this.getVerifyContext(h,this.client.metadata),c={requester:n,pairingTopic:r,id:i.id,authPayload:s,verifyContext:l,expiryTimestamp:o};await this.setAuthRequest(i.id,{request:c,pairingTopic:r}),this.client.events.emit("session_authenticate",{topic:r,params:i.params,id:i.id,verifyContext:l})}catch(n){this.client.logger.error(n);const s=i.params.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),h={type:Hr,receiverPublicKey:s,senderPublicKey:o};await this.sendError({id:i.id,topic:r,error:n,encodeOpts:h,rpcOpts:wt.wc_sessionAuthenticate.autoReject})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Er.idle,this.processSessionRequestQueue()},te.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,h=Be("session_request",o);if(this.events.listenerCount(h)===0)throw new Error(`emitting ${h} without any listeners`);this.events.emit(Be("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Er.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Er.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onPairingCreated=r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest(r.topic,Oi("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id))},this.isValidConnect=async r=>{if(!Ut(r)){const{message:l}=Z("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(l)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:h}=r;if(Ot(i)||await this.isValidPairingTopic(i),!hw(h,!0)){const{message:l}=Z("MISSING_OR_INVALID",`connect() relays: ${h}`);throw new Error(l)}!Ot(n)&&ps(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Ot(s)&&ps(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Ot(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,i)=>{const n=aw(r,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async r=>{if(!Ut(r))throw new Error(Z("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const h=this.client.proposal.get(i),l=oo(n,"approve()");if(l)throw new Error(l.message);const c=Uh(h.requiredNamespaces,n,"approve()");if(c)throw new Error(c.message);if(!ct(s,!0)){const{message:g}=Z("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}Ot(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!Ut(r)){const{message:s}=Z("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!uw(n)){const{message:s}=Z("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!Ut(r)){const{message:c}=Z("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(c)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Qu(i)){const{message:c}=Z("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const h=tw(n,"onSessionSettleRequest()");if(h)throw new Error(h.message);const l=oo(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(Wr(o)){const{message:c}=Z("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async r=>{if(!Ut(r)){const{message:l}=Z("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(l)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=oo(n,"update()");if(o)throw new Error(o.message);const h=Uh(s.requiredNamespaces,n,"update()");if(h)throw new Error(h.message)},this.isValidExtend=async r=>{if(!Ut(r)){const{message:n}=Z("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async r=>{if(!Ut(r)){const{message:l}=Z("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(l)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:h}=this.client.session.get(i);if(!Lh(h,s)){const{message:l}=Z("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(l)}if(!lw(n)){const{message:l}=Z("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(l)}if(!pw(h,s,n.method)){const{message:l}=Z("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(l)}if(o&&!ww(o,fo)){const{message:l}=Z("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${fo.min} and ${fo.max}`);throw new Error(l)}},this.isValidRespond=async r=>{var i;if(!Ut(r)){const{message:o}=Z("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!fw(s)){const{message:o}=Z("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!Ut(r)){const{message:n}=Z("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!Ut(r)){const{message:h}=Z("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(h)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Lh(o,s)){const{message:h}=Z("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(h)}if(!dw(n)){const{message:h}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}if(!gw(o,s,n.name)){const{message:h}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}},this.isValidDisconnect=async r=>{if(!Ut(r)){const{message:n}=Z("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ct(n,!1))throw new Error("uri is required parameter");if(!ct(s,!1))throw new Error("domain is required parameter");if(!ct(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(l=>Ks(l).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:h}=Ks(i[0]);if(h!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async(r,i)=>{const n={verified:{verifyUrl:i.verifyUrl||dn,validation:"UNKNOWN",origin:i.url||""}};try{const s=await this.client.core.verify.resolve({attestationId:r,verifyUrl:i.verifyUrl});s&&(n.verified.origin=s.origin,n.verified.isScam=s.isScam,n.verified.validation=s.origin===new URL(i.url).origin?"VALID":"INVALID")}catch(s){this.client.logger.info(s)}return this.client.logger.info(`Verify context: ${JSON.stringify(n)}`),n},this.validateSessionProps=(r,i)=>{Object.values(r).forEach(n=>{if(!ct(n,!1)){const{message:s}=Z("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}}async isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Bt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i}=e,{publicKey:n}=this.client.auth.authKeys.keys.includes(rs)?this.client.auth.authKeys.get(rs):{responseTopic:void 0,publicKey:void 0},s=await this.client.core.crypto.decode(r,i,{receiverPublicKey:n});try{aa(s)?(this.client.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Os(s)?(await this.client.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.client.core.history.delete(r,s.id)):this.onRelayEventUnknownPayload({topic:r,payload:s})}catch(o){this.client.logger.error(o)}}registerExpirerEvents(){this.client.core.expirer.on(rr.expired,async e=>{const{topic:r,id:i}=ou(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Z("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Z("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Di.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Di.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ct(e,!1)){const{message:r}=Z("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}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Wr(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=Z("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ct(e,!1)){const{message:r}=Z("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Wr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=Z("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=Z("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(ct(e,!1)){const{message:r}=Z("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=Z("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!cw(e)){const{message:r}=Z("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Wr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=Z("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class V2 extends wi{constructor(e,r){super(e,r,N2,ua),this.core=e,this.logger=r}}class G2 extends wi{constructor(e,r){super(e,r,O2,ua),this.core=e,this.logger=r}}class Q2 extends wi{constructor(e,r){super(e,r,P2,ua,i=>i.id),this.core=e,this.logger=r}}class Y2 extends wi{constructor(e,r){super(e,r,U2,Ps,()=>rs),this.core=e,this.logger=r}}class W2 extends wi{constructor(e,r){super(e,r,B2,Ps),this.core=e,this.logger=r}}class J2 extends wi{constructor(e,r){super(e,r,q2,Ps,i=>i.id),this.core=e,this.logger=r}}class X2{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new Y2(this.core,this.logger),this.pairingTopics=new W2(this.core,this.logger),this.requests=new J2(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Ts extends kd{constructor(e){super(e),this.protocol=gl,this.version=ml,this.name=lo.name,this.events=new Gt.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async i=>{try{return await this.engine.authenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||lo.name,this.metadata=e?.metadata||w1(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Es(zo({level:e?.logger||lo.logger}));this.core=e?.core||new M2(e),this.logger=kt(r,this.name),this.session=new G2(this.core,this.logger),this.proposal=new V2(this.core,this.logger),this.pendingRequest=new Q2(this.core,this.logger),this.engine=new H2(this),this.auth=new X2(this.core,this.logger)}static async init(e){const r=new Ts(e);return await r.initialize(),r}get context(){return zt(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(),await this.auth.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const po=ur.getDevice(),Z2={width:"245px",height:"245px",borderRadius:"40px",zIndex:"99999",backgroundColor:"white",border:"none",outline:"none"},e3=`
  <div id="argent-mobile-modal-container" style="position: relative; display: flex; justify-content: center; align-items: center">
    <iframe class="argent-iframe" allow="clipboard-write"></iframe>
  </div>
`;class t3{constructor(){Te(this,"bridgeUrl","https://login.ready.co");Te(this,"mobileUrl","ready://");Te(this,"type","overlay");Te(this,"wcUri");Te(this,"overlay");Te(this,"popupWindow");Te(this,"closingTimeout");Te(this,"standaloneConnectorModal")}showWalletConnectModal(e,r){const i=encodeURIComponent(e),n=encodeURIComponent(window.location.href);this.showModal({desktop:`${this.bridgeUrl}?wc=${i}&href=${n}&device=desktop&onlyQR=true`,ios:`${this.mobileUrl}app/wc?uri=${i}&href=${n}&device=mobile&onlyQR=true`,android:`${this.mobileUrl}app/wc?uri=${i}&href=${n}&device=mobile&onlyQR=true`},r)}getWalletConnectQR(e){const r=encodeURIComponent(e),i=encodeURIComponent(window.location.href);this.getQR({desktop:`${this.bridgeUrl}?wc=${r}&href=${i}&device=desktop&onlyQR=true`,ios:`${this.mobileUrl}app/wc?uri=${r}&href=${i}&device=mobile&onlyQR=true`,android:`${this.mobileUrl}app/wc?uri=${r}&href=${i}&device=mobile&onlyQR=true`})}openMobileApp(e){const r=document.createElement("button");r.style.display="none",r.addEventListener("click",()=>{window.location.href=e[po]}),r.click()}getQR(e){if(["android","ios"].includes(po)){this.openMobileApp(e);return}const r=document.createElement("div"),i=document.querySelector("#starknetkit-modal-container");if(i?.shadowRoot){const n=i.shadowRoot.querySelector(".qr-code-slot");if(n){n.innerHTML=e3,document.body.appendChild(r),this.overlay=r;const s=n.querySelector("iframe");s.setAttribute("src",e.desktop);for(const[o,h]of Object.entries(Z2))s.style[o]=h}else throw new Error("Cannot find QR code slot")}else throw new Error("Cannot find modal")}showApprovalModal(e){const r=encodeURIComponent(window.location.href),i={desktop:`${this.bridgeUrl}?action=sign&device=desktop&href=${r}`,ios:`${this.mobileUrl}app/wc/request?href=${r}&device=mobile`,android:`${this.mobileUrl}app/wc/request?href=${r}&device=mobile`};if(!pc.isInArgentMobileAppBrowser()){if(this.getModal(void 0,ur.Layout.approval),["android","ios"].includes(po)){this.openMobileApp(i);return}return}this.showModal(i,void 0)}closeModal({success:e,isRequest:r}={success:!1,isRequest:!1}){const i=this.standaloneConnectorModal;e?(i?.$set({layout:ur.Layout.success}),setTimeout(()=>i?.$destroy(),500)):r?(i?.$set({layout:ur.Layout.requestFailure}),setTimeout(()=>i?.$destroy(),500)):i?.$set({layout:ur.Layout.loginFailure})}getModal(e,r=ur.Layout.qrCode){this.standaloneConnectorModal=new ur.Modal({target:ur.getModalTarget(),props:{layout:r,dappName:e?.dappName,showBackButton:!1,selectedWallet:e,callback:async i=>{try{const n=i?.connector;this.standaloneConnectorModal?.$destroy(),await n?.connect()}catch{this.standaloneConnectorModal?.$set({layout:ur.Layout.loginFailure})}}}})}showModal(e,r){this.getModal(r,ur.Layout.qrCode),this.getQR(e)}}const fr=new t3,ys=Dr.constants.NetworkName,r3=async({projectId:t,chainId:e,name:r,description:i,rpcUrl:n,bridgeUrl:s=i3(e),mobileUrl:o=n3(e),modalType:h="overlay",url:l,icons:c,walletConnect:g,onlyQRCode:w,modalWallet:E},b)=>{if(!s)throw new Error("bridgeUrl is required");if(!o)throw new Error("mobileUrl is required");fr.bridgeUrl=s,fr.mobileUrl=o,fr.type=h;const S={projectId:t,metadata:{name:r??"Unknown dapp",description:i??"Unknown dapp description",url:l??"#",icons:c??[],...g?.metadata}},B=await Ts.init(S),j=new Dr.RpcProvider({nodeUrl:n}),$=new b({client:B,chainId:e,rpcUrl:n,provider:j});B.on("session_event",U=>{}),B.on("session_update",({topic:U,params:q})=>{const{namespaces:C}=q,F=B.session.get(U);$.updateSession({...F,namespaces:C})}),B.on("session_delete",()=>{});try{const U=B.session.getAll().find($.isValidSession);if(U)return $.updateSession(U),$;const q={requiredNamespaces:$.getRequiredNamespaces()};pc.resetWalletConnect(),await new Promise(T=>setTimeout(T,200));const{uri:C,approval:F}=await B.connect(q);if(C){w?fr.getWalletConnectQR(C):fr.showWalletConnectModal(C,{...E,dappName:r||""}),fr.wcUri=C;const T=await F();$.updateSession(T),fr.closeModal({success:!0})}return $}catch{return console.error("@argent/login::error"),fr.closeModal(),null}},i3=t=>{if(!t)throw new Error(`Unknown or unsupported chainId (${t}), either specify a supported chain or set bridgeUrl.`);const e=parseInt(`${t}`);if(String(t).startsWith(ys.SN_SEPOLIA)||e===11155111)return"https://mobile-login.hydrogen.argent47.net";if(String(t).startsWith(ys.SN_MAIN)||e===1)return"https://login.argent.xyz"},n3=t=>{if(!t)throw new Error(`Unknown or unsupported chainId (${t}), either specify a supported chain or set mobileUrl.`);const e=parseInt(`${t}`);if(String(t).startsWith(ys.SN_SEPOLIA)||e===11155111)return"argent-dev://";if(String(t).startsWith(ys.SN_MAIN)||e===1)return"argent://"};function s3(t){return typeof t<"u"&&typeof t.context<"u"}const xr={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class o3 extends Lw{constructor(e){super(),this.events=new Gt.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?ru(this.session.namespaces):u1(this.requiredNamespaces)}get accounts(){return this.session?tu(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",i=>{r(i)}),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:i,approval:n}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(xr.uri,{uri:i}),this.session=await n(),this.events.emit(xr.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(i=>this.events.emit("payload",Ns(e.id,i))).catch(i=>this.events.emit("payload",Cs(e.id,i.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,i)=>{this.events.once("register_error",n=>{i(n)}),this.events.once(xr.init,()=>{if(typeof this.client>"u")return i(new Error("Sign Client not initialized"));r(this.client)})});if(s3(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Ts.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(xr.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(xr.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(xr.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(xr.deleted,this.session),this.session=void 0))}))}}class a3{constructor(){Te(this,"accounts",[]);Te(this,"eventEmitter",new Gt.EventEmitter);Te(this,"updateSession",e=>{if(!this.isValidSession(e))throw console.warn("updateSession incompatible session",e,"for adapter",this.formatChainId(this.chainId)),new Error("Invalid session");this.session=e;const r=ru(e.namespaces,[this.namespace]);this.setChainIds(r);const i=tu(e.namespaces,[this.namespace]);this.setAccounts(i)});Te(this,"isValidSession",({namespaces:e,requiredNamespaces:r})=>{const i=this.formatChainId(this.chainId);return r?!!r[this.namespace]?.chains?.includes(i):!!e?.[this.namespace]?.accounts.some(n=>n.startsWith(i))})}getRequiredNamespaces(){const e=[this.formatChainId(this.chainId)];return{[this.namespace]:{chains:e,methods:this.methods,events:this.events}}}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}setChainIds(e){const i=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);i.length&&(this.chainId=i[0],this.eventEmitter.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.eventEmitter.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,i,n]=e.split(":");return{chainId:`${r}:${i}`,address:n}}getSignerConnection(e){return new o3({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e})}registerEventListeners(){this.rpcProvider.on("connect",()=>{const{chains:e,accounts:r}=this.signerConnection;e?.length&&this.setChainIds(e),r?.length&&this.setAccounts(r)}),this.signerConnection.on(xr.created,this.updateSession),this.signerConnection.on(xr.updated,this.updateSession),this.signerConnection.on(xr.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.eventEmitter.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.eventEmitter.emit(r.name,r.data)}),this.rpcProvider.on("disconnect",()=>{this.eventEmitter.emit("disconnect")})}}class dc extends Dr.Account{constructor(e,r,i,n){super(e,r,i),this.wallet=n}async execute(e,r,i={}){const n=Array.isArray(e)?e:[e],s=r===void 0||Array.isArray(r)?i:r;return await this.wallet.wallet_requestAddInvokeTransaction({accountAddress:this.address,executionRequest:{calls:n,invocationDetails:s}})}async declare(e,r){throw new Error("Not supported via Ready Login")}async deployAccount(e,r){throw new Error("Not supported via Ready Login")}}class h3{constructor(e){this.wallet=e}async getPubKey(){throw new Error("Not supported via Ready Login")}async signMessage(e,r){const{signature:i}=await this.wallet.wallet_signTypedData({accountAddress:r,typedData:e});return i}async signTransaction(e,r,i){throw new Error("Not supported via Ready Login")}async signDeployAccountTransaction(e){throw new Error("Not supported via Ready Login")}async signDeclareTransaction(e){throw new Error("Not supported via Ready Login")}}const c3=t=>t.replace(/^SN_/,"SN"),u3=t=>t.replace(/^SN/,"SN_");class l3 extends a3{constructor({client:r,chainId:i,rpcUrl:n,provider:s}){super();Te(this,"id","argentMobile");Te(this,"name","Ready (formerly Argent)");Te(this,"version","0.1.0");Te(this,"icon","");Te(this,"provider");Te(this,"signer");Te(this,"account");Te(this,"selectedAddress","");Te(this,"namespace","starknet");Te(this,"methods",["starknet_supportedSpecs","starknet_signTypedData","starknet_requestAddInvokeTransaction","wallet_supportedSpecs","wallet_signTypedData","wallet_addInvokeTransaction"]);Te(this,"events",["chainChanged","accountsChanged"]);Te(this,"remoteSigner");Te(this,"signerConnection");Te(this,"rpcProvider");Te(this,"chainId");Te(this,"client");Te(this,"session");Te(this,"rpc");Te(this,"walletRpc");Te(this,"handleRequest");Te(this,"request",async r=>{if(!this.session)throw new Error("No session");let i=r.type;(i==="wallet_addInvokeTransaction"||i==="wallet_supportedSpecs"||i==="wallet_signTypedData")&&(i=i.replace("wallet_","starknet_"));const n=this.handleRequest[i];if(n)return n(r.params);throw new Error(`Not implemented: .request() for ${r.type}`)});Te(this,"on",(r,i)=>{this.eventEmitter.on(r,i)});Te(this,"off",(r,i)=>{this.eventEmitter.off(r,i)});Te(this,"handleRequestChainId",()=>this.chainId===Dr.constants.NetworkName.SN_SEPOLIA?Dr.constants.StarknetChainId.SN_SEPOLIA:Dr.constants.StarknetChainId.SN_MAIN);Te(this,"handleRequestAccounts",()=>this.accounts);Te(this,"handleGetPermissions",async()=>await this.isPreauthorized()?["accounts"]:[]);Te(this,"handleAddInvokeTransaction",async r=>{const{calls:i}=r;return await this.requestWallet({method:"starknet_requestAddInvokeTransaction",params:{accountAddress:this.account.address,executionRequest:{calls:i?.map(({contract_address:n,entry_point:s,...o})=>({...o,contractAddress:n,entrypoint:s}))}}})});Te(this,"handleSignTypedData",async r=>{const i={accountAddress:this.account.address,typedData:r},n=await this.requestWallet({method:"starknet_signTypedData",params:i});return"signature"in n?n.signature:n});Te(this,"handleSupportedSpecs",async()=>await this.requestWallet({method:"starknet_supportedSpecs",params:{}}));this.chainId=String(i??Dr.constants.NetworkName.SN_MAIN),this.rpc={chains:i?[this.formatChainId(this.chainId)]:[],methods:this.methods,events:this.events},this.signerConnection=this.getSignerConnection(r),this.rpcProvider=new el(this.signerConnection),this.client=r,this.registerEventListeners(),this.walletRpc=new Proxy({},{get:(o,h)=>l=>this.requestWallet({method:h,params:l})}),this.remoteSigner=new h3(this.walletRpc),this.provider=s||new Dr.RpcProvider({nodeUrl:n}),this.account=new dc(this.provider,"",this.remoteSigner,this.walletRpc),this.handleRequest=Object.freeze({wallet_requestChainId:this.handleRequestChainId,wallet_requestAccounts:this.handleRequestAccounts,wallet_getPermissions:this.handleGetPermissions,starknet_addInvokeTransaction:this.handleAddInvokeTransaction,starknet_signTypedData:this.handleSignTypedData,starknet_supportedSpecs:this.handleSupportedSpecs,wallet_addInvokeTransaction:this.handleAddInvokeTransaction,wallet_signTypedData:this.handleSignTypedData,wallet_supportedSpecs:this.handleSupportedSpecs})}getNetworkName(r){if(r==="SN_SEPOLIA")return Dr.constants.NetworkName.SN_SEPOLIA;if(r==="SN_MAIN")return Dr.constants.NetworkName.SN_MAIN;throw new Error(`Unknown starknet.js network name for chainId ${r}`)}async enable(){return await this.rpcProvider.connect(),this.accounts}get isConnected(){return!0}async isPreauthorized(){return!!this.client.session.getAll().find(this.isValidSession)}async requestWallet(r){if(!this.session)throw new Error("No session");try{const{topic:i}=this.session,n=this.formatChainId(this.chainId);fr.showApprovalModal(r);const s=await this.client.request({topic:i,chainId:n,request:r});return fr.closeModal({success:!0}),s}catch(i){throw fr.closeModal({isRequest:!0}),i instanceof Error||i&&i.message!==void 0?new Error(i.message):new Error("Unknown error on requestWallet")}}get isConnecting(){return this.signerConnection.connecting}async disable(){await this.rpcProvider.disconnect()}get isWalletConnect(){return!0}registerEventListeners(){super.registerEventListeners(),this.eventEmitter.on("chainChanged",r=>{throw new Error("Not implemented: chainChanged")})}formatChainId(r){return`${this.namespace}:${c3(r)}`}parseChainId(r){return u3(r.split(":")[1])}setAccounts(r){this.accounts=r.filter(s=>this.parseChainId(this.parseAccountId(s).chainId)===this.chainId).map(s=>this.parseAccountId(s).address);const{address:i}=this.parseAccountId(r[0]),n=i.startsWith("0x")?i:`0x${i}`;this.account=new dc(this.provider,n,this.remoteSigner,this.walletRpc),this.eventEmitter.emit("accountsChanged",this.accounts),this.selectedAddress=n}}const f3=async t=>r3(t,l3);exports.getStarknetWindowObject=f3;