const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BAdBZGR3.js","assets/index-DirqwtNG.js","assets/index-CAoM9NBU.css"])))=>i.map(i=>d[i]);
import{aK as Bi,aQ as No,aR as io,aS as Sw,aG as go,aH as xw,aT as O0,aN as V1,aU as G1,aO as td,aV as rd,aW as id,aX as Pw}from"./index-DirqwtNG.js";import{i as Rw,b as Nw,a as Cw,c as Ow,d as Tw,e as Dw,f as Fw,g as qw,h as Bw,j as Lw,k as me,l as kw,w as J1,r as Ma,s as $w,m as zw,n as nd,o as W1,p as xf,x as Q1,H as Uw,q as Y1,t as jw}from"./json-BxMCAwka.js";var T0=function(r,e,t){if(t||arguments.length===2)for(var i=0,s=e.length,a;i<s;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return r.concat(a||Array.prototype.slice.call(e))},Kw=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Hw=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r}(),Vw=function(){function r(e,t,i,s){this.name=e,this.version=t,this.os=i,this.bot=s,this.type="bot-device"}return r}(),Gw=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Jw=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),Ww=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Qw=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,D0=3,Yw=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Ww]],F0=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Xw(r){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Jw:typeof navigator<"u"?e5(navigator.userAgent):r5()}function Zw(r){return r!==""&&Yw.reduce(function(e,t){var i=t[0],s=t[1];if(e)return e;var a=s.exec(r);return!!a&&[i,a]},!1)}function e5(r){var e=Zw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Gw;var s=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);s?s.length<D0&&(s=T0(T0([],s,!0),i5(D0-s.length),!0)):s=[];var a=s.join("."),f=t5(r),p=Qw.exec(r);return p&&p[1]?new Vw(t,a,f,p[1]):new Kw(t,a,f)}function t5(r){for(var e=0,t=F0.length;e<t;e++){var i=F0[e],s=i[0],a=i[1],f=a.exec(r);if(f)return s}return null}function r5(){var r=typeof process<"u"&&process.version;return r?new Hw(process.version.slice(1)):null}function i5(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}function X1(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function eu(r,e){e||(e=r.reduce((s,a)=>s+a.length,0));const t=X1(e);let i=0;for(const s of r)t.set(s,i),i+=s.length;return t}const hf={...Rw,...Nw,...Cw,...Ow,...Tw,...Dw,...Fw,...qw,...Bw,...Lw};function Z1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const q0=Z1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),tu=Z1("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=X1(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),eg={utf8:q0,"utf-8":q0,hex:hf.base16,latin1:tu,ascii:tu,binary:tu,...hf};function Fi(r,e="utf8"){const t=eg[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function ni(r,e="utf8"){const t=eg[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}const n5=/"(?:_|\\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*:/,s5=/"(?: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*:/,a5=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function o5(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){c5(r);return}return e}function c5(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function jc(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.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(!a5.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(n5.test(r)||s5.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,o5)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function f5(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function mr(r,...e){try{return f5(r(...e))}catch(t){return Promise.reject(t)}}function h5(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function u5(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ef(r){if(h5(r))return String(r);if(u5(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ef(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function tg(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Bu="base64:";function d5(r){if(typeof r=="string")return r;tg();const e=Buffer.from(r).toString("base64");return Bu+e}function l5(r){return typeof r!="string"||!r.startsWith(Bu)?r:(tg(),Buffer.from(r.slice(Bu.length),"base64"))}function ei(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function p5(...r){return ei(r.join(":"))}function Kc(r){return r=ei(r),r?r+":":""}const g5="memory",v5=()=>{const r=new Map;return{name:g5,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function b5(r={}){const e={mounts:{"":r.driver||v5()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=b=>{for(const A of e.mountpoints)if(b.startsWith(A))return{base:A,relativeKey:b.slice(A.length),driver:e.mounts[A]};return{base:"",relativeKey:b,driver:e.mounts[""]}},i=(b,A)=>e.mountpoints.filter(M=>M.startsWith(b)||A&&b.startsWith(M)).map(M=>({relativeBase:b.length>M.length?b.slice(M.length):void 0,mountpoint:M,driver:e.mounts[M]})),s=(b,A)=>{if(e.watching){A=ei(A);for(const M of e.watchListeners)M(b,A)}},a=async()=>{if(!e.watching){e.watching=!0;for(const b in e.mounts)e.unwatch[b]=await B0(e.mounts[b],s,b)}},f=async()=>{if(e.watching){for(const b in e.unwatch)await e.unwatch[b]();e.unwatch={},e.watching=!1}},p=(b,A,M)=>{const C=new Map,O=D=>{let j=C.get(D.base);return j||(j={driver:D.driver,base:D.base,items:[]},C.set(D.base,j)),j};for(const D of b){const j=typeof D=="string",G=ei(j?D:D.key),X=j?void 0:D.value,z=j||!D.options?A:{...A,...D.options},Q=t(G);O(Q).items.push({key:G,value:X,relativeKey:Q.relativeKey,options:z})}return Promise.all([...C.values()].map(D=>M(D))).then(D=>D.flat())},w={hasItem(b,A={}){b=ei(b);const{relativeKey:M,driver:C}=t(b);return mr(C.hasItem,M,A)},getItem(b,A={}){b=ei(b);const{relativeKey:M,driver:C}=t(b);return mr(C.getItem,M,A).then(O=>jc(O))},getItems(b,A){return p(b,A,M=>M.driver.getItems?mr(M.driver.getItems,M.items.map(C=>({key:C.relativeKey,options:C.options})),A).then(C=>C.map(O=>({key:p5(M.base,O.key),value:jc(O.value)}))):Promise.all(M.items.map(C=>mr(M.driver.getItem,C.relativeKey,C.options).then(O=>({key:C.key,value:jc(O)})))))},getItemRaw(b,A={}){b=ei(b);const{relativeKey:M,driver:C}=t(b);return C.getItemRaw?mr(C.getItemRaw,M,A):mr(C.getItem,M,A).then(O=>l5(O))},async setItem(b,A,M={}){if(A===void 0)return w.removeItem(b);b=ei(b);const{relativeKey:C,driver:O}=t(b);O.setItem&&(await mr(O.setItem,C,ef(A),M),O.watch||s("update",b))},async setItems(b,A){await p(b,A,async M=>{if(M.driver.setItems)return mr(M.driver.setItems,M.items.map(C=>({key:C.relativeKey,value:ef(C.value),options:C.options})),A);M.driver.setItem&&await Promise.all(M.items.map(C=>mr(M.driver.setItem,C.relativeKey,ef(C.value),C.options)))})},async setItemRaw(b,A,M={}){if(A===void 0)return w.removeItem(b,M);b=ei(b);const{relativeKey:C,driver:O}=t(b);if(O.setItemRaw)await mr(O.setItemRaw,C,A,M);else if(O.setItem)await mr(O.setItem,C,d5(A),M);else return;O.watch||s("update",b)},async removeItem(b,A={}){typeof A=="boolean"&&(A={removeMeta:A}),b=ei(b);const{relativeKey:M,driver:C}=t(b);C.removeItem&&(await mr(C.removeItem,M,A),(A.removeMeta||A.removeMata)&&await mr(C.removeItem,M+"$",A),C.watch||s("remove",b))},async getMeta(b,A={}){typeof A=="boolean"&&(A={nativeOnly:A}),b=ei(b);const{relativeKey:M,driver:C}=t(b),O=Object.create(null);if(C.getMeta&&Object.assign(O,await mr(C.getMeta,M,A)),!A.nativeOnly){const D=await mr(C.getItem,M+"$",A).then(j=>jc(j));D&&typeof D=="object"&&(typeof D.atime=="string"&&(D.atime=new Date(D.atime)),typeof D.mtime=="string"&&(D.mtime=new Date(D.mtime)),Object.assign(O,D))}return O},setMeta(b,A,M={}){return this.setItem(b+"$",A,M)},removeMeta(b,A={}){return this.removeItem(b+"$",A)},async getKeys(b,A={}){b=Kc(b);const M=i(b,!0);let C=[];const O=[];for(const D of M){const j=await mr(D.driver.getKeys,D.relativeBase,A);for(const G of j){const X=D.mountpoint+ei(G);C.some(z=>X.startsWith(z))||O.push(X)}C=[D.mountpoint,...C.filter(G=>!G.startsWith(D.mountpoint))]}return b?O.filter(D=>D.startsWith(b)&&D[D.length-1]!=="$"):O.filter(D=>D[D.length-1]!=="$")},async clear(b,A={}){b=Kc(b),await Promise.all(i(b,!1).map(async M=>{if(M.driver.clear)return mr(M.driver.clear,M.relativeBase,A);if(M.driver.removeItem){const C=await M.driver.getKeys(M.relativeBase||"",A);return Promise.all(C.map(O=>M.driver.removeItem(O,A)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(b=>L0(b)))},async watch(b){return await a(),e.watchListeners.push(b),async()=>{e.watchListeners=e.watchListeners.filter(A=>A!==b),e.watchListeners.length===0&&await f()}},async unwatch(){e.watchListeners=[],await f()},mount(b,A){if(b=Kc(b),b&&e.mounts[b])throw new Error(`already mounted at ${b}`);return b&&(e.mountpoints.push(b),e.mountpoints.sort((M,C)=>C.length-M.length)),e.mounts[b]=A,e.watching&&Promise.resolve(B0(A,s,b)).then(M=>{e.unwatch[b]=M}).catch(console.error),w},async unmount(b,A=!0){b=Kc(b),!(!b||!e.mounts[b])&&(e.watching&&b in e.unwatch&&(e.unwatch[b](),delete e.unwatch[b]),A&&await L0(e.mounts[b]),e.mountpoints=e.mountpoints.filter(M=>M!==b),delete e.mounts[b])},getMount(b=""){b=ei(b)+":";const A=t(b);return{driver:A.driver,base:A.base}},getMounts(b="",A={}){return b=ei(b),i(b,A.parents).map(C=>({driver:C.driver,base:C.mountpoint}))},keys:(b,A={})=>w.getKeys(b,A),get:(b,A={})=>w.getItem(b,A),set:(b,A,M={})=>w.setItem(b,A,M),has:(b,A={})=>w.hasItem(b,A),del:(b,A={})=>w.removeItem(b,A),remove:(b,A={})=>w.removeItem(b,A)};return w}function B0(r,e,t){return r.watch?r.watch((i,s)=>e(i,t+s)):()=>{}}async function L0(r){typeof r.dispose=="function"&&await mr(r.dispose)}function Ks(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function rg(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=Ks(t);return(s,a)=>i.then(f=>a(f.transaction(e,s).objectStore(e)))}let ru;function Co(){return ru||(ru=rg("keyval-store","keyval")),ru}function k0(r,e=Co()){return e("readonly",t=>Ks(t.get(r)))}function m5(r,e,t=Co()){return t("readwrite",i=>(i.put(e,r),Ks(i.transaction)))}function y5(r,e=Co()){return e("readwrite",t=>(t.delete(r),Ks(t.transaction)))}function w5(r=Co()){return r("readwrite",e=>(e.clear(),Ks(e.transaction)))}function _5(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ks(r.transaction)}function A5(r=Co()){return r("readonly",e=>{if(e.getAllKeys)return Ks(e.getAllKeys());const t=[];return _5(e,i=>t.push(i.key)).then(()=>t)})}const E5=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),I5=r=>{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,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function zs(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return I5(r)}catch{return r}}function Jn(r){return typeof r=="string"?r:E5(r)||""}const M5="idb-keyval";var S5=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=s=>e+s;let i;return r.dbName&&r.storeName&&(i=rg(r.dbName,r.storeName)),{name:M5,options:r,async hasItem(s){return!(typeof await k0(t(s),i)>"u")},async getItem(s){return await k0(t(s),i)??null},setItem(s,a){return m5(t(s),a,i)},removeItem(s){return y5(t(s),i)},getKeys(){return A5(i)},clear(){return w5(i)}}};const x5="WALLET_CONNECT_V2_INDEXED_DB",P5="keyvaluestorage";let R5=class{constructor(){this.indexedDb=b5({driver:S5({dbName:x5,storeName:P5})})}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 t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Jn(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var iu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},tf={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof iu<"u"&&iu.localStorage?tf.exports=iu.localStorage:typeof window<"u"&&window.localStorage?tf.exports=window.localStorage:tf.exports=new e})();function N5(r){var e;return[r[0],zs((e=r[1])!=null?e:"")]}let C5=class{constructor(){this.localStorage=tf.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(N5)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return zs(t)}async setItem(e,t){this.localStorage.setItem(e,Jn(t))}async removeItem(e){this.localStorage.removeItem(e)}};const O5="wc_storage_version",$0=1,T5=async(r,e,t)=>{const i=O5,s=await e.getItem(i);if(s&&s>=$0){t(e);return}const a=await r.getKeys();if(!a.length){t(e);return}const f=[];for(;a.length;){const p=a.shift();if(!p)continue;const w=p.toLowerCase();if(w.includes("wc@")||w.includes("walletconnect")||w.includes("wc_")||w.includes("wallet_connect")){const b=await r.getItem(p);await e.setItem(p,b),f.push(p)}}await e.setItem(i,$0),t(e),D5(r,f)},D5=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};let F5=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new C5;this.storage=e;try{const t=new R5;T5(e,t,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,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};class Hs{}let q5=class extends Hs{constructor(e){super()}};const z0=me.FIVE_SECONDS,Sa={pulse:"heartbeat_pulse"};let B5=class ig extends q5{constructor(e){super(e),this.events=new Bi.EventEmitter,this.interval=z0,this.interval=(e==null?void 0:e.interval)||z0}static async init(e){const t=new ig(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),me.toMiliseconds(this.interval))}pulse(){this.events.emit(Sa.pulse)}};const L5={level:"info"},Oo="custom_context",sd=1e3*1024;let k5=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},U0=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new k5(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}},ng=class{constructor(e,t=sd){this.level=e??"error",this.levelValue=io.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new U0(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===io.levels.values.error?console.error(e):t===io.levels.values.warn?console.warn(e):t===io.levels.values.debug?console.debug(e):t===io.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Jn({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new U0(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(Jn({extraMetadata:e})),new Blob(t,{type:"application/json"})}},$5=class{constructor(e,t=sd){this.baseChunkLogger=new ng(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}};class z5{constructor(e,t=sd){this.baseChunkLogger=new ng(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var U5=Object.defineProperty,j5=Object.defineProperties,K5=Object.getOwnPropertyDescriptors,j0=Object.getOwnPropertySymbols,H5=Object.prototype.hasOwnProperty,V5=Object.prototype.propertyIsEnumerable,K0=(r,e,t)=>e in r?U5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,uf=(r,e)=>{for(var t in e||(e={}))H5.call(e,t)&&K0(r,t,e[t]);if(j0)for(var t of j0(e))V5.call(e,t)&&K0(r,t,e[t]);return r},df=(r,e)=>j5(r,K5(e));function Pf(r){return df(uf({},r),{level:(r==null?void 0:r.level)||L5.level})}function G5(r,e=Oo){return r[e]||""}function J5(r,e,t=Oo){return r[t]=e,r}function oi(r,e=Oo){let t="";return typeof r.bindings>"u"?t=G5(r,e):t=r.bindings().context||"",t}function W5(r,e,t=Oo){const i=oi(r,t);return i.trim()?`${i}/${e}`:e}function Kr(r,e,t=Oo){const i=W5(r,e,t),s=r.child({context:i});return J5(s,i,t)}function Q5(r){var e,t;const i=new $5((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:No(df(uf({},r.opts),{level:"trace",browser:df(uf({},(t=r.opts)==null?void 0:t.browser),{write:s=>i.write(s)})})),chunkLoggerController:i}}function Y5(r){var e;const t=new z5((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:No(df(uf({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function X5(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Q5(r):Y5(r)}var ad={},sg={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=kw,t=J1;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function p(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.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 p.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},p.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},p.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._tempHi),t.wipe(this._tempLo),this.reset()},p.prototype.update=function(w,b){if(b===void 0&&(b=w.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var A=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&b>0;)this._buffer[this._bufferLength++]=w[A++],b--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(A=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,w,A,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=w[A++],b--;return this},p.prototype.finish=function(w){if(!this._finished){var b=this._bytesHashed,A=this._bufferLength,M=b/536870912|0,C=b<<3,O=b%128<112?128:256;this._buffer[A]=128;for(var D=A+1;D<O-8;D++)this._buffer[D]=0;e.writeUint32BE(M,this._buffer,O-8),e.writeUint32BE(C,this._buffer,O-4),a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,O),this._finished=!0}for(var D=0;D<this.digestLength/8;D++)e.writeUint32BE(this._stateHi[D],w,D*8),e.writeUint32BE(this._stateLo[D],w,D*8+4);return this},p.prototype.digest=function(){var w=new Uint8Array(this.digestLength);return this.finish(w),w},p.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}},p.prototype.restoreState=function(w){return this._stateHi.set(w.stateHi),this._stateLo.set(w.stateLo),this._bufferLength=w.bufferLength,w.buffer&&this._buffer.set(w.buffer),this._bytesHashed=w.bytesHashed,this._finished=!1,this},p.prototype.cleanSavedState=function(w){t.wipe(w.stateHi),t.wipe(w.stateLo),w.buffer&&t.wipe(w.buffer),w.bufferLength=0,w.bytesHashed=0},p}();r.SHA512=i;var s=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 a(p,w,b,A,M,C,O){for(var D=b[0],j=b[1],G=b[2],X=b[3],z=b[4],Q=b[5],V=b[6],H=b[7],ee=A[0],oe=A[1],ne=A[2],ge=A[3],ht=A[4],L=A[5],v=A[6],c=A[7],d,g,_,S,x,E,u,l;O>=128;){for(var R=0;R<16;R++){var ie=8*R+C;p[R]=e.readUint32BE(M,ie),w[R]=e.readUint32BE(M,ie+4)}for(var R=0;R<80;R++){var se=D,I=j,Z=G,F=X,k=z,$=Q,m=V,B=H,re=ee,he=oe,ue=ne,ve=ge,be=ht,Te=L,nt=v,Se=c;if(d=H,g=c,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=(z>>>14|ht<<18)^(z>>>18|ht<<14)^(ht>>>9|z<<23),g=(ht>>>14|z<<18)^(ht>>>18|z<<14)^(z>>>9|ht<<23),x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,d=z&Q^~z&V,g=ht&L^~ht&v,x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,d=s[R*2],g=s[R*2+1],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,d=p[R%16],g=w[R%16],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,_=u&65535|l<<16,S=x&65535|E<<16,d=_,g=S,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=(D>>>28|ee<<4)^(ee>>>2|D<<30)^(ee>>>7|D<<25),g=(ee>>>28|D<<4)^(D>>>2|ee<<30)^(D>>>7|ee<<25),x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,d=D&j^D&G^j&G,g=ee&oe^ee&ne^oe&ne,x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,B=u&65535|l<<16,Se=x&65535|E<<16,d=F,g=ve,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=_,g=S,x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,F=u&65535|l<<16,ve=x&65535|E<<16,j=se,G=I,X=Z,z=F,Q=k,V=$,H=m,D=B,oe=re,ne=he,ge=ue,ht=ve,L=be,v=Te,c=nt,ee=Se,R%16===15)for(var ie=0;ie<16;ie++)d=p[ie],g=w[ie],x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=p[(ie+9)%16],g=w[(ie+9)%16],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,_=p[(ie+1)%16],S=w[(ie+1)%16],d=(_>>>1|S<<31)^(_>>>8|S<<24)^_>>>7,g=(S>>>1|_<<31)^(S>>>8|_<<24)^(S>>>7|_<<25),x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,_=p[(ie+14)%16],S=w[(ie+14)%16],d=(_>>>19|S<<13)^(S>>>29|_<<3)^_>>>6,g=(S>>>19|_<<13)^(_>>>29|S<<3)^(S>>>6|_<<26),x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,p[ie]=u&65535|l<<16,w[ie]=x&65535|E<<16}d=D,g=ee,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[0],g=A[0],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[0]=D=u&65535|l<<16,A[0]=ee=x&65535|E<<16,d=j,g=oe,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[1],g=A[1],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[1]=j=u&65535|l<<16,A[1]=oe=x&65535|E<<16,d=G,g=ne,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[2],g=A[2],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[2]=G=u&65535|l<<16,A[2]=ne=x&65535|E<<16,d=X,g=ge,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[3],g=A[3],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[3]=X=u&65535|l<<16,A[3]=ge=x&65535|E<<16,d=z,g=ht,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[4],g=A[4],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[4]=z=u&65535|l<<16,A[4]=ht=x&65535|E<<16,d=Q,g=L,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[5],g=A[5],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[5]=Q=u&65535|l<<16,A[5]=L=x&65535|E<<16,d=V,g=v,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[6],g=A[6],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[6]=V=u&65535|l<<16,A[6]=v=x&65535|E<<16,d=H,g=c,x=g&65535,E=g>>>16,u=d&65535,l=d>>>16,d=b[7],g=A[7],x+=g&65535,E+=g>>>16,u+=d&65535,l+=d>>>16,E+=x>>>16,u+=E>>>16,l+=u>>>16,b[7]=H=u&65535|l<<16,A[7]=c=x&65535|E<<16,C+=128,O-=128}return C}function f(p){var w=new i;w.update(p);var b=w.digest();return w.clean(),b}r.hash=f})(sg);(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=Ma,t=sg,i=J1;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function s(F){const k=new Float64Array(16);if(F)for(let $=0;$<F.length;$++)k[$]=F[$];return k}const a=new Uint8Array(32);a[0]=9;const f=s(),p=s([1]),w=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),A=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),M=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function O(F,k){for(let $=0;$<16;$++)F[$]=k[$]|0}function D(F){let k=1;for(let $=0;$<16;$++){let m=F[$]+k+65535;k=Math.floor(m/65536),F[$]=m-k*65536}F[0]+=k-1+37*(k-1)}function j(F,k,$){const m=~($-1);for(let B=0;B<16;B++){const re=m&(F[B]^k[B]);F[B]^=re,k[B]^=re}}function G(F,k){const $=s(),m=s();for(let B=0;B<16;B++)m[B]=k[B];D(m),D(m),D(m);for(let B=0;B<2;B++){$[0]=m[0]-65517;for(let he=1;he<15;he++)$[he]=m[he]-65535-($[he-1]>>16&1),$[he-1]&=65535;$[15]=m[15]-32767-($[14]>>16&1);const re=$[15]>>16&1;$[14]&=65535,j(m,$,1-re)}for(let B=0;B<16;B++)F[2*B]=m[B]&255,F[2*B+1]=m[B]>>8}function X(F,k){let $=0;for(let m=0;m<32;m++)$|=F[m]^k[m];return(1&$-1>>>8)-1}function z(F,k){const $=new Uint8Array(32),m=new Uint8Array(32);return G($,F),G(m,k),X($,m)}function Q(F){const k=new Uint8Array(32);return G(k,F),k[0]&1}function V(F,k){for(let $=0;$<16;$++)F[$]=k[2*$]+(k[2*$+1]<<8);F[15]&=32767}function H(F,k,$){for(let m=0;m<16;m++)F[m]=k[m]+$[m]}function ee(F,k,$){for(let m=0;m<16;m++)F[m]=k[m]-$[m]}function oe(F,k,$){let m,B,re=0,he=0,ue=0,ve=0,be=0,Te=0,nt=0,Se=0,Ve=0,Le=0,Ae=0,Ue=0,Ge=0,ye=0,je=0,Fe=0,_e=0,We=0,ke=0,Pe=0,ot=0,ft=0,De=0,ct=0,ut=0,qe=0,wt=0,dt=0,$e=0,At=0,Mt=0,Ee=$[0],Ke=$[1],Qe=$[2],Ie=$[3],Je=$[4],He=$[5],Re=$[6],st=$[7],Ye=$[8],Ne=$[9],Xe=$[10],et=$[11],Me=$[12],ze=$[13],at=$[14],Ce=$[15];m=k[0],re+=m*Ee,he+=m*Ke,ue+=m*Qe,ve+=m*Ie,be+=m*Je,Te+=m*He,nt+=m*Re,Se+=m*st,Ve+=m*Ye,Le+=m*Ne,Ae+=m*Xe,Ue+=m*et,Ge+=m*Me,ye+=m*ze,je+=m*at,Fe+=m*Ce,m=k[1],he+=m*Ee,ue+=m*Ke,ve+=m*Qe,be+=m*Ie,Te+=m*Je,nt+=m*He,Se+=m*Re,Ve+=m*st,Le+=m*Ye,Ae+=m*Ne,Ue+=m*Xe,Ge+=m*et,ye+=m*Me,je+=m*ze,Fe+=m*at,_e+=m*Ce,m=k[2],ue+=m*Ee,ve+=m*Ke,be+=m*Qe,Te+=m*Ie,nt+=m*Je,Se+=m*He,Ve+=m*Re,Le+=m*st,Ae+=m*Ye,Ue+=m*Ne,Ge+=m*Xe,ye+=m*et,je+=m*Me,Fe+=m*ze,_e+=m*at,We+=m*Ce,m=k[3],ve+=m*Ee,be+=m*Ke,Te+=m*Qe,nt+=m*Ie,Se+=m*Je,Ve+=m*He,Le+=m*Re,Ae+=m*st,Ue+=m*Ye,Ge+=m*Ne,ye+=m*Xe,je+=m*et,Fe+=m*Me,_e+=m*ze,We+=m*at,ke+=m*Ce,m=k[4],be+=m*Ee,Te+=m*Ke,nt+=m*Qe,Se+=m*Ie,Ve+=m*Je,Le+=m*He,Ae+=m*Re,Ue+=m*st,Ge+=m*Ye,ye+=m*Ne,je+=m*Xe,Fe+=m*et,_e+=m*Me,We+=m*ze,ke+=m*at,Pe+=m*Ce,m=k[5],Te+=m*Ee,nt+=m*Ke,Se+=m*Qe,Ve+=m*Ie,Le+=m*Je,Ae+=m*He,Ue+=m*Re,Ge+=m*st,ye+=m*Ye,je+=m*Ne,Fe+=m*Xe,_e+=m*et,We+=m*Me,ke+=m*ze,Pe+=m*at,ot+=m*Ce,m=k[6],nt+=m*Ee,Se+=m*Ke,Ve+=m*Qe,Le+=m*Ie,Ae+=m*Je,Ue+=m*He,Ge+=m*Re,ye+=m*st,je+=m*Ye,Fe+=m*Ne,_e+=m*Xe,We+=m*et,ke+=m*Me,Pe+=m*ze,ot+=m*at,ft+=m*Ce,m=k[7],Se+=m*Ee,Ve+=m*Ke,Le+=m*Qe,Ae+=m*Ie,Ue+=m*Je,Ge+=m*He,ye+=m*Re,je+=m*st,Fe+=m*Ye,_e+=m*Ne,We+=m*Xe,ke+=m*et,Pe+=m*Me,ot+=m*ze,ft+=m*at,De+=m*Ce,m=k[8],Ve+=m*Ee,Le+=m*Ke,Ae+=m*Qe,Ue+=m*Ie,Ge+=m*Je,ye+=m*He,je+=m*Re,Fe+=m*st,_e+=m*Ye,We+=m*Ne,ke+=m*Xe,Pe+=m*et,ot+=m*Me,ft+=m*ze,De+=m*at,ct+=m*Ce,m=k[9],Le+=m*Ee,Ae+=m*Ke,Ue+=m*Qe,Ge+=m*Ie,ye+=m*Je,je+=m*He,Fe+=m*Re,_e+=m*st,We+=m*Ye,ke+=m*Ne,Pe+=m*Xe,ot+=m*et,ft+=m*Me,De+=m*ze,ct+=m*at,ut+=m*Ce,m=k[10],Ae+=m*Ee,Ue+=m*Ke,Ge+=m*Qe,ye+=m*Ie,je+=m*Je,Fe+=m*He,_e+=m*Re,We+=m*st,ke+=m*Ye,Pe+=m*Ne,ot+=m*Xe,ft+=m*et,De+=m*Me,ct+=m*ze,ut+=m*at,qe+=m*Ce,m=k[11],Ue+=m*Ee,Ge+=m*Ke,ye+=m*Qe,je+=m*Ie,Fe+=m*Je,_e+=m*He,We+=m*Re,ke+=m*st,Pe+=m*Ye,ot+=m*Ne,ft+=m*Xe,De+=m*et,ct+=m*Me,ut+=m*ze,qe+=m*at,wt+=m*Ce,m=k[12],Ge+=m*Ee,ye+=m*Ke,je+=m*Qe,Fe+=m*Ie,_e+=m*Je,We+=m*He,ke+=m*Re,Pe+=m*st,ot+=m*Ye,ft+=m*Ne,De+=m*Xe,ct+=m*et,ut+=m*Me,qe+=m*ze,wt+=m*at,dt+=m*Ce,m=k[13],ye+=m*Ee,je+=m*Ke,Fe+=m*Qe,_e+=m*Ie,We+=m*Je,ke+=m*He,Pe+=m*Re,ot+=m*st,ft+=m*Ye,De+=m*Ne,ct+=m*Xe,ut+=m*et,qe+=m*Me,wt+=m*ze,dt+=m*at,$e+=m*Ce,m=k[14],je+=m*Ee,Fe+=m*Ke,_e+=m*Qe,We+=m*Ie,ke+=m*Je,Pe+=m*He,ot+=m*Re,ft+=m*st,De+=m*Ye,ct+=m*Ne,ut+=m*Xe,qe+=m*et,wt+=m*Me,dt+=m*ze,$e+=m*at,At+=m*Ce,m=k[15],Fe+=m*Ee,_e+=m*Ke,We+=m*Qe,ke+=m*Ie,Pe+=m*Je,ot+=m*He,ft+=m*Re,De+=m*st,ct+=m*Ye,ut+=m*Ne,qe+=m*Xe,wt+=m*et,dt+=m*Me,$e+=m*ze,At+=m*at,Mt+=m*Ce,re+=38*_e,he+=38*We,ue+=38*ke,ve+=38*Pe,be+=38*ot,Te+=38*ft,nt+=38*De,Se+=38*ct,Ve+=38*ut,Le+=38*qe,Ae+=38*wt,Ue+=38*dt,Ge+=38*$e,ye+=38*At,je+=38*Mt,B=1,m=re+B+65535,B=Math.floor(m/65536),re=m-B*65536,m=he+B+65535,B=Math.floor(m/65536),he=m-B*65536,m=ue+B+65535,B=Math.floor(m/65536),ue=m-B*65536,m=ve+B+65535,B=Math.floor(m/65536),ve=m-B*65536,m=be+B+65535,B=Math.floor(m/65536),be=m-B*65536,m=Te+B+65535,B=Math.floor(m/65536),Te=m-B*65536,m=nt+B+65535,B=Math.floor(m/65536),nt=m-B*65536,m=Se+B+65535,B=Math.floor(m/65536),Se=m-B*65536,m=Ve+B+65535,B=Math.floor(m/65536),Ve=m-B*65536,m=Le+B+65535,B=Math.floor(m/65536),Le=m-B*65536,m=Ae+B+65535,B=Math.floor(m/65536),Ae=m-B*65536,m=Ue+B+65535,B=Math.floor(m/65536),Ue=m-B*65536,m=Ge+B+65535,B=Math.floor(m/65536),Ge=m-B*65536,m=ye+B+65535,B=Math.floor(m/65536),ye=m-B*65536,m=je+B+65535,B=Math.floor(m/65536),je=m-B*65536,m=Fe+B+65535,B=Math.floor(m/65536),Fe=m-B*65536,re+=B-1+37*(B-1),B=1,m=re+B+65535,B=Math.floor(m/65536),re=m-B*65536,m=he+B+65535,B=Math.floor(m/65536),he=m-B*65536,m=ue+B+65535,B=Math.floor(m/65536),ue=m-B*65536,m=ve+B+65535,B=Math.floor(m/65536),ve=m-B*65536,m=be+B+65535,B=Math.floor(m/65536),be=m-B*65536,m=Te+B+65535,B=Math.floor(m/65536),Te=m-B*65536,m=nt+B+65535,B=Math.floor(m/65536),nt=m-B*65536,m=Se+B+65535,B=Math.floor(m/65536),Se=m-B*65536,m=Ve+B+65535,B=Math.floor(m/65536),Ve=m-B*65536,m=Le+B+65535,B=Math.floor(m/65536),Le=m-B*65536,m=Ae+B+65535,B=Math.floor(m/65536),Ae=m-B*65536,m=Ue+B+65535,B=Math.floor(m/65536),Ue=m-B*65536,m=Ge+B+65535,B=Math.floor(m/65536),Ge=m-B*65536,m=ye+B+65535,B=Math.floor(m/65536),ye=m-B*65536,m=je+B+65535,B=Math.floor(m/65536),je=m-B*65536,m=Fe+B+65535,B=Math.floor(m/65536),Fe=m-B*65536,re+=B-1+37*(B-1),F[0]=re,F[1]=he,F[2]=ue,F[3]=ve,F[4]=be,F[5]=Te,F[6]=nt,F[7]=Se,F[8]=Ve,F[9]=Le,F[10]=Ae,F[11]=Ue,F[12]=Ge,F[13]=ye,F[14]=je,F[15]=Fe}function ne(F,k){oe(F,k,k)}function ge(F,k){const $=s();let m;for(m=0;m<16;m++)$[m]=k[m];for(m=253;m>=0;m--)ne($,$),m!==2&&m!==4&&oe($,$,k);for(m=0;m<16;m++)F[m]=$[m]}function ht(F,k){const $=s();let m;for(m=0;m<16;m++)$[m]=k[m];for(m=250;m>=0;m--)ne($,$),m!==1&&oe($,$,k);for(m=0;m<16;m++)F[m]=$[m]}function L(F,k){const $=s(),m=s(),B=s(),re=s(),he=s(),ue=s(),ve=s(),be=s(),Te=s();ee($,F[1],F[0]),ee(Te,k[1],k[0]),oe($,$,Te),H(m,F[0],F[1]),H(Te,k[0],k[1]),oe(m,m,Te),oe(B,F[3],k[3]),oe(B,B,b),oe(re,F[2],k[2]),H(re,re,re),ee(he,m,$),ee(ue,re,B),H(ve,re,B),H(be,m,$),oe(F[0],he,ue),oe(F[1],be,ve),oe(F[2],ve,ue),oe(F[3],he,be)}function v(F,k,$){for(let m=0;m<4;m++)j(F[m],k[m],$)}function c(F,k){const $=s(),m=s(),B=s();ge(B,k[2]),oe($,k[0],B),oe(m,k[1],B),G(F,m),F[31]^=Q($)<<7}function d(F,k,$){O(F[0],f),O(F[1],p),O(F[2],p),O(F[3],f);for(let m=255;m>=0;--m){const B=$[m/8|0]>>(m&7)&1;v(F,k,B),L(k,F),L(F,F),v(F,k,B)}}function g(F,k){const $=[s(),s(),s(),s()];O($[0],A),O($[1],M),O($[2],p),oe($[3],A,M),d(F,$,k)}function _(F){if(F.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const k=(0,t.hash)(F);k[0]&=248,k[31]&=127,k[31]|=64;const $=new Uint8Array(32),m=[s(),s(),s(),s()];g(m,k),c($,m);const B=new Uint8Array(64);return B.set(F),B.set($,32),{publicKey:$,secretKey:B}}r.generateKeyPairFromSeed=_;function S(F){const k=(0,e.randomBytes)(32,F),$=_(k);return(0,i.wipe)(k),$}r.generateKeyPair=S;function x(F){if(F.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(F.subarray(32))}r.extractPublicKeyFromSecretKey=x;const E=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 u(F,k){let $,m,B,re;for(m=63;m>=32;--m){for($=0,B=m-32,re=m-12;B<re;++B)k[B]+=$-16*k[m]*E[B-(m-32)],$=Math.floor((k[B]+128)/256),k[B]-=$*256;k[B]+=$,k[m]=0}for($=0,B=0;B<32;B++)k[B]+=$-(k[31]>>4)*E[B],$=k[B]>>8,k[B]&=255;for(B=0;B<32;B++)k[B]-=$*E[B];for(m=0;m<32;m++)k[m+1]+=k[m]>>8,F[m]=k[m]&255}function l(F){const k=new Float64Array(64);for(let $=0;$<64;$++)k[$]=F[$];for(let $=0;$<64;$++)F[$]=0;u(F,k)}function R(F,k){const $=new Float64Array(64),m=[s(),s(),s(),s()],B=(0,t.hash)(F.subarray(0,32));B[0]&=248,B[31]&=127,B[31]|=64;const re=new Uint8Array(64);re.set(B.subarray(32),32);const he=new t.SHA512;he.update(re.subarray(32)),he.update(k);const ue=he.digest();he.clean(),l(ue),g(m,ue),c(re,m),he.reset(),he.update(re.subarray(0,32)),he.update(F.subarray(32)),he.update(k);const ve=he.digest();l(ve);for(let be=0;be<32;be++)$[be]=ue[be];for(let be=0;be<32;be++)for(let Te=0;Te<32;Te++)$[be+Te]+=ve[be]*B[Te];return u(re.subarray(32),$),re}r.sign=R;function ie(F,k){const $=s(),m=s(),B=s(),re=s(),he=s(),ue=s(),ve=s();return O(F[2],p),V(F[1],k),ne(B,F[1]),oe(re,B,w),ee(B,B,F[2]),H(re,F[2],re),ne(he,re),ne(ue,he),oe(ve,ue,he),oe($,ve,B),oe($,$,re),ht($,$),oe($,$,B),oe($,$,re),oe($,$,re),oe(F[0],$,re),ne(m,F[0]),oe(m,m,re),z(m,B)&&oe(F[0],F[0],C),ne(m,F[0]),oe(m,m,re),z(m,B)?-1:(Q(F[0])===k[31]>>7&&ee(F[0],f,F[0]),oe(F[3],F[0],F[1]),0)}function se(F,k,$){const m=new Uint8Array(32),B=[s(),s(),s(),s()],re=[s(),s(),s(),s()];if($.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(ie(re,F))return!1;const he=new t.SHA512;he.update($.subarray(0,32)),he.update(F),he.update(k);const ue=he.digest();return l(ue),d(B,re,ue),g(re,$.subarray(32)),L(B,re),c(m,B),!X($,m)}r.verify=se;function I(F){let k=[s(),s(),s(),s()];if(ie(k,F))throw new Error("Ed25519: invalid public key");let $=s(),m=s(),B=k[1];H($,p,B),ee(m,p,B),ge(m,m),oe($,$,m);let re=new Uint8Array(32);return G(re,$),re}r.convertPublicKeyToX25519=I;function Z(F){const k=(0,t.hash)(F.subarray(0,32));k[0]&=248,k[31]&=127,k[31]|=64;const $=new Uint8Array(k.subarray(0,32));return(0,i.wipe)(k),$}r.convertSecretKeyToX25519=Z})(ad);const Z5="EdDSA",e4="JWT",lf=".",Rf="base64url",ag="utf8",og="utf8",t4=":",r4="did",i4="key",H0="base58btc",n4="z",s4="K36",a4=32;function od(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function cg(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?od(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function o4(r,e){e||(e=r.reduce((s,a)=>s+a.length,0));const t=cg(e);let i=0;for(const s of r)t.set(s,i),i+=s.length;return od(t)}function fg(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const V0=fg("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),nu=fg("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=cg(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),hg={utf8:V0,"utf-8":V0,hex:hf.base16,latin1:nu,ascii:nu,binary:nu,...hf};function Nf(r,e="utf8"){const t=hg[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function xa(r,e="utf8"){const t=hg[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?od(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function G0(r){return zs(Nf(xa(r,Rf),ag))}function pf(r){return Nf(xa(Jn(r),ag),Rf)}function ug(r){const e=xa(s4,H0),t=n4+Nf(o4([e,r]),H0);return[r4,i4,t].join(t4)}function c4(r){return Nf(r,Rf)}function f4(r){return xa(r,Rf)}function h4(r){return xa([pf(r.header),pf(r.payload)].join(lf),og)}function u4(r){return[pf(r.header),pf(r.payload),c4(r.signature)].join(lf)}function Lu(r){const e=r.split(lf),t=G0(e[0]),i=G0(e[1]),s=f4(e[2]),a=xa(e.slice(0,2).join(lf),og);return{header:t,payload:i,signature:s,data:a}}function J0(r=Ma.randomBytes(a4)){return ad.generateKeyPairFromSeed(r)}async function d4(r,e,t,i,s=me.fromMiliseconds(Date.now())){const a={alg:Z5,typ:e4},f=ug(i.publicKey),p=s+t,w={iss:f,sub:r,aud:e,iat:s,exp:p},b=h4({header:a,payload:w}),A=ad.sign(i.secretKey,b);return u4({header:a,payload:w,signature:A})}const l4="PARSE_ERROR",p4="INVALID_REQUEST",g4="METHOD_NOT_FOUND",v4="INVALID_PARAMS",dg="INTERNAL_ERROR",cd="SERVER_ERROR",b4=[-32700,-32600,-32601,-32602,-32603],yo={[l4]:{code:-32700,message:"Parse error"},[p4]:{code:-32600,message:"Invalid Request"},[g4]:{code:-32601,message:"Method not found"},[v4]:{code:-32602,message:"Invalid params"},[dg]:{code:-32603,message:"Internal error"},[cd]:{code:-32e3,message:"Server error"}},lg=cd;function m4(r){return b4.includes(r)}function W0(r){return Object.keys(yo).includes(r)?yo[r]:yo[lg]}function y4(r){const e=Object.values(yo).find(t=>t.code===r);return e||yo[lg]}function pg(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}function os(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function qs(r=6){return BigInt(os(r))}function ds(r,e,t){return{id:t||os(),jsonrpc:"2.0",method:r,params:e}}function Cf(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Of(r,e,t){return{id:r,jsonrpc:"2.0",error:w4(e)}}function w4(r,e){return typeof r>"u"?W0(dg):(typeof r=="string"&&(r=Object.assign(Object.assign({},W0(cd)),{message:r})),m4(r.code)&&(r=y4(r.code)),r)}class _4{}let A4=class extends _4{constructor(){super()}},E4=class extends A4{constructor(e){super()}};const I4="^https?:",M4="^wss?:";function S4(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function gg(r,e){const t=S4(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function Q0(r){return gg(r,I4)}function Y0(r){return gg(r,M4)}function x4(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function vg(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function fd(r){return vg(r)&&"method"in r}function Tf(r){return vg(r)&&(gn(r)||Ti(r))}function gn(r){return"result"in r}function Ti(r){return"error"in r}class an extends E4{constructor(e){super(e),this.events=new Bi.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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(ds(e.method,e.params||[],e.id||qs().toString()),t)}async requestStrict(e,t){return new Promise(async(i,s)=>{if(!this.connection.connected)try{await this.open()}catch(a){s(a)}this.events.on(`${e.id}`,a=>{Ti(a)?s(a.error):i(a.result)});try{await this.connection.send(e,t)}catch(a){s(a)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Tf(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}var su,X0;function P4(){return X0||(X0=1,su=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),su}const R4=()=>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:P4(),N4=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Z0=r=>r.split("?")[0],ep=10,C4=R4();let O4=class{constructor(e){if(this.url=e,this.events=new Bi.EventEmitter,this.registering=!1,!Y0(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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(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(Jn(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Y0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const s=new URLSearchParams(e).get("origin"),a=Sw.isReactNative()?{headers:{origin:s}}:{rejectUnauthorized:!x4(e)},f=new C4(e,[],a);N4()?f.onerror=p=>{const w=p;i(this.emitError(w.error))}:f.on("error",p=>{i(this.emitError(p))}),f.onopen=()=>{this.onOpen(f),t(f)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),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 t=typeof e.data=="string"?zs(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),s=i.message||i.toString(),a=Of(e,s);this.events.emit("payload",a)}parseError(e,t=this.url){return pg(e,Z0(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>ep&&this.events.setMaxListeners(ep)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${Z0(this.url)}`));return this.events.emit("register_error",t),t}};var gf={exports:{}};gf.exports;(function(r,e){var t=200,i="__lodash_hash_undefined__",s=1,a=2,f=9007199254740991,p="[object Arguments]",w="[object Array]",b="[object AsyncFunction]",A="[object Boolean]",M="[object Date]",C="[object Error]",O="[object Function]",D="[object GeneratorFunction]",j="[object Map]",G="[object Number]",X="[object Null]",z="[object Object]",Q="[object Promise]",V="[object Proxy]",H="[object RegExp]",ee="[object Set]",oe="[object String]",ne="[object Symbol]",ge="[object Undefined]",ht="[object WeakMap]",L="[object ArrayBuffer]",v="[object DataView]",c="[object Float32Array]",d="[object Float64Array]",g="[object Int8Array]",_="[object Int16Array]",S="[object Int32Array]",x="[object Uint8Array]",E="[object Uint8ClampedArray]",u="[object Uint16Array]",l="[object Uint32Array]",R=/[\\^$.*+?()[\]{}|]/g,ie=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,I={};I[c]=I[d]=I[g]=I[_]=I[S]=I[x]=I[E]=I[u]=I[l]=!0,I[p]=I[w]=I[L]=I[A]=I[v]=I[M]=I[C]=I[O]=I[j]=I[G]=I[z]=I[H]=I[ee]=I[oe]=I[ht]=!1;var Z=typeof go=="object"&&go&&go.Object===Object&&go,F=typeof self=="object"&&self&&self.Object===Object&&self,k=Z||F||Function("return this")(),$=e&&!e.nodeType&&e,m=$&&!0&&r&&!r.nodeType&&r,B=m&&m.exports===$,re=B&&Z.process,he=function(){try{return re&&re.binding&&re.binding("util")}catch{}}(),ue=he&&he.isTypedArray;function ve(q,J){for(var de=-1,xe=q==null?0:q.length,$t=0,pt=[];++de<xe;){var Vt=q[de];J(Vt,de,q)&&(pt[$t++]=Vt)}return pt}function be(q,J){for(var de=-1,xe=J.length,$t=q.length;++de<xe;)q[$t+de]=J[de];return q}function Te(q,J){for(var de=-1,xe=q==null?0:q.length;++de<xe;)if(J(q[de],de,q))return!0;return!1}function nt(q,J){for(var de=-1,xe=Array(q);++de<q;)xe[de]=J(de);return xe}function Se(q){return function(J){return q(J)}}function Ve(q,J){return q.has(J)}function Le(q,J){return q==null?void 0:q[J]}function Ae(q){var J=-1,de=Array(q.size);return q.forEach(function(xe,$t){de[++J]=[$t,xe]}),de}function Ue(q,J){return function(de){return q(J(de))}}function Ge(q){var J=-1,de=Array(q.size);return q.forEach(function(xe){de[++J]=xe}),de}var ye=Array.prototype,je=Function.prototype,Fe=Object.prototype,_e=k["__core-js_shared__"],We=je.toString,ke=Fe.hasOwnProperty,Pe=function(){var q=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||"");return q?"Symbol(src)_1."+q:""}(),ot=Fe.toString,ft=RegExp("^"+We.call(ke).replace(R,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=B?k.Buffer:void 0,ct=k.Symbol,ut=k.Uint8Array,qe=Fe.propertyIsEnumerable,wt=ye.splice,dt=ct?ct.toStringTag:void 0,$e=Object.getOwnPropertySymbols,At=De?De.isBuffer:void 0,Mt=Ue(Object.keys,Object),Ee=ci(k,"DataView"),Ke=ci(k,"Map"),Qe=ci(k,"Promise"),Ie=ci(k,"Set"),Je=ci(k,"WeakMap"),He=ci(Object,"create"),Re=Nn(Ee),st=Nn(Ke),Ye=Nn(Qe),Ne=Nn(Ie),Xe=Nn(Je),et=ct?ct.prototype:void 0,Me=et?et.valueOf:void 0;function ze(q){var J=-1,de=q==null?0:q.length;for(this.clear();++J<de;){var xe=q[J];this.set(xe[0],xe[1])}}function at(){this.__data__=He?He(null):{},this.size=0}function Ce(q){var J=this.has(q)&&delete this.__data__[q];return this.size-=J?1:0,J}function Ct(q){var J=this.__data__;if(He){var de=J[q];return de===i?void 0:de}return ke.call(J,q)?J[q]:void 0}function Ot(q){var J=this.__data__;return He?J[q]!==void 0:ke.call(J,q)}function tt(q,J){var de=this.__data__;return this.size+=this.has(q)?0:1,de[q]=He&&J===void 0?i:J,this}ze.prototype.clear=at,ze.prototype.delete=Ce,ze.prototype.get=Ct,ze.prototype.has=Ot,ze.prototype.set=tt;function bt(q){var J=-1,de=q==null?0:q.length;for(this.clear();++J<de;){var xe=q[J];this.set(xe[0],xe[1])}}function xr(){this.__data__=[],this.size=0}function Pr(q){var J=this.__data__,de=ms(J,q);if(de<0)return!1;var xe=J.length-1;return de==xe?J.pop():wt.call(J,de,1),--this.size,!0}function Rr(q){var J=this.__data__,de=ms(J,q);return de<0?void 0:J[de][1]}function Nr(q){return ms(this.__data__,q)>-1}function Cr(q,J){var de=this.__data__,xe=ms(de,q);return xe<0?(++this.size,de.push([q,J])):de[xe][1]=J,this}bt.prototype.clear=xr,bt.prototype.delete=Pr,bt.prototype.get=Rr,bt.prototype.has=Nr,bt.prototype.set=Cr;function Yt(q){var J=-1,de=q==null?0:q.length;for(this.clear();++J<de;){var xe=q[J];this.set(xe[0],xe[1])}}function Hr(){this.size=0,this.__data__={hash:new ze,map:new(Ke||bt),string:new ze}}function $i(q){var J=Qn(this,q).delete(q);return this.size-=J?1:0,J}function Vr(q){return Qn(this,q).get(q)}function zi(q){return Qn(this,q).has(q)}function Ui(q,J){var de=Qn(this,q),xe=de.size;return de.set(q,J),this.size+=de.size==xe?0:1,this}Yt.prototype.clear=Hr,Yt.prototype.delete=$i,Yt.prototype.get=Vr,Yt.prototype.has=zi,Yt.prototype.set=Ui;function Gr(q){var J=-1,de=q==null?0:q.length;for(this.__data__=new Yt;++J<de;)this.add(q[J])}function mi(q){return this.__data__.set(q,i),this}function yi(q){return this.__data__.has(q)}Gr.prototype.add=Gr.prototype.push=mi,Gr.prototype.has=yi;function fr(q){var J=this.__data__=new bt(q);this.size=J.size}function ji(){this.__data__=new bt,this.size=0}function Ki(q){var J=this.__data__,de=J.delete(q);return this.size=J.size,de}function Hi(q){return this.__data__.get(q)}function bs(q){return this.__data__.has(q)}function zo(q,J){var de=this.__data__;if(de instanceof bt){var xe=de.__data__;if(!Ke||xe.length<t-1)return xe.push([q,J]),this.size=++de.size,this;de=this.__data__=new Yt(xe)}return de.set(q,J),this.size=de.size,this}fr.prototype.clear=ji,fr.prototype.delete=Ki,fr.prototype.get=Hi,fr.prototype.has=bs,fr.prototype.set=zo;function Uo(q,J){var de=Zs(q),xe=!de&&ec(q),$t=!de&&!xe&&$a(q),pt=!de&&!xe&&!$t&&ic(q),Vt=de||xe||$t||pt,or=Vt?nt(q.length,String):[],Rt=or.length;for(var zt in q)ke.call(q,zt)&&!(Vt&&(zt=="length"||$t&&(zt=="offset"||zt=="parent")||pt&&(zt=="buffer"||zt=="byteLength"||zt=="byteOffset")||Wo(zt,Rt)))&&or.push(zt);return or}function ms(q,J){for(var de=q.length;de--;)if(Zo(q[de][0],J))return de;return-1}function La(q,J,de){var xe=J(q);return Zs(q)?xe:be(xe,de(q))}function ys(q){return q==null?q===void 0?ge:X:dt&&dt in Object(q)?Go(q):Gf(q)}function ka(q){return _s(q)&&ys(q)==p}function ws(q,J,de,xe,$t){return q===J?!0:q==null||J==null||!_s(q)&&!_s(J)?q!==q&&J!==J:jo(q,J,de,xe,ws,$t)}function jo(q,J,de,xe,$t,pt){var Vt=Zs(q),or=Zs(J),Rt=Vt?w:cn(q),zt=or?w:cn(J);Rt=Rt==p?z:Rt,zt=zt==p?z:zt;var rr=Rt==z,Jr=zt==z,cr=Rt==zt;if(cr&&$a(q)){if(!$a(J))return!1;Vt=!0,rr=!1}if(cr&&!rr)return pt||(pt=new fr),Vt||ic(q)?Ys(q,J,de,xe,$t,pt):Vf(q,J,Rt,de,xe,$t,pt);if(!(de&s)){var Gt=rr&&ke.call(q,"__wrapped__"),qr=Jr&&ke.call(J,"__wrapped__");if(Gt||qr){var Vi=Gt?q.value():q,wi=qr?J.value():J;return pt||(pt=new fr),$t(Vi,wi,de,xe,pt)}}return cr?(pt||(pt=new fr),Vo(q,J,de,xe,$t,pt)):!1}function Hf(q){if(!rc(q)||Yo(q))return!1;var J=ea(q)?ft:ie;return J.test(Nn(q))}function Ko(q){return _s(q)&&tc(q.length)&&!!I[ys(q)]}function Ho(q){if(!Xo(q))return Mt(q);var J=[];for(var de in Object(q))ke.call(q,de)&&de!="constructor"&&J.push(de);return J}function Ys(q,J,de,xe,$t,pt){var Vt=de&s,or=q.length,Rt=J.length;if(or!=Rt&&!(Vt&&Rt>or))return!1;var zt=pt.get(q);if(zt&&pt.get(J))return zt==J;var rr=-1,Jr=!0,cr=de&a?new Gr:void 0;for(pt.set(q,J),pt.set(J,q);++rr<or;){var Gt=q[rr],qr=J[rr];if(xe)var Vi=Vt?xe(qr,Gt,rr,J,q,pt):xe(Gt,qr,rr,q,J,pt);if(Vi!==void 0){if(Vi)continue;Jr=!1;break}if(cr){if(!Te(J,function(wi,fn){if(!Ve(cr,fn)&&(Gt===wi||$t(Gt,wi,de,xe,pt)))return cr.push(fn)})){Jr=!1;break}}else if(!(Gt===qr||$t(Gt,qr,de,xe,pt))){Jr=!1;break}}return pt.delete(q),pt.delete(J),Jr}function Vf(q,J,de,xe,$t,pt,Vt){switch(de){case v:if(q.byteLength!=J.byteLength||q.byteOffset!=J.byteOffset)return!1;q=q.buffer,J=J.buffer;case L:return!(q.byteLength!=J.byteLength||!pt(new ut(q),new ut(J)));case A:case M:case G:return Zo(+q,+J);case C:return q.name==J.name&&q.message==J.message;case H:case oe:return q==J+"";case j:var or=Ae;case ee:var Rt=xe&s;if(or||(or=Ge),q.size!=J.size&&!Rt)return!1;var zt=Vt.get(q);if(zt)return zt==J;xe|=a,Vt.set(q,J);var rr=Ys(or(q),or(J),xe,$t,pt,Vt);return Vt.delete(q),rr;case ne:if(Me)return Me.call(q)==Me.call(J)}return!1}function Vo(q,J,de,xe,$t,pt){var Vt=de&s,or=Xs(q),Rt=or.length,zt=Xs(J),rr=zt.length;if(Rt!=rr&&!Vt)return!1;for(var Jr=Rt;Jr--;){var cr=or[Jr];if(!(Vt?cr in J:ke.call(J,cr)))return!1}var Gt=pt.get(q);if(Gt&&pt.get(J))return Gt==J;var qr=!0;pt.set(q,J),pt.set(J,q);for(var Vi=Vt;++Jr<Rt;){cr=or[Jr];var wi=q[cr],fn=J[cr];if(xe)var za=Vt?xe(fn,wi,cr,J,q,pt):xe(wi,fn,cr,q,J,pt);if(!(za===void 0?wi===fn||$t(wi,fn,de,xe,pt):za)){qr=!1;break}Vi||(Vi=cr=="constructor")}if(qr&&!Vi){var As=q.constructor,pr=J.constructor;As!=pr&&"constructor"in q&&"constructor"in J&&!(typeof As=="function"&&As instanceof As&&typeof pr=="function"&&pr instanceof pr)&&(qr=!1)}return pt.delete(q),pt.delete(J),qr}function Xs(q){return La(q,Qf,Jo)}function Qn(q,J){var de=q.__data__;return Qo(J)?de[typeof J=="string"?"string":"hash"]:de.map}function ci(q,J){var de=Le(q,J);return Hf(de)?de:void 0}function Go(q){var J=ke.call(q,dt),de=q[dt];try{q[dt]=void 0;var xe=!0}catch{}var $t=ot.call(q);return xe&&(J?q[dt]=de:delete q[dt]),$t}var Jo=$e?function(q){return q==null?[]:(q=Object(q),ve($e(q),function(J){return qe.call(q,J)}))}:kt,cn=ys;(Ee&&cn(new Ee(new ArrayBuffer(1)))!=v||Ke&&cn(new Ke)!=j||Qe&&cn(Qe.resolve())!=Q||Ie&&cn(new Ie)!=ee||Je&&cn(new Je)!=ht)&&(cn=function(q){var J=ys(q),de=J==z?q.constructor:void 0,xe=de?Nn(de):"";if(xe)switch(xe){case Re:return v;case st:return j;case Ye:return Q;case Ne:return ee;case Xe:return ht}return J});function Wo(q,J){return J=J??f,!!J&&(typeof q=="number"||se.test(q))&&q>-1&&q%1==0&&q<J}function Qo(q){var J=typeof q;return J=="string"||J=="number"||J=="symbol"||J=="boolean"?q!=="__proto__":q===null}function Yo(q){return!!Pe&&Pe in q}function Xo(q){var J=q&&q.constructor,de=typeof J=="function"&&J.prototype||Fe;return q===de}function Gf(q){return ot.call(q)}function Nn(q){if(q!=null){try{return We.call(q)}catch{}try{return q+""}catch{}}return""}function Zo(q,J){return q===J||q!==q&&J!==J}var ec=ka(function(){return arguments}())?ka:function(q){return _s(q)&&ke.call(q,"callee")&&!qe.call(q,"callee")},Zs=Array.isArray;function Jf(q){return q!=null&&tc(q.length)&&!ea(q)}var $a=At||Lt;function Wf(q,J){return ws(q,J)}function ea(q){if(!rc(q))return!1;var J=ys(q);return J==O||J==D||J==b||J==V}function tc(q){return typeof q=="number"&&q>-1&&q%1==0&&q<=f}function rc(q){var J=typeof q;return q!=null&&(J=="object"||J=="function")}function _s(q){return q!=null&&typeof q=="object"}var ic=ue?Se(ue):Ko;function Qf(q){return Jf(q)?Uo(q):Ho(q)}function kt(){return[]}function Lt(){return!1}r.exports=Wf})(gf,gf.exports);var T4=gf.exports;const D4=xw(T4);var F4=Object.defineProperty,q4=Object.defineProperties,B4=Object.getOwnPropertyDescriptors,tp=Object.getOwnPropertySymbols,L4=Object.prototype.hasOwnProperty,k4=Object.prototype.propertyIsEnumerable,rp=(r,e,t)=>e in r?F4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ip=(r,e)=>{for(var t in e||(e={}))L4.call(e,t)&&rp(r,t,e[t]);if(tp)for(var t of tp(e))k4.call(e,t)&&rp(r,t,e[t]);return r},np=(r,e)=>q4(r,B4(e));const $4={Accept:"application/json","Content-Type":"application/json"},z4="POST",sp={headers:$4,method:z4},ap=10;class xn{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new Bi.EventEmitter,this.isAvailable=!1,this.registering=!1,!Q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=Jn(e),i=await(await O0(this.url,np(ip({},sp),{body:t}))).json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!Q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=Jn({id:1,jsonrpc:"2.0",method:"test",params:[]});await O0(e,np(ip({},sp),{body:t}))}this.onOpen()}catch(t){const i=this.parseError(t);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?zs(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),s=i.message||i.toString(),a=Of(e,s);this.events.emit("payload",a)}parseError(e,t=this.url){return pg(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ap&&this.events.setMaxListeners(ap)}}const U4={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var Mo={},bg="%[a-f0-9]{2}",op=new RegExp("("+bg+")|([^%]+?)","gi"),cp=new RegExp("("+bg+")+","gi");function ku(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],ku(t),ku(i))}function j4(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(op)||[],t=1;t<e.length;t++)r=ku(e,t).join(""),e=r.match(op)||[];return r}}function K4(r){for(var e={"%FE%FF":"��","%FF%FE":"��"},t=cp.exec(r);t;){try{e[t[0]]=decodeURIComponent(t[0])}catch{var i=j4(t[0]);i!==t[0]&&(e[t[0]]=i)}t=cp.exec(r)}e["%C2"]="�";for(var s=Object.keys(e),a=0;a<s.length;a++){var f=s[a];r=r.replace(new RegExp(f,"g"),e[f])}return r}var H4=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return K4(r)}},V4=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},G4=function(r,e){for(var t={},i=Object.keys(r),s=Array.isArray(e),a=0;a<i.length;a++){var f=i[a],p=r[f];(s?e.indexOf(f)!==-1:e(f,p,r))&&(t[f]=p)}return t};(function(r){const e=$w,t=H4,i=V4,s=G4,a=z=>z==null,f=Symbol("encodeFragmentIdentifier");function p(z){switch(z.arrayFormat){case"index":return Q=>(V,H)=>{const ee=V.length;return H===void 0||z.skipNull&&H===null||z.skipEmptyString&&H===""?V:H===null?[...V,[A(Q,z),"[",ee,"]"].join("")]:[...V,[A(Q,z),"[",A(ee,z),"]=",A(H,z)].join("")]};case"bracket":return Q=>(V,H)=>H===void 0||z.skipNull&&H===null||z.skipEmptyString&&H===""?V:H===null?[...V,[A(Q,z),"[]"].join("")]:[...V,[A(Q,z),"[]=",A(H,z)].join("")];case"colon-list-separator":return Q=>(V,H)=>H===void 0||z.skipNull&&H===null||z.skipEmptyString&&H===""?V:H===null?[...V,[A(Q,z),":list="].join("")]:[...V,[A(Q,z),":list=",A(H,z)].join("")];case"comma":case"separator":case"bracket-separator":{const Q=z.arrayFormat==="bracket-separator"?"[]=":"=";return V=>(H,ee)=>ee===void 0||z.skipNull&&ee===null||z.skipEmptyString&&ee===""?H:(ee=ee===null?"":ee,H.length===0?[[A(V,z),Q,A(ee,z)].join("")]:[[H,A(ee,z)].join(z.arrayFormatSeparator)])}default:return Q=>(V,H)=>H===void 0||z.skipNull&&H===null||z.skipEmptyString&&H===""?V:H===null?[...V,A(Q,z)]:[...V,[A(Q,z),"=",A(H,z)].join("")]}}function w(z){let Q;switch(z.arrayFormat){case"index":return(V,H,ee)=>{if(Q=/\[(\d*)\]$/.exec(V),V=V.replace(/\[\d*\]$/,""),!Q){ee[V]=H;return}ee[V]===void 0&&(ee[V]={}),ee[V][Q[1]]=H};case"bracket":return(V,H,ee)=>{if(Q=/(\[\])$/.exec(V),V=V.replace(/\[\]$/,""),!Q){ee[V]=H;return}if(ee[V]===void 0){ee[V]=[H];return}ee[V]=[].concat(ee[V],H)};case"colon-list-separator":return(V,H,ee)=>{if(Q=/(:list)$/.exec(V),V=V.replace(/:list$/,""),!Q){ee[V]=H;return}if(ee[V]===void 0){ee[V]=[H];return}ee[V]=[].concat(ee[V],H)};case"comma":case"separator":return(V,H,ee)=>{const oe=typeof H=="string"&&H.includes(z.arrayFormatSeparator),ne=typeof H=="string"&&!oe&&M(H,z).includes(z.arrayFormatSeparator);H=ne?M(H,z):H;const ge=oe||ne?H.split(z.arrayFormatSeparator).map(ht=>M(ht,z)):H===null?H:M(H,z);ee[V]=ge};case"bracket-separator":return(V,H,ee)=>{const oe=/(\[\])$/.test(V);if(V=V.replace(/\[\]$/,""),!oe){ee[V]=H&&M(H,z);return}const ne=H===null?[]:H.split(z.arrayFormatSeparator).map(ge=>M(ge,z));if(ee[V]===void 0){ee[V]=ne;return}ee[V]=[].concat(ee[V],ne)};default:return(V,H,ee)=>{if(ee[V]===void 0){ee[V]=H;return}ee[V]=[].concat(ee[V],H)}}}function b(z){if(typeof z!="string"||z.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function A(z,Q){return Q.encode?Q.strict?e(z):encodeURIComponent(z):z}function M(z,Q){return Q.decode?t(z):z}function C(z){return Array.isArray(z)?z.sort():typeof z=="object"?C(Object.keys(z)).sort((Q,V)=>Number(Q)-Number(V)).map(Q=>z[Q]):z}function O(z){const Q=z.indexOf("#");return Q!==-1&&(z=z.slice(0,Q)),z}function D(z){let Q="";const V=z.indexOf("#");return V!==-1&&(Q=z.slice(V)),Q}function j(z){z=O(z);const Q=z.indexOf("?");return Q===-1?"":z.slice(Q+1)}function G(z,Q){return Q.parseNumbers&&!Number.isNaN(Number(z))&&typeof z=="string"&&z.trim()!==""?z=Number(z):Q.parseBooleans&&z!==null&&(z.toLowerCase()==="true"||z.toLowerCase()==="false")&&(z=z.toLowerCase()==="true"),z}function X(z,Q){Q=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},Q),b(Q.arrayFormatSeparator);const V=w(Q),H=Object.create(null);if(typeof z!="string"||(z=z.trim().replace(/^[?#&]/,""),!z))return H;for(const ee of z.split("&")){if(ee==="")continue;let[oe,ne]=i(Q.decode?ee.replace(/\+/g," "):ee,"=");ne=ne===void 0?null:["comma","separator","bracket-separator"].includes(Q.arrayFormat)?ne:M(ne,Q),V(M(oe,Q),ne,H)}for(const ee of Object.keys(H)){const oe=H[ee];if(typeof oe=="object"&&oe!==null)for(const ne of Object.keys(oe))oe[ne]=G(oe[ne],Q);else H[ee]=G(oe,Q)}return Q.sort===!1?H:(Q.sort===!0?Object.keys(H).sort():Object.keys(H).sort(Q.sort)).reduce((ee,oe)=>{const ne=H[oe];return ne&&typeof ne=="object"&&!Array.isArray(ne)?ee[oe]=C(ne):ee[oe]=ne,ee},Object.create(null))}r.extract=j,r.parse=X,r.stringify=(z,Q)=>{if(!z)return"";Q=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},Q),b(Q.arrayFormatSeparator);const V=ne=>Q.skipNull&&a(z[ne])||Q.skipEmptyString&&z[ne]==="",H=p(Q),ee={};for(const ne of Object.keys(z))V(ne)||(ee[ne]=z[ne]);const oe=Object.keys(ee);return Q.sort!==!1&&oe.sort(Q.sort),oe.map(ne=>{const ge=z[ne];return ge===void 0?"":ge===null?A(ne,Q):Array.isArray(ge)?ge.length===0&&Q.arrayFormat==="bracket-separator"?A(ne,Q)+"[]":ge.reduce(H(ne),[]).join("&"):A(ne,Q)+"="+A(ge,Q)}).filter(ne=>ne.length>0).join("&")},r.parseUrl=(z,Q)=>{Q=Object.assign({decode:!0},Q);const[V,H]=i(z,"#");return Object.assign({url:V.split("?")[0]||"",query:X(j(z),Q)},Q&&Q.parseFragmentIdentifier&&H?{fragmentIdentifier:M(H,Q)}:{})},r.stringifyUrl=(z,Q)=>{Q=Object.assign({encode:!0,strict:!0,[f]:!0},Q);const V=O(z.url).split("?")[0]||"",H=r.extract(z.url),ee=r.parse(H,{sort:!1}),oe=Object.assign(ee,z.query);let ne=r.stringify(oe,Q);ne&&(ne=`?${ne}`);let ge=D(z.url);return z.fragmentIdentifier&&(ge=`#${Q[f]?A(z.fragmentIdentifier,Q):z.fragmentIdentifier}`),`${V}${ne}${ge}`},r.pick=(z,Q,V)=>{V=Object.assign({parseFragmentIdentifier:!0,[f]:!1},V);const{url:H,query:ee,fragmentIdentifier:oe}=r.parseUrl(z,V);return r.stringifyUrl({url:H,query:s(ee,Q),fragmentIdentifier:oe},V)},r.exclude=(z,Q,V)=>{const H=Array.isArray(Q)?ee=>!Q.includes(ee):(ee,oe)=>!Q(ee,oe);return r.pick(z,H,V)}})(Mo);var mg={};const J4="elliptic",W4="6.5.7",Q4="EC cryptography",Y4="lib/elliptic.js",X4=["lib"],Z4={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},e8={type:"git",url:"git@github.com:indutny/elliptic"},t8=["EC","Elliptic","curve","Cryptography"],r8="Fedor Indutny <fedor@indutny.com>",i8="MIT",n8={url:"https://github.com/indutny/elliptic/issues"},s8="https://github.com/indutny/elliptic",a8={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},o8={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},c8={name:J4,version:W4,description:Q4,main:Y4,files:X4,scripts:Z4,repository:e8,keywords:t8,author:r8,license:i8,bugs:n8,homepage:s8,devDependencies:a8,dependencies:o8};var bi={},hd={exports:{}};hd.exports;(function(r){(function(e,t){function i(L,v){if(!L)throw new Error(v||"Assertion failed")}function s(L,v){L.super_=v;var c=function(){};c.prototype=v.prototype,L.prototype=new c,L.prototype.constructor=L}function a(L,v,c){if(a.isBN(L))return L;this.negative=0,this.words=null,this.length=0,this.red=null,L!==null&&((v==="le"||v==="be")&&(c=v,v=10),this._init(L||0,v||10,c||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=V1.Buffer}catch{}a.isBN=function(v){return v instanceof a?!0:v!==null&&typeof v=="object"&&v.constructor.wordSize===a.wordSize&&Array.isArray(v.words)},a.max=function(v,c){return v.cmp(c)>0?v:c},a.min=function(v,c){return v.cmp(c)<0?v:c},a.prototype._init=function(v,c,d){if(typeof v=="number")return this._initNumber(v,c,d);if(typeof v=="object")return this._initArray(v,c,d);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),v=v.toString().replace(/\s+/g,"");var g=0;v[0]==="-"&&(g++,this.negative=1),g<v.length&&(c===16?this._parseHex(v,g,d):(this._parseBase(v,c,g),d==="le"&&this._initArray(this.toArray(),c,d)))},a.prototype._initNumber=function(v,c,d){v<0&&(this.negative=1,v=-v),v<67108864?(this.words=[v&67108863],this.length=1):v<4503599627370496?(this.words=[v&67108863,v/67108864&67108863],this.length=2):(i(v<9007199254740992),this.words=[v&67108863,v/67108864&67108863,1],this.length=3),d==="le"&&this._initArray(this.toArray(),c,d)},a.prototype._initArray=function(v,c,d){if(i(typeof v.length=="number"),v.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(v.length/3),this.words=new Array(this.length);for(var g=0;g<this.length;g++)this.words[g]=0;var _,S,x=0;if(d==="be")for(g=v.length-1,_=0;g>=0;g-=3)S=v[g]|v[g-1]<<8|v[g-2]<<16,this.words[_]|=S<<x&67108863,this.words[_+1]=S>>>26-x&67108863,x+=24,x>=26&&(x-=26,_++);else if(d==="le")for(g=0,_=0;g<v.length;g+=3)S=v[g]|v[g+1]<<8|v[g+2]<<16,this.words[_]|=S<<x&67108863,this.words[_+1]=S>>>26-x&67108863,x+=24,x>=26&&(x-=26,_++);return this.strip()};function p(L,v){var c=L.charCodeAt(v);return c>=65&&c<=70?c-55:c>=97&&c<=102?c-87:c-48&15}function w(L,v,c){var d=p(L,c);return c-1>=v&&(d|=p(L,c-1)<<4),d}a.prototype._parseHex=function(v,c,d){this.length=Math.ceil((v.length-c)/6),this.words=new Array(this.length);for(var g=0;g<this.length;g++)this.words[g]=0;var _=0,S=0,x;if(d==="be")for(g=v.length-1;g>=c;g-=2)x=w(v,c,g)<<_,this.words[S]|=x&67108863,_>=18?(_-=18,S+=1,this.words[S]|=x>>>26):_+=8;else{var E=v.length-c;for(g=E%2===0?c+1:c;g<v.length;g+=2)x=w(v,c,g)<<_,this.words[S]|=x&67108863,_>=18?(_-=18,S+=1,this.words[S]|=x>>>26):_+=8}this.strip()};function b(L,v,c,d){for(var g=0,_=Math.min(L.length,c),S=v;S<_;S++){var x=L.charCodeAt(S)-48;g*=d,x>=49?g+=x-49+10:x>=17?g+=x-17+10:g+=x}return g}a.prototype._parseBase=function(v,c,d){this.words=[0],this.length=1;for(var g=0,_=1;_<=67108863;_*=c)g++;g--,_=_/c|0;for(var S=v.length-d,x=S%g,E=Math.min(S,S-x)+d,u=0,l=d;l<E;l+=g)u=b(v,l,l+g,c),this.imuln(_),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(x!==0){var R=1;for(u=b(v,l,v.length,c),l=0;l<x;l++)R*=c;this.imuln(R),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},a.prototype.copy=function(v){v.words=new Array(this.length);for(var c=0;c<this.length;c++)v.words[c]=this.words[c];v.length=this.length,v.negative=this.negative,v.red=this.red},a.prototype.clone=function(){var v=new a(null);return this.copy(v),v},a.prototype._expand=function(v){for(;this.length<v;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var A=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],M=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],C=[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];a.prototype.toString=function(v,c){v=v||10,c=c|0||1;var d;if(v===16||v==="hex"){d="";for(var g=0,_=0,S=0;S<this.length;S++){var x=this.words[S],E=((x<<g|_)&16777215).toString(16);_=x>>>24-g&16777215,_!==0||S!==this.length-1?d=A[6-E.length]+E+d:d=E+d,g+=2,g>=26&&(g-=26,S--)}for(_!==0&&(d=_.toString(16)+d);d.length%c!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}if(v===(v|0)&&v>=2&&v<=36){var u=M[v],l=C[v];d="";var R=this.clone();for(R.negative=0;!R.isZero();){var ie=R.modn(l).toString(v);R=R.idivn(l),R.isZero()?d=ie+d:d=A[u-ie.length]+ie+d}for(this.isZero()&&(d="0"+d);d.length%c!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var v=this.words[0];return this.length===2?v+=this.words[1]*67108864:this.length===3&&this.words[2]===1?v+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-v:v},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(v,c){return i(typeof f<"u"),this.toArrayLike(f,v,c)},a.prototype.toArray=function(v,c){return this.toArrayLike(Array,v,c)},a.prototype.toArrayLike=function(v,c,d){var g=this.byteLength(),_=d||Math.max(1,g);i(g<=_,"byte array longer than desired length"),i(_>0,"Requested array length <= 0"),this.strip();var S=c==="le",x=new v(_),E,u,l=this.clone();if(S){for(u=0;!l.isZero();u++)E=l.andln(255),l.iushrn(8),x[u]=E;for(;u<_;u++)x[u]=0}else{for(u=0;u<_-g;u++)x[u]=0;for(u=0;!l.isZero();u++)E=l.andln(255),l.iushrn(8),x[_-u-1]=E}return x},Math.clz32?a.prototype._countBits=function(v){return 32-Math.clz32(v)}:a.prototype._countBits=function(v){var c=v,d=0;return c>=4096&&(d+=13,c>>>=13),c>=64&&(d+=7,c>>>=7),c>=8&&(d+=4,c>>>=4),c>=2&&(d+=2,c>>>=2),d+c},a.prototype._zeroBits=function(v){if(v===0)return 26;var c=v,d=0;return c&8191||(d+=13,c>>>=13),c&127||(d+=7,c>>>=7),c&15||(d+=4,c>>>=4),c&3||(d+=2,c>>>=2),c&1||d++,d},a.prototype.bitLength=function(){var v=this.words[this.length-1],c=this._countBits(v);return(this.length-1)*26+c};function O(L){for(var v=new Array(L.bitLength()),c=0;c<v.length;c++){var d=c/26|0,g=c%26;v[c]=(L.words[d]&1<<g)>>>g}return v}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var v=0,c=0;c<this.length;c++){var d=this._zeroBits(this.words[c]);if(v+=d,d!==26)break}return v},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(v){return this.negative!==0?this.abs().inotn(v).iaddn(1):this.clone()},a.prototype.fromTwos=function(v){return this.testn(v-1)?this.notn(v).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(v){for(;this.length<v.length;)this.words[this.length++]=0;for(var c=0;c<v.length;c++)this.words[c]=this.words[c]|v.words[c];return this.strip()},a.prototype.ior=function(v){return i((this.negative|v.negative)===0),this.iuor(v)},a.prototype.or=function(v){return this.length>v.length?this.clone().ior(v):v.clone().ior(this)},a.prototype.uor=function(v){return this.length>v.length?this.clone().iuor(v):v.clone().iuor(this)},a.prototype.iuand=function(v){var c;this.length>v.length?c=v:c=this;for(var d=0;d<c.length;d++)this.words[d]=this.words[d]&v.words[d];return this.length=c.length,this.strip()},a.prototype.iand=function(v){return i((this.negative|v.negative)===0),this.iuand(v)},a.prototype.and=function(v){return this.length>v.length?this.clone().iand(v):v.clone().iand(this)},a.prototype.uand=function(v){return this.length>v.length?this.clone().iuand(v):v.clone().iuand(this)},a.prototype.iuxor=function(v){var c,d;this.length>v.length?(c=this,d=v):(c=v,d=this);for(var g=0;g<d.length;g++)this.words[g]=c.words[g]^d.words[g];if(this!==c)for(;g<c.length;g++)this.words[g]=c.words[g];return this.length=c.length,this.strip()},a.prototype.ixor=function(v){return i((this.negative|v.negative)===0),this.iuxor(v)},a.prototype.xor=function(v){return this.length>v.length?this.clone().ixor(v):v.clone().ixor(this)},a.prototype.uxor=function(v){return this.length>v.length?this.clone().iuxor(v):v.clone().iuxor(this)},a.prototype.inotn=function(v){i(typeof v=="number"&&v>=0);var c=Math.ceil(v/26)|0,d=v%26;this._expand(c),d>0&&c--;for(var g=0;g<c;g++)this.words[g]=~this.words[g]&67108863;return d>0&&(this.words[g]=~this.words[g]&67108863>>26-d),this.strip()},a.prototype.notn=function(v){return this.clone().inotn(v)},a.prototype.setn=function(v,c){i(typeof v=="number"&&v>=0);var d=v/26|0,g=v%26;return this._expand(d+1),c?this.words[d]=this.words[d]|1<<g:this.words[d]=this.words[d]&~(1<<g),this.strip()},a.prototype.iadd=function(v){var c;if(this.negative!==0&&v.negative===0)return this.negative=0,c=this.isub(v),this.negative^=1,this._normSign();if(this.negative===0&&v.negative!==0)return v.negative=0,c=this.isub(v),v.negative=1,c._normSign();var d,g;this.length>v.length?(d=this,g=v):(d=v,g=this);for(var _=0,S=0;S<g.length;S++)c=(d.words[S]|0)+(g.words[S]|0)+_,this.words[S]=c&67108863,_=c>>>26;for(;_!==0&&S<d.length;S++)c=(d.words[S]|0)+_,this.words[S]=c&67108863,_=c>>>26;if(this.length=d.length,_!==0)this.words[this.length]=_,this.length++;else if(d!==this)for(;S<d.length;S++)this.words[S]=d.words[S];return this},a.prototype.add=function(v){var c;return v.negative!==0&&this.negative===0?(v.negative=0,c=this.sub(v),v.negative^=1,c):v.negative===0&&this.negative!==0?(this.negative=0,c=v.sub(this),this.negative=1,c):this.length>v.length?this.clone().iadd(v):v.clone().iadd(this)},a.prototype.isub=function(v){if(v.negative!==0){v.negative=0;var c=this.iadd(v);return v.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(v),this.negative=1,this._normSign();var d=this.cmp(v);if(d===0)return this.negative=0,this.length=1,this.words[0]=0,this;var g,_;d>0?(g=this,_=v):(g=v,_=this);for(var S=0,x=0;x<_.length;x++)c=(g.words[x]|0)-(_.words[x]|0)+S,S=c>>26,this.words[x]=c&67108863;for(;S!==0&&x<g.length;x++)c=(g.words[x]|0)+S,S=c>>26,this.words[x]=c&67108863;if(S===0&&x<g.length&&g!==this)for(;x<g.length;x++)this.words[x]=g.words[x];return this.length=Math.max(this.length,x),g!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(v){return this.clone().isub(v)};function D(L,v,c){c.negative=v.negative^L.negative;var d=L.length+v.length|0;c.length=d,d=d-1|0;var g=L.words[0]|0,_=v.words[0]|0,S=g*_,x=S&67108863,E=S/67108864|0;c.words[0]=x;for(var u=1;u<d;u++){for(var l=E>>>26,R=E&67108863,ie=Math.min(u,v.length-1),se=Math.max(0,u-L.length+1);se<=ie;se++){var I=u-se|0;g=L.words[I]|0,_=v.words[se]|0,S=g*_+R,l+=S/67108864|0,R=S&67108863}c.words[u]=R|0,E=l|0}return E!==0?c.words[u]=E|0:c.length--,c.strip()}var j=function(v,c,d){var g=v.words,_=c.words,S=d.words,x=0,E,u,l,R=g[0]|0,ie=R&8191,se=R>>>13,I=g[1]|0,Z=I&8191,F=I>>>13,k=g[2]|0,$=k&8191,m=k>>>13,B=g[3]|0,re=B&8191,he=B>>>13,ue=g[4]|0,ve=ue&8191,be=ue>>>13,Te=g[5]|0,nt=Te&8191,Se=Te>>>13,Ve=g[6]|0,Le=Ve&8191,Ae=Ve>>>13,Ue=g[7]|0,Ge=Ue&8191,ye=Ue>>>13,je=g[8]|0,Fe=je&8191,_e=je>>>13,We=g[9]|0,ke=We&8191,Pe=We>>>13,ot=_[0]|0,ft=ot&8191,De=ot>>>13,ct=_[1]|0,ut=ct&8191,qe=ct>>>13,wt=_[2]|0,dt=wt&8191,$e=wt>>>13,At=_[3]|0,Mt=At&8191,Ee=At>>>13,Ke=_[4]|0,Qe=Ke&8191,Ie=Ke>>>13,Je=_[5]|0,He=Je&8191,Re=Je>>>13,st=_[6]|0,Ye=st&8191,Ne=st>>>13,Xe=_[7]|0,et=Xe&8191,Me=Xe>>>13,ze=_[8]|0,at=ze&8191,Ce=ze>>>13,Ct=_[9]|0,Ot=Ct&8191,tt=Ct>>>13;d.negative=v.negative^c.negative,d.length=19,E=Math.imul(ie,ft),u=Math.imul(ie,De),u=u+Math.imul(se,ft)|0,l=Math.imul(se,De);var bt=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(bt>>>26)|0,bt&=67108863,E=Math.imul(Z,ft),u=Math.imul(Z,De),u=u+Math.imul(F,ft)|0,l=Math.imul(F,De),E=E+Math.imul(ie,ut)|0,u=u+Math.imul(ie,qe)|0,u=u+Math.imul(se,ut)|0,l=l+Math.imul(se,qe)|0;var xr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(xr>>>26)|0,xr&=67108863,E=Math.imul($,ft),u=Math.imul($,De),u=u+Math.imul(m,ft)|0,l=Math.imul(m,De),E=E+Math.imul(Z,ut)|0,u=u+Math.imul(Z,qe)|0,u=u+Math.imul(F,ut)|0,l=l+Math.imul(F,qe)|0,E=E+Math.imul(ie,dt)|0,u=u+Math.imul(ie,$e)|0,u=u+Math.imul(se,dt)|0,l=l+Math.imul(se,$e)|0;var Pr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,E=Math.imul(re,ft),u=Math.imul(re,De),u=u+Math.imul(he,ft)|0,l=Math.imul(he,De),E=E+Math.imul($,ut)|0,u=u+Math.imul($,qe)|0,u=u+Math.imul(m,ut)|0,l=l+Math.imul(m,qe)|0,E=E+Math.imul(Z,dt)|0,u=u+Math.imul(Z,$e)|0,u=u+Math.imul(F,dt)|0,l=l+Math.imul(F,$e)|0,E=E+Math.imul(ie,Mt)|0,u=u+Math.imul(ie,Ee)|0,u=u+Math.imul(se,Mt)|0,l=l+Math.imul(se,Ee)|0;var Rr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,E=Math.imul(ve,ft),u=Math.imul(ve,De),u=u+Math.imul(be,ft)|0,l=Math.imul(be,De),E=E+Math.imul(re,ut)|0,u=u+Math.imul(re,qe)|0,u=u+Math.imul(he,ut)|0,l=l+Math.imul(he,qe)|0,E=E+Math.imul($,dt)|0,u=u+Math.imul($,$e)|0,u=u+Math.imul(m,dt)|0,l=l+Math.imul(m,$e)|0,E=E+Math.imul(Z,Mt)|0,u=u+Math.imul(Z,Ee)|0,u=u+Math.imul(F,Mt)|0,l=l+Math.imul(F,Ee)|0,E=E+Math.imul(ie,Qe)|0,u=u+Math.imul(ie,Ie)|0,u=u+Math.imul(se,Qe)|0,l=l+Math.imul(se,Ie)|0;var Nr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,E=Math.imul(nt,ft),u=Math.imul(nt,De),u=u+Math.imul(Se,ft)|0,l=Math.imul(Se,De),E=E+Math.imul(ve,ut)|0,u=u+Math.imul(ve,qe)|0,u=u+Math.imul(be,ut)|0,l=l+Math.imul(be,qe)|0,E=E+Math.imul(re,dt)|0,u=u+Math.imul(re,$e)|0,u=u+Math.imul(he,dt)|0,l=l+Math.imul(he,$e)|0,E=E+Math.imul($,Mt)|0,u=u+Math.imul($,Ee)|0,u=u+Math.imul(m,Mt)|0,l=l+Math.imul(m,Ee)|0,E=E+Math.imul(Z,Qe)|0,u=u+Math.imul(Z,Ie)|0,u=u+Math.imul(F,Qe)|0,l=l+Math.imul(F,Ie)|0,E=E+Math.imul(ie,He)|0,u=u+Math.imul(ie,Re)|0,u=u+Math.imul(se,He)|0,l=l+Math.imul(se,Re)|0;var Cr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,E=Math.imul(Le,ft),u=Math.imul(Le,De),u=u+Math.imul(Ae,ft)|0,l=Math.imul(Ae,De),E=E+Math.imul(nt,ut)|0,u=u+Math.imul(nt,qe)|0,u=u+Math.imul(Se,ut)|0,l=l+Math.imul(Se,qe)|0,E=E+Math.imul(ve,dt)|0,u=u+Math.imul(ve,$e)|0,u=u+Math.imul(be,dt)|0,l=l+Math.imul(be,$e)|0,E=E+Math.imul(re,Mt)|0,u=u+Math.imul(re,Ee)|0,u=u+Math.imul(he,Mt)|0,l=l+Math.imul(he,Ee)|0,E=E+Math.imul($,Qe)|0,u=u+Math.imul($,Ie)|0,u=u+Math.imul(m,Qe)|0,l=l+Math.imul(m,Ie)|0,E=E+Math.imul(Z,He)|0,u=u+Math.imul(Z,Re)|0,u=u+Math.imul(F,He)|0,l=l+Math.imul(F,Re)|0,E=E+Math.imul(ie,Ye)|0,u=u+Math.imul(ie,Ne)|0,u=u+Math.imul(se,Ye)|0,l=l+Math.imul(se,Ne)|0;var Yt=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,E=Math.imul(Ge,ft),u=Math.imul(Ge,De),u=u+Math.imul(ye,ft)|0,l=Math.imul(ye,De),E=E+Math.imul(Le,ut)|0,u=u+Math.imul(Le,qe)|0,u=u+Math.imul(Ae,ut)|0,l=l+Math.imul(Ae,qe)|0,E=E+Math.imul(nt,dt)|0,u=u+Math.imul(nt,$e)|0,u=u+Math.imul(Se,dt)|0,l=l+Math.imul(Se,$e)|0,E=E+Math.imul(ve,Mt)|0,u=u+Math.imul(ve,Ee)|0,u=u+Math.imul(be,Mt)|0,l=l+Math.imul(be,Ee)|0,E=E+Math.imul(re,Qe)|0,u=u+Math.imul(re,Ie)|0,u=u+Math.imul(he,Qe)|0,l=l+Math.imul(he,Ie)|0,E=E+Math.imul($,He)|0,u=u+Math.imul($,Re)|0,u=u+Math.imul(m,He)|0,l=l+Math.imul(m,Re)|0,E=E+Math.imul(Z,Ye)|0,u=u+Math.imul(Z,Ne)|0,u=u+Math.imul(F,Ye)|0,l=l+Math.imul(F,Ne)|0,E=E+Math.imul(ie,et)|0,u=u+Math.imul(ie,Me)|0,u=u+Math.imul(se,et)|0,l=l+Math.imul(se,Me)|0;var Hr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,E=Math.imul(Fe,ft),u=Math.imul(Fe,De),u=u+Math.imul(_e,ft)|0,l=Math.imul(_e,De),E=E+Math.imul(Ge,ut)|0,u=u+Math.imul(Ge,qe)|0,u=u+Math.imul(ye,ut)|0,l=l+Math.imul(ye,qe)|0,E=E+Math.imul(Le,dt)|0,u=u+Math.imul(Le,$e)|0,u=u+Math.imul(Ae,dt)|0,l=l+Math.imul(Ae,$e)|0,E=E+Math.imul(nt,Mt)|0,u=u+Math.imul(nt,Ee)|0,u=u+Math.imul(Se,Mt)|0,l=l+Math.imul(Se,Ee)|0,E=E+Math.imul(ve,Qe)|0,u=u+Math.imul(ve,Ie)|0,u=u+Math.imul(be,Qe)|0,l=l+Math.imul(be,Ie)|0,E=E+Math.imul(re,He)|0,u=u+Math.imul(re,Re)|0,u=u+Math.imul(he,He)|0,l=l+Math.imul(he,Re)|0,E=E+Math.imul($,Ye)|0,u=u+Math.imul($,Ne)|0,u=u+Math.imul(m,Ye)|0,l=l+Math.imul(m,Ne)|0,E=E+Math.imul(Z,et)|0,u=u+Math.imul(Z,Me)|0,u=u+Math.imul(F,et)|0,l=l+Math.imul(F,Me)|0,E=E+Math.imul(ie,at)|0,u=u+Math.imul(ie,Ce)|0,u=u+Math.imul(se,at)|0,l=l+Math.imul(se,Ce)|0;var $i=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+($i>>>26)|0,$i&=67108863,E=Math.imul(ke,ft),u=Math.imul(ke,De),u=u+Math.imul(Pe,ft)|0,l=Math.imul(Pe,De),E=E+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,qe)|0,u=u+Math.imul(_e,ut)|0,l=l+Math.imul(_e,qe)|0,E=E+Math.imul(Ge,dt)|0,u=u+Math.imul(Ge,$e)|0,u=u+Math.imul(ye,dt)|0,l=l+Math.imul(ye,$e)|0,E=E+Math.imul(Le,Mt)|0,u=u+Math.imul(Le,Ee)|0,u=u+Math.imul(Ae,Mt)|0,l=l+Math.imul(Ae,Ee)|0,E=E+Math.imul(nt,Qe)|0,u=u+Math.imul(nt,Ie)|0,u=u+Math.imul(Se,Qe)|0,l=l+Math.imul(Se,Ie)|0,E=E+Math.imul(ve,He)|0,u=u+Math.imul(ve,Re)|0,u=u+Math.imul(be,He)|0,l=l+Math.imul(be,Re)|0,E=E+Math.imul(re,Ye)|0,u=u+Math.imul(re,Ne)|0,u=u+Math.imul(he,Ye)|0,l=l+Math.imul(he,Ne)|0,E=E+Math.imul($,et)|0,u=u+Math.imul($,Me)|0,u=u+Math.imul(m,et)|0,l=l+Math.imul(m,Me)|0,E=E+Math.imul(Z,at)|0,u=u+Math.imul(Z,Ce)|0,u=u+Math.imul(F,at)|0,l=l+Math.imul(F,Ce)|0,E=E+Math.imul(ie,Ot)|0,u=u+Math.imul(ie,tt)|0,u=u+Math.imul(se,Ot)|0,l=l+Math.imul(se,tt)|0;var Vr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Vr>>>26)|0,Vr&=67108863,E=Math.imul(ke,ut),u=Math.imul(ke,qe),u=u+Math.imul(Pe,ut)|0,l=Math.imul(Pe,qe),E=E+Math.imul(Fe,dt)|0,u=u+Math.imul(Fe,$e)|0,u=u+Math.imul(_e,dt)|0,l=l+Math.imul(_e,$e)|0,E=E+Math.imul(Ge,Mt)|0,u=u+Math.imul(Ge,Ee)|0,u=u+Math.imul(ye,Mt)|0,l=l+Math.imul(ye,Ee)|0,E=E+Math.imul(Le,Qe)|0,u=u+Math.imul(Le,Ie)|0,u=u+Math.imul(Ae,Qe)|0,l=l+Math.imul(Ae,Ie)|0,E=E+Math.imul(nt,He)|0,u=u+Math.imul(nt,Re)|0,u=u+Math.imul(Se,He)|0,l=l+Math.imul(Se,Re)|0,E=E+Math.imul(ve,Ye)|0,u=u+Math.imul(ve,Ne)|0,u=u+Math.imul(be,Ye)|0,l=l+Math.imul(be,Ne)|0,E=E+Math.imul(re,et)|0,u=u+Math.imul(re,Me)|0,u=u+Math.imul(he,et)|0,l=l+Math.imul(he,Me)|0,E=E+Math.imul($,at)|0,u=u+Math.imul($,Ce)|0,u=u+Math.imul(m,at)|0,l=l+Math.imul(m,Ce)|0,E=E+Math.imul(Z,Ot)|0,u=u+Math.imul(Z,tt)|0,u=u+Math.imul(F,Ot)|0,l=l+Math.imul(F,tt)|0;var zi=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(zi>>>26)|0,zi&=67108863,E=Math.imul(ke,dt),u=Math.imul(ke,$e),u=u+Math.imul(Pe,dt)|0,l=Math.imul(Pe,$e),E=E+Math.imul(Fe,Mt)|0,u=u+Math.imul(Fe,Ee)|0,u=u+Math.imul(_e,Mt)|0,l=l+Math.imul(_e,Ee)|0,E=E+Math.imul(Ge,Qe)|0,u=u+Math.imul(Ge,Ie)|0,u=u+Math.imul(ye,Qe)|0,l=l+Math.imul(ye,Ie)|0,E=E+Math.imul(Le,He)|0,u=u+Math.imul(Le,Re)|0,u=u+Math.imul(Ae,He)|0,l=l+Math.imul(Ae,Re)|0,E=E+Math.imul(nt,Ye)|0,u=u+Math.imul(nt,Ne)|0,u=u+Math.imul(Se,Ye)|0,l=l+Math.imul(Se,Ne)|0,E=E+Math.imul(ve,et)|0,u=u+Math.imul(ve,Me)|0,u=u+Math.imul(be,et)|0,l=l+Math.imul(be,Me)|0,E=E+Math.imul(re,at)|0,u=u+Math.imul(re,Ce)|0,u=u+Math.imul(he,at)|0,l=l+Math.imul(he,Ce)|0,E=E+Math.imul($,Ot)|0,u=u+Math.imul($,tt)|0,u=u+Math.imul(m,Ot)|0,l=l+Math.imul(m,tt)|0;var Ui=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,E=Math.imul(ke,Mt),u=Math.imul(ke,Ee),u=u+Math.imul(Pe,Mt)|0,l=Math.imul(Pe,Ee),E=E+Math.imul(Fe,Qe)|0,u=u+Math.imul(Fe,Ie)|0,u=u+Math.imul(_e,Qe)|0,l=l+Math.imul(_e,Ie)|0,E=E+Math.imul(Ge,He)|0,u=u+Math.imul(Ge,Re)|0,u=u+Math.imul(ye,He)|0,l=l+Math.imul(ye,Re)|0,E=E+Math.imul(Le,Ye)|0,u=u+Math.imul(Le,Ne)|0,u=u+Math.imul(Ae,Ye)|0,l=l+Math.imul(Ae,Ne)|0,E=E+Math.imul(nt,et)|0,u=u+Math.imul(nt,Me)|0,u=u+Math.imul(Se,et)|0,l=l+Math.imul(Se,Me)|0,E=E+Math.imul(ve,at)|0,u=u+Math.imul(ve,Ce)|0,u=u+Math.imul(be,at)|0,l=l+Math.imul(be,Ce)|0,E=E+Math.imul(re,Ot)|0,u=u+Math.imul(re,tt)|0,u=u+Math.imul(he,Ot)|0,l=l+Math.imul(he,tt)|0;var Gr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,E=Math.imul(ke,Qe),u=Math.imul(ke,Ie),u=u+Math.imul(Pe,Qe)|0,l=Math.imul(Pe,Ie),E=E+Math.imul(Fe,He)|0,u=u+Math.imul(Fe,Re)|0,u=u+Math.imul(_e,He)|0,l=l+Math.imul(_e,Re)|0,E=E+Math.imul(Ge,Ye)|0,u=u+Math.imul(Ge,Ne)|0,u=u+Math.imul(ye,Ye)|0,l=l+Math.imul(ye,Ne)|0,E=E+Math.imul(Le,et)|0,u=u+Math.imul(Le,Me)|0,u=u+Math.imul(Ae,et)|0,l=l+Math.imul(Ae,Me)|0,E=E+Math.imul(nt,at)|0,u=u+Math.imul(nt,Ce)|0,u=u+Math.imul(Se,at)|0,l=l+Math.imul(Se,Ce)|0,E=E+Math.imul(ve,Ot)|0,u=u+Math.imul(ve,tt)|0,u=u+Math.imul(be,Ot)|0,l=l+Math.imul(be,tt)|0;var mi=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(mi>>>26)|0,mi&=67108863,E=Math.imul(ke,He),u=Math.imul(ke,Re),u=u+Math.imul(Pe,He)|0,l=Math.imul(Pe,Re),E=E+Math.imul(Fe,Ye)|0,u=u+Math.imul(Fe,Ne)|0,u=u+Math.imul(_e,Ye)|0,l=l+Math.imul(_e,Ne)|0,E=E+Math.imul(Ge,et)|0,u=u+Math.imul(Ge,Me)|0,u=u+Math.imul(ye,et)|0,l=l+Math.imul(ye,Me)|0,E=E+Math.imul(Le,at)|0,u=u+Math.imul(Le,Ce)|0,u=u+Math.imul(Ae,at)|0,l=l+Math.imul(Ae,Ce)|0,E=E+Math.imul(nt,Ot)|0,u=u+Math.imul(nt,tt)|0,u=u+Math.imul(Se,Ot)|0,l=l+Math.imul(Se,tt)|0;var yi=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(yi>>>26)|0,yi&=67108863,E=Math.imul(ke,Ye),u=Math.imul(ke,Ne),u=u+Math.imul(Pe,Ye)|0,l=Math.imul(Pe,Ne),E=E+Math.imul(Fe,et)|0,u=u+Math.imul(Fe,Me)|0,u=u+Math.imul(_e,et)|0,l=l+Math.imul(_e,Me)|0,E=E+Math.imul(Ge,at)|0,u=u+Math.imul(Ge,Ce)|0,u=u+Math.imul(ye,at)|0,l=l+Math.imul(ye,Ce)|0,E=E+Math.imul(Le,Ot)|0,u=u+Math.imul(Le,tt)|0,u=u+Math.imul(Ae,Ot)|0,l=l+Math.imul(Ae,tt)|0;var fr=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(fr>>>26)|0,fr&=67108863,E=Math.imul(ke,et),u=Math.imul(ke,Me),u=u+Math.imul(Pe,et)|0,l=Math.imul(Pe,Me),E=E+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,Ce)|0,u=u+Math.imul(_e,at)|0,l=l+Math.imul(_e,Ce)|0,E=E+Math.imul(Ge,Ot)|0,u=u+Math.imul(Ge,tt)|0,u=u+Math.imul(ye,Ot)|0,l=l+Math.imul(ye,tt)|0;var ji=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(ji>>>26)|0,ji&=67108863,E=Math.imul(ke,at),u=Math.imul(ke,Ce),u=u+Math.imul(Pe,at)|0,l=Math.imul(Pe,Ce),E=E+Math.imul(Fe,Ot)|0,u=u+Math.imul(Fe,tt)|0,u=u+Math.imul(_e,Ot)|0,l=l+Math.imul(_e,tt)|0;var Ki=(x+E|0)+((u&8191)<<13)|0;x=(l+(u>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,E=Math.imul(ke,Ot),u=Math.imul(ke,tt),u=u+Math.imul(Pe,Ot)|0,l=Math.imul(Pe,tt);var Hi=(x+E|0)+((u&8191)<<13)|0;return x=(l+(u>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,S[0]=bt,S[1]=xr,S[2]=Pr,S[3]=Rr,S[4]=Nr,S[5]=Cr,S[6]=Yt,S[7]=Hr,S[8]=$i,S[9]=Vr,S[10]=zi,S[11]=Ui,S[12]=Gr,S[13]=mi,S[14]=yi,S[15]=fr,S[16]=ji,S[17]=Ki,S[18]=Hi,x!==0&&(S[19]=x,d.length++),d};Math.imul||(j=D);function G(L,v,c){c.negative=v.negative^L.negative,c.length=L.length+v.length;for(var d=0,g=0,_=0;_<c.length-1;_++){var S=g;g=0;for(var x=d&67108863,E=Math.min(_,v.length-1),u=Math.max(0,_-L.length+1);u<=E;u++){var l=_-u,R=L.words[l]|0,ie=v.words[u]|0,se=R*ie,I=se&67108863;S=S+(se/67108864|0)|0,I=I+x|0,x=I&67108863,S=S+(I>>>26)|0,g+=S>>>26,S&=67108863}c.words[_]=x,d=S,S=g}return d!==0?c.words[_]=d:c.length--,c.strip()}function X(L,v,c){var d=new z;return d.mulp(L,v,c)}a.prototype.mulTo=function(v,c){var d,g=this.length+v.length;return this.length===10&&v.length===10?d=j(this,v,c):g<63?d=D(this,v,c):g<1024?d=G(this,v,c):d=X(this,v,c),d};function z(L,v){this.x=L,this.y=v}z.prototype.makeRBT=function(v){for(var c=new Array(v),d=a.prototype._countBits(v)-1,g=0;g<v;g++)c[g]=this.revBin(g,d,v);return c},z.prototype.revBin=function(v,c,d){if(v===0||v===d-1)return v;for(var g=0,_=0;_<c;_++)g|=(v&1)<<c-_-1,v>>=1;return g},z.prototype.permute=function(v,c,d,g,_,S){for(var x=0;x<S;x++)g[x]=c[v[x]],_[x]=d[v[x]]},z.prototype.transform=function(v,c,d,g,_,S){this.permute(S,v,c,d,g,_);for(var x=1;x<_;x<<=1)for(var E=x<<1,u=Math.cos(2*Math.PI/E),l=Math.sin(2*Math.PI/E),R=0;R<_;R+=E)for(var ie=u,se=l,I=0;I<x;I++){var Z=d[R+I],F=g[R+I],k=d[R+I+x],$=g[R+I+x],m=ie*k-se*$;$=ie*$+se*k,k=m,d[R+I]=Z+k,g[R+I]=F+$,d[R+I+x]=Z-k,g[R+I+x]=F-$,I!==E&&(m=u*ie-l*se,se=u*se+l*ie,ie=m)}},z.prototype.guessLen13b=function(v,c){var d=Math.max(c,v)|1,g=d&1,_=0;for(d=d/2|0;d;d=d>>>1)_++;return 1<<_+1+g},z.prototype.conjugate=function(v,c,d){if(!(d<=1))for(var g=0;g<d/2;g++){var _=v[g];v[g]=v[d-g-1],v[d-g-1]=_,_=c[g],c[g]=-c[d-g-1],c[d-g-1]=-_}},z.prototype.normalize13b=function(v,c){for(var d=0,g=0;g<c/2;g++){var _=Math.round(v[2*g+1]/c)*8192+Math.round(v[2*g]/c)+d;v[g]=_&67108863,_<67108864?d=0:d=_/67108864|0}return v},z.prototype.convert13b=function(v,c,d,g){for(var _=0,S=0;S<c;S++)_=_+(v[S]|0),d[2*S]=_&8191,_=_>>>13,d[2*S+1]=_&8191,_=_>>>13;for(S=2*c;S<g;++S)d[S]=0;i(_===0),i((_&-8192)===0)},z.prototype.stub=function(v){for(var c=new Array(v),d=0;d<v;d++)c[d]=0;return c},z.prototype.mulp=function(v,c,d){var g=2*this.guessLen13b(v.length,c.length),_=this.makeRBT(g),S=this.stub(g),x=new Array(g),E=new Array(g),u=new Array(g),l=new Array(g),R=new Array(g),ie=new Array(g),se=d.words;se.length=g,this.convert13b(v.words,v.length,x,g),this.convert13b(c.words,c.length,l,g),this.transform(x,S,E,u,g,_),this.transform(l,S,R,ie,g,_);for(var I=0;I<g;I++){var Z=E[I]*R[I]-u[I]*ie[I];u[I]=E[I]*ie[I]+u[I]*R[I],E[I]=Z}return this.conjugate(E,u,g),this.transform(E,u,se,S,g,_),this.conjugate(se,S,g),this.normalize13b(se,g),d.negative=v.negative^c.negative,d.length=v.length+c.length,d.strip()},a.prototype.mul=function(v){var c=new a(null);return c.words=new Array(this.length+v.length),this.mulTo(v,c)},a.prototype.mulf=function(v){var c=new a(null);return c.words=new Array(this.length+v.length),X(this,v,c)},a.prototype.imul=function(v){return this.clone().mulTo(v,this)},a.prototype.imuln=function(v){i(typeof v=="number"),i(v<67108864);for(var c=0,d=0;d<this.length;d++){var g=(this.words[d]|0)*v,_=(g&67108863)+(c&67108863);c>>=26,c+=g/67108864|0,c+=_>>>26,this.words[d]=_&67108863}return c!==0&&(this.words[d]=c,this.length++),this},a.prototype.muln=function(v){return this.clone().imuln(v)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(v){var c=O(v);if(c.length===0)return new a(1);for(var d=this,g=0;g<c.length&&c[g]===0;g++,d=d.sqr());if(++g<c.length)for(var _=d.sqr();g<c.length;g++,_=_.sqr())c[g]!==0&&(d=d.mul(_));return d},a.prototype.iushln=function(v){i(typeof v=="number"&&v>=0);var c=v%26,d=(v-c)/26,g=67108863>>>26-c<<26-c,_;if(c!==0){var S=0;for(_=0;_<this.length;_++){var x=this.words[_]&g,E=(this.words[_]|0)-x<<c;this.words[_]=E|S,S=x>>>26-c}S&&(this.words[_]=S,this.length++)}if(d!==0){for(_=this.length-1;_>=0;_--)this.words[_+d]=this.words[_];for(_=0;_<d;_++)this.words[_]=0;this.length+=d}return this.strip()},a.prototype.ishln=function(v){return i(this.negative===0),this.iushln(v)},a.prototype.iushrn=function(v,c,d){i(typeof v=="number"&&v>=0);var g;c?g=(c-c%26)/26:g=0;var _=v%26,S=Math.min((v-_)/26,this.length),x=67108863^67108863>>>_<<_,E=d;if(g-=S,g=Math.max(0,g),E){for(var u=0;u<S;u++)E.words[u]=this.words[u];E.length=S}if(S!==0)if(this.length>S)for(this.length-=S,u=0;u<this.length;u++)this.words[u]=this.words[u+S];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=g);u--){var R=this.words[u]|0;this.words[u]=l<<26-_|R>>>_,l=R&x}return E&&l!==0&&(E.words[E.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(v,c,d){return i(this.negative===0),this.iushrn(v,c,d)},a.prototype.shln=function(v){return this.clone().ishln(v)},a.prototype.ushln=function(v){return this.clone().iushln(v)},a.prototype.shrn=function(v){return this.clone().ishrn(v)},a.prototype.ushrn=function(v){return this.clone().iushrn(v)},a.prototype.testn=function(v){i(typeof v=="number"&&v>=0);var c=v%26,d=(v-c)/26,g=1<<c;if(this.length<=d)return!1;var _=this.words[d];return!!(_&g)},a.prototype.imaskn=function(v){i(typeof v=="number"&&v>=0);var c=v%26,d=(v-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=d)return this;if(c!==0&&d++,this.length=Math.min(d,this.length),c!==0){var g=67108863^67108863>>>c<<c;this.words[this.length-1]&=g}return this.strip()},a.prototype.maskn=function(v){return this.clone().imaskn(v)},a.prototype.iaddn=function(v){return i(typeof v=="number"),i(v<67108864),v<0?this.isubn(-v):this.negative!==0?this.length===1&&(this.words[0]|0)<v?(this.words[0]=v-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(v),this.negative=1,this):this._iaddn(v)},a.prototype._iaddn=function(v){this.words[0]+=v;for(var c=0;c<this.length&&this.words[c]>=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},a.prototype.isubn=function(v){if(i(typeof v=="number"),i(v<67108864),v<0)return this.iaddn(-v);if(this.negative!==0)return this.negative=0,this.iaddn(v),this.negative=1,this;if(this.words[0]-=v,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c<this.length&&this.words[c]<0;c++)this.words[c]+=67108864,this.words[c+1]-=1;return this.strip()},a.prototype.addn=function(v){return this.clone().iaddn(v)},a.prototype.subn=function(v){return this.clone().isubn(v)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(v,c,d){var g=v.length+d,_;this._expand(g);var S,x=0;for(_=0;_<v.length;_++){S=(this.words[_+d]|0)+x;var E=(v.words[_]|0)*c;S-=E&67108863,x=(S>>26)-(E/67108864|0),this.words[_+d]=S&67108863}for(;_<this.length-d;_++)S=(this.words[_+d]|0)+x,x=S>>26,this.words[_+d]=S&67108863;if(x===0)return this.strip();for(i(x===-1),x=0,_=0;_<this.length;_++)S=-(this.words[_]|0)+x,x=S>>26,this.words[_]=S&67108863;return this.negative=1,this.strip()},a.prototype._wordDiv=function(v,c){var d=this.length-v.length,g=this.clone(),_=v,S=_.words[_.length-1]|0,x=this._countBits(S);d=26-x,d!==0&&(_=_.ushln(d),g.iushln(d),S=_.words[_.length-1]|0);var E=g.length-_.length,u;if(c!=="mod"){u=new a(null),u.length=E+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var R=g.clone()._ishlnsubmul(_,1,E);R.negative===0&&(g=R,u&&(u.words[E]=1));for(var ie=E-1;ie>=0;ie--){var se=(g.words[_.length+ie]|0)*67108864+(g.words[_.length+ie-1]|0);for(se=Math.min(se/S|0,67108863),g._ishlnsubmul(_,se,ie);g.negative!==0;)se--,g.negative=0,g._ishlnsubmul(_,1,ie),g.isZero()||(g.negative^=1);u&&(u.words[ie]=se)}return u&&u.strip(),g.strip(),c!=="div"&&d!==0&&g.iushrn(d),{div:u||null,mod:g}},a.prototype.divmod=function(v,c,d){if(i(!v.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var g,_,S;return this.negative!==0&&v.negative===0?(S=this.neg().divmod(v,c),c!=="mod"&&(g=S.div.neg()),c!=="div"&&(_=S.mod.neg(),d&&_.negative!==0&&_.iadd(v)),{div:g,mod:_}):this.negative===0&&v.negative!==0?(S=this.divmod(v.neg(),c),c!=="mod"&&(g=S.div.neg()),{div:g,mod:S.mod}):this.negative&v.negative?(S=this.neg().divmod(v.neg(),c),c!=="div"&&(_=S.mod.neg(),d&&_.negative!==0&&_.isub(v)),{div:S.div,mod:_}):v.length>this.length||this.cmp(v)<0?{div:new a(0),mod:this}:v.length===1?c==="div"?{div:this.divn(v.words[0]),mod:null}:c==="mod"?{div:null,mod:new a(this.modn(v.words[0]))}:{div:this.divn(v.words[0]),mod:new a(this.modn(v.words[0]))}:this._wordDiv(v,c)},a.prototype.div=function(v){return this.divmod(v,"div",!1).div},a.prototype.mod=function(v){return this.divmod(v,"mod",!1).mod},a.prototype.umod=function(v){return this.divmod(v,"mod",!0).mod},a.prototype.divRound=function(v){var c=this.divmod(v);if(c.mod.isZero())return c.div;var d=c.div.negative!==0?c.mod.isub(v):c.mod,g=v.ushrn(1),_=v.andln(1),S=d.cmp(g);return S<0||_===1&&S===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},a.prototype.modn=function(v){i(v<=67108863);for(var c=(1<<26)%v,d=0,g=this.length-1;g>=0;g--)d=(c*d+(this.words[g]|0))%v;return d},a.prototype.idivn=function(v){i(v<=67108863);for(var c=0,d=this.length-1;d>=0;d--){var g=(this.words[d]|0)+c*67108864;this.words[d]=g/v|0,c=g%v}return this.strip()},a.prototype.divn=function(v){return this.clone().idivn(v)},a.prototype.egcd=function(v){i(v.negative===0),i(!v.isZero());var c=this,d=v.clone();c.negative!==0?c=c.umod(v):c=c.clone();for(var g=new a(1),_=new a(0),S=new a(0),x=new a(1),E=0;c.isEven()&&d.isEven();)c.iushrn(1),d.iushrn(1),++E;for(var u=d.clone(),l=c.clone();!c.isZero();){for(var R=0,ie=1;!(c.words[0]&ie)&&R<26;++R,ie<<=1);if(R>0)for(c.iushrn(R);R-- >0;)(g.isOdd()||_.isOdd())&&(g.iadd(u),_.isub(l)),g.iushrn(1),_.iushrn(1);for(var se=0,I=1;!(d.words[0]&I)&&se<26;++se,I<<=1);if(se>0)for(d.iushrn(se);se-- >0;)(S.isOdd()||x.isOdd())&&(S.iadd(u),x.isub(l)),S.iushrn(1),x.iushrn(1);c.cmp(d)>=0?(c.isub(d),g.isub(S),_.isub(x)):(d.isub(c),S.isub(g),x.isub(_))}return{a:S,b:x,gcd:d.iushln(E)}},a.prototype._invmp=function(v){i(v.negative===0),i(!v.isZero());var c=this,d=v.clone();c.negative!==0?c=c.umod(v):c=c.clone();for(var g=new a(1),_=new a(0),S=d.clone();c.cmpn(1)>0&&d.cmpn(1)>0;){for(var x=0,E=1;!(c.words[0]&E)&&x<26;++x,E<<=1);if(x>0)for(c.iushrn(x);x-- >0;)g.isOdd()&&g.iadd(S),g.iushrn(1);for(var u=0,l=1;!(d.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(d.iushrn(u);u-- >0;)_.isOdd()&&_.iadd(S),_.iushrn(1);c.cmp(d)>=0?(c.isub(d),g.isub(_)):(d.isub(c),_.isub(g))}var R;return c.cmpn(1)===0?R=g:R=_,R.cmpn(0)<0&&R.iadd(v),R},a.prototype.gcd=function(v){if(this.isZero())return v.abs();if(v.isZero())return this.abs();var c=this.clone(),d=v.clone();c.negative=0,d.negative=0;for(var g=0;c.isEven()&&d.isEven();g++)c.iushrn(1),d.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;d.isEven();)d.iushrn(1);var _=c.cmp(d);if(_<0){var S=c;c=d,d=S}else if(_===0||d.cmpn(1)===0)break;c.isub(d)}while(!0);return d.iushln(g)},a.prototype.invm=function(v){return this.egcd(v).a.umod(v)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(v){return this.words[0]&v},a.prototype.bincn=function(v){i(typeof v=="number");var c=v%26,d=(v-c)/26,g=1<<c;if(this.length<=d)return this._expand(d+1),this.words[d]|=g,this;for(var _=g,S=d;_!==0&&S<this.length;S++){var x=this.words[S]|0;x+=_,_=x>>>26,x&=67108863,this.words[S]=x}return _!==0&&(this.words[S]=_,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(v){var c=v<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this.strip();var d;if(this.length>1)d=1;else{c&&(v=-v),i(v<=67108863,"Number is too big");var g=this.words[0]|0;d=g===v?0:g<v?-1:1}return this.negative!==0?-d|0:d},a.prototype.cmp=function(v){if(this.negative!==0&&v.negative===0)return-1;if(this.negative===0&&v.negative!==0)return 1;var c=this.ucmp(v);return this.negative!==0?-c|0:c},a.prototype.ucmp=function(v){if(this.length>v.length)return 1;if(this.length<v.length)return-1;for(var c=0,d=this.length-1;d>=0;d--){var g=this.words[d]|0,_=v.words[d]|0;if(g!==_){g<_?c=-1:g>_&&(c=1);break}}return c},a.prototype.gtn=function(v){return this.cmpn(v)===1},a.prototype.gt=function(v){return this.cmp(v)===1},a.prototype.gten=function(v){return this.cmpn(v)>=0},a.prototype.gte=function(v){return this.cmp(v)>=0},a.prototype.ltn=function(v){return this.cmpn(v)===-1},a.prototype.lt=function(v){return this.cmp(v)===-1},a.prototype.lten=function(v){return this.cmpn(v)<=0},a.prototype.lte=function(v){return this.cmp(v)<=0},a.prototype.eqn=function(v){return this.cmpn(v)===0},a.prototype.eq=function(v){return this.cmp(v)===0},a.red=function(v){return new ge(v)},a.prototype.toRed=function(v){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),v.convertTo(this)._forceRed(v)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(v){return this.red=v,this},a.prototype.forceRed=function(v){return i(!this.red,"Already a number in reduction context"),this._forceRed(v)},a.prototype.redAdd=function(v){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,v)},a.prototype.redIAdd=function(v){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,v)},a.prototype.redSub=function(v){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,v)},a.prototype.redISub=function(v){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,v)},a.prototype.redShl=function(v){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,v)},a.prototype.redMul=function(v){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,v),this.red.mul(this,v)},a.prototype.redIMul=function(v){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,v),this.red.imul(this,v)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(v){return i(this.red&&!v.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,v)};var Q={k256:null,p224:null,p192:null,p25519:null};function V(L,v){this.name=L,this.p=new a(v,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var v=new a(null);return v.words=new Array(Math.ceil(this.n/13)),v},V.prototype.ireduce=function(v){var c=v,d;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),d=c.bitLength();while(d>this.n);var g=d<this.n?-1:c.ucmp(this.p);return g===0?(c.words[0]=0,c.length=1):g>0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},V.prototype.split=function(v,c){v.iushrn(this.n,0,c)},V.prototype.imulK=function(v){return v.imul(this.k)};function H(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(H,V),H.prototype.split=function(v,c){for(var d=4194303,g=Math.min(v.length,9),_=0;_<g;_++)c.words[_]=v.words[_];if(c.length=g,v.length<=9){v.words[0]=0,v.length=1;return}var S=v.words[9];for(c.words[c.length++]=S&d,_=10;_<v.length;_++){var x=v.words[_]|0;v.words[_-10]=(x&d)<<4|S>>>22,S=x}S>>>=22,v.words[_-10]=S,S===0&&v.length>10?v.length-=10:v.length-=9},H.prototype.imulK=function(v){v.words[v.length]=0,v.words[v.length+1]=0,v.length+=2;for(var c=0,d=0;d<v.length;d++){var g=v.words[d]|0;c+=g*977,v.words[d]=c&67108863,c=g*64+(c/67108864|0)}return v.words[v.length-1]===0&&(v.length--,v.words[v.length-1]===0&&v.length--),v};function ee(){V.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ee,V);function oe(){V.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(oe,V);function ne(){V.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ne,V),ne.prototype.imulK=function(v){for(var c=0,d=0;d<v.length;d++){var g=(v.words[d]|0)*19+c,_=g&67108863;g>>>=26,v.words[d]=_,c=g}return c!==0&&(v.words[v.length++]=c),v},a._prime=function(v){if(Q[v])return Q[v];var c;if(v==="k256")c=new H;else if(v==="p224")c=new ee;else if(v==="p192")c=new oe;else if(v==="p25519")c=new ne;else throw new Error("Unknown prime "+v);return Q[v]=c,c};function ge(L){if(typeof L=="string"){var v=a._prime(L);this.m=v.p,this.prime=v}else i(L.gtn(1),"modulus must be greater than 1"),this.m=L,this.prime=null}ge.prototype._verify1=function(v){i(v.negative===0,"red works only with positives"),i(v.red,"red works only with red numbers")},ge.prototype._verify2=function(v,c){i((v.negative|c.negative)===0,"red works only with positives"),i(v.red&&v.red===c.red,"red works only with red numbers")},ge.prototype.imod=function(v){return this.prime?this.prime.ireduce(v)._forceRed(this):v.umod(this.m)._forceRed(this)},ge.prototype.neg=function(v){return v.isZero()?v.clone():this.m.sub(v)._forceRed(this)},ge.prototype.add=function(v,c){this._verify2(v,c);var d=v.add(c);return d.cmp(this.m)>=0&&d.isub(this.m),d._forceRed(this)},ge.prototype.iadd=function(v,c){this._verify2(v,c);var d=v.iadd(c);return d.cmp(this.m)>=0&&d.isub(this.m),d},ge.prototype.sub=function(v,c){this._verify2(v,c);var d=v.sub(c);return d.cmpn(0)<0&&d.iadd(this.m),d._forceRed(this)},ge.prototype.isub=function(v,c){this._verify2(v,c);var d=v.isub(c);return d.cmpn(0)<0&&d.iadd(this.m),d},ge.prototype.shl=function(v,c){return this._verify1(v),this.imod(v.ushln(c))},ge.prototype.imul=function(v,c){return this._verify2(v,c),this.imod(v.imul(c))},ge.prototype.mul=function(v,c){return this._verify2(v,c),this.imod(v.mul(c))},ge.prototype.isqr=function(v){return this.imul(v,v.clone())},ge.prototype.sqr=function(v){return this.mul(v,v)},ge.prototype.sqrt=function(v){if(v.isZero())return v.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var d=this.m.add(new a(1)).iushrn(2);return this.pow(v,d)}for(var g=this.m.subn(1),_=0;!g.isZero()&&g.andln(1)===0;)_++,g.iushrn(1);i(!g.isZero());var S=new a(1).toRed(this),x=S.redNeg(),E=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);this.pow(u,E).cmp(x)!==0;)u.redIAdd(x);for(var l=this.pow(u,g),R=this.pow(v,g.addn(1).iushrn(1)),ie=this.pow(v,g),se=_;ie.cmp(S)!==0;){for(var I=ie,Z=0;I.cmp(S)!==0;Z++)I=I.redSqr();i(Z<se);var F=this.pow(l,new a(1).iushln(se-Z-1));R=R.redMul(F),l=F.redSqr(),ie=ie.redMul(l),se=Z}return R},ge.prototype.invm=function(v){var c=v._invmp(this.m);return c.negative!==0?(c.negative=0,this.imod(c).redNeg()):this.imod(c)},ge.prototype.pow=function(v,c){if(c.isZero())return new a(1).toRed(this);if(c.cmpn(1)===0)return v.clone();var d=4,g=new Array(1<<d);g[0]=new a(1).toRed(this),g[1]=v;for(var _=2;_<g.length;_++)g[_]=this.mul(g[_-1],v);var S=g[0],x=0,E=0,u=c.bitLength()%26;for(u===0&&(u=26),_=c.length-1;_>=0;_--){for(var l=c.words[_],R=u-1;R>=0;R--){var ie=l>>R&1;if(S!==g[0]&&(S=this.sqr(S)),ie===0&&x===0){E=0;continue}x<<=1,x|=ie,E++,!(E!==d&&(_!==0||R!==0))&&(S=this.mul(S,g[x]),E=0,x=0)}u=26}return S},ge.prototype.convertTo=function(v){var c=v.umod(this.m);return c===v?c.clone():c},ge.prototype.convertFrom=function(v){var c=v.clone();return c.red=null,c},a.mont=function(v){return new ht(v)};function ht(L){ge.call(this,L),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}s(ht,ge),ht.prototype.convertTo=function(v){return this.imod(v.ushln(this.shift))},ht.prototype.convertFrom=function(v){var c=this.imod(v.mul(this.rinv));return c.red=null,c},ht.prototype.imul=function(v,c){if(v.isZero()||c.isZero())return v.words[0]=0,v.length=1,v;var d=v.imul(c),g=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=d.isub(g).iushrn(this.shift),S=_;return _.cmp(this.m)>=0?S=_.isub(this.m):_.cmpn(0)<0&&(S=_.iadd(this.m)),S._forceRed(this)},ht.prototype.mul=function(v,c){if(v.isZero()||c.isZero())return new a(0)._forceRed(this);var d=v.mul(c),g=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=d.isub(g).iushrn(this.shift),S=_;return _.cmp(this.m)>=0?S=_.isub(this.m):_.cmpn(0)<0&&(S=_.iadd(this.m)),S._forceRed(this)},ht.prototype.invm=function(v){var c=this.imod(v._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,go)})(hd);var Wn=hd.exports,ud={};(function(r){var e=r;function t(a,f){if(Array.isArray(a))return a.slice();if(!a)return[];var p=[];if(typeof a!="string"){for(var w=0;w<a.length;w++)p[w]=a[w]|0;return p}if(f==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var w=0;w<a.length;w+=2)p.push(parseInt(a[w]+a[w+1],16))}else for(var w=0;w<a.length;w++){var b=a.charCodeAt(w),A=b>>8,M=b&255;A?p.push(A,M):p.push(M)}return p}e.toArray=t;function i(a){return a.length===1?"0"+a:a}e.zero2=i;function s(a){for(var f="",p=0;p<a.length;p++)f+=i(a[p].toString(16));return f}e.toHex=s,e.encode=function(f,p){return p==="hex"?s(f):f}})(ud);(function(r){var e=r,t=Wn,i=G1,s=ud;e.assert=i,e.toArray=s.toArray,e.zero2=s.zero2,e.toHex=s.toHex,e.encode=s.encode;function a(A,M,C){var O=new Array(Math.max(A.bitLength(),C)+1),D;for(D=0;D<O.length;D+=1)O[D]=0;var j=1<<M+1,G=A.clone();for(D=0;D<O.length;D++){var X,z=G.andln(j-1);G.isOdd()?(z>(j>>1)-1?X=(j>>1)-z:X=z,G.isubn(X)):X=0,O[D]=X,G.iushrn(1)}return O}e.getNAF=a;function f(A,M){var C=[[],[]];A=A.clone(),M=M.clone();for(var O=0,D=0,j;A.cmpn(-O)>0||M.cmpn(-D)>0;){var G=A.andln(3)+O&3,X=M.andln(3)+D&3;G===3&&(G=-1),X===3&&(X=-1);var z;G&1?(j=A.andln(7)+O&7,(j===3||j===5)&&X===2?z=-G:z=G):z=0,C[0].push(z);var Q;X&1?(j=M.andln(7)+D&7,(j===3||j===5)&&G===2?Q=-X:Q=X):Q=0,C[1].push(Q),2*O===z+1&&(O=1-O),2*D===Q+1&&(D=1-D),A.iushrn(1),M.iushrn(1)}return C}e.getJSF=f;function p(A,M,C){var O="_"+M;A.prototype[M]=function(){return this[O]!==void 0?this[O]:this[O]=C.call(this)}}e.cachedProperty=p;function w(A){return typeof A=="string"?e.toArray(A,"hex"):A}e.parseBytes=w;function b(A){return new t(A,"hex","le")}e.intFromLE=b})(bi);var dd={exports:{}},au;dd.exports=function(e){return au||(au=new ls(null)),au.generate(e)};function ls(r){this.rand=r}dd.exports.Rand=ls;ls.prototype.generate=function(e){return this._rand(e)};ls.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t};if(typeof self=="object")self.crypto&&self.crypto.getRandomValues?ls.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?ls.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:typeof window=="object"&&(ls.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var fp=V1;if(typeof fp.randomBytes!="function")throw new Error("Not supported");ls.prototype._rand=function(e){return fp.randomBytes(e)}}catch{}var yg=dd.exports,ld={},Cs=Wn,To=bi,vf=To.getNAF,f8=To.getJSF,bf=To.assert;function vs(r,e){this.type=r,this.p=new Cs(e.p,16),this.red=e.prime?Cs.red(e.prime):Cs.mont(this.p),this.zero=new Cs(0).toRed(this.red),this.one=new Cs(1).toRed(this.red),this.two=new Cs(2).toRed(this.red),this.n=e.n&&new Cs(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Df=vs;vs.prototype.point=function(){throw new Error("Not implemented")};vs.prototype.validate=function(){throw new Error("Not implemented")};vs.prototype._fixedNafMul=function(e,t){bf(e.precomputed);var i=e._getDoubles(),s=vf(t,1,this._bitLength),a=(1<<i.step+1)-(i.step%2===0?2:1);a/=3;var f=[],p,w;for(p=0;p<s.length;p+=i.step){w=0;for(var b=p+i.step-1;b>=p;b--)w=(w<<1)+s[b];f.push(w)}for(var A=this.jpoint(null,null,null),M=this.jpoint(null,null,null),C=a;C>0;C--){for(p=0;p<f.length;p++)w=f[p],w===C?M=M.mixedAdd(i.points[p]):w===-C&&(M=M.mixedAdd(i.points[p].neg()));A=A.add(M)}return A.toP()};vs.prototype._wnafMul=function(e,t){var i=4,s=e._getNAFPoints(i);i=s.wnd;for(var a=s.points,f=vf(t,i,this._bitLength),p=this.jpoint(null,null,null),w=f.length-1;w>=0;w--){for(var b=0;w>=0&&f[w]===0;w--)b++;if(w>=0&&b++,p=p.dblp(b),w<0)break;var A=f[w];bf(A!==0),e.type==="affine"?A>0?p=p.mixedAdd(a[A-1>>1]):p=p.mixedAdd(a[-A-1>>1].neg()):A>0?p=p.add(a[A-1>>1]):p=p.add(a[-A-1>>1].neg())}return e.type==="affine"?p.toP():p};vs.prototype._wnafMulAdd=function(e,t,i,s,a){var f=this._wnafT1,p=this._wnafT2,w=this._wnafT3,b=0,A,M,C;for(A=0;A<s;A++){C=t[A];var O=C._getNAFPoints(e);f[A]=O.wnd,p[A]=O.points}for(A=s-1;A>=1;A-=2){var D=A-1,j=A;if(f[D]!==1||f[j]!==1){w[D]=vf(i[D],f[D],this._bitLength),w[j]=vf(i[j],f[j],this._bitLength),b=Math.max(w[D].length,b),b=Math.max(w[j].length,b);continue}var G=[t[D],null,null,t[j]];t[D].y.cmp(t[j].y)===0?(G[1]=t[D].add(t[j]),G[2]=t[D].toJ().mixedAdd(t[j].neg())):t[D].y.cmp(t[j].y.redNeg())===0?(G[1]=t[D].toJ().mixedAdd(t[j]),G[2]=t[D].add(t[j].neg())):(G[1]=t[D].toJ().mixedAdd(t[j]),G[2]=t[D].toJ().mixedAdd(t[j].neg()));var X=[-3,-1,-5,-7,0,7,5,1,3],z=f8(i[D],i[j]);for(b=Math.max(z[0].length,b),w[D]=new Array(b),w[j]=new Array(b),M=0;M<b;M++){var Q=z[0][M]|0,V=z[1][M]|0;w[D][M]=X[(Q+1)*3+(V+1)],w[j][M]=0,p[D]=G}}var H=this.jpoint(null,null,null),ee=this._wnafT4;for(A=b;A>=0;A--){for(var oe=0;A>=0;){var ne=!0;for(M=0;M<s;M++)ee[M]=w[M][A]|0,ee[M]!==0&&(ne=!1);if(!ne)break;oe++,A--}if(A>=0&&oe++,H=H.dblp(oe),A<0)break;for(M=0;M<s;M++){var ge=ee[M];ge!==0&&(ge>0?C=p[M][ge-1>>1]:ge<0&&(C=p[M][-ge-1>>1].neg()),C.type==="affine"?H=H.mixedAdd(C):H=H.add(C))}}for(A=0;A<s;A++)p[A]=null;return a?H:H.toP()};function Li(r,e){this.curve=r,this.type=e,this.precomputed=null}vs.BasePoint=Li;Li.prototype.eq=function(){throw new Error("Not implemented")};Li.prototype.validate=function(){return this.curve.validate(this)};vs.prototype.decodePoint=function(e,t){e=To.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?bf(e[e.length-1]%2===0):e[0]===7&&bf(e[e.length-1]%2===1);var s=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return s}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")};Li.prototype.encodeCompressed=function(e){return this.encode(e,!0)};Li.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))};Li.prototype.encode=function(e,t){return To.encode(this._encode(t),e)};Li.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this};Li.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1};Li.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],s=this,a=0;a<t;a+=e){for(var f=0;f<e;f++)s=s.dbl();i.push(s)}return{step:e,points:i}};Li.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,s=i===1?null:this.dbl(),a=1;a<i;a++)t[a]=t[a-1].add(s);return{wnd:e,points:t}};Li.prototype._getBeta=function(){return null};Li.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var h8=bi,tr=Wn,pd=td,Pa=Df,u8=h8.assert;function ki(r){Pa.call(this,"short",r),this.a=new tr(r.a,16).toRed(this.red),this.b=new tr(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}pd(ki,Pa);var d8=ki;ki.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new tr(e.beta,16).toRed(this.red);else{var s=this._getEndoRoots(this.p);t=s[0].cmp(s[1])<0?s[0]:s[1],t=t.toRed(this.red)}if(e.lambda)i=new tr(e.lambda,16);else{var a=this._getEndoRoots(this.n);this.g.mul(a[0]).x.cmp(this.g.x.redMul(t))===0?i=a[0]:(i=a[1],u8(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var f;return e.basis?f=e.basis.map(function(p){return{a:new tr(p.a,16),b:new tr(p.b,16)}}):f=this._getEndoBasis(i),{beta:t,lambda:i,basis:f}}};ki.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:tr.mont(e),i=new tr(2).toRed(t).redInvm(),s=i.redNeg(),a=new tr(3).toRed(t).redNeg().redSqrt().redMul(i),f=s.redAdd(a).fromRed(),p=s.redSub(a).fromRed();return[f,p]};ki.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,s=this.n.clone(),a=new tr(1),f=new tr(0),p=new tr(0),w=new tr(1),b,A,M,C,O,D,j,G=0,X,z;i.cmpn(0)!==0;){var Q=s.div(i);X=s.sub(Q.mul(i)),z=p.sub(Q.mul(a));var V=w.sub(Q.mul(f));if(!M&&X.cmp(t)<0)b=j.neg(),A=a,M=X.neg(),C=z;else if(M&&++G===2)break;j=X,s=i,i=X,p=a,a=z,w=f,f=V}O=X.neg(),D=z;var H=M.sqr().add(C.sqr()),ee=O.sqr().add(D.sqr());return ee.cmp(H)>=0&&(O=b,D=A),M.negative&&(M=M.neg(),C=C.neg()),O.negative&&(O=O.neg(),D=D.neg()),[{a:M,b:C},{a:O,b:D}]};ki.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],s=t[1],a=s.b.mul(e).divRound(this.n),f=i.b.neg().mul(e).divRound(this.n),p=a.mul(i.a),w=f.mul(s.a),b=a.mul(i.b),A=f.mul(s.b),M=e.sub(p).sub(w),C=b.add(A).neg();return{k1:M,k2:C}};ki.prototype.pointFromX=function(e,t){e=new tr(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),s=i.redSqrt();if(s.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var a=s.fromRed().isOdd();return(t&&!a||!t&&a)&&(s=s.redNeg()),this.point(e,s)};ki.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,s=this.a.redMul(t),a=t.redSqr().redMul(t).redIAdd(s).redIAdd(this.b);return i.redSqr().redISub(a).cmpn(0)===0};ki.prototype._endoWnafMulAdd=function(e,t,i){for(var s=this._endoWnafT1,a=this._endoWnafT2,f=0;f<e.length;f++){var p=this._endoSplit(t[f]),w=e[f],b=w._getBeta();p.k1.negative&&(p.k1.ineg(),w=w.neg(!0)),p.k2.negative&&(p.k2.ineg(),b=b.neg(!0)),s[f*2]=w,s[f*2+1]=b,a[f*2]=p.k1,a[f*2+1]=p.k2}for(var A=this._wnafMulAdd(1,s,a,f*2,i),M=0;M<f*2;M++)s[M]=null,a[M]=null;return A};function _r(r,e,t,i){Pa.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new tr(e,16),this.y=new tr(t,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)}pd(_r,Pa.BasePoint);ki.prototype.point=function(e,t,i){return new _r(this,e,t,i)};ki.prototype.pointFromJSON=function(e,t){return _r.fromJSON(this,e,t)};_r.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,s=function(a){return i.point(a.x.redMul(i.endo.beta),a.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(s)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(s)}}}return t}};_r.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]};_r.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var s=e.point(t[0],t[1],i);if(!t[2])return s;function a(p){return e.point(p[0],p[1],i)}var f=t[2];return s.precomputed={beta:null,doubles:f.doubles&&{step:f.doubles.step,points:[s].concat(f.doubles.points.map(a))},naf:f.naf&&{wnd:f.naf.wnd,points:[s].concat(f.naf.points.map(a))}},s};_r.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)+">"};_r.prototype.isInfinity=function(){return this.inf};_r.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),s=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,s)};_r.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),s=e.redInvm(),a=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(s),f=a.redSqr().redISub(this.x.redAdd(this.x)),p=a.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,p)};_r.prototype.getX=function(){return this.x.fromRed()};_r.prototype.getY=function(){return this.y.fromRed()};_r.prototype.mul=function(e){return e=new tr(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};_r.prototype.mulAdd=function(e,t,i){var s=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(s,a):this.curve._wnafMulAdd(1,s,a,2)};_r.prototype.jmulAdd=function(e,t,i){var s=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(s,a,!0):this.curve._wnafMulAdd(1,s,a,2,!0)};_r.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};_r.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,s=function(a){return a.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(s)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(s)}}}return t};_r.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Mr(r,e,t,i){Pa.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new tr(0)):(this.x=new tr(e,16),this.y=new tr(t,16),this.z=new tr(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}pd(Mr,Pa.BasePoint);ki.prototype.jpoint=function(e,t,i){return new Mr(this,e,t,i)};Mr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),s=this.y.redMul(t).redMul(e);return this.curve.point(i,s)};Mr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Mr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),s=this.x.redMul(t),a=e.x.redMul(i),f=this.y.redMul(t.redMul(e.z)),p=e.y.redMul(i.redMul(this.z)),w=s.redSub(a),b=f.redSub(p);if(w.cmpn(0)===0)return b.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var A=w.redSqr(),M=A.redMul(w),C=s.redMul(A),O=b.redSqr().redIAdd(M).redISub(C).redISub(C),D=b.redMul(C.redISub(O)).redISub(f.redMul(M)),j=this.z.redMul(e.z).redMul(w);return this.curve.jpoint(O,D,j)};Mr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,s=e.x.redMul(t),a=this.y,f=e.y.redMul(t).redMul(this.z),p=i.redSub(s),w=a.redSub(f);if(p.cmpn(0)===0)return w.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=p.redSqr(),A=b.redMul(p),M=i.redMul(b),C=w.redSqr().redIAdd(A).redISub(M).redISub(M),O=w.redMul(M.redISub(C)).redISub(a.redMul(A)),D=this.z.redMul(p);return this.curve.jpoint(C,O,D)};Mr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var s=this.curve.a,a=this.curve.tinv,f=this.x,p=this.y,w=this.z,b=w.redSqr().redSqr(),A=p.redAdd(p);for(t=0;t<e;t++){var M=f.redSqr(),C=A.redSqr(),O=C.redSqr(),D=M.redAdd(M).redIAdd(M).redIAdd(s.redMul(b)),j=f.redMul(C),G=D.redSqr().redISub(j.redAdd(j)),X=j.redISub(G),z=D.redMul(X);z=z.redIAdd(z).redISub(O);var Q=A.redMul(w);t+1<e&&(b=b.redMul(O)),f=G,w=Q,A=z}return this.curve.jpoint(f,A.redMul(a),w)};Mr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};Mr.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var s=this.x.redSqr(),a=this.y.redSqr(),f=a.redSqr(),p=this.x.redAdd(a).redSqr().redISub(s).redISub(f);p=p.redIAdd(p);var w=s.redAdd(s).redIAdd(s),b=w.redSqr().redISub(p).redISub(p),A=f.redIAdd(f);A=A.redIAdd(A),A=A.redIAdd(A),e=b,t=w.redMul(p.redISub(b)).redISub(A),i=this.y.redAdd(this.y)}else{var M=this.x.redSqr(),C=this.y.redSqr(),O=C.redSqr(),D=this.x.redAdd(C).redSqr().redISub(M).redISub(O);D=D.redIAdd(D);var j=M.redAdd(M).redIAdd(M),G=j.redSqr(),X=O.redIAdd(O);X=X.redIAdd(X),X=X.redIAdd(X),e=G.redISub(D).redISub(D),t=j.redMul(D.redISub(e)).redISub(X),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)};Mr.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var s=this.x.redSqr(),a=this.y.redSqr(),f=a.redSqr(),p=this.x.redAdd(a).redSqr().redISub(s).redISub(f);p=p.redIAdd(p);var w=s.redAdd(s).redIAdd(s).redIAdd(this.curve.a),b=w.redSqr().redISub(p).redISub(p);e=b;var A=f.redIAdd(f);A=A.redIAdd(A),A=A.redIAdd(A),t=w.redMul(p.redISub(b)).redISub(A),i=this.y.redAdd(this.y)}else{var M=this.z.redSqr(),C=this.y.redSqr(),O=this.x.redMul(C),D=this.x.redSub(M).redMul(this.x.redAdd(M));D=D.redAdd(D).redIAdd(D);var j=O.redIAdd(O);j=j.redIAdd(j);var G=j.redAdd(j);e=D.redSqr().redISub(G),i=this.y.redAdd(this.z).redSqr().redISub(C).redISub(M);var X=C.redSqr();X=X.redIAdd(X),X=X.redIAdd(X),X=X.redIAdd(X),t=D.redMul(j.redISub(e)).redISub(X)}return this.curve.jpoint(e,t,i)};Mr.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,s=this.z,a=s.redSqr().redSqr(),f=t.redSqr(),p=i.redSqr(),w=f.redAdd(f).redIAdd(f).redIAdd(e.redMul(a)),b=t.redAdd(t);b=b.redIAdd(b);var A=b.redMul(p),M=w.redSqr().redISub(A.redAdd(A)),C=A.redISub(M),O=p.redSqr();O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O);var D=w.redMul(C).redISub(O),j=i.redAdd(i).redMul(s);return this.curve.jpoint(M,D,j)};Mr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),s=t.redSqr(),a=e.redAdd(e).redIAdd(e),f=a.redSqr(),p=this.x.redAdd(t).redSqr().redISub(e).redISub(s);p=p.redIAdd(p),p=p.redAdd(p).redIAdd(p),p=p.redISub(f);var w=p.redSqr(),b=s.redIAdd(s);b=b.redIAdd(b),b=b.redIAdd(b),b=b.redIAdd(b);var A=a.redIAdd(p).redSqr().redISub(f).redISub(w).redISub(b),M=t.redMul(A);M=M.redIAdd(M),M=M.redIAdd(M);var C=this.x.redMul(w).redISub(M);C=C.redIAdd(C),C=C.redIAdd(C);var O=this.y.redMul(A.redMul(b.redISub(A)).redISub(p.redMul(w)));O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O);var D=this.z.redAdd(p).redSqr().redISub(i).redISub(w);return this.curve.jpoint(C,O,D)};Mr.prototype.mul=function(e,t){return e=new tr(e,t),this.curve._wnafMul(this,e)};Mr.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var s=t.redMul(this.z),a=i.redMul(e.z);return this.y.redMul(a).redISub(e.y.redMul(s)).cmpn(0)===0};Mr.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var s=e.clone(),a=this.curve.redN.redMul(t);;){if(s.iadd(this.curve.n),s.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(a),this.x.cmp(i)===0)return!0}};Mr.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)+">"};Mr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ma=Wn,wg=td,Ff=Df,l8=bi;function Ra(r){Ff.call(this,"mont",r),this.a=new ma(r.a,16).toRed(this.red),this.b=new ma(r.b,16).toRed(this.red),this.i4=new ma(4).toRed(this.red).redInvm(),this.two=new ma(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}wg(Ra,Ff);var p8=Ra;Ra.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),s=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),a=s.redSqrt();return a.redSqr().cmp(s)===0};function wr(r,e,t){Ff.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new ma(e,16),this.z=new ma(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}wg(wr,Ff.BasePoint);Ra.prototype.decodePoint=function(e,t){return this.point(l8.toArray(e,t),1)};Ra.prototype.point=function(e,t){return new wr(this,e,t)};Ra.prototype.pointFromJSON=function(e){return wr.fromJSON(this,e)};wr.prototype.precompute=function(){};wr.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};wr.fromJSON=function(e,t){return new wr(e,t[0],t[1]||e.one)};wr.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};wr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};wr.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),s=i.redSqr(),a=t.redSub(s),f=t.redMul(s),p=a.redMul(s.redAdd(this.curve.a24.redMul(a)));return this.curve.point(f,p)};wr.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};wr.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),s=this.x.redSub(this.z),a=e.x.redAdd(e.z),f=e.x.redSub(e.z),p=f.redMul(i),w=a.redMul(s),b=t.z.redMul(p.redAdd(w).redSqr()),A=t.x.redMul(p.redISub(w).redSqr());return this.curve.point(b,A)};wr.prototype.mul=function(e){for(var t=e.clone(),i=this,s=this.curve.point(null,null),a=this,f=[];t.cmpn(0)!==0;t.iushrn(1))f.push(t.andln(1));for(var p=f.length-1;p>=0;p--)f[p]===0?(i=i.diffAdd(s,a),s=s.dbl()):(s=i.diffAdd(s,a),i=i.dbl());return s};wr.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};wr.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};wr.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};wr.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};wr.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var g8=bi,Vn=Wn,_g=td,qf=Df,v8=g8.assert;function Pn(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,qf.call(this,"edwards",r),this.a=new Vn(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Vn(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Vn(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),v8(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}_g(Pn,qf);var b8=Pn;Pn.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Pn.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Pn.prototype.jpoint=function(e,t,i,s){return this.point(e,t,i,s)};Pn.prototype.pointFromX=function(e,t){e=new Vn(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),s=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),f=s.redMul(a.redInvm()),p=f.redSqrt();if(p.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");var w=p.fromRed().isOdd();return(t&&!w||!t&&w)&&(p=p.redNeg()),this.point(e,p)};Pn.prototype.pointFromY=function(e,t){e=new Vn(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),s=i.redSub(this.c2),a=i.redMul(this.d).redMul(this.c2).redSub(this.a),f=s.redMul(a.redInvm());if(f.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var p=f.redSqrt();if(p.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");return p.fromRed().isOdd()!==t&&(p=p.redNeg()),this.point(p,e)};Pn.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),s=t.redMul(this.a).redAdd(i),a=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return s.cmp(a)===0};function Ht(r,e,t,i,s){qf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Vn(e,16),this.y=new Vn(t,16),this.z=i?new Vn(i,16):this.curve.one,this.t=s&&new Vn(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}_g(Ht,qf.BasePoint);Pn.prototype.pointFromJSON=function(e){return Ht.fromJSON(this,e)};Pn.prototype.point=function(e,t,i,s){return new Ht(this,e,t,i,s)};Ht.fromJSON=function(e,t){return new Ht(e,t[0],t[1],t[2])};Ht.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"};Ht.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ht.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var s=this.curve._mulA(e),a=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),f=s.redAdd(t),p=f.redSub(i),w=s.redSub(t),b=a.redMul(p),A=f.redMul(w),M=a.redMul(w),C=p.redMul(f);return this.curve.point(b,A,C,M)};Ht.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),s,a,f,p,w,b;if(this.curve.twisted){p=this.curve._mulA(t);var A=p.redAdd(i);this.zOne?(s=e.redSub(t).redSub(i).redMul(A.redSub(this.curve.two)),a=A.redMul(p.redSub(i)),f=A.redSqr().redSub(A).redSub(A)):(w=this.z.redSqr(),b=A.redSub(w).redISub(w),s=e.redSub(t).redISub(i).redMul(b),a=A.redMul(p.redSub(i)),f=A.redMul(b))}else p=t.redAdd(i),w=this.curve._mulC(this.z).redSqr(),b=p.redSub(w).redSub(w),s=this.curve._mulC(e.redISub(p)).redMul(b),a=this.curve._mulC(p).redMul(t.redISub(i)),f=p.redMul(b);return this.curve.point(s,a,f)};Ht.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ht.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),s=this.t.redMul(this.curve.dd).redMul(e.t),a=this.z.redMul(e.z.redAdd(e.z)),f=i.redSub(t),p=a.redSub(s),w=a.redAdd(s),b=i.redAdd(t),A=f.redMul(p),M=w.redMul(b),C=f.redMul(b),O=p.redMul(w);return this.curve.point(A,M,O,C)};Ht.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),s=this.x.redMul(e.x),a=this.y.redMul(e.y),f=this.curve.d.redMul(s).redMul(a),p=i.redSub(f),w=i.redAdd(f),b=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(a),A=t.redMul(p).redMul(b),M,C;return this.curve.twisted?(M=t.redMul(w).redMul(a.redSub(this.curve._mulA(s))),C=p.redMul(w)):(M=t.redMul(w).redMul(a.redSub(s)),C=this.curve._mulC(p).redMul(w)),this.curve.point(A,M,C)};Ht.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ht.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ht.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ht.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ht.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ht.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ht.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ht.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ht.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),s=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(s),this.x.cmp(t)===0)return!0}};Ht.prototype.toP=Ht.prototype.normalize;Ht.prototype.mixedAdd=Ht.prototype.add;(function(r){var e=r;e.base=Df,e.short=d8,e.mont=p8,e.edwards=b8})(ld);var Bf={},ou,hp;function m8(){return hp||(hp=1,ou={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),ou}(function(r){var e=r,t=rd,i=ld,s=bi,a=s.assert;function f(b){b.type==="short"?this.curve=new i.short(b):b.type==="edwards"?this.curve=new i.edwards(b):this.curve=new i.mont(b),this.g=this.curve.g,this.n=this.curve.n,this.hash=b.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=f;function p(b,A){Object.defineProperty(e,b,{configurable:!0,enumerable:!0,get:function(){var M=new f(A);return Object.defineProperty(e,b,{configurable:!0,enumerable:!0,value:M}),M}})}p("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:t.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),p("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:t.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),p("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:t.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),p("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:t.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"]}),p("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:t.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"]}),p("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["9"]}),p("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:t.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var w;try{w=m8()}catch{w=void 0}p("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:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",w]})})(Bf);var y8=rd,Ls=ud,Ag=G1;function gs(r){if(!(this instanceof gs))return new gs(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Ls.toArray(r.entropy,r.entropyEnc||"hex"),t=Ls.toArray(r.nonce,r.nonceEnc||"hex"),i=Ls.toArray(r.pers,r.persEnc||"hex");Ag(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var w8=gs;gs.prototype._init=function(e,t,i){var s=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var a=0;a<this.V.length;a++)this.K[a]=0,this.V[a]=1;this._update(s),this._reseed=1,this.reseedInterval=281474976710656};gs.prototype._hmac=function(){return new y8.hmac(this.hash,this.K)};gs.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};gs.prototype.reseed=function(e,t,i,s){typeof t!="string"&&(s=i,i=t,t=null),e=Ls.toArray(e,t),i=Ls.toArray(i,s),Ag(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};gs.prototype.generate=function(e,t,i,s){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(s=i,i=t,t=null),i&&(i=Ls.toArray(i,s||"hex"),this._update(i));for(var a=[];a.length<e;)this.V=this._hmac().update(this.V).digest(),a=a.concat(this.V);var f=a.slice(0,e);return this._update(i),this._reseed++,Ls.encode(f,t)};var _8=Wn,A8=bi,$u=A8.assert;function Fr(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var E8=Fr;Fr.fromPublic=function(e,t,i){return t instanceof Fr?t:new Fr(e,{pub:t,pubEnc:i})};Fr.fromPrivate=function(e,t,i){return t instanceof Fr?t:new Fr(e,{priv:t,privEnc:i})};Fr.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Fr.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Fr.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Fr.prototype._importPrivate=function(e,t){this.priv=new _8(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Fr.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?$u(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&$u(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Fr.prototype.derive=function(e){return e.validate()||$u(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Fr.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Fr.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Fr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var mf=Wn,gd=bi,I8=gd.assert;function Lf(r,e){if(r instanceof Lf)return r;this._importDER(r,e)||(I8(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var M8=Lf;function S8(){this.place=0}function cu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var s=0,a=0,f=e.place;a<i;a++,f++)s<<=8,s|=r[f],s>>>=0;return s<=127?!1:(e.place=f,s)}function up(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}Lf.prototype._importDER=function(e,t){e=gd.toArray(e,t);var i=new S8;if(e[i.place++]!==48)return!1;var s=cu(e,i);if(s===!1||s+i.place!==e.length||e[i.place++]!==2)return!1;var a=cu(e,i);if(a===!1||e[i.place]&128)return!1;var f=e.slice(i.place,a+i.place);if(i.place+=a,e[i.place++]!==2)return!1;var p=cu(e,i);if(p===!1||e.length!==p+i.place||e[i.place]&128)return!1;var w=e.slice(i.place,p+i.place);if(f[0]===0)if(f[1]&128)f=f.slice(1);else return!1;if(w[0]===0)if(w[1]&128)w=w.slice(1);else return!1;return this.r=new mf(f),this.s=new mf(w),this.recoveryParam=null,!0};function fu(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Lf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=up(t),i=up(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var s=[2];fu(s,t.length),s=s.concat(t),s.push(2),fu(s,i.length);var a=s.concat(i),f=[48];return fu(f,a.length),f=f.concat(a),gd.encode(f,e)};var ks=Wn,Eg=w8,x8=bi,hu=Bf,P8=yg,Ig=x8.assert,vd=E8,kf=M8;function qi(r){if(!(this instanceof qi))return new qi(r);typeof r=="string"&&(Ig(Object.prototype.hasOwnProperty.call(hu,r),"Unknown curve "+r),r=hu[r]),r instanceof hu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var R8=qi;qi.prototype.keyPair=function(e){return new vd(this,e)};qi.prototype.keyFromPrivate=function(e,t){return vd.fromPrivate(this,e,t)};qi.prototype.keyFromPublic=function(e,t){return vd.fromPublic(this,e,t)};qi.prototype.genKeyPair=function(e){e||(e={});for(var t=new Eg({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||P8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),s=this.n.sub(new ks(2));;){var a=new ks(t.generate(i));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}};qi.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};qi.prototype.sign=function(e,t,i,s){typeof i=="object"&&(s=i,i=null),s||(s={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new ks(e,16));for(var a=this.n.byteLength(),f=t.getPrivate().toArray("be",a),p=e.toArray("be",a),w=new Eg({hash:this.hash,entropy:f,nonce:p,pers:s.pers,persEnc:s.persEnc||"utf8"}),b=this.n.sub(new ks(1)),A=0;;A++){var M=s.k?s.k(A):new ks(w.generate(this.n.byteLength()));if(M=this._truncateToN(M,!0),!(M.cmpn(1)<=0||M.cmp(b)>=0)){var C=this.g.mul(M);if(!C.isInfinity()){var O=C.getX(),D=O.umod(this.n);if(D.cmpn(0)!==0){var j=M.invm(this.n).mul(D.mul(t.getPrivate()).iadd(e));if(j=j.umod(this.n),j.cmpn(0)!==0){var G=(C.getY().isOdd()?1:0)|(O.cmp(D)!==0?2:0);return s.canonical&&j.cmp(this.nh)>0&&(j=this.n.sub(j),G^=1),new kf({r:D,s:j,recoveryParam:G})}}}}}};qi.prototype.verify=function(e,t,i,s){e=this._truncateToN(new ks(e,16)),i=this.keyFromPublic(i,s),t=new kf(t,"hex");var a=t.r,f=t.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var p=f.invm(this.n),w=p.mul(e).umod(this.n),b=p.mul(a).umod(this.n),A;return this.curve._maxwellTrick?(A=this.g.jmulAdd(w,i.getPublic(),b),A.isInfinity()?!1:A.eqXToP(a)):(A=this.g.mulAdd(w,i.getPublic(),b),A.isInfinity()?!1:A.getX().umod(this.n).cmp(a)===0)};qi.prototype.recoverPubKey=function(r,e,t,i){Ig((3&t)===t,"The recovery param is more than two bits"),e=new kf(e,i);var s=this.n,a=new ks(r),f=e.r,p=e.s,w=t&1,b=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&b)throw new Error("Unable to find sencond key candinate");b?f=this.curve.pointFromX(f.add(this.curve.n),w):f=this.curve.pointFromX(f,w);var A=e.r.invm(s),M=s.sub(a).mul(A).umod(s),C=p.mul(A).umod(s);return this.g.mulAdd(M,f,C)};qi.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new kf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var s=0;s<4;s++){var a;try{a=this.recoverPubKey(r,e,s)}catch{continue}if(a.eq(t))return s}throw new Error("Unable to find valid recovery factor")};var Do=bi,Mg=Do.assert,dp=Do.parseBytes,Na=Do.cachedProperty;function yr(r,e){this.eddsa=r,this._secret=dp(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=dp(e.pub)}yr.fromPublic=function(e,t){return t instanceof yr?t:new yr(e,{pub:t})};yr.fromSecret=function(e,t){return t instanceof yr?t:new yr(e,{secret:t})};yr.prototype.secret=function(){return this._secret};Na(yr,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Na(yr,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Na(yr,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,s=t.slice(0,e.encodingLength);return s[0]&=248,s[i]&=127,s[i]|=64,s});Na(yr,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Na(yr,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Na(yr,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});yr.prototype.sign=function(e){return Mg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};yr.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};yr.prototype.getSecret=function(e){return Mg(this._secret,"KeyPair is public only"),Do.encode(this.secret(),e)};yr.prototype.getPublic=function(e){return Do.encode(this.pubBytes(),e)};var N8=yr,C8=Wn,$f=bi,lp=$f.assert,zf=$f.cachedProperty,O8=$f.parseBytes;function Vs(r,e){this.eddsa=r,typeof e!="object"&&(e=O8(e)),Array.isArray(e)&&(lp(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),lp(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof C8&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}zf(Vs,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});zf(Vs,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});zf(Vs,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});zf(Vs,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Vs.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Vs.prototype.toHex=function(){return $f.encode(this.toBytes(),"hex").toUpperCase()};var T8=Vs,D8=rd,F8=Bf,Aa=bi,q8=Aa.assert,Sg=Aa.parseBytes,xg=N8,pp=T8;function si(r){if(q8(r==="ed25519","only tested with ed25519 so far"),!(this instanceof si))return new si(r);r=F8[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=D8.sha512}var B8=si;si.prototype.sign=function(e,t){e=Sg(e);var i=this.keyFromSecret(t),s=this.hashInt(i.messagePrefix(),e),a=this.g.mul(s),f=this.encodePoint(a),p=this.hashInt(f,i.pubBytes(),e).mul(i.priv()),w=s.add(p).umod(this.curve.n);return this.makeSignature({R:a,S:w,Rencoded:f})};si.prototype.verify=function(e,t,i){if(e=Sg(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var s=this.keyFromPublic(i),a=this.hashInt(t.Rencoded(),s.pubBytes(),e),f=this.g.mul(t.S()),p=t.R().add(s.pub().mul(a));return p.eq(f)};si.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return Aa.intFromLE(e.digest()).umod(this.curve.n)};si.prototype.keyFromPublic=function(e){return xg.fromPublic(this,e)};si.prototype.keyFromSecret=function(e){return xg.fromSecret(this,e)};si.prototype.makeSignature=function(e){return e instanceof pp?e:new pp(this,e)};si.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t};si.prototype.decodePoint=function(e){e=Aa.parseBytes(e);var t=e.length-1,i=e.slice(0,t).concat(e[t]&-129),s=(e[t]&128)!==0,a=Aa.intFromLE(i);return this.curve.pointFromY(a,s)};si.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)};si.prototype.decodeInt=function(e){return Aa.intFromLE(e)};si.prototype.isPoint=function(e){return e instanceof this.pointClass};(function(r){var e=r;e.version=c8.version,e.utils=bi,e.rand=yg,e.curve=ld,e.curves=Bf,e.ec=R8,e.eddsa=B8})(mg);var L8={};const k8=":";function wo(r){const[e,t]=r.split(k8);return{namespace:e,reference:t}}function gp(r,e=[]){const t=[];return Object.keys(r).forEach(i=>{if(e.length&&!e.includes(i))return;const s=r[i];t.push(...s.accounts)}),t}function Pg(r,e){return r.includes(":")?[r]:e.chains||[]}var $8=Object.defineProperty,vp=Object.getOwnPropertySymbols,z8=Object.prototype.hasOwnProperty,U8=Object.prototype.propertyIsEnumerable,bp=(r,e,t)=>e in r?$8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mp=(r,e)=>{for(var t in e||(e={}))z8.call(e,t)&&bp(r,t,e[t]);if(vp)for(var t of vp(e))U8.call(e,t)&&bp(r,t,e[t]);return r};const j8="ReactNative",pi={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},K8="js";function yf(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ca(){return!nd()&&!!W1()&&navigator.product===j8}function Fo(){return!yf()&&!!W1()&&!!nd()}function qo(){return Ca()?pi.reactNative:yf()?pi.node:Fo()?pi.browser:pi.unknown}function H8(){var r;try{return Ca()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function V8(r,e){let t=Mo.parse(r);return t=mp(mp({},t),e),r=Mo.stringify(t),r}function Rg(){return zw()||{name:"",description:"",url:"",icons:[""]}}function G8(){if(qo()===pi.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:t,Version:i}=global.Platform;return[t,i].join("-")}const r=Xw();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function J8(){var r;const e=qo();return e===pi.browser?[e,((r=jw())==null?void 0:r.host)||"unknown"].join(":"):e}function Ng(r,e,t){const i=G8(),s=J8();return[[r,e].join("-"),[K8,t].join("-"),i,s].join("/")}function W8({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:s,projectId:a,useOnCloseEvent:f,bundleId:p}){const w=t.split("?"),b=Ng(r,e,i),A={auth:s,ua:b,projectId:a,useOnCloseEvent:f||void 0,origin:p||void 0},M=V8(w[1]||"",A);return w[0]+"?"+M}function Bs(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Cg(r){return Object.fromEntries(r.entries())}function Og(r){return new Map(Object.entries(r))}function Ds(r=me.FIVE_MINUTES,e){const t=me.toMiliseconds(r||me.FIVE_MINUTES);let i,s,a;return{resolve:f=>{a&&i&&(clearTimeout(a),i(f))},reject:f=>{a&&s&&(clearTimeout(a),s(f))},done:()=>new Promise((f,p)=>{a=setTimeout(()=>{p(new Error(e))},t),i=f,s=p})}}function ya(r,e,t){return new Promise(async(i,s)=>{const a=setTimeout(()=>s(new Error(t)),e);try{const f=await r;i(f)}catch(f){s(f)}clearTimeout(a)})}function Tg(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.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: ${r}`)}function Q8(r){return Tg("topic",r)}function Y8(r){return Tg("id",r)}function Dg(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function lr(r,e){return me.fromMiliseconds(Date.now()+me.toMiliseconds(r))}function cs(r){return Date.now()>=me.toMiliseconds(r)}function It(r,e){return`${r}${e?`:${e}`:""}`}function rf(r=[],e=[]){return[...new Set([...r,...e])]}async function X8({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const s=typeof t=="string"?JSON.parse(t):t,a=s==null?void 0:s.href;if(typeof a!="string")return;const f=Z8(a,r,e),p=qo();if(p===pi.browser){if(!((i=nd())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}f.startsWith("https://")||f.startsWith("http://")?window.open(f,"_blank","noreferrer noopener"):window.open(f,t9()?"_blank":"_self","noreferrer noopener")}else p===pi.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(f)}catch(s){console.error(s)}}function Z8(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let s=`${r}`;if(r.startsWith("https://t.me")){const a=r.includes("?")?"&startapp=":"?startapp=";s=`${s}${a}${r9(i,!0)}`}else s=`${s}/wc?${i}`;return s}async function e9(r,e){let t="";try{if(Fo()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function yp(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function wp(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function bd(){return typeof process<"u"&&L8.IS_VITEST==="true"}function t9(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function r9(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Fg(r){return Buffer.from(r,"base64").toString("utf-8")}var qg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function i9(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),t}var Bg={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(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",s=i?window:{};s.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",f=!s.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;f?s=qg:a&&(s=self);var p=!s.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,w=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",b="0123456789abcdef".split(""),A=[31,7936,2031616,520093696],M=[4,1024,262144,67108864],C=[1,256,65536,16777216],O=[6,1536,393216,100663296],D=[0,8,16,24],j=[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],G=[224,256,384,512],X=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],Q={128:168,256:136};(s.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(I){return Object.prototype.toString.call(I)==="[object Array]"}),w&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(I){return typeof I=="object"&&I.buffer&&I.buffer.constructor===ArrayBuffer});for(var V=function(I,Z,F){return function(k){return new R(I,Z,I).update(k)[F]()}},H=function(I,Z,F){return function(k,$){return new R(I,Z,$).update(k)[F]()}},ee=function(I,Z,F){return function(k,$,m,B){return d["cshake"+I].update(k,$,m,B)[F]()}},oe=function(I,Z,F){return function(k,$,m,B){return d["kmac"+I].update(k,$,m,B)[F]()}},ne=function(I,Z,F,k){for(var $=0;$<z.length;++$){var m=z[$];I[m]=Z(F,k,m)}return I},ge=function(I,Z){var F=V(I,Z,"hex");return F.create=function(){return new R(I,Z,I)},F.update=function(k){return F.create().update(k)},ne(F,V,I,Z)},ht=function(I,Z){var F=H(I,Z,"hex");return F.create=function(k){return new R(I,Z,k)},F.update=function(k,$){return F.create($).update(k)},ne(F,H,I,Z)},L=function(I,Z){var F=Q[I],k=ee(I,Z,"hex");return k.create=function($,m,B){return!m&&!B?d["shake"+I].create($):new R(I,Z,$).bytepad([m,B],F)},k.update=function($,m,B,re){return k.create(m,B,re).update($)},ne(k,ee,I,Z)},v=function(I,Z){var F=Q[I],k=oe(I,Z,"hex");return k.create=function($,m,B){return new ie(I,Z,m).bytepad(["KMAC",B],F).bytepad([$],F)},k.update=function($,m,B,re){return k.create($,B,re).update(m)},ne(k,oe,I,Z)},c=[{name:"keccak",padding:C,bits:G,createMethod:ge},{name:"sha3",padding:O,bits:G,createMethod:ge},{name:"shake",padding:A,bits:X,createMethod:ht},{name:"cshake",padding:M,bits:X,createMethod:L},{name:"kmac",padding:M,bits:X,createMethod:v}],d={},g=[],_=0;_<c.length;++_)for(var S=c[_],x=S.bits,E=0;E<x.length;++E){var u=S.name+"_"+x[E];if(g.push(u),d[u]=S.createMethod(x[E],S.padding),S.name!=="sha3"){var l=S.name+x[E];g.push(l),d[l]=d[u]}}function R(I,Z,F){this.blocks=[],this.s=[],this.padding=Z,this.outputBits=F,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(I<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var k=0;k<50;++k)this.s[k]=0}R.prototype.update=function(I){if(this.finalized)throw new Error(t);var Z,F=typeof I;if(F!=="string"){if(F==="object"){if(I===null)throw new Error(e);if(w&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!w||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);Z=!0}for(var k=this.blocks,$=this.byteCount,m=I.length,B=this.blockCount,re=0,he=this.s,ue,ve;re<m;){if(this.reset)for(this.reset=!1,k[0]=this.block,ue=1;ue<B+1;++ue)k[ue]=0;if(Z)for(ue=this.start;re<m&&ue<$;++re)k[ue>>2]|=I[re]<<D[ue++&3];else for(ue=this.start;re<m&&ue<$;++re)ve=I.charCodeAt(re),ve<128?k[ue>>2]|=ve<<D[ue++&3]:ve<2048?(k[ue>>2]|=(192|ve>>6)<<D[ue++&3],k[ue>>2]|=(128|ve&63)<<D[ue++&3]):ve<55296||ve>=57344?(k[ue>>2]|=(224|ve>>12)<<D[ue++&3],k[ue>>2]|=(128|ve>>6&63)<<D[ue++&3],k[ue>>2]|=(128|ve&63)<<D[ue++&3]):(ve=65536+((ve&1023)<<10|I.charCodeAt(++re)&1023),k[ue>>2]|=(240|ve>>18)<<D[ue++&3],k[ue>>2]|=(128|ve>>12&63)<<D[ue++&3],k[ue>>2]|=(128|ve>>6&63)<<D[ue++&3],k[ue>>2]|=(128|ve&63)<<D[ue++&3]);if(this.lastByteIndex=ue,ue>=$){for(this.start=ue-$,this.block=k[B],ue=0;ue<B;++ue)he[ue]^=k[ue];se(he),this.reset=!0}else this.start=ue}return this},R.prototype.encode=function(I,Z){var F=I&255,k=1,$=[F];for(I=I>>8,F=I&255;F>0;)$.unshift(F),I=I>>8,F=I&255,++k;return Z?$.push(k):$.unshift(k),this.update($),$.length},R.prototype.encodeString=function(I){var Z,F=typeof I;if(F!=="string"){if(F==="object"){if(I===null)throw new Error(e);if(w&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!w||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);Z=!0}var k=0,$=I.length;if(Z)k=$;else for(var m=0;m<I.length;++m){var B=I.charCodeAt(m);B<128?k+=1:B<2048?k+=2:B<55296||B>=57344?k+=3:(B=65536+((B&1023)<<10|I.charCodeAt(++m)&1023),k+=4)}return k+=this.encode(k*8),this.update(I),k},R.prototype.bytepad=function(I,Z){for(var F=this.encode(Z),k=0;k<I.length;++k)F+=this.encodeString(I[k]);var $=Z-F%Z,m=[];return m.length=$,this.update(m),this},R.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var I=this.blocks,Z=this.lastByteIndex,F=this.blockCount,k=this.s;if(I[Z>>2]|=this.padding[Z&3],this.lastByteIndex===this.byteCount)for(I[0]=I[F],Z=1;Z<F+1;++Z)I[Z]=0;for(I[F-1]|=2147483648,Z=0;Z<F;++Z)k[Z]^=I[Z];se(k)}},R.prototype.toString=R.prototype.hex=function(){this.finalize();for(var I=this.blockCount,Z=this.s,F=this.outputBlocks,k=this.extraBytes,$=0,m=0,B="",re;m<F;){for($=0;$<I&&m<F;++$,++m)re=Z[$],B+=b[re>>4&15]+b[re&15]+b[re>>12&15]+b[re>>8&15]+b[re>>20&15]+b[re>>16&15]+b[re>>28&15]+b[re>>24&15];m%I===0&&(se(Z),$=0)}return k&&(re=Z[$],B+=b[re>>4&15]+b[re&15],k>1&&(B+=b[re>>12&15]+b[re>>8&15]),k>2&&(B+=b[re>>20&15]+b[re>>16&15])),B},R.prototype.arrayBuffer=function(){this.finalize();var I=this.blockCount,Z=this.s,F=this.outputBlocks,k=this.extraBytes,$=0,m=0,B=this.outputBits>>3,re;k?re=new ArrayBuffer(F+1<<2):re=new ArrayBuffer(B);for(var he=new Uint32Array(re);m<F;){for($=0;$<I&&m<F;++$,++m)he[m]=Z[$];m%I===0&&se(Z)}return k&&(he[$]=Z[$],re=re.slice(0,B)),re},R.prototype.buffer=R.prototype.arrayBuffer,R.prototype.digest=R.prototype.array=function(){this.finalize();for(var I=this.blockCount,Z=this.s,F=this.outputBlocks,k=this.extraBytes,$=0,m=0,B=[],re,he;m<F;){for($=0;$<I&&m<F;++$,++m)re=m<<2,he=Z[$],B[re]=he&255,B[re+1]=he>>8&255,B[re+2]=he>>16&255,B[re+3]=he>>24&255;m%I===0&&se(Z)}return k&&(re=m<<2,he=Z[$],B[re]=he&255,k>1&&(B[re+1]=he>>8&255),k>2&&(B[re+2]=he>>16&255)),B};function ie(I,Z,F){R.call(this,I,Z,F)}ie.prototype=new R,ie.prototype.finalize=function(){return this.encode(this.outputBits,!0),R.prototype.finalize.call(this)};var se=function(I){var Z,F,k,$,m,B,re,he,ue,ve,be,Te,nt,Se,Ve,Le,Ae,Ue,Ge,ye,je,Fe,_e,We,ke,Pe,ot,ft,De,ct,ut,qe,wt,dt,$e,At,Mt,Ee,Ke,Qe,Ie,Je,He,Re,st,Ye,Ne,Xe,et,Me,ze,at,Ce,Ct,Ot,tt,bt,xr,Pr,Rr,Nr,Cr,Yt;for(k=0;k<48;k+=2)$=I[0]^I[10]^I[20]^I[30]^I[40],m=I[1]^I[11]^I[21]^I[31]^I[41],B=I[2]^I[12]^I[22]^I[32]^I[42],re=I[3]^I[13]^I[23]^I[33]^I[43],he=I[4]^I[14]^I[24]^I[34]^I[44],ue=I[5]^I[15]^I[25]^I[35]^I[45],ve=I[6]^I[16]^I[26]^I[36]^I[46],be=I[7]^I[17]^I[27]^I[37]^I[47],Te=I[8]^I[18]^I[28]^I[38]^I[48],nt=I[9]^I[19]^I[29]^I[39]^I[49],Z=Te^(B<<1|re>>>31),F=nt^(re<<1|B>>>31),I[0]^=Z,I[1]^=F,I[10]^=Z,I[11]^=F,I[20]^=Z,I[21]^=F,I[30]^=Z,I[31]^=F,I[40]^=Z,I[41]^=F,Z=$^(he<<1|ue>>>31),F=m^(ue<<1|he>>>31),I[2]^=Z,I[3]^=F,I[12]^=Z,I[13]^=F,I[22]^=Z,I[23]^=F,I[32]^=Z,I[33]^=F,I[42]^=Z,I[43]^=F,Z=B^(ve<<1|be>>>31),F=re^(be<<1|ve>>>31),I[4]^=Z,I[5]^=F,I[14]^=Z,I[15]^=F,I[24]^=Z,I[25]^=F,I[34]^=Z,I[35]^=F,I[44]^=Z,I[45]^=F,Z=he^(Te<<1|nt>>>31),F=ue^(nt<<1|Te>>>31),I[6]^=Z,I[7]^=F,I[16]^=Z,I[17]^=F,I[26]^=Z,I[27]^=F,I[36]^=Z,I[37]^=F,I[46]^=Z,I[47]^=F,Z=ve^($<<1|m>>>31),F=be^(m<<1|$>>>31),I[8]^=Z,I[9]^=F,I[18]^=Z,I[19]^=F,I[28]^=Z,I[29]^=F,I[38]^=Z,I[39]^=F,I[48]^=Z,I[49]^=F,Se=I[0],Ve=I[1],Ye=I[11]<<4|I[10]>>>28,Ne=I[10]<<4|I[11]>>>28,ft=I[20]<<3|I[21]>>>29,De=I[21]<<3|I[20]>>>29,Rr=I[31]<<9|I[30]>>>23,Nr=I[30]<<9|I[31]>>>23,Je=I[40]<<18|I[41]>>>14,He=I[41]<<18|I[40]>>>14,dt=I[2]<<1|I[3]>>>31,$e=I[3]<<1|I[2]>>>31,Le=I[13]<<12|I[12]>>>20,Ae=I[12]<<12|I[13]>>>20,Xe=I[22]<<10|I[23]>>>22,et=I[23]<<10|I[22]>>>22,ct=I[33]<<13|I[32]>>>19,ut=I[32]<<13|I[33]>>>19,Cr=I[42]<<2|I[43]>>>30,Yt=I[43]<<2|I[42]>>>30,Ct=I[5]<<30|I[4]>>>2,Ot=I[4]<<30|I[5]>>>2,At=I[14]<<6|I[15]>>>26,Mt=I[15]<<6|I[14]>>>26,Ue=I[25]<<11|I[24]>>>21,Ge=I[24]<<11|I[25]>>>21,Me=I[34]<<15|I[35]>>>17,ze=I[35]<<15|I[34]>>>17,qe=I[45]<<29|I[44]>>>3,wt=I[44]<<29|I[45]>>>3,We=I[6]<<28|I[7]>>>4,ke=I[7]<<28|I[6]>>>4,tt=I[17]<<23|I[16]>>>9,bt=I[16]<<23|I[17]>>>9,Ee=I[26]<<25|I[27]>>>7,Ke=I[27]<<25|I[26]>>>7,ye=I[36]<<21|I[37]>>>11,je=I[37]<<21|I[36]>>>11,at=I[47]<<24|I[46]>>>8,Ce=I[46]<<24|I[47]>>>8,Re=I[8]<<27|I[9]>>>5,st=I[9]<<27|I[8]>>>5,Pe=I[18]<<20|I[19]>>>12,ot=I[19]<<20|I[18]>>>12,xr=I[29]<<7|I[28]>>>25,Pr=I[28]<<7|I[29]>>>25,Qe=I[38]<<8|I[39]>>>24,Ie=I[39]<<8|I[38]>>>24,Fe=I[48]<<14|I[49]>>>18,_e=I[49]<<14|I[48]>>>18,I[0]=Se^~Le&Ue,I[1]=Ve^~Ae&Ge,I[10]=We^~Pe&ft,I[11]=ke^~ot&De,I[20]=dt^~At&Ee,I[21]=$e^~Mt&Ke,I[30]=Re^~Ye&Xe,I[31]=st^~Ne&et,I[40]=Ct^~tt&xr,I[41]=Ot^~bt&Pr,I[2]=Le^~Ue&ye,I[3]=Ae^~Ge&je,I[12]=Pe^~ft&ct,I[13]=ot^~De&ut,I[22]=At^~Ee&Qe,I[23]=Mt^~Ke&Ie,I[32]=Ye^~Xe&Me,I[33]=Ne^~et&ze,I[42]=tt^~xr&Rr,I[43]=bt^~Pr&Nr,I[4]=Ue^~ye&Fe,I[5]=Ge^~je&_e,I[14]=ft^~ct&qe,I[15]=De^~ut&wt,I[24]=Ee^~Qe&Je,I[25]=Ke^~Ie&He,I[34]=Xe^~Me&at,I[35]=et^~ze&Ce,I[44]=xr^~Rr&Cr,I[45]=Pr^~Nr&Yt,I[6]=ye^~Fe&Se,I[7]=je^~_e&Ve,I[16]=ct^~qe&We,I[17]=ut^~wt&ke,I[26]=Qe^~Je&dt,I[27]=Ie^~He&$e,I[36]=Me^~at&Re,I[37]=ze^~Ce&st,I[46]=Rr^~Cr&Ct,I[47]=Nr^~Yt&Ot,I[8]=Fe^~Se&Le,I[9]=_e^~Ve&Ae,I[18]=qe^~We&Pe,I[19]=wt^~ke&ot,I[28]=Je^~dt&At,I[29]=He^~$e&Mt,I[38]=at^~Re&Ye,I[39]=Ce^~st&Ne,I[48]=Cr^~Ct&tt,I[49]=Yt^~Ot&bt,I[0]^=j[k],I[1]^=j[k+1]};if(p)r.exports=d;else for(_=0;_<g.length;++_)s[g[_]]=d[g[_]]})()})(Bg);var n9=Bg.exports;const s9="logger/5.7.0";let _p=!1,Ap=!1;const nf={debug:1,default:2,info:2,warning:3,error:4,off:5};let Ep=nf.default,uu=null;function a9(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const Ip=a9();var zu;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(zu||(zu={}));var tn;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(tn||(tn={}));const Mp="0123456789abcdef";let Ir=class dr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();nf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ep>nf[i])&&console.log.apply(console,t)}debug(...e){this._log(dr.levels.DEBUG,e)}info(...e){this._log(dr.levels.INFO,e)}warn(...e){this._log(dr.levels.WARNING,e)}makeError(e,t,i){if(Ap)return this.makeError("censored error",t,{});t||(t=dr.errors.UNKNOWN_ERROR),i||(i={});const s=[];Object.keys(i).forEach(w=>{const b=i[w];try{if(b instanceof Uint8Array){let A="";for(let M=0;M<b.length;M++)A+=Mp[b[M]>>4],A+=Mp[b[M]&15];s.push(w+"=Uint8Array(0x"+A+")")}else s.push(w+"="+JSON.stringify(b))}catch{s.push(w+"="+JSON.stringify(i[w].toString()))}}),s.push(`code=${t}`),s.push(`version=${this.version}`);const a=e;let f="";switch(t){case tn.NUMERIC_FAULT:{f="NUMERIC_FAULT";const w=e;switch(w){case"overflow":case"underflow":case"division-by-zero":f+="-"+w;break;case"negative-power":case"negative-width":f+="-unsupported";break;case"unbound-bitwise-result":f+="-unbound-result";break}break}case tn.CALL_EXCEPTION:case tn.INSUFFICIENT_FUNDS:case tn.MISSING_NEW:case tn.NONCE_EXPIRED:case tn.REPLACEMENT_UNDERPRICED:case tn.TRANSACTION_REPLACED:case tn.UNPREDICTABLE_GAS_LIMIT:f=t;break}f&&(e+=" [ See: https://links.ethers.org/v5-errors-"+f+" ]"),s.length&&(e+=" ("+s.join(", ")+")");const p=new Error(e);return p.reason=a,p.code=t,Object.keys(i).forEach(function(w){p[w]=i[w]}),p}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,dr.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,s){e||this.throwError(t,i,s)}assertArgument(e,t,i,s){e||this.throwArgumentError(t,i,s)}checkNormalize(e){Ip&&this.throwError("platform missing String.prototype.normalize",dr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Ip})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,dr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,dr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,dr.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,dr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",dr.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",dr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",dr.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return uu||(uu=new dr(s9)),uu}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",dr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_p){if(!e)return;this.globalLogger().throwError("error censorship permanent",dr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Ap=!!e,_p=!!t}static setLogLevel(e){const t=nf[e.toLowerCase()];if(t==null){dr.globalLogger().warn("invalid log level - "+e);return}Ep=t}static from(e){return new dr(e)}};Ir.errors=tn,Ir.levels=zu;const o9="bytes/5.7.0",sr=new Ir(o9);function Lg(r){return!!r.toHexString}function wa(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return wa(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function c9(r){return gi(r)&&!(r.length%2)||Oa(r)}function Sp(r){return typeof r=="number"&&r==r&&r%1===0}function Oa(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!Sp(r.length)||r.length<0)return!1;for(let e=0;e<r.length;e++){const t=r[e];if(!Sp(t)||t<0||t>=256)return!1}return!0}function er(r,e){if(e||(e={}),typeof r=="number"){sr.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),wa(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Lg(r)&&(r=r.toHexString()),gi(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":sr.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let s=0;s<t.length;s+=2)i.push(parseInt(t.substring(s,s+2),16));return wa(new Uint8Array(i))}return Oa(r)?wa(new Uint8Array(r)):sr.throwArgumentError("invalid arrayify value","value",r)}function f9(r){const e=r.map(s=>er(s)),t=e.reduce((s,a)=>s+a.length,0),i=new Uint8Array(t);return e.reduce((s,a)=>(i.set(a,s),s+a.length),0),wa(i)}function h9(r,e){r=er(r),r.length>e&&sr.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),wa(t)}function gi(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const du="0123456789abcdef";function ri(r,e){if(e||(e={}),typeof r=="number"){sr.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=du[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Lg(r))return r.toHexString();if(gi(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":sr.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Oa(r)){let t="0x";for(let i=0;i<r.length;i++){let s=r[i];t+=du[(s&240)>>4]+du[s&15]}return t}return sr.throwArgumentError("invalid hexlify value","value",r)}function u9(r){if(typeof r!="string")r=ri(r);else if(!gi(r)||r.length%2)return null;return(r.length-2)/2}function xp(r,e,t){return typeof r!="string"?r=ri(r):(!gi(r)||r.length%2)&&sr.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function _n(r,e){for(typeof r!="string"?r=ri(r):gi(r)||sr.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&sr.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function kg(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(c9(r)){let t=er(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=ri(t.slice(0,32)),e.s=ri(t.slice(32,64))):t.length===65?(e.r=ri(t.slice(0,32)),e.s=ri(t.slice(32,64)),e.v=t[64]):sr.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:sr.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=ri(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const s=h9(er(e._vs),32);e._vs=ri(s);const a=s[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&sr.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),s[0]&=127;const f=ri(s);e.s==null?e.s=f:e.s!==f&&sr.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?sr.throwArgumentError("signature missing v and recoveryParam","signature",r):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 s=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==s&&sr.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!gi(e.r)?sr.throwArgumentError("signature missing or invalid r","signature",r):e.r=_n(e.r,32),e.s==null||!gi(e.s)?sr.throwArgumentError("signature missing or invalid s","signature",r):e.s=_n(e.s,32);const t=er(e.s);t[0]>=128&&sr.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=ri(t);e._vs&&(gi(e._vs)||sr.throwArgumentError("signature invalid _vs","signature",r),e._vs=_n(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&sr.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function md(r){return"0x"+n9.keccak_256(er(r))}var $g={exports:{}},d9={},l9=Object.freeze({__proto__:null,default:d9}),p9=i9(l9);(function(r){(function(e,t){function i(c,d){if(!c)throw new Error(d||"Assertion failed")}function s(c,d){c.super_=d;var g=function(){};g.prototype=d.prototype,c.prototype=new g,c.prototype.constructor=c}function a(c,d,g){if(a.isBN(c))return c;this.negative=0,this.words=null,this.length=0,this.red=null,c!==null&&((d==="le"||d==="be")&&(g=d,d=10),this._init(c||0,d||10,g||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var f;try{typeof window<"u"&&typeof window.Buffer<"u"?f=window.Buffer:f=p9.Buffer}catch{}a.isBN=function(c){return c instanceof a?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===a.wordSize&&Array.isArray(c.words)},a.max=function(c,d){return c.cmp(d)>0?c:d},a.min=function(c,d){return c.cmp(d)<0?c:d},a.prototype._init=function(c,d,g){if(typeof c=="number")return this._initNumber(c,d,g);if(typeof c=="object")return this._initArray(c,d,g);d==="hex"&&(d=16),i(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var _=0;c[0]==="-"&&(_++,this.negative=1),_<c.length&&(d===16?this._parseHex(c,_,g):(this._parseBase(c,d,_),g==="le"&&this._initArray(this.toArray(),d,g)))},a.prototype._initNumber=function(c,d,g){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(i(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),g==="le"&&this._initArray(this.toArray(),d,g)},a.prototype._initArray=function(c,d,g){if(i(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var S,x,E=0;if(g==="be")for(_=c.length-1,S=0;_>=0;_-=3)x=c[_]|c[_-1]<<8|c[_-2]<<16,this.words[S]|=x<<E&67108863,this.words[S+1]=x>>>26-E&67108863,E+=24,E>=26&&(E-=26,S++);else if(g==="le")for(_=0,S=0;_<c.length;_+=3)x=c[_]|c[_+1]<<8|c[_+2]<<16,this.words[S]|=x<<E&67108863,this.words[S+1]=x>>>26-E&67108863,E+=24,E>=26&&(E-=26,S++);return this._strip()};function p(c,d){var g=c.charCodeAt(d);if(g>=48&&g<=57)return g-48;if(g>=65&&g<=70)return g-55;if(g>=97&&g<=102)return g-87;i(!1,"Invalid character in "+c)}function w(c,d,g){var _=p(c,g);return g-1>=d&&(_|=p(c,g-1)<<4),_}a.prototype._parseHex=function(c,d,g){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var S=0,x=0,E;if(g==="be")for(_=c.length-1;_>=d;_-=2)E=w(c,d,_)<<S,this.words[x]|=E&67108863,S>=18?(S-=18,x+=1,this.words[x]|=E>>>26):S+=8;else{var u=c.length-d;for(_=u%2===0?d+1:d;_<c.length;_+=2)E=w(c,d,_)<<S,this.words[x]|=E&67108863,S>=18?(S-=18,x+=1,this.words[x]|=E>>>26):S+=8}this._strip()};function b(c,d,g,_){for(var S=0,x=0,E=Math.min(c.length,g),u=d;u<E;u++){var l=c.charCodeAt(u)-48;S*=_,l>=49?x=l-49+10:l>=17?x=l-17+10:x=l,i(l>=0&&x<_,"Invalid character"),S+=x}return S}a.prototype._parseBase=function(c,d,g){this.words=[0],this.length=1;for(var _=0,S=1;S<=67108863;S*=d)_++;_--,S=S/d|0;for(var x=c.length-g,E=x%_,u=Math.min(x,x-E)+g,l=0,R=g;R<u;R+=_)l=b(c,R,R+_,d),this.imuln(S),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l);if(E!==0){var ie=1;for(l=b(c,R,c.length,d),R=0;R<E;R++)ie*=d;this.imuln(ie),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l)}this._strip()},a.prototype.copy=function(c){c.words=new Array(this.length);for(var d=0;d<this.length;d++)c.words[d]=this.words[d];c.length=this.length,c.negative=this.negative,c.red=this.red};function A(c,d){c.words=d.words,c.length=d.length,c.negative=d.negative,c.red=d.red}if(a.prototype._move=function(c){A(c,this)},a.prototype.clone=function(){var c=new a(null);return this.copy(c),c},a.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=M}catch{a.prototype.inspect=M}else a.prototype.inspect=M;function M(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var C=["","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"],O=[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],D=[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];a.prototype.toString=function(c,d){c=c||10,d=d|0||1;var g;if(c===16||c==="hex"){g="";for(var _=0,S=0,x=0;x<this.length;x++){var E=this.words[x],u=((E<<_|S)&16777215).toString(16);S=E>>>24-_&16777215,_+=2,_>=26&&(_-=26,x--),S!==0||x!==this.length-1?g=C[6-u.length]+u+g:g=u+g}for(S!==0&&(g=S.toString(16)+g);g.length%d!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(c===(c|0)&&c>=2&&c<=36){var l=O[c],R=D[c];g="";var ie=this.clone();for(ie.negative=0;!ie.isZero();){var se=ie.modrn(R).toString(c);ie=ie.idivn(R),ie.isZero()?g=se+g:g=C[l-se.length]+se+g}for(this.isZero()&&(g="0"+g);g.length%d!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},a.prototype.toJSON=function(){return this.toString(16,2)},f&&(a.prototype.toBuffer=function(c,d){return this.toArrayLike(f,c,d)}),a.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var j=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};a.prototype.toArrayLike=function(c,d,g){this._strip();var _=this.byteLength(),S=g||Math.max(1,_);i(_<=S,"byte array longer than desired length"),i(S>0,"Requested array length <= 0");var x=j(c,S),E=d==="le"?"LE":"BE";return this["_toArrayLike"+E](x,_),x},a.prototype._toArrayLikeLE=function(c,d){for(var g=0,_=0,S=0,x=0;S<this.length;S++){var E=this.words[S]<<x|_;c[g++]=E&255,g<c.length&&(c[g++]=E>>8&255),g<c.length&&(c[g++]=E>>16&255),x===6?(g<c.length&&(c[g++]=E>>24&255),_=0,x=0):(_=E>>>24,x+=2)}if(g<c.length)for(c[g++]=_;g<c.length;)c[g++]=0},a.prototype._toArrayLikeBE=function(c,d){for(var g=c.length-1,_=0,S=0,x=0;S<this.length;S++){var E=this.words[S]<<x|_;c[g--]=E&255,g>=0&&(c[g--]=E>>8&255),g>=0&&(c[g--]=E>>16&255),x===6?(g>=0&&(c[g--]=E>>24&255),_=0,x=0):(_=E>>>24,x+=2)}if(g>=0)for(c[g--]=_;g>=0;)c[g--]=0},Math.clz32?a.prototype._countBits=function(c){return 32-Math.clz32(c)}:a.prototype._countBits=function(c){var d=c,g=0;return d>=4096&&(g+=13,d>>>=13),d>=64&&(g+=7,d>>>=7),d>=8&&(g+=4,d>>>=4),d>=2&&(g+=2,d>>>=2),g+d},a.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,g=0;return d&8191||(g+=13,d>>>=13),d&127||(g+=7,d>>>=7),d&15||(g+=4,d>>>=4),d&3||(g+=2,d>>>=2),d&1||g++,g},a.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function G(c){for(var d=new Array(c.bitLength()),g=0;g<d.length;g++){var _=g/26|0,S=g%26;d[g]=c.words[_]>>>S&1}return d}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;d<this.length;d++){var g=this._zeroBits(this.words[d]);if(c+=g,g!==26)break}return c},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},a.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var d=0;d<c.length;d++)this.words[d]=this.words[d]|c.words[d];return this._strip()},a.prototype.ior=function(c){return i((this.negative|c.negative)===0),this.iuor(c)},a.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},a.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},a.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var g=0;g<d.length;g++)this.words[g]=this.words[g]&c.words[g];return this.length=d.length,this._strip()},a.prototype.iand=function(c){return i((this.negative|c.negative)===0),this.iuand(c)},a.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},a.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},a.prototype.iuxor=function(c){var d,g;this.length>c.length?(d=this,g=c):(d=c,g=this);for(var _=0;_<g.length;_++)this.words[_]=d.words[_]^g.words[_];if(this!==d)for(;_<d.length;_++)this.words[_]=d.words[_];return this.length=d.length,this._strip()},a.prototype.ixor=function(c){return i((this.negative|c.negative)===0),this.iuxor(c)},a.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},a.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},a.prototype.inotn=function(c){i(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,g=c%26;this._expand(d),g>0&&d--;for(var _=0;_<d;_++)this.words[_]=~this.words[_]&67108863;return g>0&&(this.words[_]=~this.words[_]&67108863>>26-g),this._strip()},a.prototype.notn=function(c){return this.clone().inotn(c)},a.prototype.setn=function(c,d){i(typeof c=="number"&&c>=0);var g=c/26|0,_=c%26;return this._expand(g+1),d?this.words[g]=this.words[g]|1<<_:this.words[g]=this.words[g]&~(1<<_),this._strip()},a.prototype.iadd=function(c){var d;if(this.negative!==0&&c.negative===0)return this.negative=0,d=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,d=this.isub(c),c.negative=1,d._normSign();var g,_;this.length>c.length?(g=this,_=c):(g=c,_=this);for(var S=0,x=0;x<_.length;x++)d=(g.words[x]|0)+(_.words[x]|0)+S,this.words[x]=d&67108863,S=d>>>26;for(;S!==0&&x<g.length;x++)d=(g.words[x]|0)+S,this.words[x]=d&67108863,S=d>>>26;if(this.length=g.length,S!==0)this.words[this.length]=S,this.length++;else if(g!==this)for(;x<g.length;x++)this.words[x]=g.words[x];return this},a.prototype.add=function(c){var d;return c.negative!==0&&this.negative===0?(c.negative=0,d=this.sub(c),c.negative^=1,d):c.negative===0&&this.negative!==0?(this.negative=0,d=c.sub(this),this.negative=1,d):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},a.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var g=this.cmp(c);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,S;g>0?(_=this,S=c):(_=c,S=this);for(var x=0,E=0;E<S.length;E++)d=(_.words[E]|0)-(S.words[E]|0)+x,x=d>>26,this.words[E]=d&67108863;for(;x!==0&&E<_.length;E++)d=(_.words[E]|0)+x,x=d>>26,this.words[E]=d&67108863;if(x===0&&E<_.length&&_!==this)for(;E<_.length;E++)this.words[E]=_.words[E];return this.length=Math.max(this.length,E),_!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(c){return this.clone().isub(c)};function X(c,d,g){g.negative=d.negative^c.negative;var _=c.length+d.length|0;g.length=_,_=_-1|0;var S=c.words[0]|0,x=d.words[0]|0,E=S*x,u=E&67108863,l=E/67108864|0;g.words[0]=u;for(var R=1;R<_;R++){for(var ie=l>>>26,se=l&67108863,I=Math.min(R,d.length-1),Z=Math.max(0,R-c.length+1);Z<=I;Z++){var F=R-Z|0;S=c.words[F]|0,x=d.words[Z]|0,E=S*x+se,ie+=E/67108864|0,se=E&67108863}g.words[R]=se|0,l=ie|0}return l!==0?g.words[R]=l|0:g.length--,g._strip()}var z=function(c,d,g){var _=c.words,S=d.words,x=g.words,E=0,u,l,R,ie=_[0]|0,se=ie&8191,I=ie>>>13,Z=_[1]|0,F=Z&8191,k=Z>>>13,$=_[2]|0,m=$&8191,B=$>>>13,re=_[3]|0,he=re&8191,ue=re>>>13,ve=_[4]|0,be=ve&8191,Te=ve>>>13,nt=_[5]|0,Se=nt&8191,Ve=nt>>>13,Le=_[6]|0,Ae=Le&8191,Ue=Le>>>13,Ge=_[7]|0,ye=Ge&8191,je=Ge>>>13,Fe=_[8]|0,_e=Fe&8191,We=Fe>>>13,ke=_[9]|0,Pe=ke&8191,ot=ke>>>13,ft=S[0]|0,De=ft&8191,ct=ft>>>13,ut=S[1]|0,qe=ut&8191,wt=ut>>>13,dt=S[2]|0,$e=dt&8191,At=dt>>>13,Mt=S[3]|0,Ee=Mt&8191,Ke=Mt>>>13,Qe=S[4]|0,Ie=Qe&8191,Je=Qe>>>13,He=S[5]|0,Re=He&8191,st=He>>>13,Ye=S[6]|0,Ne=Ye&8191,Xe=Ye>>>13,et=S[7]|0,Me=et&8191,ze=et>>>13,at=S[8]|0,Ce=at&8191,Ct=at>>>13,Ot=S[9]|0,tt=Ot&8191,bt=Ot>>>13;g.negative=c.negative^d.negative,g.length=19,u=Math.imul(se,De),l=Math.imul(se,ct),l=l+Math.imul(I,De)|0,R=Math.imul(I,ct);var xr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(xr>>>26)|0,xr&=67108863,u=Math.imul(F,De),l=Math.imul(F,ct),l=l+Math.imul(k,De)|0,R=Math.imul(k,ct),u=u+Math.imul(se,qe)|0,l=l+Math.imul(se,wt)|0,l=l+Math.imul(I,qe)|0,R=R+Math.imul(I,wt)|0;var Pr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,u=Math.imul(m,De),l=Math.imul(m,ct),l=l+Math.imul(B,De)|0,R=Math.imul(B,ct),u=u+Math.imul(F,qe)|0,l=l+Math.imul(F,wt)|0,l=l+Math.imul(k,qe)|0,R=R+Math.imul(k,wt)|0,u=u+Math.imul(se,$e)|0,l=l+Math.imul(se,At)|0,l=l+Math.imul(I,$e)|0,R=R+Math.imul(I,At)|0;var Rr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,u=Math.imul(he,De),l=Math.imul(he,ct),l=l+Math.imul(ue,De)|0,R=Math.imul(ue,ct),u=u+Math.imul(m,qe)|0,l=l+Math.imul(m,wt)|0,l=l+Math.imul(B,qe)|0,R=R+Math.imul(B,wt)|0,u=u+Math.imul(F,$e)|0,l=l+Math.imul(F,At)|0,l=l+Math.imul(k,$e)|0,R=R+Math.imul(k,At)|0,u=u+Math.imul(se,Ee)|0,l=l+Math.imul(se,Ke)|0,l=l+Math.imul(I,Ee)|0,R=R+Math.imul(I,Ke)|0;var Nr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,u=Math.imul(be,De),l=Math.imul(be,ct),l=l+Math.imul(Te,De)|0,R=Math.imul(Te,ct),u=u+Math.imul(he,qe)|0,l=l+Math.imul(he,wt)|0,l=l+Math.imul(ue,qe)|0,R=R+Math.imul(ue,wt)|0,u=u+Math.imul(m,$e)|0,l=l+Math.imul(m,At)|0,l=l+Math.imul(B,$e)|0,R=R+Math.imul(B,At)|0,u=u+Math.imul(F,Ee)|0,l=l+Math.imul(F,Ke)|0,l=l+Math.imul(k,Ee)|0,R=R+Math.imul(k,Ke)|0,u=u+Math.imul(se,Ie)|0,l=l+Math.imul(se,Je)|0,l=l+Math.imul(I,Ie)|0,R=R+Math.imul(I,Je)|0;var Cr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Cr>>>26)|0,Cr&=67108863,u=Math.imul(Se,De),l=Math.imul(Se,ct),l=l+Math.imul(Ve,De)|0,R=Math.imul(Ve,ct),u=u+Math.imul(be,qe)|0,l=l+Math.imul(be,wt)|0,l=l+Math.imul(Te,qe)|0,R=R+Math.imul(Te,wt)|0,u=u+Math.imul(he,$e)|0,l=l+Math.imul(he,At)|0,l=l+Math.imul(ue,$e)|0,R=R+Math.imul(ue,At)|0,u=u+Math.imul(m,Ee)|0,l=l+Math.imul(m,Ke)|0,l=l+Math.imul(B,Ee)|0,R=R+Math.imul(B,Ke)|0,u=u+Math.imul(F,Ie)|0,l=l+Math.imul(F,Je)|0,l=l+Math.imul(k,Ie)|0,R=R+Math.imul(k,Je)|0,u=u+Math.imul(se,Re)|0,l=l+Math.imul(se,st)|0,l=l+Math.imul(I,Re)|0,R=R+Math.imul(I,st)|0;var Yt=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,u=Math.imul(Ae,De),l=Math.imul(Ae,ct),l=l+Math.imul(Ue,De)|0,R=Math.imul(Ue,ct),u=u+Math.imul(Se,qe)|0,l=l+Math.imul(Se,wt)|0,l=l+Math.imul(Ve,qe)|0,R=R+Math.imul(Ve,wt)|0,u=u+Math.imul(be,$e)|0,l=l+Math.imul(be,At)|0,l=l+Math.imul(Te,$e)|0,R=R+Math.imul(Te,At)|0,u=u+Math.imul(he,Ee)|0,l=l+Math.imul(he,Ke)|0,l=l+Math.imul(ue,Ee)|0,R=R+Math.imul(ue,Ke)|0,u=u+Math.imul(m,Ie)|0,l=l+Math.imul(m,Je)|0,l=l+Math.imul(B,Ie)|0,R=R+Math.imul(B,Je)|0,u=u+Math.imul(F,Re)|0,l=l+Math.imul(F,st)|0,l=l+Math.imul(k,Re)|0,R=R+Math.imul(k,st)|0,u=u+Math.imul(se,Ne)|0,l=l+Math.imul(se,Xe)|0,l=l+Math.imul(I,Ne)|0,R=R+Math.imul(I,Xe)|0;var Hr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,u=Math.imul(ye,De),l=Math.imul(ye,ct),l=l+Math.imul(je,De)|0,R=Math.imul(je,ct),u=u+Math.imul(Ae,qe)|0,l=l+Math.imul(Ae,wt)|0,l=l+Math.imul(Ue,qe)|0,R=R+Math.imul(Ue,wt)|0,u=u+Math.imul(Se,$e)|0,l=l+Math.imul(Se,At)|0,l=l+Math.imul(Ve,$e)|0,R=R+Math.imul(Ve,At)|0,u=u+Math.imul(be,Ee)|0,l=l+Math.imul(be,Ke)|0,l=l+Math.imul(Te,Ee)|0,R=R+Math.imul(Te,Ke)|0,u=u+Math.imul(he,Ie)|0,l=l+Math.imul(he,Je)|0,l=l+Math.imul(ue,Ie)|0,R=R+Math.imul(ue,Je)|0,u=u+Math.imul(m,Re)|0,l=l+Math.imul(m,st)|0,l=l+Math.imul(B,Re)|0,R=R+Math.imul(B,st)|0,u=u+Math.imul(F,Ne)|0,l=l+Math.imul(F,Xe)|0,l=l+Math.imul(k,Ne)|0,R=R+Math.imul(k,Xe)|0,u=u+Math.imul(se,Me)|0,l=l+Math.imul(se,ze)|0,l=l+Math.imul(I,Me)|0,R=R+Math.imul(I,ze)|0;var $i=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+($i>>>26)|0,$i&=67108863,u=Math.imul(_e,De),l=Math.imul(_e,ct),l=l+Math.imul(We,De)|0,R=Math.imul(We,ct),u=u+Math.imul(ye,qe)|0,l=l+Math.imul(ye,wt)|0,l=l+Math.imul(je,qe)|0,R=R+Math.imul(je,wt)|0,u=u+Math.imul(Ae,$e)|0,l=l+Math.imul(Ae,At)|0,l=l+Math.imul(Ue,$e)|0,R=R+Math.imul(Ue,At)|0,u=u+Math.imul(Se,Ee)|0,l=l+Math.imul(Se,Ke)|0,l=l+Math.imul(Ve,Ee)|0,R=R+Math.imul(Ve,Ke)|0,u=u+Math.imul(be,Ie)|0,l=l+Math.imul(be,Je)|0,l=l+Math.imul(Te,Ie)|0,R=R+Math.imul(Te,Je)|0,u=u+Math.imul(he,Re)|0,l=l+Math.imul(he,st)|0,l=l+Math.imul(ue,Re)|0,R=R+Math.imul(ue,st)|0,u=u+Math.imul(m,Ne)|0,l=l+Math.imul(m,Xe)|0,l=l+Math.imul(B,Ne)|0,R=R+Math.imul(B,Xe)|0,u=u+Math.imul(F,Me)|0,l=l+Math.imul(F,ze)|0,l=l+Math.imul(k,Me)|0,R=R+Math.imul(k,ze)|0,u=u+Math.imul(se,Ce)|0,l=l+Math.imul(se,Ct)|0,l=l+Math.imul(I,Ce)|0,R=R+Math.imul(I,Ct)|0;var Vr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Vr>>>26)|0,Vr&=67108863,u=Math.imul(Pe,De),l=Math.imul(Pe,ct),l=l+Math.imul(ot,De)|0,R=Math.imul(ot,ct),u=u+Math.imul(_e,qe)|0,l=l+Math.imul(_e,wt)|0,l=l+Math.imul(We,qe)|0,R=R+Math.imul(We,wt)|0,u=u+Math.imul(ye,$e)|0,l=l+Math.imul(ye,At)|0,l=l+Math.imul(je,$e)|0,R=R+Math.imul(je,At)|0,u=u+Math.imul(Ae,Ee)|0,l=l+Math.imul(Ae,Ke)|0,l=l+Math.imul(Ue,Ee)|0,R=R+Math.imul(Ue,Ke)|0,u=u+Math.imul(Se,Ie)|0,l=l+Math.imul(Se,Je)|0,l=l+Math.imul(Ve,Ie)|0,R=R+Math.imul(Ve,Je)|0,u=u+Math.imul(be,Re)|0,l=l+Math.imul(be,st)|0,l=l+Math.imul(Te,Re)|0,R=R+Math.imul(Te,st)|0,u=u+Math.imul(he,Ne)|0,l=l+Math.imul(he,Xe)|0,l=l+Math.imul(ue,Ne)|0,R=R+Math.imul(ue,Xe)|0,u=u+Math.imul(m,Me)|0,l=l+Math.imul(m,ze)|0,l=l+Math.imul(B,Me)|0,R=R+Math.imul(B,ze)|0,u=u+Math.imul(F,Ce)|0,l=l+Math.imul(F,Ct)|0,l=l+Math.imul(k,Ce)|0,R=R+Math.imul(k,Ct)|0,u=u+Math.imul(se,tt)|0,l=l+Math.imul(se,bt)|0,l=l+Math.imul(I,tt)|0,R=R+Math.imul(I,bt)|0;var zi=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(zi>>>26)|0,zi&=67108863,u=Math.imul(Pe,qe),l=Math.imul(Pe,wt),l=l+Math.imul(ot,qe)|0,R=Math.imul(ot,wt),u=u+Math.imul(_e,$e)|0,l=l+Math.imul(_e,At)|0,l=l+Math.imul(We,$e)|0,R=R+Math.imul(We,At)|0,u=u+Math.imul(ye,Ee)|0,l=l+Math.imul(ye,Ke)|0,l=l+Math.imul(je,Ee)|0,R=R+Math.imul(je,Ke)|0,u=u+Math.imul(Ae,Ie)|0,l=l+Math.imul(Ae,Je)|0,l=l+Math.imul(Ue,Ie)|0,R=R+Math.imul(Ue,Je)|0,u=u+Math.imul(Se,Re)|0,l=l+Math.imul(Se,st)|0,l=l+Math.imul(Ve,Re)|0,R=R+Math.imul(Ve,st)|0,u=u+Math.imul(be,Ne)|0,l=l+Math.imul(be,Xe)|0,l=l+Math.imul(Te,Ne)|0,R=R+Math.imul(Te,Xe)|0,u=u+Math.imul(he,Me)|0,l=l+Math.imul(he,ze)|0,l=l+Math.imul(ue,Me)|0,R=R+Math.imul(ue,ze)|0,u=u+Math.imul(m,Ce)|0,l=l+Math.imul(m,Ct)|0,l=l+Math.imul(B,Ce)|0,R=R+Math.imul(B,Ct)|0,u=u+Math.imul(F,tt)|0,l=l+Math.imul(F,bt)|0,l=l+Math.imul(k,tt)|0,R=R+Math.imul(k,bt)|0;var Ui=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,u=Math.imul(Pe,$e),l=Math.imul(Pe,At),l=l+Math.imul(ot,$e)|0,R=Math.imul(ot,At),u=u+Math.imul(_e,Ee)|0,l=l+Math.imul(_e,Ke)|0,l=l+Math.imul(We,Ee)|0,R=R+Math.imul(We,Ke)|0,u=u+Math.imul(ye,Ie)|0,l=l+Math.imul(ye,Je)|0,l=l+Math.imul(je,Ie)|0,R=R+Math.imul(je,Je)|0,u=u+Math.imul(Ae,Re)|0,l=l+Math.imul(Ae,st)|0,l=l+Math.imul(Ue,Re)|0,R=R+Math.imul(Ue,st)|0,u=u+Math.imul(Se,Ne)|0,l=l+Math.imul(Se,Xe)|0,l=l+Math.imul(Ve,Ne)|0,R=R+Math.imul(Ve,Xe)|0,u=u+Math.imul(be,Me)|0,l=l+Math.imul(be,ze)|0,l=l+Math.imul(Te,Me)|0,R=R+Math.imul(Te,ze)|0,u=u+Math.imul(he,Ce)|0,l=l+Math.imul(he,Ct)|0,l=l+Math.imul(ue,Ce)|0,R=R+Math.imul(ue,Ct)|0,u=u+Math.imul(m,tt)|0,l=l+Math.imul(m,bt)|0,l=l+Math.imul(B,tt)|0,R=R+Math.imul(B,bt)|0;var Gr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,u=Math.imul(Pe,Ee),l=Math.imul(Pe,Ke),l=l+Math.imul(ot,Ee)|0,R=Math.imul(ot,Ke),u=u+Math.imul(_e,Ie)|0,l=l+Math.imul(_e,Je)|0,l=l+Math.imul(We,Ie)|0,R=R+Math.imul(We,Je)|0,u=u+Math.imul(ye,Re)|0,l=l+Math.imul(ye,st)|0,l=l+Math.imul(je,Re)|0,R=R+Math.imul(je,st)|0,u=u+Math.imul(Ae,Ne)|0,l=l+Math.imul(Ae,Xe)|0,l=l+Math.imul(Ue,Ne)|0,R=R+Math.imul(Ue,Xe)|0,u=u+Math.imul(Se,Me)|0,l=l+Math.imul(Se,ze)|0,l=l+Math.imul(Ve,Me)|0,R=R+Math.imul(Ve,ze)|0,u=u+Math.imul(be,Ce)|0,l=l+Math.imul(be,Ct)|0,l=l+Math.imul(Te,Ce)|0,R=R+Math.imul(Te,Ct)|0,u=u+Math.imul(he,tt)|0,l=l+Math.imul(he,bt)|0,l=l+Math.imul(ue,tt)|0,R=R+Math.imul(ue,bt)|0;var mi=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(mi>>>26)|0,mi&=67108863,u=Math.imul(Pe,Ie),l=Math.imul(Pe,Je),l=l+Math.imul(ot,Ie)|0,R=Math.imul(ot,Je),u=u+Math.imul(_e,Re)|0,l=l+Math.imul(_e,st)|0,l=l+Math.imul(We,Re)|0,R=R+Math.imul(We,st)|0,u=u+Math.imul(ye,Ne)|0,l=l+Math.imul(ye,Xe)|0,l=l+Math.imul(je,Ne)|0,R=R+Math.imul(je,Xe)|0,u=u+Math.imul(Ae,Me)|0,l=l+Math.imul(Ae,ze)|0,l=l+Math.imul(Ue,Me)|0,R=R+Math.imul(Ue,ze)|0,u=u+Math.imul(Se,Ce)|0,l=l+Math.imul(Se,Ct)|0,l=l+Math.imul(Ve,Ce)|0,R=R+Math.imul(Ve,Ct)|0,u=u+Math.imul(be,tt)|0,l=l+Math.imul(be,bt)|0,l=l+Math.imul(Te,tt)|0,R=R+Math.imul(Te,bt)|0;var yi=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(yi>>>26)|0,yi&=67108863,u=Math.imul(Pe,Re),l=Math.imul(Pe,st),l=l+Math.imul(ot,Re)|0,R=Math.imul(ot,st),u=u+Math.imul(_e,Ne)|0,l=l+Math.imul(_e,Xe)|0,l=l+Math.imul(We,Ne)|0,R=R+Math.imul(We,Xe)|0,u=u+Math.imul(ye,Me)|0,l=l+Math.imul(ye,ze)|0,l=l+Math.imul(je,Me)|0,R=R+Math.imul(je,ze)|0,u=u+Math.imul(Ae,Ce)|0,l=l+Math.imul(Ae,Ct)|0,l=l+Math.imul(Ue,Ce)|0,R=R+Math.imul(Ue,Ct)|0,u=u+Math.imul(Se,tt)|0,l=l+Math.imul(Se,bt)|0,l=l+Math.imul(Ve,tt)|0,R=R+Math.imul(Ve,bt)|0;var fr=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(fr>>>26)|0,fr&=67108863,u=Math.imul(Pe,Ne),l=Math.imul(Pe,Xe),l=l+Math.imul(ot,Ne)|0,R=Math.imul(ot,Xe),u=u+Math.imul(_e,Me)|0,l=l+Math.imul(_e,ze)|0,l=l+Math.imul(We,Me)|0,R=R+Math.imul(We,ze)|0,u=u+Math.imul(ye,Ce)|0,l=l+Math.imul(ye,Ct)|0,l=l+Math.imul(je,Ce)|0,R=R+Math.imul(je,Ct)|0,u=u+Math.imul(Ae,tt)|0,l=l+Math.imul(Ae,bt)|0,l=l+Math.imul(Ue,tt)|0,R=R+Math.imul(Ue,bt)|0;var ji=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(ji>>>26)|0,ji&=67108863,u=Math.imul(Pe,Me),l=Math.imul(Pe,ze),l=l+Math.imul(ot,Me)|0,R=Math.imul(ot,ze),u=u+Math.imul(_e,Ce)|0,l=l+Math.imul(_e,Ct)|0,l=l+Math.imul(We,Ce)|0,R=R+Math.imul(We,Ct)|0,u=u+Math.imul(ye,tt)|0,l=l+Math.imul(ye,bt)|0,l=l+Math.imul(je,tt)|0,R=R+Math.imul(je,bt)|0;var Ki=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,u=Math.imul(Pe,Ce),l=Math.imul(Pe,Ct),l=l+Math.imul(ot,Ce)|0,R=Math.imul(ot,Ct),u=u+Math.imul(_e,tt)|0,l=l+Math.imul(_e,bt)|0,l=l+Math.imul(We,tt)|0,R=R+Math.imul(We,bt)|0;var Hi=(E+u|0)+((l&8191)<<13)|0;E=(R+(l>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,u=Math.imul(Pe,tt),l=Math.imul(Pe,bt),l=l+Math.imul(ot,tt)|0,R=Math.imul(ot,bt);var bs=(E+u|0)+((l&8191)<<13)|0;return E=(R+(l>>>13)|0)+(bs>>>26)|0,bs&=67108863,x[0]=xr,x[1]=Pr,x[2]=Rr,x[3]=Nr,x[4]=Cr,x[5]=Yt,x[6]=Hr,x[7]=$i,x[8]=Vr,x[9]=zi,x[10]=Ui,x[11]=Gr,x[12]=mi,x[13]=yi,x[14]=fr,x[15]=ji,x[16]=Ki,x[17]=Hi,x[18]=bs,E!==0&&(x[19]=E,g.length++),g};Math.imul||(z=X);function Q(c,d,g){g.negative=d.negative^c.negative,g.length=c.length+d.length;for(var _=0,S=0,x=0;x<g.length-1;x++){var E=S;S=0;for(var u=_&67108863,l=Math.min(x,d.length-1),R=Math.max(0,x-c.length+1);R<=l;R++){var ie=x-R,se=c.words[ie]|0,I=d.words[R]|0,Z=se*I,F=Z&67108863;E=E+(Z/67108864|0)|0,F=F+u|0,u=F&67108863,E=E+(F>>>26)|0,S+=E>>>26,E&=67108863}g.words[x]=u,_=E,E=S}return _!==0?g.words[x]=_:g.length--,g._strip()}function V(c,d,g){return Q(c,d,g)}a.prototype.mulTo=function(c,d){var g,_=this.length+c.length;return this.length===10&&c.length===10?g=z(this,c,d):_<63?g=X(this,c,d):_<1024?g=Q(this,c,d):g=V(this,c,d),g},a.prototype.mul=function(c){var d=new a(null);return d.words=new Array(this.length+c.length),this.mulTo(c,d)},a.prototype.mulf=function(c){var d=new a(null);return d.words=new Array(this.length+c.length),V(this,c,d)},a.prototype.imul=function(c){return this.clone().mulTo(c,this)},a.prototype.imuln=function(c){var d=c<0;d&&(c=-c),i(typeof c=="number"),i(c<67108864);for(var g=0,_=0;_<this.length;_++){var S=(this.words[_]|0)*c,x=(S&67108863)+(g&67108863);g>>=26,g+=S/67108864|0,g+=x>>>26,this.words[_]=x&67108863}return g!==0&&(this.words[_]=g,this.length++),d?this.ineg():this},a.prototype.muln=function(c){return this.clone().imuln(c)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(c){var d=G(c);if(d.length===0)return new a(1);for(var g=this,_=0;_<d.length&&d[_]===0;_++,g=g.sqr());if(++_<d.length)for(var S=g.sqr();_<d.length;_++,S=S.sqr())d[_]!==0&&(g=g.mul(S));return g},a.prototype.iushln=function(c){i(typeof c=="number"&&c>=0);var d=c%26,g=(c-d)/26,_=67108863>>>26-d<<26-d,S;if(d!==0){var x=0;for(S=0;S<this.length;S++){var E=this.words[S]&_,u=(this.words[S]|0)-E<<d;this.words[S]=u|x,x=E>>>26-d}x&&(this.words[S]=x,this.length++)}if(g!==0){for(S=this.length-1;S>=0;S--)this.words[S+g]=this.words[S];for(S=0;S<g;S++)this.words[S]=0;this.length+=g}return this._strip()},a.prototype.ishln=function(c){return i(this.negative===0),this.iushln(c)},a.prototype.iushrn=function(c,d,g){i(typeof c=="number"&&c>=0);var _;d?_=(d-d%26)/26:_=0;var S=c%26,x=Math.min((c-S)/26,this.length),E=67108863^67108863>>>S<<S,u=g;if(_-=x,_=Math.max(0,_),u){for(var l=0;l<x;l++)u.words[l]=this.words[l];u.length=x}if(x!==0)if(this.length>x)for(this.length-=x,l=0;l<this.length;l++)this.words[l]=this.words[l+x];else this.words[0]=0,this.length=1;var R=0;for(l=this.length-1;l>=0&&(R!==0||l>=_);l--){var ie=this.words[l]|0;this.words[l]=R<<26-S|ie>>>S,R=ie&E}return u&&R!==0&&(u.words[u.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(c,d,g){return i(this.negative===0),this.iushrn(c,d,g)},a.prototype.shln=function(c){return this.clone().ishln(c)},a.prototype.ushln=function(c){return this.clone().iushln(c)},a.prototype.shrn=function(c){return this.clone().ishrn(c)},a.prototype.ushrn=function(c){return this.clone().iushrn(c)},a.prototype.testn=function(c){i(typeof c=="number"&&c>=0);var d=c%26,g=(c-d)/26,_=1<<d;if(this.length<=g)return!1;var S=this.words[g];return!!(S&_)},a.prototype.imaskn=function(c){i(typeof c=="number"&&c>=0);var d=c%26,g=(c-d)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(d!==0&&g++,this.length=Math.min(g,this.length),d!==0){var _=67108863^67108863>>>d<<d;this.words[this.length-1]&=_}return this._strip()},a.prototype.maskn=function(c){return this.clone().imaskn(c)},a.prototype.iaddn=function(c){return i(typeof c=="number"),i(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},a.prototype._iaddn=function(c){this.words[0]+=c;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},a.prototype.isubn=function(c){if(i(typeof c=="number"),i(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,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()},a.prototype.addn=function(c){return this.clone().iaddn(c)},a.prototype.subn=function(c){return this.clone().isubn(c)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(c,d,g){var _=c.length+g,S;this._expand(_);var x,E=0;for(S=0;S<c.length;S++){x=(this.words[S+g]|0)+E;var u=(c.words[S]|0)*d;x-=u&67108863,E=(x>>26)-(u/67108864|0),this.words[S+g]=x&67108863}for(;S<this.length-g;S++)x=(this.words[S+g]|0)+E,E=x>>26,this.words[S+g]=x&67108863;if(E===0)return this._strip();for(i(E===-1),E=0,S=0;S<this.length;S++)x=-(this.words[S]|0)+E,E=x>>26,this.words[S]=x&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(c,d){var g=this.length-c.length,_=this.clone(),S=c,x=S.words[S.length-1]|0,E=this._countBits(x);g=26-E,g!==0&&(S=S.ushln(g),_.iushln(g),x=S.words[S.length-1]|0);var u=_.length-S.length,l;if(d!=="mod"){l=new a(null),l.length=u+1,l.words=new Array(l.length);for(var R=0;R<l.length;R++)l.words[R]=0}var ie=_.clone()._ishlnsubmul(S,1,u);ie.negative===0&&(_=ie,l&&(l.words[u]=1));for(var se=u-1;se>=0;se--){var I=(_.words[S.length+se]|0)*67108864+(_.words[S.length+se-1]|0);for(I=Math.min(I/x|0,67108863),_._ishlnsubmul(S,I,se);_.negative!==0;)I--,_.negative=0,_._ishlnsubmul(S,1,se),_.isZero()||(_.negative^=1);l&&(l.words[se]=I)}return l&&l._strip(),_._strip(),d!=="div"&&g!==0&&_.iushrn(g),{div:l||null,mod:_}},a.prototype.divmod=function(c,d,g){if(i(!c.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var _,S,x;return this.negative!==0&&c.negative===0?(x=this.neg().divmod(c,d),d!=="mod"&&(_=x.div.neg()),d!=="div"&&(S=x.mod.neg(),g&&S.negative!==0&&S.iadd(c)),{div:_,mod:S}):this.negative===0&&c.negative!==0?(x=this.divmod(c.neg(),d),d!=="mod"&&(_=x.div.neg()),{div:_,mod:x.mod}):this.negative&c.negative?(x=this.neg().divmod(c.neg(),d),d!=="div"&&(S=x.mod.neg(),g&&S.negative!==0&&S.isub(c)),{div:x.div,mod:S}):c.length>this.length||this.cmp(c)<0?{div:new a(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new a(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new a(this.modrn(c.words[0]))}:this._wordDiv(c,d)},a.prototype.div=function(c){return this.divmod(c,"div",!1).div},a.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},a.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},a.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var g=d.div.negative!==0?d.mod.isub(c):d.mod,_=c.ushrn(1),S=c.andln(1),x=g.cmp(_);return x<0||S===1&&x===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},a.prototype.modrn=function(c){var d=c<0;d&&(c=-c),i(c<=67108863);for(var g=(1<<26)%c,_=0,S=this.length-1;S>=0;S--)_=(g*_+(this.words[S]|0))%c;return d?-_:_},a.prototype.modn=function(c){return this.modrn(c)},a.prototype.idivn=function(c){var d=c<0;d&&(c=-c),i(c<=67108863);for(var g=0,_=this.length-1;_>=0;_--){var S=(this.words[_]|0)+g*67108864;this.words[_]=S/c|0,g=S%c}return this._strip(),d?this.ineg():this},a.prototype.divn=function(c){return this.clone().idivn(c)},a.prototype.egcd=function(c){i(c.negative===0),i(!c.isZero());var d=this,g=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var _=new a(1),S=new a(0),x=new a(0),E=new a(1),u=0;d.isEven()&&g.isEven();)d.iushrn(1),g.iushrn(1),++u;for(var l=g.clone(),R=d.clone();!d.isZero();){for(var ie=0,se=1;!(d.words[0]&se)&&ie<26;++ie,se<<=1);if(ie>0)for(d.iushrn(ie);ie-- >0;)(_.isOdd()||S.isOdd())&&(_.iadd(l),S.isub(R)),_.iushrn(1),S.iushrn(1);for(var I=0,Z=1;!(g.words[0]&Z)&&I<26;++I,Z<<=1);if(I>0)for(g.iushrn(I);I-- >0;)(x.isOdd()||E.isOdd())&&(x.iadd(l),E.isub(R)),x.iushrn(1),E.iushrn(1);d.cmp(g)>=0?(d.isub(g),_.isub(x),S.isub(E)):(g.isub(d),x.isub(_),E.isub(S))}return{a:x,b:E,gcd:g.iushln(u)}},a.prototype._invmp=function(c){i(c.negative===0),i(!c.isZero());var d=this,g=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var _=new a(1),S=new a(0),x=g.clone();d.cmpn(1)>0&&g.cmpn(1)>0;){for(var E=0,u=1;!(d.words[0]&u)&&E<26;++E,u<<=1);if(E>0)for(d.iushrn(E);E-- >0;)_.isOdd()&&_.iadd(x),_.iushrn(1);for(var l=0,R=1;!(g.words[0]&R)&&l<26;++l,R<<=1);if(l>0)for(g.iushrn(l);l-- >0;)S.isOdd()&&S.iadd(x),S.iushrn(1);d.cmp(g)>=0?(d.isub(g),_.isub(S)):(g.isub(d),S.isub(_))}var ie;return d.cmpn(1)===0?ie=_:ie=S,ie.cmpn(0)<0&&ie.iadd(c),ie},a.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),g=c.clone();d.negative=0,g.negative=0;for(var _=0;d.isEven()&&g.isEven();_++)d.iushrn(1),g.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;g.isEven();)g.iushrn(1);var S=d.cmp(g);if(S<0){var x=d;d=g,g=x}else if(S===0||g.cmpn(1)===0)break;d.isub(g)}while(!0);return g.iushln(_)},a.prototype.invm=function(c){return this.egcd(c).a.umod(c)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(c){return this.words[0]&c},a.prototype.bincn=function(c){i(typeof c=="number");var d=c%26,g=(c-d)/26,_=1<<d;if(this.length<=g)return this._expand(g+1),this.words[g]|=_,this;for(var S=_,x=g;S!==0&&x<this.length;x++){var E=this.words[x]|0;E+=S,S=E>>>26,E&=67108863,this.words[x]=E}return S!==0&&(this.words[x]=S,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var g;if(this.length>1)g=1;else{d&&(c=-c),i(c<=67108863,"Number is too big");var _=this.words[0]|0;g=_===c?0:_<c?-1:1}return this.negative!==0?-g|0:g},a.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var d=this.ucmp(c);return this.negative!==0?-d|0:d},a.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var d=0,g=this.length-1;g>=0;g--){var _=this.words[g]|0,S=c.words[g]|0;if(_!==S){_<S?d=-1:_>S&&(d=1);break}}return d},a.prototype.gtn=function(c){return this.cmpn(c)===1},a.prototype.gt=function(c){return this.cmp(c)===1},a.prototype.gten=function(c){return this.cmpn(c)>=0},a.prototype.gte=function(c){return this.cmp(c)>=0},a.prototype.ltn=function(c){return this.cmpn(c)===-1},a.prototype.lt=function(c){return this.cmp(c)===-1},a.prototype.lten=function(c){return this.cmpn(c)<=0},a.prototype.lte=function(c){return this.cmp(c)<=0},a.prototype.eqn=function(c){return this.cmpn(c)===0},a.prototype.eq=function(c){return this.cmp(c)===0},a.red=function(c){return new L(c)},a.prototype.toRed=function(c){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(c){return this.red=c,this},a.prototype.forceRed=function(c){return i(!this.red,"Already a number in reduction context"),this._forceRed(c)},a.prototype.redAdd=function(c){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},a.prototype.redIAdd=function(c){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},a.prototype.redSub=function(c){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},a.prototype.redISub=function(c){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},a.prototype.redShl=function(c){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},a.prototype.redMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},a.prototype.redIMul=function(c){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(c){return i(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var H={k256:null,p224:null,p192:null,p25519:null};function ee(c,d){this.name=c,this.p=new a(d,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}ee.prototype._tmp=function(){var c=new a(null);return c.words=new Array(Math.ceil(this.n/13)),c},ee.prototype.ireduce=function(c){var d=c,g;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),g=d.bitLength();while(g>this.n);var _=g<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},ee.prototype.split=function(c,d){c.iushrn(this.n,0,d)},ee.prototype.imulK=function(c){return c.imul(this.k)};function oe(){ee.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(oe,ee),oe.prototype.split=function(c,d){for(var g=4194303,_=Math.min(c.length,9),S=0;S<_;S++)d.words[S]=c.words[S];if(d.length=_,c.length<=9){c.words[0]=0,c.length=1;return}var x=c.words[9];for(d.words[d.length++]=x&g,S=10;S<c.length;S++){var E=c.words[S]|0;c.words[S-10]=(E&g)<<4|x>>>22,x=E}x>>>=22,c.words[S-10]=x,x===0&&c.length>10?c.length-=10:c.length-=9},oe.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,g=0;g<c.length;g++){var _=c.words[g]|0;d+=_*977,c.words[g]=d&67108863,d=_*64+(d/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function ne(){ee.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ne,ee);function ge(){ee.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(ge,ee);function ht(){ee.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ht,ee),ht.prototype.imulK=function(c){for(var d=0,g=0;g<c.length;g++){var _=(c.words[g]|0)*19+d,S=_&67108863;_>>>=26,c.words[g]=S,d=_}return d!==0&&(c.words[c.length++]=d),c},a._prime=function(c){if(H[c])return H[c];var d;if(c==="k256")d=new oe;else if(c==="p224")d=new ne;else if(c==="p192")d=new ge;else if(c==="p25519")d=new ht;else throw new Error("Unknown prime "+c);return H[c]=d,d};function L(c){if(typeof c=="string"){var d=a._prime(c);this.m=d.p,this.prime=d}else i(c.gtn(1),"modulus must be greater than 1"),this.m=c,this.prime=null}L.prototype._verify1=function(c){i(c.negative===0,"red works only with positives"),i(c.red,"red works only with red numbers")},L.prototype._verify2=function(c,d){i((c.negative|d.negative)===0,"red works only with positives"),i(c.red&&c.red===d.red,"red works only with red numbers")},L.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(A(c,c.umod(this.m)._forceRed(this)),c)},L.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},L.prototype.add=function(c,d){this._verify2(c,d);var g=c.add(d);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},L.prototype.iadd=function(c,d){this._verify2(c,d);var g=c.iadd(d);return g.cmp(this.m)>=0&&g.isub(this.m),g},L.prototype.sub=function(c,d){this._verify2(c,d);var g=c.sub(d);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},L.prototype.isub=function(c,d){this._verify2(c,d);var g=c.isub(d);return g.cmpn(0)<0&&g.iadd(this.m),g},L.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},L.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},L.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},L.prototype.isqr=function(c){return this.imul(c,c.clone())},L.prototype.sqr=function(c){return this.mul(c,c)},L.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(i(d%2===1),d===3){var g=this.m.add(new a(1)).iushrn(2);return this.pow(c,g)}for(var _=this.m.subn(1),S=0;!_.isZero()&&_.andln(1)===0;)S++,_.iushrn(1);i(!_.isZero());var x=new a(1).toRed(this),E=x.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new a(2*l*l).toRed(this);this.pow(l,u).cmp(E)!==0;)l.redIAdd(E);for(var R=this.pow(l,_),ie=this.pow(c,_.addn(1).iushrn(1)),se=this.pow(c,_),I=S;se.cmp(x)!==0;){for(var Z=se,F=0;Z.cmp(x)!==0;F++)Z=Z.redSqr();i(F<I);var k=this.pow(R,new a(1).iushln(I-F-1));ie=ie.redMul(k),R=k.redSqr(),se=se.redMul(R),I=F}return ie},L.prototype.invm=function(c){var d=c._invmp(this.m);return d.negative!==0?(d.negative=0,this.imod(d).redNeg()):this.imod(d)},L.prototype.pow=function(c,d){if(d.isZero())return new a(1).toRed(this);if(d.cmpn(1)===0)return c.clone();var g=4,_=new Array(1<<g);_[0]=new a(1).toRed(this),_[1]=c;for(var S=2;S<_.length;S++)_[S]=this.mul(_[S-1],c);var x=_[0],E=0,u=0,l=d.bitLength()%26;for(l===0&&(l=26),S=d.length-1;S>=0;S--){for(var R=d.words[S],ie=l-1;ie>=0;ie--){var se=R>>ie&1;if(x!==_[0]&&(x=this.sqr(x)),se===0&&E===0){u=0;continue}E<<=1,E|=se,u++,!(u!==g&&(S!==0||ie!==0))&&(x=this.mul(x,_[E]),u=0,E=0)}l=26}return x},L.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},L.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},a.mont=function(c){return new v(c)};function v(c){L.call(this,c),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}s(v,L),v.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},v.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},v.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var g=c.imul(d),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=g.isub(_).iushrn(this.shift),x=S;return S.cmp(this.m)>=0?x=S.isub(this.m):S.cmpn(0)<0&&(x=S.iadd(this.m)),x._forceRed(this)},v.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new a(0)._forceRed(this);var g=c.mul(d),_=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=g.isub(_).iushrn(this.shift),x=S;return S.cmp(this.m)>=0?x=S.isub(this.m):S.cmpn(0)<0&&(x=S.iadd(this.m)),x._forceRed(this)},v.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(r,qg)})($g);var vt=$g.exports;const zg="bignumber/5.7.0";var wf=vt.BN;const Un=new Ir(zg),lu={},Pp=9007199254740991;function g9(r){return r!=null&&(Kt.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||gi(r)||typeof r=="bigint"||Oa(r))}let Rp=!1;class Kt{constructor(e,t){e!==lu&&Un.throwError("cannot call constructor directly; use BigNumber.from",Ir.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Zr(xt(this).fromTwos(e))}toTwos(e){return Zr(xt(this).toTwos(e))}abs(){return this._hex[0]==="-"?Kt.from(this._hex.substring(1)):this}add(e){return Zr(xt(this).add(xt(e)))}sub(e){return Zr(xt(this).sub(xt(e)))}div(e){return Kt.from(e).isZero()&&Pi("division-by-zero","div"),Zr(xt(this).div(xt(e)))}mul(e){return Zr(xt(this).mul(xt(e)))}mod(e){const t=xt(e);return t.isNeg()&&Pi("division-by-zero","mod"),Zr(xt(this).umod(t))}pow(e){const t=xt(e);return t.isNeg()&&Pi("negative-power","pow"),Zr(xt(this).pow(t))}and(e){const t=xt(e);return(this.isNegative()||t.isNeg())&&Pi("unbound-bitwise-result","and"),Zr(xt(this).and(t))}or(e){const t=xt(e);return(this.isNegative()||t.isNeg())&&Pi("unbound-bitwise-result","or"),Zr(xt(this).or(t))}xor(e){const t=xt(e);return(this.isNegative()||t.isNeg())&&Pi("unbound-bitwise-result","xor"),Zr(xt(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Pi("negative-width","mask"),Zr(xt(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Pi("negative-width","shl"),Zr(xt(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Pi("negative-width","shr"),Zr(xt(this).shrn(e))}eq(e){return xt(this).eq(xt(e))}lt(e){return xt(this).lt(xt(e))}lte(e){return xt(this).lte(xt(e))}gt(e){return xt(this).gt(xt(e))}gte(e){return xt(this).gte(xt(e))}isNegative(){return this._hex[0]==="-"}isZero(){return xt(this).isZero()}toNumber(){try{return xt(this).toNumber()}catch{Pi("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Un.throwError("this platform does not support BigInt",Ir.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Rp||(Rp=!0,Un.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Un.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ir.errors.UNEXPECTED_ARGUMENT,{}):Un.throwError("BigNumber.toString does not accept parameters",Ir.errors.UNEXPECTED_ARGUMENT,{})),xt(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Kt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Kt(lu,So(e)):e.match(/^-?[0-9]+$/)?new Kt(lu,So(new wf(e))):Un.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Pi("underflow","BigNumber.from",e),(e>=Pp||e<=-Pp)&&Pi("overflow","BigNumber.from",e),Kt.from(String(e));const t=e;if(typeof t=="bigint")return Kt.from(t.toString());if(Oa(t))return Kt.from(ri(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return Kt.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(gi(i)||i[0]==="-"&&gi(i.substring(1))))return Kt.from(i)}return Un.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function So(r){if(typeof r!="string")return So(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Un.throwArgumentError("invalid hex","value",r),r=So(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function Zr(r){return Kt.from(So(r))}function xt(r){const e=Kt.from(r).toHexString();return e[0]==="-"?new wf("-"+e.substring(3),16):new wf(e.substring(2),16)}function Pi(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),Un.throwError(r,Ir.errors.NUMERIC_FAULT,i)}function v9(r){return new wf(r,36).toString(16)}const Ur=new Ir(zg),_o={},Ug=Kt.from(0),jg=Kt.from(-1);function Kg(r,e,t,i){const s={fault:e,operation:t};return i!==void 0&&(s.value=i),Ur.throwError(r,Ir.errors.NUMERIC_FAULT,s)}let Ao="0";for(;Ao.length<256;)Ao+=Ao;function yd(r){if(typeof r!="number")try{r=Kt.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Ao.substring(0,r):Ur.throwArgumentError("invalid decimal size","decimals",r)}function pu(r,e){e==null&&(e=0);const t=yd(e);r=Kt.from(r);const i=r.lt(Ug);i&&(r=r.mul(jg));let s=r.mod(t).toString();for(;s.length<t.length-1;)s="0"+s;s=s.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=r.div(t).toString();return t.length===1?r=a:r=a+"."+s,i&&(r="-"+r),r}function $n(r,e){e==null&&(e=0);const t=yd(e);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Ur.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Ur.throwArgumentError("missing value","value",r);const s=r.split(".");s.length>2&&Ur.throwArgumentError("too many decimal points","value",r);let a=s[0],f=s[1];for(a||(a="0"),f||(f="0");f[f.length-1]==="0";)f=f.substring(0,f.length-1);for(f.length>t.length-1&&Kg("fractional component exceeds decimals","underflow","parseFixed"),f===""&&(f="0");f.length<t.length-1;)f+="0";const p=Kt.from(a),w=Kt.from(f);let b=p.mul(t).add(w);return i&&(b=b.mul(jg)),b}let gu=class Uu{constructor(e,t,i,s){e!==_o&&Ur.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ir.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=i,this.decimals=s,this.name=(t?"":"u")+"fixed"+String(i)+"x"+String(s),this._multiplier=yd(s),Object.freeze(this)}static from(e){if(e instanceof Uu)return e;typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,i=128,s=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const a=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);a||Ur.throwArgumentError("invalid fixed format","format",e),t=a[1]!=="u",i=parseInt(a[2]),s=parseInt(a[3])}}else if(e){const a=(f,p,w)=>e[f]==null?w:(typeof e[f]!==p&&Ur.throwArgumentError("invalid fixed format ("+f+" not "+p+")","format."+f,e[f]),e[f]);t=a("signed","boolean",t),i=a("width","number",i),s=a("decimals","number",s)}return i%8&&Ur.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),s>80&&Ur.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new Uu(_o,t,i,s)}},Hg=class $r{constructor(e,t,i,s){e!==_o&&Ur.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ir.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=s,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Ur.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=$n(this._value,this.format.decimals),i=$n(e._value,e.format.decimals);return $r.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=$n(this._value,this.format.decimals),i=$n(e._value,e.format.decimals);return $r.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=$n(this._value,this.format.decimals),i=$n(e._value,e.format.decimals);return $r.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=$n(this._value,this.format.decimals),i=$n(e._value,e.format.decimals);return $r.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=$r.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(Np.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=$r.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(Np.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Ur.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=$r.from("1"+Ao.substring(0,e),this.format),s=b9.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(s).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&&Ur.throwArgumentError("invalid byte width","width",e);const t=Kt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return _n(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return $r.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!g9(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),$r.fromString(pu(e,t),gu.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=gu.from(t),s=$n(e,i.decimals);!i.signed&&s.lt(Ug)&&Kg("unsigned value cannot be negative","overflow","value",e);let a=null;i.signed?a=s.toTwos(i.width).toHexString():(a=s.toHexString(),a=_n(a,i.width/8));const f=pu(s,i.decimals);return new $r(_o,a,f,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=gu.from(t);if(er(e).length>i.width/8)throw new Error("overflow");let s=Kt.from(e);i.signed&&(s=s.fromTwos(i.width));const a=s.toTwos((i.signed?0:1)+i.width).toHexString(),f=pu(s,i.decimals);return new $r(_o,a,f,i)}static from(e,t){if(typeof e=="string")return $r.fromString(e,t);if(Oa(e))return $r.fromBytes(e,t);try{return $r.fromValue(e,0,t)}catch(i){if(i.code!==Ir.errors.INVALID_ARGUMENT)throw i}return Ur.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}};const Np=Hg.from(1),b9=Hg.from("0.5"),m9="strings/5.7.0",y9=new Ir(m9);var _f;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(_f||(_f={}));var Cp;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(Cp||(Cp={}));function vu(r,e=_f.current){e!=_f.current&&(y9.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i<r.length;i++){const s=r.charCodeAt(i);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){i++;const a=r.charCodeAt(i);if(i>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const f=65536+((s&1023)<<10)+(a&1023);t.push(f>>18|240),t.push(f>>12&63|128),t.push(f>>6&63|128),t.push(f&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return er(t)}function w9(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t<r.length;t+=4)e.push(parseInt(r.substring(t,t+4),16));return e}function bu(r,e){e||(e=function(s){return[parseInt(s,16)]});let t=0,i={};return r.split(",").forEach(s=>{let a=s.split(":");t+=parseInt(a[0],16),i[t]=e(a[1])}),i}function Op(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let s=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:s,h:e}})}Op("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(r=>parseInt(r,16)),bu("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"),bu("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"),bu("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",w9),Op("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 _9(r){r=atob(r);const e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return er(e)}function Vg(r,e){e==null&&(e=1);const t=[],i=t.forEach,s=function(a,f){i.call(a,function(p){f>0&&Array.isArray(p)?s(p,f-1):t.push(p)})};return s(r,e),t}function A9(r){const e={};for(let t=0;t<r.length;t++){const i=r[t];e[i[0]]=i[1]}return e}function E9(r){let e=0;function t(){return r[e++]<<8|r[e++]}let i=t(),s=1,a=[0,1];for(let H=1;H<i;H++)a.push(s+=t());let f=t(),p=e;e+=f;let w=0,b=0;function A(){return w==0&&(b=b<<8|r[e++],w=8),b>>--w&1}const M=31,C=Math.pow(2,M),O=C>>>1,D=O>>1,j=C-1;let G=0;for(let H=0;H<M;H++)G=G<<1|A();let X=[],z=0,Q=C;for(;;){let H=Math.floor(((G-z+1)*s-1)/Q),ee=0,oe=i;for(;oe-ee>1;){let ht=ee+oe>>>1;H<a[ht]?oe=ht:ee=ht}if(ee==0)break;X.push(ee);let ne=z+Math.floor(Q*a[ee]/s),ge=z+Math.floor(Q*a[ee+1]/s)-1;for(;!((ne^ge)&O);)G=G<<1&j|A(),ne=ne<<1&j,ge=ge<<1&j|1;for(;ne&~ge&D;)G=G&O|G<<1&j>>>1|A(),ne=ne<<1^O,ge=(ge^O)<<1|O|1;z=ne,Q=1+ge-ne}let V=i-4;return X.map(H=>{switch(H-V){case 3:return V+65792+(r[p++]<<16|r[p++]<<8|r[p++]);case 2:return V+256+(r[p++]<<8|r[p++]);case 1:return V+r[p++];default:return H-1}})}function I9(r){let e=0;return()=>r[e++]}function M9(r){return I9(E9(r))}function S9(r){return r&1?~r>>1:r>>1}function x9(r,e){let t=Array(r);for(let i=0;i<r;i++)t[i]=1+e();return t}function Tp(r,e){let t=Array(r);for(let i=0,s=-1;i<r;i++)t[i]=s+=1+e();return t}function P9(r,e){let t=Array(r);for(let i=0,s=0;i<r;i++)t[i]=s+=S9(e());return t}function Af(r,e){let t=Tp(r(),r),i=r(),s=Tp(i,r),a=x9(i,r);for(let f=0;f<i;f++)for(let p=0;p<a[f];p++)t.push(s[f]+p);return e?t.map(f=>e[f]):t}function R9(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(C9(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(O9(t,r))}return A9(Vg(e))}function N9(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function Gg(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let s=0;s<e;s++)P9(r,t).forEach((a,f)=>i[f].push(a));return i}function C9(r,e){let t=1+e(),i=e(),s=N9(e),a=Gg(s.length,1+r,e);return Vg(a.map((f,p)=>{const w=f[0],b=f.slice(1);return Array(s[p]).fill(void 0).map((A,M)=>{let C=M*i;return[w+M*t,b.map(O=>O+C)]})}))}function O9(r,e){let t=1+e();return Gg(t,1+r,e).map(i=>[i[0],i.slice(1)])}function T9(r){let e=Af(r).sort((i,s)=>i-s);return t();function t(){let i=[];for(;;){let b=Af(r,e);if(b.length==0)break;i.push({set:new Set(b),node:t()})}i.sort((b,A)=>A.set.size-b.set.size);let s=r(),a=s%3;s=s/3|0;let f=!!(s&1);s>>=1;let p=s==1,w=s==2;return{branches:i,valid:a,fe0f:f,save:p,check:w}}}function D9(){return M9(_9("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 Hc=D9();new Set(Af(Hc)),new Set(Af(Hc)),R9(Hc),T9(Hc);const F9=new Uint8Array(32);F9.fill(0);const q9=`Ethereum Signed Message:
`;function Jg(r){return typeof r=="string"&&(r=vu(r)),md(f9([vu(q9),vu(String(r.length)),r]))}const B9="address/5.7.0",vo=new Ir(B9);function Dp(r){gi(r,20)||vo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const i=er(md(t));for(let s=0;s<40;s+=2)i[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(i[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const L9=9007199254740991;function k9(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const wd={};for(let r=0;r<10;r++)wd[String(r)]=String(r);for(let r=0;r<26;r++)wd[String.fromCharCode(65+r)]=String(10+r);const Fp=Math.floor(k9(L9));function $9(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>wd[i]).join("");for(;e.length>=Fp;){let i=e.substring(0,Fp);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function z9(r){let e=null;if(typeof r!="string"&&vo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Dp(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&vo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==$9(r)&&vo.throwArgumentError("bad icap checksum","address",r),e=v9(r.substring(4));e.length<40;)e="0"+e;e=Dp("0x"+e)}else vo.throwArgumentError("invalid address","address",r);return e}function no(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}const U9=new Uint8Array(32);U9.fill(0),Kt.from(-1);const j9=Kt.from(0),K9=Kt.from(1);Kt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_n(K9.toHexString(),32),_n(j9.toHexString(),32);var vn={},Pt={},Bo=Wg;function Wg(r,e){if(!r)throw new Error(e||"Assertion failed")}Wg.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var ju={exports:{}};typeof Object.create=="function"?ju.exports=function(r,e){e&&(r.super_=e,r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:ju.exports=function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}};var H9=Bo,V9=ju.exports;Pt.inherits=V9;function G9(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function J9(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),s=0;s<r.length;s+=2)t.push(parseInt(r[s]+r[s+1],16))}else for(var i=0,s=0;s<r.length;s++){var a=r.charCodeAt(s);a<128?t[i++]=a:a<2048?(t[i++]=a>>6|192,t[i++]=a&63|128):G9(r,s)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++s)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(s=0;s<r.length;s++)t[s]=r[s]|0;return t}Pt.toArray=J9;function W9(r){for(var e="",t=0;t<r.length;t++)e+=Yg(r[t].toString(16));return e}Pt.toHex=W9;function Qg(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Pt.htonl=Qg;function Q9(r,e){for(var t="",i=0;i<r.length;i++){var s=r[i];e==="little"&&(s=Qg(s)),t+=Xg(s.toString(16))}return t}Pt.toHex32=Q9;function Yg(r){return r.length===1?"0"+r:r}Pt.zero2=Yg;function Xg(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Pt.zero8=Xg;function Y9(r,e,t,i){var s=t-e;H9(s%4===0);for(var a=new Array(s/4),f=0,p=e;f<a.length;f++,p+=4){var w;i==="big"?w=r[p]<<24|r[p+1]<<16|r[p+2]<<8|r[p+3]:w=r[p+3]<<24|r[p+2]<<16|r[p+1]<<8|r[p],a[f]=w>>>0}return a}Pt.join32=Y9;function X9(r,e){for(var t=new Array(r.length*4),i=0,s=0;i<r.length;i++,s+=4){var a=r[i];e==="big"?(t[s]=a>>>24,t[s+1]=a>>>16&255,t[s+2]=a>>>8&255,t[s+3]=a&255):(t[s+3]=a>>>24,t[s+2]=a>>>16&255,t[s+1]=a>>>8&255,t[s]=a&255)}return t}Pt.split32=X9;function Z9(r,e){return r>>>e|r<<32-e}Pt.rotr32=Z9;function e7(r,e){return r<<e|r>>>32-e}Pt.rotl32=e7;function t7(r,e){return r+e>>>0}Pt.sum32=t7;function r7(r,e,t){return r+e+t>>>0}Pt.sum32_3=r7;function i7(r,e,t,i){return r+e+t+i>>>0}Pt.sum32_4=i7;function n7(r,e,t,i,s){return r+e+t+i+s>>>0}Pt.sum32_5=n7;function s7(r,e,t,i){var s=r[e],a=r[e+1],f=i+a>>>0,p=(f<i?1:0)+t+s;r[e]=p>>>0,r[e+1]=f}Pt.sum64=s7;function a7(r,e,t,i){var s=e+i>>>0,a=(s<e?1:0)+r+t;return a>>>0}Pt.sum64_hi=a7;function o7(r,e,t,i){var s=e+i;return s>>>0}Pt.sum64_lo=o7;function c7(r,e,t,i,s,a,f,p){var w=0,b=e;b=b+i>>>0,w+=b<e?1:0,b=b+a>>>0,w+=b<a?1:0,b=b+p>>>0,w+=b<p?1:0;var A=r+t+s+f+w;return A>>>0}Pt.sum64_4_hi=c7;function f7(r,e,t,i,s,a,f,p){var w=e+i+a+p;return w>>>0}Pt.sum64_4_lo=f7;function h7(r,e,t,i,s,a,f,p,w,b){var A=0,M=e;M=M+i>>>0,A+=M<e?1:0,M=M+a>>>0,A+=M<a?1:0,M=M+p>>>0,A+=M<p?1:0,M=M+b>>>0,A+=M<b?1:0;var C=r+t+s+f+w+A;return C>>>0}Pt.sum64_5_hi=h7;function u7(r,e,t,i,s,a,f,p,w,b){var A=e+i+a+p+b;return A>>>0}Pt.sum64_5_lo=u7;function d7(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Pt.rotr64_hi=d7;function l7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Pt.rotr64_lo=l7;function p7(r,e,t){return r>>>t}Pt.shr64_hi=p7;function g7(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Pt.shr64_lo=g7;var Ta={},qp=Pt,v7=Bo;function Vc(){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}Ta.BlockHash=Vc,Vc.prototype.update=function(r,e){if(r=qp.toArray(r,e),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var t=r.length%this._delta8;this.pending=r.slice(r.length-t,r.length),this.pending.length===0&&(this.pending=null),r=qp.join32(r,0,r.length-t,this.endian);for(var i=0;i<r.length;i+=this._delta32)this._update(r,i,i+this._delta32)}return this},Vc.prototype.digest=function(r){return this.update(this._pad()),v7(this.pending===null),this._digest(r)},Vc.prototype._pad=function(){var r=this.pendingTotal,e=this._delta8,t=e-(r+this.padLength)%e,i=new Array(t+this.padLength);i[0]=128;for(var s=1;s<t;s++)i[s]=0;if(r<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)i[s++]=0;i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=r>>>24&255,i[s++]=r>>>16&255,i[s++]=r>>>8&255,i[s++]=r&255}else for(i[s++]=r&255,i[s++]=r>>>8&255,i[s++]=r>>>16&255,i[s++]=r>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,a=8;a<this.padLength;a++)i[s++]=0;return i};var ga={},Rn={},b7=Pt,An=b7.rotr32;function m7(r,e,t,i){if(r===0)return Zg(e,t,i);if(r===1||r===3)return tv(e,t,i);if(r===2)return ev(e,t,i)}Rn.ft_1=m7;function Zg(r,e,t){return r&e^~r&t}Rn.ch32=Zg;function ev(r,e,t){return r&e^r&t^e&t}Rn.maj32=ev;function tv(r,e,t){return r^e^t}Rn.p32=tv;function y7(r){return An(r,2)^An(r,13)^An(r,22)}Rn.s0_256=y7;function w7(r){return An(r,6)^An(r,11)^An(r,25)}Rn.s1_256=w7;function _7(r){return An(r,7)^An(r,18)^r>>>3}Rn.g0_256=_7;function A7(r){return An(r,17)^An(r,19)^r>>>10}Rn.g1_256=A7;var Ea=Pt,E7=Ta,I7=Rn,mu=Ea.rotl32,so=Ea.sum32,M7=Ea.sum32_5,S7=I7.ft_1,rv=E7.BlockHash,x7=[1518500249,1859775393,2400959708,3395469782];function yn(){if(!(this instanceof yn))return new yn;rv.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ea.inherits(yn,rv);var P7=yn;yn.blockSize=512,yn.outSize=160,yn.hmacStrength=80,yn.padLength=64,yn.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;i<t.length;i++)t[i]=mu(t[i-3]^t[i-8]^t[i-14]^t[i-16],1);var s=this.h[0],a=this.h[1],f=this.h[2],p=this.h[3],w=this.h[4];for(i=0;i<t.length;i++){var b=~~(i/20),A=M7(mu(s,5),S7(b,a,f,p),w,t[i],x7[b]);w=p,p=f,f=mu(a,30),a=s,s=A}this.h[0]=so(this.h[0],s),this.h[1]=so(this.h[1],a),this.h[2]=so(this.h[2],f),this.h[3]=so(this.h[3],p),this.h[4]=so(this.h[4],w)},yn.prototype._digest=function(r){return r==="hex"?Ea.toHex32(this.h,"big"):Ea.split32(this.h,"big")};var Ia=Pt,R7=Ta,Da=Rn,N7=Bo,Yi=Ia.sum32,C7=Ia.sum32_4,O7=Ia.sum32_5,T7=Da.ch32,D7=Da.maj32,F7=Da.s0_256,q7=Da.s1_256,B7=Da.g0_256,L7=Da.g1_256,iv=R7.BlockHash,k7=[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 wn(){if(!(this instanceof wn))return new wn;iv.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=k7,this.W=new Array(64)}Ia.inherits(wn,iv);var nv=wn;wn.blockSize=512,wn.outSize=256,wn.hmacStrength=192,wn.padLength=64,wn.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;i<t.length;i++)t[i]=C7(L7(t[i-2]),t[i-7],B7(t[i-15]),t[i-16]);var s=this.h[0],a=this.h[1],f=this.h[2],p=this.h[3],w=this.h[4],b=this.h[5],A=this.h[6],M=this.h[7];for(N7(this.k.length===t.length),i=0;i<t.length;i++){var C=O7(M,q7(w),T7(w,b,A),this.k[i],t[i]),O=Yi(F7(s),D7(s,a,f));M=A,A=b,b=w,w=Yi(p,C),p=f,f=a,a=s,s=Yi(C,O)}this.h[0]=Yi(this.h[0],s),this.h[1]=Yi(this.h[1],a),this.h[2]=Yi(this.h[2],f),this.h[3]=Yi(this.h[3],p),this.h[4]=Yi(this.h[4],w),this.h[5]=Yi(this.h[5],b),this.h[6]=Yi(this.h[6],A),this.h[7]=Yi(this.h[7],M)},wn.prototype._digest=function(r){return r==="hex"?Ia.toHex32(this.h,"big"):Ia.split32(this.h,"big")};var Ku=Pt,sv=nv;function Kn(){if(!(this instanceof Kn))return new Kn;sv.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Ku.inherits(Kn,sv);var $7=Kn;Kn.blockSize=512,Kn.outSize=224,Kn.hmacStrength=192,Kn.padLength=64,Kn.prototype._digest=function(r){return r==="hex"?Ku.toHex32(this.h.slice(0,7),"big"):Ku.split32(this.h.slice(0,7),"big")};var ai=Pt,z7=Ta,U7=Bo,En=ai.rotr64_hi,In=ai.rotr64_lo,av=ai.shr64_hi,ov=ai.shr64_lo,as=ai.sum64,yu=ai.sum64_hi,wu=ai.sum64_lo,j7=ai.sum64_4_hi,K7=ai.sum64_4_lo,H7=ai.sum64_5_hi,V7=ai.sum64_5_lo,cv=z7.BlockHash,G7=[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 rn(){if(!(this instanceof rn))return new rn;cv.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=G7,this.W=new Array(160)}ai.inherits(rn,cv);var fv=rn;rn.blockSize=1024,rn.outSize=512,rn.hmacStrength=192,rn.padLength=128,rn.prototype._prepareBlock=function(r,e){for(var t=this.W,i=0;i<32;i++)t[i]=r[e+i];for(;i<t.length;i+=2){var s=n_(t[i-4],t[i-3]),a=s_(t[i-4],t[i-3]),f=t[i-14],p=t[i-13],w=r_(t[i-30],t[i-29]),b=i_(t[i-30],t[i-29]),A=t[i-32],M=t[i-31];t[i]=j7(s,a,f,p,w,b,A,M),t[i+1]=K7(s,a,f,p,w,b,A,M)}},rn.prototype._update=function(r,e){this._prepareBlock(r,e);var t=this.W,i=this.h[0],s=this.h[1],a=this.h[2],f=this.h[3],p=this.h[4],w=this.h[5],b=this.h[6],A=this.h[7],M=this.h[8],C=this.h[9],O=this.h[10],D=this.h[11],j=this.h[12],G=this.h[13],X=this.h[14],z=this.h[15];U7(this.k.length===t.length);for(var Q=0;Q<t.length;Q+=2){var V=X,H=z,ee=e_(M,C),oe=t_(M,C),ne=J7(M,C,O,D,j),ge=W7(M,C,O,D,j,G),ht=this.k[Q],L=this.k[Q+1],v=t[Q],c=t[Q+1],d=H7(V,H,ee,oe,ne,ge,ht,L,v,c),g=V7(V,H,ee,oe,ne,ge,ht,L,v,c);V=X7(i,s),H=Z7(i,s),ee=Q7(i,s,a,f,p),oe=Y7(i,s,a,f,p,w);var _=yu(V,H,ee,oe),S=wu(V,H,ee,oe);X=j,z=G,j=O,G=D,O=M,D=C,M=yu(b,A,d,g),C=wu(A,A,d,g),b=p,A=w,p=a,w=f,a=i,f=s,i=yu(d,g,_,S),s=wu(d,g,_,S)}as(this.h,0,i,s),as(this.h,2,a,f),as(this.h,4,p,w),as(this.h,6,b,A),as(this.h,8,M,C),as(this.h,10,O,D),as(this.h,12,j,G),as(this.h,14,X,z)},rn.prototype._digest=function(r){return r==="hex"?ai.toHex32(this.h,"big"):ai.split32(this.h,"big")};function J7(r,e,t,i,s){var a=r&t^~r&s;return a<0&&(a+=4294967296),a}function W7(r,e,t,i,s,a){var f=e&i^~e&a;return f<0&&(f+=4294967296),f}function Q7(r,e,t,i,s){var a=r&t^r&s^t&s;return a<0&&(a+=4294967296),a}function Y7(r,e,t,i,s,a){var f=e&i^e&a^i&a;return f<0&&(f+=4294967296),f}function X7(r,e){var t=En(r,e,28),i=En(e,r,2),s=En(e,r,7),a=t^i^s;return a<0&&(a+=4294967296),a}function Z7(r,e){var t=In(r,e,28),i=In(e,r,2),s=In(e,r,7),a=t^i^s;return a<0&&(a+=4294967296),a}function e_(r,e){var t=En(r,e,14),i=En(r,e,18),s=En(e,r,9),a=t^i^s;return a<0&&(a+=4294967296),a}function t_(r,e){var t=In(r,e,14),i=In(r,e,18),s=In(e,r,9),a=t^i^s;return a<0&&(a+=4294967296),a}function r_(r,e){var t=En(r,e,1),i=En(r,e,8),s=av(r,e,7),a=t^i^s;return a<0&&(a+=4294967296),a}function i_(r,e){var t=In(r,e,1),i=In(r,e,8),s=ov(r,e,7),a=t^i^s;return a<0&&(a+=4294967296),a}function n_(r,e){var t=En(r,e,19),i=En(e,r,29),s=av(r,e,6),a=t^i^s;return a<0&&(a+=4294967296),a}function s_(r,e){var t=In(r,e,19),i=In(e,r,29),s=ov(r,e,6),a=t^i^s;return a<0&&(a+=4294967296),a}var Hu=Pt,hv=fv;function Hn(){if(!(this instanceof Hn))return new Hn;hv.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Hu.inherits(Hn,hv);var a_=Hn;Hn.blockSize=1024,Hn.outSize=384,Hn.hmacStrength=192,Hn.padLength=128,Hn.prototype._digest=function(r){return r==="hex"?Hu.toHex32(this.h.slice(0,12),"big"):Hu.split32(this.h.slice(0,12),"big")},ga.sha1=P7,ga.sha224=$7,ga.sha256=nv,ga.sha384=a_,ga.sha512=fv;var uv={},$s=Pt,o_=Ta,Gc=$s.rotl32,Bp=$s.sum32,ao=$s.sum32_3,Lp=$s.sum32_4,dv=o_.BlockHash;function bn(){if(!(this instanceof bn))return new bn;dv.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}$s.inherits(bn,dv),uv.ripemd160=bn,bn.blockSize=512,bn.outSize=160,bn.hmacStrength=192,bn.padLength=64,bn.prototype._update=function(r,e){for(var t=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],f=this.h[4],p=t,w=i,b=s,A=a,M=f,C=0;C<80;C++){var O=Bp(Gc(Lp(t,kp(C,i,s,a),r[h_[C]+e],c_(C)),d_[C]),f);t=f,f=a,a=Gc(s,10),s=i,i=O,O=Bp(Gc(Lp(p,kp(79-C,w,b,A),r[u_[C]+e],f_(C)),l_[C]),M),p=M,M=A,A=Gc(b,10),b=w,w=O}O=ao(this.h[1],s,A),this.h[1]=ao(this.h[2],a,M),this.h[2]=ao(this.h[3],f,p),this.h[3]=ao(this.h[4],t,w),this.h[4]=ao(this.h[0],i,b),this.h[0]=O},bn.prototype._digest=function(r){return r==="hex"?$s.toHex32(this.h,"little"):$s.split32(this.h,"little")};function kp(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function c_(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function f_(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var h_=[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],u_=[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],d_=[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],l_=[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],p_=Pt,g_=Bo;function _a(r,e,t){if(!(this instanceof _a))return new _a(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(p_.toArray(e,t))}var v_=_a;_a.prototype._init=function(r){r.length>this.blockSize&&(r=new this.Hash().update(r).digest()),g_(r.length<=this.blockSize);for(var e=r.length;e<this.blockSize;e++)r.push(0);for(e=0;e<r.length;e++)r[e]^=54;for(this.inner=new this.Hash().update(r),e=0;e<r.length;e++)r[e]^=106;this.outer=new this.Hash().update(r)},_a.prototype.update=function(r,e){return this.inner.update(r,e),this},_a.prototype.digest=function(r){return this.outer.update(this.inner.digest()),this.outer.digest(r)},function(r){var e=r;e.utils=Pt,e.common=Ta,e.sha=ga,e.ripemd=uv,e.hmac=v_,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}(vn);function Fa(r,e,t){return t={path:e,exports:{},require:function(i,s){return b_(i,s??t.path)}},r(t,t.exports),t.exports}function b_(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var _d=lv;function lv(r,e){if(!r)throw new Error(e||"Assertion failed")}lv.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var nn=Fa(function(r,e){var t=e;function i(f,p){if(Array.isArray(f))return f.slice();if(!f)return[];var w=[];if(typeof f!="string"){for(var b=0;b<f.length;b++)w[b]=f[b]|0;return w}if(p==="hex"){f=f.replace(/[^a-z0-9]+/ig,""),f.length%2!==0&&(f="0"+f);for(var b=0;b<f.length;b+=2)w.push(parseInt(f[b]+f[b+1],16))}else for(var b=0;b<f.length;b++){var A=f.charCodeAt(b),M=A>>8,C=A&255;M?w.push(M,C):w.push(C)}return w}t.toArray=i;function s(f){return f.length===1?"0"+f:f}t.zero2=s;function a(f){for(var p="",w=0;w<f.length;w++)p+=s(f[w].toString(16));return p}t.toHex=a,t.encode=function(f,p){return p==="hex"?a(f):f}}),vi=Fa(function(r,e){var t=e;t.assert=_d,t.toArray=nn.toArray,t.zero2=nn.zero2,t.toHex=nn.toHex,t.encode=nn.encode;function i(w,b,A){var M=new Array(Math.max(w.bitLength(),A)+1);M.fill(0);for(var C=1<<b+1,O=w.clone(),D=0;D<M.length;D++){var j,G=O.andln(C-1);O.isOdd()?(G>(C>>1)-1?j=(C>>1)-G:j=G,O.isubn(j)):j=0,M[D]=j,O.iushrn(1)}return M}t.getNAF=i;function s(w,b){var A=[[],[]];w=w.clone(),b=b.clone();for(var M=0,C=0,O;w.cmpn(-M)>0||b.cmpn(-C)>0;){var D=w.andln(3)+M&3,j=b.andln(3)+C&3;D===3&&(D=-1),j===3&&(j=-1);var G;D&1?(O=w.andln(7)+M&7,(O===3||O===5)&&j===2?G=-D:G=D):G=0,A[0].push(G);var X;j&1?(O=b.andln(7)+C&7,(O===3||O===5)&&D===2?X=-j:X=j):X=0,A[1].push(X),2*M===G+1&&(M=1-M),2*C===X+1&&(C=1-C),w.iushrn(1),b.iushrn(1)}return A}t.getJSF=s;function a(w,b,A){var M="_"+b;w.prototype[b]=function(){return this[M]!==void 0?this[M]:this[M]=A.call(this)}}t.cachedProperty=a;function f(w){return typeof w=="string"?t.toArray(w,"hex"):w}t.parseBytes=f;function p(w){return new vt(w,"hex","le")}t.intFromLE=p}),Jc=vi.getNAF,m_=vi.getJSF,Ef=vi.assert;function hs(r,e){this.type=r,this.p=new vt(e.p,16),this.red=e.prime?vt.red(e.prime):vt.mont(this.p),this.zero=new vt(0).toRed(this.red),this.one=new vt(1).toRed(this.red),this.two=new vt(2).toRed(this.red),this.n=e.n&&new vt(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Gs=hs;hs.prototype.point=function(){throw new Error("Not implemented")},hs.prototype.validate=function(){throw new Error("Not implemented")},hs.prototype._fixedNafMul=function(r,e){Ef(r.precomputed);var t=r._getDoubles(),i=Jc(e,1,this._bitLength),s=(1<<t.step+1)-(t.step%2===0?2:1);s/=3;var a=[],f,p;for(f=0;f<i.length;f+=t.step){p=0;for(var w=f+t.step-1;w>=f;w--)p=(p<<1)+i[w];a.push(p)}for(var b=this.jpoint(null,null,null),A=this.jpoint(null,null,null),M=s;M>0;M--){for(f=0;f<a.length;f++)p=a[f],p===M?A=A.mixedAdd(t.points[f]):p===-M&&(A=A.mixedAdd(t.points[f].neg()));b=b.add(A)}return b.toP()},hs.prototype._wnafMul=function(r,e){var t=4,i=r._getNAFPoints(t);t=i.wnd;for(var s=i.points,a=Jc(e,t,this._bitLength),f=this.jpoint(null,null,null),p=a.length-1;p>=0;p--){for(var w=0;p>=0&&a[p]===0;p--)w++;if(p>=0&&w++,f=f.dblp(w),p<0)break;var b=a[p];Ef(b!==0),r.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return r.type==="affine"?f.toP():f},hs.prototype._wnafMulAdd=function(r,e,t,i,s){var a=this._wnafT1,f=this._wnafT2,p=this._wnafT3,w=0,b,A,M;for(b=0;b<i;b++){M=e[b];var C=M._getNAFPoints(r);a[b]=C.wnd,f[b]=C.points}for(b=i-1;b>=1;b-=2){var O=b-1,D=b;if(a[O]!==1||a[D]!==1){p[O]=Jc(t[O],a[O],this._bitLength),p[D]=Jc(t[D],a[D],this._bitLength),w=Math.max(p[O].length,w),w=Math.max(p[D].length,w);continue}var j=[e[O],null,null,e[D]];e[O].y.cmp(e[D].y)===0?(j[1]=e[O].add(e[D]),j[2]=e[O].toJ().mixedAdd(e[D].neg())):e[O].y.cmp(e[D].y.redNeg())===0?(j[1]=e[O].toJ().mixedAdd(e[D]),j[2]=e[O].add(e[D].neg())):(j[1]=e[O].toJ().mixedAdd(e[D]),j[2]=e[O].toJ().mixedAdd(e[D].neg()));var G=[-3,-1,-5,-7,0,7,5,1,3],X=m_(t[O],t[D]);for(w=Math.max(X[0].length,w),p[O]=new Array(w),p[D]=new Array(w),A=0;A<w;A++){var z=X[0][A]|0,Q=X[1][A]|0;p[O][A]=G[(z+1)*3+(Q+1)],p[D][A]=0,f[O]=j}}var V=this.jpoint(null,null,null),H=this._wnafT4;for(b=w;b>=0;b--){for(var ee=0;b>=0;){var oe=!0;for(A=0;A<i;A++)H[A]=p[A][b]|0,H[A]!==0&&(oe=!1);if(!oe)break;ee++,b--}if(b>=0&&ee++,V=V.dblp(ee),b<0)break;for(A=0;A<i;A++){var ne=H[A];ne!==0&&(ne>0?M=f[A][ne-1>>1]:ne<0&&(M=f[A][-ne-1>>1].neg()),M.type==="affine"?V=V.mixedAdd(M):V=V.add(M))}}for(b=0;b<i;b++)f[b]=null;return s?V:V.toP()};function Ri(r,e){this.curve=r,this.type=e,this.precomputed=null}hs.BasePoint=Ri,Ri.prototype.eq=function(){throw new Error("Not implemented")},Ri.prototype.validate=function(){return this.curve.validate(this)},hs.prototype.decodePoint=function(r,e){r=vi.toArray(r,e);var t=this.p.byteLength();if((r[0]===4||r[0]===6||r[0]===7)&&r.length-1===2*t){r[0]===6?Ef(r[r.length-1]%2===0):r[0]===7&&Ef(r[r.length-1]%2===1);var i=this.point(r.slice(1,1+t),r.slice(1+t,1+2*t));return i}else if((r[0]===2||r[0]===3)&&r.length-1===t)return this.pointFromX(r.slice(1,1+t),r[0]===3);throw new Error("Unknown point format")},Ri.prototype.encodeCompressed=function(r){return this.encode(r,!0)},Ri.prototype._encode=function(r){var e=this.curve.p.byteLength(),t=this.getX().toArray("be",e);return r?[this.getY().isEven()?2:3].concat(t):[4].concat(t,this.getY().toArray("be",e))},Ri.prototype.encode=function(r,e){return vi.encode(this._encode(e),r)},Ri.prototype.precompute=function(r){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,r),e.beta=this._getBeta(),this.precomputed=e,this},Ri.prototype._hasDoubles=function(r){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((r.bitLength()+1)/e.step):!1},Ri.prototype._getDoubles=function(r,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],i=this,s=0;s<e;s+=r){for(var a=0;a<r;a++)i=i.dbl();t.push(i)}return{step:r,points:t}},Ri.prototype._getNAFPoints=function(r){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],t=(1<<r)-1,i=t===1?null:this.dbl(),s=1;s<t;s++)e[s]=e[s-1].add(i);return{wnd:r,points:e}},Ri.prototype._getBeta=function(){return null},Ri.prototype.dblp=function(r){for(var e=this,t=0;t<r;t++)e=e.dbl();return e};var Ad=Fa(function(r){typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}}),y_=vi.assert;function Di(r){Gs.call(this,"short",r),this.a=new vt(r.a,16).toRed(this.red),this.b=new vt(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Ad(Di,Gs);var w_=Di;Di.prototype._getEndomorphism=function(r){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,t;if(r.beta)e=new vt(r.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(r.lambda)t=new vt(r.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))===0?t=s[0]:(t=s[1],y_(this.g.mul(t).x.cmp(this.g.x.redMul(e))===0))}var a;return r.basis?a=r.basis.map(function(f){return{a:new vt(f.a,16),b:new vt(f.b,16)}}):a=this._getEndoBasis(t),{beta:e,lambda:t,basis:a}}},Di.prototype._getEndoRoots=function(r){var e=r===this.p?this.red:vt.mont(r),t=new vt(2).toRed(e).redInvm(),i=t.redNeg(),s=new vt(3).toRed(e).redNeg().redSqrt().redMul(t),a=i.redAdd(s).fromRed(),f=i.redSub(s).fromRed();return[a,f]},Di.prototype._getEndoBasis=function(r){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),t=r,i=this.n.clone(),s=new vt(1),a=new vt(0),f=new vt(0),p=new vt(1),w,b,A,M,C,O,D,j=0,G,X;t.cmpn(0)!==0;){var z=i.div(t);G=i.sub(z.mul(t)),X=f.sub(z.mul(s));var Q=p.sub(z.mul(a));if(!A&&G.cmp(e)<0)w=D.neg(),b=s,A=G.neg(),M=X;else if(A&&++j===2)break;D=G,i=t,t=G,f=s,s=X,p=a,a=Q}C=G.neg(),O=X;var V=A.sqr().add(M.sqr()),H=C.sqr().add(O.sqr());return H.cmp(V)>=0&&(C=w,O=b),A.negative&&(A=A.neg(),M=M.neg()),C.negative&&(C=C.neg(),O=O.neg()),[{a:A,b:M},{a:C,b:O}]},Di.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],i=e[1],s=i.b.mul(r).divRound(this.n),a=t.b.neg().mul(r).divRound(this.n),f=s.mul(t.a),p=a.mul(i.a),w=s.mul(t.b),b=a.mul(i.b),A=r.sub(f).sub(p),M=w.add(b).neg();return{k1:A,k2:M}},Di.prototype.pointFromX=function(r,e){r=new vt(r,16),r.red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=t.redSqrt();if(i.redSqr().redSub(t).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(e&&!s||!e&&s)&&(i=i.redNeg()),this.point(r,i)},Di.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,i=this.a.redMul(e),s=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return t.redSqr().redISub(s).cmpn(0)===0},Di.prototype._endoWnafMulAdd=function(r,e,t){for(var i=this._endoWnafT1,s=this._endoWnafT2,a=0;a<r.length;a++){var f=this._endoSplit(e[a]),p=r[a],w=p._getBeta();f.k1.negative&&(f.k1.ineg(),p=p.neg(!0)),f.k2.negative&&(f.k2.ineg(),w=w.neg(!0)),i[a*2]=p,i[a*2+1]=w,s[a*2]=f.k1,s[a*2+1]=f.k2}for(var b=this._wnafMulAdd(1,i,s,a*2,t),A=0;A<a*2;A++)i[A]=null,s[A]=null;return b};function vr(r,e,t,i){Gs.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new vt(e,16),this.y=new vt(t,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)}Ad(vr,Gs.BasePoint),Di.prototype.point=function(r,e,t){return new vr(this,r,e,t)},Di.prototype.pointFromJSON=function(r,e){return vr.fromJSON(this,r,e)},vr.prototype._getBeta=function(){if(this.curve.endo){var r=this.precomputed;if(r&&r.beta)return r.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(r){var t=this.curve,i=function(s){return t.point(s.x.redMul(t.endo.beta),s.y)};r.beta=e,e.precomputed={beta:null,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}},vr.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]},vr.fromJSON=function(r,e,t){typeof e=="string"&&(e=JSON.parse(e));var i=r.point(e[0],e[1],t);if(!e[2])return i;function s(f){return r.point(f[0],f[1],t)}var a=e[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(s))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(s))}},i},vr.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)+">"},vr.prototype.isInfinity=function(){return this.inf},vr.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(this.x.cmp(r.x)===0)return this.curve.point(null,null);var e=this.y.redSub(r.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),i=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,i)},vr.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(r.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),i=r.redInvm(),s=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(i),a=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,f)},vr.prototype.getX=function(){return this.x.fromRed()},vr.prototype.getY=function(){return this.y.fromRed()},vr.prototype.mul=function(r){return r=new vt(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},vr.prototype.mulAdd=function(r,e,t){var i=[this,e],s=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},vr.prototype.jmulAdd=function(r,e,t){var i=[this,e],s=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},vr.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||this.x.cmp(r.x)===0&&this.y.cmp(r.y)===0)},vr.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,i=function(s){return s.neg()};e.precomputed={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},vr.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var r=this.curve.jpoint(this.x,this.y,this.curve.one);return r};function Er(r,e,t,i){Gs.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new vt(0)):(this.x=new vt(e,16),this.y=new vt(t,16),this.z=new vt(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}Ad(Er,Gs.BasePoint),Di.prototype.jpoint=function(r,e,t){return new Er(this,r,e,t)},Er.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),i=this.y.redMul(e).redMul(r);return this.curve.point(t,i)},Er.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Er.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),i=this.x.redMul(e),s=r.x.redMul(t),a=this.y.redMul(e.redMul(r.z)),f=r.y.redMul(t.redMul(this.z)),p=i.redSub(s),w=a.redSub(f);if(p.cmpn(0)===0)return w.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=p.redSqr(),A=b.redMul(p),M=i.redMul(b),C=w.redSqr().redIAdd(A).redISub(M).redISub(M),O=w.redMul(M.redISub(C)).redISub(a.redMul(A)),D=this.z.redMul(r.z).redMul(p);return this.curve.jpoint(C,O,D)},Er.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,i=r.x.redMul(e),s=this.y,a=r.y.redMul(e).redMul(this.z),f=t.redSub(i),p=s.redSub(a);if(f.cmpn(0)===0)return p.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var w=f.redSqr(),b=w.redMul(f),A=t.redMul(w),M=p.redSqr().redIAdd(b).redISub(A).redISub(A),C=p.redMul(A.redISub(M)).redISub(s.redMul(b)),O=this.z.redMul(f);return this.curve.jpoint(M,C,O)},Er.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var t=this;for(e=0;e<r;e++)t=t.dbl();return t}var i=this.curve.a,s=this.curve.tinv,a=this.x,f=this.y,p=this.z,w=p.redSqr().redSqr(),b=f.redAdd(f);for(e=0;e<r;e++){var A=a.redSqr(),M=b.redSqr(),C=M.redSqr(),O=A.redAdd(A).redIAdd(A).redIAdd(i.redMul(w)),D=a.redMul(M),j=O.redSqr().redISub(D.redAdd(D)),G=D.redISub(j),X=O.redMul(G);X=X.redIAdd(X).redISub(C);var z=b.redMul(p);e+1<r&&(w=w.redMul(C)),a=j,p=z,b=X}return this.curve.jpoint(a,b.redMul(s),p)},Er.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Er.prototype._zeroDbl=function(){var r,e,t;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var p=i.redAdd(i).redIAdd(i),w=p.redSqr().redISub(f).redISub(f),b=a.redIAdd(a);b=b.redIAdd(b),b=b.redIAdd(b),r=w,e=p.redMul(f.redISub(w)).redISub(b),t=this.y.redAdd(this.y)}else{var A=this.x.redSqr(),M=this.y.redSqr(),C=M.redSqr(),O=this.x.redAdd(M).redSqr().redISub(A).redISub(C);O=O.redIAdd(O);var D=A.redAdd(A).redIAdd(A),j=D.redSqr(),G=C.redIAdd(C);G=G.redIAdd(G),G=G.redIAdd(G),r=j.redISub(O).redISub(O),e=D.redMul(O.redISub(r)).redISub(G),t=this.y.redMul(this.z),t=t.redIAdd(t)}return this.curve.jpoint(r,e,t)},Er.prototype._threeDbl=function(){var r,e,t;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var p=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),w=p.redSqr().redISub(f).redISub(f);r=w;var b=a.redIAdd(a);b=b.redIAdd(b),b=b.redIAdd(b),e=p.redMul(f.redISub(w)).redISub(b),t=this.y.redAdd(this.y)}else{var A=this.z.redSqr(),M=this.y.redSqr(),C=this.x.redMul(M),O=this.x.redSub(A).redMul(this.x.redAdd(A));O=O.redAdd(O).redIAdd(O);var D=C.redIAdd(C);D=D.redIAdd(D);var j=D.redAdd(D);r=O.redSqr().redISub(j),t=this.y.redAdd(this.z).redSqr().redISub(M).redISub(A);var G=M.redSqr();G=G.redIAdd(G),G=G.redIAdd(G),G=G.redIAdd(G),e=O.redMul(D.redISub(r)).redISub(G)}return this.curve.jpoint(r,e,t)},Er.prototype._dbl=function(){var r=this.curve.a,e=this.x,t=this.y,i=this.z,s=i.redSqr().redSqr(),a=e.redSqr(),f=t.redSqr(),p=a.redAdd(a).redIAdd(a).redIAdd(r.redMul(s)),w=e.redAdd(e);w=w.redIAdd(w);var b=w.redMul(f),A=p.redSqr().redISub(b.redAdd(b)),M=b.redISub(A),C=f.redSqr();C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var O=p.redMul(M).redISub(C),D=t.redAdd(t).redMul(i);return this.curve.jpoint(A,O,D)},Er.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var r=this.x.redSqr(),e=this.y.redSqr(),t=this.z.redSqr(),i=e.redSqr(),s=r.redAdd(r).redIAdd(r),a=s.redSqr(),f=this.x.redAdd(e).redSqr().redISub(r).redISub(i);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(a);var p=f.redSqr(),w=i.redIAdd(i);w=w.redIAdd(w),w=w.redIAdd(w),w=w.redIAdd(w);var b=s.redIAdd(f).redSqr().redISub(a).redISub(p).redISub(w),A=e.redMul(b);A=A.redIAdd(A),A=A.redIAdd(A);var M=this.x.redMul(p).redISub(A);M=M.redIAdd(M),M=M.redIAdd(M);var C=this.y.redMul(b.redMul(w.redISub(b)).redISub(f.redMul(p)));C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var O=this.z.redAdd(f).redSqr().redISub(t).redISub(p);return this.curve.jpoint(M,C,O)},Er.prototype.mul=function(r,e){return r=new vt(r,e),this.curve._wnafMul(this,r)},Er.prototype.eq=function(r){if(r.type==="affine")return this.eq(r.toJ());if(this===r)return!0;var e=this.z.redSqr(),t=r.z.redSqr();if(this.x.redMul(t).redISub(r.x.redMul(e)).cmpn(0)!==0)return!1;var i=e.redMul(this.z),s=t.redMul(r.z);return this.y.redMul(s).redISub(r.y.redMul(i)).cmpn(0)===0},Er.prototype.eqXToP=function(r){var e=this.z.redSqr(),t=r.toRed(this.curve.red).redMul(e);if(this.x.cmp(t)===0)return!0;for(var i=r.clone(),s=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(s),this.x.cmp(t)===0)return!0}},Er.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)+">"},Er.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var sf=Fa(function(r,e){var t=e;t.base=Gs,t.short=w_,t.mont=null,t.edwards=null}),af=Fa(function(r,e){var t=e,i=vi.assert;function s(p){p.type==="short"?this.curve=new sf.short(p):p.type==="edwards"?this.curve=new sf.edwards(p):this.curve=new sf.mont(p),this.g=this.curve.g,this.n=this.curve.n,this.hash=p.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=s;function a(p,w){Object.defineProperty(t,p,{configurable:!0,enumerable:!0,get:function(){var b=new s(w);return Object.defineProperty(t,p,{configurable:!0,enumerable:!0,value:b}),b}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:vn.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=null.crash()}catch{f=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})});function us(r){if(!(this instanceof us))return new us(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=nn.toArray(r.entropy,r.entropyEnc||"hex"),t=nn.toArray(r.nonce,r.nonceEnc||"hex"),i=nn.toArray(r.pers,r.persEnc||"hex");_d(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var $p=us;us.prototype._init=function(r,e,t){var i=r.concat(e).concat(t);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},us.prototype._hmac=function(){return new vn.hmac(this.hash,this.K)},us.prototype._update=function(r){var e=this._hmac().update(this.V).update([0]);r&&(e=e.update(r)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),r&&(this.K=this._hmac().update(this.V).update([1]).update(r).digest(),this.V=this._hmac().update(this.V).digest())},us.prototype.reseed=function(r,e,t,i){typeof e!="string"&&(i=t,t=e,e=null),r=nn.toArray(r,e),t=nn.toArray(t,i),_d(r.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(t||[])),this._reseed=1},us.prototype.generate=function(r,e,t,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=t,t=e,e=null),t&&(t=nn.toArray(t,i||"hex"),this._update(t));for(var s=[];s.length<r;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var a=s.slice(0,r);return this._update(t),this._reseed++,nn.encode(a,e)};var _u=vi.assert;function Dr(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Au=Dr;Dr.fromPublic=function(r,e,t){return e instanceof Dr?e:new Dr(r,{pub:e,pubEnc:t})},Dr.fromPrivate=function(r,e,t){return e instanceof Dr?e:new Dr(r,{priv:e,privEnc:t})},Dr.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.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"}},Dr.prototype.getPublic=function(r,e){return typeof r=="string"&&(e=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,r):this.pub},Dr.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},Dr.prototype._importPrivate=function(r,e){this.priv=new vt(r,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Dr.prototype._importPublic=function(r,e){if(r.x||r.y){this.ec.curve.type==="mont"?_u(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&_u(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,e)},Dr.prototype.derive=function(r){return r.validate()||_u(r.validate(),"public point not validated"),r.mul(this.priv).getX()},Dr.prototype.sign=function(r,e,t){return this.ec.sign(r,this,e,t)},Dr.prototype.verify=function(r,e){return this.ec.verify(r,e,this)},Dr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var __=vi.assert;function Uf(r,e){if(r instanceof Uf)return r;this._importDER(r,e)||(__(r.r&&r.s,"Signature without r or s"),this.r=new vt(r.r,16),this.s=new vt(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var Wc=Uf;function A_(){this.place=0}function Eu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var s=0,a=0,f=e.place;a<i;a++,f++)s<<=8,s|=r[f],s>>>=0;return s<=127?!1:(e.place=f,s)}function zp(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}Uf.prototype._importDER=function(r,e){r=vi.toArray(r,e);var t=new A_;if(r[t.place++]!==48)return!1;var i=Eu(r,t);if(i===!1||i+t.place!==r.length||r[t.place++]!==2)return!1;var s=Eu(r,t);if(s===!1)return!1;var a=r.slice(t.place,s+t.place);if(t.place+=s,r[t.place++]!==2)return!1;var f=Eu(r,t);if(f===!1||r.length!==f+t.place)return!1;var p=r.slice(t.place,f+t.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(p[0]===0)if(p[1]&128)p=p.slice(1);else return!1;return this.r=new vt(a),this.s=new vt(p),this.recoveryParam=null,!0};function Iu(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Uf.prototype.toDER=function(r){var e=this.r.toArray(),t=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),t[0]&128&&(t=[0].concat(t)),e=zp(e),t=zp(t);!t[0]&&!(t[1]&128);)t=t.slice(1);var i=[2];Iu(i,e.length),i=i.concat(e),i.push(2),Iu(i,t.length);var s=i.concat(t),a=[48];return Iu(a,s.length),a=a.concat(s),vi.encode(a,r)};var E_=function(){throw new Error("unsupported")},pv=vi.assert;function Oi(r){if(!(this instanceof Oi))return new Oi(r);typeof r=="string"&&(pv(Object.prototype.hasOwnProperty.call(af,r),"Unknown curve "+r),r=af[r]),r instanceof af.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var I_=Oi;Oi.prototype.keyPair=function(r){return new Au(this,r)},Oi.prototype.keyFromPrivate=function(r,e){return Au.fromPrivate(this,r,e)},Oi.prototype.keyFromPublic=function(r,e){return Au.fromPublic(this,r,e)},Oi.prototype.genKeyPair=function(r){r||(r={});for(var e=new $p({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||E_(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),i=this.n.sub(new vt(2));;){var s=new vt(e.generate(t));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Oi.prototype._truncateToN=function(r,e){var t=r.byteLength()*8-this.n.bitLength();return t>0&&(r=r.ushrn(t)),!e&&r.cmp(this.n)>=0?r.sub(this.n):r},Oi.prototype.sign=function(r,e,t,i){typeof t=="object"&&(i=t,t=null),i||(i={}),e=this.keyFromPrivate(e,t),r=this._truncateToN(new vt(r,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),f=r.toArray("be",s),p=new $p({hash:this.hash,entropy:a,nonce:f,pers:i.pers,persEnc:i.persEnc||"utf8"}),w=this.n.sub(new vt(1)),b=0;;b++){var A=i.k?i.k(b):new vt(p.generate(this.n.byteLength()));if(A=this._truncateToN(A,!0),!(A.cmpn(1)<=0||A.cmp(w)>=0)){var M=this.g.mul(A);if(!M.isInfinity()){var C=M.getX(),O=C.umod(this.n);if(O.cmpn(0)!==0){var D=A.invm(this.n).mul(O.mul(e.getPrivate()).iadd(r));if(D=D.umod(this.n),D.cmpn(0)!==0){var j=(M.getY().isOdd()?1:0)|(C.cmp(O)!==0?2:0);return i.canonical&&D.cmp(this.nh)>0&&(D=this.n.sub(D),j^=1),new Wc({r:O,s:D,recoveryParam:j})}}}}}},Oi.prototype.verify=function(r,e,t,i){r=this._truncateToN(new vt(r,16)),t=this.keyFromPublic(t,i),e=new Wc(e,"hex");var s=e.r,a=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f=a.invm(this.n),p=f.mul(r).umod(this.n),w=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(p,t.getPublic(),w),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(p,t.getPublic(),w),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)},Oi.prototype.recoverPubKey=function(r,e,t,i){pv((3&t)===t,"The recovery param is more than two bits"),e=new Wc(e,i);var s=this.n,a=new vt(r),f=e.r,p=e.s,w=t&1,b=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&b)throw new Error("Unable to find sencond key candinate");b?f=this.curve.pointFromX(f.add(this.curve.n),w):f=this.curve.pointFromX(f,w);var A=e.r.invm(s),M=s.sub(a).mul(A).umod(s),C=p.mul(A).umod(s);return this.g.mulAdd(M,f,C)},Oi.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Wc(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var s=0;s<4;s++){var a;try{a=this.recoverPubKey(r,e,s)}catch{continue}if(a.eq(t))return s}throw new Error("Unable to find valid recovery factor")};var M_=Fa(function(r,e){var t=e;t.version="6.5.4",t.utils=vi,t.rand=function(){throw new Error("unsupported")},t.curve=sf,t.curves=af,t.ec=I_,t.eddsa=null}),S_=M_.ec;const x_="signing-key/5.7.0",Vu=new Ir(x_);let Mu=null;function fs(){return Mu||(Mu=new S_("secp256k1")),Mu}class P_{constructor(e){no(this,"curve","secp256k1"),no(this,"privateKey",ri(e)),u9(this.privateKey)!==32&&Vu.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=fs().keyFromPrivate(er(this.privateKey));no(this,"publicKey","0x"+t.getPublic(!1,"hex")),no(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),no(this,"_isSigningKey",!0)}_addPoint(e){const t=fs().keyFromPublic(er(this.publicKey)),i=fs().keyFromPublic(er(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=fs().keyFromPrivate(er(this.privateKey)),i=er(e);i.length!==32&&Vu.throwArgumentError("bad digest length","digest",e);const s=t.sign(i,{canonical:!0});return kg({recoveryParam:s.recoveryParam,r:_n("0x"+s.r.toString(16),32),s:_n("0x"+s.s.toString(16),32)})}computeSharedSecret(e){const t=fs().keyFromPrivate(er(this.privateKey)),i=fs().keyFromPublic(er(gv(e)));return _n("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function R_(r,e){const t=kg(e),i={r:er(t.r),s:er(t.s)};return"0x"+fs().recoverPubKey(er(r),i,t.recoveryParam).encode("hex",!1)}function gv(r,e){const t=er(r);return t.length===32?new P_(t).publicKey:t.length===33?"0x"+fs().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?ri(t):Vu.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Up;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(Up||(Up={}));function N_(r){const e=gv(r);return z9(xp(md(xp(e,1)),12))}function C_(r,e){return N_(R_(er(r),e))}const O_="https://rpc.walletconnect.org/v1";async function T_(r,e,t,i,s,a){switch(t.t){case"eip191":return D_(r,e,t.s);case"eip1271":return await F_(r,e,t.s,i,s,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function D_(r,e,t){return C_(Jg(e),t).toLowerCase()===r.toLowerCase()}async function F_(r,e,t,i,s,a){try{const f="0x1626ba7e",p="0000000000000000000000000000000000000000000000000000000000000040",w="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),A=Jg(e).substring(2),M=f+A+p+w+b,C=await fetch(`${a||O_}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:q_(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:M},"latest"]})}),{result:O}=await C.json();return O?O.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function q_(){return Date.now()+Math.floor(Math.random()*1e3)}var B_=Object.defineProperty,L_=Object.defineProperties,k_=Object.getOwnPropertyDescriptors,jp=Object.getOwnPropertySymbols,$_=Object.prototype.hasOwnProperty,z_=Object.prototype.propertyIsEnumerable,Kp=(r,e,t)=>e in r?B_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,U_=(r,e)=>{for(var t in e||(e={}))$_.call(e,t)&&Kp(r,t,e[t]);if(jp)for(var t of jp(e))z_.call(e,t)&&Kp(r,t,e[t]);return r},j_=(r,e)=>L_(r,k_(e));const K_="did:pkh:",Ed=r=>r==null?void 0:r.split(":"),vv=r=>{const e=r&&Ed(r);if(e)return r.includes(K_)?e[3]:e[1]},Hp=r=>{const e=r&&Ed(r);if(e)return e[2]+":"+e[3]},If=r=>{const e=r&&Ed(r);if(e)return e.pop()};async function Vp(r){const{cacao:e,projectId:t}=r,{s:i,p:s}=e,a=bv(s,s.iss),f=If(s.iss);return await T_(f,a,i,vv(s.iss),t)}const bv=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=If(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,f=`Version: ${r.version}`,p=`Chain ID: ${vv(e)}`,w=`Nonce: ${r.nonce}`,b=`Issued At: ${r.iat}`,A=r.exp?`Expiration Time: ${r.exp}`:void 0,M=r.nbf?`Not Before: ${r.nbf}`:void 0,C=r.requestId?`Request ID: ${r.requestId}`:void 0,O=r.resources?`Resources:${r.resources.map(j=>`
- ${j}`).join("")}`:void 0,D=of(r.resources);if(D){const j=xo(D);s=Z_(s,j)}return[t,i,"",s,"",a,f,p,w,b,A,M,C,O].filter(j=>j!=null).join(`
`)};function H_(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function V_(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Us(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(s=>{const a=i[s];if(!Array.isArray(a))throw new Error(`Ability limits ${s} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);a.forEach(f=>{if(typeof f!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${f}`)})})})}function G_(r,e,t,i={}){return t==null||t.sort((s,a)=>s.localeCompare(a)),{att:{[r]:J_(e,t,i)}}}function J_(r,e,t={}){e=e==null?void 0:e.sort((s,a)=>s.localeCompare(a));const i=e.map(s=>({[`${r}/${s}`]:[t]}));return Object.assign({},...i)}function mv(r){return Us(r),`urn:recap:${H_(r).replace(/=/g,"")}`}function xo(r){const e=V_(r.replace("urn:recap:",""));return Us(e),e}function W_(r,e,t){const i=G_(r,e,t);return mv(i)}function Q_(r){return r&&r.includes("urn:recap:")}function Y_(r,e){const t=xo(r),i=xo(e),s=X_(t,i);return mv(s)}function X_(r,e){Us(r),Us(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((s,a)=>s.localeCompare(a)),i={att:{}};return t.forEach(s=>{var a,f;Object.keys(((a=r.att)==null?void 0:a[s])||{}).concat(Object.keys(((f=e.att)==null?void 0:f[s])||{})).sort((p,w)=>p.localeCompare(w)).forEach(p=>{var w,b;i.att[s]=j_(U_({},i.att[s]),{[p]:((w=r.att[s])==null?void 0:w[p])||((b=e.att[s])==null?void 0:b[p])})})}),i}function Z_(r="",e){Us(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let s=0;Object.keys(e.att).forEach(p=>{const w=Object.keys(e.att[p]).map(M=>({ability:M.split("/")[0],action:M.split("/")[1]}));w.sort((M,C)=>M.action.localeCompare(C.action));const b={};w.forEach(M=>{b[M.ability]||(b[M.ability]=[]),b[M.ability].push(M.action)});const A=Object.keys(b).map(M=>(s++,`(${s}) '${M}': '${b[M].join("', '")}' for '${p}'.`));i.push(A.join(", ").replace(".,","."))});const a=i.join(" "),f=`${t}${a}`;return`${r?r+" ":""}${f}`}function Gp(r){var e;const t=xo(r);Us(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function Jp(r){const e=xo(r);Us(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(s=>{var a;(a=s==null?void 0:s[0])!=null&&a.chains&&t.push(s[0].chains)})}),[...new Set(t.flat())]}function of(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return Q_(e)?e:void 0}const yv="base10",jr="base16",ps="base64pad",oo="base64url",Lo="utf8",wv=0,Gn=1,ko=2,eA=0,Wp=1,Eo=12,Id=32;function tA(){const r=Q1.generateKeyPair();return{privateKey:ni(r.secretKey,jr),publicKey:ni(r.publicKey,jr)}}function Gu(){const r=Ma.randomBytes(Id);return ni(r,jr)}function rA(r,e){const t=Q1.sharedKey(Fi(r,jr),Fi(e,jr),!0),i=new Uw(xf.SHA256,t).expand(Id);return ni(i,jr)}function cf(r){const e=xf.hash(Fi(r,jr));return ni(e,jr)}function jn(r){const e=xf.hash(Fi(r,Lo));return ni(e,jr)}function _v(r){return Fi(`${r}`,yv)}function js(r){return Number(ni(r,yv))}function iA(r){const e=_v(typeof r.type<"u"?r.type:wv);if(js(e)===Gn&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Fi(r.senderPublicKey,jr):void 0,i=typeof r.iv<"u"?Fi(r.iv,jr):Ma.randomBytes(Eo),s=new Y1.ChaCha20Poly1305(Fi(r.symKey,jr)).seal(i,Fi(r.message,Lo));return Av({type:e,sealed:s,iv:i,senderPublicKey:t,encoding:r.encoding})}function nA(r,e){const t=_v(ko),i=Ma.randomBytes(Eo),s=Fi(r,Lo);return Av({type:t,sealed:s,iv:i,encoding:e})}function sA(r){const e=new Y1.ChaCha20Poly1305(Fi(r.symKey,jr)),{sealed:t,iv:i}=Po({encoded:r.encoded,encoding:r==null?void 0:r.encoding}),s=e.open(i,t);if(s===null)throw new Error("Failed to decrypt");return ni(s,Lo)}function aA(r,e){const{sealed:t}=Po({encoded:r,encoding:e});return ni(t,Lo)}function Av(r){const{encoding:e=ps}=r;if(js(r.type)===ko)return ni(eu([r.type,r.sealed]),e);if(js(r.type)===Gn){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ni(eu([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return ni(eu([r.type,r.iv,r.sealed]),e)}function Po(r){const{encoded:e,encoding:t=ps}=r,i=Fi(e,t),s=i.slice(eA,Wp),a=Wp;if(js(s)===Gn){const b=a+Id,A=b+Eo,M=i.slice(a,b),C=i.slice(b,A),O=i.slice(A);return{type:s,sealed:O,iv:C,senderPublicKey:M}}if(js(s)===ko){const b=i.slice(a),A=Ma.randomBytes(Eo);return{type:s,sealed:b,iv:A}}const f=a+Eo,p=i.slice(a,f),w=i.slice(f);return{type:s,sealed:w,iv:p}}function oA(r,e){const t=Po({encoded:r,encoding:e==null?void 0:e.encoding});return Ev({type:js(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?ni(t.senderPublicKey,jr):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Ev(r){const e=(r==null?void 0:r.type)||wv;if(e===Gn){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function Qp(r){return r.type===Gn&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Yp(r){return r.type===ko}function cA(r){return new mg.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function fA(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function hA(r){return Buffer.from(fA(r),"base64")}function uA(r,e){const[t,i,s]=r.split("."),a=hA(s);if(a.length!==64)throw new Error("Invalid signature length");const f=a.slice(0,32).toString("hex"),p=a.slice(32,64).toString("hex"),w=`${t}.${i}`,b=new xf.SHA256().update(Buffer.from(w)).digest(),A=cA(e),M=Buffer.from(b).toString("hex");if(!A.verify(M,{r:f,s:p}))throw new Error("Invalid signature");return Lu(r).payload}const dA="irn";function Ju(r){return(r==null?void 0:r.relay)||{protocol:dA}}function bo(r){const e=U4[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var lA=Object.defineProperty,pA=Object.defineProperties,gA=Object.getOwnPropertyDescriptors,Xp=Object.getOwnPropertySymbols,vA=Object.prototype.hasOwnProperty,bA=Object.prototype.propertyIsEnumerable,Zp=(r,e,t)=>e in r?lA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e1=(r,e)=>{for(var t in e||(e={}))vA.call(e,t)&&Zp(r,t,e[t]);if(Xp)for(var t of Xp(e))bA.call(e,t)&&Zp(r,t,e[t]);return r},mA=(r,e)=>pA(r,gA(e));function yA(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(s=>{if(s.startsWith(i)){const a=s.replace(i,""),f=r[s];t[a]=f}}),t}function t1(r){if(!r.includes("wc:")){const w=Fg(r);w!=null&&w.includes("wc:")&&(r=w)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),s=r.substring(e+1,t).split("@"),a=typeof t<"u"?r.substring(t):"",f=Mo.parse(a),p=typeof f.methods=="string"?f.methods.split(","):void 0;return{protocol:i,topic:wA(s[0]),version:parseInt(s[1],10),symKey:f.symKey,relay:yA(f),methods:p,expiryTimestamp:f.expiryTimestamp?parseInt(f.expiryTimestamp,10):void 0}}function wA(r){return r.startsWith("//")?r.substring(2):r}function _A(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(s=>{const a=t+e+s;r[s]&&(i[a]=r[s])}),i}function r1(r){return`${r.protocol}:${r.topic}@${r.version}?`+Mo.stringify(e1(mA(e1({symKey:r.symKey},_A(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Qc(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function qa(r){const e=[];return r.forEach(t=>{const[i,s]=t.split(":");e.push(`${i}:${s}`)}),e}function AA(r){const e=[];return Object.values(r).forEach(t=>{e.push(...qa(t.accounts))}),e}function EA(r,e){const t=[];return Object.values(r).forEach(i=>{qa(i.accounts).includes(e)&&t.push(...i.methods)}),t}function IA(r,e){const t=[];return Object.values(r).forEach(i=>{qa(i.accounts).includes(e)&&t.push(...i.events)}),t}function Md(r){return r.includes(":")}function mo(r){return Md(r)?r.split(":")[0]:r}function MA(r){const e={};return r==null||r.forEach(t=>{const[i,s]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${s}`)}),e}function i1(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=MA(e);for(const[i,s]of Object.entries(t))s.methods?s.methods=rf(s.methods,r):s.methods=r,s.events=["chainChanged","accountsChanged"];return t}const SA={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}},xA={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 pe(r,e){const{message:t,code:i}=xA[r];return{message:e?`${t} ${e}`:t,code:i}}function Bt(r,e){const{message:t,code:i}=SA[r];return{message:e?`${t} ${e}`:t,code:i}}function Mn(r,e){return!!Array.isArray(r)}function Ro(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function ii(r){return typeof r>"u"}function ar(r,e){return e&&ii(r)?!0:typeof r=="string"&&!!r.trim().length}function Sd(r,e){return typeof r=="number"&&!isNaN(r)}function PA(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),s=Object.keys(t);let a=!0;return Bs(s,i)?(i.forEach(f=>{const{accounts:p,methods:w,events:b}=r.namespaces[f],A=qa(p),M=t[f];(!Bs(Pg(f,M),A)||!Bs(M.methods,w)||!Bs(M.events,b))&&(a=!1)}),a):!1}function Mf(r){return ar(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function RA(r){if(ar(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Mf(t)}}return!1}function NA(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(ar(r,!1)){if(e(r))return!0;const t=Fg(r);return e(t)}}catch{}return!1}function CA(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function OA(r){return r==null?void 0:r.topic}function TA(r,e){let t=null;return ar(r==null?void 0:r.publicKey,!1)||(t=pe("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function n1(r){let e=!0;return Mn(r)?r.length&&(e=r.every(t=>ar(t,!1))):e=!1,e}function DA(r,e,t){let i=null;return Mn(e)&&e.length?e.forEach(s=>{i||Mf(s)||(i=Bt("UNSUPPORTED_CHAINS",`${t}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):Mf(r)||(i=Bt("UNSUPPORTED_CHAINS",`${t}, 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 FA(r,e,t){let i=null;return Object.entries(r).forEach(([s,a])=>{if(i)return;const f=DA(s,Pg(s,a),`${e} ${t}`);f&&(i=f)}),i}function qA(r,e){let t=null;return Mn(r)?r.forEach(i=>{t||RA(i)||(t=Bt("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Bt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function BA(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const s=qA(i==null?void 0:i.accounts,`${e} namespace`);s&&(t=s)}),t}function LA(r,e){let t=null;return n1(r==null?void 0:r.methods)?n1(r==null?void 0:r.events)||(t=Bt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Bt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Iv(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const s=LA(i,`${e}, namespace`);s&&(t=s)}),t}function kA(r,e,t){let i=null;if(r&&Ro(r)){const s=Iv(r,e);s&&(i=s);const a=FA(r,e,t);a&&(i=a)}else i=pe("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Su(r,e){let t=null;if(r&&Ro(r)){const i=Iv(r,e);i&&(t=i);const s=BA(r,e);s&&(t=s)}else t=pe("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Mv(r){return ar(r.protocol,!0)}function $A(r,e){let t=!1;return r?r&&Mn(r)&&r.length&&r.forEach(i=>{t=Mv(i)}):t=!0,t}function zA(r){return typeof r=="number"}function ti(r){return typeof r<"u"&&typeof r!==null}function UA(r){return!(!r||typeof r!="object"||!r.code||!Sd(r.code)||!r.message||!ar(r.message,!1))}function jA(r){return!(ii(r)||!ar(r.method,!1))}function KA(r){return!(ii(r)||ii(r.result)&&ii(r.error)||!Sd(r.id)||!ar(r.jsonrpc,!1))}function HA(r){return!(ii(r)||!ar(r.name,!1))}function s1(r,e){return!(!Mf(e)||!AA(r).includes(e))}function VA(r,e,t){return ar(t,!1)?EA(r,e).includes(t):!1}function GA(r,e,t){return ar(t,!1)?IA(r,e).includes(t):!1}function a1(r,e,t){let i=null;const s=JA(r),a=WA(e),f=Object.keys(s),p=Object.keys(a),w=o1(Object.keys(r)),b=o1(Object.keys(e)),A=w.filter(M=>!b.includes(M));return A.length&&(i=pe("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
      Required: ${A.toString()}
      Received: ${Object.keys(e).toString()}`)),Bs(f,p)||(i=pe("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
      Required: ${f.toString()}
      Approved: ${p.toString()}`)),Object.keys(e).forEach(M=>{if(!M.includes(":")||i)return;const C=qa(e[M].accounts);C.includes(M)||(i=pe("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${M}
        Required: ${M}
        Approved: ${C.toString()}`))}),f.forEach(M=>{i||(Bs(s[M].methods,a[M].methods)?Bs(s[M].events,a[M].events)||(i=pe("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${M}`)):i=pe("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${M}`))}),i}function JA(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(s=>{e[s]={methods:r[t].methods,events:r[t].events}})}),e}function o1(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function WA(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=qa(r[t].accounts);i==null||i.forEach(s=>{e[s]={accounts:r[t].accounts.filter(a=>a.includes(`${s}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function QA(r,e){return Sd(r)&&r<=e.max&&r>=e.min}function c1(){const r=qo();return new Promise(e=>{switch(r){case pi.browser:e(YA());break;case pi.reactNative:e(XA());break;case pi.node:e(ZA());break;default:e(!0)}})}function YA(){return Fo()&&(navigator==null?void 0:navigator.onLine)}async function XA(){if(Ca()&&typeof global<"u"&&global!=null&&global.NetInfo){const r=await(global==null?void 0:global.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function ZA(){return!0}function eE(r){switch(qo()){case pi.browser:tE(r);break;case pi.reactNative:rE(r);break}}function tE(r){!Ca()&&Fo()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function rE(r){Ca()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const xu={};class co{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}}class iE extends Hs{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class nE extends Hs{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class sE{constructor(e,t){this.logger=e,this.core=t}}let aE=class extends Hs{constructor(e,t){super(),this.relayer=e,this.logger=t}},oE=class extends Hs{constructor(e){super()}},cE=class{constructor(e,t,i,s){this.core=e,this.logger=t,this.name=i}};class fE extends Hs{constructor(e,t){super(),this.relayer=e,this.logger=t}}let hE=class extends Hs{constructor(e,t){super(),this.core=e,this.logger=t}},uE=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},dE=class{constructor(e,t){this.projectId=e,this.logger=t}},lE=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};class pE{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}let gE=class{constructor(e){this.client=e}};const Sv="wc",xv=2,xd="core",Sn=`${Sv}@2:${xd}:`,vE={name:xd,logger:"error"},bE={database:":memory:"},mE="crypto",f1="client_ed25519_seed",yE=me.ONE_DAY,wE="keychain",_E="0.3",AE="messages",EE="0.3",IE=me.SIX_HOURS,ME="publisher",Pv="irn",SE="error",Rv="wss://relay.walletconnect.org",xE="relayer",zr={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"},PE="_subscription",Ni={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},RE=.1,Wu="2.17.0",jt={link_mode:"link_mode",relay:"relay"},NE="0.3",CE="WALLETCONNECT_CLIENT_ID",h1="WALLETCONNECT_LINK_MODE_APPS",mn={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},OE="subscription",TE="0.3",DE=me.FIVE_SECONDS*1e3,FE="pairing",qE="0.3",fo={wc_pairingDelete:{req:{ttl:me.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:me.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:me.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:me.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:me.ONE_DAY,prompt:!1,tag:0},res:{ttl:me.ONE_DAY,prompt:!1,tag:0}}},Fs={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Xi={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},BE="history",LE="0.3",kE="expirer",Ci={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},$E="0.3",zE="verify-api",UE="https://verify.walletconnect.com",Nv="https://verify.walletconnect.org",Io=Nv,jE=`${Io}/v3`,KE=[UE,Nv],HE="echo",VE="https://echo.walletconnect.com",pn={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},zn={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Zi={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Os={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Ts={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ho={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},GE=.1,JE="event-client",WE=86400,QE="https://pulse.walletconnect.org/batch";function YE(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),f=a.charCodeAt(0);if(t[f]!==255)throw new TypeError(a+" is ambiguous");t[f]=s}var p=r.length,w=r.charAt(0),b=Math.log(p)/Math.log(256),A=Math.log(256)/Math.log(p);function M(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var j=0,G=0,X=0,z=D.length;X!==z&&D[X]===0;)X++,j++;for(var Q=(z-X)*A+1>>>0,V=new Uint8Array(Q);X!==z;){for(var H=D[X],ee=0,oe=Q-1;(H!==0||ee<G)&&oe!==-1;oe--,ee++)H+=256*V[oe]>>>0,V[oe]=H%p>>>0,H=H/p>>>0;if(H!==0)throw new Error("Non-zero carry");G=ee,X++}for(var ne=Q-G;ne!==Q&&V[ne]===0;)ne++;for(var ge=w.repeat(j);ne<Q;++ne)ge+=r.charAt(V[ne]);return ge}function C(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var j=0;if(D[j]!==" "){for(var G=0,X=0;D[j]===w;)G++,j++;for(var z=(D.length-j)*b+1>>>0,Q=new Uint8Array(z);D[j];){var V=t[D.charCodeAt(j)];if(V===255)return;for(var H=0,ee=z-1;(V!==0||H<X)&&ee!==-1;ee--,H++)V+=p*Q[ee]>>>0,Q[ee]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");X=H,j++}if(D[j]!==" "){for(var oe=z-X;oe!==z&&Q[oe]===0;)oe++;for(var ne=new Uint8Array(G+(z-oe)),ge=G;oe!==z;)ne[ge++]=Q[oe++];return ne}}}function O(D){var j=C(D);if(j)return j;throw new Error(`Non-${e} character`)}return{encode:M,decodeUnsafe:C,decode:O}}var XE=YE,ZE=XE;const Cv=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},eI=r=>new TextEncoder().encode(r),tI=r=>new TextDecoder().decode(r);class rI{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class iI{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 Ov(this,e)}}class nI{constructor(e){this.decoders=e}or(e){return Ov(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 Ov=(r,e)=>new nI({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class sI{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new rI(e,t,i),this.decoder=new iI(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const jf=({name:r,prefix:e,encode:t,decode:i})=>new sI(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:s}=ZE(t,e);return jf({prefix:r,name:e,encode:i,decode:a=>Cv(s(a))})},aI=(r,e,t,i)=>{const s={};for(let A=0;A<e.length;++A)s[e[A]]=A;let a=r.length;for(;r[a-1]==="=";)--a;const f=new Uint8Array(a*t/8|0);let p=0,w=0,b=0;for(let A=0;A<a;++A){const M=s[r[A]];if(M===void 0)throw new SyntaxError(`Non-${i} character`);w=w<<t|M,p+=t,p>=8&&(p-=8,f[b++]=255&w>>p)}if(p>=t||255&w<<8-p)throw new SyntaxError("Unexpected end of data");return f},oI=(r,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let a="",f=0,p=0;for(let w=0;w<r.length;++w)for(p=p<<8|r[w],f+=8;f>t;)f-=t,a+=e[s&p>>f];if(f&&(a+=e[s&p<<t-f]),i)for(;a.length*t&7;)a+="=";return a},Sr=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>jf({prefix:e,name:r,encode(s){return oI(s,i,t)},decode(s){return aI(s,i,t,r)}}),cI=jf({prefix:"\0",name:"identity",encode:r=>tI(r),decode:r=>eI(r)});var fI=Object.freeze({__proto__:null,identity:cI});const hI=Sr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var uI=Object.freeze({__proto__:null,base2:hI});const dI=Sr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var lI=Object.freeze({__proto__:null,base8:dI});const pI=$o({prefix:"9",name:"base10",alphabet:"0123456789"});var gI=Object.freeze({__proto__:null,base10:pI});const vI=Sr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bI=Sr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var mI=Object.freeze({__proto__:null,base16:vI,base16upper:bI});const yI=Sr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wI=Sr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_I=Sr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),AI=Sr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),EI=Sr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),II=Sr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),MI=Sr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),SI=Sr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xI=Sr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var PI=Object.freeze({__proto__:null,base32:yI,base32upper:wI,base32pad:_I,base32padupper:AI,base32hex:EI,base32hexupper:II,base32hexpad:MI,base32hexpadupper:SI,base32z:xI});const RI=$o({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),NI=$o({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var CI=Object.freeze({__proto__:null,base36:RI,base36upper:NI});const OI=$o({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TI=$o({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var DI=Object.freeze({__proto__:null,base58btc:OI,base58flickr:TI});const FI=Sr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qI=Sr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),BI=Sr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),LI=Sr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kI=Object.freeze({__proto__:null,base64:FI,base64pad:qI,base64url:BI,base64urlpad:LI});const Tv=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),$I=Tv.reduce((r,e,t)=>(r[t]=e,r),[]),zI=Tv.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function UI(r){return r.reduce((e,t)=>(e+=$I[t],e),"")}function jI(r){const e=[];for(const t of r){const i=zI[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const KI=jf({prefix:"🚀",name:"base256emoji",encode:UI,decode:jI});var HI=Object.freeze({__proto__:null,base256emoji:KI}),VI=Dv,u1=128,GI=127,JI=~GI,WI=Math.pow(2,31);function Dv(r,e,t){e=e||[],t=t||0;for(var i=t;r>=WI;)e[t++]=r&255|u1,r/=128;for(;r&JI;)e[t++]=r&255|u1,r>>>=7;return e[t]=r|0,Dv.bytes=t-i+1,e}var QI=Qu,YI=128,d1=127;function Qu(r,i){var t=0,i=i||0,s=0,a=i,f,p=r.length;do{if(a>=p)throw Qu.bytes=0,new RangeError("Could not decode varint");f=r[a++],t+=s<28?(f&d1)<<s:(f&d1)*Math.pow(2,s),s+=7}while(f>=YI);return Qu.bytes=a-i,t}var XI=Math.pow(2,7),ZI=Math.pow(2,14),eM=Math.pow(2,21),tM=Math.pow(2,28),rM=Math.pow(2,35),iM=Math.pow(2,42),nM=Math.pow(2,49),sM=Math.pow(2,56),aM=Math.pow(2,63),oM=function(r){return r<XI?1:r<ZI?2:r<eM?3:r<tM?4:r<rM?5:r<iM?6:r<nM?7:r<sM?8:r<aM?9:10},cM={encode:VI,decode:QI,encodingLength:oM},Fv=cM;const l1=(r,e,t=0)=>(Fv.encode(r,e,t),e),p1=r=>Fv.encodingLength(r),Yu=(r,e)=>{const t=e.byteLength,i=p1(r),s=i+p1(t),a=new Uint8Array(s+t);return l1(r,a,0),l1(t,a,i),a.set(e,s),new fM(r,t,e,a)};class fM{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s}}const qv=({name:r,code:e,encode:t})=>new hM(r,e,t);class hM{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Yu(this.code,t):t.then(i=>Yu(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Bv=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),uM=qv({name:"sha2-256",code:18,encode:Bv("SHA-256")}),dM=qv({name:"sha2-512",code:19,encode:Bv("SHA-512")});var lM=Object.freeze({__proto__:null,sha256:uM,sha512:dM});const Lv=0,pM="identity",kv=Cv,gM=r=>Yu(Lv,kv(r)),vM={code:Lv,name:pM,encode:kv,digest:gM};var bM=Object.freeze({__proto__:null,identity:vM});new TextEncoder,new TextDecoder;const g1={...fI,...uI,...lI,...gI,...mI,...PI,...CI,...DI,...kI,...HI};({...lM,...bM});function mM(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function $v(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const v1=$v("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Pu=$v("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=mM(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),yM={utf8:v1,"utf-8":v1,hex:g1.base16,latin1:Pu,ascii:Pu,binary:Pu,...g1};function wM(r,e="utf8"){const t=yM[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class _M{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=wE,this.version=_E,this.initialized=!1,this.storagePrefix=Sn,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,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist()},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:a}=pe("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(a)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Kr(t,this.name)}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Cg(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Og(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}class AM{constructor(e,t,i){this.core=e,this.logger=t,this.name=mE,this.randomSessionIdentifier=Gu(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),a=J0(s);return ug(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=tA();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const a=await this.getClientSeed(),f=J0(a),p=this.randomSessionIdentifier;return await d4(p,s,yE,f)},this.generateSharedKey=(s,a,f)=>{this.isInitialized();const p=this.getPrivateKey(s),w=rA(p,a);return this.setSymKey(w,f)},this.setSymKey=async(s,a)=>{this.isInitialized();const f=a||cf(s);return await this.keychain.set(f,s),f},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s)},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s)},this.encode=async(s,a,f)=>{this.isInitialized();const p=Ev(f),w=Jn(a);if(Yp(p))return nA(w,f==null?void 0:f.encoding);if(Qp(p)){const C=p.senderPublicKey,O=p.receiverPublicKey;s=await this.generateSharedKey(C,O)}const b=this.getSymKey(s),{type:A,senderPublicKey:M}=p;return iA({type:A,symKey:b,message:w,senderPublicKey:M,encoding:f==null?void 0:f.encoding})},this.decode=async(s,a,f)=>{this.isInitialized();const p=oA(a,f);if(Yp(p)){const w=aA(a,f==null?void 0:f.encoding);return zs(w)}if(Qp(p)){const w=p.receiverPublicKey,b=p.senderPublicKey;s=await this.generateSharedKey(w,b)}try{const w=this.getSymKey(s),b=sA({symKey:w,encoded:a,encoding:f==null?void 0:f.encoding});return zs(b)}catch(w){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(w)}},this.getPayloadType=(s,a=ps)=>{const f=Po({encoded:s,encoding:a});return js(f.type)},this.getPayloadSenderPublicKey=(s,a=ps)=>{const f=Po({encoded:s,encoding:a});return f.senderPublicKey?ni(f.senderPublicKey,jr):void 0},this.core=e,this.logger=Kr(t,this.name),this.keychain=i||new _M(this.core,this.logger)}get context(){return oi(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(f1)}catch{e=Gu(),await this.keychain.set(f1,e)}return wM(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}class EM extends sE{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=AE,this.version=EE,this.initialized=!1,this.storagePrefix=Sn,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,s)=>{this.isInitialized();const a=jn(s);let f=this.messages.get(i);return typeof f>"u"&&(f={}),typeof f[a]<"u"||(f[a]=s,this.messages.set(i,f),await this.persist()),a},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const a=this.get(i),f=jn(s);return typeof a[f]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Kr(e,this.name),this.core=t}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Cg(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Og(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}class IM extends aE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Bi.EventEmitter,this.name=ME,this.queue=new Map,this.publishTimeout=me.toMiliseconds(me.ONE_MINUTE),this.failedPublishTimeout=me.toMiliseconds(me.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,s,a)=>{var f;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:a}});const p=(a==null?void 0:a.ttl)||IE,w=Ju(a),b=(a==null?void 0:a.prompt)||!1,A=(a==null?void 0:a.tag)||0,M=(a==null?void 0:a.id)||qs().toString(),C={topic:i,message:s,opts:{ttl:p,relay:w,prompt:b,tag:A,id:M,attestation:a==null?void 0:a.attestation}},O=`Failed to publish payload, please try again. id:${M} tag:${A}`,D=Date.now();let j,G=1;try{for(;j===void 0;){if(Date.now()-D>this.publishTimeout)throw new Error(O);this.logger.trace({id:M,attempts:G},`publisher.publish - attempt ${G}`),j=await await ya(this.rpcPublish(i,s,p,w,b,A,M,a==null?void 0:a.attestation).catch(X=>this.logger.warn(X)),this.publishTimeout,O),G++,j||await new Promise(X=>setTimeout(X,this.failedPublishTimeout))}this.relayer.events.emit(zr.publish,C),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:M,topic:i,message:s,opts:a}})}catch(X){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(X),(f=a==null?void 0:a.internal)!=null&&f.throwOnFailedPublish)throw X;this.queue.set(M,C)}},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.relayer=e,this.logger=Kr(t,this.name),this.registerEventListeners()}get context(){return oi(this.logger)}rpcPublish(e,t,i,s,a,f,p,w){var b,A,M,C;const O={method:bo(s.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:a,tag:f,attestation:w},id:p};return ii((b=O.params)==null?void 0:b.prompt)&&((A=O.params)==null||delete A.prompt),ii((M=O.params)==null?void 0:M.tag)&&((C=O.params)==null||delete C.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:O}),this.relayer.request(O)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:s}=e;await this.publish(t,i,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(Sa.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(zr.connection_stalled);return}this.checkQueue()}),this.relayer.on(zr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class MM{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(a=>a!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var SM=Object.defineProperty,xM=Object.defineProperties,PM=Object.getOwnPropertyDescriptors,b1=Object.getOwnPropertySymbols,RM=Object.prototype.hasOwnProperty,NM=Object.prototype.propertyIsEnumerable,m1=(r,e,t)=>e in r?SM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,uo=(r,e)=>{for(var t in e||(e={}))RM.call(e,t)&&m1(r,t,e[t]);if(b1)for(var t of b1(e))NM.call(e,t)&&m1(r,t,e[t]);return r},Ru=(r,e)=>xM(r,PM(e));class CM extends fE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new MM,this.events=new Bi.EventEmitter,this.name=OE,this.version=TE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Sn,this.subscribeTimeout=me.toMiliseconds(me.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(),await this.restore()),this.initialized=!0},this.subscribe=async(i,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const a=Ju(s),f={topic:i,relay:a,transportType:s==null?void 0:s.transportType};this.pending.set(i,f);const p=await this.rpcSubscribe(i,a,s==null?void 0:s.transportType);return typeof p=="string"&&(this.onSubscribe(p,f),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),p}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof(s==null?void 0:s.id)<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((a,f)=>{const p=new me.Watch;p.start(s);const w=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(w),p.stop(s),a(!0)),p.elapsed(s)>=DE&&(clearInterval(w),p.stop(s),f(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},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=Kr(t,this.name),this.clientId=""}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=Ju(i);await this.rpcUnsubscribe(e,t,s);const a=Bt("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t,i=jt.relay){i===jt.relay&&await this.restartToComplete();const s={method:bo(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{const a=jn(e+this.clientId);return i===jt.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(f=>this.logger.warn(f))},me.toMiliseconds(me.ONE_SECOND)),a):await await ya(this.relayer.request(s).catch(f=>this.logger.warn(f)),this.subscribeTimeout)?a:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(zr.connection_stalled)}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:bo(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await ya(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(zr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:bo(t.protocol).batchFetchMessages,params:{topics:e.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await ya(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(zr.connection_stalled)}return s}rpcUnsubscribe(e,t,i){const s={method:bo(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,Ru(uo({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,uo({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,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,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,uo({},t)),this.topicMap.set(t.topic,e),this.events.emit(mn.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=pe("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(mn.deleted,Ru(uo({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(mn.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(mn.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=pe("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}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 t=await this.rpcBatchSubscribe(e);Mn(t)&&this.onBatchSubscribe(t.map((i,s)=>Ru(uo({},e[s]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.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(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Sa.pulse,async()=>{await this.checkPending()}),this.events.on(mn.created,async e=>{const t=mn.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(mn.deleted,async e=>{const t=mn.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}}var OM=Object.defineProperty,y1=Object.getOwnPropertySymbols,TM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,w1=(r,e,t)=>e in r?OM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,FM=(r,e)=>{for(var t in e||(e={}))TM.call(e,t)&&w1(r,t,e[t]);if(y1)for(var t of y1(e))DM.call(e,t)&&w1(r,t,e[t]);return r};class qM extends oE{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Bi.EventEmitter,this.name=xE,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=me.toMiliseconds(me.THIRTY_SECONDS+me.ONE_SECOND),this.request=async t=>{var i,s;this.logger.debug("Publishing Request Payload");const a=t.id||qs().toString();await this.toEstablishConnection();try{const f=this.provider.request(t);this.requestsInFlight.set(a,{promise:f,request:t}),this.logger.trace({id:a,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const p=await new Promise(async(w,b)=>{const A=()=>{b(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(Ni.disconnect,A);const M=await f;this.provider.off(Ni.disconnect,A),w(M)});return this.logger.trace({id:a,method:t.method,topic:(s=t.params)==null?void 0:s.topic},"relayer.request - published"),p}catch(f){throw this.logger.debug(`Failed to Publish Request: ${a}`),f}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(yf())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,s;(s=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(zr.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(zr.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Ni.payload,this.onPayloadHandler),this.provider.on(Ni.connect,this.onConnectHandler),this.provider.on(Ni.disconnect,this.onDisconnectHandler),this.provider.on(Ni.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Kr(e.logger,this.name):No(Pf({level:e.logger||SE})),this.messages=new EM(this.logger,e.core),this.subscriber=new CM(this,this.logger),this.publisher=new IM(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Rv,this.projectId=e.projectId,this.bundleId=H8(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return oi(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:jt.relay})}async subscribe(e,t){var i;this.isInitialized(),(t==null?void 0:t.transportType)==="relay"&&await this.toEstablishConnection();let s=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",a;const f=p=>{p.topic===e&&(this.subscriber.off(mn.created,f),a())};return await Promise.all([new Promise(p=>{a=p,this.subscriber.on(mn.created,f)}),new Promise(async p=>{s=await this.subscriber.subscribe(e,t)||s,p()})]),s}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){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 ya(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(t,i)=>{const s=()=>{this.provider.off(Ni.disconnect,s),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Ni.disconnect,s),await ya(this.provider.connect(),me.toMiliseconds(me.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(a=>{this.logger.error(a),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);const i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}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 c1())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const s=lr(me.FIVE_MINUTES),a={topic:i,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,a)}this.events.emit(zr.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,s,a;if(yf())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((a=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(f){this.logger.warn(f)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new an(new O4(W8({sdkVersion:Wu,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:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),fd(e)){if(!e.method.endsWith(PE))return;const t=e.params,{topic:i,message:s,publishedAt:a,attestation:f}=t.data,p={topic:i,message:s,publishedAt:a,transportType:jt.relay,attestation:f};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(FM({type:"event",event:t.id},p)),this.events.emit(t.id,p),await this.acknowledgePayload(e),await this.onMessageEvent(p)}else Tf(e)&&this.events.emit(zr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(zr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Cf(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(Ni.payload,this.onPayloadHandler),this.provider.off(Ni.connect,this.onConnectHandler),this.provider.off(Ni.disconnect,this.onDisconnectHandler),this.provider.off(Ni.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await c1();eE(async t=>{e!==t&&(e=t,t?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(zr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},me.toMiliseconds(RE))))}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var BM=Object.defineProperty,_1=Object.getOwnPropertySymbols,LM=Object.prototype.hasOwnProperty,kM=Object.prototype.propertyIsEnumerable,A1=(r,e,t)=>e in r?BM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,E1=(r,e)=>{for(var t in e||(e={}))LM.call(e,t)&&A1(r,t,e[t]);if(_1)for(var t of _1(e))kM.call(e,t)&&A1(r,t,e[t]);return r};class Js extends cE{constructor(e,t,i,s=Sn,a=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=NE,this.cached=[],this.initialized=!1,this.storagePrefix=Sn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(f=>{this.getKey&&f!==null&&!ii(f)?this.map.set(this.getKey(f),f):CA(f)?this.map.set(f.id,f):OA(f)&&this.map.set(f.topic,f)}),this.cached=[],this.initialized=!0)},this.set=async(f,p)=>{this.isInitialized(),this.map.has(f)?await this.update(f,p):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:f,value:p}),this.map.set(f,p),await this.persist())},this.get=f=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:f}),this.getData(f)),this.getAll=f=>(this.isInitialized(),f?this.values.filter(p=>Object.keys(f).every(w=>D4(p[w],f[w]))):this.values),this.update=async(f,p)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:f,update:p});const w=E1(E1({},this.getData(f)),p);this.map.set(f,w),await this.persist()},this.delete=async(f,p)=>{this.isInitialized(),this.map.has(f)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:f,reason:p}),this.map.delete(f),this.addToRecentlyDeleted(f),await this.persist())},this.logger=Kr(t,this.name),this.storagePrefix=s,this.getKey=a}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:s}=pe("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=pe("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=pe("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $M{constructor(e,t){this.core=e,this.logger=t,this.name=FE,this.version=qE,this.events=new id,this.initialized=!1,this.storagePrefix=Sn,this.ignoredPayloadTypes=[Gn],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 s=Gu(),a=await this.core.crypto.setSymKey(s),f=lr(me.FIVE_MINUTES),p={protocol:Pv},w={topic:a,expiry:f,relay:p,active:!1,methods:i==null?void 0:i.methods},b=r1({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:p,expiryTimestamp:f,methods:i==null?void 0:i.methods});return this.events.emit(Fs.create,w),this.core.expirer.set(a,f),await this.pairings.set(a,w),await this.core.relayer.subscribe(a,{transportType:i==null?void 0:i.transportType}),{topic:a,uri:b}},this.pair=async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[pn.pairing_started]}});this.isValidPair(i,s);const{topic:a,symKey:f,relay:p,expiryTimestamp:w,methods:b}=t1(i.uri);s.props.properties.topic=a,s.addTrace(pn.pairing_uri_validation_success),s.addTrace(pn.pairing_uri_not_expired);let A;if(this.pairings.keys.includes(a)){if(A=this.pairings.get(a),s.addTrace(pn.existing_pairing),A.active)throw s.setError(zn.active_pairing_already_exists),new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);s.addTrace(pn.pairing_not_expired)}const M=w||lr(me.FIVE_MINUTES),C={topic:a,relay:p,expiry:M,active:!1,methods:b};this.core.expirer.set(a,M),await this.pairings.set(a,C),s.addTrace(pn.store_new_pairing),i.activatePairing&&await this.activate({topic:a}),this.events.emit(Fs.create,C),s.addTrace(pn.emit_inactive_pairing),this.core.crypto.keychain.has(a)||await this.core.crypto.setSymKey(f,a),s.addTrace(pn.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(zn.no_internet_connection)}try{await this.core.relayer.subscribe(a,{relay:p})}catch(O){throw s.setError(zn.subscribe_pairing_topic_failure),O}return s.addTrace(pn.subscribe_pairing_topic_success),C},this.activate=async({topic:i})=>{this.isInitialized();const s=lr(me.THIRTY_DAYS);this.core.expirer.set(i,s),await this.pairings.update(i,{active:!0,expiry:s})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const a=await this.sendRequest(s,"wc_pairingPing",{}),{done:f,resolve:p,reject:w}=Ds();this.events.once(It("pairing_ping",a),({error:b})=>{b?w(b):p()}),await f()}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s})},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",Bt("USER_DISCONNECTED")),await this.deletePairing(s))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:s,relay:a,expiry:f,methods:p}=i,w=this.core.crypto.keychain.get(s);return r1({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:w,relay:a,expiryTimestamp:f,methods:p})},this.sendRequest=async(i,s,a)=>{const f=ds(s,a),p=await this.core.crypto.encode(i,f),w=fo[s].req;return this.core.history.set(i,f),this.core.relayer.publish(i,p,w),f.id},this.sendResult=async(i,s,a)=>{const f=Cf(i,a),p=await this.core.crypto.encode(s,f),w=await this.core.history.get(s,i),b=fo[w.request.method].res;await this.core.relayer.publish(s,p,b),await this.core.history.resolve(f)},this.sendError=async(i,s,a)=>{const f=Of(i,a),p=await this.core.crypto.encode(s,f),w=await this.core.history.get(s,i),b=fo[w.request.method]?fo[w.request.method].res:fo.unregistered_method.res;await this.core.relayer.publish(s,p,b),await this.core.history.resolve(f)},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Bt("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>cs(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)))},this.onRelayEventRequest=i=>{const{topic:s,payload:a}=i;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(s,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,a);default:return this.onUnknownRpcMethodRequest(s,a)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:a}=i,f=(await this.core.history.get(s,a.id)).request.method;switch(f){case"wc_pairingPing":return this.onPairingPingResponse(s,a);default:return this.onUnknownRpcMethodResponse(f)}},this.onPairingPingRequest=async(i,s)=>{const{id:a}=s;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(Fs.ping,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onPairingPingResponse=(i,s)=>{const{id:a}=s;setTimeout(()=>{gn(s)?this.events.emit(It("pairing_ping",a),{}):Ti(s)&&this.events.emit(It("pairing_ping",a),{error:s.error})},500)},this.onPairingDeleteRequest=async(i,s)=>{const{id:a}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Fs.delete,{id:a,topic:i})}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:a,method:f}=s;try{if(this.registeredMethods.includes(f))return;const p=Bt("WC_METHOD_UNSUPPORTED",f);await this.sendError(a,i,p),this.logger.error(p)}catch(p){await this.sendError(a,i,p),this.logger.error(p)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Bt("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,s)=>{var a;if(!ti(i)){const{message:p}=pe("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(zn.malformed_pairing_uri),new Error(p)}if(!NA(i.uri)){const{message:p}=pe("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(zn.malformed_pairing_uri),new Error(p)}const f=t1(i==null?void 0:i.uri);if(!((a=f==null?void 0:f.relay)!=null&&a.protocol)){const{message:p}=pe("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(zn.malformed_pairing_uri),new Error(p)}if(!(f!=null&&f.symKey)){const{message:p}=pe("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(zn.malformed_pairing_uri),new Error(p)}if(f!=null&&f.expiryTimestamp&&me.toMiliseconds(f==null?void 0:f.expiryTimestamp)<Date.now()){s.setError(zn.pairing_expired);const{message:p}=pe("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(p)}},this.isValidPing=async i=>{if(!ti(i)){const{message:a}=pe("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidDisconnect=async i=>{if(!ti(i)){const{message:a}=pe("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async i=>{if(!ar(i,!1)){const{message:s}=pe("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=pe("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(cs(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=pe("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=e,this.logger=Kr(t,this.name),this.pairings=new Js(this.core,this.logger,this.name,this.storagePrefix)}get context(){return oi(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(zr.message,async e=>{const{topic:t,message:i,transportType:s}=e;if(!this.pairings.keys.includes(t)||s===jt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const a=await this.core.crypto.decode(t,i);try{fd(a)?(this.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a})):Tf(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a}),this.core.history.delete(t,a.id))}catch(f){this.logger.error(f)}})}registerExpirerEvents(){this.core.expirer.on(Ci.expired,async e=>{const{topic:t}=Dg(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Fs.expire,{topic:t}))})}}class zM extends nE{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Bi.EventEmitter,this.name=BE,this.version=LE,this.cached=[],this.initialized=!1,this.storagePrefix=Sn,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,s,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:a}),this.records.has(s.id))return;const f={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:a,expiry:lr(me.THIRTY_DAYS)};this.records.set(f.id,f),this.persist(),this.events.emit(Xi.created,f)},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 s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=Ti(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(Xi.updated,s))},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(a=>{if(a.topic===i){if(typeof s<"u"&&a.id!==s)return;this.records.delete(a.id),this.events.emit(Xi.deleted,a)}}),this.persist()},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.logger=Kr(t,this.name)}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:ds(t.request.method,t.request.params,t.id),chainId:t.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 t=this.records.get(e);if(!t){const{message:i}=pe("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Xi.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=pe("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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(Xi.created,e=>{const t=Xi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Xi.updated,e=>{const t=Xi.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Xi.deleted,e=>{const t=Xi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Sa.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{me.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Xi.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}class UM extends hE{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Bi.EventEmitter,this.name=kE,this.version=$E,this.cached=[],this.initialized=!1,this.storagePrefix=Sn,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 s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return!1}},this.set=(i,s)=>{this.isInitialized();const a=this.formatTarget(i),f={target:a,expiry:s};this.expirations.set(a,f),this.checkExpiry(a,f),this.events.emit(Ci.created,{target:a,expiration:f})},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),a=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Ci.deleted,{target:s,expiration:a})}},this.on=(i,s)=>{this.events.on(i,s)},this.once=(i,s)=>{this.events.once(i,s)},this.off=(i,s)=>{this.events.off(i,s)},this.removeListener=(i,s)=>{this.events.removeListener(i,s)},this.logger=Kr(t,this.name)}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Q8(e);if(typeof e=="number")return Y8(e);const{message:t}=pe("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ci.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=pe("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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 t=this.expirations.get(e);if(!t){const{message:i}=pe("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;me.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ci.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Sa.pulse,()=>this.checkExpirations()),this.events.on(Ci.created,e=>{const t=Ci.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ci.expired,e=>{const t=Ci.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ci.deleted,e=>{const t=Ci.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.getLocalStorage=Jt.getLocalStorageOrThrow=Jt.getCrypto=Jt.getCryptoOrThrow=Jt.getLocation=Jt.getLocationOrThrow=Jt.getNavigator=Jt.getNavigatorOrThrow=zv=Jt.getDocument=Jt.getDocumentOrThrow=Jt.getFromWindowOrThrow=Jt.getFromWindow=void 0;function Ws(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Jt.getFromWindow=Ws;function Ba(r){const e=Ws(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Jt.getFromWindowOrThrow=Ba;function jM(){return Ba("document")}Jt.getDocumentOrThrow=jM;function KM(){return Ws("document")}var zv=Jt.getDocument=KM;function HM(){return Ba("navigator")}Jt.getNavigatorOrThrow=HM;function VM(){return Ws("navigator")}Jt.getNavigator=VM;function GM(){return Ba("location")}Jt.getLocationOrThrow=GM;function JM(){return Ws("location")}Jt.getLocation=JM;function WM(){return Ba("crypto")}Jt.getCryptoOrThrow=WM;function QM(){return Ws("crypto")}Jt.getCrypto=QM;function YM(){return Ba("localStorage")}Jt.getLocalStorageOrThrow=YM;function XM(){return Ws("localStorage")}Jt.getLocalStorage=XM;class ZM extends uE{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=zE,this.verifyUrlV3=jE,this.storagePrefix=Sn,this.version=xv,this.init=async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&me.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async s=>{if(!Fo()||this.isDevEnv)return;const a=window.location.origin,{id:f,decryptedId:p}=s,w=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${a}&id=${f}&decryptedId=${p}`;try{const b=zv(),A=this.startAbortTimer(me.ONE_SECOND*5),M=await new Promise((C,O)=>{const D=()=>{window.removeEventListener("message",G),b.body.removeChild(j),O("attestation aborted")};this.abortController.signal.addEventListener("abort",D);const j=b.createElement("iframe");j.src=w,j.style.display="none",j.addEventListener("error",D,{signal:this.abortController.signal});const G=X=>{if(X.data&&typeof X.data=="string")try{const z=JSON.parse(X.data);if(z.type==="verify_attestation"){if(Lu(z.attestation).payload.id!==f)return;clearInterval(A),b.body.removeChild(j),this.abortController.signal.removeEventListener("abort",D),window.removeEventListener("message",G),C(z.attestation===null?"":z.attestation)}}catch(z){this.logger.warn(z)}};b.body.appendChild(j),window.addEventListener("message",G,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",M),M}catch(b){this.logger.warn(b)}return""},this.resolve=async s=>{if(this.isDevEnv)return"";const{attestationId:a,hash:f,encryptedId:p}=s;if(a===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(a){if(Lu(a).payload.id!==p)return;const b=await this.isValidJwtAttestation(a);if(b){if(!b.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return b}}if(!f)return;const w=this.getVerifyUrl(s==null?void 0:s.verifyUrl);return this.fetchAttestation(f,w)},this.fetchAttestation=async(s,a)=>{this.logger.debug(`resolving attestation: ${s} from url: ${a}`);const f=this.startAbortTimer(me.ONE_SECOND*5),p=await fetch(`${a}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(f),p.status===200?await p.json():void 0},this.getVerifyUrl=s=>{let a=s||Io;return KE.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${Io}`),a=Io),a},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(me.FIVE_SECONDS),a=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await a.json()}catch(s){this.logger.warn(s)}},this.persistPublicKey=async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async s=>{const a=await this.getPublicKey();try{if(a)return this.validateAttestation(s,a)}catch(p){this.logger.error(p),this.logger.warn("error validating attestation")}const f=await this.fetchAndPersistPublicKey();try{if(f)return this.validateAttestation(s,f)}catch(p){this.logger.error(p),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async a=>{const f=await this.fetchPublicKey();f&&(await this.persistPublicKey(f),a(f))});const s=await this.fetchPromise;return this.fetchPromise=void 0,s},this.validateAttestation=(s,a)=>{const f=uA(s,a.publicKey),p={hasExpired:me.toMiliseconds(f.exp)<Date.now(),payload:f};if(p.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:p.payload.origin,isScam:p.payload.isScam,isVerified:p.payload.isVerified}},this.logger=Kr(t,this.name),this.abortController=new AbortController,this.isDevEnv=bd(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return oi(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),me.toMiliseconds(e))}}class eS extends dE{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=HE,this.registerDeviceToken=async i=>{const{clientId:s,token:a,notificationType:f,enableEncrypted:p=!1}=i,w=`${VE}/${this.projectId}/clients`;await fetch(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:f,token:a,always_raw:p})})},this.logger=Kr(t,this.context)}}var tS=Object.defineProperty,I1=Object.getOwnPropertySymbols,rS=Object.prototype.hasOwnProperty,iS=Object.prototype.propertyIsEnumerable,M1=(r,e,t)=>e in r?tS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,lo=(r,e)=>{for(var t in e||(e={}))rS.call(e,t)&&M1(r,t,e[t]);if(I1)for(var t of I1(e))iS.call(e,t)&&M1(r,t,e[t]);return r};class nS extends lE{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=JE,this.storagePrefix=Sn,this.storageVersion=GE,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!bd())try{const s={eventId:wp(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Ng(this.core.relayer.protocol,this.core.relayer.version,Wu)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}},this.createEvent=s=>{const{event:a="ERROR",type:f="",properties:{topic:p,trace:w}}=s,b=wp(),A=this.core.projectId||"",M=Date.now(),C=lo({eventId:b,timestamp:M,props:{event:a,type:f,properties:{topic:p,trace:w}},bundleId:A,domain:this.getAppDomain()},this.setMethods(b));return this.telemetryEnabled&&(this.events.set(b,C),this.shouldPersist=!0),C},this.getEvent=s=>{const{eventId:a,topic:f}=s;if(a)return this.events.get(a);const p=Array.from(this.events.values()).find(w=>w.props.properties.topic===f);if(p)return lo(lo({},p),this.setMethods(p.eventId))},this.deleteEvent=s=>{const{eventId:a}=s;this.events.delete(a),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Sa.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{me.fromMiliseconds(Date.now())-me.fromMiliseconds(s.timestamp)>WE&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})},this.setMethods=s=>({addTrace:a=>this.addTrace(s,a),setError:a=>this.setError(s,a)}),this.addTrace=(s,a)=>{const f=this.events.get(s);f&&(f.props.properties.trace.push(a),this.events.set(s,f),this.shouldPersist=!0)},this.setError=(s,a)=>{const f=this.events.get(s);f&&(f.props.type=a,f.timestamp=Date.now(),this.events.set(s,f),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(a=>{this.events.set(a.eventId,lo(lo({},a),this.setMethods(a.eventId)))})}catch(s){this.logger.warn(s)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[a,f]of this.events)f.props.type&&s.push(f);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const a of s)this.events.delete(a.eventId),this.shouldPersist=!0}catch(a){this.logger.warn(a)}},this.sendEvent=async s=>{const a=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${QE}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Wu}${a}`,{method:"POST",body:JSON.stringify(s)})},this.getAppDomain=()=>Rg().url,this.logger=Kr(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var sS=Object.defineProperty,S1=Object.getOwnPropertySymbols,aS=Object.prototype.hasOwnProperty,oS=Object.prototype.propertyIsEnumerable,x1=(r,e,t)=>e in r?sS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,P1=(r,e)=>{for(var t in e||(e={}))aS.call(e,t)&&x1(r,t,e[t]);if(S1)for(var t of S1(e))oS.call(e,t)&&x1(r,t,e[t]);return r};class Pd extends iE{constructor(e){var t;super(e),this.protocol=Sv,this.version=xv,this.name=xd,this.events=new Bi.EventEmitter,this.initialized=!1,this.on=(f,p)=>this.events.on(f,p),this.once=(f,p)=>this.events.once(f,p),this.off=(f,p)=>this.events.off(f,p),this.removeListener=(f,p)=>this.events.removeListener(f,p),this.dispatchEnvelope=({topic:f,message:p,sessionExists:w})=>{if(!f||!p)return;const b={topic:f,message:p,publishedAt:Date.now(),transportType:jt.link_mode};this.relayer.onLinkMessageEvent(b,{sessionExists:w})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Rv,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Pf({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:vE.logger}),{logger:s,chunkLoggerController:a}=X5({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=a,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var f,p;(f=this.logChunkController)!=null&&f.downloadLogsBlobInBrowser&&((p=this.logChunkController)==null||p.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Kr(s,this.name),this.heartbeat=new B5,this.crypto=new AM(this,this.logger,e==null?void 0:e.keychain),this.history=new zM(this,this.logger),this.expirer=new UM(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new F5(P1(P1({},bE),e==null?void 0:e.storageOptions)),this.relayer=new qM({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new $M(this,this.logger),this.verify=new ZM(this,this.logger,this.storage),this.echoClient=new eS(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new nS(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new Pd(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(CE,i),t}get context(){return oi(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(h1,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(h1)||[],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 cS=Pd,Uv="wc",jv=2,Kv="client",Rd=`${Uv}@${jv}:${Kv}:`,Nu={name:Kv,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},R1="WALLETCONNECT_DEEPLINK_CHOICE",fS="proposal",Hv="Proposal expired",hS="session",pa=me.SEVEN_DAYS,uS="engine",br={wc_sessionPropose:{req:{ttl:me.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:me.ONE_DAY,prompt:!1,tag:1104},res:{ttl:me.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:me.ONE_DAY,prompt:!1,tag:1106},res:{ttl:me.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:me.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:me.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:me.ONE_DAY,prompt:!1,tag:1112},res:{ttl:me.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:me.ONE_DAY,prompt:!1,tag:1114},res:{ttl:me.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:me.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:me.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:me.FIVE_MINUTES,prompt:!1,tag:1119}}},Cu={min:me.FIVE_MINUTES,max:me.SEVEN_DAYS},ln={idle:"IDLE",active:"ACTIVE"},dS="request",lS=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],pS="wc",gS="auth",vS="authKeys",bS="pairingTopics",mS="requests",Kf=`${pS}@${1.5}:${gS}:`,ff=`${Kf}:PUB_KEY`;var yS=Object.defineProperty,wS=Object.defineProperties,_S=Object.getOwnPropertyDescriptors,N1=Object.getOwnPropertySymbols,AS=Object.prototype.hasOwnProperty,ES=Object.prototype.propertyIsEnumerable,C1=(r,e,t)=>e in r?yS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zt=(r,e)=>{for(var t in e||(e={}))AS.call(e,t)&&C1(r,t,e[t]);if(N1)for(var t of N1(e))ES.call(e,t)&&C1(r,t,e[t]);return r},en=(r,e)=>wS(r,_S(e));class IS extends gE{constructor(e){super(e),this.name=uS,this.events=new id,this.initialized=!1,this.requestQueue={state:ln.idle,queue:[]},this.sessionRequestQueue={state:ln.idle,queue:[]},this.requestQueueDelay=me.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(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(br)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},me.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=en(Zt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:f,sessionProperties:p,relays:w}=i;let b=s,A,M=!1;try{b&&(M=this.client.core.pairing.pairings.get(b).active)}catch(V){throw this.client.logger.error(`connect() -> pairing.get(${b}) failed`),V}if(!b||!M){const{topic:V,uri:H}=await this.client.core.pairing.create();b=V,A=H}if(!b){const{message:V}=pe("NO_MATCHING_KEY",`connect() pairing topic: ${b}`);throw new Error(V)}const C=await this.client.core.crypto.generateKeyPair(),O=br.wc_sessionPropose.req.ttl||me.FIVE_MINUTES,D=lr(O),j=Zt({requiredNamespaces:a,optionalNamespaces:f,relays:w??[{protocol:Pv}],proposer:{publicKey:C,metadata:this.client.metadata},expiryTimestamp:D,pairingTopic:b},p&&{sessionProperties:p}),{reject:G,resolve:X,done:z}=Ds(O,Hv);this.events.once(It("session_connect"),async({error:V,session:H})=>{if(V)G(V);else if(H){H.self.publicKey=C;const ee=en(Zt({},H),{pairingTopic:j.pairingTopic,requiredNamespaces:j.requiredNamespaces,optionalNamespaces:j.optionalNamespaces,transportType:jt.relay});await this.client.session.set(H.topic,ee),await this.setExpiry(H.topic,H.expiry),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:H.peer.metadata}),this.cleanupDuplicatePairings(ee),X(ee)}});const Q=await this.sendRequest({topic:b,method:"wc_sessionPropose",params:j,throwOnFailedPublish:!0});return await this.setProposal(Q,Zt({id:Q},j)),{uri:A,approval:z}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,s,a;const f=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[Zi.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(ne){throw f.setError(Os.no_internet_connection),ne}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(ne){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),f.setError(Os.proposal_not_found),ne}try{await this.isValidApprove(t)}catch(ne){throw this.client.logger.error("approve() -> isValidApprove() failed"),f.setError(Os.session_approve_namespace_validation_failure),ne}const{id:p,relayProtocol:w,namespaces:b,sessionProperties:A,sessionConfig:M}=t,C=this.client.proposal.get(p);this.client.core.eventClient.deleteEvent({eventId:f.eventId});const{pairingTopic:O,proposer:D,requiredNamespaces:j,optionalNamespaces:G}=C;let X=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:O});X||(X=(a=this.client.core.eventClient)==null?void 0:a.createEvent({type:Zi.session_approve_started,properties:{topic:O,trace:[Zi.session_approve_started,Zi.session_namespaces_validation_success]}}));const z=await this.client.core.crypto.generateKeyPair(),Q=D.publicKey,V=await this.client.core.crypto.generateSharedKey(z,Q),H=Zt(Zt({relay:{protocol:w??"irn"},namespaces:b,controller:{publicKey:z,metadata:this.client.metadata},expiry:lr(pa)},A&&{sessionProperties:A}),M&&{sessionConfig:M}),ee=jt.relay;X.addTrace(Zi.subscribing_session_topic);try{await this.client.core.relayer.subscribe(V,{transportType:ee})}catch(ne){throw X.setError(Os.subscribe_session_topic_failure),ne}X.addTrace(Zi.subscribe_session_topic_success);const oe=en(Zt({},H),{topic:V,requiredNamespaces:j,optionalNamespaces:G,pairingTopic:O,acknowledged:!1,self:H.controller,peer:{publicKey:D.publicKey,metadata:D.metadata},controller:z,transportType:jt.relay});await this.client.session.set(V,oe),X.addTrace(Zi.store_session);try{X.addTrace(Zi.publishing_session_settle),await this.sendRequest({topic:V,method:"wc_sessionSettle",params:H,throwOnFailedPublish:!0}).catch(ne=>{throw X==null||X.setError(Os.session_settle_publish_failure),ne}),X.addTrace(Zi.session_settle_publish_success),X.addTrace(Zi.publishing_session_approve),await this.sendResult({id:p,topic:O,result:{relay:{protocol:w??"irn"},responderPublicKey:z},throwOnFailedPublish:!0}).catch(ne=>{throw X==null||X.setError(Os.session_approve_publish_failure),ne}),X.addTrace(Zi.session_approve_publish_success)}catch(ne){throw this.client.logger.error(ne),this.client.session.delete(V,Bt("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(V),ne}return this.client.core.eventClient.deleteEvent({eventId:X.eventId}),await this.client.core.pairing.updateMetadata({topic:O,metadata:D.metadata}),await this.client.proposal.delete(p,Bt("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:O}),await this.setExpiry(V,lr(pa)),{topic:V,acknowledged:()=>Promise.resolve(this.client.session.get(V))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(f){throw this.client.logger.error("reject() -> isValidReject() failed"),f}const{id:i,reason:s}=t;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(f){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),f}a&&(await this.sendError({id:i,topic:a,error:s,rpcOpts:br.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Bt("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(M){throw this.client.logger.error("update() -> isValidUpdate() failed"),M}const{topic:i,namespaces:s}=t,{done:a,resolve:f,reject:p}=Ds(),w=os(),b=qs().toString(),A=this.client.session.get(i).namespaces;return this.events.once(It("session_update",w),({error:M})=>{M?p(M):f()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:w,relayRpcId:b}).catch(M=>{this.client.logger.error(M),this.client.session.update(i,{namespaces:A}),p(M)}),{acknowledged:a}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(w){throw this.client.logger.error("extend() -> isValidExtend() failed"),w}const{topic:i}=t,s=os(),{done:a,resolve:f,reject:p}=Ds();return this.events.once(It("session_extend",s),({error:w})=>{w?p(w):f()}),await this.setExpiry(i,lr(pa)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(w=>{p(w)}),{acknowledged:a}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(D){throw this.client.logger.error("request() -> isValidRequest() failed"),D}const{chainId:i,request:s,topic:a,expiry:f=br.wc_sessionRequest.req.ttl}=t,p=this.client.session.get(a);(p==null?void 0:p.transportType)===jt.relay&&await this.confirmOnlineStateOrThrow();const w=os(),b=qs().toString(),{done:A,resolve:M,reject:C}=Ds(f,"Request expired. Please try again.");this.events.once(It("session_request",w),({error:D,result:j})=>{D?C(D):M(j)});const O=this.getAppLinkIfEnabled(p.peer.metadata,p.transportType);return O?(await this.sendRequest({clientRpcId:w,relayRpcId:b,topic:a,method:"wc_sessionRequest",params:{request:en(Zt({},s),{expiryTimestamp:lr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0,appLink:O}).catch(D=>C(D)),this.client.events.emit("session_request_sent",{topic:a,request:s,chainId:i,id:w}),await A()):await Promise.all([new Promise(async D=>{await this.sendRequest({clientRpcId:w,relayRpcId:b,topic:a,method:"wc_sessionRequest",params:{request:en(Zt({},s),{expiryTimestamp:lr(f)}),chainId:i},expiry:f,throwOnFailedPublish:!0}).catch(j=>C(j)),this.client.events.emit("session_request_sent",{topic:a,request:s,chainId:i,id:w}),D()}),new Promise(async D=>{var j;if(!((j=p.sessionConfig)!=null&&j.disableDeepLink)){const G=await e9(this.client.core.storage,R1);await X8({id:w,topic:a,wcDeepLink:G})}D()}),A()]).then(D=>D[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:s}=t,{id:a}=s,f=this.client.session.get(i);f.transportType===jt.relay&&await this.confirmOnlineStateOrThrow();const p=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);gn(s)?await this.sendResult({id:a,topic:i,result:s.result,throwOnFailedPublish:!0,appLink:p}):Ti(s)&&await this.sendError({id:a,topic:i,error:s.error,appLink:p}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=t;if(this.client.session.keys.includes(i)){const s=os(),a=qs().toString(),{done:f,resolve:p,reject:w}=Ds();this.events.once(It("session_ping",s),({error:b})=>{b?w(b):p()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:a}),f()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:s,chainId:a}=t,f=qs().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:a},throwOnFailedPublish:!0,relayRpcId:f})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Bt("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:s}=pe("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>PA(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var s;this.isInitialized(),this.isValidAuthenticate(t);const a=i&&this.client.core.linkModeSupportedApps.includes(i)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),f=a?jt.link_mode:jt.relay;f===jt.relay&&await this.confirmOnlineStateOrThrow();const{chains:p,statement:w="",uri:b,domain:A,nonce:M,type:C,exp:O,nbf:D,methods:j=[],expiry:G}=t,X=[...t.resources||[]],{topic:z,uri:Q}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:f});this.client.logger.info({message:"Generated new pairing",pairing:{topic:z,uri:Q}});const V=await this.client.core.crypto.generateKeyPair(),H=cf(V);if(await Promise.all([this.client.auth.authKeys.set(ff,{responseTopic:H,publicKey:V}),this.client.auth.pairingTopics.set(H,{topic:H,pairingTopic:z})]),await this.client.core.relayer.subscribe(H,{transportType:f}),this.client.logger.info(`sending request to new pairing topic: ${z}`),j.length>0){const{namespace:x}=wo(p[0]);let E=W_(x,"request",j);of(X)&&(E=Y_(E,X.pop())),X.push(E)}const ee=G&&G>br.wc_sessionAuthenticate.req.ttl?G:br.wc_sessionAuthenticate.req.ttl,oe={authPayload:{type:C??"caip122",chains:p,statement:w,aud:b,domain:A,version:"1",nonce:M,iat:new Date().toISOString(),exp:O,nbf:D,resources:X},requester:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:lr(ee)},ne={eip155:{chains:p,methods:[...new Set(["personal_sign",...j])],events:["chainChanged","accountsChanged"]}},ge={requiredNamespaces:{},optionalNamespaces:ne,relays:[{protocol:"irn"}],pairingTopic:z,proposer:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:lr(br.wc_sessionPropose.req.ttl)},{done:ht,resolve:L,reject:v}=Ds(ee,"Request expired"),c=async({error:x,session:E})=>{if(this.events.off(It("session_request",g),d),x)v(x);else if(E){E.self.publicKey=V,await this.client.session.set(E.topic,E),await this.setExpiry(E.topic,E.expiry),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:E.peer.metadata});const u=this.client.session.get(E.topic);await this.deleteProposal(_),L({session:u})}},d=async x=>{var E,u,l;if(await this.deletePendingAuthRequest(g,{message:"fulfilled",code:0}),x.error){const k=Bt("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return x.error.code===k.code?void 0:(this.events.off(It("session_connect"),c),v(x.error.message))}await this.deleteProposal(_),this.events.off(It("session_connect"),c);const{cacaos:R,responder:ie}=x.result,se=[],I=[];for(const k of R){await Vp({cacao:k,projectId:this.client.core.projectId})||(this.client.logger.error(k,"Signature verification failed"),v(Bt("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:$}=k,m=of($.resources),B=[Hp($.iss)],re=If($.iss);if(m){const he=Gp(m),ue=Jp(m);se.push(...he),B.push(...ue)}for(const he of B)I.push(`${he}:${re}`)}const Z=await this.client.core.crypto.generateSharedKey(V,ie.publicKey);let F;se.length>0&&(F={topic:Z,acknowledged:!0,self:{publicKey:V,metadata:this.client.metadata},peer:ie,controller:ie.publicKey,expiry:lr(pa),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:z,namespaces:i1([...new Set(se)],[...new Set(I)]),transportType:f},await this.client.core.relayer.subscribe(Z,{transportType:f}),await this.client.session.set(Z,F),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:ie.metadata}),F=this.client.session.get(Z)),(E=this.client.metadata.redirect)!=null&&E.linkMode&&(u=ie.metadata.redirect)!=null&&u.linkMode&&(l=ie.metadata.redirect)!=null&&l.universal&&i&&(this.client.core.addLinkModeSupportedApp(ie.metadata.redirect.universal),this.client.session.update(Z,{transportType:jt.link_mode})),L({auths:R,session:F})},g=os(),_=os();this.events.once(It("session_connect"),c),this.events.once(It("session_request",g),d);let S;try{if(a){const x=ds("wc_sessionAuthenticate",oe,g);this.client.core.history.set(z,x);const E=await this.client.core.crypto.encode("",x,{type:ko,encoding:oo});S=Qc(i,z,E)}else await Promise.all([this.sendRequest({topic:z,method:"wc_sessionAuthenticate",params:oe,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:g}),this.sendRequest({topic:z,method:"wc_sessionPropose",params:ge,expiry:br.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:_})])}catch(x){throw this.events.off(It("session_connect"),c),this.events.off(It("session_request",g),d),x}return await this.setProposal(_,Zt({id:_},ge)),await this.setAuthRequest(g,{request:en(Zt({},oe),{verifyContext:{}}),pairingTopic:z,transportType:f}),{uri:S??Q,response:ht}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:s}=t,a=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Ts.authenticated_session_approve_started]}});try{this.isInitialized()}catch(G){throw a.setError(ho.no_internet_connection),G}const f=this.getPendingAuthRequest(i);if(!f)throw a.setError(ho.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const p=f.transportType||jt.relay;p===jt.relay&&await this.confirmOnlineStateOrThrow();const w=f.requester.publicKey,b=await this.client.core.crypto.generateKeyPair(),A=cf(w),M={type:Gn,receiverPublicKey:w,senderPublicKey:b},C=[],O=[];for(const G of s){if(!await Vp({cacao:G,projectId:this.client.core.projectId})){a.setError(ho.invalid_cacao);const H=Bt("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:A,error:H,encodeOpts:M}),new Error(H.message)}a.addTrace(Ts.cacaos_verified);const{p:X}=G,z=of(X.resources),Q=[Hp(X.iss)],V=If(X.iss);if(z){const H=Gp(z),ee=Jp(z);C.push(...H),Q.push(...ee)}for(const H of Q)O.push(`${H}:${V}`)}const D=await this.client.core.crypto.generateSharedKey(b,w);a.addTrace(Ts.create_authenticated_session_topic);let j;if((C==null?void 0:C.length)>0){j={topic:D,acknowledged:!0,self:{publicKey:b,metadata:this.client.metadata},peer:{publicKey:w,metadata:f.requester.metadata},controller:w,expiry:lr(pa),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:f.pairingTopic,namespaces:i1([...new Set(C)],[...new Set(O)]),transportType:p},a.addTrace(Ts.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(D,{transportType:p})}catch(G){throw a.setError(ho.subscribe_authenticated_session_topic_failure),G}a.addTrace(Ts.subscribe_authenticated_session_topic_success),await this.client.session.set(D,j),a.addTrace(Ts.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:f.requester.metadata})}a.addTrace(Ts.publishing_authenticated_session_approve);try{await this.sendResult({topic:A,id:i,result:{cacaos:s,responder:{publicKey:b,metadata:this.client.metadata}},encodeOpts:M,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(f.requester.metadata,p)})}catch(G){throw a.setError(ho.authenticated_session_approve_publish_failure),G}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:f.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:a.eventId}),{session:j}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:s}=t,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);a.transportType===jt.relay&&await this.confirmOnlineStateOrThrow();const f=a.requester.publicKey,p=await this.client.core.crypto.generateKeyPair(),w=cf(f),b={type:Gn,receiverPublicKey:f,senderPublicKey:p};await this.sendError({id:i,topic:w,error:s,encodeOpts:b,rpcOpts:br.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(a.requester.metadata,a.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Bt("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:s}=t;return bv(i,s)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(a=>{var f,p;return((f=a.peerMetadata)==null?void 0:f.url)&&((p=a.peerMetadata)==null?void 0:p.url)===t.peer.metadata.url&&a.topic&&a.topic!==i.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(a=>this.client.core.pairing.disconnect({topic:a.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:s,expirerHasDeleted:a=!1,emitEvent:f=!0,id:p=0}=t,{self:w}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,Bt("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(w.publicKey)&&await this.client.core.crypto.deleteKeyPair(w.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),a||this.client.core.expirer.del(s),this.client.core.storage.removeItem(R1).catch(b=>this.client.logger.warn(b)),this.getPendingSessionRequests().forEach(b=>{b.topic===s&&this.deletePendingSessionRequest(b.id,Bt("USER_DISCONNECTED"))}),s===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=ln.idle),f&&this.client.events.emit("session_delete",{id:p,topic:s})},this.deleteProposal=async(t,i)=>{if(i)try{const s=this.client.proposal.get(t),a=this.client.core.eventClient.getEvent({topic:s.pairingTopic});a==null||a.setError(Os.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Bt("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),s?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==t),s&&(this.sessionRequestQueue.state=ln.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),s?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,lr(br.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:s,pairingTopic:a,transportType:f=jt.relay}=i;this.client.core.expirer.set(t,s.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:t,pairingTopic:a,verifyContext:s.verifyContext,transportType:f})},this.setPendingSessionRequest=async t=>{const{id:i,topic:s,params:a,verifyContext:f}=t,p=a.request.expiryTimestamp||lr(br.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,p),await this.client.pendingRequest.set(i,{id:i,topic:s,params:a,verifyContext:f})},this.sendRequest=async t=>{const{topic:i,method:s,params:a,expiry:f,relayRpcId:p,clientRpcId:w,throwOnFailedPublish:b,appLink:A}=t,M=ds(s,a,w);let C;const O=!!A;try{const G=O?oo:ps;C=await this.client.core.crypto.encode(i,M,{encoding:G})}catch(G){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),G}let D;if(lS.includes(s)){const G=jn(JSON.stringify(M)),X=jn(C);D=await this.client.core.verify.register({id:X,decryptedId:G})}const j=br[s].req;if(j.attestation=D,f&&(j.ttl=f),p&&(j.id=p),this.client.core.history.set(i,M),O){const G=Qc(A,i,C);await global.Linking.openURL(G,this.client.name)}else{const G=br[s].req;f&&(G.ttl=f),p&&(G.id=p),b?(G.internal=en(Zt({},G.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,C,G)):this.client.core.relayer.publish(i,C,G).catch(X=>this.client.logger.error(X))}return M.id},this.sendResult=async t=>{const{id:i,topic:s,result:a,throwOnFailedPublish:f,encodeOpts:p,appLink:w}=t,b=Cf(i,a);let A;const M=w&&typeof(global==null?void 0:global.Linking)<"u";try{const O=M?oo:ps;A=await this.client.core.crypto.encode(s,b,en(Zt({},p||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),O}let C;try{C=await this.client.core.history.get(s,i)}catch(O){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),O}if(M){const O=Qc(w,s,A);await global.Linking.openURL(O,this.client.name)}else{const O=br[C.request.method].res;f?(O.internal=en(Zt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,A,O)):this.client.core.relayer.publish(s,A,O).catch(D=>this.client.logger.error(D))}await this.client.core.history.resolve(b)},this.sendError=async t=>{const{id:i,topic:s,error:a,encodeOpts:f,rpcOpts:p,appLink:w}=t,b=Of(i,a);let A;const M=w&&typeof(global==null?void 0:global.Linking)<"u";try{const O=M?oo:ps;A=await this.client.core.crypto.encode(s,b,en(Zt({},f||{}),{encoding:O}))}catch(O){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),O}let C;try{C=await this.client.core.history.get(s,i)}catch(O){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),O}if(M){const O=Qc(w,s,A);await global.Linking.openURL(O,this.client.name)}else{const O=p||br[C.request.method].res;this.client.core.relayer.publish(s,A,O)}await this.client.core.history.resolve(b)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(s=>{let a=!1;cs(s.expiry)&&(a=!0),this.client.core.crypto.keychain.has(s.topic)||(a=!0),a&&t.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{cs(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...t.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===ln.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=ln.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=ln.idle},this.processRequest=async t=>{const{topic:i,payload:s,attestation:a,transportType:f,encryptedId:p}=t,w=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:w}))switch(w){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:s,attestation:a,encryptedId:p});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,s);case"wc_sessionPing":return await this.onSessionPingRequest(i,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:s,attestation:a,encryptedId:p,transportType:f});case"wc_sessionEvent":return await this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:s,attestation:a,encryptedId:p,transportType:f});default:return this.client.logger.info(`Unsupported request method ${w}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:s,transportType:a}=t,f=(await this.client.core.history.get(i,s.id)).request.method;switch(f){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s,a);case"wc_sessionSettle":return this.onSessionSettleResponse(i,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,s);case"wc_sessionExtend":return this.onSessionExtendResponse(i,s);case"wc_sessionPing":return this.onSessionPingResponse(i,s);case"wc_sessionRequest":return this.onSessionRequestResponse(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,s);default:return this.client.logger.info(`Unsupported response method ${f}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:s}=pe("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:s}=t,a=this.expectedPairingMethodMap.get(i);return!a||a.includes(s)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:s,attestation:a,encryptedId:f}=t,{params:p,id:w}=s;try{const b=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(Zt({},s.params));const A=p.expiryTimestamp||lr(br.wc_sessionPropose.req.ttl),M=Zt({id:w,pairingTopic:i,expiryTimestamp:A},p);await this.setProposal(w,M);const C=await this.getVerifyContext({attestationId:a,hash:jn(JSON.stringify(s)),encryptedId:f,metadata:M.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),b==null||b.setError(zn.proposal_listener_not_found)),b==null||b.addTrace(pn.emit_session_proposal),this.client.events.emit("session_proposal",{id:w,params:M,verifyContext:C})}catch(b){await this.sendError({id:w,topic:i,error:b,rpcOpts:br.wc_sessionPropose.autoReject}),this.client.logger.error(b)}},this.onSessionProposeResponse=async(t,i,s)=>{const{id:a}=i;if(gn(i)){const{result:f}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:f});const p=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:p});const w=p.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:w});const b=f.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:b});const A=await this.client.core.crypto.generateSharedKey(w,b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:A});const M=await this.client.core.relayer.subscribe(A,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:M}),await this.client.core.pairing.activate({topic:t})}else if(Ti(i)){await this.client.proposal.delete(a,Bt("USER_DISCONNECTED"));const f=It("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners, 954`);this.events.emit(It("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:s,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:f,controller:p,expiry:w,namespaces:b,sessionProperties:A,sessionConfig:M}=i.params,C=en(Zt(Zt({topic:t,relay:f,expiry:w,namespaces:b,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:p.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:p.publicKey,metadata:p.metadata}},A&&{sessionProperties:A}),M&&{sessionConfig:M}),{transportType:jt.relay}),O=It("session_connect");if(this.events.listenerCount(O)===0)throw new Error(`emitting ${O} without any listeners 997`);this.events.emit(It("session_connect"),{session:C}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){await this.sendError({id:s,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionSettleResponse=async(t,i)=>{const{id:s}=i;gn(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(It("session_approve",s),{})):Ti(i)&&(await this.client.session.delete(t,Bt("USER_DISCONNECTED")),this.events.emit(It("session_approve",s),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:s,id:a}=i;try{const f=`${t}_session_update`,p=co.get(f);if(p&&this.isRequestOutOfSync(p,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:t,error:Bt("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Zt({topic:t},s));try{co.set(f,a),await this.client.session.update(t,{namespaces:s.namespaces}),await this.sendResult({id:a,topic:t,result:!0,throwOnFailedPublish:!0})}catch(w){throw co.delete(f),w}this.client.events.emit("session_update",{id:a,topic:t,params:s})}catch(f){await this.sendError({id:a,topic:t,error:f}),this.client.logger.error(f)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{const{id:s}=i,a=It("session_update",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);gn(i)?this.events.emit(It("session_update",s),{}):Ti(i)&&this.events.emit(It("session_update",s),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:s}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,lr(pa)),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:t})}catch(a){await this.sendError({id:s,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(t,i)=>{const{id:s}=i,a=It("session_extend",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);gn(i)?this.events.emit(It("session_extend",s),{}):Ti(i)&&this.events.emit(It("session_extend",s),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:s}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:t})}catch(a){await this.sendError({id:s,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(t,i)=>{const{id:s}=i,a=It("session_ping",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{gn(i)?this.events.emit(It("session_ping",s),{}):Ti(i)&&this.events.emit(It("session_ping",s),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(a=>{this.client.core.relayer.once(zr.publish,async()=>{a(await this.deleteSession({topic:t,id:s}))})}),this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Bt("USER_DISCONNECTED")})]).catch(a=>this.client.logger.error(a))}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async t=>{var i,s,a;const{topic:f,payload:p,attestation:w,encryptedId:b,transportType:A}=t,{id:M,params:C}=p;try{await this.isValidRequest(Zt({topic:f},C));const O=this.client.session.get(f),D=await this.getVerifyContext({attestationId:w,hash:jn(JSON.stringify(ds("wc_sessionRequest",C,M))),encryptedId:b,metadata:O.peer.metadata,transportType:A}),j={id:M,topic:f,params:C,verifyContext:D};await this.setPendingSessionRequest(j),A===jt.link_mode&&(i=O.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((s=O.peer.metadata.redirect)==null?void 0:s.universal),(a=this.client.signConfig)!=null&&a.disableRequestQueue?this.emitSessionRequest(j):(this.addSessionRequestToSessionRequestQueue(j),this.processSessionRequestQueue())}catch(O){await this.sendError({id:M,topic:f,error:O}),this.client.logger.error(O)}},this.onSessionRequestResponse=(t,i)=>{const{id:s}=i,a=It("session_request",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);gn(i)?this.events.emit(It("session_request",s),{result:i.result}):Ti(i)&&this.events.emit(It("session_request",s),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:s,params:a}=i;try{const f=`${t}_session_event_${a.event.name}`,p=co.get(f);if(p&&this.isRequestOutOfSync(p,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(Zt({topic:t},a)),this.client.events.emit("session_event",{id:s,topic:t,params:a}),co.set(f,s)}catch(f){await this.sendError({id:s,topic:t,error:f}),this.client.logger.error(f)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),gn(i)?this.events.emit(It("session_request",s),{result:i.result}):Ti(i)&&this.events.emit(It("session_request",s),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:s,payload:a,attestation:f,encryptedId:p,transportType:w}=t;try{const{requester:b,authPayload:A,expiryTimestamp:M}=a.params,C=await this.getVerifyContext({attestationId:f,hash:jn(JSON.stringify(a)),encryptedId:p,metadata:b.metadata,transportType:w}),O={requester:b,pairingTopic:s,id:a.id,authPayload:A,verifyContext:C,expiryTimestamp:M};await this.setAuthRequest(a.id,{request:O,pairingTopic:s,transportType:w}),w===jt.link_mode&&(i=b.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(b.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:a.params,id:a.id,verifyContext:C})}catch(b){this.client.logger.error(b);const A=a.params.requester.publicKey,M=await this.client.core.crypto.generateKeyPair(),C=this.getAppLinkIfEnabled(a.params.requester.metadata,w),O={type:Gn,receiverPublicKey:A,senderPublicKey:M};await this.sendError({id:a.id,topic:s,error:b,encodeOpts:O,rpcOpts:br.wc_sessionAuthenticate.autoReject,appLink:C})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=ln.idle,this.processSessionRequestQueue()},me.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(a=>a.topic===t&&a.request.method==="wc_sessionRequest").forEach(a=>{const f=a.request.id,p=It("session_request",f);if(this.events.listenerCount(p)===0)throw new Error(`emitting ${p} without any listeners`);this.events.emit(It("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===ln.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=ln.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:ds("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!ti(t)){const{message:w}=pe("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(w)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:a,sessionProperties:f,relays:p}=t;if(ii(i)||await this.isValidPairingTopic(i),!$A(p)){const{message:w}=pe("MISSING_OR_INVALID",`connect() relays: ${p}`);throw new Error(w)}!ii(s)&&Ro(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!ii(a)&&Ro(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),ii(f)||this.validateSessionProps(f,"sessionProperties")},this.validateNamespaces=(t,i)=>{const s=kA(t,"connect()",i);if(s)throw new Error(s.message)},this.isValidApprove=async t=>{if(!ti(t))throw new Error(pe("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:s,relayProtocol:a,sessionProperties:f}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const p=this.client.proposal.get(i),w=Su(s,"approve()");if(w)throw new Error(w.message);const b=a1(p.requiredNamespaces,s,"approve()");if(b)throw new Error(b.message);if(!ar(a,!0)){const{message:A}=pe("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(A)}ii(f)||this.validateSessionProps(f,"sessionProperties")},this.isValidReject=async t=>{if(!ti(t)){const{message:a}=pe("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(a)}const{id:i,reason:s}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!UA(s)){const{message:a}=pe("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidSessionSettleRequest=t=>{if(!ti(t)){const{message:b}=pe("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(b)}const{relay:i,controller:s,namespaces:a,expiry:f}=t;if(!Mv(i)){const{message:b}=pe("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(b)}const p=TA(s,"onSessionSettleRequest()");if(p)throw new Error(p.message);const w=Su(a,"onSessionSettleRequest()");if(w)throw new Error(w.message);if(cs(f)){const{message:b}=pe("EXPIRED","onSessionSettleRequest()");throw new Error(b)}},this.isValidUpdate=async t=>{if(!ti(t)){const{message:w}=pe("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(w)}const{topic:i,namespaces:s}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),f=Su(s,"update()");if(f)throw new Error(f.message);const p=a1(a.requiredNamespaces,s,"update()");if(p)throw new Error(p.message)},this.isValidExtend=async t=>{if(!ti(t)){const{message:s}=pe("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(s)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!ti(t)){const{message:w}=pe("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(w)}const{topic:i,request:s,chainId:a,expiry:f}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:p}=this.client.session.get(i);if(!s1(p,a)){const{message:w}=pe("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(w)}if(!jA(s)){const{message:w}=pe("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(w)}if(!VA(p,a,s.method)){const{message:w}=pe("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(w)}if(f&&!QA(f,Cu)){const{message:w}=pe("MISSING_OR_INVALID",`request() expiry: ${f}. Expiry must be a number (in seconds) between ${Cu.min} and ${Cu.max}`);throw new Error(w)}},this.isValidRespond=async t=>{var i;if(!ti(t)){const{message:f}=pe("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(f)}const{topic:s,response:a}=t;try{await this.isValidSessionTopic(s)}catch(f){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),f}if(!KA(a)){const{message:f}=pe("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(f)}},this.isValidPing=async t=>{if(!ti(t)){const{message:s}=pe("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(s)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!ti(t)){const{message:p}=pe("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(p)}const{topic:i,event:s,chainId:a}=t;await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!s1(f,a)){const{message:p}=pe("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(p)}if(!HA(s)){const{message:p}=pe("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(p)}if(!GA(f,a,s.name)){const{message:p}=pe("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(p)}},this.isValidDisconnect=async t=>{if(!ti(t)){const{message:s}=pe("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(s)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:s,domain:a,nonce:f}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ar(s,!1))throw new Error("uri is required parameter");if(!ar(a,!1))throw new Error("domain is required parameter");if(!ar(f,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(w=>wo(w).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:p}=wo(i[0]);if(p!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:s,encryptedId:a,metadata:f,transportType:p}=t,w={verified:{verifyUrl:f.verifyUrl||Io,validation:"UNKNOWN",origin:f.url||""}};try{if(p===jt.link_mode){const A=this.getAppLinkIfEnabled(f,p);return w.verified.validation=A&&new URL(A).origin===new URL(f.url).origin?"VALID":"INVALID",w}const b=await this.client.core.verify.resolve({attestationId:i,hash:s,encryptedId:a,verifyUrl:f.verifyUrl});b&&(w.verified.origin=b.origin,w.verified.isScam=b.isScam,w.verified.validation=b.origin===new URL(f.url).origin?"VALID":"INVALID")}catch(b){this.client.logger.warn(b)}return this.client.logger.debug(`Verify context: ${JSON.stringify(w)}`),w},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(s=>{if(!ar(s,!1)){const{message:a}=pe("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(s)}`);throw new Error(a)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const a=this.recentlyDeletedLimit/2;for(const f of this.recentlyDeletedMap.keys()){if(s++>=a)break;this.recentlyDeletedMap.delete(f)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:s}=pe("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(s)}},this.isLinkModeEnabled=(t,i)=>{var s,a,f,p,w,b,A,M,C;return!t||i!==jt.link_mode?!1:((a=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:a.linkMode)===!0&&((p=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:p.universal)!==void 0&&((b=(w=this.client.metadata)==null?void 0:w.redirect)==null?void 0:b.universal)!==""&&((A=t==null?void 0:t.redirect)==null?void 0:A.universal)!==void 0&&((M=t==null?void 0:t.redirect)==null?void 0:M.universal)!==""&&((C=t==null?void 0:t.redirect)==null?void 0:C.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var s;return this.isLinkModeEnabled(t,i)?(s=t==null?void 0:t.redirect)==null?void 0:s.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=yp(t,"topic")||"",s=decodeURIComponent(yp(t,"wc_ev")||""),a=this.client.session.keys.includes(i);a&&this.client.session.update(i,{transportType:jt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:s,sessionExists:a})},this.registerLinkModeListeners=async()=>{var t;if(bd()||Ca()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const s=await i.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=pe("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(zr.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:s,transportType:a}=e,{publicKey:f}=this.client.auth.authKeys.keys.includes(ff)?this.client.auth.authKeys.get(ff):{responseTopic:void 0,publicKey:void 0},p=await this.client.core.crypto.decode(t,i,{receiverPublicKey:f,encoding:a===jt.link_mode?oo:ps});try{fd(p)?(this.client.core.history.set(t,p),this.onRelayEventRequest({topic:t,payload:p,attestation:s,transportType:a,encryptedId:jn(i)})):Tf(p)?(await this.client.core.history.resolve(p),await this.onRelayEventResponse({topic:t,payload:p,transportType:a}),this.client.core.history.delete(t,p.id)):this.onRelayEventUnknownPayload({topic:t,payload:p,transportType:a})}catch(w){this.client.logger.error(w)}}registerExpirerEvents(){this.client.core.expirer.on(Ci.expired,async e=>{const{topic:t,id:i}=Dg(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,pe("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,pe("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Fs.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Fs.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ar(e,!1)){const{message:t}=pe("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=pe("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(cs(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=pe("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!ar(e,!1)){const{message:t}=pe("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=pe("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(cs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=pe("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=pe("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(ar(e,!1)){const{message:t}=pe("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=pe("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!zA(e)){const{message:t}=pe("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=pe("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(cs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=pe("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class MS extends Js{constructor(e,t){super(e,t,fS,Rd),this.core=e,this.logger=t}}class SS extends Js{constructor(e,t){super(e,t,hS,Rd),this.core=e,this.logger=t}}class xS extends Js{constructor(e,t){super(e,t,dS,Rd,i=>i.id),this.core=e,this.logger=t}}class PS extends Js{constructor(e,t){super(e,t,vS,Kf,()=>ff),this.core=e,this.logger=t}}class RS extends Js{constructor(e,t){super(e,t,bS,Kf),this.core=e,this.logger=t}}class NS extends Js{constructor(e,t){super(e,t,mS,Kf,i=>i.id),this.core=e,this.logger=t}}class CS{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new PS(this.core,this.logger),this.pairingTopics=new RS(this.core,this.logger),this.requests=new NS(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Nd extends pE{constructor(e){super(e),this.protocol=Uv,this.version=jv,this.name=Nu.name,this.events=new Bi.EventEmitter,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(s){throw this.logger.error(s.message),s}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(s){throw this.logger.error(s.message),s}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(s){throw this.logger.error(s.message),s}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(s){throw this.logger.error(s.message),s}},this.update=async i=>{try{return await this.engine.update(i)}catch(s){throw this.logger.error(s.message),s}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(s){throw this.logger.error(s.message),s}},this.request=async i=>{try{return await this.engine.request(i)}catch(s){throw this.logger.error(s.message),s}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(s){throw this.logger.error(s.message),s}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(s){throw this.logger.error(s.message),s}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(s){throw this.logger.error(s.message),s}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(s){throw this.logger.error(s.message),s}},this.find=i=>{try{return this.engine.find(i)}catch(s){throw this.logger.error(s.message),s}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,s)=>{try{return await this.engine.authenticate(i,s)}catch(a){throw this.logger.error(a.message),a}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(s){throw this.logger.error(s.message),s}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}},this.name=(e==null?void 0:e.name)||Nu.name,this.metadata=(e==null?void 0:e.metadata)||Rg(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:No(Pf({level:(e==null?void 0:e.logger)||Nu.logger}));this.core=(e==null?void 0:e.core)||new cS(e),this.logger=Kr(t,this.name),this.session=new SS(this.core,this.logger),this.proposal=new MS(this.core,this.logger),this.pendingRequest=new xS(this.core,this.logger),this.engine=new IS(this),this.auth=new CS(this.core,this.logger)}static async init(e){const t=new Nd(e);return await t.initialize(),t}get context(){return oi(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const O1="error",OS="wss://relay.walletconnect.org",TS="wc",DS="universal_provider",T1=`${TS}@2:${DS}:`,Vv="https://rpc.walletconnect.org/v1/",va="generic",FS=`${Vv}bundler`,on={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var po=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Xu={exports:{}};/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/(function(r,e){(function(){var t,i="4.17.21",s=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",p="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",b=500,A="__lodash_placeholder__",M=1,C=2,O=4,D=1,j=2,G=1,X=2,z=4,Q=8,V=16,H=32,ee=64,oe=128,ne=256,ge=512,ht=30,L="...",v=800,c=16,d=1,g=2,_=3,S=1/0,x=9007199254740991,E=17976931348623157e292,u=NaN,l=4294967295,R=l-1,ie=l>>>1,se=[["ary",oe],["bind",G],["bindKey",X],["curry",Q],["curryRight",V],["flip",ge],["partial",H],["partialRight",ee],["rearg",ne]],I="[object Arguments]",Z="[object Array]",F="[object AsyncFunction]",k="[object Boolean]",$="[object Date]",m="[object DOMException]",B="[object Error]",re="[object Function]",he="[object GeneratorFunction]",ue="[object Map]",ve="[object Number]",be="[object Null]",Te="[object Object]",nt="[object Promise]",Se="[object Proxy]",Ve="[object RegExp]",Le="[object Set]",Ae="[object String]",Ue="[object Symbol]",Ge="[object Undefined]",ye="[object WeakMap]",je="[object WeakSet]",Fe="[object ArrayBuffer]",_e="[object DataView]",We="[object Float32Array]",ke="[object Float64Array]",Pe="[object Int8Array]",ot="[object Int16Array]",ft="[object Int32Array]",De="[object Uint8Array]",ct="[object Uint8ClampedArray]",ut="[object Uint16Array]",qe="[object Uint32Array]",wt=/\b__p \+= '';/g,dt=/\b(__p \+=) '' \+/g,$e=/(__e\(.*?\)|\b__t\)) \+\n'';/g,At=/&(?:amp|lt|gt|quot|#39);/g,Mt=/[&<>"']/g,Ee=RegExp(At.source),Ke=RegExp(Mt.source),Qe=/<%-([\s\S]+?)%>/g,Ie=/<%([\s\S]+?)%>/g,Je=/<%=([\s\S]+?)%>/g,He=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Re=/^\w*$/,st=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ye=/[\\^$.*+?()[\]{}|]/g,Ne=RegExp(Ye.source),Xe=/^\s+/,et=/\s/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ze=/\{\n\/\* \[wrapped with (.+)\] \*/,at=/,? & /,Ce=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ct=/[()=,{}\[\]\/\s]/,Ot=/\\(\\)?/g,tt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,bt=/\w*$/,xr=/^[-+]0x[0-9a-f]+$/i,Pr=/^0b[01]+$/i,Rr=/^\[object .+?Constructor\]$/,Nr=/^0o[0-7]+$/i,Cr=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Hr=/($^)/,$i=/['\n\r\u2028\u2029\\]/g,Vr="\\ud800-\\udfff",zi="\\u0300-\\u036f",Ui="\\ufe20-\\ufe2f",Gr="\\u20d0-\\u20ff",mi=zi+Ui+Gr,yi="\\u2700-\\u27bf",fr="a-z\\xdf-\\xf6\\xf8-\\xff",ji="\\xac\\xb1\\xd7\\xf7",Ki="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Hi="\\u2000-\\u206f",bs=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",zo="A-Z\\xc0-\\xd6\\xd8-\\xde",Uo="\\ufe0e\\ufe0f",ms=ji+Ki+Hi+bs,La="['’]",ys="["+Vr+"]",ka="["+ms+"]",ws="["+mi+"]",jo="\\d+",Hf="["+yi+"]",Ko="["+fr+"]",Ho="[^"+Vr+ms+jo+yi+fr+zo+"]",Ys="\\ud83c[\\udffb-\\udfff]",Vf="(?:"+ws+"|"+Ys+")",Vo="[^"+Vr+"]",Xs="(?:\\ud83c[\\udde6-\\uddff]){2}",Qn="[\\ud800-\\udbff][\\udc00-\\udfff]",ci="["+zo+"]",Go="\\u200d",Jo="(?:"+Ko+"|"+Ho+")",cn="(?:"+ci+"|"+Ho+")",Wo="(?:"+La+"(?:d|ll|m|re|s|t|ve))?",Qo="(?:"+La+"(?:D|LL|M|RE|S|T|VE))?",Yo=Vf+"?",Xo="["+Uo+"]?",Gf="(?:"+Go+"(?:"+[Vo,Xs,Qn].join("|")+")"+Xo+Yo+")*",Nn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zo="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ec=Xo+Yo+Gf,Zs="(?:"+[Hf,Xs,Qn].join("|")+")"+ec,Jf="(?:"+[Vo+ws+"?",ws,Xs,Qn,ys].join("|")+")",$a=RegExp(La,"g"),Wf=RegExp(ws,"g"),ea=RegExp(Ys+"(?="+Ys+")|"+Jf+ec,"g"),tc=RegExp([ci+"?"+Ko+"+"+Wo+"(?="+[ka,ci,"$"].join("|")+")",cn+"+"+Qo+"(?="+[ka,ci+Jo,"$"].join("|")+")",ci+"?"+Jo+"+"+Wo,ci+"+"+Qo,Zo,Nn,jo,Zs].join("|"),"g"),rc=RegExp("["+Go+Vr+mi+Uo+"]"),_s=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ic=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Qf=-1,kt={};kt[We]=kt[ke]=kt[Pe]=kt[ot]=kt[ft]=kt[De]=kt[ct]=kt[ut]=kt[qe]=!0,kt[I]=kt[Z]=kt[Fe]=kt[k]=kt[_e]=kt[$]=kt[B]=kt[re]=kt[ue]=kt[ve]=kt[Te]=kt[Ve]=kt[Le]=kt[Ae]=kt[ye]=!1;var Lt={};Lt[I]=Lt[Z]=Lt[Fe]=Lt[_e]=Lt[k]=Lt[$]=Lt[We]=Lt[ke]=Lt[Pe]=Lt[ot]=Lt[ft]=Lt[ue]=Lt[ve]=Lt[Te]=Lt[Ve]=Lt[Le]=Lt[Ae]=Lt[Ue]=Lt[De]=Lt[ct]=Lt[ut]=Lt[qe]=!0,Lt[B]=Lt[re]=Lt[ye]=!1;var q={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},J={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},de={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},xe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=parseFloat,pt=parseInt,Vt=typeof po=="object"&&po&&po.Object===Object&&po,or=typeof self=="object"&&self&&self.Object===Object&&self,Rt=Vt||or||Function("return this")(),zt=e&&!e.nodeType&&e,rr=zt&&!0&&r&&!r.nodeType&&r,Jr=rr&&rr.exports===zt,cr=Jr&&Vt.process,Gt=function(){try{var W=rr&&rr.require&&rr.require("util").types;return W||cr&&cr.binding&&cr.binding("util")}catch{}}(),qr=Gt&&Gt.isArrayBuffer,Vi=Gt&&Gt.isDate,wi=Gt&&Gt.isMap,fn=Gt&&Gt.isRegExp,za=Gt&&Gt.isSet,As=Gt&&Gt.isTypedArray;function pr(W,ae,te){switch(te.length){case 0:return W.call(ae);case 1:return W.call(ae,te[0]);case 2:return W.call(ae,te[0],te[1]);case 3:return W.call(ae,te[0],te[1],te[2])}return W.apply(ae,te)}function Wv(W,ae,te,Oe){for(var lt=-1,Tt=W==null?0:W.length;++lt<Tt;){var hr=W[lt];ae(Oe,hr,te(hr),W)}return Oe}function _i(W,ae){for(var te=-1,Oe=W==null?0:W.length;++te<Oe&&ae(W[te],te,W)!==!1;);return W}function Qv(W,ae){for(var te=W==null?0:W.length;te--&&ae(W[te],te,W)!==!1;);return W}function Td(W,ae){for(var te=-1,Oe=W==null?0:W.length;++te<Oe;)if(!ae(W[te],te,W))return!1;return!0}function Yn(W,ae){for(var te=-1,Oe=W==null?0:W.length,lt=0,Tt=[];++te<Oe;){var hr=W[te];ae(hr,te,W)&&(Tt[lt++]=hr)}return Tt}function nc(W,ae){var te=W==null?0:W.length;return!!te&&ta(W,ae,0)>-1}function Yf(W,ae,te){for(var Oe=-1,lt=W==null?0:W.length;++Oe<lt;)if(te(ae,W[Oe]))return!0;return!1}function Wt(W,ae){for(var te=-1,Oe=W==null?0:W.length,lt=Array(Oe);++te<Oe;)lt[te]=ae(W[te],te,W);return lt}function Xn(W,ae){for(var te=-1,Oe=ae.length,lt=W.length;++te<Oe;)W[lt+te]=ae[te];return W}function Xf(W,ae,te,Oe){var lt=-1,Tt=W==null?0:W.length;for(Oe&&Tt&&(te=W[++lt]);++lt<Tt;)te=ae(te,W[lt],lt,W);return te}function Yv(W,ae,te,Oe){var lt=W==null?0:W.length;for(Oe&&lt&&(te=W[--lt]);lt--;)te=ae(te,W[lt],lt,W);return te}function Zf(W,ae){for(var te=-1,Oe=W==null?0:W.length;++te<Oe;)if(ae(W[te],te,W))return!0;return!1}var Xv=eh("length");function Zv(W){return W.split("")}function eb(W){return W.match(Ce)||[]}function Dd(W,ae,te){var Oe;return te(W,function(lt,Tt,hr){if(ae(lt,Tt,hr))return Oe=Tt,!1}),Oe}function sc(W,ae,te,Oe){for(var lt=W.length,Tt=te+(Oe?1:-1);Oe?Tt--:++Tt<lt;)if(ae(W[Tt],Tt,W))return Tt;return-1}function ta(W,ae,te){return ae===ae?db(W,ae,te):sc(W,Fd,te)}function tb(W,ae,te,Oe){for(var lt=te-1,Tt=W.length;++lt<Tt;)if(Oe(W[lt],ae))return lt;return-1}function Fd(W){return W!==W}function qd(W,ae){var te=W==null?0:W.length;return te?rh(W,ae)/te:u}function eh(W){return function(ae){return ae==null?t:ae[W]}}function th(W){return function(ae){return W==null?t:W[ae]}}function Bd(W,ae,te,Oe,lt){return lt(W,function(Tt,hr,Ut){te=Oe?(Oe=!1,Tt):ae(te,Tt,hr,Ut)}),te}function rb(W,ae){var te=W.length;for(W.sort(ae);te--;)W[te]=W[te].value;return W}function rh(W,ae){for(var te,Oe=-1,lt=W.length;++Oe<lt;){var Tt=ae(W[Oe]);Tt!==t&&(te=te===t?Tt:te+Tt)}return te}function ih(W,ae){for(var te=-1,Oe=Array(W);++te<W;)Oe[te]=ae(te);return Oe}function ib(W,ae){return Wt(ae,function(te){return[te,W[te]]})}function Ld(W){return W&&W.slice(0,Ud(W)+1).replace(Xe,"")}function fi(W){return function(ae){return W(ae)}}function nh(W,ae){return Wt(ae,function(te){return W[te]})}function Ua(W,ae){return W.has(ae)}function kd(W,ae){for(var te=-1,Oe=W.length;++te<Oe&&ta(ae,W[te],0)>-1;);return te}function $d(W,ae){for(var te=W.length;te--&&ta(ae,W[te],0)>-1;);return te}function nb(W,ae){for(var te=W.length,Oe=0;te--;)W[te]===ae&&++Oe;return Oe}var sb=th(q),ab=th(J);function ob(W){return"\\"+xe[W]}function cb(W,ae){return W==null?t:W[ae]}function ra(W){return rc.test(W)}function fb(W){return _s.test(W)}function hb(W){for(var ae,te=[];!(ae=W.next()).done;)te.push(ae.value);return te}function sh(W){var ae=-1,te=Array(W.size);return W.forEach(function(Oe,lt){te[++ae]=[lt,Oe]}),te}function zd(W,ae){return function(te){return W(ae(te))}}function Zn(W,ae){for(var te=-1,Oe=W.length,lt=0,Tt=[];++te<Oe;){var hr=W[te];(hr===ae||hr===A)&&(W[te]=A,Tt[lt++]=te)}return Tt}function ac(W){var ae=-1,te=Array(W.size);return W.forEach(function(Oe){te[++ae]=Oe}),te}function ub(W){var ae=-1,te=Array(W.size);return W.forEach(function(Oe){te[++ae]=[Oe,Oe]}),te}function db(W,ae,te){for(var Oe=te-1,lt=W.length;++Oe<lt;)if(W[Oe]===ae)return Oe;return-1}function lb(W,ae,te){for(var Oe=te+1;Oe--;)if(W[Oe]===ae)return Oe;return Oe}function ia(W){return ra(W)?gb(W):Xv(W)}function Gi(W){return ra(W)?vb(W):Zv(W)}function Ud(W){for(var ae=W.length;ae--&&et.test(W.charAt(ae)););return ae}var pb=th(de);function gb(W){for(var ae=ea.lastIndex=0;ea.test(W);)++ae;return ae}function vb(W){return W.match(ea)||[]}function bb(W){return W.match(tc)||[]}var mb=function W(ae){ae=ae==null?Rt:na.defaults(Rt.Object(),ae,na.pick(Rt,ic));var te=ae.Array,Oe=ae.Date,lt=ae.Error,Tt=ae.Function,hr=ae.Math,Ut=ae.Object,ah=ae.RegExp,yb=ae.String,Ai=ae.TypeError,oc=te.prototype,wb=Tt.prototype,sa=Ut.prototype,cc=ae["__core-js_shared__"],fc=wb.toString,qt=sa.hasOwnProperty,_b=0,jd=function(){var n=/[^.]+$/.exec(cc&&cc.keys&&cc.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),hc=sa.toString,Ab=fc.call(Ut),Eb=Rt._,Ib=ah("^"+fc.call(qt).replace(Ye,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),uc=Jr?ae.Buffer:t,es=ae.Symbol,dc=ae.Uint8Array,Kd=uc?uc.allocUnsafe:t,lc=zd(Ut.getPrototypeOf,Ut),Hd=Ut.create,Vd=sa.propertyIsEnumerable,pc=oc.splice,Gd=es?es.isConcatSpreadable:t,ja=es?es.iterator:t,Es=es?es.toStringTag:t,gc=function(){try{var n=Ps(Ut,"defineProperty");return n({},"",{}),n}catch{}}(),Mb=ae.clearTimeout!==Rt.clearTimeout&&ae.clearTimeout,Sb=Oe&&Oe.now!==Rt.Date.now&&Oe.now,xb=ae.setTimeout!==Rt.setTimeout&&ae.setTimeout,vc=hr.ceil,bc=hr.floor,oh=Ut.getOwnPropertySymbols,Pb=uc?uc.isBuffer:t,Jd=ae.isFinite,Rb=oc.join,Nb=zd(Ut.keys,Ut),ur=hr.max,Or=hr.min,Cb=Oe.now,Ob=ae.parseInt,Wd=hr.random,Tb=oc.reverse,ch=Ps(ae,"DataView"),Ka=Ps(ae,"Map"),fh=Ps(ae,"Promise"),aa=Ps(ae,"Set"),Ha=Ps(ae,"WeakMap"),Va=Ps(Ut,"create"),mc=Ha&&new Ha,oa={},Db=Rs(ch),Fb=Rs(Ka),qb=Rs(fh),Bb=Rs(aa),Lb=Rs(Ha),yc=es?es.prototype:t,Ga=yc?yc.valueOf:t,Qd=yc?yc.toString:t;function N(n){if(Xt(n)&&!gt(n)&&!(n instanceof St)){if(n instanceof Ei)return n;if(qt.call(n,"__wrapped__"))return Yl(n)}return new Ei(n)}var ca=function(){function n(){}return function(o){if(!Qt(o))return{};if(Hd)return Hd(o);n.prototype=o;var h=new n;return n.prototype=t,h}}();function wc(){}function Ei(n,o){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=t}N.templateSettings={escape:Qe,evaluate:Ie,interpolate:Je,variable:"",imports:{_:N}},N.prototype=wc.prototype,N.prototype.constructor=N,Ei.prototype=ca(wc.prototype),Ei.prototype.constructor=Ei;function St(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=l,this.__views__=[]}function kb(){var n=new St(this.__wrapped__);return n.__actions__=Wr(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Wr(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Wr(this.__views__),n}function $b(){if(this.__filtered__){var n=new St(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function zb(){var n=this.__wrapped__.value(),o=this.__dir__,h=gt(n),y=o<0,P=h?n.length:0,T=Zm(0,P,this.__views__),U=T.start,K=T.end,Y=K-U,ce=y?K:U-1,fe=this.__iteratees__,le=fe.length,we=0,Be=Or(Y,this.__takeCount__);if(!h||!y&&P==Y&&Be==Y)return wl(n,this.__actions__);var rt=[];e:for(;Y--&&we<Be;){ce+=o;for(var yt=-1,it=n[ce];++yt<le;){var Et=fe[yt],Nt=Et.iteratee,di=Et.type,kr=Nt(it);if(di==g)it=kr;else if(!kr){if(di==d)continue e;break e}}rt[we++]=it}return rt}St.prototype=ca(wc.prototype),St.prototype.constructor=St;function Is(n){var o=-1,h=n==null?0:n.length;for(this.clear();++o<h;){var y=n[o];this.set(y[0],y[1])}}function Ub(){this.__data__=Va?Va(null):{},this.size=0}function jb(n){var o=this.has(n)&&delete this.__data__[n];return this.size-=o?1:0,o}function Kb(n){var o=this.__data__;if(Va){var h=o[n];return h===w?t:h}return qt.call(o,n)?o[n]:t}function Hb(n){var o=this.__data__;return Va?o[n]!==t:qt.call(o,n)}function Vb(n,o){var h=this.__data__;return this.size+=this.has(n)?0:1,h[n]=Va&&o===t?w:o,this}Is.prototype.clear=Ub,Is.prototype.delete=jb,Is.prototype.get=Kb,Is.prototype.has=Hb,Is.prototype.set=Vb;function Cn(n){var o=-1,h=n==null?0:n.length;for(this.clear();++o<h;){var y=n[o];this.set(y[0],y[1])}}function Gb(){this.__data__=[],this.size=0}function Jb(n){var o=this.__data__,h=_c(o,n);if(h<0)return!1;var y=o.length-1;return h==y?o.pop():pc.call(o,h,1),--this.size,!0}function Wb(n){var o=this.__data__,h=_c(o,n);return h<0?t:o[h][1]}function Qb(n){return _c(this.__data__,n)>-1}function Yb(n,o){var h=this.__data__,y=_c(h,n);return y<0?(++this.size,h.push([n,o])):h[y][1]=o,this}Cn.prototype.clear=Gb,Cn.prototype.delete=Jb,Cn.prototype.get=Wb,Cn.prototype.has=Qb,Cn.prototype.set=Yb;function On(n){var o=-1,h=n==null?0:n.length;for(this.clear();++o<h;){var y=n[o];this.set(y[0],y[1])}}function Xb(){this.size=0,this.__data__={hash:new Is,map:new(Ka||Cn),string:new Is}}function Zb(n){var o=Tc(this,n).delete(n);return this.size-=o?1:0,o}function em(n){return Tc(this,n).get(n)}function tm(n){return Tc(this,n).has(n)}function rm(n,o){var h=Tc(this,n),y=h.size;return h.set(n,o),this.size+=h.size==y?0:1,this}On.prototype.clear=Xb,On.prototype.delete=Zb,On.prototype.get=em,On.prototype.has=tm,On.prototype.set=rm;function Ms(n){var o=-1,h=n==null?0:n.length;for(this.__data__=new On;++o<h;)this.add(n[o])}function im(n){return this.__data__.set(n,w),this}function nm(n){return this.__data__.has(n)}Ms.prototype.add=Ms.prototype.push=im,Ms.prototype.has=nm;function Ji(n){var o=this.__data__=new Cn(n);this.size=o.size}function sm(){this.__data__=new Cn,this.size=0}function am(n){var o=this.__data__,h=o.delete(n);return this.size=o.size,h}function om(n){return this.__data__.get(n)}function cm(n){return this.__data__.has(n)}function fm(n,o){var h=this.__data__;if(h instanceof Cn){var y=h.__data__;if(!Ka||y.length<s-1)return y.push([n,o]),this.size=++h.size,this;h=this.__data__=new On(y)}return h.set(n,o),this.size=h.size,this}Ji.prototype.clear=sm,Ji.prototype.delete=am,Ji.prototype.get=om,Ji.prototype.has=cm,Ji.prototype.set=fm;function Yd(n,o){var h=gt(n),y=!h&&Ns(n),P=!h&&!y&&ss(n),T=!h&&!y&&!P&&da(n),U=h||y||P||T,K=U?ih(n.length,yb):[],Y=K.length;for(var ce in n)(o||qt.call(n,ce))&&!(U&&(ce=="length"||P&&(ce=="offset"||ce=="parent")||T&&(ce=="buffer"||ce=="byteLength"||ce=="byteOffset")||qn(ce,Y)))&&K.push(ce);return K}function Xd(n){var o=n.length;return o?n[wh(0,o-1)]:t}function hm(n,o){return Dc(Wr(n),Ss(o,0,n.length))}function um(n){return Dc(Wr(n))}function hh(n,o,h){(h!==t&&!Wi(n[o],h)||h===t&&!(o in n))&&Tn(n,o,h)}function Ja(n,o,h){var y=n[o];(!(qt.call(n,o)&&Wi(y,h))||h===t&&!(o in n))&&Tn(n,o,h)}function _c(n,o){for(var h=n.length;h--;)if(Wi(n[h][0],o))return h;return-1}function dm(n,o,h,y){return ts(n,function(P,T,U){o(y,P,h(P),U)}),y}function Zd(n,o){return n&&un(o,gr(o),n)}function lm(n,o){return n&&un(o,Yr(o),n)}function Tn(n,o,h){o=="__proto__"&&gc?gc(n,o,{configurable:!0,enumerable:!0,value:h,writable:!0}):n[o]=h}function uh(n,o){for(var h=-1,y=o.length,P=te(y),T=n==null;++h<y;)P[h]=T?t:Hh(n,o[h]);return P}function Ss(n,o,h){return n===n&&(h!==t&&(n=n<=h?n:h),o!==t&&(n=n>=o?n:o)),n}function Ii(n,o,h,y,P,T){var U,K=o&M,Y=o&C,ce=o&O;if(h&&(U=P?h(n,y,P,T):h(n)),U!==t)return U;if(!Qt(n))return n;var fe=gt(n);if(fe){if(U=t2(n),!K)return Wr(n,U)}else{var le=Tr(n),we=le==re||le==he;if(ss(n))return El(n,K);if(le==Te||le==I||we&&!P){if(U=Y||we?{}:Ul(n),!K)return Y?Km(n,lm(U,n)):jm(n,Zd(U,n))}else{if(!Lt[le])return P?n:{};U=r2(n,le,K)}}T||(T=new Ji);var Be=T.get(n);if(Be)return Be;T.set(n,U),b0(n)?n.forEach(function(it){U.add(Ii(it,o,h,it,n,T))}):g0(n)&&n.forEach(function(it,Et){U.set(Et,Ii(it,o,h,Et,n,T))});var rt=ce?Y?Ch:Nh:Y?Yr:gr,yt=fe?t:rt(n);return _i(yt||n,function(it,Et){yt&&(Et=it,it=n[Et]),Ja(U,Et,Ii(it,o,h,Et,n,T))}),U}function pm(n){var o=gr(n);return function(h){return el(h,n,o)}}function el(n,o,h){var y=h.length;if(n==null)return!y;for(n=Ut(n);y--;){var P=h[y],T=o[P],U=n[P];if(U===t&&!(P in n)||!T(U))return!1}return!0}function tl(n,o,h){if(typeof n!="function")throw new Ai(f);return to(function(){n.apply(t,h)},o)}function Wa(n,o,h,y){var P=-1,T=nc,U=!0,K=n.length,Y=[],ce=o.length;if(!K)return Y;h&&(o=Wt(o,fi(h))),y?(T=Yf,U=!1):o.length>=s&&(T=Ua,U=!1,o=new Ms(o));e:for(;++P<K;){var fe=n[P],le=h==null?fe:h(fe);if(fe=y||fe!==0?fe:0,U&&le===le){for(var we=ce;we--;)if(o[we]===le)continue e;Y.push(fe)}else T(o,le,y)||Y.push(fe)}return Y}var ts=Pl(hn),rl=Pl(lh,!0);function gm(n,o){var h=!0;return ts(n,function(y,P,T){return h=!!o(y,P,T),h}),h}function Ac(n,o,h){for(var y=-1,P=n.length;++y<P;){var T=n[y],U=o(T);if(U!=null&&(K===t?U===U&&!ui(U):h(U,K)))var K=U,Y=T}return Y}function vm(n,o,h,y){var P=n.length;for(h=mt(h),h<0&&(h=-h>P?0:P+h),y=y===t||y>P?P:mt(y),y<0&&(y+=P),y=h>y?0:y0(y);h<y;)n[h++]=o;return n}function il(n,o){var h=[];return ts(n,function(y,P,T){o(y,P,T)&&h.push(y)}),h}function Ar(n,o,h,y,P){var T=-1,U=n.length;for(h||(h=n2),P||(P=[]);++T<U;){var K=n[T];o>0&&h(K)?o>1?Ar(K,o-1,h,y,P):Xn(P,K):y||(P[P.length]=K)}return P}var dh=Rl(),nl=Rl(!0);function hn(n,o){return n&&dh(n,o,gr)}function lh(n,o){return n&&nl(n,o,gr)}function Ec(n,o){return Yn(o,function(h){return Bn(n[h])})}function xs(n,o){o=is(o,n);for(var h=0,y=o.length;n!=null&&h<y;)n=n[dn(o[h++])];return h&&h==y?n:t}function sl(n,o,h){var y=o(n);return gt(n)?y:Xn(y,h(n))}function Br(n){return n==null?n===t?Ge:be:Es&&Es in Ut(n)?Xm(n):u2(n)}function ph(n,o){return n>o}function bm(n,o){return n!=null&&qt.call(n,o)}function mm(n,o){return n!=null&&o in Ut(n)}function ym(n,o,h){return n>=Or(o,h)&&n<ur(o,h)}function gh(n,o,h){for(var y=h?Yf:nc,P=n[0].length,T=n.length,U=T,K=te(T),Y=1/0,ce=[];U--;){var fe=n[U];U&&o&&(fe=Wt(fe,fi(o))),Y=Or(fe.length,Y),K[U]=!h&&(o||P>=120&&fe.length>=120)?new Ms(U&&fe):t}fe=n[0];var le=-1,we=K[0];e:for(;++le<P&&ce.length<Y;){var Be=fe[le],rt=o?o(Be):Be;if(Be=h||Be!==0?Be:0,!(we?Ua(we,rt):y(ce,rt,h))){for(U=T;--U;){var yt=K[U];if(!(yt?Ua(yt,rt):y(n[U],rt,h)))continue e}we&&we.push(rt),ce.push(Be)}}return ce}function wm(n,o,h,y){return hn(n,function(P,T,U){o(y,h(P),T,U)}),y}function Qa(n,o,h){o=is(o,n),n=Vl(n,o);var y=n==null?n:n[dn(Si(o))];return y==null?t:pr(y,n,h)}function al(n){return Xt(n)&&Br(n)==I}function _m(n){return Xt(n)&&Br(n)==Fe}function Am(n){return Xt(n)&&Br(n)==$}function Ya(n,o,h,y,P){return n===o?!0:n==null||o==null||!Xt(n)&&!Xt(o)?n!==n&&o!==o:Em(n,o,h,y,Ya,P)}function Em(n,o,h,y,P,T){var U=gt(n),K=gt(o),Y=U?Z:Tr(n),ce=K?Z:Tr(o);Y=Y==I?Te:Y,ce=ce==I?Te:ce;var fe=Y==Te,le=ce==Te,we=Y==ce;if(we&&ss(n)){if(!ss(o))return!1;U=!0,fe=!1}if(we&&!fe)return T||(T=new Ji),U||da(n)?kl(n,o,h,y,P,T):Qm(n,o,Y,h,y,P,T);if(!(h&D)){var Be=fe&&qt.call(n,"__wrapped__"),rt=le&&qt.call(o,"__wrapped__");if(Be||rt){var yt=Be?n.value():n,it=rt?o.value():o;return T||(T=new Ji),P(yt,it,h,y,T)}}return we?(T||(T=new Ji),Ym(n,o,h,y,P,T)):!1}function Im(n){return Xt(n)&&Tr(n)==ue}function vh(n,o,h,y){var P=h.length,T=P,U=!y;if(n==null)return!T;for(n=Ut(n);P--;){var K=h[P];if(U&&K[2]?K[1]!==n[K[0]]:!(K[0]in n))return!1}for(;++P<T;){K=h[P];var Y=K[0],ce=n[Y],fe=K[1];if(U&&K[2]){if(ce===t&&!(Y in n))return!1}else{var le=new Ji;if(y)var we=y(ce,fe,Y,n,o,le);if(!(we===t?Ya(fe,ce,D|j,y,le):we))return!1}}return!0}function ol(n){if(!Qt(n)||a2(n))return!1;var o=Bn(n)?Ib:Rr;return o.test(Rs(n))}function Mm(n){return Xt(n)&&Br(n)==Ve}function Sm(n){return Xt(n)&&Tr(n)==Le}function xm(n){return Xt(n)&&$c(n.length)&&!!kt[Br(n)]}function cl(n){return typeof n=="function"?n:n==null?Xr:typeof n=="object"?gt(n)?ul(n[0],n[1]):hl(n):N0(n)}function bh(n){if(!eo(n))return Nb(n);var o=[];for(var h in Ut(n))qt.call(n,h)&&h!="constructor"&&o.push(h);return o}function Pm(n){if(!Qt(n))return h2(n);var o=eo(n),h=[];for(var y in n)y=="constructor"&&(o||!qt.call(n,y))||h.push(y);return h}function mh(n,o){return n<o}function fl(n,o){var h=-1,y=Qr(n)?te(n.length):[];return ts(n,function(P,T,U){y[++h]=o(P,T,U)}),y}function hl(n){var o=Th(n);return o.length==1&&o[0][2]?Kl(o[0][0],o[0][1]):function(h){return h===n||vh(h,n,o)}}function ul(n,o){return Fh(n)&&jl(o)?Kl(dn(n),o):function(h){var y=Hh(h,n);return y===t&&y===o?Vh(h,n):Ya(o,y,D|j)}}function Ic(n,o,h,y,P){n!==o&&dh(o,function(T,U){if(P||(P=new Ji),Qt(T))Rm(n,o,U,h,Ic,y,P);else{var K=y?y(Bh(n,U),T,U+"",n,o,P):t;K===t&&(K=T),hh(n,U,K)}},Yr)}function Rm(n,o,h,y,P,T,U){var K=Bh(n,h),Y=Bh(o,h),ce=U.get(Y);if(ce){hh(n,h,ce);return}var fe=T?T(K,Y,h+"",n,o,U):t,le=fe===t;if(le){var we=gt(Y),Be=!we&&ss(Y),rt=!we&&!Be&&da(Y);fe=Y,we||Be||rt?gt(K)?fe=K:ir(K)?fe=Wr(K):Be?(le=!1,fe=El(Y,!0)):rt?(le=!1,fe=Il(Y,!0)):fe=[]:ro(Y)||Ns(Y)?(fe=K,Ns(K)?fe=w0(K):(!Qt(K)||Bn(K))&&(fe=Ul(Y))):le=!1}le&&(U.set(Y,fe),P(fe,Y,y,T,U),U.delete(Y)),hh(n,h,fe)}function dl(n,o){var h=n.length;if(h)return o+=o<0?h:0,qn(o,h)?n[o]:t}function ll(n,o,h){o.length?o=Wt(o,function(T){return gt(T)?function(U){return xs(U,T.length===1?T[0]:T)}:T}):o=[Xr];var y=-1;o=Wt(o,fi(Ze()));var P=fl(n,function(T,U,K){var Y=Wt(o,function(ce){return ce(T)});return{criteria:Y,index:++y,value:T}});return rb(P,function(T,U){return Um(T,U,h)})}function Nm(n,o){return pl(n,o,function(h,y){return Vh(n,y)})}function pl(n,o,h){for(var y=-1,P=o.length,T={};++y<P;){var U=o[y],K=xs(n,U);h(K,U)&&Xa(T,is(U,n),K)}return T}function Cm(n){return function(o){return xs(o,n)}}function yh(n,o,h,y){var P=y?tb:ta,T=-1,U=o.length,K=n;for(n===o&&(o=Wr(o)),h&&(K=Wt(n,fi(h)));++T<U;)for(var Y=0,ce=o[T],fe=h?h(ce):ce;(Y=P(K,fe,Y,y))>-1;)K!==n&&pc.call(K,Y,1),pc.call(n,Y,1);return n}function gl(n,o){for(var h=n?o.length:0,y=h-1;h--;){var P=o[h];if(h==y||P!==T){var T=P;qn(P)?pc.call(n,P,1):Eh(n,P)}}return n}function wh(n,o){return n+bc(Wd()*(o-n+1))}function Om(n,o,h,y){for(var P=-1,T=ur(vc((o-n)/(h||1)),0),U=te(T);T--;)U[y?T:++P]=n,n+=h;return U}function _h(n,o){var h="";if(!n||o<1||o>x)return h;do o%2&&(h+=n),o=bc(o/2),o&&(n+=n);while(o);return h}function _t(n,o){return Lh(Hl(n,o,Xr),n+"")}function Tm(n){return Xd(la(n))}function Dm(n,o){var h=la(n);return Dc(h,Ss(o,0,h.length))}function Xa(n,o,h,y){if(!Qt(n))return n;o=is(o,n);for(var P=-1,T=o.length,U=T-1,K=n;K!=null&&++P<T;){var Y=dn(o[P]),ce=h;if(Y==="__proto__"||Y==="constructor"||Y==="prototype")return n;if(P!=U){var fe=K[Y];ce=y?y(fe,Y,K):t,ce===t&&(ce=Qt(fe)?fe:qn(o[P+1])?[]:{})}Ja(K,Y,ce),K=K[Y]}return n}var vl=mc?function(n,o){return mc.set(n,o),n}:Xr,Fm=gc?function(n,o){return gc(n,"toString",{configurable:!0,enumerable:!1,value:Jh(o),writable:!0})}:Xr;function qm(n){return Dc(la(n))}function Mi(n,o,h){var y=-1,P=n.length;o<0&&(o=-o>P?0:P+o),h=h>P?P:h,h<0&&(h+=P),P=o>h?0:h-o>>>0,o>>>=0;for(var T=te(P);++y<P;)T[y]=n[y+o];return T}function Bm(n,o){var h;return ts(n,function(y,P,T){return h=o(y,P,T),!h}),!!h}function Mc(n,o,h){var y=0,P=n==null?y:n.length;if(typeof o=="number"&&o===o&&P<=ie){for(;y<P;){var T=y+P>>>1,U=n[T];U!==null&&!ui(U)&&(h?U<=o:U<o)?y=T+1:P=T}return P}return Ah(n,o,Xr,h)}function Ah(n,o,h,y){var P=0,T=n==null?0:n.length;if(T===0)return 0;o=h(o);for(var U=o!==o,K=o===null,Y=ui(o),ce=o===t;P<T;){var fe=bc((P+T)/2),le=h(n[fe]),we=le!==t,Be=le===null,rt=le===le,yt=ui(le);if(U)var it=y||rt;else ce?it=rt&&(y||we):K?it=rt&&we&&(y||!Be):Y?it=rt&&we&&!Be&&(y||!yt):Be||yt?it=!1:it=y?le<=o:le<o;it?P=fe+1:T=fe}return Or(T,R)}function bl(n,o){for(var h=-1,y=n.length,P=0,T=[];++h<y;){var U=n[h],K=o?o(U):U;if(!h||!Wi(K,Y)){var Y=K;T[P++]=U===0?0:U}}return T}function ml(n){return typeof n=="number"?n:ui(n)?u:+n}function hi(n){if(typeof n=="string")return n;if(gt(n))return Wt(n,hi)+"";if(ui(n))return Qd?Qd.call(n):"";var o=n+"";return o=="0"&&1/n==-S?"-0":o}function rs(n,o,h){var y=-1,P=nc,T=n.length,U=!0,K=[],Y=K;if(h)U=!1,P=Yf;else if(T>=s){var ce=o?null:Jm(n);if(ce)return ac(ce);U=!1,P=Ua,Y=new Ms}else Y=o?[]:K;e:for(;++y<T;){var fe=n[y],le=o?o(fe):fe;if(fe=h||fe!==0?fe:0,U&&le===le){for(var we=Y.length;we--;)if(Y[we]===le)continue e;o&&Y.push(le),K.push(fe)}else P(Y,le,h)||(Y!==K&&Y.push(le),K.push(fe))}return K}function Eh(n,o){return o=is(o,n),n=Vl(n,o),n==null||delete n[dn(Si(o))]}function yl(n,o,h,y){return Xa(n,o,h(xs(n,o)),y)}function Sc(n,o,h,y){for(var P=n.length,T=y?P:-1;(y?T--:++T<P)&&o(n[T],T,n););return h?Mi(n,y?0:T,y?T+1:P):Mi(n,y?T+1:0,y?P:T)}function wl(n,o){var h=n;return h instanceof St&&(h=h.value()),Xf(o,function(y,P){return P.func.apply(P.thisArg,Xn([y],P.args))},h)}function Ih(n,o,h){var y=n.length;if(y<2)return y?rs(n[0]):[];for(var P=-1,T=te(y);++P<y;)for(var U=n[P],K=-1;++K<y;)K!=P&&(T[P]=Wa(T[P]||U,n[K],o,h));return rs(Ar(T,1),o,h)}function _l(n,o,h){for(var y=-1,P=n.length,T=o.length,U={};++y<P;){var K=y<T?o[y]:t;h(U,n[y],K)}return U}function Mh(n){return ir(n)?n:[]}function Sh(n){return typeof n=="function"?n:Xr}function is(n,o){return gt(n)?n:Fh(n,o)?[n]:Ql(Dt(n))}var Lm=_t;function ns(n,o,h){var y=n.length;return h=h===t?y:h,!o&&h>=y?n:Mi(n,o,h)}var Al=Mb||function(n){return Rt.clearTimeout(n)};function El(n,o){if(o)return n.slice();var h=n.length,y=Kd?Kd(h):new n.constructor(h);return n.copy(y),y}function xh(n){var o=new n.constructor(n.byteLength);return new dc(o).set(new dc(n)),o}function km(n,o){var h=o?xh(n.buffer):n.buffer;return new n.constructor(h,n.byteOffset,n.byteLength)}function $m(n){var o=new n.constructor(n.source,bt.exec(n));return o.lastIndex=n.lastIndex,o}function zm(n){return Ga?Ut(Ga.call(n)):{}}function Il(n,o){var h=o?xh(n.buffer):n.buffer;return new n.constructor(h,n.byteOffset,n.length)}function Ml(n,o){if(n!==o){var h=n!==t,y=n===null,P=n===n,T=ui(n),U=o!==t,K=o===null,Y=o===o,ce=ui(o);if(!K&&!ce&&!T&&n>o||T&&U&&Y&&!K&&!ce||y&&U&&Y||!h&&Y||!P)return 1;if(!y&&!T&&!ce&&n<o||ce&&h&&P&&!y&&!T||K&&h&&P||!U&&P||!Y)return-1}return 0}function Um(n,o,h){for(var y=-1,P=n.criteria,T=o.criteria,U=P.length,K=h.length;++y<U;){var Y=Ml(P[y],T[y]);if(Y){if(y>=K)return Y;var ce=h[y];return Y*(ce=="desc"?-1:1)}}return n.index-o.index}function Sl(n,o,h,y){for(var P=-1,T=n.length,U=h.length,K=-1,Y=o.length,ce=ur(T-U,0),fe=te(Y+ce),le=!y;++K<Y;)fe[K]=o[K];for(;++P<U;)(le||P<T)&&(fe[h[P]]=n[P]);for(;ce--;)fe[K++]=n[P++];return fe}function xl(n,o,h,y){for(var P=-1,T=n.length,U=-1,K=h.length,Y=-1,ce=o.length,fe=ur(T-K,0),le=te(fe+ce),we=!y;++P<fe;)le[P]=n[P];for(var Be=P;++Y<ce;)le[Be+Y]=o[Y];for(;++U<K;)(we||P<T)&&(le[Be+h[U]]=n[P++]);return le}function Wr(n,o){var h=-1,y=n.length;for(o||(o=te(y));++h<y;)o[h]=n[h];return o}function un(n,o,h,y){var P=!h;h||(h={});for(var T=-1,U=o.length;++T<U;){var K=o[T],Y=y?y(h[K],n[K],K,h,n):t;Y===t&&(Y=n[K]),P?Tn(h,K,Y):Ja(h,K,Y)}return h}function jm(n,o){return un(n,Dh(n),o)}function Km(n,o){return un(n,$l(n),o)}function xc(n,o){return function(h,y){var P=gt(h)?Wv:dm,T=o?o():{};return P(h,n,Ze(y,2),T)}}function fa(n){return _t(function(o,h){var y=-1,P=h.length,T=P>1?h[P-1]:t,U=P>2?h[2]:t;for(T=n.length>3&&typeof T=="function"?(P--,T):t,U&&Lr(h[0],h[1],U)&&(T=P<3?t:T,P=1),o=Ut(o);++y<P;){var K=h[y];K&&n(o,K,y,T)}return o})}function Pl(n,o){return function(h,y){if(h==null)return h;if(!Qr(h))return n(h,y);for(var P=h.length,T=o?P:-1,U=Ut(h);(o?T--:++T<P)&&y(U[T],T,U)!==!1;);return h}}function Rl(n){return function(o,h,y){for(var P=-1,T=Ut(o),U=y(o),K=U.length;K--;){var Y=U[n?K:++P];if(h(T[Y],Y,T)===!1)break}return o}}function Hm(n,o,h){var y=o&G,P=Za(n);function T(){var U=this&&this!==Rt&&this instanceof T?P:n;return U.apply(y?h:this,arguments)}return T}function Nl(n){return function(o){o=Dt(o);var h=ra(o)?Gi(o):t,y=h?h[0]:o.charAt(0),P=h?ns(h,1).join(""):o.slice(1);return y[n]()+P}}function ha(n){return function(o){return Xf(P0(x0(o).replace($a,"")),n,"")}}function Za(n){return function(){var o=arguments;switch(o.length){case 0:return new n;case 1:return new n(o[0]);case 2:return new n(o[0],o[1]);case 3:return new n(o[0],o[1],o[2]);case 4:return new n(o[0],o[1],o[2],o[3]);case 5:return new n(o[0],o[1],o[2],o[3],o[4]);case 6:return new n(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new n(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var h=ca(n.prototype),y=n.apply(h,o);return Qt(y)?y:h}}function Vm(n,o,h){var y=Za(n);function P(){for(var T=arguments.length,U=te(T),K=T,Y=ua(P);K--;)U[K]=arguments[K];var ce=T<3&&U[0]!==Y&&U[T-1]!==Y?[]:Zn(U,Y);if(T-=ce.length,T<h)return Fl(n,o,Pc,P.placeholder,t,U,ce,t,t,h-T);var fe=this&&this!==Rt&&this instanceof P?y:n;return pr(fe,this,U)}return P}function Cl(n){return function(o,h,y){var P=Ut(o);if(!Qr(o)){var T=Ze(h,3);o=gr(o),h=function(K){return T(P[K],K,P)}}var U=n(o,h,y);return U>-1?P[T?o[U]:U]:t}}function Ol(n){return Fn(function(o){var h=o.length,y=h,P=Ei.prototype.thru;for(n&&o.reverse();y--;){var T=o[y];if(typeof T!="function")throw new Ai(f);if(P&&!U&&Oc(T)=="wrapper")var U=new Ei([],!0)}for(y=U?y:h;++y<h;){T=o[y];var K=Oc(T),Y=K=="wrapper"?Oh(T):t;Y&&qh(Y[0])&&Y[1]==(oe|Q|H|ne)&&!Y[4].length&&Y[9]==1?U=U[Oc(Y[0])].apply(U,Y[3]):U=T.length==1&&qh(T)?U[K]():U.thru(T)}return function(){var ce=arguments,fe=ce[0];if(U&&ce.length==1&&gt(fe))return U.plant(fe).value();for(var le=0,we=h?o[le].apply(this,ce):fe;++le<h;)we=o[le].call(this,we);return we}})}function Pc(n,o,h,y,P,T,U,K,Y,ce){var fe=o&oe,le=o&G,we=o&X,Be=o&(Q|V),rt=o&ge,yt=we?t:Za(n);function it(){for(var Et=arguments.length,Nt=te(Et),di=Et;di--;)Nt[di]=arguments[di];if(Be)var kr=ua(it),li=nb(Nt,kr);if(y&&(Nt=Sl(Nt,y,P,Be)),T&&(Nt=xl(Nt,T,U,Be)),Et-=li,Be&&Et<ce){var nr=Zn(Nt,kr);return Fl(n,o,Pc,it.placeholder,h,Nt,nr,K,Y,ce-Et)}var Qi=le?h:this,kn=we?Qi[n]:n;return Et=Nt.length,K?Nt=d2(Nt,K):rt&&Et>1&&Nt.reverse(),fe&&Y<Et&&(Nt.length=Y),this&&this!==Rt&&this instanceof it&&(kn=yt||Za(kn)),kn.apply(Qi,Nt)}return it}function Tl(n,o){return function(h,y){return wm(h,n,o(y),{})}}function Rc(n,o){return function(h,y){var P;if(h===t&&y===t)return o;if(h!==t&&(P=h),y!==t){if(P===t)return y;typeof h=="string"||typeof y=="string"?(h=hi(h),y=hi(y)):(h=ml(h),y=ml(y)),P=n(h,y)}return P}}function Ph(n){return Fn(function(o){return o=Wt(o,fi(Ze())),_t(function(h){var y=this;return n(o,function(P){return pr(P,y,h)})})})}function Nc(n,o){o=o===t?" ":hi(o);var h=o.length;if(h<2)return h?_h(o,n):o;var y=_h(o,vc(n/ia(o)));return ra(o)?ns(Gi(y),0,n).join(""):y.slice(0,n)}function Gm(n,o,h,y){var P=o&G,T=Za(n);function U(){for(var K=-1,Y=arguments.length,ce=-1,fe=y.length,le=te(fe+Y),we=this&&this!==Rt&&this instanceof U?T:n;++ce<fe;)le[ce]=y[ce];for(;Y--;)le[ce++]=arguments[++K];return pr(we,P?h:this,le)}return U}function Dl(n){return function(o,h,y){return y&&typeof y!="number"&&Lr(o,h,y)&&(h=y=t),o=Ln(o),h===t?(h=o,o=0):h=Ln(h),y=y===t?o<h?1:-1:Ln(y),Om(o,h,y,n)}}function Cc(n){return function(o,h){return typeof o=="string"&&typeof h=="string"||(o=xi(o),h=xi(h)),n(o,h)}}function Fl(n,o,h,y,P,T,U,K,Y,ce){var fe=o&Q,le=fe?U:t,we=fe?t:U,Be=fe?T:t,rt=fe?t:T;o|=fe?H:ee,o&=~(fe?ee:H),o&z||(o&=~(G|X));var yt=[n,o,P,Be,le,rt,we,K,Y,ce],it=h.apply(t,yt);return qh(n)&&Gl(it,yt),it.placeholder=y,Jl(it,n,o)}function Rh(n){var o=hr[n];return function(h,y){if(h=xi(h),y=y==null?0:Or(mt(y),292),y&&Jd(h)){var P=(Dt(h)+"e").split("e"),T=o(P[0]+"e"+(+P[1]+y));return P=(Dt(T)+"e").split("e"),+(P[0]+"e"+(+P[1]-y))}return o(h)}}var Jm=aa&&1/ac(new aa([,-0]))[1]==S?function(n){return new aa(n)}:Yh;function ql(n){return function(o){var h=Tr(o);return h==ue?sh(o):h==Le?ub(o):ib(o,n(o))}}function Dn(n,o,h,y,P,T,U,K){var Y=o&X;if(!Y&&typeof n!="function")throw new Ai(f);var ce=y?y.length:0;if(ce||(o&=~(H|ee),y=P=t),U=U===t?U:ur(mt(U),0),K=K===t?K:mt(K),ce-=P?P.length:0,o&ee){var fe=y,le=P;y=P=t}var we=Y?t:Oh(n),Be=[n,o,h,y,P,fe,le,T,U,K];if(we&&f2(Be,we),n=Be[0],o=Be[1],h=Be[2],y=Be[3],P=Be[4],K=Be[9]=Be[9]===t?Y?0:n.length:ur(Be[9]-ce,0),!K&&o&(Q|V)&&(o&=~(Q|V)),!o||o==G)var rt=Hm(n,o,h);else o==Q||o==V?rt=Vm(n,o,K):(o==H||o==(G|H))&&!P.length?rt=Gm(n,o,h,y):rt=Pc.apply(t,Be);var yt=we?vl:Gl;return Jl(yt(rt,Be),n,o)}function Bl(n,o,h,y){return n===t||Wi(n,sa[h])&&!qt.call(y,h)?o:n}function Ll(n,o,h,y,P,T){return Qt(n)&&Qt(o)&&(T.set(o,n),Ic(n,o,t,Ll,T),T.delete(o)),n}function Wm(n){return ro(n)?t:n}function kl(n,o,h,y,P,T){var U=h&D,K=n.length,Y=o.length;if(K!=Y&&!(U&&Y>K))return!1;var ce=T.get(n),fe=T.get(o);if(ce&&fe)return ce==o&&fe==n;var le=-1,we=!0,Be=h&j?new Ms:t;for(T.set(n,o),T.set(o,n);++le<K;){var rt=n[le],yt=o[le];if(y)var it=U?y(yt,rt,le,o,n,T):y(rt,yt,le,n,o,T);if(it!==t){if(it)continue;we=!1;break}if(Be){if(!Zf(o,function(Et,Nt){if(!Ua(Be,Nt)&&(rt===Et||P(rt,Et,h,y,T)))return Be.push(Nt)})){we=!1;break}}else if(!(rt===yt||P(rt,yt,h,y,T))){we=!1;break}}return T.delete(n),T.delete(o),we}function Qm(n,o,h,y,P,T,U){switch(h){case _e:if(n.byteLength!=o.byteLength||n.byteOffset!=o.byteOffset)return!1;n=n.buffer,o=o.buffer;case Fe:return!(n.byteLength!=o.byteLength||!T(new dc(n),new dc(o)));case k:case $:case ve:return Wi(+n,+o);case B:return n.name==o.name&&n.message==o.message;case Ve:case Ae:return n==o+"";case ue:var K=sh;case Le:var Y=y&D;if(K||(K=ac),n.size!=o.size&&!Y)return!1;var ce=U.get(n);if(ce)return ce==o;y|=j,U.set(n,o);var fe=kl(K(n),K(o),y,P,T,U);return U.delete(n),fe;case Ue:if(Ga)return Ga.call(n)==Ga.call(o)}return!1}function Ym(n,o,h,y,P,T){var U=h&D,K=Nh(n),Y=K.length,ce=Nh(o),fe=ce.length;if(Y!=fe&&!U)return!1;for(var le=Y;le--;){var we=K[le];if(!(U?we in o:qt.call(o,we)))return!1}var Be=T.get(n),rt=T.get(o);if(Be&&rt)return Be==o&&rt==n;var yt=!0;T.set(n,o),T.set(o,n);for(var it=U;++le<Y;){we=K[le];var Et=n[we],Nt=o[we];if(y)var di=U?y(Nt,Et,we,o,n,T):y(Et,Nt,we,n,o,T);if(!(di===t?Et===Nt||P(Et,Nt,h,y,T):di)){yt=!1;break}it||(it=we=="constructor")}if(yt&&!it){var kr=n.constructor,li=o.constructor;kr!=li&&"constructor"in n&&"constructor"in o&&!(typeof kr=="function"&&kr instanceof kr&&typeof li=="function"&&li instanceof li)&&(yt=!1)}return T.delete(n),T.delete(o),yt}function Fn(n){return Lh(Hl(n,t,e0),n+"")}function Nh(n){return sl(n,gr,Dh)}function Ch(n){return sl(n,Yr,$l)}var Oh=mc?function(n){return mc.get(n)}:Yh;function Oc(n){for(var o=n.name+"",h=oa[o],y=qt.call(oa,o)?h.length:0;y--;){var P=h[y],T=P.func;if(T==null||T==n)return P.name}return o}function ua(n){var o=qt.call(N,"placeholder")?N:n;return o.placeholder}function Ze(){var n=N.iteratee||Wh;return n=n===Wh?cl:n,arguments.length?n(arguments[0],arguments[1]):n}function Tc(n,o){var h=n.__data__;return s2(o)?h[typeof o=="string"?"string":"hash"]:h.map}function Th(n){for(var o=gr(n),h=o.length;h--;){var y=o[h],P=n[y];o[h]=[y,P,jl(P)]}return o}function Ps(n,o){var h=cb(n,o);return ol(h)?h:t}function Xm(n){var o=qt.call(n,Es),h=n[Es];try{n[Es]=t;var y=!0}catch{}var P=hc.call(n);return y&&(o?n[Es]=h:delete n[Es]),P}var Dh=oh?function(n){return n==null?[]:(n=Ut(n),Yn(oh(n),function(o){return Vd.call(n,o)}))}:Xh,$l=oh?function(n){for(var o=[];n;)Xn(o,Dh(n)),n=lc(n);return o}:Xh,Tr=Br;(ch&&Tr(new ch(new ArrayBuffer(1)))!=_e||Ka&&Tr(new Ka)!=ue||fh&&Tr(fh.resolve())!=nt||aa&&Tr(new aa)!=Le||Ha&&Tr(new Ha)!=ye)&&(Tr=function(n){var o=Br(n),h=o==Te?n.constructor:t,y=h?Rs(h):"";if(y)switch(y){case Db:return _e;case Fb:return ue;case qb:return nt;case Bb:return Le;case Lb:return ye}return o});function Zm(n,o,h){for(var y=-1,P=h.length;++y<P;){var T=h[y],U=T.size;switch(T.type){case"drop":n+=U;break;case"dropRight":o-=U;break;case"take":o=Or(o,n+U);break;case"takeRight":n=ur(n,o-U);break}}return{start:n,end:o}}function e2(n){var o=n.match(ze);return o?o[1].split(at):[]}function zl(n,o,h){o=is(o,n);for(var y=-1,P=o.length,T=!1;++y<P;){var U=dn(o[y]);if(!(T=n!=null&&h(n,U)))break;n=n[U]}return T||++y!=P?T:(P=n==null?0:n.length,!!P&&$c(P)&&qn(U,P)&&(gt(n)||Ns(n)))}function t2(n){var o=n.length,h=new n.constructor(o);return o&&typeof n[0]=="string"&&qt.call(n,"index")&&(h.index=n.index,h.input=n.input),h}function Ul(n){return typeof n.constructor=="function"&&!eo(n)?ca(lc(n)):{}}function r2(n,o,h){var y=n.constructor;switch(o){case Fe:return xh(n);case k:case $:return new y(+n);case _e:return km(n,h);case We:case ke:case Pe:case ot:case ft:case De:case ct:case ut:case qe:return Il(n,h);case ue:return new y;case ve:case Ae:return new y(n);case Ve:return $m(n);case Le:return new y;case Ue:return zm(n)}}function i2(n,o){var h=o.length;if(!h)return n;var y=h-1;return o[y]=(h>1?"& ":"")+o[y],o=o.join(h>2?", ":" "),n.replace(Me,`{
/* [wrapped with `+o+`] */
`)}function n2(n){return gt(n)||Ns(n)||!!(Gd&&n&&n[Gd])}function qn(n,o){var h=typeof n;return o=o??x,!!o&&(h=="number"||h!="symbol"&&Cr.test(n))&&n>-1&&n%1==0&&n<o}function Lr(n,o,h){if(!Qt(h))return!1;var y=typeof o;return(y=="number"?Qr(h)&&qn(o,h.length):y=="string"&&o in h)?Wi(h[o],n):!1}function Fh(n,o){if(gt(n))return!1;var h=typeof n;return h=="number"||h=="symbol"||h=="boolean"||n==null||ui(n)?!0:Re.test(n)||!He.test(n)||o!=null&&n in Ut(o)}function s2(n){var o=typeof n;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?n!=="__proto__":n===null}function qh(n){var o=Oc(n),h=N[o];if(typeof h!="function"||!(o in St.prototype))return!1;if(n===h)return!0;var y=Oh(h);return!!y&&n===y[0]}function a2(n){return!!jd&&jd in n}var o2=cc?Bn:Zh;function eo(n){var o=n&&n.constructor,h=typeof o=="function"&&o.prototype||sa;return n===h}function jl(n){return n===n&&!Qt(n)}function Kl(n,o){return function(h){return h==null?!1:h[n]===o&&(o!==t||n in Ut(h))}}function c2(n){var o=Lc(n,function(y){return h.size===b&&h.clear(),y}),h=o.cache;return o}function f2(n,o){var h=n[1],y=o[1],P=h|y,T=P<(G|X|oe),U=y==oe&&h==Q||y==oe&&h==ne&&n[7].length<=o[8]||y==(oe|ne)&&o[7].length<=o[8]&&h==Q;if(!(T||U))return n;y&G&&(n[2]=o[2],P|=h&G?0:z);var K=o[3];if(K){var Y=n[3];n[3]=Y?Sl(Y,K,o[4]):K,n[4]=Y?Zn(n[3],A):o[4]}return K=o[5],K&&(Y=n[5],n[5]=Y?xl(Y,K,o[6]):K,n[6]=Y?Zn(n[5],A):o[6]),K=o[7],K&&(n[7]=K),y&oe&&(n[8]=n[8]==null?o[8]:Or(n[8],o[8])),n[9]==null&&(n[9]=o[9]),n[0]=o[0],n[1]=P,n}function h2(n){var o=[];if(n!=null)for(var h in Ut(n))o.push(h);return o}function u2(n){return hc.call(n)}function Hl(n,o,h){return o=ur(o===t?n.length-1:o,0),function(){for(var y=arguments,P=-1,T=ur(y.length-o,0),U=te(T);++P<T;)U[P]=y[o+P];P=-1;for(var K=te(o+1);++P<o;)K[P]=y[P];return K[o]=h(U),pr(n,this,K)}}function Vl(n,o){return o.length<2?n:xs(n,Mi(o,0,-1))}function d2(n,o){for(var h=n.length,y=Or(o.length,h),P=Wr(n);y--;){var T=o[y];n[y]=qn(T,h)?P[T]:t}return n}function Bh(n,o){if(!(o==="constructor"&&typeof n[o]=="function")&&o!="__proto__")return n[o]}var Gl=Wl(vl),to=xb||function(n,o){return Rt.setTimeout(n,o)},Lh=Wl(Fm);function Jl(n,o,h){var y=o+"";return Lh(n,i2(y,l2(e2(y),h)))}function Wl(n){var o=0,h=0;return function(){var y=Cb(),P=c-(y-h);if(h=y,P>0){if(++o>=v)return arguments[0]}else o=0;return n.apply(t,arguments)}}function Dc(n,o){var h=-1,y=n.length,P=y-1;for(o=o===t?y:o;++h<o;){var T=wh(h,P),U=n[T];n[T]=n[h],n[h]=U}return n.length=o,n}var Ql=c2(function(n){var o=[];return n.charCodeAt(0)===46&&o.push(""),n.replace(st,function(h,y,P,T){o.push(P?T.replace(Ot,"$1"):y||h)}),o});function dn(n){if(typeof n=="string"||ui(n))return n;var o=n+"";return o=="0"&&1/n==-S?"-0":o}function Rs(n){if(n!=null){try{return fc.call(n)}catch{}try{return n+""}catch{}}return""}function l2(n,o){return _i(se,function(h){var y="_."+h[0];o&h[1]&&!nc(n,y)&&n.push(y)}),n.sort()}function Yl(n){if(n instanceof St)return n.clone();var o=new Ei(n.__wrapped__,n.__chain__);return o.__actions__=Wr(n.__actions__),o.__index__=n.__index__,o.__values__=n.__values__,o}function p2(n,o,h){(h?Lr(n,o,h):o===t)?o=1:o=ur(mt(o),0);var y=n==null?0:n.length;if(!y||o<1)return[];for(var P=0,T=0,U=te(vc(y/o));P<y;)U[T++]=Mi(n,P,P+=o);return U}function g2(n){for(var o=-1,h=n==null?0:n.length,y=0,P=[];++o<h;){var T=n[o];T&&(P[y++]=T)}return P}function v2(){var n=arguments.length;if(!n)return[];for(var o=te(n-1),h=arguments[0],y=n;y--;)o[y-1]=arguments[y];return Xn(gt(h)?Wr(h):[h],Ar(o,1))}var b2=_t(function(n,o){return ir(n)?Wa(n,Ar(o,1,ir,!0)):[]}),m2=_t(function(n,o){var h=Si(o);return ir(h)&&(h=t),ir(n)?Wa(n,Ar(o,1,ir,!0),Ze(h,2)):[]}),y2=_t(function(n,o){var h=Si(o);return ir(h)&&(h=t),ir(n)?Wa(n,Ar(o,1,ir,!0),t,h):[]});function w2(n,o,h){var y=n==null?0:n.length;return y?(o=h||o===t?1:mt(o),Mi(n,o<0?0:o,y)):[]}function _2(n,o,h){var y=n==null?0:n.length;return y?(o=h||o===t?1:mt(o),o=y-o,Mi(n,0,o<0?0:o)):[]}function A2(n,o){return n&&n.length?Sc(n,Ze(o,3),!0,!0):[]}function E2(n,o){return n&&n.length?Sc(n,Ze(o,3),!0):[]}function I2(n,o,h,y){var P=n==null?0:n.length;return P?(h&&typeof h!="number"&&Lr(n,o,h)&&(h=0,y=P),vm(n,o,h,y)):[]}function Xl(n,o,h){var y=n==null?0:n.length;if(!y)return-1;var P=h==null?0:mt(h);return P<0&&(P=ur(y+P,0)),sc(n,Ze(o,3),P)}function Zl(n,o,h){var y=n==null?0:n.length;if(!y)return-1;var P=y-1;return h!==t&&(P=mt(h),P=h<0?ur(y+P,0):Or(P,y-1)),sc(n,Ze(o,3),P,!0)}function e0(n){var o=n==null?0:n.length;return o?Ar(n,1):[]}function M2(n){var o=n==null?0:n.length;return o?Ar(n,S):[]}function S2(n,o){var h=n==null?0:n.length;return h?(o=o===t?1:mt(o),Ar(n,o)):[]}function x2(n){for(var o=-1,h=n==null?0:n.length,y={};++o<h;){var P=n[o];y[P[0]]=P[1]}return y}function t0(n){return n&&n.length?n[0]:t}function P2(n,o,h){var y=n==null?0:n.length;if(!y)return-1;var P=h==null?0:mt(h);return P<0&&(P=ur(y+P,0)),ta(n,o,P)}function R2(n){var o=n==null?0:n.length;return o?Mi(n,0,-1):[]}var N2=_t(function(n){var o=Wt(n,Mh);return o.length&&o[0]===n[0]?gh(o):[]}),C2=_t(function(n){var o=Si(n),h=Wt(n,Mh);return o===Si(h)?o=t:h.pop(),h.length&&h[0]===n[0]?gh(h,Ze(o,2)):[]}),O2=_t(function(n){var o=Si(n),h=Wt(n,Mh);return o=typeof o=="function"?o:t,o&&h.pop(),h.length&&h[0]===n[0]?gh(h,t,o):[]});function T2(n,o){return n==null?"":Rb.call(n,o)}function Si(n){var o=n==null?0:n.length;return o?n[o-1]:t}function D2(n,o,h){var y=n==null?0:n.length;if(!y)return-1;var P=y;return h!==t&&(P=mt(h),P=P<0?ur(y+P,0):Or(P,y-1)),o===o?lb(n,o,P):sc(n,Fd,P,!0)}function F2(n,o){return n&&n.length?dl(n,mt(o)):t}var q2=_t(r0);function r0(n,o){return n&&n.length&&o&&o.length?yh(n,o):n}function B2(n,o,h){return n&&n.length&&o&&o.length?yh(n,o,Ze(h,2)):n}function L2(n,o,h){return n&&n.length&&o&&o.length?yh(n,o,t,h):n}var k2=Fn(function(n,o){var h=n==null?0:n.length,y=uh(n,o);return gl(n,Wt(o,function(P){return qn(P,h)?+P:P}).sort(Ml)),y});function $2(n,o){var h=[];if(!(n&&n.length))return h;var y=-1,P=[],T=n.length;for(o=Ze(o,3);++y<T;){var U=n[y];o(U,y,n)&&(h.push(U),P.push(y))}return gl(n,P),h}function kh(n){return n==null?n:Tb.call(n)}function z2(n,o,h){var y=n==null?0:n.length;return y?(h&&typeof h!="number"&&Lr(n,o,h)?(o=0,h=y):(o=o==null?0:mt(o),h=h===t?y:mt(h)),Mi(n,o,h)):[]}function U2(n,o){return Mc(n,o)}function j2(n,o,h){return Ah(n,o,Ze(h,2))}function K2(n,o){var h=n==null?0:n.length;if(h){var y=Mc(n,o);if(y<h&&Wi(n[y],o))return y}return-1}function H2(n,o){return Mc(n,o,!0)}function V2(n,o,h){return Ah(n,o,Ze(h,2),!0)}function G2(n,o){var h=n==null?0:n.length;if(h){var y=Mc(n,o,!0)-1;if(Wi(n[y],o))return y}return-1}function J2(n){return n&&n.length?bl(n):[]}function W2(n,o){return n&&n.length?bl(n,Ze(o,2)):[]}function Q2(n){var o=n==null?0:n.length;return o?Mi(n,1,o):[]}function Y2(n,o,h){return n&&n.length?(o=h||o===t?1:mt(o),Mi(n,0,o<0?0:o)):[]}function X2(n,o,h){var y=n==null?0:n.length;return y?(o=h||o===t?1:mt(o),o=y-o,Mi(n,o<0?0:o,y)):[]}function Z2(n,o){return n&&n.length?Sc(n,Ze(o,3),!1,!0):[]}function ey(n,o){return n&&n.length?Sc(n,Ze(o,3)):[]}var ty=_t(function(n){return rs(Ar(n,1,ir,!0))}),ry=_t(function(n){var o=Si(n);return ir(o)&&(o=t),rs(Ar(n,1,ir,!0),Ze(o,2))}),iy=_t(function(n){var o=Si(n);return o=typeof o=="function"?o:t,rs(Ar(n,1,ir,!0),t,o)});function ny(n){return n&&n.length?rs(n):[]}function sy(n,o){return n&&n.length?rs(n,Ze(o,2)):[]}function ay(n,o){return o=typeof o=="function"?o:t,n&&n.length?rs(n,t,o):[]}function $h(n){if(!(n&&n.length))return[];var o=0;return n=Yn(n,function(h){if(ir(h))return o=ur(h.length,o),!0}),ih(o,function(h){return Wt(n,eh(h))})}function i0(n,o){if(!(n&&n.length))return[];var h=$h(n);return o==null?h:Wt(h,function(y){return pr(o,t,y)})}var oy=_t(function(n,o){return ir(n)?Wa(n,o):[]}),cy=_t(function(n){return Ih(Yn(n,ir))}),fy=_t(function(n){var o=Si(n);return ir(o)&&(o=t),Ih(Yn(n,ir),Ze(o,2))}),hy=_t(function(n){var o=Si(n);return o=typeof o=="function"?o:t,Ih(Yn(n,ir),t,o)}),uy=_t($h);function dy(n,o){return _l(n||[],o||[],Ja)}function ly(n,o){return _l(n||[],o||[],Xa)}var py=_t(function(n){var o=n.length,h=o>1?n[o-1]:t;return h=typeof h=="function"?(n.pop(),h):t,i0(n,h)});function n0(n){var o=N(n);return o.__chain__=!0,o}function gy(n,o){return o(n),n}function Fc(n,o){return o(n)}var vy=Fn(function(n){var o=n.length,h=o?n[0]:0,y=this.__wrapped__,P=function(T){return uh(T,n)};return o>1||this.__actions__.length||!(y instanceof St)||!qn(h)?this.thru(P):(y=y.slice(h,+h+(o?1:0)),y.__actions__.push({func:Fc,args:[P],thisArg:t}),new Ei(y,this.__chain__).thru(function(T){return o&&!T.length&&T.push(t),T}))});function by(){return n0(this)}function my(){return new Ei(this.value(),this.__chain__)}function yy(){this.__values__===t&&(this.__values__=m0(this.value()));var n=this.__index__>=this.__values__.length,o=n?t:this.__values__[this.__index__++];return{done:n,value:o}}function wy(){return this}function _y(n){for(var o,h=this;h instanceof wc;){var y=Yl(h);y.__index__=0,y.__values__=t,o?P.__wrapped__=y:o=y;var P=y;h=h.__wrapped__}return P.__wrapped__=n,o}function Ay(){var n=this.__wrapped__;if(n instanceof St){var o=n;return this.__actions__.length&&(o=new St(this)),o=o.reverse(),o.__actions__.push({func:Fc,args:[kh],thisArg:t}),new Ei(o,this.__chain__)}return this.thru(kh)}function Ey(){return wl(this.__wrapped__,this.__actions__)}var Iy=xc(function(n,o,h){qt.call(n,h)?++n[h]:Tn(n,h,1)});function My(n,o,h){var y=gt(n)?Td:gm;return h&&Lr(n,o,h)&&(o=t),y(n,Ze(o,3))}function Sy(n,o){var h=gt(n)?Yn:il;return h(n,Ze(o,3))}var xy=Cl(Xl),Py=Cl(Zl);function Ry(n,o){return Ar(qc(n,o),1)}function Ny(n,o){return Ar(qc(n,o),S)}function Cy(n,o,h){return h=h===t?1:mt(h),Ar(qc(n,o),h)}function s0(n,o){var h=gt(n)?_i:ts;return h(n,Ze(o,3))}function a0(n,o){var h=gt(n)?Qv:rl;return h(n,Ze(o,3))}var Oy=xc(function(n,o,h){qt.call(n,h)?n[h].push(o):Tn(n,h,[o])});function Ty(n,o,h,y){n=Qr(n)?n:la(n),h=h&&!y?mt(h):0;var P=n.length;return h<0&&(h=ur(P+h,0)),zc(n)?h<=P&&n.indexOf(o,h)>-1:!!P&&ta(n,o,h)>-1}var Dy=_t(function(n,o,h){var y=-1,P=typeof o=="function",T=Qr(n)?te(n.length):[];return ts(n,function(U){T[++y]=P?pr(o,U,h):Qa(U,o,h)}),T}),Fy=xc(function(n,o,h){Tn(n,h,o)});function qc(n,o){var h=gt(n)?Wt:fl;return h(n,Ze(o,3))}function qy(n,o,h,y){return n==null?[]:(gt(o)||(o=o==null?[]:[o]),h=y?t:h,gt(h)||(h=h==null?[]:[h]),ll(n,o,h))}var By=xc(function(n,o,h){n[h?0:1].push(o)},function(){return[[],[]]});function Ly(n,o,h){var y=gt(n)?Xf:Bd,P=arguments.length<3;return y(n,Ze(o,4),h,P,ts)}function ky(n,o,h){var y=gt(n)?Yv:Bd,P=arguments.length<3;return y(n,Ze(o,4),h,P,rl)}function $y(n,o){var h=gt(n)?Yn:il;return h(n,kc(Ze(o,3)))}function zy(n){var o=gt(n)?Xd:Tm;return o(n)}function Uy(n,o,h){(h?Lr(n,o,h):o===t)?o=1:o=mt(o);var y=gt(n)?hm:Dm;return y(n,o)}function jy(n){var o=gt(n)?um:qm;return o(n)}function Ky(n){if(n==null)return 0;if(Qr(n))return zc(n)?ia(n):n.length;var o=Tr(n);return o==ue||o==Le?n.size:bh(n).length}function Hy(n,o,h){var y=gt(n)?Zf:Bm;return h&&Lr(n,o,h)&&(o=t),y(n,Ze(o,3))}var Vy=_t(function(n,o){if(n==null)return[];var h=o.length;return h>1&&Lr(n,o[0],o[1])?o=[]:h>2&&Lr(o[0],o[1],o[2])&&(o=[o[0]]),ll(n,Ar(o,1),[])}),Bc=Sb||function(){return Rt.Date.now()};function Gy(n,o){if(typeof o!="function")throw new Ai(f);return n=mt(n),function(){if(--n<1)return o.apply(this,arguments)}}function o0(n,o,h){return o=h?t:o,o=n&&o==null?n.length:o,Dn(n,oe,t,t,t,t,o)}function c0(n,o){var h;if(typeof o!="function")throw new Ai(f);return n=mt(n),function(){return--n>0&&(h=o.apply(this,arguments)),n<=1&&(o=t),h}}var zh=_t(function(n,o,h){var y=G;if(h.length){var P=Zn(h,ua(zh));y|=H}return Dn(n,y,o,h,P)}),f0=_t(function(n,o,h){var y=G|X;if(h.length){var P=Zn(h,ua(f0));y|=H}return Dn(o,y,n,h,P)});function h0(n,o,h){o=h?t:o;var y=Dn(n,Q,t,t,t,t,t,o);return y.placeholder=h0.placeholder,y}function u0(n,o,h){o=h?t:o;var y=Dn(n,V,t,t,t,t,t,o);return y.placeholder=u0.placeholder,y}function d0(n,o,h){var y,P,T,U,K,Y,ce=0,fe=!1,le=!1,we=!0;if(typeof n!="function")throw new Ai(f);o=xi(o)||0,Qt(h)&&(fe=!!h.leading,le="maxWait"in h,T=le?ur(xi(h.maxWait)||0,o):T,we="trailing"in h?!!h.trailing:we);function Be(nr){var Qi=y,kn=P;return y=P=t,ce=nr,U=n.apply(kn,Qi),U}function rt(nr){return ce=nr,K=to(Et,o),fe?Be(nr):U}function yt(nr){var Qi=nr-Y,kn=nr-ce,C0=o-Qi;return le?Or(C0,T-kn):C0}function it(nr){var Qi=nr-Y,kn=nr-ce;return Y===t||Qi>=o||Qi<0||le&&kn>=T}function Et(){var nr=Bc();if(it(nr))return Nt(nr);K=to(Et,yt(nr))}function Nt(nr){return K=t,we&&y?Be(nr):(y=P=t,U)}function di(){K!==t&&Al(K),ce=0,y=Y=P=K=t}function kr(){return K===t?U:Nt(Bc())}function li(){var nr=Bc(),Qi=it(nr);if(y=arguments,P=this,Y=nr,Qi){if(K===t)return rt(Y);if(le)return Al(K),K=to(Et,o),Be(Y)}return K===t&&(K=to(Et,o)),U}return li.cancel=di,li.flush=kr,li}var Jy=_t(function(n,o){return tl(n,1,o)}),Wy=_t(function(n,o,h){return tl(n,xi(o)||0,h)});function Qy(n){return Dn(n,ge)}function Lc(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new Ai(f);var h=function(){var y=arguments,P=o?o.apply(this,y):y[0],T=h.cache;if(T.has(P))return T.get(P);var U=n.apply(this,y);return h.cache=T.set(P,U)||T,U};return h.cache=new(Lc.Cache||On),h}Lc.Cache=On;function kc(n){if(typeof n!="function")throw new Ai(f);return function(){var o=arguments;switch(o.length){case 0:return!n.call(this);case 1:return!n.call(this,o[0]);case 2:return!n.call(this,o[0],o[1]);case 3:return!n.call(this,o[0],o[1],o[2])}return!n.apply(this,o)}}function Yy(n){return c0(2,n)}var Xy=Lm(function(n,o){o=o.length==1&&gt(o[0])?Wt(o[0],fi(Ze())):Wt(Ar(o,1),fi(Ze()));var h=o.length;return _t(function(y){for(var P=-1,T=Or(y.length,h);++P<T;)y[P]=o[P].call(this,y[P]);return pr(n,this,y)})}),Uh=_t(function(n,o){var h=Zn(o,ua(Uh));return Dn(n,H,t,o,h)}),l0=_t(function(n,o){var h=Zn(o,ua(l0));return Dn(n,ee,t,o,h)}),Zy=Fn(function(n,o){return Dn(n,ne,t,t,t,o)});function e6(n,o){if(typeof n!="function")throw new Ai(f);return o=o===t?o:mt(o),_t(n,o)}function t6(n,o){if(typeof n!="function")throw new Ai(f);return o=o==null?0:ur(mt(o),0),_t(function(h){var y=h[o],P=ns(h,0,o);return y&&Xn(P,y),pr(n,this,P)})}function r6(n,o,h){var y=!0,P=!0;if(typeof n!="function")throw new Ai(f);return Qt(h)&&(y="leading"in h?!!h.leading:y,P="trailing"in h?!!h.trailing:P),d0(n,o,{leading:y,maxWait:o,trailing:P})}function i6(n){return o0(n,1)}function n6(n,o){return Uh(Sh(o),n)}function s6(){if(!arguments.length)return[];var n=arguments[0];return gt(n)?n:[n]}function a6(n){return Ii(n,O)}function o6(n,o){return o=typeof o=="function"?o:t,Ii(n,O,o)}function c6(n){return Ii(n,M|O)}function f6(n,o){return o=typeof o=="function"?o:t,Ii(n,M|O,o)}function h6(n,o){return o==null||el(n,o,gr(o))}function Wi(n,o){return n===o||n!==n&&o!==o}var u6=Cc(ph),d6=Cc(function(n,o){return n>=o}),Ns=al(function(){return arguments}())?al:function(n){return Xt(n)&&qt.call(n,"callee")&&!Vd.call(n,"callee")},gt=te.isArray,l6=qr?fi(qr):_m;function Qr(n){return n!=null&&$c(n.length)&&!Bn(n)}function ir(n){return Xt(n)&&Qr(n)}function p6(n){return n===!0||n===!1||Xt(n)&&Br(n)==k}var ss=Pb||Zh,g6=Vi?fi(Vi):Am;function v6(n){return Xt(n)&&n.nodeType===1&&!ro(n)}function b6(n){if(n==null)return!0;if(Qr(n)&&(gt(n)||typeof n=="string"||typeof n.splice=="function"||ss(n)||da(n)||Ns(n)))return!n.length;var o=Tr(n);if(o==ue||o==Le)return!n.size;if(eo(n))return!bh(n).length;for(var h in n)if(qt.call(n,h))return!1;return!0}function m6(n,o){return Ya(n,o)}function y6(n,o,h){h=typeof h=="function"?h:t;var y=h?h(n,o):t;return y===t?Ya(n,o,t,h):!!y}function jh(n){if(!Xt(n))return!1;var o=Br(n);return o==B||o==m||typeof n.message=="string"&&typeof n.name=="string"&&!ro(n)}function w6(n){return typeof n=="number"&&Jd(n)}function Bn(n){if(!Qt(n))return!1;var o=Br(n);return o==re||o==he||o==F||o==Se}function p0(n){return typeof n=="number"&&n==mt(n)}function $c(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=x}function Qt(n){var o=typeof n;return n!=null&&(o=="object"||o=="function")}function Xt(n){return n!=null&&typeof n=="object"}var g0=wi?fi(wi):Im;function _6(n,o){return n===o||vh(n,o,Th(o))}function A6(n,o,h){return h=typeof h=="function"?h:t,vh(n,o,Th(o),h)}function E6(n){return v0(n)&&n!=+n}function I6(n){if(o2(n))throw new lt(a);return ol(n)}function M6(n){return n===null}function S6(n){return n==null}function v0(n){return typeof n=="number"||Xt(n)&&Br(n)==ve}function ro(n){if(!Xt(n)||Br(n)!=Te)return!1;var o=lc(n);if(o===null)return!0;var h=qt.call(o,"constructor")&&o.constructor;return typeof h=="function"&&h instanceof h&&fc.call(h)==Ab}var Kh=fn?fi(fn):Mm;function x6(n){return p0(n)&&n>=-x&&n<=x}var b0=za?fi(za):Sm;function zc(n){return typeof n=="string"||!gt(n)&&Xt(n)&&Br(n)==Ae}function ui(n){return typeof n=="symbol"||Xt(n)&&Br(n)==Ue}var da=As?fi(As):xm;function P6(n){return n===t}function R6(n){return Xt(n)&&Tr(n)==ye}function N6(n){return Xt(n)&&Br(n)==je}var C6=Cc(mh),O6=Cc(function(n,o){return n<=o});function m0(n){if(!n)return[];if(Qr(n))return zc(n)?Gi(n):Wr(n);if(ja&&n[ja])return hb(n[ja]());var o=Tr(n),h=o==ue?sh:o==Le?ac:la;return h(n)}function Ln(n){if(!n)return n===0?n:0;if(n=xi(n),n===S||n===-S){var o=n<0?-1:1;return o*E}return n===n?n:0}function mt(n){var o=Ln(n),h=o%1;return o===o?h?o-h:o:0}function y0(n){return n?Ss(mt(n),0,l):0}function xi(n){if(typeof n=="number")return n;if(ui(n))return u;if(Qt(n)){var o=typeof n.valueOf=="function"?n.valueOf():n;n=Qt(o)?o+"":o}if(typeof n!="string")return n===0?n:+n;n=Ld(n);var h=Pr.test(n);return h||Nr.test(n)?pt(n.slice(2),h?2:8):xr.test(n)?u:+n}function w0(n){return un(n,Yr(n))}function T6(n){return n?Ss(mt(n),-x,x):n===0?n:0}function Dt(n){return n==null?"":hi(n)}var D6=fa(function(n,o){if(eo(o)||Qr(o)){un(o,gr(o),n);return}for(var h in o)qt.call(o,h)&&Ja(n,h,o[h])}),_0=fa(function(n,o){un(o,Yr(o),n)}),Uc=fa(function(n,o,h,y){un(o,Yr(o),n,y)}),F6=fa(function(n,o,h,y){un(o,gr(o),n,y)}),q6=Fn(uh);function B6(n,o){var h=ca(n);return o==null?h:Zd(h,o)}var L6=_t(function(n,o){n=Ut(n);var h=-1,y=o.length,P=y>2?o[2]:t;for(P&&Lr(o[0],o[1],P)&&(y=1);++h<y;)for(var T=o[h],U=Yr(T),K=-1,Y=U.length;++K<Y;){var ce=U[K],fe=n[ce];(fe===t||Wi(fe,sa[ce])&&!qt.call(n,ce))&&(n[ce]=T[ce])}return n}),k6=_t(function(n){return n.push(t,Ll),pr(A0,t,n)});function $6(n,o){return Dd(n,Ze(o,3),hn)}function z6(n,o){return Dd(n,Ze(o,3),lh)}function U6(n,o){return n==null?n:dh(n,Ze(o,3),Yr)}function j6(n,o){return n==null?n:nl(n,Ze(o,3),Yr)}function K6(n,o){return n&&hn(n,Ze(o,3))}function H6(n,o){return n&&lh(n,Ze(o,3))}function V6(n){return n==null?[]:Ec(n,gr(n))}function G6(n){return n==null?[]:Ec(n,Yr(n))}function Hh(n,o,h){var y=n==null?t:xs(n,o);return y===t?h:y}function J6(n,o){return n!=null&&zl(n,o,bm)}function Vh(n,o){return n!=null&&zl(n,o,mm)}var W6=Tl(function(n,o,h){o!=null&&typeof o.toString!="function"&&(o=hc.call(o)),n[o]=h},Jh(Xr)),Q6=Tl(function(n,o,h){o!=null&&typeof o.toString!="function"&&(o=hc.call(o)),qt.call(n,o)?n[o].push(h):n[o]=[h]},Ze),Y6=_t(Qa);function gr(n){return Qr(n)?Yd(n):bh(n)}function Yr(n){return Qr(n)?Yd(n,!0):Pm(n)}function X6(n,o){var h={};return o=Ze(o,3),hn(n,function(y,P,T){Tn(h,o(y,P,T),y)}),h}function Z6(n,o){var h={};return o=Ze(o,3),hn(n,function(y,P,T){Tn(h,P,o(y,P,T))}),h}var e3=fa(function(n,o,h){Ic(n,o,h)}),A0=fa(function(n,o,h,y){Ic(n,o,h,y)}),t3=Fn(function(n,o){var h={};if(n==null)return h;var y=!1;o=Wt(o,function(T){return T=is(T,n),y||(y=T.length>1),T}),un(n,Ch(n),h),y&&(h=Ii(h,M|C|O,Wm));for(var P=o.length;P--;)Eh(h,o[P]);return h});function r3(n,o){return E0(n,kc(Ze(o)))}var i3=Fn(function(n,o){return n==null?{}:Nm(n,o)});function E0(n,o){if(n==null)return{};var h=Wt(Ch(n),function(y){return[y]});return o=Ze(o),pl(n,h,function(y,P){return o(y,P[0])})}function n3(n,o,h){o=is(o,n);var y=-1,P=o.length;for(P||(P=1,n=t);++y<P;){var T=n==null?t:n[dn(o[y])];T===t&&(y=P,T=h),n=Bn(T)?T.call(n):T}return n}function s3(n,o,h){return n==null?n:Xa(n,o,h)}function a3(n,o,h,y){return y=typeof y=="function"?y:t,n==null?n:Xa(n,o,h,y)}var I0=ql(gr),M0=ql(Yr);function o3(n,o,h){var y=gt(n),P=y||ss(n)||da(n);if(o=Ze(o,4),h==null){var T=n&&n.constructor;P?h=y?new T:[]:Qt(n)?h=Bn(T)?ca(lc(n)):{}:h={}}return(P?_i:hn)(n,function(U,K,Y){return o(h,U,K,Y)}),h}function c3(n,o){return n==null?!0:Eh(n,o)}function f3(n,o,h){return n==null?n:yl(n,o,Sh(h))}function h3(n,o,h,y){return y=typeof y=="function"?y:t,n==null?n:yl(n,o,Sh(h),y)}function la(n){return n==null?[]:nh(n,gr(n))}function u3(n){return n==null?[]:nh(n,Yr(n))}function d3(n,o,h){return h===t&&(h=o,o=t),h!==t&&(h=xi(h),h=h===h?h:0),o!==t&&(o=xi(o),o=o===o?o:0),Ss(xi(n),o,h)}function l3(n,o,h){return o=Ln(o),h===t?(h=o,o=0):h=Ln(h),n=xi(n),ym(n,o,h)}function p3(n,o,h){if(h&&typeof h!="boolean"&&Lr(n,o,h)&&(o=h=t),h===t&&(typeof o=="boolean"?(h=o,o=t):typeof n=="boolean"&&(h=n,n=t)),n===t&&o===t?(n=0,o=1):(n=Ln(n),o===t?(o=n,n=0):o=Ln(o)),n>o){var y=n;n=o,o=y}if(h||n%1||o%1){var P=Wd();return Or(n+P*(o-n+$t("1e-"+((P+"").length-1))),o)}return wh(n,o)}var g3=ha(function(n,o,h){return o=o.toLowerCase(),n+(h?S0(o):o)});function S0(n){return Gh(Dt(n).toLowerCase())}function x0(n){return n=Dt(n),n&&n.replace(Yt,sb).replace(Wf,"")}function v3(n,o,h){n=Dt(n),o=hi(o);var y=n.length;h=h===t?y:Ss(mt(h),0,y);var P=h;return h-=o.length,h>=0&&n.slice(h,P)==o}function b3(n){return n=Dt(n),n&&Ke.test(n)?n.replace(Mt,ab):n}function m3(n){return n=Dt(n),n&&Ne.test(n)?n.replace(Ye,"\\$&"):n}var y3=ha(function(n,o,h){return n+(h?"-":"")+o.toLowerCase()}),w3=ha(function(n,o,h){return n+(h?" ":"")+o.toLowerCase()}),_3=Nl("toLowerCase");function A3(n,o,h){n=Dt(n),o=mt(o);var y=o?ia(n):0;if(!o||y>=o)return n;var P=(o-y)/2;return Nc(bc(P),h)+n+Nc(vc(P),h)}function E3(n,o,h){n=Dt(n),o=mt(o);var y=o?ia(n):0;return o&&y<o?n+Nc(o-y,h):n}function I3(n,o,h){n=Dt(n),o=mt(o);var y=o?ia(n):0;return o&&y<o?Nc(o-y,h)+n:n}function M3(n,o,h){return h||o==null?o=0:o&&(o=+o),Ob(Dt(n).replace(Xe,""),o||0)}function S3(n,o,h){return(h?Lr(n,o,h):o===t)?o=1:o=mt(o),_h(Dt(n),o)}function x3(){var n=arguments,o=Dt(n[0]);return n.length<3?o:o.replace(n[1],n[2])}var P3=ha(function(n,o,h){return n+(h?"_":"")+o.toLowerCase()});function R3(n,o,h){return h&&typeof h!="number"&&Lr(n,o,h)&&(o=h=t),h=h===t?l:h>>>0,h?(n=Dt(n),n&&(typeof o=="string"||o!=null&&!Kh(o))&&(o=hi(o),!o&&ra(n))?ns(Gi(n),0,h):n.split(o,h)):[]}var N3=ha(function(n,o,h){return n+(h?" ":"")+Gh(o)});function C3(n,o,h){return n=Dt(n),h=h==null?0:Ss(mt(h),0,n.length),o=hi(o),n.slice(h,h+o.length)==o}function O3(n,o,h){var y=N.templateSettings;h&&Lr(n,o,h)&&(o=t),n=Dt(n),o=Uc({},o,y,Bl);var P=Uc({},o.imports,y.imports,Bl),T=gr(P),U=nh(P,T),K,Y,ce=0,fe=o.interpolate||Hr,le="__p += '",we=ah((o.escape||Hr).source+"|"+fe.source+"|"+(fe===Je?tt:Hr).source+"|"+(o.evaluate||Hr).source+"|$","g"),Be="//# sourceURL="+(qt.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Qf+"]")+`
`;n.replace(we,function(it,Et,Nt,di,kr,li){return Nt||(Nt=di),le+=n.slice(ce,li).replace($i,ob),Et&&(K=!0,le+=`' +
__e(`+Et+`) +
'`),kr&&(Y=!0,le+=`';
`+kr+`;
__p += '`),Nt&&(le+=`' +
((__t = (`+Nt+`)) == null ? '' : __t) +
'`),ce=li+it.length,it}),le+=`';
`;var rt=qt.call(o,"variable")&&o.variable;if(!rt)le=`with (obj) {
`+le+`
}
`;else if(Ct.test(rt))throw new lt(p);le=(Y?le.replace(wt,""):le).replace(dt,"$1").replace($e,"$1;"),le="function("+(rt||"obj")+`) {
`+(rt?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(K?", __e = _.escape":"")+(Y?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+le+`return __p
}`;var yt=R0(function(){return Tt(T,Be+"return "+le).apply(t,U)});if(yt.source=le,jh(yt))throw yt;return yt}function T3(n){return Dt(n).toLowerCase()}function D3(n){return Dt(n).toUpperCase()}function F3(n,o,h){if(n=Dt(n),n&&(h||o===t))return Ld(n);if(!n||!(o=hi(o)))return n;var y=Gi(n),P=Gi(o),T=kd(y,P),U=$d(y,P)+1;return ns(y,T,U).join("")}function q3(n,o,h){if(n=Dt(n),n&&(h||o===t))return n.slice(0,Ud(n)+1);if(!n||!(o=hi(o)))return n;var y=Gi(n),P=$d(y,Gi(o))+1;return ns(y,0,P).join("")}function B3(n,o,h){if(n=Dt(n),n&&(h||o===t))return n.replace(Xe,"");if(!n||!(o=hi(o)))return n;var y=Gi(n),P=kd(y,Gi(o));return ns(y,P).join("")}function L3(n,o){var h=ht,y=L;if(Qt(o)){var P="separator"in o?o.separator:P;h="length"in o?mt(o.length):h,y="omission"in o?hi(o.omission):y}n=Dt(n);var T=n.length;if(ra(n)){var U=Gi(n);T=U.length}if(h>=T)return n;var K=h-ia(y);if(K<1)return y;var Y=U?ns(U,0,K).join(""):n.slice(0,K);if(P===t)return Y+y;if(U&&(K+=Y.length-K),Kh(P)){if(n.slice(K).search(P)){var ce,fe=Y;for(P.global||(P=ah(P.source,Dt(bt.exec(P))+"g")),P.lastIndex=0;ce=P.exec(fe);)var le=ce.index;Y=Y.slice(0,le===t?K:le)}}else if(n.indexOf(hi(P),K)!=K){var we=Y.lastIndexOf(P);we>-1&&(Y=Y.slice(0,we))}return Y+y}function k3(n){return n=Dt(n),n&&Ee.test(n)?n.replace(At,pb):n}var $3=ha(function(n,o,h){return n+(h?" ":"")+o.toUpperCase()}),Gh=Nl("toUpperCase");function P0(n,o,h){return n=Dt(n),o=h?t:o,o===t?fb(n)?bb(n):eb(n):n.match(o)||[]}var R0=_t(function(n,o){try{return pr(n,t,o)}catch(h){return jh(h)?h:new lt(h)}}),z3=Fn(function(n,o){return _i(o,function(h){h=dn(h),Tn(n,h,zh(n[h],n))}),n});function U3(n){var o=n==null?0:n.length,h=Ze();return n=o?Wt(n,function(y){if(typeof y[1]!="function")throw new Ai(f);return[h(y[0]),y[1]]}):[],_t(function(y){for(var P=-1;++P<o;){var T=n[P];if(pr(T[0],this,y))return pr(T[1],this,y)}})}function j3(n){return pm(Ii(n,M))}function Jh(n){return function(){return n}}function K3(n,o){return n==null||n!==n?o:n}var H3=Ol(),V3=Ol(!0);function Xr(n){return n}function Wh(n){return cl(typeof n=="function"?n:Ii(n,M))}function G3(n){return hl(Ii(n,M))}function J3(n,o){return ul(n,Ii(o,M))}var W3=_t(function(n,o){return function(h){return Qa(h,n,o)}}),Q3=_t(function(n,o){return function(h){return Qa(n,h,o)}});function Qh(n,o,h){var y=gr(o),P=Ec(o,y);h==null&&!(Qt(o)&&(P.length||!y.length))&&(h=o,o=n,n=this,P=Ec(o,gr(o)));var T=!(Qt(h)&&"chain"in h)||!!h.chain,U=Bn(n);return _i(P,function(K){var Y=o[K];n[K]=Y,U&&(n.prototype[K]=function(){var ce=this.__chain__;if(T||ce){var fe=n(this.__wrapped__),le=fe.__actions__=Wr(this.__actions__);return le.push({func:Y,args:arguments,thisArg:n}),fe.__chain__=ce,fe}return Y.apply(n,Xn([this.value()],arguments))})}),n}function Y3(){return Rt._===this&&(Rt._=Eb),this}function Yh(){}function X3(n){return n=mt(n),_t(function(o){return dl(o,n)})}var Z3=Ph(Wt),ew=Ph(Td),tw=Ph(Zf);function N0(n){return Fh(n)?eh(dn(n)):Cm(n)}function rw(n){return function(o){return n==null?t:xs(n,o)}}var iw=Dl(),nw=Dl(!0);function Xh(){return[]}function Zh(){return!1}function sw(){return{}}function aw(){return""}function ow(){return!0}function cw(n,o){if(n=mt(n),n<1||n>x)return[];var h=l,y=Or(n,l);o=Ze(o),n-=l;for(var P=ih(y,o);++h<n;)o(h);return P}function fw(n){return gt(n)?Wt(n,dn):ui(n)?[n]:Wr(Ql(Dt(n)))}function hw(n){var o=++_b;return Dt(n)+o}var uw=Rc(function(n,o){return n+o},0),dw=Rh("ceil"),lw=Rc(function(n,o){return n/o},1),pw=Rh("floor");function gw(n){return n&&n.length?Ac(n,Xr,ph):t}function vw(n,o){return n&&n.length?Ac(n,Ze(o,2),ph):t}function bw(n){return qd(n,Xr)}function mw(n,o){return qd(n,Ze(o,2))}function yw(n){return n&&n.length?Ac(n,Xr,mh):t}function ww(n,o){return n&&n.length?Ac(n,Ze(o,2),mh):t}var _w=Rc(function(n,o){return n*o},1),Aw=Rh("round"),Ew=Rc(function(n,o){return n-o},0);function Iw(n){return n&&n.length?rh(n,Xr):0}function Mw(n,o){return n&&n.length?rh(n,Ze(o,2)):0}return N.after=Gy,N.ary=o0,N.assign=D6,N.assignIn=_0,N.assignInWith=Uc,N.assignWith=F6,N.at=q6,N.before=c0,N.bind=zh,N.bindAll=z3,N.bindKey=f0,N.castArray=s6,N.chain=n0,N.chunk=p2,N.compact=g2,N.concat=v2,N.cond=U3,N.conforms=j3,N.constant=Jh,N.countBy=Iy,N.create=B6,N.curry=h0,N.curryRight=u0,N.debounce=d0,N.defaults=L6,N.defaultsDeep=k6,N.defer=Jy,N.delay=Wy,N.difference=b2,N.differenceBy=m2,N.differenceWith=y2,N.drop=w2,N.dropRight=_2,N.dropRightWhile=A2,N.dropWhile=E2,N.fill=I2,N.filter=Sy,N.flatMap=Ry,N.flatMapDeep=Ny,N.flatMapDepth=Cy,N.flatten=e0,N.flattenDeep=M2,N.flattenDepth=S2,N.flip=Qy,N.flow=H3,N.flowRight=V3,N.fromPairs=x2,N.functions=V6,N.functionsIn=G6,N.groupBy=Oy,N.initial=R2,N.intersection=N2,N.intersectionBy=C2,N.intersectionWith=O2,N.invert=W6,N.invertBy=Q6,N.invokeMap=Dy,N.iteratee=Wh,N.keyBy=Fy,N.keys=gr,N.keysIn=Yr,N.map=qc,N.mapKeys=X6,N.mapValues=Z6,N.matches=G3,N.matchesProperty=J3,N.memoize=Lc,N.merge=e3,N.mergeWith=A0,N.method=W3,N.methodOf=Q3,N.mixin=Qh,N.negate=kc,N.nthArg=X3,N.omit=t3,N.omitBy=r3,N.once=Yy,N.orderBy=qy,N.over=Z3,N.overArgs=Xy,N.overEvery=ew,N.overSome=tw,N.partial=Uh,N.partialRight=l0,N.partition=By,N.pick=i3,N.pickBy=E0,N.property=N0,N.propertyOf=rw,N.pull=q2,N.pullAll=r0,N.pullAllBy=B2,N.pullAllWith=L2,N.pullAt=k2,N.range=iw,N.rangeRight=nw,N.rearg=Zy,N.reject=$y,N.remove=$2,N.rest=e6,N.reverse=kh,N.sampleSize=Uy,N.set=s3,N.setWith=a3,N.shuffle=jy,N.slice=z2,N.sortBy=Vy,N.sortedUniq=J2,N.sortedUniqBy=W2,N.split=R3,N.spread=t6,N.tail=Q2,N.take=Y2,N.takeRight=X2,N.takeRightWhile=Z2,N.takeWhile=ey,N.tap=gy,N.throttle=r6,N.thru=Fc,N.toArray=m0,N.toPairs=I0,N.toPairsIn=M0,N.toPath=fw,N.toPlainObject=w0,N.transform=o3,N.unary=i6,N.union=ty,N.unionBy=ry,N.unionWith=iy,N.uniq=ny,N.uniqBy=sy,N.uniqWith=ay,N.unset=c3,N.unzip=$h,N.unzipWith=i0,N.update=f3,N.updateWith=h3,N.values=la,N.valuesIn=u3,N.without=oy,N.words=P0,N.wrap=n6,N.xor=cy,N.xorBy=fy,N.xorWith=hy,N.zip=uy,N.zipObject=dy,N.zipObjectDeep=ly,N.zipWith=py,N.entries=I0,N.entriesIn=M0,N.extend=_0,N.extendWith=Uc,Qh(N,N),N.add=uw,N.attempt=R0,N.camelCase=g3,N.capitalize=S0,N.ceil=dw,N.clamp=d3,N.clone=a6,N.cloneDeep=c6,N.cloneDeepWith=f6,N.cloneWith=o6,N.conformsTo=h6,N.deburr=x0,N.defaultTo=K3,N.divide=lw,N.endsWith=v3,N.eq=Wi,N.escape=b3,N.escapeRegExp=m3,N.every=My,N.find=xy,N.findIndex=Xl,N.findKey=$6,N.findLast=Py,N.findLastIndex=Zl,N.findLastKey=z6,N.floor=pw,N.forEach=s0,N.forEachRight=a0,N.forIn=U6,N.forInRight=j6,N.forOwn=K6,N.forOwnRight=H6,N.get=Hh,N.gt=u6,N.gte=d6,N.has=J6,N.hasIn=Vh,N.head=t0,N.identity=Xr,N.includes=Ty,N.indexOf=P2,N.inRange=l3,N.invoke=Y6,N.isArguments=Ns,N.isArray=gt,N.isArrayBuffer=l6,N.isArrayLike=Qr,N.isArrayLikeObject=ir,N.isBoolean=p6,N.isBuffer=ss,N.isDate=g6,N.isElement=v6,N.isEmpty=b6,N.isEqual=m6,N.isEqualWith=y6,N.isError=jh,N.isFinite=w6,N.isFunction=Bn,N.isInteger=p0,N.isLength=$c,N.isMap=g0,N.isMatch=_6,N.isMatchWith=A6,N.isNaN=E6,N.isNative=I6,N.isNil=S6,N.isNull=M6,N.isNumber=v0,N.isObject=Qt,N.isObjectLike=Xt,N.isPlainObject=ro,N.isRegExp=Kh,N.isSafeInteger=x6,N.isSet=b0,N.isString=zc,N.isSymbol=ui,N.isTypedArray=da,N.isUndefined=P6,N.isWeakMap=R6,N.isWeakSet=N6,N.join=T2,N.kebabCase=y3,N.last=Si,N.lastIndexOf=D2,N.lowerCase=w3,N.lowerFirst=_3,N.lt=C6,N.lte=O6,N.max=gw,N.maxBy=vw,N.mean=bw,N.meanBy=mw,N.min=yw,N.minBy=ww,N.stubArray=Xh,N.stubFalse=Zh,N.stubObject=sw,N.stubString=aw,N.stubTrue=ow,N.multiply=_w,N.nth=F2,N.noConflict=Y3,N.noop=Yh,N.now=Bc,N.pad=A3,N.padEnd=E3,N.padStart=I3,N.parseInt=M3,N.random=p3,N.reduce=Ly,N.reduceRight=ky,N.repeat=S3,N.replace=x3,N.result=n3,N.round=Aw,N.runInContext=W,N.sample=zy,N.size=Ky,N.snakeCase=P3,N.some=Hy,N.sortedIndex=U2,N.sortedIndexBy=j2,N.sortedIndexOf=K2,N.sortedLastIndex=H2,N.sortedLastIndexBy=V2,N.sortedLastIndexOf=G2,N.startCase=N3,N.startsWith=C3,N.subtract=Ew,N.sum=Iw,N.sumBy=Mw,N.template=O3,N.times=cw,N.toFinite=Ln,N.toInteger=mt,N.toLength=y0,N.toLower=T3,N.toNumber=xi,N.toSafeInteger=T6,N.toString=Dt,N.toUpper=D3,N.trim=F3,N.trimEnd=q3,N.trimStart=B3,N.truncate=L3,N.unescape=k3,N.uniqueId=hw,N.upperCase=$3,N.upperFirst=Gh,N.each=s0,N.eachRight=a0,N.first=t0,Qh(N,function(){var n={};return hn(N,function(o,h){qt.call(N.prototype,h)||(n[h]=o)}),n}(),{chain:!1}),N.VERSION=i,_i(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){N[n].placeholder=N}),_i(["drop","take"],function(n,o){St.prototype[n]=function(h){h=h===t?1:ur(mt(h),0);var y=this.__filtered__&&!o?new St(this):this.clone();return y.__filtered__?y.__takeCount__=Or(h,y.__takeCount__):y.__views__.push({size:Or(h,l),type:n+(y.__dir__<0?"Right":"")}),y},St.prototype[n+"Right"]=function(h){return this.reverse()[n](h).reverse()}}),_i(["filter","map","takeWhile"],function(n,o){var h=o+1,y=h==d||h==_;St.prototype[n]=function(P){var T=this.clone();return T.__iteratees__.push({iteratee:Ze(P,3),type:h}),T.__filtered__=T.__filtered__||y,T}}),_i(["head","last"],function(n,o){var h="take"+(o?"Right":"");St.prototype[n]=function(){return this[h](1).value()[0]}}),_i(["initial","tail"],function(n,o){var h="drop"+(o?"":"Right");St.prototype[n]=function(){return this.__filtered__?new St(this):this[h](1)}}),St.prototype.compact=function(){return this.filter(Xr)},St.prototype.find=function(n){return this.filter(n).head()},St.prototype.findLast=function(n){return this.reverse().find(n)},St.prototype.invokeMap=_t(function(n,o){return typeof n=="function"?new St(this):this.map(function(h){return Qa(h,n,o)})}),St.prototype.reject=function(n){return this.filter(kc(Ze(n)))},St.prototype.slice=function(n,o){n=mt(n);var h=this;return h.__filtered__&&(n>0||o<0)?new St(h):(n<0?h=h.takeRight(-n):n&&(h=h.drop(n)),o!==t&&(o=mt(o),h=o<0?h.dropRight(-o):h.take(o-n)),h)},St.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},St.prototype.toArray=function(){return this.take(l)},hn(St.prototype,function(n,o){var h=/^(?:filter|find|map|reject)|While$/.test(o),y=/^(?:head|last)$/.test(o),P=N[y?"take"+(o=="last"?"Right":""):o],T=y||/^find/.test(o);P&&(N.prototype[o]=function(){var U=this.__wrapped__,K=y?[1]:arguments,Y=U instanceof St,ce=K[0],fe=Y||gt(U),le=function(Et){var Nt=P.apply(N,Xn([Et],K));return y&&we?Nt[0]:Nt};fe&&h&&typeof ce=="function"&&ce.length!=1&&(Y=fe=!1);var we=this.__chain__,Be=!!this.__actions__.length,rt=T&&!we,yt=Y&&!Be;if(!T&&fe){U=yt?U:new St(this);var it=n.apply(U,K);return it.__actions__.push({func:Fc,args:[le],thisArg:t}),new Ei(it,we)}return rt&&yt?n.apply(this,K):(it=this.thru(le),rt?y?it.value()[0]:it.value():it)})}),_i(["pop","push","shift","sort","splice","unshift"],function(n){var o=oc[n],h=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",y=/^(?:pop|shift)$/.test(n);N.prototype[n]=function(){var P=arguments;if(y&&!this.__chain__){var T=this.value();return o.apply(gt(T)?T:[],P)}return this[h](function(U){return o.apply(gt(U)?U:[],P)})}}),hn(St.prototype,function(n,o){var h=N[o];if(h){var y=h.name+"";qt.call(oa,y)||(oa[y]=[]),oa[y].push({name:o,func:h})}}),oa[Pc(t,X).name]=[{name:"wrapper",func:t}],St.prototype.clone=kb,St.prototype.reverse=$b,St.prototype.value=zb,N.prototype.at=vy,N.prototype.chain=by,N.prototype.commit=my,N.prototype.next=yy,N.prototype.plant=_y,N.prototype.reverse=Ay,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=Ey,N.prototype.first=N.prototype.head,ja&&(N.prototype[ja]=wy),N},na=mb();rr?((rr.exports=na)._=na,zt._=na):Rt._=na}).call(po)})(Xu,Xu.exports);var qS=Object.defineProperty,BS=Object.defineProperties,LS=Object.getOwnPropertyDescriptors,D1=Object.getOwnPropertySymbols,kS=Object.prototype.hasOwnProperty,$S=Object.prototype.propertyIsEnumerable,F1=(r,e,t)=>e in r?qS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yc=(r,e)=>{for(var t in e||(e={}))kS.call(e,t)&&F1(r,t,e[t]);if(D1)for(var t of D1(e))$S.call(e,t)&&F1(r,t,e[t]);return r},zS=(r,e)=>BS(r,LS(e));function sn(r,e,t){var i;const s=wo(r);return((i=e.rpcMap)==null?void 0:i[s.reference])||`${Vv}?chainId=${s.namespace}:${s.reference}&projectId=${t}`}function Qs(r){return r.includes(":")?r.split(":")[1]:r}function Gv(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function US(r,e){const t=Object.keys(e.namespaces).filter(s=>s.includes(r));if(!t.length)return[];const i=[];return t.forEach(s=>{const a=e.namespaces[s].accounts;i.push(...a)}),i}function Ou(r={},e={}){const t=q1(r),i=q1(e);return Xu.exports.merge(t,i)}function q1(r){var e,t,i,s;const a={};if(!Ro(r))return a;for(const[f,p]of Object.entries(r)){const w=Md(f)?[f]:p.chains,b=p.methods||[],A=p.events||[],M=p.rpcMap||{},C=mo(f);a[C]=zS(Yc(Yc({},a[C]),p),{chains:rf(w,(e=a[C])==null?void 0:e.chains),methods:rf(b,(t=a[C])==null?void 0:t.methods),events:rf(A,(i=a[C])==null?void 0:i.events),rpcMap:Yc(Yc({},M),(s=a[C])==null?void 0:s.rpcMap)})}return a}function jS(r){return r.includes(":")?r.split(":")[2]:r}function B1(r){const e={};for(const[t,i]of Object.entries(r)){const s=i.methods||[],a=i.events||[],f=i.accounts||[],p=Md(t)?[t]:i.chains?i.chains:Gv(i.accounts);e[t]={chains:p,methods:s,events:a,accounts:f}}return e}function Tu(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const Jv={},Ft=r=>Jv[r],Du=(r,e)=>{Jv[r]=e};class KS{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Qs(t);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}var HS=Object.defineProperty,VS=Object.defineProperties,GS=Object.getOwnPropertyDescriptors,L1=Object.getOwnPropertySymbols,JS=Object.prototype.hasOwnProperty,WS=Object.prototype.propertyIsEnumerable,k1=(r,e,t)=>e in r?HS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$1=(r,e)=>{for(var t in e||(e={}))JS.call(e,t)&&k1(r,t,e[t]);if(L1)for(var t of L1(e))WS.call(e,t)&&k1(r,t,e[t]);return r},z1=(r,e)=>VS(r,GS(e));class QS{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||sn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=parseInt(Qs(t));e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let s=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const a=parseInt(s,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,s;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const f=this.client.session.get(e.topic),p=((s=f==null?void 0:f.sessionProperties)==null?void 0:s.capabilities)||{};if(p!=null&&p[a])return p==null?void 0:p[a];const w=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:z1($1({},f.sessionProperties||{}),{capabilities:z1($1({},p||{}),{[a]:w})})})}catch(b){console.warn("Failed to update session with capabilities",b)}return w}async getCallStatus(e){var t,i;const s=this.client.session.get(e.topic),a=(t=s.sessionProperties)==null?void 0:t.bundler_name;if(a){const p=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(p,e)}catch(w){console.warn("Failed to fetch call status from bundler",w,p)}}const f=(i=s.sessionProperties)==null?void 0:i.bundler_url;if(f)try{return await this.getUserOperationReceipt(f,e)}catch(p){console.warn("Failed to fetch call status from custom bundler",p,f)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const s=new URL(e),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ds("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${FS}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class YS{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Qs(t);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}class XS{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Qs(t);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}class ZS{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||sn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new an(new xn(i,Ft("disableProviderPing")))}}class ex{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),s=Qs(t);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}class tx{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Qs(t);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}class rx{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Qs(t);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}class ix{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||sn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace);return typeof i>"u"?void 0:new an(new xn(i,Ft("disableProviderPing")))}}class nx{constructor(e){this.name=va,this.namespace=e.namespace,this.events=Ft("events"),this.client=Ft("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(on.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(s=>{const a=wo(s);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(s)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||sn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new an(new xn(i,Ft("disableProviderPing")))}}var sx=Object.defineProperty,ax=Object.defineProperties,ox=Object.getOwnPropertyDescriptors,U1=Object.getOwnPropertySymbols,cx=Object.prototype.hasOwnProperty,fx=Object.prototype.propertyIsEnumerable,j1=(r,e,t)=>e in r?sx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Xc=(r,e)=>{for(var t in e||(e={}))cx.call(e,t)&&j1(r,t,e[t]);if(U1)for(var t of U1(e))fx.call(e,t)&&j1(r,t,e[t]);return r},Fu=(r,e)=>ax(r,ox(e));class Cd{constructor(e){this.events=new id,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:No(Pf({level:(e==null?void 0:e.logger)||O1})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new Cd(e);return await t.initialize(),t}async request(e,t,i){const[s,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Xc({},e),chainId:`${s}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,s){const a=new Date().getTime();this.request(e,i,s).then(f=>t(null,Cf(a,f))).catch(f=>t(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Bt("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:s}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await s();if(this.session=a.session,this.session){const f=B1(this.session.namespaces);this.namespaces=Ou(this.namespaces,f),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:s}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await s().then(a=>{this.session=a;const f=B1(a.namespaces);this.namespaces=Ou(this.namespaces,f),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==Hv)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,s]=this.validateChain(e),a=this.getProvider(i);a.name===va?a.setDefaultChain(`${i}:${s}`,t):a.setDefaultChain(s,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Mn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Nd.init({core:this.providerOpts.core,logger:this.providerOpts.logger||O1,relayUrl:this.providerOpts.relayUrl||OS,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>mo(t)))];Du("client",this.client),Du("events",this.events),Du("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=US(t,this.session),s=Gv(i),a=Ou(this.namespaces,this.optionalNamespaces),f=Fu(Xc({},a[t]),{accounts:i,chains:s});switch(t){case"eip155":this.rpcProviders[t]=new QS({namespace:f});break;case"algorand":this.rpcProviders[t]=new ZS({namespace:f});break;case"solana":this.rpcProviders[t]=new YS({namespace:f});break;case"cosmos":this.rpcProviders[t]=new XS({namespace:f});break;case"polkadot":this.rpcProviders[t]=new KS({namespace:f});break;case"cip34":this.rpcProviders[t]=new ex({namespace:f});break;case"elrond":this.rpcProviders[t]=new tx({namespace:f});break;case"multiversx":this.rpcProviders[t]=new rx({namespace:f});break;case"near":this.rpcProviders[t]=new ix({namespace:f});break;default:this.rpcProviders[va]?this.rpcProviders[va].updateNamespace(f):this.rpcProviders[va]=new nx({namespace:f})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const s=i.data;s&&Mn(s)&&this.events.emit("accountsChanged",s.map(jS))}else if(i.name==="chainChanged"){const s=t.chainId,a=t.event.data,f=mo(s),p=Tu(s)!==Tu(a)?`${f}:${Tu(a)}`:s;this.onChainChanged(p)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:s}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=Fu(Xc({},a),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Fu(Xc({},Bt("USER_DISCONNECTED")),{data:e.topic}))}),this.on(on.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[va]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:s}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(f=>mo(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const s=mo(Object.keys(this.namespaces)[0]),a=this.rpcProviders[s].getDefaultChain();return[s,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);s&&(t||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${T1}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${T1}/${e}`)}}const hx=Cd,ux="wc",dx="ethereum_provider",lx=`${ux}@2:${dx}:`,px="https://rpc.walletconnect.org/v1/",Zu=["eth_sendTransaction","personal_sign"],gx=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],ed=["chainChanged","accountsChanged"],vx=["chainChanged","accountsChanged","message","disconnect","connect"];var bx=Object.defineProperty,mx=Object.defineProperties,yx=Object.getOwnPropertyDescriptors,K1=Object.getOwnPropertySymbols,wx=Object.prototype.hasOwnProperty,_x=Object.prototype.propertyIsEnumerable,H1=(r,e,t)=>e in r?bx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ba=(r,e)=>{for(var t in e||(e={}))wx.call(e,t)&&H1(r,t,e[t]);if(K1)for(var t of K1(e))_x.call(e,t)&&H1(r,t,e[t]);return r},qu=(r,e)=>mx(r,yx(e));function Sf(r){return Number(r[0].split(":")[1])}function Zc(r){return`0x${r.toString(16)}`}function Ax(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:s,events:a,optionalEvents:f,rpcMap:p}=r;if(!Mn(e))throw new Error("Invalid chains");const w={chains:e,methods:i||Zu,events:a||ed,rpcMap:ba({},e.length?{[Sf(e)]:p[Sf(e)]}:{})},b=a==null?void 0:a.filter(O=>!ed.includes(O)),A=i==null?void 0:i.filter(O=>!Zu.includes(O));if(!t&&!f&&!s&&!(b!=null&&b.length)&&!(A!=null&&A.length))return{required:e.length?w:void 0};const M=(b==null?void 0:b.length)&&(A==null?void 0:A.length)||!t,C={chains:[...new Set(M?w.chains.concat(t||[]):t)],methods:[...new Set(w.methods.concat(s!=null&&s.length?s:gx))],events:[...new Set(w.events.concat(f!=null&&f.length?f:vx))],rpcMap:p};return{required:e.length?w:void 0,optional:t.length?C:void 0}}class Od{constructor(){this.events=new Bi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=lx,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new Od;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:i}=Ax(this.rpc);try{const s=await new Promise(async(f,p)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),p(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(qu(ba({namespaces:ba({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(b=>{f(b)}).catch(b=>{p(new Error(b.message))})});if(!s)return;const a=gp(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Zc(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,f)=>{var p;this.rpc.showQrModal&&((p=this.modal)==null||p.subscribeModal(w=>{!w.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(qu(ba({},e),{chains:this.rpc.chains}),t).then(w=>{a(w)}).catch(w=>{f(new Error(w.message))})}),s=i.session;if(s){const a=gp(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Zc(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",Zc(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",qu(ba({},Bt("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",Zc(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,s]=e.split(":");return{chainId:`${t}:${i}`,address:s}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const s=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],f=s.concat(a);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const p=s.length?(e==null?void 0:e.methods)||Zu:[],w=s.length?(e==null?void 0:e.events)||ed:[],b=(e==null?void 0:e.optionalMethods)||[],A=(e==null?void 0:e.optionalEvents)||[],M=(e==null?void 0:e.rpcMap)||this.buildRpcMap(f,e.projectId),C=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(O=>this.formatChainId(O)),optionalChains:a.map(O=>this.formatChainId(O)),methods:p,events:w,optionalMethods:b,optionalEvents:A,rpcMap:M,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:C,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(s=>{i[s]=this.getRpcUrl(s,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Sf(this.rpc.chains):Sf(this.rpc.optionalChains),this.signer=await hx.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:i}=await Pw(()=>import("./index-BAdBZGR3.js"),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(ba({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:s}=e;t&&Mn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)})),i&&Mn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${px}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const Kx=Od;export{Kx as EthereumProvider,vx as OPTIONAL_EVENTS,gx as OPTIONAL_METHODS,ed as REQUIRED_EVENTS,Zu as REQUIRED_METHODS,Od as default};