@dcl/vesting-dashboard 3.0.5 → 3.0.6-9213391407.commit-101c1e4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ import{p as ri,g as S1,c as X3,r as Z3,a as Ie,B as ua,e as Di,b as Bl,d as Xi,W as Ll,o as hd,_ as t6}from"./index-25febcc8.js";var ld=globalThis&&globalThis.__spreadArray||function(r,t,e){if(e||arguments.length===2)for(var i=0,s=t.length,a;i<s;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return r.concat(a||Array.prototype.slice.call(t))},e6=function(){function r(t,e,i){this.name=t,this.version=e,this.os=i,this.type="browser"}return r}(),r6=function(){function r(t){this.version=t,this.type="node",this.name="node",this.os=ri.platform}return r}(),i6=function(){function r(t,e,i,s){this.name=t,this.version=e,this.os=i,this.bot=s,this.type="bot-device"}return r}(),n6=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),s6=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),o6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,a6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,fd=3,c6=[["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",o6]],dd=[["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 u6(r){return r?pd(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new s6:typeof navigator<"u"?pd(navigator.userAgent):f6()}function h6(r){return r!==""&&c6.reduce(function(t,e){var i=e[0],s=e[1];if(t)return t;var a=s.exec(r);return!!a&&[i,a]},!1)}function pd(r){var t=h6(r);if(!t)return null;var e=t[0],i=t[1];if(e==="searchbot")return new n6;var s=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);s?s.length<fd&&(s=ld(ld([],s,!0),d6(fd-s.length),!0)):s=[];var a=s.join("."),u=l6(r),l=a6.exec(r);return l&&l[1]?new i6(e,a,u,l[1]):new e6(e,a,u)}function l6(r){for(var t=0,e=dd.length;t<e;t++){var i=dd[t],s=i[0],a=i[1],u=a.exec(r);if(u)return s}return null}function f6(){var r=typeof ri<"u"&&ri.version;return r?new r6(ri.version.slice(1)):null}function d6(r){for(var t=[],e=0;e<r;e++)t.push("0");return t}var bt={};/*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */var ul=function(r,t){return ul=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)i.hasOwnProperty(s)&&(e[s]=i[s])},ul(r,t)};function p6(r,t){ul(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var hl=function(){return hl=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},hl.apply(this,arguments)};function g6(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(r);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(r,i[s])&&(e[i[s]]=r[i[s]]);return e}function m6(r,t,e,i){var s=arguments.length,a=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,i);else for(var l=r.length-1;l>=0;l--)(u=r[l])&&(a=(s<3?u(a):s>3?u(t,e,a):u(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a}function v6(r,t){return function(e,i){t(e,i,r)}}function y6(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function w6(r,t,e,i){function s(a){return a instanceof e?a:new e(function(u){u(a)})}return new(e||(e=Promise))(function(a,u){function l(w){try{f(i.next(w))}catch(E){u(E)}}function d(w){try{f(i.throw(w))}catch(E){u(E)}}function f(w){w.done?a(w.value):s(w.value).then(l,d)}f((i=i.apply(r,t||[])).next())})}function b6(r,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,u;return u={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function l(f){return function(w){return d([f,w])}}function d(f){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,s&&(a=f[0]&2?s.return:f[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,f[1])).done)return a;switch(s=0,a&&(f=[f[0]&2,a.value]),f[0]){case 0:case 1:a=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,s=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!a||f[1]>a[0]&&f[1]<a[3])){e.label=f[1];break}if(f[0]===6&&e.label<a[1]){e.label=a[1],a=f;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(f);break}a[2]&&e.ops.pop(),e.trys.pop();continue}f=t.call(r,e)}catch(w){f=[6,w],s=0}finally{i=a=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function _6(r,t,e,i){i===void 0&&(i=e),r[i]=t[e]}function E6(r,t){for(var e in r)e!=="default"&&!t.hasOwnProperty(e)&&(t[e]=r[e])}function ll(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function I1(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),s,a=[],u;try{for(;(t===void 0||t-- >0)&&!(s=i.next()).done;)a.push(s.value)}catch(l){u={error:l}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(u)throw u.error}}return a}function A6(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(I1(arguments[t]));return r}function S6(){for(var r=0,t=0,e=arguments.length;t<e;t++)r+=arguments[t].length;for(var i=Array(r),s=0,t=0;t<e;t++)for(var a=arguments[t],u=0,l=a.length;u<l;u++,s++)i[s]=a[u];return i}function ea(r){return this instanceof ea?(this.v=r,this):new ea(r)}function I6(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),s,a=[];return s={},u("next"),u("throw"),u("return"),s[Symbol.asyncIterator]=function(){return this},s;function u(I){i[I]&&(s[I]=function(D){return new Promise(function(P,Y){a.push([I,D,P,Y])>1||l(I,D)})})}function l(I,D){try{d(i[I](D))}catch(P){E(a[0][3],P)}}function d(I){I.value instanceof ea?Promise.resolve(I.value.v).then(f,w):E(a[0][2],I)}function f(I){l("next",I)}function w(I){l("throw",I)}function E(I,D){I(D),a.shift(),a.length&&l(a[0][0],a[0][1])}}function D6(r){var t,e;return t={},i("next"),i("throw",function(s){throw s}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(s,a){t[s]=r[s]?function(u){return(e=!e)?{value:ea(r[s](u)),done:s==="return"}:a?a(u):u}:a}}function x6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof ll=="function"?ll(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(a){e[a]=r[a]&&function(u){return new Promise(function(l,d){u=r[a](u),s(l,d,u.done,u.value)})}}function s(a,u,l,d){Promise.resolve(d).then(function(f){a({value:f,done:l})},u)}}function M6(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function C6(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function P6(r){return r&&r.__esModule?r:{default:r}}function O6(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function N6(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const R6=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return hl},__asyncDelegator:D6,__asyncGenerator:I6,__asyncValues:x6,__await:ea,__awaiter:w6,__classPrivateFieldGet:O6,__classPrivateFieldSet:N6,__createBinding:_6,__decorate:m6,__exportStar:E6,__extends:p6,__generator:b6,__importDefault:P6,__importStar:C6,__makeTemplateObject:M6,__metadata:y6,__param:v6,__read:I1,__rest:g6,__spread:A6,__spreadArrays:S6,__values:ll},Symbol.toStringTag,{value:"Module"})),ha=S1(R6);var Mh={},jo={},gd;function T6(){if(gd)return jo;gd=1,Object.defineProperty(jo,"__esModule",{value:!0}),jo.delay=void 0;function r(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}return jo.delay=r,jo}var ys={},Ch={},ws={},md;function F6(){return md||(md=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.ONE_THOUSAND=ws.ONE_HUNDRED=void 0,ws.ONE_HUNDRED=100,ws.ONE_THOUSAND=1e3),ws}var Ph={},vd;function U6(){return vd||(vd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(Ph)),Ph}var yd;function D1(){return yd||(yd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ha;t.__exportStar(F6(),r),t.__exportStar(U6(),r)}(Ch)),Ch}var wd;function B6(){if(wd)return ys;wd=1,Object.defineProperty(ys,"__esModule",{value:!0}),ys.fromMiliseconds=ys.toMiliseconds=void 0;const r=D1();function t(i){return i*r.ONE_THOUSAND}ys.toMiliseconds=t;function e(i){return Math.floor(i/r.ONE_THOUSAND)}return ys.fromMiliseconds=e,ys}var bd;function L6(){return bd||(bd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ha;t.__exportStar(T6(),r),t.__exportStar(B6(),r)}(Mh)),Mh}var Qs={},_d;function q6(){if(_d)return Qs;_d=1,Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const i=this.get(e);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const s=Date.now()-i.started;this.timestamps.set(e,{started:i.started,elapsed:s})}get(e){const i=this.timestamps.get(e);if(typeof i>"u")throw new Error(`No timestamp found for label: ${e}`);return i}elapsed(e){const i=this.get(e);return i.elapsed||Date.now()-i.started}}return Qs.Watch=r,Qs.default=r,Qs}var Oh={},$o={},Ed;function j6(){if(Ed)return $o;Ed=1,Object.defineProperty($o,"__esModule",{value:!0}),$o.IWatch=void 0;class r{}return $o.IWatch=r,$o}var Ad;function $6(){return Ad||(Ad=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),ha.__exportStar(j6(),r)}(Oh)),Oh}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ha;t.__exportStar(L6(),r),t.__exportStar(q6(),r),t.__exportStar($6(),r),t.__exportStar(D1(),r)})(bt);var je={};Object.defineProperty(je,"__esModule",{value:!0});je.getLocalStorage=je.getLocalStorageOrThrow=je.getCrypto=je.getCryptoOrThrow=x1=je.getLocation=je.getLocationOrThrow=jl=je.getNavigator=je.getNavigatorOrThrow=ql=je.getDocument=je.getDocumentOrThrow=je.getFromWindowOrThrow=je.getFromWindow=void 0;function xs(r){let t;return typeof window<"u"&&typeof window[r]<"u"&&(t=window[r]),t}je.getFromWindow=xs;function lo(r){const t=xs(r);if(!t)throw new Error(`${r} is not defined in Window`);return t}je.getFromWindowOrThrow=lo;function z6(){return lo("document")}je.getDocumentOrThrow=z6;function k6(){return xs("document")}var ql=je.getDocument=k6;function H6(){return lo("navigator")}je.getNavigatorOrThrow=H6;function K6(){return xs("navigator")}var jl=je.getNavigator=K6;function V6(){return lo("location")}je.getLocationOrThrow=V6;function G6(){return xs("location")}var x1=je.getLocation=G6;function W6(){return lo("crypto")}je.getCryptoOrThrow=W6;function Y6(){return xs("crypto")}je.getCrypto=Y6;function Q6(){return lo("localStorage")}je.getLocalStorageOrThrow=Q6;function J6(){return xs("localStorage")}je.getLocalStorage=J6;var $l={};Object.defineProperty($l,"__esModule",{value:!0});var M1=$l.getWindowMetadata=void 0;const Sd=je;function X6(){let r,t;try{r=Sd.getDocumentOrThrow(),t=Sd.getLocationOrThrow()}catch{return null}function e(){const E=r.getElementsByTagName("link"),I=[];for(let D=0;D<E.length;D++){const P=E[D],Y=P.getAttribute("rel");if(Y&&Y.toLowerCase().indexOf("icon")>-1){const G=P.getAttribute("href");if(G)if(G.toLowerCase().indexOf("https:")===-1&&G.toLowerCase().indexOf("http:")===-1&&G.indexOf("//")!==0){let tt=t.protocol+"//"+t.host;if(G.indexOf("/")===0)tt+=G;else{const K=t.pathname.split("/");K.pop();const V=K.join("/");tt+=V+"/"+G}I.push(tt)}else if(G.indexOf("//")===0){const tt=t.protocol+G;I.push(tt)}else I.push(G)}}return I}function i(...E){const I=r.getElementsByTagName("meta");for(let D=0;D<I.length;D++){const P=I[D],Y=["itemprop","property","name"].map(G=>P.getAttribute(G)).filter(G=>G?E.includes(G):!1);if(Y.length&&Y){const G=P.getAttribute("content");if(G)return G}}return""}function s(){let E=i("name","og:site_name","og:title","twitter:title");return E||(E=r.title),E}function a(){return i("description","og:description","twitter:description","keywords")}const u=s(),l=a(),d=t.origin,f=e();return{description:l,url:d,icons:f,name:u}}M1=$l.getWindowMetadata=X6;var ra={},Z6=r=>encodeURIComponent(r).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),C1="%[a-f0-9]{2}",Id=new RegExp("("+C1+")|([^%]+?)","gi"),Dd=new RegExp("("+C1+")+","gi");function fl(r,t){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;t=t||1;var e=r.slice(0,t),i=r.slice(t);return Array.prototype.concat.call([],fl(e),fl(i))}function t_(r){try{return decodeURIComponent(r)}catch{for(var t=r.match(Id)||[],e=1;e<t.length;e++)r=fl(t,e).join(""),t=r.match(Id)||[];return r}}function e_(r){for(var t={"%FE%FF":"��","%FF%FE":"��"},e=Dd.exec(r);e;){try{t[e[0]]=decodeURIComponent(e[0])}catch{var i=t_(e[0]);i!==e[0]&&(t[e[0]]=i)}e=Dd.exec(r)}t["%C2"]="�";for(var s=Object.keys(t),a=0;a<s.length;a++){var u=s[a];r=r.replace(new RegExp(u,"g"),t[u])}return r}var r_=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 e_(r)}},i_=(r,t)=>{if(!(typeof r=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(t==="")return[r];const e=r.indexOf(t);return e===-1?[r]:[r.slice(0,e),r.slice(e+t.length)]},n_=function(r,t){for(var e={},i=Object.keys(r),s=Array.isArray(t),a=0;a<i.length;a++){var u=i[a],l=r[u];(s?t.indexOf(u)!==-1:t(u,l,r))&&(e[u]=l)}return e};(function(r){const t=Z6,e=r_,i=i_,s=n_,a=K=>K==null,u=Symbol("encodeFragmentIdentifier");function l(K){switch(K.arrayFormat){case"index":return V=>(B,$)=>{const z=B.length;return $===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?B:$===null?[...B,[w(V,K),"[",z,"]"].join("")]:[...B,[w(V,K),"[",w(z,K),"]=",w($,K)].join("")]};case"bracket":return V=>(B,$)=>$===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?B:$===null?[...B,[w(V,K),"[]"].join("")]:[...B,[w(V,K),"[]=",w($,K)].join("")];case"colon-list-separator":return V=>(B,$)=>$===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?B:$===null?[...B,[w(V,K),":list="].join("")]:[...B,[w(V,K),":list=",w($,K)].join("")];case"comma":case"separator":case"bracket-separator":{const V=K.arrayFormat==="bracket-separator"?"[]=":"=";return B=>($,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?$:(z=z===null?"":z,$.length===0?[[w(B,K),V,w(z,K)].join("")]:[[$,w(z,K)].join(K.arrayFormatSeparator)])}default:return V=>(B,$)=>$===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?B:$===null?[...B,w(V,K)]:[...B,[w(V,K),"=",w($,K)].join("")]}}function d(K){let V;switch(K.arrayFormat){case"index":return(B,$,z)=>{if(V=/\[(\d*)\]$/.exec(B),B=B.replace(/\[\d*\]$/,""),!V){z[B]=$;return}z[B]===void 0&&(z[B]={}),z[B][V[1]]=$};case"bracket":return(B,$,z)=>{if(V=/(\[\])$/.exec(B),B=B.replace(/\[\]$/,""),!V){z[B]=$;return}if(z[B]===void 0){z[B]=[$];return}z[B]=[].concat(z[B],$)};case"colon-list-separator":return(B,$,z)=>{if(V=/(:list)$/.exec(B),B=B.replace(/:list$/,""),!V){z[B]=$;return}if(z[B]===void 0){z[B]=[$];return}z[B]=[].concat(z[B],$)};case"comma":case"separator":return(B,$,z)=>{const v=typeof $=="string"&&$.includes(K.arrayFormatSeparator),T=typeof $=="string"&&!v&&E($,K).includes(K.arrayFormatSeparator);$=T?E($,K):$;const nt=v||T?$.split(K.arrayFormatSeparator).map(ft=>E(ft,K)):$===null?$:E($,K);z[B]=nt};case"bracket-separator":return(B,$,z)=>{const v=/(\[\])$/.test(B);if(B=B.replace(/\[\]$/,""),!v){z[B]=$&&E($,K);return}const T=$===null?[]:$.split(K.arrayFormatSeparator).map(nt=>E(nt,K));if(z[B]===void 0){z[B]=T;return}z[B]=[].concat(z[B],T)};default:return(B,$,z)=>{if(z[B]===void 0){z[B]=$;return}z[B]=[].concat(z[B],$)}}}function f(K){if(typeof K!="string"||K.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function w(K,V){return V.encode?V.strict?t(K):encodeURIComponent(K):K}function E(K,V){return V.decode?e(K):K}function I(K){return Array.isArray(K)?K.sort():typeof K=="object"?I(Object.keys(K)).sort((V,B)=>Number(V)-Number(B)).map(V=>K[V]):K}function D(K){const V=K.indexOf("#");return V!==-1&&(K=K.slice(0,V)),K}function P(K){let V="";const B=K.indexOf("#");return B!==-1&&(V=K.slice(B)),V}function Y(K){K=D(K);const V=K.indexOf("?");return V===-1?"":K.slice(V+1)}function G(K,V){return V.parseNumbers&&!Number.isNaN(Number(K))&&typeof K=="string"&&K.trim()!==""?K=Number(K):V.parseBooleans&&K!==null&&(K.toLowerCase()==="true"||K.toLowerCase()==="false")&&(K=K.toLowerCase()==="true"),K}function tt(K,V){V=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},V),f(V.arrayFormatSeparator);const B=d(V),$=Object.create(null);if(typeof K!="string"||(K=K.trim().replace(/^[?#&]/,""),!K))return $;for(const z of K.split("&")){if(z==="")continue;let[v,T]=i(V.decode?z.replace(/\+/g," "):z,"=");T=T===void 0?null:["comma","separator","bracket-separator"].includes(V.arrayFormat)?T:E(T,V),B(E(v,V),T,$)}for(const z of Object.keys($)){const v=$[z];if(typeof v=="object"&&v!==null)for(const T of Object.keys(v))v[T]=G(v[T],V);else $[z]=G(v,V)}return V.sort===!1?$:(V.sort===!0?Object.keys($).sort():Object.keys($).sort(V.sort)).reduce((z,v)=>{const T=$[v];return T&&typeof T=="object"&&!Array.isArray(T)?z[v]=I(T):z[v]=T,z},Object.create(null))}r.extract=Y,r.parse=tt,r.stringify=(K,V)=>{if(!K)return"";V=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},V),f(V.arrayFormatSeparator);const B=T=>V.skipNull&&a(K[T])||V.skipEmptyString&&K[T]==="",$=l(V),z={};for(const T of Object.keys(K))B(T)||(z[T]=K[T]);const v=Object.keys(z);return V.sort!==!1&&v.sort(V.sort),v.map(T=>{const nt=K[T];return nt===void 0?"":nt===null?w(T,V):Array.isArray(nt)?nt.length===0&&V.arrayFormat==="bracket-separator"?w(T,V)+"[]":nt.reduce($(T),[]).join("&"):w(T,V)+"="+w(nt,V)}).filter(T=>T.length>0).join("&")},r.parseUrl=(K,V)=>{V=Object.assign({decode:!0},V);const[B,$]=i(K,"#");return Object.assign({url:B.split("?")[0]||"",query:tt(Y(K),V)},V&&V.parseFragmentIdentifier&&$?{fragmentIdentifier:E($,V)}:{})},r.stringifyUrl=(K,V)=>{V=Object.assign({encode:!0,strict:!0,[u]:!0},V);const B=D(K.url).split("?")[0]||"",$=r.extract(K.url),z=r.parse($,{sort:!1}),v=Object.assign(z,K.query);let T=r.stringify(v,V);T&&(T=`?${T}`);let nt=P(K.url);return K.fragmentIdentifier&&(nt=`#${V[u]?w(K.fragmentIdentifier,V):K.fragmentIdentifier}`),`${B}${T}${nt}`},r.pick=(K,V,B)=>{B=Object.assign({parseFragmentIdentifier:!0,[u]:!1},B);const{url:$,query:z,fragmentIdentifier:v}=r.parseUrl(K,B);return r.stringifyUrl({url:$,query:s(z,V),fragmentIdentifier:v},B)},r.exclude=(K,V,B)=>{const $=Array.isArray(V)?z=>!V.includes(z):(z,v)=>!V(z,v);return r.pick(K,$,B)}})(ra);var zl={},su={},oe={},P1={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function t(l,d){var f=l>>>16&65535,w=l&65535,E=d>>>16&65535,I=d&65535;return w*I+(f*I+w*E<<16>>>0)|0}r.mul=Math.imul||t;function e(l,d){return l+d|0}r.add=e;function i(l,d){return l-d|0}r.sub=i;function s(l,d){return l<<d|l>>>32-d}r.rotl=s;function a(l,d){return l<<32-d|l>>>d}r.rotr=a;function u(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}r.isInteger=Number.isInteger||u,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(l){return r.isInteger(l)&&l>=-r.MAX_SAFE_INTEGER&&l<=r.MAX_SAFE_INTEGER}})(P1);Object.defineProperty(oe,"__esModule",{value:!0});var O1=P1;function s_(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])<<16>>16}oe.readInt16BE=s_;function o_(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])>>>0}oe.readUint16BE=o_;function a_(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])<<16>>16}oe.readInt16LE=a_;function c_(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])>>>0}oe.readUint16LE=c_;function N1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>8,t[e+1]=r>>>0,t}oe.writeUint16BE=N1;oe.writeInt16BE=N1;function R1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t}oe.writeUint16LE=R1;oe.writeInt16LE=R1;function dl(r,t){return t===void 0&&(t=0),r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}oe.readInt32BE=dl;function pl(r,t){return t===void 0&&(t=0),(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}oe.readUint32BE=pl;function gl(r,t){return t===void 0&&(t=0),r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t]}oe.readInt32LE=gl;function ml(r,t){return t===void 0&&(t=0),(r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t])>>>0}oe.readUint32LE=ml;function Kc(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r>>>0,t}oe.writeUint32BE=Kc;oe.writeInt32BE=Kc;function Vc(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t[e+2]=r>>>16,t[e+3]=r>>>24,t}oe.writeUint32LE=Vc;oe.writeInt32LE=Vc;function u_(r,t){t===void 0&&(t=0);var e=dl(r,t),i=dl(r,t+4);return e*4294967296+i-(i>>31)*4294967296}oe.readInt64BE=u_;function h_(r,t){t===void 0&&(t=0);var e=pl(r,t),i=pl(r,t+4);return e*4294967296+i}oe.readUint64BE=h_;function l_(r,t){t===void 0&&(t=0);var e=gl(r,t),i=gl(r,t+4);return i*4294967296+e-(e>>31)*4294967296}oe.readInt64LE=l_;function f_(r,t){t===void 0&&(t=0);var e=ml(r,t),i=ml(r,t+4);return i*4294967296+e}oe.readUint64LE=f_;function T1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Kc(r/4294967296>>>0,t,e),Kc(r>>>0,t,e+4),t}oe.writeUint64BE=T1;oe.writeInt64BE=T1;function F1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Vc(r>>>0,t,e),Vc(r/4294967296>>>0,t,e+4),t}oe.writeUint64LE=F1;oe.writeInt64LE=F1;function d_(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,s=1,a=r/8+e-1;a>=e;a--)i+=t[a]*s,s*=256;return i}oe.readUintBE=d_;function p_(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,s=1,a=e;a<e+r/8;a++)i+=t[a]*s,s*=256;return i}oe.readUintLE=p_;function g_(r,t,e,i){if(e===void 0&&(e=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!O1.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var s=1,a=r/8+i-1;a>=i;a--)e[a]=t/s&255,s*=256;return e}oe.writeUintBE=g_;function m_(r,t,e,i){if(e===void 0&&(e=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!O1.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,a=i;a<i+r/8;a++)e[a]=t/s&255,s*=256;return e}oe.writeUintLE=m_;function v_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t)}oe.readFloat32BE=v_;function y_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t,!0)}oe.readFloat32LE=y_;function w_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t)}oe.readFloat64BE=w_;function b_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t,!0)}oe.readFloat64LE=b_;function __(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat32(e,r),t}oe.writeFloat32BE=__;function E_(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat32(e,r,!0),t}oe.writeFloat32LE=E_;function A_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat64(e,r),t}oe.writeFloat64BE=A_;function S_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setFloat64(e,r,!0),t}oe.writeFloat64LE=S_;var si={};Object.defineProperty(si,"__esModule",{value:!0});function I_(r){for(var t=0;t<r.length;t++)r[t]=0;return r}si.wipe=I_;Object.defineProperty(su,"__esModule",{value:!0});var br=oe,vl=si,D_=20;function x_(r,t,e){for(var i=1634760805,s=857760878,a=2036477234,u=1797285236,l=e[3]<<24|e[2]<<16|e[1]<<8|e[0],d=e[7]<<24|e[6]<<16|e[5]<<8|e[4],f=e[11]<<24|e[10]<<16|e[9]<<8|e[8],w=e[15]<<24|e[14]<<16|e[13]<<8|e[12],E=e[19]<<24|e[18]<<16|e[17]<<8|e[16],I=e[23]<<24|e[22]<<16|e[21]<<8|e[20],D=e[27]<<24|e[26]<<16|e[25]<<8|e[24],P=e[31]<<24|e[30]<<16|e[29]<<8|e[28],Y=t[3]<<24|t[2]<<16|t[1]<<8|t[0],G=t[7]<<24|t[6]<<16|t[5]<<8|t[4],tt=t[11]<<24|t[10]<<16|t[9]<<8|t[8],K=t[15]<<24|t[14]<<16|t[13]<<8|t[12],V=i,B=s,$=a,z=u,v=l,T=d,nt=f,ft=w,pt=E,mt=I,h=D,y=P,b=Y,M=G,C=tt,R=K,j=0;j<D_;j+=2)V=V+v|0,b^=V,b=b>>>32-16|b<<16,pt=pt+b|0,v^=pt,v=v>>>32-12|v<<12,B=B+T|0,M^=B,M=M>>>32-16|M<<16,mt=mt+M|0,T^=mt,T=T>>>32-12|T<<12,$=$+nt|0,C^=$,C=C>>>32-16|C<<16,h=h+C|0,nt^=h,nt=nt>>>32-12|nt<<12,z=z+ft|0,R^=z,R=R>>>32-16|R<<16,y=y+R|0,ft^=y,ft=ft>>>32-12|ft<<12,$=$+nt|0,C^=$,C=C>>>32-8|C<<8,h=h+C|0,nt^=h,nt=nt>>>32-7|nt<<7,z=z+ft|0,R^=z,R=R>>>32-8|R<<8,y=y+R|0,ft^=y,ft=ft>>>32-7|ft<<7,B=B+T|0,M^=B,M=M>>>32-8|M<<8,mt=mt+M|0,T^=mt,T=T>>>32-7|T<<7,V=V+v|0,b^=V,b=b>>>32-8|b<<8,pt=pt+b|0,v^=pt,v=v>>>32-7|v<<7,V=V+T|0,R^=V,R=R>>>32-16|R<<16,h=h+R|0,T^=h,T=T>>>32-12|T<<12,B=B+nt|0,b^=B,b=b>>>32-16|b<<16,y=y+b|0,nt^=y,nt=nt>>>32-12|nt<<12,$=$+ft|0,M^=$,M=M>>>32-16|M<<16,pt=pt+M|0,ft^=pt,ft=ft>>>32-12|ft<<12,z=z+v|0,C^=z,C=C>>>32-16|C<<16,mt=mt+C|0,v^=mt,v=v>>>32-12|v<<12,$=$+ft|0,M^=$,M=M>>>32-8|M<<8,pt=pt+M|0,ft^=pt,ft=ft>>>32-7|ft<<7,z=z+v|0,C^=z,C=C>>>32-8|C<<8,mt=mt+C|0,v^=mt,v=v>>>32-7|v<<7,B=B+nt|0,b^=B,b=b>>>32-8|b<<8,y=y+b|0,nt^=y,nt=nt>>>32-7|nt<<7,V=V+T|0,R^=V,R=R>>>32-8|R<<8,h=h+R|0,T^=h,T=T>>>32-7|T<<7;br.writeUint32LE(V+i|0,r,0),br.writeUint32LE(B+s|0,r,4),br.writeUint32LE($+a|0,r,8),br.writeUint32LE(z+u|0,r,12),br.writeUint32LE(v+l|0,r,16),br.writeUint32LE(T+d|0,r,20),br.writeUint32LE(nt+f|0,r,24),br.writeUint32LE(ft+w|0,r,28),br.writeUint32LE(pt+E|0,r,32),br.writeUint32LE(mt+I|0,r,36),br.writeUint32LE(h+D|0,r,40),br.writeUint32LE(y+P|0,r,44),br.writeUint32LE(b+Y|0,r,48),br.writeUint32LE(M+G|0,r,52),br.writeUint32LE(C+tt|0,r,56),br.writeUint32LE(R+K|0,r,60)}function U1(r,t,e,i,s){if(s===void 0&&(s=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<e.length)throw new Error("ChaCha: destination is shorter than source");var a,u;if(s===0){if(t.length!==8&&t.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");a=new Uint8Array(16),u=a.length-t.length,a.set(t,u)}else{if(t.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");a=t,u=s}for(var l=new Uint8Array(64),d=0;d<e.length;d+=64){x_(l,a,r);for(var f=d;f<d+64&&f<e.length;f++)i[f]=e[f]^l[f-d];C_(a,0,u)}return vl.wipe(l),s===0&&vl.wipe(a),i}su.streamXOR=U1;function M_(r,t,e,i){return i===void 0&&(i=0),vl.wipe(e),U1(r,t,e,e,i)}su.stream=M_;function C_(r,t,e){for(var i=1;e--;)i=i+(r[t]&255)|0,r[t]=i&255,i>>>=8,t++;if(i>0)throw new Error("ChaCha: counter overflow")}var B1={},Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});function P_(r,t,e){return~(r-1)&t|r-1&e}Qn.select=P_;function O_(r,t){return(r|0)-(t|0)-1>>>31&1}Qn.lessOrEqual=O_;function L1(r,t){if(r.length!==t.length)return 0;for(var e=0,i=0;i<r.length;i++)e|=r[i]^t[i];return 1&e-1>>>8}Qn.compare=L1;function N_(r,t){return r.length===0||t.length===0?!1:L1(r,t)!==0}Qn.equal=N_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=Qn,e=si;r.DIGEST_LENGTH=16;var i=function(){function u(l){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var d=l[0]|l[1]<<8;this._r[0]=d&8191;var f=l[2]|l[3]<<8;this._r[1]=(d>>>13|f<<3)&8191;var w=l[4]|l[5]<<8;this._r[2]=(f>>>10|w<<6)&7939;var E=l[6]|l[7]<<8;this._r[3]=(w>>>7|E<<9)&8191;var I=l[8]|l[9]<<8;this._r[4]=(E>>>4|I<<12)&255,this._r[5]=I>>>1&8190;var D=l[10]|l[11]<<8;this._r[6]=(I>>>14|D<<2)&8191;var P=l[12]|l[13]<<8;this._r[7]=(D>>>11|P<<5)&8065;var Y=l[14]|l[15]<<8;this._r[8]=(P>>>8|Y<<8)&8191,this._r[9]=Y>>>5&127,this._pad[0]=l[16]|l[17]<<8,this._pad[1]=l[18]|l[19]<<8,this._pad[2]=l[20]|l[21]<<8,this._pad[3]=l[22]|l[23]<<8,this._pad[4]=l[24]|l[25]<<8,this._pad[5]=l[26]|l[27]<<8,this._pad[6]=l[28]|l[29]<<8,this._pad[7]=l[30]|l[31]<<8}return u.prototype._blocks=function(l,d,f){for(var w=this._fin?0:2048,E=this._h[0],I=this._h[1],D=this._h[2],P=this._h[3],Y=this._h[4],G=this._h[5],tt=this._h[6],K=this._h[7],V=this._h[8],B=this._h[9],$=this._r[0],z=this._r[1],v=this._r[2],T=this._r[3],nt=this._r[4],ft=this._r[5],pt=this._r[6],mt=this._r[7],h=this._r[8],y=this._r[9];f>=16;){var b=l[d+0]|l[d+1]<<8;E+=b&8191;var M=l[d+2]|l[d+3]<<8;I+=(b>>>13|M<<3)&8191;var C=l[d+4]|l[d+5]<<8;D+=(M>>>10|C<<6)&8191;var R=l[d+6]|l[d+7]<<8;P+=(C>>>7|R<<9)&8191;var j=l[d+8]|l[d+9]<<8;Y+=(R>>>4|j<<12)&8191,G+=j>>>1&8191;var S=l[d+10]|l[d+11]<<8;tt+=(j>>>14|S<<2)&8191;var g=l[d+12]|l[d+13]<<8;K+=(S>>>11|g<<5)&8191;var N=l[d+14]|l[d+15]<<8;V+=(g>>>8|N<<8)&8191,B+=N>>>5|w;var it=0,lt=it;lt+=E*$,lt+=I*(5*y),lt+=D*(5*h),lt+=P*(5*mt),lt+=Y*(5*pt),it=lt>>>13,lt&=8191,lt+=G*(5*ft),lt+=tt*(5*nt),lt+=K*(5*T),lt+=V*(5*v),lt+=B*(5*z),it+=lt>>>13,lt&=8191;var _=it;_+=E*z,_+=I*$,_+=D*(5*y),_+=P*(5*h),_+=Y*(5*mt),it=_>>>13,_&=8191,_+=G*(5*pt),_+=tt*(5*ft),_+=K*(5*nt),_+=V*(5*T),_+=B*(5*v),it+=_>>>13,_&=8191;var Z=it;Z+=E*v,Z+=I*z,Z+=D*$,Z+=P*(5*y),Z+=Y*(5*h),it=Z>>>13,Z&=8191,Z+=G*(5*mt),Z+=tt*(5*pt),Z+=K*(5*ft),Z+=V*(5*nt),Z+=B*(5*T),it+=Z>>>13,Z&=8191;var U=it;U+=E*T,U+=I*v,U+=D*z,U+=P*$,U+=Y*(5*y),it=U>>>13,U&=8191,U+=G*(5*h),U+=tt*(5*mt),U+=K*(5*pt),U+=V*(5*ft),U+=B*(5*nt),it+=U>>>13,U&=8191;var L=it;L+=E*nt,L+=I*T,L+=D*v,L+=P*z,L+=Y*$,it=L>>>13,L&=8191,L+=G*(5*y),L+=tt*(5*h),L+=K*(5*mt),L+=V*(5*pt),L+=B*(5*ft),it+=L>>>13,L&=8191;var k=it;k+=E*ft,k+=I*nt,k+=D*T,k+=P*v,k+=Y*z,it=k>>>13,k&=8191,k+=G*$,k+=tt*(5*y),k+=K*(5*h),k+=V*(5*mt),k+=B*(5*pt),it+=k>>>13,k&=8191;var p=it;p+=E*pt,p+=I*ft,p+=D*nt,p+=P*T,p+=Y*v,it=p>>>13,p&=8191,p+=G*z,p+=tt*$,p+=K*(5*y),p+=V*(5*h),p+=B*(5*mt),it+=p>>>13,p&=8191;var F=it;F+=E*mt,F+=I*pt,F+=D*ft,F+=P*nt,F+=Y*T,it=F>>>13,F&=8191,F+=G*v,F+=tt*z,F+=K*$,F+=V*(5*y),F+=B*(5*h),it+=F>>>13,F&=8191;var et=it;et+=E*h,et+=I*mt,et+=D*pt,et+=P*ft,et+=Y*nt,it=et>>>13,et&=8191,et+=G*T,et+=tt*v,et+=K*z,et+=V*$,et+=B*(5*y),it+=et>>>13,et&=8191;var ut=it;ut+=E*y,ut+=I*h,ut+=D*mt,ut+=P*pt,ut+=Y*ft,it=ut>>>13,ut&=8191,ut+=G*nt,ut+=tt*T,ut+=K*v,ut+=V*z,ut+=B*$,it+=ut>>>13,ut&=8191,it=(it<<2)+it|0,it=it+lt|0,lt=it&8191,it=it>>>13,_+=it,E=lt,I=_,D=Z,P=U,Y=L,G=k,tt=p,K=F,V=et,B=ut,d+=16,f-=16}this._h[0]=E,this._h[1]=I,this._h[2]=D,this._h[3]=P,this._h[4]=Y,this._h[5]=G,this._h[6]=tt,this._h[7]=K,this._h[8]=V,this._h[9]=B},u.prototype.finish=function(l,d){d===void 0&&(d=0);var f=new Uint16Array(10),w,E,I,D;if(this._leftover){for(D=this._leftover,this._buffer[D++]=1;D<16;D++)this._buffer[D]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(w=this._h[1]>>>13,this._h[1]&=8191,D=2;D<10;D++)this._h[D]+=w,w=this._h[D]>>>13,this._h[D]&=8191;for(this._h[0]+=w*5,w=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=w,w=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=w,f[0]=this._h[0]+5,w=f[0]>>>13,f[0]&=8191,D=1;D<10;D++)f[D]=this._h[D]+w,w=f[D]>>>13,f[D]&=8191;for(f[9]-=8192,E=(w^1)-1,D=0;D<10;D++)f[D]&=E;for(E=~E,D=0;D<10;D++)this._h[D]=this._h[D]&E|f[D];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,I=this._h[0]+this._pad[0],this._h[0]=I&65535,D=1;D<8;D++)I=(this._h[D]+this._pad[D]|0)+(I>>>16)|0,this._h[D]=I&65535;return l[d+0]=this._h[0]>>>0,l[d+1]=this._h[0]>>>8,l[d+2]=this._h[1]>>>0,l[d+3]=this._h[1]>>>8,l[d+4]=this._h[2]>>>0,l[d+5]=this._h[2]>>>8,l[d+6]=this._h[3]>>>0,l[d+7]=this._h[3]>>>8,l[d+8]=this._h[4]>>>0,l[d+9]=this._h[4]>>>8,l[d+10]=this._h[5]>>>0,l[d+11]=this._h[5]>>>8,l[d+12]=this._h[6]>>>0,l[d+13]=this._h[6]>>>8,l[d+14]=this._h[7]>>>0,l[d+15]=this._h[7]>>>8,this._finished=!0,this},u.prototype.update=function(l){var d=0,f=l.length,w;if(this._leftover){w=16-this._leftover,w>f&&(w=f);for(var E=0;E<w;E++)this._buffer[this._leftover+E]=l[d+E];if(f-=w,d+=w,this._leftover+=w,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(w=f-f%16,this._blocks(l,d,w),d+=w,f-=w),f){for(var E=0;E<f;E++)this._buffer[this._leftover+E]=l[d+E];this._leftover+=f}return this},u.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var l=new Uint8Array(16);return this.finish(l),l},u.prototype.clean=function(){return e.wipe(this._buffer),e.wipe(this._r),e.wipe(this._h),e.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},u}();r.Poly1305=i;function s(u,l){var d=new i(u);d.update(l);var f=d.digest();return d.clean(),f}r.oneTimeAuth=s;function a(u,l){return u.length!==r.DIGEST_LENGTH||l.length!==r.DIGEST_LENGTH?!1:t.equal(u,l)}r.equal=a})(B1);(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=su,e=B1,i=si,s=oe,a=Qn;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var u=new Uint8Array(16),l=function(){function d(f){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,f.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return d.prototype.seal=function(f,w,E,I){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var D=new Uint8Array(16);D.set(f,D.length-f.length);var P=new Uint8Array(32);t.stream(this._key,D,P,4);var Y=w.length+this.tagLength,G;if(I){if(I.length!==Y)throw new Error("ChaCha20Poly1305: incorrect destination length");G=I}else G=new Uint8Array(Y);return t.streamXOR(this._key,D,w,G,4),this._authenticate(G.subarray(G.length-this.tagLength,G.length),P,G.subarray(0,G.length-this.tagLength),E),i.wipe(D),G},d.prototype.open=function(f,w,E,I){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(w.length<this.tagLength)return null;var D=new Uint8Array(16);D.set(f,D.length-f.length);var P=new Uint8Array(32);t.stream(this._key,D,P,4);var Y=new Uint8Array(this.tagLength);if(this._authenticate(Y,P,w.subarray(0,w.length-this.tagLength),E),!a.equal(Y,w.subarray(w.length-this.tagLength,w.length)))return null;var G=w.length-this.tagLength,tt;if(I){if(I.length!==G)throw new Error("ChaCha20Poly1305: incorrect destination length");tt=I}else tt=new Uint8Array(G);return t.streamXOR(this._key,D,w.subarray(0,w.length-this.tagLength),tt,4),i.wipe(D),tt},d.prototype.clean=function(){return i.wipe(this._key),this},d.prototype._authenticate=function(f,w,E,I){var D=new e.Poly1305(w);I&&(D.update(I),I.length%16>0&&D.update(u.subarray(I.length%16))),D.update(E),E.length%16>0&&D.update(u.subarray(E.length%16));var P=new Uint8Array(8);I&&s.writeUint64LE(I.length,P),D.update(P),s.writeUint64LE(E.length,P),D.update(P);for(var Y=D.digest(),G=0;G<Y.length;G++)f[G]=Y[G];D.clean(),i.wipe(Y),i.wipe(P)},d}();r.ChaCha20Poly1305=l})(zl);var q1={},la={},kl={};Object.defineProperty(kl,"__esModule",{value:!0});function R_(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}kl.isSerializableHash=R_;Object.defineProperty(la,"__esModule",{value:!0});var Gi=kl,T_=Qn,F_=si,j1=function(){function r(t,e){this._finished=!1,this._inner=new t,this._outer=new t,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);e.length>this.blockSize?this._inner.update(e).finish(i).clean():i.set(e);for(var s=0;s<i.length;s++)i[s]^=54;this._inner.update(i);for(var s=0;s<i.length;s++)i[s]^=106;this._outer.update(i),Gi.isSerializableHash(this._inner)&&Gi.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),F_.wipe(i)}return r.prototype.reset=function(){if(!Gi.isSerializableHash(this._inner)||!Gi.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){Gi.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Gi.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(t){return this._inner.update(t),this},r.prototype.finish=function(t){return this._finished?(this._outer.finish(t),this):(this._inner.finish(t),this._outer.update(t.subarray(0,this.digestLength)).finish(t),this._finished=!0,this)},r.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},r.prototype.saveState=function(){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(t){if(!Gi.isSerializableHash(this._inner)||!Gi.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(t),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(t){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(t)},r}();la.HMAC=j1;function U_(r,t,e){var i=new j1(r,t);i.update(e);var s=i.digest();return i.clean(),s}la.hmac=U_;la.equal=T_.equal;Object.defineProperty(q1,"__esModule",{value:!0});var xd=la,Md=si,B_=function(){function r(t,e,i,s){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=t,this._info=s;var a=xd.hmac(this._hash,i,e);this._hmac=new xd.HMAC(t,a),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var t=this._counter[0];if(t===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),t>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(t){for(var e=new Uint8Array(t),i=0;i<e.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),e[i]=this._buffer[this._bufpos++];return e},r.prototype.clean=function(){this._hmac.clean(),Md.wipe(this._buffer),Md.wipe(this._counter),this._bufpos=0},r}(),L_=q1.HKDF=B_,fo={},ou={},au={};Object.defineProperty(au,"__esModule",{value:!0});au.BrowserRandomSource=void 0;const Cd=65536;class q_{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t=typeof self<"u"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let i=0;i<e.length;i+=Cd)this._crypto.getRandomValues(e.subarray(i,i+Math.min(e.length-i,Cd)));return e}}au.BrowserRandomSource=q_;var cu={};Object.defineProperty(cu,"__esModule",{value:!0});cu.NodeRandomSource=void 0;const j_=si;class $_{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof X3<"u"){const t=Z3();t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(t);for(let s=0;s<i.length;s++)i[s]=e[s];return(0,j_.wipe)(e),i}}cu.NodeRandomSource=$_;Object.defineProperty(ou,"__esModule",{value:!0});ou.SystemRandomSource=void 0;const z_=au,k_=cu;class H_{constructor(){if(this.isAvailable=!1,this.name="",this._source=new z_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new k_.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}ou.SystemRandomSource=H_;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const t=ou,e=oe,i=si;r.defaultRandomSource=new t.SystemRandomSource;function s(f,w=r.defaultRandomSource){return w.randomBytes(f)}r.randomBytes=s;function a(f=r.defaultRandomSource){const w=s(4,f),E=(0,e.readUint32LE)(w);return(0,i.wipe)(w),E}r.randomUint32=a;const u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(f,w=u,E=r.defaultRandomSource){if(w.length<2)throw new Error("randomString charset is too short");if(w.length>256)throw new Error("randomString charset is too long");let I="";const D=w.length,P=256-256%D;for(;f>0;){const Y=s(Math.ceil(f*256/P),E);for(let G=0;G<Y.length&&f>0;G++){const tt=Y[G];tt<P&&(I+=w.charAt(tt%D),f--)}(0,i.wipe)(Y)}return I}r.randomString=l;function d(f,w=u,E=r.defaultRandomSource){const I=Math.ceil(f/(Math.log(w.length)/Math.LN2));return l(I,w,E)}r.randomStringForEntropy=d})(fo);var uu={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=si;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function l(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return l.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._temp),this.reset()},l.prototype.update=function(d,f){if(f===void 0&&(f=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=d[w++],f--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._temp,this._state,d,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=d[w++],f--;return this},l.prototype.finish=function(d){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,I=f<<3,D=f%64<56?64:128;this._buffer[w]=128;for(var P=w+1;P<D-8;P++)this._buffer[P]=0;t.writeUint32BE(E,this._buffer,D-8),t.writeUint32BE(I,this._buffer,D-4),a(this._temp,this._state,this._buffer,0,D),this._finished=!0}for(var P=0;P<this.digestLength/4;P++)t.writeUint32BE(this._state[P],d,P*4);return this},l.prototype.digest=function(){var d=new Uint8Array(this.digestLength);return this.finish(d),d},l.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},l.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(d){e.wipe(d.state),d.buffer&&e.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},l}();r.SHA256=i;var s=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function a(l,d,f,w,E){for(;E>=64;){for(var I=d[0],D=d[1],P=d[2],Y=d[3],G=d[4],tt=d[5],K=d[6],V=d[7],B=0;B<16;B++){var $=w+B*4;l[B]=t.readUint32BE(f,$)}for(var B=16;B<64;B++){var z=l[B-2],v=(z>>>17|z<<32-17)^(z>>>19|z<<32-19)^z>>>10;z=l[B-15];var T=(z>>>7|z<<32-7)^(z>>>18|z<<32-18)^z>>>3;l[B]=(v+l[B-7]|0)+(T+l[B-16]|0)}for(var B=0;B<64;B++){var v=(((G>>>6|G<<26)^(G>>>11|G<<21)^(G>>>25|G<<7))+(G&tt^~G&K)|0)+(V+(s[B]+l[B]|0)|0)|0,T=((I>>>2|I<<32-2)^(I>>>13|I<<32-13)^(I>>>22|I<<32-22))+(I&D^I&P^D&P)|0;V=K,K=tt,tt=G,G=Y+v|0,Y=P,P=D,D=I,I=v+T|0}d[0]+=I,d[1]+=D,d[2]+=P,d[3]+=Y,d[4]+=G,d[5]+=tt,d[6]+=K,d[7]+=V,w+=64,E-=64}return w}function u(l){var d=new i;d.update(l);var f=d.digest();return d.clean(),f}r.hash=u})(uu);var Hl={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const t=fo,e=si;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(B){const $=new Float64Array(16);if(B)for(let z=0;z<B.length;z++)$[z]=B[z];return $}const s=new Uint8Array(32);s[0]=9;const a=i([56129,1]);function u(B){let $=1;for(let z=0;z<16;z++){let v=B[z]+$+65535;$=Math.floor(v/65536),B[z]=v-$*65536}B[0]+=$-1+37*($-1)}function l(B,$,z){const v=~(z-1);for(let T=0;T<16;T++){const nt=v&(B[T]^$[T]);B[T]^=nt,$[T]^=nt}}function d(B,$){const z=i(),v=i();for(let T=0;T<16;T++)v[T]=$[T];u(v),u(v),u(v);for(let T=0;T<2;T++){z[0]=v[0]-65517;for(let ft=1;ft<15;ft++)z[ft]=v[ft]-65535-(z[ft-1]>>16&1),z[ft-1]&=65535;z[15]=v[15]-32767-(z[14]>>16&1);const nt=z[15]>>16&1;z[14]&=65535,l(v,z,1-nt)}for(let T=0;T<16;T++)B[2*T]=v[T]&255,B[2*T+1]=v[T]>>8}function f(B,$){for(let z=0;z<16;z++)B[z]=$[2*z]+($[2*z+1]<<8);B[15]&=32767}function w(B,$,z){for(let v=0;v<16;v++)B[v]=$[v]+z[v]}function E(B,$,z){for(let v=0;v<16;v++)B[v]=$[v]-z[v]}function I(B,$,z){let v,T,nt=0,ft=0,pt=0,mt=0,h=0,y=0,b=0,M=0,C=0,R=0,j=0,S=0,g=0,N=0,it=0,lt=0,_=0,Z=0,U=0,L=0,k=0,p=0,F=0,et=0,ut=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=z[0],Bt=z[1],_t=z[2],Et=z[3],Vt=z[4],yt=z[5],At=z[6],Ut=z[7],wt=z[8],Ct=z[9],Lt=z[10],Ot=z[11],Nt=z[12],se=z[13],Tt=z[14],Rt=z[15];v=$[0],nt+=v*xt,ft+=v*Bt,pt+=v*_t,mt+=v*Et,h+=v*Vt,y+=v*yt,b+=v*At,M+=v*Ut,C+=v*wt,R+=v*Ct,j+=v*Lt,S+=v*Ot,g+=v*Nt,N+=v*se,it+=v*Tt,lt+=v*Rt,v=$[1],ft+=v*xt,pt+=v*Bt,mt+=v*_t,h+=v*Et,y+=v*Vt,b+=v*yt,M+=v*At,C+=v*Ut,R+=v*wt,j+=v*Ct,S+=v*Lt,g+=v*Ot,N+=v*Nt,it+=v*se,lt+=v*Tt,_+=v*Rt,v=$[2],pt+=v*xt,mt+=v*Bt,h+=v*_t,y+=v*Et,b+=v*Vt,M+=v*yt,C+=v*At,R+=v*Ut,j+=v*wt,S+=v*Ct,g+=v*Lt,N+=v*Ot,it+=v*Nt,lt+=v*se,_+=v*Tt,Z+=v*Rt,v=$[3],mt+=v*xt,h+=v*Bt,y+=v*_t,b+=v*Et,M+=v*Vt,C+=v*yt,R+=v*At,j+=v*Ut,S+=v*wt,g+=v*Ct,N+=v*Lt,it+=v*Ot,lt+=v*Nt,_+=v*se,Z+=v*Tt,U+=v*Rt,v=$[4],h+=v*xt,y+=v*Bt,b+=v*_t,M+=v*Et,C+=v*Vt,R+=v*yt,j+=v*At,S+=v*Ut,g+=v*wt,N+=v*Ct,it+=v*Lt,lt+=v*Ot,_+=v*Nt,Z+=v*se,U+=v*Tt,L+=v*Rt,v=$[5],y+=v*xt,b+=v*Bt,M+=v*_t,C+=v*Et,R+=v*Vt,j+=v*yt,S+=v*At,g+=v*Ut,N+=v*wt,it+=v*Ct,lt+=v*Lt,_+=v*Ot,Z+=v*Nt,U+=v*se,L+=v*Tt,k+=v*Rt,v=$[6],b+=v*xt,M+=v*Bt,C+=v*_t,R+=v*Et,j+=v*Vt,S+=v*yt,g+=v*At,N+=v*Ut,it+=v*wt,lt+=v*Ct,_+=v*Lt,Z+=v*Ot,U+=v*Nt,L+=v*se,k+=v*Tt,p+=v*Rt,v=$[7],M+=v*xt,C+=v*Bt,R+=v*_t,j+=v*Et,S+=v*Vt,g+=v*yt,N+=v*At,it+=v*Ut,lt+=v*wt,_+=v*Ct,Z+=v*Lt,U+=v*Ot,L+=v*Nt,k+=v*se,p+=v*Tt,F+=v*Rt,v=$[8],C+=v*xt,R+=v*Bt,j+=v*_t,S+=v*Et,g+=v*Vt,N+=v*yt,it+=v*At,lt+=v*Ut,_+=v*wt,Z+=v*Ct,U+=v*Lt,L+=v*Ot,k+=v*Nt,p+=v*se,F+=v*Tt,et+=v*Rt,v=$[9],R+=v*xt,j+=v*Bt,S+=v*_t,g+=v*Et,N+=v*Vt,it+=v*yt,lt+=v*At,_+=v*Ut,Z+=v*wt,U+=v*Ct,L+=v*Lt,k+=v*Ot,p+=v*Nt,F+=v*se,et+=v*Tt,ut+=v*Rt,v=$[10],j+=v*xt,S+=v*Bt,g+=v*_t,N+=v*Et,it+=v*Vt,lt+=v*yt,_+=v*At,Z+=v*Ut,U+=v*wt,L+=v*Ct,k+=v*Lt,p+=v*Ot,F+=v*Nt,et+=v*se,ut+=v*Tt,at+=v*Rt,v=$[11],S+=v*xt,g+=v*Bt,N+=v*_t,it+=v*Et,lt+=v*Vt,_+=v*yt,Z+=v*At,U+=v*Ut,L+=v*wt,k+=v*Ct,p+=v*Lt,F+=v*Ot,et+=v*Nt,ut+=v*se,at+=v*Tt,Mt+=v*Rt,v=$[12],g+=v*xt,N+=v*Bt,it+=v*_t,lt+=v*Et,_+=v*Vt,Z+=v*yt,U+=v*At,L+=v*Ut,k+=v*wt,p+=v*Ct,F+=v*Lt,et+=v*Ot,ut+=v*Nt,at+=v*se,Mt+=v*Tt,Pt+=v*Rt,v=$[13],N+=v*xt,it+=v*Bt,lt+=v*_t,_+=v*Et,Z+=v*Vt,U+=v*yt,L+=v*At,k+=v*Ut,p+=v*wt,F+=v*Ct,et+=v*Lt,ut+=v*Ot,at+=v*Nt,Mt+=v*se,Pt+=v*Tt,It+=v*Rt,v=$[14],it+=v*xt,lt+=v*Bt,_+=v*_t,Z+=v*Et,U+=v*Vt,L+=v*yt,k+=v*At,p+=v*Ut,F+=v*wt,et+=v*Ct,ut+=v*Lt,at+=v*Ot,Mt+=v*Nt,Pt+=v*se,It+=v*Tt,Ee+=v*Rt,v=$[15],lt+=v*xt,_+=v*Bt,Z+=v*_t,U+=v*Et,L+=v*Vt,k+=v*yt,p+=v*At,F+=v*Ut,et+=v*wt,ut+=v*Ct,at+=v*Lt,Mt+=v*Ot,Pt+=v*Nt,It+=v*se,Ee+=v*Tt,$t+=v*Rt,nt+=38*_,ft+=38*Z,pt+=38*U,mt+=38*L,h+=38*k,y+=38*p,b+=38*F,M+=38*et,C+=38*ut,R+=38*at,j+=38*Mt,S+=38*Pt,g+=38*It,N+=38*Ee,it+=38*$t,T=1,v=nt+T+65535,T=Math.floor(v/65536),nt=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=mt+T+65535,T=Math.floor(v/65536),mt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=R+T+65535,T=Math.floor(v/65536),R=v-T*65536,v=j+T+65535,T=Math.floor(v/65536),j=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=g+T+65535,T=Math.floor(v/65536),g=v-T*65536,v=N+T+65535,T=Math.floor(v/65536),N=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,nt+=T-1+37*(T-1),T=1,v=nt+T+65535,T=Math.floor(v/65536),nt=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=mt+T+65535,T=Math.floor(v/65536),mt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=R+T+65535,T=Math.floor(v/65536),R=v-T*65536,v=j+T+65535,T=Math.floor(v/65536),j=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=g+T+65535,T=Math.floor(v/65536),g=v-T*65536,v=N+T+65535,T=Math.floor(v/65536),N=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,nt+=T-1+37*(T-1),B[0]=nt,B[1]=ft,B[2]=pt,B[3]=mt,B[4]=h,B[5]=y,B[6]=b,B[7]=M,B[8]=C,B[9]=R,B[10]=j,B[11]=S,B[12]=g,B[13]=N,B[14]=it,B[15]=lt}function D(B,$){I(B,$,$)}function P(B,$){const z=i();for(let v=0;v<16;v++)z[v]=$[v];for(let v=253;v>=0;v--)D(z,z),v!==2&&v!==4&&I(z,z,$);for(let v=0;v<16;v++)B[v]=z[v]}function Y(B,$){const z=new Uint8Array(32),v=new Float64Array(80),T=i(),nt=i(),ft=i(),pt=i(),mt=i(),h=i();for(let C=0;C<31;C++)z[C]=B[C];z[31]=B[31]&127|64,z[0]&=248,f(v,$);for(let C=0;C<16;C++)nt[C]=v[C];T[0]=pt[0]=1;for(let C=254;C>=0;--C){const R=z[C>>>3]>>>(C&7)&1;l(T,nt,R),l(ft,pt,R),w(mt,T,ft),E(T,T,ft),w(ft,nt,pt),E(nt,nt,pt),D(pt,mt),D(h,T),I(T,ft,T),I(ft,nt,mt),w(mt,T,ft),E(T,T,ft),D(nt,T),E(ft,pt,h),I(T,ft,a),w(T,T,pt),I(ft,ft,T),I(T,pt,h),I(pt,nt,v),D(nt,mt),l(T,nt,R),l(ft,pt,R)}for(let C=0;C<16;C++)v[C+16]=T[C],v[C+32]=ft[C],v[C+48]=nt[C],v[C+64]=pt[C];const y=v.subarray(32),b=v.subarray(16);P(y,y),I(b,b,y);const M=new Uint8Array(32);return d(M,b),M}r.scalarMult=Y;function G(B){return Y(B,s)}r.scalarMultBase=G;function tt(B){if(B.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const $=new Uint8Array(B);return{publicKey:G($),secretKey:$}}r.generateKeyPairFromSeed=tt;function K(B){const $=(0,t.randomBytes)(32,B),z=tt($);return(0,e.wipe)($),z}r.generateKeyPair=K;function V(B,$,z=!1){if(B.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if($.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const v=Y(B,$);if(z){let T=0;for(let nt=0;nt<v.length;nt++)T|=v[nt];if(T===0)throw new Error("X25519: invalid shared key")}return v}r.sharedKey=V})(Hl);function $1(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function yl(r,t){t||(t=r.reduce((s,a)=>s+a.length,0));const e=$1(t);let i=0;for(const s of r)e.set(s,i),i+=s.length;return e}function K_(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),i=0;i<e.length;i++)e[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),u=a.charCodeAt(0);if(e[u]!==255)throw new TypeError(a+" is ambiguous");e[u]=s}var l=r.length,d=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var Y=0,G=0,tt=0,K=P.length;tt!==K&&P[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var $=P[tt],z=0,v=V-1;($!==0||z<G)&&v!==-1;v--,z++)$+=256*B[v]>>>0,B[v]=$%l>>>0,$=$/l>>>0;if($!==0)throw new Error("Non-zero carry");G=z,tt++}for(var T=V-G;T!==V&&B[T]===0;)T++;for(var nt=d.repeat(Y);T<V;++T)nt+=r.charAt(B[T]);return nt}function I(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var Y=0;if(P[Y]!==" "){for(var G=0,tt=0;P[Y]===d;)G++,Y++;for(var K=(P.length-Y)*f+1>>>0,V=new Uint8Array(K);P[Y];){var B=e[P.charCodeAt(Y)];if(B===255)return;for(var $=0,z=K-1;(B!==0||$<tt)&&z!==-1;z--,$++)B+=l*V[z]>>>0,V[z]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=$,Y++}if(P[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(G+(K-v)),nt=G;v!==K;)T[nt++]=V[v++];return T}}}function D(P){var Y=I(P);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:I,decode:D}}var V_=K_,G_=V_;const W_=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")},Y_=r=>new TextEncoder().encode(r),Q_=r=>new TextDecoder().decode(r);class J_{constructor(t,e,i){this.name=t,this.prefix=e,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class X_{constructor(t,e,i){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return z1(this,t)}}class Z_{constructor(t){this.decoders=t}or(t){return z1(this,t)}decode(t){const e=t[0],i=this.decoders[e];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const z1=(r,t)=>new Z_({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class tE{constructor(t,e,i,s){this.name=t,this.prefix=e,this.baseEncode=i,this.baseDecode=s,this.encoder=new J_(t,e,i),this.decoder=new X_(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const hu=({name:r,prefix:t,encode:e,decode:i})=>new tE(r,t,e,i),fa=({prefix:r,name:t,alphabet:e})=>{const{encode:i,decode:s}=G_(e,t);return hu({prefix:r,name:t,encode:i,decode:a=>W_(s(a))})},eE=(r,t,e,i)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const u=new Uint8Array(a*e/8|0);let l=0,d=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);d=d<<e|E,l+=e,l>=8&&(l-=8,u[f++]=255&d>>l)}if(l>=e||255&d<<8-l)throw new SyntaxError("Unexpected end of data");return u},rE=(r,t,e)=>{const i=t[t.length-1]==="=",s=(1<<e)-1;let a="",u=0,l=0;for(let d=0;d<r.length;++d)for(l=l<<8|r[d],u+=8;u>e;)u-=e,a+=t[s&l>>u];if(u&&(a+=t[s&l<<e-u]),i)for(;a.length*e&7;)a+="=";return a},mr=({name:r,prefix:t,bitsPerChar:e,alphabet:i})=>hu({prefix:t,name:r,encode(s){return rE(s,i,e)},decode(s){return eE(s,i,e,r)}}),iE=hu({prefix:"\0",name:"identity",encode:r=>Q_(r),decode:r=>Y_(r)}),nE=Object.freeze(Object.defineProperty({__proto__:null,identity:iE},Symbol.toStringTag,{value:"Module"})),sE=mr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),oE=Object.freeze(Object.defineProperty({__proto__:null,base2:sE},Symbol.toStringTag,{value:"Module"})),aE=mr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),cE=Object.freeze(Object.defineProperty({__proto__:null,base8:aE},Symbol.toStringTag,{value:"Module"})),uE=fa({prefix:"9",name:"base10",alphabet:"0123456789"}),hE=Object.freeze(Object.defineProperty({__proto__:null,base10:uE},Symbol.toStringTag,{value:"Module"})),lE=mr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fE=mr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dE=Object.freeze(Object.defineProperty({__proto__:null,base16:lE,base16upper:fE},Symbol.toStringTag,{value:"Module"})),pE=mr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gE=mr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mE=mr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vE=mr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yE=mr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wE=mr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bE=mr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_E=mr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),EE=mr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),AE=Object.freeze(Object.defineProperty({__proto__:null,base32:pE,base32hex:yE,base32hexpad:bE,base32hexpadupper:_E,base32hexupper:wE,base32pad:mE,base32padupper:vE,base32upper:gE,base32z:EE},Symbol.toStringTag,{value:"Module"})),SE=fa({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),IE=fa({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),DE=Object.freeze(Object.defineProperty({__proto__:null,base36:SE,base36upper:IE},Symbol.toStringTag,{value:"Module"})),xE=fa({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ME=fa({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),CE=Object.freeze(Object.defineProperty({__proto__:null,base58btc:xE,base58flickr:ME},Symbol.toStringTag,{value:"Module"})),PE=mr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),OE=mr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),NE=mr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),RE=mr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),TE=Object.freeze(Object.defineProperty({__proto__:null,base64:PE,base64pad:OE,base64url:NE,base64urlpad:RE},Symbol.toStringTag,{value:"Module"})),k1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),FE=k1.reduce((r,t,e)=>(r[e]=t,r),[]),UE=k1.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function BE(r){return r.reduce((t,e)=>(t+=FE[e],t),"")}function LE(r){const t=[];for(const e of r){const i=UE[e.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(i)}return new Uint8Array(t)}const qE=hu({prefix:"🚀",name:"base256emoji",encode:BE,decode:LE}),jE=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:qE},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Pd={...nE,...oE,...cE,...hE,...dE,...AE,...DE,...CE,...TE,...jE};function H1(r,t,e,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:i}}}const Od=H1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Nh=H1("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=$1(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),K1={utf8:Od,"utf-8":Od,hex:Pd.base16,latin1:Nh,ascii:Nh,binary:Nh,...Pd};function Hr(r,t="utf8"){const e=K1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):e.decoder.decode(`${e.prefix}${r}`)}function Rr(r,t="utf8"){const e=K1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}const $E={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"}},zE=":";function Fc(r){const[t,e]=r.split(zE);return{namespace:t,reference:e}}function Nd(r,t=[]){const e=[];return Object.keys(r).forEach(i=>{if(t.length&&!t.includes(i))return;const s=r[i];e.push(...s.accounts)}),e}function V1(r,t){return r.includes(":")?[r]:t.chains||[]}var kE=Object.defineProperty,Rd=Object.getOwnPropertySymbols,HE=Object.prototype.hasOwnProperty,KE=Object.prototype.propertyIsEnumerable,Td=(r,t,e)=>t in r?kE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fd=(r,t)=>{for(var e in t||(t={}))HE.call(t,e)&&Td(r,e,t[e]);if(Rd)for(var e of Rd(t))KE.call(t,e)&&Td(r,e,t[e]);return r};const VE="ReactNative",ei={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},GE="js";function ia(){return typeof ri<"u"&&typeof ri.versions<"u"&&typeof ri.versions.node<"u"}function po(){return!ql()&&!!jl()&&navigator.product===VE}function go(){return!ia()&&!!jl()&&!!ql()}function da(){return po()?ei.reactNative:ia()?ei.node:go()?ei.browser:ei.unknown}function WE(){var r;try{return po()&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Application)<"u"?(r=Ie.Application)==null?void 0:r.applicationId:void 0}catch{return}}function YE(r,t){let e=ra.parse(r);return e=Fd(Fd({},e),t),r=ra.stringify(e),r}function QE(){return M1()||{name:"",description:"",url:"",icons:[""]}}function JE(){if(da()===ei.reactNative&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Platform)<"u"){const{OS:e,Version:i}=Ie.Platform;return[e,i].join("-")}const r=u6();if(r===null)return"unknown";const t=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[t,r.name,r.version].join("-"):[t,r.version].join("-")}function XE(){var r;const t=da();return t===ei.browser?[t,((r=x1())==null?void 0:r.host)||"unknown"].join(":"):t}function ZE(r,t,e){const i=JE(),s=XE();return[[r,t].join("-"),[GE,e].join("-"),i,s].join("/")}function t5({protocol:r,version:t,relayUrl:e,sdkVersion:i,auth:s,projectId:a,useOnCloseEvent:u,bundleId:l}){const d=e.split("?"),f=ZE(r,t,i),w={auth:s,ua:f,projectId:a,useOnCloseEvent:u||void 0,origin:l||void 0},E=YE(d[1]||"",w);return d[0]+"?"+E}function Es(r,t){return r.filter(e=>t.includes(e)).length===r.length}function G1(r){return Object.fromEntries(r.entries())}function W1(r){return new Map(Object.entries(r))}function _s(r=bt.FIVE_MINUTES,t){const e=bt.toMiliseconds(r||bt.FIVE_MINUTES);let i,s,a;return{resolve:u=>{a&&i&&(clearTimeout(a),i(u))},reject:u=>{a&&s&&(clearTimeout(a),s(u))},done:()=>new Promise((u,l)=>{a=setTimeout(()=>{l(new Error(t))},e),i=u,s=l})}}function so(r,t,e){return new Promise(async(i,s)=>{const a=setTimeout(()=>s(new Error(e)),t);try{const u=await r;i(u)}catch(u){s(u)}clearTimeout(a)})}function Y1(r,t){if(typeof t=="string"&&t.startsWith(`${r}:`))return t;if(r.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(r.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${r}`)}function e5(r){return Y1("topic",r)}function r5(r){return Y1("id",r)}function Q1(r){const[t,e]=r.split(":"),i={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")i.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))i.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return i}function pr(r,t){return bt.fromMiliseconds((t||Date.now())+bt.toMiliseconds(r))}function kn(r){return Date.now()>=bt.toMiliseconds(r)}function de(r,t){return`${r}${t?`:${t}`:""}`}function Uc(r=[],t=[]){return[...new Set([...r,...t])]}async function i5({id:r,topic:t,wcDeepLink:e}){try{if(!e)return;const i=typeof e=="string"?JSON.parse(e):e;let s=i==null?void 0:i.href;if(typeof s!="string")return;s.endsWith("/")&&(s=s.slice(0,-1));const a=`${s}/wc?requestId=${r}&sessionTopic=${t}`,u=da();u===ei.browser?a.startsWith("https://")||a.startsWith("http://")?window.open(a,"_blank","noreferrer noopener"):window.open(a,"_self","noreferrer noopener"):u===ei.reactNative&&typeof(Ie==null?void 0:Ie.Linking)<"u"&&await Ie.Linking.openURL(a)}catch(i){console.error(i)}}async function n5(r,t){try{return await r.getItem(t)||(go()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}var J1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{};function s5(r){var t=r.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var X1={exports:{}};/**
15
+ * [js-sha3]{@link https://github.com/emn178/js-sha3}
16
+ *
17
+ * @version 0.8.0
18
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
19
+ * @copyright Chen, Yi-Cyuan 2015-2018
20
+ * @license MIT
21
+ */(function(r){(function(){var t="input is invalid type",e="finalize already called",i=typeof window=="object",s=i?window:{};s.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",u=!s.JS_SHA3_NO_NODE_JS&&typeof ri=="object"&&ri.versions&&ri.versions.node;u?s=J1:a&&(s=self);var l=!s.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,d=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),w=[31,7936,2031616,520093696],E=[4,1024,262144,67108864],I=[1,256,65536,16777216],D=[6,1536,393216,100663296],P=[0,8,16,24],Y=[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],tt=[128,256],K=["hex","buffer","arrayBuffer","array","digest"],V={128:168,256:136};(s.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(_){return Object.prototype.toString.call(_)==="[object Array]"}),d&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(_){return typeof _=="object"&&_.buffer&&_.buffer.constructor===ArrayBuffer});for(var B=function(_,Z,U){return function(L){return new N(_,Z,_).update(L)[U]()}},$=function(_,Z,U){return function(L,k){return new N(_,Z,k).update(L)[U]()}},z=function(_,Z,U){return function(L,k,p,F){return y["cshake"+_].update(L,k,p,F)[U]()}},v=function(_,Z,U){return function(L,k,p,F){return y["kmac"+_].update(L,k,p,F)[U]()}},T=function(_,Z,U,L){for(var k=0;k<K.length;++k){var p=K[k];_[p]=Z(U,L,p)}return _},nt=function(_,Z){var U=B(_,Z,"hex");return U.create=function(){return new N(_,Z,_)},U.update=function(L){return U.create().update(L)},T(U,B,_,Z)},ft=function(_,Z){var U=$(_,Z,"hex");return U.create=function(L){return new N(_,Z,L)},U.update=function(L,k){return U.create(k).update(L)},T(U,$,_,Z)},pt=function(_,Z){var U=V[_],L=z(_,Z,"hex");return L.create=function(k,p,F){return!p&&!F?y["shake"+_].create(k):new N(_,Z,k).bytepad([p,F],U)},L.update=function(k,p,F,et){return L.create(p,F,et).update(k)},T(L,z,_,Z)},mt=function(_,Z){var U=V[_],L=v(_,Z,"hex");return L.create=function(k,p,F){return new it(_,Z,p).bytepad(["KMAC",F],U).bytepad([k],U)},L.update=function(k,p,F,et){return L.create(k,F,et).update(p)},T(L,v,_,Z)},h=[{name:"keccak",padding:I,bits:G,createMethod:nt},{name:"sha3",padding:D,bits:G,createMethod:nt},{name:"shake",padding:w,bits:tt,createMethod:ft},{name:"cshake",padding:E,bits:tt,createMethod:pt},{name:"kmac",padding:E,bits:tt,createMethod:mt}],y={},b=[],M=0;M<h.length;++M)for(var C=h[M],R=C.bits,j=0;j<R.length;++j){var S=C.name+"_"+R[j];if(b.push(S),y[S]=C.createMethod(R[j],C.padding),C.name!=="sha3"){var g=C.name+R[j];b.push(g),y[g]=y[S]}}function N(_,Z,U){this.blocks=[],this.s=[],this.padding=Z,this.outputBits=U,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(_<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=U>>5,this.extraBytes=(U&31)>>3;for(var L=0;L<50;++L)this.s[L]=0}N.prototype.update=function(_){if(this.finalized)throw new Error(e);var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(d&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!d||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}for(var L=this.blocks,k=this.byteCount,p=_.length,F=this.blockCount,et=0,ut=this.s,at,Mt;et<p;){if(this.reset)for(this.reset=!1,L[0]=this.block,at=1;at<F+1;++at)L[at]=0;if(Z)for(at=this.start;et<p&&at<k;++et)L[at>>2]|=_[et]<<P[at++&3];else for(at=this.start;et<p&&at<k;++et)Mt=_.charCodeAt(et),Mt<128?L[at>>2]|=Mt<<P[at++&3]:Mt<2048?(L[at>>2]|=(192|Mt>>6)<<P[at++&3],L[at>>2]|=(128|Mt&63)<<P[at++&3]):Mt<55296||Mt>=57344?(L[at>>2]|=(224|Mt>>12)<<P[at++&3],L[at>>2]|=(128|Mt>>6&63)<<P[at++&3],L[at>>2]|=(128|Mt&63)<<P[at++&3]):(Mt=65536+((Mt&1023)<<10|_.charCodeAt(++et)&1023),L[at>>2]|=(240|Mt>>18)<<P[at++&3],L[at>>2]|=(128|Mt>>12&63)<<P[at++&3],L[at>>2]|=(128|Mt>>6&63)<<P[at++&3],L[at>>2]|=(128|Mt&63)<<P[at++&3]);if(this.lastByteIndex=at,at>=k){for(this.start=at-k,this.block=L[F],at=0;at<F;++at)ut[at]^=L[at];lt(ut),this.reset=!0}else this.start=at}return this},N.prototype.encode=function(_,Z){var U=_&255,L=1,k=[U];for(_=_>>8,U=_&255;U>0;)k.unshift(U),_=_>>8,U=_&255,++L;return Z?k.push(L):k.unshift(L),this.update(k),k.length},N.prototype.encodeString=function(_){var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(d&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!d||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}var L=0,k=_.length;if(Z)L=k;else for(var p=0;p<_.length;++p){var F=_.charCodeAt(p);F<128?L+=1:F<2048?L+=2:F<55296||F>=57344?L+=3:(F=65536+((F&1023)<<10|_.charCodeAt(++p)&1023),L+=4)}return L+=this.encode(L*8),this.update(_),L},N.prototype.bytepad=function(_,Z){for(var U=this.encode(Z),L=0;L<_.length;++L)U+=this.encodeString(_[L]);var k=Z-U%Z,p=[];return p.length=k,this.update(p),this},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var _=this.blocks,Z=this.lastByteIndex,U=this.blockCount,L=this.s;if(_[Z>>2]|=this.padding[Z&3],this.lastByteIndex===this.byteCount)for(_[0]=_[U],Z=1;Z<U+1;++Z)_[Z]=0;for(_[U-1]|=2147483648,Z=0;Z<U;++Z)L[Z]^=_[Z];lt(L)}},N.prototype.toString=N.prototype.hex=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F="",et;p<U;){for(k=0;k<_&&p<U;++k,++p)et=Z[k],F+=f[et>>4&15]+f[et&15]+f[et>>12&15]+f[et>>8&15]+f[et>>20&15]+f[et>>16&15]+f[et>>28&15]+f[et>>24&15];p%_===0&&(lt(Z),k=0)}return L&&(et=Z[k],F+=f[et>>4&15]+f[et&15],L>1&&(F+=f[et>>12&15]+f[et>>8&15]),L>2&&(F+=f[et>>20&15]+f[et>>16&15])),F},N.prototype.arrayBuffer=function(){this.finalize();var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F=this.outputBits>>3,et;L?et=new ArrayBuffer(U+1<<2):et=new ArrayBuffer(F);for(var ut=new Uint32Array(et);p<U;){for(k=0;k<_&&p<U;++k,++p)ut[p]=Z[k];p%_===0&&lt(Z)}return L&&(ut[k]=Z[k],et=et.slice(0,F)),et},N.prototype.buffer=N.prototype.arrayBuffer,N.prototype.digest=N.prototype.array=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F=[],et,ut;p<U;){for(k=0;k<_&&p<U;++k,++p)et=p<<2,ut=Z[k],F[et]=ut&255,F[et+1]=ut>>8&255,F[et+2]=ut>>16&255,F[et+3]=ut>>24&255;p%_===0&&lt(Z)}return L&&(et=p<<2,ut=Z[k],F[et]=ut&255,L>1&&(F[et+1]=ut>>8&255),L>2&&(F[et+2]=ut>>16&255)),F};function it(_,Z,U){N.call(this,_,Z,U)}it.prototype=new N,it.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var lt=function(_){var Z,U,L,k,p,F,et,ut,at,Mt,Pt,It,Ee,$t,xt,Bt,_t,Et,Vt,yt,At,Ut,wt,Ct,Lt,Ot,Nt,se,Tt,Rt,Ke,ce,pe,Ve,ye,_e,Er,Gt,zt,De,Wt,Kt,Ae,Jt,Xt,xe,Zt,Yt,Ce,Qt,qt,Te,te,Pe,xi,Oe,le,oi,ai,ci,ui,hi,ar;for(L=0;L<48;L+=2)k=_[0]^_[10]^_[20]^_[30]^_[40],p=_[1]^_[11]^_[21]^_[31]^_[41],F=_[2]^_[12]^_[22]^_[32]^_[42],et=_[3]^_[13]^_[23]^_[33]^_[43],ut=_[4]^_[14]^_[24]^_[34]^_[44],at=_[5]^_[15]^_[25]^_[35]^_[45],Mt=_[6]^_[16]^_[26]^_[36]^_[46],Pt=_[7]^_[17]^_[27]^_[37]^_[47],It=_[8]^_[18]^_[28]^_[38]^_[48],Ee=_[9]^_[19]^_[29]^_[39]^_[49],Z=It^(F<<1|et>>>31),U=Ee^(et<<1|F>>>31),_[0]^=Z,_[1]^=U,_[10]^=Z,_[11]^=U,_[20]^=Z,_[21]^=U,_[30]^=Z,_[31]^=U,_[40]^=Z,_[41]^=U,Z=k^(ut<<1|at>>>31),U=p^(at<<1|ut>>>31),_[2]^=Z,_[3]^=U,_[12]^=Z,_[13]^=U,_[22]^=Z,_[23]^=U,_[32]^=Z,_[33]^=U,_[42]^=Z,_[43]^=U,Z=F^(Mt<<1|Pt>>>31),U=et^(Pt<<1|Mt>>>31),_[4]^=Z,_[5]^=U,_[14]^=Z,_[15]^=U,_[24]^=Z,_[25]^=U,_[34]^=Z,_[35]^=U,_[44]^=Z,_[45]^=U,Z=ut^(It<<1|Ee>>>31),U=at^(Ee<<1|It>>>31),_[6]^=Z,_[7]^=U,_[16]^=Z,_[17]^=U,_[26]^=Z,_[27]^=U,_[36]^=Z,_[37]^=U,_[46]^=Z,_[47]^=U,Z=Mt^(k<<1|p>>>31),U=Pt^(p<<1|k>>>31),_[8]^=Z,_[9]^=U,_[18]^=Z,_[19]^=U,_[28]^=Z,_[29]^=U,_[38]^=Z,_[39]^=U,_[48]^=Z,_[49]^=U,$t=_[0],xt=_[1],xe=_[11]<<4|_[10]>>>28,Zt=_[10]<<4|_[11]>>>28,se=_[20]<<3|_[21]>>>29,Tt=_[21]<<3|_[20]>>>29,ci=_[31]<<9|_[30]>>>23,ui=_[30]<<9|_[31]>>>23,Kt=_[40]<<18|_[41]>>>14,Ae=_[41]<<18|_[40]>>>14,Ve=_[2]<<1|_[3]>>>31,ye=_[3]<<1|_[2]>>>31,Bt=_[13]<<12|_[12]>>>20,_t=_[12]<<12|_[13]>>>20,Yt=_[22]<<10|_[23]>>>22,Ce=_[23]<<10|_[22]>>>22,Rt=_[33]<<13|_[32]>>>19,Ke=_[32]<<13|_[33]>>>19,hi=_[42]<<2|_[43]>>>30,ar=_[43]<<2|_[42]>>>30,Pe=_[5]<<30|_[4]>>>2,xi=_[4]<<30|_[5]>>>2,_e=_[14]<<6|_[15]>>>26,Er=_[15]<<6|_[14]>>>26,Et=_[25]<<11|_[24]>>>21,Vt=_[24]<<11|_[25]>>>21,Qt=_[34]<<15|_[35]>>>17,qt=_[35]<<15|_[34]>>>17,ce=_[45]<<29|_[44]>>>3,pe=_[44]<<29|_[45]>>>3,Ct=_[6]<<28|_[7]>>>4,Lt=_[7]<<28|_[6]>>>4,Oe=_[17]<<23|_[16]>>>9,le=_[16]<<23|_[17]>>>9,Gt=_[26]<<25|_[27]>>>7,zt=_[27]<<25|_[26]>>>7,yt=_[36]<<21|_[37]>>>11,At=_[37]<<21|_[36]>>>11,Te=_[47]<<24|_[46]>>>8,te=_[46]<<24|_[47]>>>8,Jt=_[8]<<27|_[9]>>>5,Xt=_[9]<<27|_[8]>>>5,Ot=_[18]<<20|_[19]>>>12,Nt=_[19]<<20|_[18]>>>12,oi=_[29]<<7|_[28]>>>25,ai=_[28]<<7|_[29]>>>25,De=_[38]<<8|_[39]>>>24,Wt=_[39]<<8|_[38]>>>24,Ut=_[48]<<14|_[49]>>>18,wt=_[49]<<14|_[48]>>>18,_[0]=$t^~Bt&Et,_[1]=xt^~_t&Vt,_[10]=Ct^~Ot&se,_[11]=Lt^~Nt&Tt,_[20]=Ve^~_e&Gt,_[21]=ye^~Er&zt,_[30]=Jt^~xe&Yt,_[31]=Xt^~Zt&Ce,_[40]=Pe^~Oe&oi,_[41]=xi^~le&ai,_[2]=Bt^~Et&yt,_[3]=_t^~Vt&At,_[12]=Ot^~se&Rt,_[13]=Nt^~Tt&Ke,_[22]=_e^~Gt&De,_[23]=Er^~zt&Wt,_[32]=xe^~Yt&Qt,_[33]=Zt^~Ce&qt,_[42]=Oe^~oi&ci,_[43]=le^~ai&ui,_[4]=Et^~yt&Ut,_[5]=Vt^~At&wt,_[14]=se^~Rt&ce,_[15]=Tt^~Ke&pe,_[24]=Gt^~De&Kt,_[25]=zt^~Wt&Ae,_[34]=Yt^~Qt&Te,_[35]=Ce^~qt&te,_[44]=oi^~ci&hi,_[45]=ai^~ui&ar,_[6]=yt^~Ut&$t,_[7]=At^~wt&xt,_[16]=Rt^~ce&Ct,_[17]=Ke^~pe&Lt,_[26]=De^~Kt&Ve,_[27]=Wt^~Ae&ye,_[36]=Qt^~Te&Jt,_[37]=qt^~te&Xt,_[46]=ci^~hi&Pe,_[47]=ui^~ar&xi,_[8]=Ut^~$t&Bt,_[9]=wt^~xt&_t,_[18]=ce^~Ct&Ot,_[19]=pe^~Lt&Nt,_[28]=Kt^~Ve&_e,_[29]=Ae^~ye&Er,_[38]=Te^~Jt&xe,_[39]=te^~Xt&Zt,_[48]=hi^~Pe&Oe,_[49]=ar^~xi&le,_[0]^=Y[L],_[1]^=Y[L+1]};if(l)r.exports=y;else for(M=0;M<b.length;++M)s[b[M]]=y[b[M]]})()})(X1);var o5=X1.exports;const a5="logger/5.7.0";let Ud=!1,Bd=!1;const Bc={debug:1,default:2,info:2,warning:3,error:4,off:5};let Ld=Bc.default,Rh=null;function c5(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),r.length)throw new Error("missing "+r.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(r){return r.message}return null}const qd=c5();var wl;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(wl||(wl={}));var Ui;(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"})(Ui||(Ui={}));const jd="0123456789abcdef";let gr=class or{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const i=t.toLowerCase();Bc[i]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(Ld>Bc[i])&&console.log.apply(console,e)}debug(...t){this._log(or.levels.DEBUG,t)}info(...t){this._log(or.levels.INFO,t)}warn(...t){this._log(or.levels.WARNING,t)}makeError(t,e,i){if(Bd)return this.makeError("censored error",e,{});e||(e=or.errors.UNKNOWN_ERROR),i||(i={});const s=[];Object.keys(i).forEach(d=>{const f=i[d];try{if(f instanceof Uint8Array){let w="";for(let E=0;E<f.length;E++)w+=jd[f[E]>>4],w+=jd[f[E]&15];s.push(d+"=Uint8Array(0x"+w+")")}else s.push(d+"="+JSON.stringify(f))}catch{s.push(d+"="+JSON.stringify(i[d].toString()))}}),s.push(`code=${e}`),s.push(`version=${this.version}`);const a=t;let u="";switch(e){case Ui.NUMERIC_FAULT:{u="NUMERIC_FAULT";const d=t;switch(d){case"overflow":case"underflow":case"division-by-zero":u+="-"+d;break;case"negative-power":case"negative-width":u+="-unsupported";break;case"unbound-bitwise-result":u+="-unbound-result";break}break}case Ui.CALL_EXCEPTION:case Ui.INSUFFICIENT_FUNDS:case Ui.MISSING_NEW:case Ui.NONCE_EXPIRED:case Ui.REPLACEMENT_UNDERPRICED:case Ui.TRANSACTION_REPLACED:case Ui.UNPREDICTABLE_GAS_LIMIT:u=e;break}u&&(t+=" [ See: https://links.ethers.org/v5-errors-"+u+" ]"),s.length&&(t+=" ("+s.join(", ")+")");const l=new Error(t);return l.reason=a,l.code=e,Object.keys(i).forEach(function(d){l[d]=i[d]}),l}throwError(t,e,i){throw this.makeError(t,e,i)}throwArgumentError(t,e,i){return this.throwError(t,or.errors.INVALID_ARGUMENT,{argument:e,value:i})}assert(t,e,i,s){t||this.throwError(e,i,s)}assertArgument(t,e,i,s){t||this.throwArgumentError(e,i,s)}checkNormalize(t){qd&&this.throwError("platform missing String.prototype.normalize",or.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qd})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,or.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,or.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,i){i?i=": "+i:i="",t<e&&this.throwError("missing argument"+i,or.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+i,or.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",or.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",or.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",or.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Rh||(Rh=new or(a5)),Rh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",or.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Ud){if(!t)return;this.globalLogger().throwError("error censorship permanent",or.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Bd=!!t,Ud=!!e}static setLogLevel(t){const e=Bc[t.toLowerCase()];if(e==null){or.globalLogger().warn("invalid log level - "+t);return}Ld=e}static from(t){return new or(t)}};gr.errors=Ui,gr.levels=wl;const u5="bytes/5.7.0",Ze=new gr(u5);function Z1(r){return!!r.toHexString}function oo(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return oo(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function h5(r){return ii(r)&&!(r.length%2)||mo(r)}function $d(r){return typeof r=="number"&&r==r&&r%1===0}function mo(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!$d(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const e=r[t];if(!$d(e)||e<0||e>=256)return!1}return!0}function Ye(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid arrayify value");const e=[];for(;r;)e.unshift(r&255),r=parseInt(String(r/256));return e.length===0&&e.push(0),oo(new Uint8Array(e))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Z1(r)&&(r=r.toHexString()),ii(r)){let e=r.substring(2);e.length%2&&(t.hexPad==="left"?e="0"+e:t.hexPad==="right"?e+="0":Ze.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let s=0;s<e.length;s+=2)i.push(parseInt(e.substring(s,s+2),16));return oo(new Uint8Array(i))}return mo(r)?oo(new Uint8Array(r)):Ze.throwArgumentError("invalid arrayify value","value",r)}function l5(r){const t=r.map(s=>Ye(s)),e=t.reduce((s,a)=>s+a.length,0),i=new Uint8Array(e);return t.reduce((s,a)=>(i.set(a,s),s+a.length),0),oo(i)}function f5(r,t){r=Ye(r),r.length>t&&Ze.throwArgumentError("value out of range","value",arguments[0]);const e=new Uint8Array(t);return e.set(r,t-r.length),oo(e)}function ii(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const Th="0123456789abcdef";function Cr(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid hexlify value");let e="";for(;r;)e=Th[r&15]+e,r=Math.floor(r/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Z1(r))return r.toHexString();if(ii(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":Ze.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(mo(r)){let e="0x";for(let i=0;i<r.length;i++){let s=r[i];e+=Th[(s&240)>>4]+Th[s&15]}return e}return Ze.throwArgumentError("invalid hexlify value","value",r)}function d5(r){if(typeof r!="string")r=Cr(r);else if(!ii(r)||r.length%2)return null;return(r.length-2)/2}function zd(r,t,e){return typeof r!="string"?r=Cr(r):(!ii(r)||r.length%2)&&Ze.throwArgumentError("invalid hexData","value",r),t=2+2*t,e!=null?"0x"+r.substring(t,2+2*e):"0x"+r.substring(t)}function rn(r,t){for(typeof r!="string"?r=Cr(r):ii(r)||Ze.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&Ze.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function tg(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(h5(r)){let e=Ye(r);e.length===64?(t.v=27+(e[32]>>7),e[32]&=127,t.r=Cr(e.slice(0,32)),t.s=Cr(e.slice(32,64))):e.length===65?(t.r=Cr(e.slice(0,32)),t.s=Cr(e.slice(32,64)),t.v=e[64]):Ze.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:Ze.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(e[32]|=128),t._vs=Cr(e.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const s=f5(Ye(t._vs),32);t._vs=Cr(s);const a=s[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=a:t.recoveryParam!==a&&Ze.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),s[0]&=127;const u=Cr(s);t.s==null?t.s=u:t.s!==u&&Ze.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?Ze.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const s=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==s&&Ze.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!ii(t.r)?Ze.throwArgumentError("signature missing or invalid r","signature",r):t.r=rn(t.r,32),t.s==null||!ii(t.s)?Ze.throwArgumentError("signature missing or invalid s","signature",r):t.s=rn(t.s,32);const e=Ye(t.s);e[0]>=128&&Ze.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(e[0]|=128);const i=Cr(e);t._vs&&(ii(t._vs)||Ze.throwArgumentError("signature invalid _vs","signature",r),t._vs=rn(t._vs,32)),t._vs==null?t._vs=i:t._vs!==i&&Ze.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function Kl(r){return"0x"+o5.keccak_256(Ye(r))}var eg={exports:{}},p5={},g5=Object.freeze({__proto__:null,default:p5}),m5=s5(g5);(function(r){(function(t,e){function i(h,y){if(!h)throw new Error(y||"Assertion failed")}function s(h,y){h.super_=y;var b=function(){};b.prototype=y.prototype,h.prototype=new b,h.prototype.constructor=h}function a(h,y,b){if(a.isBN(h))return h;this.negative=0,this.words=null,this.length=0,this.red=null,h!==null&&((y==="le"||y==="be")&&(b=y,y=10),this._init(h||0,y||10,b||"be"))}typeof t=="object"?t.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var u;try{typeof window<"u"&&typeof window.Buffer<"u"?u=window.Buffer:u=m5.Buffer}catch{}a.isBN=function(h){return h instanceof a?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===a.wordSize&&Array.isArray(h.words)},a.max=function(h,y){return h.cmp(y)>0?h:y},a.min=function(h,y){return h.cmp(y)<0?h:y},a.prototype._init=function(h,y,b){if(typeof h=="number")return this._initNumber(h,y,b);if(typeof h=="object")return this._initArray(h,y,b);y==="hex"&&(y=16),i(y===(y|0)&&y>=2&&y<=36),h=h.toString().replace(/\s+/g,"");var M=0;h[0]==="-"&&(M++,this.negative=1),M<h.length&&(y===16?this._parseHex(h,M,b):(this._parseBase(h,y,M),b==="le"&&this._initArray(this.toArray(),y,b)))},a.prototype._initNumber=function(h,y,b){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(i(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),y,b)},a.prototype._initArray=function(h,y,b){if(i(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var C,R,j=0;if(b==="be")for(M=h.length-1,C=0;M>=0;M-=3)R=h[M]|h[M-1]<<8|h[M-2]<<16,this.words[C]|=R<<j&67108863,this.words[C+1]=R>>>26-j&67108863,j+=24,j>=26&&(j-=26,C++);else if(b==="le")for(M=0,C=0;M<h.length;M+=3)R=h[M]|h[M+1]<<8|h[M+2]<<16,this.words[C]|=R<<j&67108863,this.words[C+1]=R>>>26-j&67108863,j+=24,j>=26&&(j-=26,C++);return this._strip()};function l(h,y){var b=h.charCodeAt(y);if(b>=48&&b<=57)return b-48;if(b>=65&&b<=70)return b-55;if(b>=97&&b<=102)return b-87;i(!1,"Invalid character in "+h)}function d(h,y,b){var M=l(h,b);return b-1>=y&&(M|=l(h,b-1)<<4),M}a.prototype._parseHex=function(h,y,b){this.length=Math.ceil((h.length-y)/6),this.words=new Array(this.length);for(var M=0;M<this.length;M++)this.words[M]=0;var C=0,R=0,j;if(b==="be")for(M=h.length-1;M>=y;M-=2)j=d(h,y,M)<<C,this.words[R]|=j&67108863,C>=18?(C-=18,R+=1,this.words[R]|=j>>>26):C+=8;else{var S=h.length-y;for(M=S%2===0?y+1:y;M<h.length;M+=2)j=d(h,y,M)<<C,this.words[R]|=j&67108863,C>=18?(C-=18,R+=1,this.words[R]|=j>>>26):C+=8}this._strip()};function f(h,y,b,M){for(var C=0,R=0,j=Math.min(h.length,b),S=y;S<j;S++){var g=h.charCodeAt(S)-48;C*=M,g>=49?R=g-49+10:g>=17?R=g-17+10:R=g,i(g>=0&&R<M,"Invalid character"),C+=R}return C}a.prototype._parseBase=function(h,y,b){this.words=[0],this.length=1;for(var M=0,C=1;C<=67108863;C*=y)M++;M--,C=C/y|0;for(var R=h.length-b,j=R%M,S=Math.min(R,R-j)+b,g=0,N=b;N<S;N+=M)g=f(h,N,N+M,y),this.imuln(C),this.words[0]+g<67108864?this.words[0]+=g:this._iaddn(g);if(j!==0){var it=1;for(g=f(h,N,h.length,y),N=0;N<j;N++)it*=y;this.imuln(it),this.words[0]+g<67108864?this.words[0]+=g:this._iaddn(g)}this._strip()},a.prototype.copy=function(h){h.words=new Array(this.length);for(var y=0;y<this.length;y++)h.words[y]=this.words[y];h.length=this.length,h.negative=this.negative,h.red=this.red};function w(h,y){h.words=y.words,h.length=y.length,h.negative=y.negative,h.red=y.red}if(a.prototype._move=function(h){w(h,this)},a.prototype.clone=function(){var h=new a(null);return this.copy(h),h},a.prototype._expand=function(h){for(;this.length<h;)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")]=E}catch{a.prototype.inspect=E}else a.prototype.inspect=E;function E(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],D=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],P=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];a.prototype.toString=function(h,y){h=h||10,y=y|0||1;var b;if(h===16||h==="hex"){b="";for(var M=0,C=0,R=0;R<this.length;R++){var j=this.words[R],S=((j<<M|C)&16777215).toString(16);C=j>>>24-M&16777215,M+=2,M>=26&&(M-=26,R--),C!==0||R!==this.length-1?b=I[6-S.length]+S+b:b=S+b}for(C!==0&&(b=C.toString(16)+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(h===(h|0)&&h>=2&&h<=36){var g=D[h],N=P[h];b="";var it=this.clone();for(it.negative=0;!it.isZero();){var lt=it.modrn(N).toString(h);it=it.idivn(N),it.isZero()?b=lt+b:b=I[g-lt.length]+lt+b}for(this.isZero()&&(b="0"+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},a.prototype.toJSON=function(){return this.toString(16,2)},u&&(a.prototype.toBuffer=function(h,y){return this.toArrayLike(u,h,y)}),a.prototype.toArray=function(h,y){return this.toArrayLike(Array,h,y)};var Y=function(h,y){return h.allocUnsafe?h.allocUnsafe(y):new h(y)};a.prototype.toArrayLike=function(h,y,b){this._strip();var M=this.byteLength(),C=b||Math.max(1,M);i(M<=C,"byte array longer than desired length"),i(C>0,"Requested array length <= 0");var R=Y(h,C),j=y==="le"?"LE":"BE";return this["_toArrayLike"+j](R,M),R},a.prototype._toArrayLikeLE=function(h,y){for(var b=0,M=0,C=0,R=0;C<this.length;C++){var j=this.words[C]<<R|M;h[b++]=j&255,b<h.length&&(h[b++]=j>>8&255),b<h.length&&(h[b++]=j>>16&255),R===6?(b<h.length&&(h[b++]=j>>24&255),M=0,R=0):(M=j>>>24,R+=2)}if(b<h.length)for(h[b++]=M;b<h.length;)h[b++]=0},a.prototype._toArrayLikeBE=function(h,y){for(var b=h.length-1,M=0,C=0,R=0;C<this.length;C++){var j=this.words[C]<<R|M;h[b--]=j&255,b>=0&&(h[b--]=j>>8&255),b>=0&&(h[b--]=j>>16&255),R===6?(b>=0&&(h[b--]=j>>24&255),M=0,R=0):(M=j>>>24,R+=2)}if(b>=0)for(h[b--]=M;b>=0;)h[b--]=0},Math.clz32?a.prototype._countBits=function(h){return 32-Math.clz32(h)}:a.prototype._countBits=function(h){var y=h,b=0;return y>=4096&&(b+=13,y>>>=13),y>=64&&(b+=7,y>>>=7),y>=8&&(b+=4,y>>>=4),y>=2&&(b+=2,y>>>=2),b+y},a.prototype._zeroBits=function(h){if(h===0)return 26;var y=h,b=0;return y&8191||(b+=13,y>>>=13),y&127||(b+=7,y>>>=7),y&15||(b+=4,y>>>=4),y&3||(b+=2,y>>>=2),y&1||b++,b},a.prototype.bitLength=function(){var h=this.words[this.length-1],y=this._countBits(h);return(this.length-1)*26+y};function G(h){for(var y=new Array(h.bitLength()),b=0;b<y.length;b++){var M=b/26|0,C=b%26;y[b]=h.words[M]>>>C&1}return y}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,y=0;y<this.length;y++){var b=this._zeroBits(this.words[y]);if(h+=b,b!==26)break}return h},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},a.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).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(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]|h.words[y];return this._strip()},a.prototype.ior=function(h){return i((this.negative|h.negative)===0),this.iuor(h)},a.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},a.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},a.prototype.iuand=function(h){var y;this.length>h.length?y=h:y=this;for(var b=0;b<y.length;b++)this.words[b]=this.words[b]&h.words[b];return this.length=y.length,this._strip()},a.prototype.iand=function(h){return i((this.negative|h.negative)===0),this.iuand(h)},a.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},a.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},a.prototype.iuxor=function(h){var y,b;this.length>h.length?(y=this,b=h):(y=h,b=this);for(var M=0;M<b.length;M++)this.words[M]=y.words[M]^b.words[M];if(this!==y)for(;M<y.length;M++)this.words[M]=y.words[M];return this.length=y.length,this._strip()},a.prototype.ixor=function(h){return i((this.negative|h.negative)===0),this.iuxor(h)},a.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},a.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},a.prototype.inotn=function(h){i(typeof h=="number"&&h>=0);var y=Math.ceil(h/26)|0,b=h%26;this._expand(y),b>0&&y--;for(var M=0;M<y;M++)this.words[M]=~this.words[M]&67108863;return b>0&&(this.words[M]=~this.words[M]&67108863>>26-b),this._strip()},a.prototype.notn=function(h){return this.clone().inotn(h)},a.prototype.setn=function(h,y){i(typeof h=="number"&&h>=0);var b=h/26|0,M=h%26;return this._expand(b+1),y?this.words[b]=this.words[b]|1<<M:this.words[b]=this.words[b]&~(1<<M),this._strip()},a.prototype.iadd=function(h){var y;if(this.negative!==0&&h.negative===0)return this.negative=0,y=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,y=this.isub(h),h.negative=1,y._normSign();var b,M;this.length>h.length?(b=this,M=h):(b=h,M=this);for(var C=0,R=0;R<M.length;R++)y=(b.words[R]|0)+(M.words[R]|0)+C,this.words[R]=y&67108863,C=y>>>26;for(;C!==0&&R<b.length;R++)y=(b.words[R]|0)+C,this.words[R]=y&67108863,C=y>>>26;if(this.length=b.length,C!==0)this.words[this.length]=C,this.length++;else if(b!==this)for(;R<b.length;R++)this.words[R]=b.words[R];return this},a.prototype.add=function(h){var y;return h.negative!==0&&this.negative===0?(h.negative=0,y=this.sub(h),h.negative^=1,y):h.negative===0&&this.negative!==0?(this.negative=0,y=h.sub(this),this.negative=1,y):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},a.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var y=this.iadd(h);return h.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var b=this.cmp(h);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,C;b>0?(M=this,C=h):(M=h,C=this);for(var R=0,j=0;j<C.length;j++)y=(M.words[j]|0)-(C.words[j]|0)+R,R=y>>26,this.words[j]=y&67108863;for(;R!==0&&j<M.length;j++)y=(M.words[j]|0)+R,R=y>>26,this.words[j]=y&67108863;if(R===0&&j<M.length&&M!==this)for(;j<M.length;j++)this.words[j]=M.words[j];return this.length=Math.max(this.length,j),M!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(h){return this.clone().isub(h)};function tt(h,y,b){b.negative=y.negative^h.negative;var M=h.length+y.length|0;b.length=M,M=M-1|0;var C=h.words[0]|0,R=y.words[0]|0,j=C*R,S=j&67108863,g=j/67108864|0;b.words[0]=S;for(var N=1;N<M;N++){for(var it=g>>>26,lt=g&67108863,_=Math.min(N,y.length-1),Z=Math.max(0,N-h.length+1);Z<=_;Z++){var U=N-Z|0;C=h.words[U]|0,R=y.words[Z]|0,j=C*R+lt,it+=j/67108864|0,lt=j&67108863}b.words[N]=lt|0,g=it|0}return g!==0?b.words[N]=g|0:b.length--,b._strip()}var K=function(h,y,b){var M=h.words,C=y.words,R=b.words,j=0,S,g,N,it=M[0]|0,lt=it&8191,_=it>>>13,Z=M[1]|0,U=Z&8191,L=Z>>>13,k=M[2]|0,p=k&8191,F=k>>>13,et=M[3]|0,ut=et&8191,at=et>>>13,Mt=M[4]|0,Pt=Mt&8191,It=Mt>>>13,Ee=M[5]|0,$t=Ee&8191,xt=Ee>>>13,Bt=M[6]|0,_t=Bt&8191,Et=Bt>>>13,Vt=M[7]|0,yt=Vt&8191,At=Vt>>>13,Ut=M[8]|0,wt=Ut&8191,Ct=Ut>>>13,Lt=M[9]|0,Ot=Lt&8191,Nt=Lt>>>13,se=C[0]|0,Tt=se&8191,Rt=se>>>13,Ke=C[1]|0,ce=Ke&8191,pe=Ke>>>13,Ve=C[2]|0,ye=Ve&8191,_e=Ve>>>13,Er=C[3]|0,Gt=Er&8191,zt=Er>>>13,De=C[4]|0,Wt=De&8191,Kt=De>>>13,Ae=C[5]|0,Jt=Ae&8191,Xt=Ae>>>13,xe=C[6]|0,Zt=xe&8191,Yt=xe>>>13,Ce=C[7]|0,Qt=Ce&8191,qt=Ce>>>13,Te=C[8]|0,te=Te&8191,Pe=Te>>>13,xi=C[9]|0,Oe=xi&8191,le=xi>>>13;b.negative=h.negative^y.negative,b.length=19,S=Math.imul(lt,Tt),g=Math.imul(lt,Rt),g=g+Math.imul(_,Tt)|0,N=Math.imul(_,Rt);var oi=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(oi>>>26)|0,oi&=67108863,S=Math.imul(U,Tt),g=Math.imul(U,Rt),g=g+Math.imul(L,Tt)|0,N=Math.imul(L,Rt),S=S+Math.imul(lt,ce)|0,g=g+Math.imul(lt,pe)|0,g=g+Math.imul(_,ce)|0,N=N+Math.imul(_,pe)|0;var ai=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ai>>>26)|0,ai&=67108863,S=Math.imul(p,Tt),g=Math.imul(p,Rt),g=g+Math.imul(F,Tt)|0,N=Math.imul(F,Rt),S=S+Math.imul(U,ce)|0,g=g+Math.imul(U,pe)|0,g=g+Math.imul(L,ce)|0,N=N+Math.imul(L,pe)|0,S=S+Math.imul(lt,ye)|0,g=g+Math.imul(lt,_e)|0,g=g+Math.imul(_,ye)|0,N=N+Math.imul(_,_e)|0;var ci=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ci>>>26)|0,ci&=67108863,S=Math.imul(ut,Tt),g=Math.imul(ut,Rt),g=g+Math.imul(at,Tt)|0,N=Math.imul(at,Rt),S=S+Math.imul(p,ce)|0,g=g+Math.imul(p,pe)|0,g=g+Math.imul(F,ce)|0,N=N+Math.imul(F,pe)|0,S=S+Math.imul(U,ye)|0,g=g+Math.imul(U,_e)|0,g=g+Math.imul(L,ye)|0,N=N+Math.imul(L,_e)|0,S=S+Math.imul(lt,Gt)|0,g=g+Math.imul(lt,zt)|0,g=g+Math.imul(_,Gt)|0,N=N+Math.imul(_,zt)|0;var ui=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ui>>>26)|0,ui&=67108863,S=Math.imul(Pt,Tt),g=Math.imul(Pt,Rt),g=g+Math.imul(It,Tt)|0,N=Math.imul(It,Rt),S=S+Math.imul(ut,ce)|0,g=g+Math.imul(ut,pe)|0,g=g+Math.imul(at,ce)|0,N=N+Math.imul(at,pe)|0,S=S+Math.imul(p,ye)|0,g=g+Math.imul(p,_e)|0,g=g+Math.imul(F,ye)|0,N=N+Math.imul(F,_e)|0,S=S+Math.imul(U,Gt)|0,g=g+Math.imul(U,zt)|0,g=g+Math.imul(L,Gt)|0,N=N+Math.imul(L,zt)|0,S=S+Math.imul(lt,Wt)|0,g=g+Math.imul(lt,Kt)|0,g=g+Math.imul(_,Wt)|0,N=N+Math.imul(_,Kt)|0;var hi=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(hi>>>26)|0,hi&=67108863,S=Math.imul($t,Tt),g=Math.imul($t,Rt),g=g+Math.imul(xt,Tt)|0,N=Math.imul(xt,Rt),S=S+Math.imul(Pt,ce)|0,g=g+Math.imul(Pt,pe)|0,g=g+Math.imul(It,ce)|0,N=N+Math.imul(It,pe)|0,S=S+Math.imul(ut,ye)|0,g=g+Math.imul(ut,_e)|0,g=g+Math.imul(at,ye)|0,N=N+Math.imul(at,_e)|0,S=S+Math.imul(p,Gt)|0,g=g+Math.imul(p,zt)|0,g=g+Math.imul(F,Gt)|0,N=N+Math.imul(F,zt)|0,S=S+Math.imul(U,Wt)|0,g=g+Math.imul(U,Kt)|0,g=g+Math.imul(L,Wt)|0,N=N+Math.imul(L,Kt)|0,S=S+Math.imul(lt,Jt)|0,g=g+Math.imul(lt,Xt)|0,g=g+Math.imul(_,Jt)|0,N=N+Math.imul(_,Xt)|0;var ar=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ar>>>26)|0,ar&=67108863,S=Math.imul(_t,Tt),g=Math.imul(_t,Rt),g=g+Math.imul(Et,Tt)|0,N=Math.imul(Et,Rt),S=S+Math.imul($t,ce)|0,g=g+Math.imul($t,pe)|0,g=g+Math.imul(xt,ce)|0,N=N+Math.imul(xt,pe)|0,S=S+Math.imul(Pt,ye)|0,g=g+Math.imul(Pt,_e)|0,g=g+Math.imul(It,ye)|0,N=N+Math.imul(It,_e)|0,S=S+Math.imul(ut,Gt)|0,g=g+Math.imul(ut,zt)|0,g=g+Math.imul(at,Gt)|0,N=N+Math.imul(at,zt)|0,S=S+Math.imul(p,Wt)|0,g=g+Math.imul(p,Kt)|0,g=g+Math.imul(F,Wt)|0,N=N+Math.imul(F,Kt)|0,S=S+Math.imul(U,Jt)|0,g=g+Math.imul(U,Xt)|0,g=g+Math.imul(L,Jt)|0,N=N+Math.imul(L,Xt)|0,S=S+Math.imul(lt,Zt)|0,g=g+Math.imul(lt,Yt)|0,g=g+Math.imul(_,Zt)|0,N=N+Math.imul(_,Yt)|0;var qi=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(qi>>>26)|0,qi&=67108863,S=Math.imul(yt,Tt),g=Math.imul(yt,Rt),g=g+Math.imul(At,Tt)|0,N=Math.imul(At,Rt),S=S+Math.imul(_t,ce)|0,g=g+Math.imul(_t,pe)|0,g=g+Math.imul(Et,ce)|0,N=N+Math.imul(Et,pe)|0,S=S+Math.imul($t,ye)|0,g=g+Math.imul($t,_e)|0,g=g+Math.imul(xt,ye)|0,N=N+Math.imul(xt,_e)|0,S=S+Math.imul(Pt,Gt)|0,g=g+Math.imul(Pt,zt)|0,g=g+Math.imul(It,Gt)|0,N=N+Math.imul(It,zt)|0,S=S+Math.imul(ut,Wt)|0,g=g+Math.imul(ut,Kt)|0,g=g+Math.imul(at,Wt)|0,N=N+Math.imul(at,Kt)|0,S=S+Math.imul(p,Jt)|0,g=g+Math.imul(p,Xt)|0,g=g+Math.imul(F,Jt)|0,N=N+Math.imul(F,Xt)|0,S=S+Math.imul(U,Zt)|0,g=g+Math.imul(U,Yt)|0,g=g+Math.imul(L,Zt)|0,N=N+Math.imul(L,Yt)|0,S=S+Math.imul(lt,Qt)|0,g=g+Math.imul(lt,qt)|0,g=g+Math.imul(_,Qt)|0,N=N+Math.imul(_,qt)|0;var Xn=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(Xn>>>26)|0,Xn&=67108863,S=Math.imul(wt,Tt),g=Math.imul(wt,Rt),g=g+Math.imul(Ct,Tt)|0,N=Math.imul(Ct,Rt),S=S+Math.imul(yt,ce)|0,g=g+Math.imul(yt,pe)|0,g=g+Math.imul(At,ce)|0,N=N+Math.imul(At,pe)|0,S=S+Math.imul(_t,ye)|0,g=g+Math.imul(_t,_e)|0,g=g+Math.imul(Et,ye)|0,N=N+Math.imul(Et,_e)|0,S=S+Math.imul($t,Gt)|0,g=g+Math.imul($t,zt)|0,g=g+Math.imul(xt,Gt)|0,N=N+Math.imul(xt,zt)|0,S=S+Math.imul(Pt,Wt)|0,g=g+Math.imul(Pt,Kt)|0,g=g+Math.imul(It,Wt)|0,N=N+Math.imul(It,Kt)|0,S=S+Math.imul(ut,Jt)|0,g=g+Math.imul(ut,Xt)|0,g=g+Math.imul(at,Jt)|0,N=N+Math.imul(at,Xt)|0,S=S+Math.imul(p,Zt)|0,g=g+Math.imul(p,Yt)|0,g=g+Math.imul(F,Zt)|0,N=N+Math.imul(F,Yt)|0,S=S+Math.imul(U,Qt)|0,g=g+Math.imul(U,qt)|0,g=g+Math.imul(L,Qt)|0,N=N+Math.imul(L,qt)|0,S=S+Math.imul(lt,te)|0,g=g+Math.imul(lt,Pe)|0,g=g+Math.imul(_,te)|0,N=N+Math.imul(_,Pe)|0;var ji=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ji>>>26)|0,ji&=67108863,S=Math.imul(Ot,Tt),g=Math.imul(Ot,Rt),g=g+Math.imul(Nt,Tt)|0,N=Math.imul(Nt,Rt),S=S+Math.imul(wt,ce)|0,g=g+Math.imul(wt,pe)|0,g=g+Math.imul(Ct,ce)|0,N=N+Math.imul(Ct,pe)|0,S=S+Math.imul(yt,ye)|0,g=g+Math.imul(yt,_e)|0,g=g+Math.imul(At,ye)|0,N=N+Math.imul(At,_e)|0,S=S+Math.imul(_t,Gt)|0,g=g+Math.imul(_t,zt)|0,g=g+Math.imul(Et,Gt)|0,N=N+Math.imul(Et,zt)|0,S=S+Math.imul($t,Wt)|0,g=g+Math.imul($t,Kt)|0,g=g+Math.imul(xt,Wt)|0,N=N+Math.imul(xt,Kt)|0,S=S+Math.imul(Pt,Jt)|0,g=g+Math.imul(Pt,Xt)|0,g=g+Math.imul(It,Jt)|0,N=N+Math.imul(It,Xt)|0,S=S+Math.imul(ut,Zt)|0,g=g+Math.imul(ut,Yt)|0,g=g+Math.imul(at,Zt)|0,N=N+Math.imul(at,Yt)|0,S=S+Math.imul(p,Qt)|0,g=g+Math.imul(p,qt)|0,g=g+Math.imul(F,Qt)|0,N=N+Math.imul(F,qt)|0,S=S+Math.imul(U,te)|0,g=g+Math.imul(U,Pe)|0,g=g+Math.imul(L,te)|0,N=N+Math.imul(L,Pe)|0,S=S+Math.imul(lt,Oe)|0,g=g+Math.imul(lt,le)|0,g=g+Math.imul(_,Oe)|0,N=N+Math.imul(_,le)|0;var Zn=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(Zn>>>26)|0,Zn&=67108863,S=Math.imul(Ot,ce),g=Math.imul(Ot,pe),g=g+Math.imul(Nt,ce)|0,N=Math.imul(Nt,pe),S=S+Math.imul(wt,ye)|0,g=g+Math.imul(wt,_e)|0,g=g+Math.imul(Ct,ye)|0,N=N+Math.imul(Ct,_e)|0,S=S+Math.imul(yt,Gt)|0,g=g+Math.imul(yt,zt)|0,g=g+Math.imul(At,Gt)|0,N=N+Math.imul(At,zt)|0,S=S+Math.imul(_t,Wt)|0,g=g+Math.imul(_t,Kt)|0,g=g+Math.imul(Et,Wt)|0,N=N+Math.imul(Et,Kt)|0,S=S+Math.imul($t,Jt)|0,g=g+Math.imul($t,Xt)|0,g=g+Math.imul(xt,Jt)|0,N=N+Math.imul(xt,Xt)|0,S=S+Math.imul(Pt,Zt)|0,g=g+Math.imul(Pt,Yt)|0,g=g+Math.imul(It,Zt)|0,N=N+Math.imul(It,Yt)|0,S=S+Math.imul(ut,Qt)|0,g=g+Math.imul(ut,qt)|0,g=g+Math.imul(at,Qt)|0,N=N+Math.imul(at,qt)|0,S=S+Math.imul(p,te)|0,g=g+Math.imul(p,Pe)|0,g=g+Math.imul(F,te)|0,N=N+Math.imul(F,Pe)|0,S=S+Math.imul(U,Oe)|0,g=g+Math.imul(U,le)|0,g=g+Math.imul(L,Oe)|0,N=N+Math.imul(L,le)|0;var ts=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(ts>>>26)|0,ts&=67108863,S=Math.imul(Ot,ye),g=Math.imul(Ot,_e),g=g+Math.imul(Nt,ye)|0,N=Math.imul(Nt,_e),S=S+Math.imul(wt,Gt)|0,g=g+Math.imul(wt,zt)|0,g=g+Math.imul(Ct,Gt)|0,N=N+Math.imul(Ct,zt)|0,S=S+Math.imul(yt,Wt)|0,g=g+Math.imul(yt,Kt)|0,g=g+Math.imul(At,Wt)|0,N=N+Math.imul(At,Kt)|0,S=S+Math.imul(_t,Jt)|0,g=g+Math.imul(_t,Xt)|0,g=g+Math.imul(Et,Jt)|0,N=N+Math.imul(Et,Xt)|0,S=S+Math.imul($t,Zt)|0,g=g+Math.imul($t,Yt)|0,g=g+Math.imul(xt,Zt)|0,N=N+Math.imul(xt,Yt)|0,S=S+Math.imul(Pt,Qt)|0,g=g+Math.imul(Pt,qt)|0,g=g+Math.imul(It,Qt)|0,N=N+Math.imul(It,qt)|0,S=S+Math.imul(ut,te)|0,g=g+Math.imul(ut,Pe)|0,g=g+Math.imul(at,te)|0,N=N+Math.imul(at,Pe)|0,S=S+Math.imul(p,Oe)|0,g=g+Math.imul(p,le)|0,g=g+Math.imul(F,Oe)|0,N=N+Math.imul(F,le)|0;var $i=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+($i>>>26)|0,$i&=67108863,S=Math.imul(Ot,Gt),g=Math.imul(Ot,zt),g=g+Math.imul(Nt,Gt)|0,N=Math.imul(Nt,zt),S=S+Math.imul(wt,Wt)|0,g=g+Math.imul(wt,Kt)|0,g=g+Math.imul(Ct,Wt)|0,N=N+Math.imul(Ct,Kt)|0,S=S+Math.imul(yt,Jt)|0,g=g+Math.imul(yt,Xt)|0,g=g+Math.imul(At,Jt)|0,N=N+Math.imul(At,Xt)|0,S=S+Math.imul(_t,Zt)|0,g=g+Math.imul(_t,Yt)|0,g=g+Math.imul(Et,Zt)|0,N=N+Math.imul(Et,Yt)|0,S=S+Math.imul($t,Qt)|0,g=g+Math.imul($t,qt)|0,g=g+Math.imul(xt,Qt)|0,N=N+Math.imul(xt,qt)|0,S=S+Math.imul(Pt,te)|0,g=g+Math.imul(Pt,Pe)|0,g=g+Math.imul(It,te)|0,N=N+Math.imul(It,Pe)|0,S=S+Math.imul(ut,Oe)|0,g=g+Math.imul(ut,le)|0,g=g+Math.imul(at,Oe)|0,N=N+Math.imul(at,le)|0;var Pn=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,S=Math.imul(Ot,Wt),g=Math.imul(Ot,Kt),g=g+Math.imul(Nt,Wt)|0,N=Math.imul(Nt,Kt),S=S+Math.imul(wt,Jt)|0,g=g+Math.imul(wt,Xt)|0,g=g+Math.imul(Ct,Jt)|0,N=N+Math.imul(Ct,Xt)|0,S=S+Math.imul(yt,Zt)|0,g=g+Math.imul(yt,Yt)|0,g=g+Math.imul(At,Zt)|0,N=N+Math.imul(At,Yt)|0,S=S+Math.imul(_t,Qt)|0,g=g+Math.imul(_t,qt)|0,g=g+Math.imul(Et,Qt)|0,N=N+Math.imul(Et,qt)|0,S=S+Math.imul($t,te)|0,g=g+Math.imul($t,Pe)|0,g=g+Math.imul(xt,te)|0,N=N+Math.imul(xt,Pe)|0,S=S+Math.imul(Pt,Oe)|0,g=g+Math.imul(Pt,le)|0,g=g+Math.imul(It,Oe)|0,N=N+Math.imul(It,le)|0;var On=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(On>>>26)|0,On&=67108863,S=Math.imul(Ot,Jt),g=Math.imul(Ot,Xt),g=g+Math.imul(Nt,Jt)|0,N=Math.imul(Nt,Xt),S=S+Math.imul(wt,Zt)|0,g=g+Math.imul(wt,Yt)|0,g=g+Math.imul(Ct,Zt)|0,N=N+Math.imul(Ct,Yt)|0,S=S+Math.imul(yt,Qt)|0,g=g+Math.imul(yt,qt)|0,g=g+Math.imul(At,Qt)|0,N=N+Math.imul(At,qt)|0,S=S+Math.imul(_t,te)|0,g=g+Math.imul(_t,Pe)|0,g=g+Math.imul(Et,te)|0,N=N+Math.imul(Et,Pe)|0,S=S+Math.imul($t,Oe)|0,g=g+Math.imul($t,le)|0,g=g+Math.imul(xt,Oe)|0,N=N+Math.imul(xt,le)|0;var Ar=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,S=Math.imul(Ot,Zt),g=Math.imul(Ot,Yt),g=g+Math.imul(Nt,Zt)|0,N=Math.imul(Nt,Yt),S=S+Math.imul(wt,Qt)|0,g=g+Math.imul(wt,qt)|0,g=g+Math.imul(Ct,Qt)|0,N=N+Math.imul(Ct,qt)|0,S=S+Math.imul(yt,te)|0,g=g+Math.imul(yt,Pe)|0,g=g+Math.imul(At,te)|0,N=N+Math.imul(At,Pe)|0,S=S+Math.imul(_t,Oe)|0,g=g+Math.imul(_t,le)|0,g=g+Math.imul(Et,Oe)|0,N=N+Math.imul(Et,le)|0;var es=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(es>>>26)|0,es&=67108863,S=Math.imul(Ot,Qt),g=Math.imul(Ot,qt),g=g+Math.imul(Nt,Qt)|0,N=Math.imul(Nt,qt),S=S+Math.imul(wt,te)|0,g=g+Math.imul(wt,Pe)|0,g=g+Math.imul(Ct,te)|0,N=N+Math.imul(Ct,Pe)|0,S=S+Math.imul(yt,Oe)|0,g=g+Math.imul(yt,le)|0,g=g+Math.imul(At,Oe)|0,N=N+Math.imul(At,le)|0;var rs=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(rs>>>26)|0,rs&=67108863,S=Math.imul(Ot,te),g=Math.imul(Ot,Pe),g=g+Math.imul(Nt,te)|0,N=Math.imul(Nt,Pe),S=S+Math.imul(wt,Oe)|0,g=g+Math.imul(wt,le)|0,g=g+Math.imul(Ct,Oe)|0,N=N+Math.imul(Ct,le)|0;var is=(j+S|0)+((g&8191)<<13)|0;j=(N+(g>>>13)|0)+(is>>>26)|0,is&=67108863,S=Math.imul(Ot,Oe),g=Math.imul(Ot,le),g=g+Math.imul(Nt,Oe)|0,N=Math.imul(Nt,le);var ns=(j+S|0)+((g&8191)<<13)|0;return j=(N+(g>>>13)|0)+(ns>>>26)|0,ns&=67108863,R[0]=oi,R[1]=ai,R[2]=ci,R[3]=ui,R[4]=hi,R[5]=ar,R[6]=qi,R[7]=Xn,R[8]=ji,R[9]=Zn,R[10]=ts,R[11]=$i,R[12]=Pn,R[13]=On,R[14]=Ar,R[15]=es,R[16]=rs,R[17]=is,R[18]=ns,j!==0&&(R[19]=j,b.length++),b};Math.imul||(K=tt);function V(h,y,b){b.negative=y.negative^h.negative,b.length=h.length+y.length;for(var M=0,C=0,R=0;R<b.length-1;R++){var j=C;C=0;for(var S=M&67108863,g=Math.min(R,y.length-1),N=Math.max(0,R-h.length+1);N<=g;N++){var it=R-N,lt=h.words[it]|0,_=y.words[N]|0,Z=lt*_,U=Z&67108863;j=j+(Z/67108864|0)|0,U=U+S|0,S=U&67108863,j=j+(U>>>26)|0,C+=j>>>26,j&=67108863}b.words[R]=S,M=j,j=C}return M!==0?b.words[R]=M:b.length--,b._strip()}function B(h,y,b){return V(h,y,b)}a.prototype.mulTo=function(h,y){var b,M=this.length+h.length;return this.length===10&&h.length===10?b=K(this,h,y):M<63?b=tt(this,h,y):M<1024?b=V(this,h,y):b=B(this,h,y),b},a.prototype.mul=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),this.mulTo(h,y)},a.prototype.mulf=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),B(this,h,y)},a.prototype.imul=function(h){return this.clone().mulTo(h,this)},a.prototype.imuln=function(h){var y=h<0;y&&(h=-h),i(typeof h=="number"),i(h<67108864);for(var b=0,M=0;M<this.length;M++){var C=(this.words[M]|0)*h,R=(C&67108863)+(b&67108863);b>>=26,b+=C/67108864|0,b+=R>>>26,this.words[M]=R&67108863}return b!==0&&(this.words[M]=b,this.length++),y?this.ineg():this},a.prototype.muln=function(h){return this.clone().imuln(h)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(h){var y=G(h);if(y.length===0)return new a(1);for(var b=this,M=0;M<y.length&&y[M]===0;M++,b=b.sqr());if(++M<y.length)for(var C=b.sqr();M<y.length;M++,C=C.sqr())y[M]!==0&&(b=b.mul(C));return b},a.prototype.iushln=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,M=67108863>>>26-y<<26-y,C;if(y!==0){var R=0;for(C=0;C<this.length;C++){var j=this.words[C]&M,S=(this.words[C]|0)-j<<y;this.words[C]=S|R,R=j>>>26-y}R&&(this.words[C]=R,this.length++)}if(b!==0){for(C=this.length-1;C>=0;C--)this.words[C+b]=this.words[C];for(C=0;C<b;C++)this.words[C]=0;this.length+=b}return this._strip()},a.prototype.ishln=function(h){return i(this.negative===0),this.iushln(h)},a.prototype.iushrn=function(h,y,b){i(typeof h=="number"&&h>=0);var M;y?M=(y-y%26)/26:M=0;var C=h%26,R=Math.min((h-C)/26,this.length),j=67108863^67108863>>>C<<C,S=b;if(M-=R,M=Math.max(0,M),S){for(var g=0;g<R;g++)S.words[g]=this.words[g];S.length=R}if(R!==0)if(this.length>R)for(this.length-=R,g=0;g<this.length;g++)this.words[g]=this.words[g+R];else this.words[0]=0,this.length=1;var N=0;for(g=this.length-1;g>=0&&(N!==0||g>=M);g--){var it=this.words[g]|0;this.words[g]=N<<26-C|it>>>C,N=it&j}return S&&N!==0&&(S.words[S.length++]=N),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(h,y,b){return i(this.negative===0),this.iushrn(h,y,b)},a.prototype.shln=function(h){return this.clone().ishln(h)},a.prototype.ushln=function(h){return this.clone().iushln(h)},a.prototype.shrn=function(h){return this.clone().ishrn(h)},a.prototype.ushrn=function(h){return this.clone().iushrn(h)},a.prototype.testn=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,M=1<<y;if(this.length<=b)return!1;var C=this.words[b];return!!(C&M)},a.prototype.imaskn=function(h){i(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(y!==0&&b++,this.length=Math.min(b,this.length),y!==0){var M=67108863^67108863>>>y<<y;this.words[this.length-1]&=M}return this._strip()},a.prototype.maskn=function(h){return this.clone().imaskn(h)},a.prototype.iaddn=function(h){return i(typeof h=="number"),i(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<=h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},a.prototype._iaddn=function(h){this.words[0]+=h;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},a.prototype.isubn=function(h){if(i(typeof h=="number"),i(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},a.prototype.addn=function(h){return this.clone().iaddn(h)},a.prototype.subn=function(h){return this.clone().isubn(h)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(h,y,b){var M=h.length+b,C;this._expand(M);var R,j=0;for(C=0;C<h.length;C++){R=(this.words[C+b]|0)+j;var S=(h.words[C]|0)*y;R-=S&67108863,j=(R>>26)-(S/67108864|0),this.words[C+b]=R&67108863}for(;C<this.length-b;C++)R=(this.words[C+b]|0)+j,j=R>>26,this.words[C+b]=R&67108863;if(j===0)return this._strip();for(i(j===-1),j=0,C=0;C<this.length;C++)R=-(this.words[C]|0)+j,j=R>>26,this.words[C]=R&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(h,y){var b=this.length-h.length,M=this.clone(),C=h,R=C.words[C.length-1]|0,j=this._countBits(R);b=26-j,b!==0&&(C=C.ushln(b),M.iushln(b),R=C.words[C.length-1]|0);var S=M.length-C.length,g;if(y!=="mod"){g=new a(null),g.length=S+1,g.words=new Array(g.length);for(var N=0;N<g.length;N++)g.words[N]=0}var it=M.clone()._ishlnsubmul(C,1,S);it.negative===0&&(M=it,g&&(g.words[S]=1));for(var lt=S-1;lt>=0;lt--){var _=(M.words[C.length+lt]|0)*67108864+(M.words[C.length+lt-1]|0);for(_=Math.min(_/R|0,67108863),M._ishlnsubmul(C,_,lt);M.negative!==0;)_--,M.negative=0,M._ishlnsubmul(C,1,lt),M.isZero()||(M.negative^=1);g&&(g.words[lt]=_)}return g&&g._strip(),M._strip(),y!=="div"&&b!==0&&M.iushrn(b),{div:g||null,mod:M}},a.prototype.divmod=function(h,y,b){if(i(!h.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var M,C,R;return this.negative!==0&&h.negative===0?(R=this.neg().divmod(h,y),y!=="mod"&&(M=R.div.neg()),y!=="div"&&(C=R.mod.neg(),b&&C.negative!==0&&C.iadd(h)),{div:M,mod:C}):this.negative===0&&h.negative!==0?(R=this.divmod(h.neg(),y),y!=="mod"&&(M=R.div.neg()),{div:M,mod:R.mod}):this.negative&h.negative?(R=this.neg().divmod(h.neg(),y),y!=="div"&&(C=R.mod.neg(),b&&C.negative!==0&&C.isub(h)),{div:R.div,mod:C}):h.length>this.length||this.cmp(h)<0?{div:new a(0),mod:this}:h.length===1?y==="div"?{div:this.divn(h.words[0]),mod:null}:y==="mod"?{div:null,mod:new a(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new a(this.modrn(h.words[0]))}:this._wordDiv(h,y)},a.prototype.div=function(h){return this.divmod(h,"div",!1).div},a.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},a.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},a.prototype.divRound=function(h){var y=this.divmod(h);if(y.mod.isZero())return y.div;var b=y.div.negative!==0?y.mod.isub(h):y.mod,M=h.ushrn(1),C=h.andln(1),R=b.cmp(M);return R<0||C===1&&R===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},a.prototype.modrn=function(h){var y=h<0;y&&(h=-h),i(h<=67108863);for(var b=(1<<26)%h,M=0,C=this.length-1;C>=0;C--)M=(b*M+(this.words[C]|0))%h;return y?-M:M},a.prototype.modn=function(h){return this.modrn(h)},a.prototype.idivn=function(h){var y=h<0;y&&(h=-h),i(h<=67108863);for(var b=0,M=this.length-1;M>=0;M--){var C=(this.words[M]|0)+b*67108864;this.words[M]=C/h|0,b=C%h}return this._strip(),y?this.ineg():this},a.prototype.divn=function(h){return this.clone().idivn(h)},a.prototype.egcd=function(h){i(h.negative===0),i(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var M=new a(1),C=new a(0),R=new a(0),j=new a(1),S=0;y.isEven()&&b.isEven();)y.iushrn(1),b.iushrn(1),++S;for(var g=b.clone(),N=y.clone();!y.isZero();){for(var it=0,lt=1;!(y.words[0]&lt)&&it<26;++it,lt<<=1);if(it>0)for(y.iushrn(it);it-- >0;)(M.isOdd()||C.isOdd())&&(M.iadd(g),C.isub(N)),M.iushrn(1),C.iushrn(1);for(var _=0,Z=1;!(b.words[0]&Z)&&_<26;++_,Z<<=1);if(_>0)for(b.iushrn(_);_-- >0;)(R.isOdd()||j.isOdd())&&(R.iadd(g),j.isub(N)),R.iushrn(1),j.iushrn(1);y.cmp(b)>=0?(y.isub(b),M.isub(R),C.isub(j)):(b.isub(y),R.isub(M),j.isub(C))}return{a:R,b:j,gcd:b.iushln(S)}},a.prototype._invmp=function(h){i(h.negative===0),i(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var M=new a(1),C=new a(0),R=b.clone();y.cmpn(1)>0&&b.cmpn(1)>0;){for(var j=0,S=1;!(y.words[0]&S)&&j<26;++j,S<<=1);if(j>0)for(y.iushrn(j);j-- >0;)M.isOdd()&&M.iadd(R),M.iushrn(1);for(var g=0,N=1;!(b.words[0]&N)&&g<26;++g,N<<=1);if(g>0)for(b.iushrn(g);g-- >0;)C.isOdd()&&C.iadd(R),C.iushrn(1);y.cmp(b)>=0?(y.isub(b),M.isub(C)):(b.isub(y),C.isub(M))}var it;return y.cmpn(1)===0?it=M:it=C,it.cmpn(0)<0&&it.iadd(h),it},a.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var y=this.clone(),b=h.clone();y.negative=0,b.negative=0;for(var M=0;y.isEven()&&b.isEven();M++)y.iushrn(1),b.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;b.isEven();)b.iushrn(1);var C=y.cmp(b);if(C<0){var R=y;y=b,b=R}else if(C===0||b.cmpn(1)===0)break;y.isub(b)}while(!0);return b.iushln(M)},a.prototype.invm=function(h){return this.egcd(h).a.umod(h)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(h){return this.words[0]&h},a.prototype.bincn=function(h){i(typeof h=="number");var y=h%26,b=(h-y)/26,M=1<<y;if(this.length<=b)return this._expand(b+1),this.words[b]|=M,this;for(var C=M,R=b;C!==0&&R<this.length;R++){var j=this.words[R]|0;j+=C,C=j>>>26,j&=67108863,this.words[R]=j}return C!==0&&(this.words[R]=C,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(h){var y=h<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var b;if(this.length>1)b=1;else{y&&(h=-h),i(h<=67108863,"Number is too big");var M=this.words[0]|0;b=M===h?0:M<h?-1:1}return this.negative!==0?-b|0:b},a.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var y=this.ucmp(h);return this.negative!==0?-y|0:y},a.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var y=0,b=this.length-1;b>=0;b--){var M=this.words[b]|0,C=h.words[b]|0;if(M!==C){M<C?y=-1:M>C&&(y=1);break}}return y},a.prototype.gtn=function(h){return this.cmpn(h)===1},a.prototype.gt=function(h){return this.cmp(h)===1},a.prototype.gten=function(h){return this.cmpn(h)>=0},a.prototype.gte=function(h){return this.cmp(h)>=0},a.prototype.ltn=function(h){return this.cmpn(h)===-1},a.prototype.lt=function(h){return this.cmp(h)===-1},a.prototype.lten=function(h){return this.cmpn(h)<=0},a.prototype.lte=function(h){return this.cmp(h)<=0},a.prototype.eqn=function(h){return this.cmpn(h)===0},a.prototype.eq=function(h){return this.cmp(h)===0},a.red=function(h){return new pt(h)},a.prototype.toRed=function(h){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(h){return this.red=h,this},a.prototype.forceRed=function(h){return i(!this.red,"Already a number in reduction context"),this._forceRed(h)},a.prototype.redAdd=function(h){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},a.prototype.redIAdd=function(h){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},a.prototype.redSub=function(h){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},a.prototype.redISub=function(h){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},a.prototype.redShl=function(h){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},a.prototype.redMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},a.prototype.redIMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},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(h){return i(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var $={k256:null,p224:null,p192:null,p25519:null};function z(h,y){this.name=h,this.p=new a(y,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var h=new a(null);return h.words=new Array(Math.ceil(this.n/13)),h},z.prototype.ireduce=function(h){var y=h,b;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),b=y.bitLength();while(b>this.n);var M=b<this.n?-1:y.ucmp(this.p);return M===0?(y.words[0]=0,y.length=1):M>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},z.prototype.split=function(h,y){h.iushrn(this.n,0,y)},z.prototype.imulK=function(h){return h.imul(this.k)};function v(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(v,z),v.prototype.split=function(h,y){for(var b=4194303,M=Math.min(h.length,9),C=0;C<M;C++)y.words[C]=h.words[C];if(y.length=M,h.length<=9){h.words[0]=0,h.length=1;return}var R=h.words[9];for(y.words[y.length++]=R&b,C=10;C<h.length;C++){var j=h.words[C]|0;h.words[C-10]=(j&b)<<4|R>>>22,R=j}R>>>=22,h.words[C-10]=R,R===0&&h.length>10?h.length-=10:h.length-=9},v.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var y=0,b=0;b<h.length;b++){var M=h.words[b]|0;y+=M*977,h.words[b]=y&67108863,y=M*64+(y/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function T(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(T,z);function nt(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(nt,z);function ft(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ft,z),ft.prototype.imulK=function(h){for(var y=0,b=0;b<h.length;b++){var M=(h.words[b]|0)*19+y,C=M&67108863;M>>>=26,h.words[b]=C,y=M}return y!==0&&(h.words[h.length++]=y),h},a._prime=function(h){if($[h])return $[h];var y;if(h==="k256")y=new v;else if(h==="p224")y=new T;else if(h==="p192")y=new nt;else if(h==="p25519")y=new ft;else throw new Error("Unknown prime "+h);return $[h]=y,y};function pt(h){if(typeof h=="string"){var y=a._prime(h);this.m=y.p,this.prime=y}else i(h.gtn(1),"modulus must be greater than 1"),this.m=h,this.prime=null}pt.prototype._verify1=function(h){i(h.negative===0,"red works only with positives"),i(h.red,"red works only with red numbers")},pt.prototype._verify2=function(h,y){i((h.negative|y.negative)===0,"red works only with positives"),i(h.red&&h.red===y.red,"red works only with red numbers")},pt.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(w(h,h.umod(this.m)._forceRed(this)),h)},pt.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},pt.prototype.add=function(h,y){this._verify2(h,y);var b=h.add(y);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},pt.prototype.iadd=function(h,y){this._verify2(h,y);var b=h.iadd(y);return b.cmp(this.m)>=0&&b.isub(this.m),b},pt.prototype.sub=function(h,y){this._verify2(h,y);var b=h.sub(y);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},pt.prototype.isub=function(h,y){this._verify2(h,y);var b=h.isub(y);return b.cmpn(0)<0&&b.iadd(this.m),b},pt.prototype.shl=function(h,y){return this._verify1(h),this.imod(h.ushln(y))},pt.prototype.imul=function(h,y){return this._verify2(h,y),this.imod(h.imul(y))},pt.prototype.mul=function(h,y){return this._verify2(h,y),this.imod(h.mul(y))},pt.prototype.isqr=function(h){return this.imul(h,h.clone())},pt.prototype.sqr=function(h){return this.mul(h,h)},pt.prototype.sqrt=function(h){if(h.isZero())return h.clone();var y=this.m.andln(3);if(i(y%2===1),y===3){var b=this.m.add(new a(1)).iushrn(2);return this.pow(h,b)}for(var M=this.m.subn(1),C=0;!M.isZero()&&M.andln(1)===0;)C++,M.iushrn(1);i(!M.isZero());var R=new a(1).toRed(this),j=R.redNeg(),S=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new a(2*g*g).toRed(this);this.pow(g,S).cmp(j)!==0;)g.redIAdd(j);for(var N=this.pow(g,M),it=this.pow(h,M.addn(1).iushrn(1)),lt=this.pow(h,M),_=C;lt.cmp(R)!==0;){for(var Z=lt,U=0;Z.cmp(R)!==0;U++)Z=Z.redSqr();i(U<_);var L=this.pow(N,new a(1).iushln(_-U-1));it=it.redMul(L),N=L.redSqr(),lt=lt.redMul(N),_=U}return it},pt.prototype.invm=function(h){var y=h._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},pt.prototype.pow=function(h,y){if(y.isZero())return new a(1).toRed(this);if(y.cmpn(1)===0)return h.clone();var b=4,M=new Array(1<<b);M[0]=new a(1).toRed(this),M[1]=h;for(var C=2;C<M.length;C++)M[C]=this.mul(M[C-1],h);var R=M[0],j=0,S=0,g=y.bitLength()%26;for(g===0&&(g=26),C=y.length-1;C>=0;C--){for(var N=y.words[C],it=g-1;it>=0;it--){var lt=N>>it&1;if(R!==M[0]&&(R=this.sqr(R)),lt===0&&j===0){S=0;continue}j<<=1,j|=lt,S++,!(S!==b&&(C!==0||it!==0))&&(R=this.mul(R,M[j]),S=0,j=0)}g=26}return R},pt.prototype.convertTo=function(h){var y=h.umod(this.m);return y===h?y.clone():y},pt.prototype.convertFrom=function(h){var y=h.clone();return y.red=null,y},a.mont=function(h){return new mt(h)};function mt(h){pt.call(this,h),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(mt,pt),mt.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},mt.prototype.convertFrom=function(h){var y=this.imod(h.mul(this.rinv));return y.red=null,y},mt.prototype.imul=function(h,y){if(h.isZero()||y.isZero())return h.words[0]=0,h.length=1,h;var b=h.imul(y),M=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),C=b.isub(M).iushrn(this.shift),R=C;return C.cmp(this.m)>=0?R=C.isub(this.m):C.cmpn(0)<0&&(R=C.iadd(this.m)),R._forceRed(this)},mt.prototype.mul=function(h,y){if(h.isZero()||y.isZero())return new a(0)._forceRed(this);var b=h.mul(y),M=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),C=b.isub(M).iushrn(this.shift),R=C;return C.cmp(this.m)>=0?R=C.isub(this.m):C.cmpn(0)<0&&(R=C.iadd(this.m)),R._forceRed(this)},mt.prototype.invm=function(h){var y=this.imod(h._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(r,J1)})(eg);var ne=eg.exports;const rg="bignumber/5.7.0";var Gc=ne.BN;const Sn=new gr(rg),Fh={},kd=9007199254740991;function v5(r){return r!=null&&(Tr.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||ii(r)||typeof r=="bigint"||mo(r))}let Hd=!1,Tr=class Fi{constructor(t,e){t!==Fh&&Sn.throwError("cannot call constructor directly; use BigNumber.from",gr.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return jr(me(this).fromTwos(t))}toTwos(t){return jr(me(this).toTwos(t))}abs(){return this._hex[0]==="-"?Fi.from(this._hex.substring(1)):this}add(t){return jr(me(this).add(me(t)))}sub(t){return jr(me(this).sub(me(t)))}div(t){return Fi.from(t).isZero()&&wi("division-by-zero","div"),jr(me(this).div(me(t)))}mul(t){return jr(me(this).mul(me(t)))}mod(t){const e=me(t);return e.isNeg()&&wi("division-by-zero","mod"),jr(me(this).umod(e))}pow(t){const e=me(t);return e.isNeg()&&wi("negative-power","pow"),jr(me(this).pow(e))}and(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","and"),jr(me(this).and(e))}or(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","or"),jr(me(this).or(e))}xor(t){const e=me(t);return(this.isNegative()||e.isNeg())&&wi("unbound-bitwise-result","xor"),jr(me(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&wi("negative-width","mask"),jr(me(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&wi("negative-width","shl"),jr(me(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&wi("negative-width","shr"),jr(me(this).shrn(t))}eq(t){return me(this).eq(me(t))}lt(t){return me(this).lt(me(t))}lte(t){return me(this).lte(me(t))}gt(t){return me(this).gt(me(t))}gte(t){return me(this).gte(me(t))}isNegative(){return this._hex[0]==="-"}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch{wi("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Sn.throwError("this platform does not support BigInt",gr.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Hd||(Hd=!0,Sn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Sn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",gr.errors.UNEXPECTED_ARGUMENT,{}):Sn.throwError("BigNumber.toString does not accept parameters",gr.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Fi)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new Fi(Fh,na(t)):t.match(/^-?[0-9]+$/)?new Fi(Fh,na(new Gc(t))):Sn.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&wi("underflow","BigNumber.from",t),(t>=kd||t<=-kd)&&wi("overflow","BigNumber.from",t),Fi.from(String(t));const e=t;if(typeof e=="bigint")return Fi.from(e.toString());if(mo(e))return Fi.from(Cr(e));if(e)if(e.toHexString){const i=e.toHexString();if(typeof i=="string")return Fi.from(i)}else{let i=e._hex;if(i==null&&e.type==="BigNumber"&&(i=e.hex),typeof i=="string"&&(ii(i)||i[0]==="-"&&ii(i.substring(1))))return Fi.from(i)}return Sn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}};function na(r){if(typeof r!="string")return na(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Sn.throwArgumentError("invalid hex","value",r),r=na(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 jr(r){return Tr.from(na(r))}function me(r){const t=Tr.from(r).toHexString();return t[0]==="-"?new Gc("-"+t.substring(3),16):new Gc(t.substring(2),16)}function wi(r,t,e){const i={fault:r,operation:t};return e!=null&&(i.value=e),Sn.throwError(r,gr.errors.NUMERIC_FAULT,i)}function y5(r){return new Gc(r,36).toString(16)}const Pr=new gr(rg),Xo={},ig=Tr.from(0),ng=Tr.from(-1);function sg(r,t,e,i){const s={fault:t,operation:e};return i!==void 0&&(s.value=i),Pr.throwError(r,gr.errors.NUMERIC_FAULT,s)}let Zo="0";for(;Zo.length<256;)Zo+=Zo;function Vl(r){if(typeof r!="number")try{r=Tr.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Zo.substring(0,r):Pr.throwArgumentError("invalid decimal size","decimals",r)}function Uh(r,t){t==null&&(t=0);const e=Vl(t);r=Tr.from(r);const i=r.lt(ig);i&&(r=r.mul(ng));let s=r.mod(e).toString();for(;s.length<e.length-1;)s="0"+s;s=s.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=r.div(e).toString();return e.length===1?r=a:r=a+"."+s,i&&(r="-"+r),r}function bn(r,t){t==null&&(t=0);const e=Vl(t);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Pr.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Pr.throwArgumentError("missing value","value",r);const s=r.split(".");s.length>2&&Pr.throwArgumentError("too many decimal points","value",r);let a=s[0],u=s[1];for(a||(a="0"),u||(u="0");u[u.length-1]==="0";)u=u.substring(0,u.length-1);for(u.length>e.length-1&&sg("fractional component exceeds decimals","underflow","parseFixed"),u===""&&(u="0");u.length<e.length-1;)u+="0";const l=Tr.from(a),d=Tr.from(u);let f=l.mul(e).add(d);return i&&(f=f.mul(ng)),f}let Bh=class bl{constructor(t,e,i,s){t!==Xo&&Pr.throwError("cannot use FixedFormat constructor; use FixedFormat.from",gr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=i,this.decimals=s,this.name=(e?"":"u")+"fixed"+String(i)+"x"+String(s),this._multiplier=Vl(s),Object.freeze(this)}static from(t){if(t instanceof bl)return t;typeof t=="number"&&(t=`fixed128x${t}`);let e=!0,i=128,s=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")e=!1;else{const a=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);a||Pr.throwArgumentError("invalid fixed format","format",t),e=a[1]!=="u",i=parseInt(a[2]),s=parseInt(a[3])}}else if(t){const a=(u,l,d)=>t[u]==null?d:(typeof t[u]!==l&&Pr.throwArgumentError("invalid fixed format ("+u+" not "+l+")","format."+u,t[u]),t[u]);e=a("signed","boolean",e),i=a("width","number",i),s=a("decimals","number",s)}return i%8&&Pr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),s>80&&Pr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new bl(Xo,e,i,s)}},og=class Mr{constructor(t,e,i,s){t!==Xo&&Pr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",gr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=s,this._hex=e,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&Pr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),i=bn(t._value,t.format.decimals);return Mr.fromValue(e.add(i),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),i=bn(t._value,t.format.decimals);return Mr.fromValue(e.sub(i),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),i=bn(t._value,t.format.decimals);return Mr.fromValue(e.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),i=bn(t._value,t.format.decimals);return Mr.fromValue(e.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Mr.from(t[0],this.format);const i=!t[1].match(/^(0*)$/);return this.isNegative()&&i&&(e=e.subUnsafe(Kd.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Mr.from(t[0],this.format);const i=!t[1].match(/^(0*)$/);return!this.isNegative()&&i&&(e=e.addUnsafe(Kd.toFormat(e.format))),e}round(t){t==null&&(t=0);const e=this.toString().split(".");if(e.length===1&&e.push("0"),(t<0||t>80||t%1)&&Pr.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const i=Mr.from("1"+Zo.substring(0,t),this.format),s=w5.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(t){if(t==null)return this._hex;t%8&&Pr.throwArgumentError("invalid byte width","width",t);const e=Tr.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return rn(e,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return Mr.fromString(this._value,t)}static fromValue(t,e,i){return i==null&&e!=null&&!v5(e)&&(i=e,e=null),e==null&&(e=0),i==null&&(i="fixed"),Mr.fromString(Uh(t,e),Bh.from(i))}static fromString(t,e){e==null&&(e="fixed");const i=Bh.from(e),s=bn(t,i.decimals);!i.signed&&s.lt(ig)&&sg("unsigned value cannot be negative","overflow","value",t);let a=null;i.signed?a=s.toTwos(i.width).toHexString():(a=s.toHexString(),a=rn(a,i.width/8));const u=Uh(s,i.decimals);return new Mr(Xo,a,u,i)}static fromBytes(t,e){e==null&&(e="fixed");const i=Bh.from(e);if(Ye(t).length>i.width/8)throw new Error("overflow");let s=Tr.from(t);i.signed&&(s=s.fromTwos(i.width));const a=s.toTwos((i.signed?0:1)+i.width).toHexString(),u=Uh(s,i.decimals);return new Mr(Xo,a,u,i)}static from(t,e){if(typeof t=="string")return Mr.fromString(t,e);if(mo(t))return Mr.fromBytes(t,e);try{return Mr.fromValue(t,0,e)}catch(i){if(i.code!==gr.errors.INVALID_ARGUMENT)throw i}return Pr.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}};const Kd=og.from(1),w5=og.from("0.5"),b5="strings/5.7.0",_5=new gr(b5);var Wc;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Wc||(Wc={}));var Vd;(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"})(Vd||(Vd={}));function Lh(r,t=Wc.current){t!=Wc.current&&(_5.checkNormalize(),r=r.normalize(t));let e=[];for(let i=0;i<r.length;i++){const s=r.charCodeAt(i);if(s<128)e.push(s);else if(s<2048)e.push(s>>6|192),e.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 u=65536+((s&1023)<<10)+(a&1023);e.push(u>>18|240),e.push(u>>12&63|128),e.push(u>>6&63|128),e.push(u&63|128)}else e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128)}return Ye(e)}function E5(r){if(r.length%4!==0)throw new Error("bad data");let t=[];for(let e=0;e<r.length;e+=4)t.push(parseInt(r.substring(e,e+4),16));return t}function qh(r,t){t||(t=function(s){return[parseInt(s,16)]});let e=0,i={};return r.split(",").forEach(s=>{let a=s.split(":");e+=parseInt(a[0],16),i[e]=t(a[1])}),i}function Gd(r){let t=0;return r.split(",").map(e=>{let i=e.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let s=t+parseInt(i[0],16);return t=parseInt(i[1],16),{l:s,h:t}})}Gd("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)),qh("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"),qh("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"),qh("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",E5),Gd("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 A5(r){r=atob(r);const t=[];for(let e=0;e<r.length;e++)t.push(r.charCodeAt(e));return Ye(t)}function ag(r,t){t==null&&(t=1);const e=[],i=e.forEach,s=function(a,u){i.call(a,function(l){u>0&&Array.isArray(l)?s(l,u-1):e.push(l)})};return s(r,t),e}function S5(r){const t={};for(let e=0;e<r.length;e++){const i=r[e];t[i[0]]=i[1]}return t}function I5(r){let t=0;function e(){return r[t++]<<8|r[t++]}let i=e(),s=1,a=[0,1];for(let $=1;$<i;$++)a.push(s+=e());let u=e(),l=t;t+=u;let d=0,f=0;function w(){return d==0&&(f=f<<8|r[t++],d=8),f>>--d&1}const E=31,I=Math.pow(2,E),D=I>>>1,P=D>>1,Y=I-1;let G=0;for(let $=0;$<E;$++)G=G<<1|w();let tt=[],K=0,V=I;for(;;){let $=Math.floor(((G-K+1)*s-1)/V),z=0,v=i;for(;v-z>1;){let ft=z+v>>>1;$<a[ft]?v=ft:z=ft}if(z==0)break;tt.push(z);let T=K+Math.floor(V*a[z]/s),nt=K+Math.floor(V*a[z+1]/s)-1;for(;!((T^nt)&D);)G=G<<1&Y|w(),T=T<<1&Y,nt=nt<<1&Y|1;for(;T&~nt&P;)G=G&D|G<<1&Y>>>1|w(),T=T<<1^D,nt=(nt^D)<<1|D|1;K=T,V=1+nt-T}let B=i-4;return tt.map($=>{switch($-B){case 3:return B+65792+(r[l++]<<16|r[l++]<<8|r[l++]);case 2:return B+256+(r[l++]<<8|r[l++]);case 1:return B+r[l++];default:return $-1}})}function D5(r){let t=0;return()=>r[t++]}function x5(r){return D5(I5(r))}function M5(r){return r&1?~r>>1:r>>1}function C5(r,t){let e=Array(r);for(let i=0;i<r;i++)e[i]=1+t();return e}function Wd(r,t){let e=Array(r);for(let i=0,s=-1;i<r;i++)e[i]=s+=1+t();return e}function P5(r,t){let e=Array(r);for(let i=0,s=0;i<r;i++)e[i]=s+=M5(t());return e}function Yc(r,t){let e=Wd(r(),r),i=r(),s=Wd(i,r),a=C5(i,r);for(let u=0;u<i;u++)for(let l=0;l<a[u];l++)e.push(s[u]+l);return t?e.map(u=>t[u]):e}function O5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(R5(e,r))}for(;;){let e=r()-1;if(e<0)break;t.push(T5(e,r))}return S5(ag(t))}function N5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(e)}return t}function cg(r,t,e){let i=Array(r).fill(void 0).map(()=>[]);for(let s=0;s<t;s++)P5(r,e).forEach((a,u)=>i[u].push(a));return i}function R5(r,t){let e=1+t(),i=t(),s=N5(t),a=cg(s.length,1+r,t);return ag(a.map((u,l)=>{const d=u[0],f=u.slice(1);return Array(s[l]).fill(void 0).map((w,E)=>{let I=E*i;return[d+E*e,f.map(D=>D+I)]})}))}function T5(r,t){let e=1+t();return cg(e,1+r,t).map(i=>[i[0],i.slice(1)])}function F5(r){let t=Yc(r).sort((i,s)=>i-s);return e();function e(){let i=[];for(;;){let f=Yc(r,t);if(f.length==0)break;i.push({set:new Set(f),node:e()})}i.sort((f,w)=>w.set.size-f.set.size);let s=r(),a=s%3;s=s/3|0;let u=!!(s&1);s>>=1;let l=s==1,d=s==2;return{branches:i,valid:a,fe0f:u,save:l,check:d}}}function U5(){return x5(A5("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 Sc=U5();new Set(Yc(Sc)),new Set(Yc(Sc)),O5(Sc),F5(Sc);const B5=new Uint8Array(32);B5.fill(0);const L5=`Ethereum Signed Message:
22
+ `;function ug(r){return typeof r=="string"&&(r=Lh(r)),Kl(l5([Lh(L5),Lh(String(r.length)),r]))}const q5="address/5.7.0",Yo=new gr(q5);function Yd(r){ii(r,20)||Yo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let s=0;s<40;s++)e[s]=t[s].charCodeAt(0);const i=Ye(Kl(e));for(let s=0;s<40;s+=2)i[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(i[s>>1]&15)>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const j5=9007199254740991;function $5(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Gl={};for(let r=0;r<10;r++)Gl[String(r)]=String(r);for(let r=0;r<26;r++)Gl[String.fromCharCode(65+r)]=String(10+r);const Qd=Math.floor($5(j5));function z5(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(i=>Gl[i]).join("");for(;t.length>=Qd;){let i=t.substring(0,Qd);t=parseInt(i,10)%97+t.substring(i.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}function k5(r){let t=null;if(typeof r!="string"&&Yo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=Yd(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&Yo.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)!==z5(r)&&Yo.throwArgumentError("bad icap checksum","address",r),t=y5(r.substring(4));t.length<40;)t="0"+t;t=Yd("0x"+t)}else Yo.throwArgumentError("invalid address","address",r);return t}function zo(r,t,e){Object.defineProperty(r,t,{enumerable:!0,value:e,writable:!1})}const H5=new Uint8Array(32);H5.fill(0),Tr.from(-1);const K5=Tr.from(0),V5=Tr.from(1);Tr.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),rn(V5.toHexString(),32),rn(K5.toHexString(),32);var Wi={},ve={},pa=hg;function hg(r,t){if(!r)throw new Error(t||"Assertion failed")}hg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var _l={exports:{}};typeof Object.create=="function"?_l.exports=function(r,t){t&&(r.super_=t,r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:_l.exports=function(r,t){if(t){r.super_=t;var e=function(){};e.prototype=t.prototype,r.prototype=new e,r.prototype.constructor=r}};var G5=pa,W5=_l.exports;ve.inherits=W5;function Y5(r,t){return(r.charCodeAt(t)&64512)!==55296||t<0||t+1>=r.length?!1:(r.charCodeAt(t+1)&64512)===56320}function Q5(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var e=[];if(typeof r=="string")if(t){if(t==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),s=0;s<r.length;s+=2)e.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?e[i++]=a:a<2048?(e[i++]=a>>6|192,e[i++]=a&63|128):Y5(r,s)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++s)&1023),e[i++]=a>>18|240,e[i++]=a>>12&63|128,e[i++]=a>>6&63|128,e[i++]=a&63|128):(e[i++]=a>>12|224,e[i++]=a>>6&63|128,e[i++]=a&63|128)}else for(s=0;s<r.length;s++)e[s]=r[s]|0;return e}ve.toArray=Q5;function J5(r){for(var t="",e=0;e<r.length;e++)t+=fg(r[e].toString(16));return t}ve.toHex=J5;function lg(r){var t=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return t>>>0}ve.htonl=lg;function X5(r,t){for(var e="",i=0;i<r.length;i++){var s=r[i];t==="little"&&(s=lg(s)),e+=dg(s.toString(16))}return e}ve.toHex32=X5;function fg(r){return r.length===1?"0"+r:r}ve.zero2=fg;function dg(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}ve.zero8=dg;function Z5(r,t,e,i){var s=e-t;G5(s%4===0);for(var a=new Array(s/4),u=0,l=t;u<a.length;u++,l+=4){var d;i==="big"?d=r[l]<<24|r[l+1]<<16|r[l+2]<<8|r[l+3]:d=r[l+3]<<24|r[l+2]<<16|r[l+1]<<8|r[l],a[u]=d>>>0}return a}ve.join32=Z5;function t8(r,t){for(var e=new Array(r.length*4),i=0,s=0;i<r.length;i++,s+=4){var a=r[i];t==="big"?(e[s]=a>>>24,e[s+1]=a>>>16&255,e[s+2]=a>>>8&255,e[s+3]=a&255):(e[s+3]=a>>>24,e[s+2]=a>>>16&255,e[s+1]=a>>>8&255,e[s]=a&255)}return e}ve.split32=t8;function e8(r,t){return r>>>t|r<<32-t}ve.rotr32=e8;function r8(r,t){return r<<t|r>>>32-t}ve.rotl32=r8;function i8(r,t){return r+t>>>0}ve.sum32=i8;function n8(r,t,e){return r+t+e>>>0}ve.sum32_3=n8;function s8(r,t,e,i){return r+t+e+i>>>0}ve.sum32_4=s8;function o8(r,t,e,i,s){return r+t+e+i+s>>>0}ve.sum32_5=o8;function a8(r,t,e,i){var s=r[t],a=r[t+1],u=i+a>>>0,l=(u<i?1:0)+e+s;r[t]=l>>>0,r[t+1]=u}ve.sum64=a8;function c8(r,t,e,i){var s=t+i>>>0,a=(s<t?1:0)+r+e;return a>>>0}ve.sum64_hi=c8;function u8(r,t,e,i){var s=t+i;return s>>>0}ve.sum64_lo=u8;function h8(r,t,e,i,s,a,u,l){var d=0,f=t;f=f+i>>>0,d+=f<t?1:0,f=f+a>>>0,d+=f<a?1:0,f=f+l>>>0,d+=f<l?1:0;var w=r+e+s+u+d;return w>>>0}ve.sum64_4_hi=h8;function l8(r,t,e,i,s,a,u,l){var d=t+i+a+l;return d>>>0}ve.sum64_4_lo=l8;function f8(r,t,e,i,s,a,u,l,d,f){var w=0,E=t;E=E+i>>>0,w+=E<t?1:0,E=E+a>>>0,w+=E<a?1:0,E=E+l>>>0,w+=E<l?1:0,E=E+f>>>0,w+=E<f?1:0;var I=r+e+s+u+d+w;return I>>>0}ve.sum64_5_hi=f8;function d8(r,t,e,i,s,a,u,l,d,f){var w=t+i+a+l+f;return w>>>0}ve.sum64_5_lo=d8;function p8(r,t,e){var i=t<<32-e|r>>>e;return i>>>0}ve.rotr64_hi=p8;function g8(r,t,e){var i=r<<32-e|t>>>e;return i>>>0}ve.rotr64_lo=g8;function m8(r,t,e){return r>>>e}ve.shr64_hi=m8;function v8(r,t,e){var i=r<<32-e|t>>>e;return i>>>0}ve.shr64_lo=v8;var vo={},Jd=ve,y8=pa;function Ic(){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}vo.BlockHash=Ic,Ic.prototype.update=function(r,t){if(r=Jd.toArray(r,t),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var e=r.length%this._delta8;this.pending=r.slice(r.length-e,r.length),this.pending.length===0&&(this.pending=null),r=Jd.join32(r,0,r.length-e,this.endian);for(var i=0;i<r.length;i+=this._delta32)this._update(r,i,i+this._delta32)}return this},Ic.prototype.digest=function(r){return this.update(this._pad()),y8(this.pending===null),this._digest(r)},Ic.prototype._pad=function(){var r=this.pendingTotal,t=this._delta8,e=t-(r+this.padLength)%t,i=new Array(e+this.padLength);i[0]=128;for(var s=1;s<e;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 to={},un={},w8=ve,nn=w8.rotr32;function b8(r,t,e,i){if(r===0)return pg(t,e,i);if(r===1||r===3)return mg(t,e,i);if(r===2)return gg(t,e,i)}un.ft_1=b8;function pg(r,t,e){return r&t^~r&e}un.ch32=pg;function gg(r,t,e){return r&t^r&e^t&e}un.maj32=gg;function mg(r,t,e){return r^t^e}un.p32=mg;function _8(r){return nn(r,2)^nn(r,13)^nn(r,22)}un.s0_256=_8;function E8(r){return nn(r,6)^nn(r,11)^nn(r,25)}un.s1_256=E8;function A8(r){return nn(r,7)^nn(r,18)^r>>>3}un.g0_256=A8;function S8(r){return nn(r,17)^nn(r,19)^r>>>10}un.g1_256=S8;var uo=ve,I8=vo,D8=un,jh=uo.rotl32,ko=uo.sum32,x8=uo.sum32_5,M8=D8.ft_1,vg=I8.BlockHash,C8=[1518500249,1859775393,2400959708,3395469782];function Zi(){if(!(this instanceof Zi))return new Zi;vg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}uo.inherits(Zi,vg);var P8=Zi;Zi.blockSize=512,Zi.outSize=160,Zi.hmacStrength=80,Zi.padLength=64,Zi.prototype._update=function(r,t){for(var e=this.W,i=0;i<16;i++)e[i]=r[t+i];for(;i<e.length;i++)e[i]=jh(e[i-3]^e[i-8]^e[i-14]^e[i-16],1);var s=this.h[0],a=this.h[1],u=this.h[2],l=this.h[3],d=this.h[4];for(i=0;i<e.length;i++){var f=~~(i/20),w=x8(jh(s,5),M8(f,a,u,l),d,e[i],C8[f]);d=l,l=u,u=jh(a,30),a=s,s=w}this.h[0]=ko(this.h[0],s),this.h[1]=ko(this.h[1],a),this.h[2]=ko(this.h[2],u),this.h[3]=ko(this.h[3],l),this.h[4]=ko(this.h[4],d)},Zi.prototype._digest=function(r){return r==="hex"?uo.toHex32(this.h,"big"):uo.split32(this.h,"big")};var ho=ve,O8=vo,yo=un,N8=pa,Ri=ho.sum32,R8=ho.sum32_4,T8=ho.sum32_5,F8=yo.ch32,U8=yo.maj32,B8=yo.s0_256,L8=yo.s1_256,q8=yo.g0_256,j8=yo.g1_256,yg=O8.BlockHash,$8=[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 tn(){if(!(this instanceof tn))return new tn;yg.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=$8,this.W=new Array(64)}ho.inherits(tn,yg);var wg=tn;tn.blockSize=512,tn.outSize=256,tn.hmacStrength=192,tn.padLength=64,tn.prototype._update=function(r,t){for(var e=this.W,i=0;i<16;i++)e[i]=r[t+i];for(;i<e.length;i++)e[i]=R8(j8(e[i-2]),e[i-7],q8(e[i-15]),e[i-16]);var s=this.h[0],a=this.h[1],u=this.h[2],l=this.h[3],d=this.h[4],f=this.h[5],w=this.h[6],E=this.h[7];for(N8(this.k.length===e.length),i=0;i<e.length;i++){var I=T8(E,L8(d),F8(d,f,w),this.k[i],e[i]),D=Ri(B8(s),U8(s,a,u));E=w,w=f,f=d,d=Ri(l,I),l=u,u=a,a=s,s=Ri(I,D)}this.h[0]=Ri(this.h[0],s),this.h[1]=Ri(this.h[1],a),this.h[2]=Ri(this.h[2],u),this.h[3]=Ri(this.h[3],l),this.h[4]=Ri(this.h[4],d),this.h[5]=Ri(this.h[5],f),this.h[6]=Ri(this.h[6],w),this.h[7]=Ri(this.h[7],E)},tn.prototype._digest=function(r){return r==="hex"?ho.toHex32(this.h,"big"):ho.split32(this.h,"big")};var El=ve,bg=wg;function In(){if(!(this instanceof In))return new In;bg.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}El.inherits(In,bg);var z8=In;In.blockSize=512,In.outSize=224,In.hmacStrength=192,In.padLength=64,In.prototype._digest=function(r){return r==="hex"?El.toHex32(this.h.slice(0,7),"big"):El.split32(this.h.slice(0,7),"big")};var Kr=ve,k8=vo,H8=pa,sn=Kr.rotr64_hi,on=Kr.rotr64_lo,_g=Kr.shr64_hi,Eg=Kr.shr64_lo,zn=Kr.sum64,$h=Kr.sum64_hi,zh=Kr.sum64_lo,K8=Kr.sum64_4_hi,V8=Kr.sum64_4_lo,G8=Kr.sum64_5_hi,W8=Kr.sum64_5_lo,Ag=k8.BlockHash,Y8=[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 Bi(){if(!(this instanceof Bi))return new Bi;Ag.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Y8,this.W=new Array(160)}Kr.inherits(Bi,Ag);var Sg=Bi;Bi.blockSize=1024,Bi.outSize=512,Bi.hmacStrength=192,Bi.padLength=128,Bi.prototype._prepareBlock=function(r,t){for(var e=this.W,i=0;i<32;i++)e[i]=r[t+i];for(;i<e.length;i+=2){var s=oA(e[i-4],e[i-3]),a=aA(e[i-4],e[i-3]),u=e[i-14],l=e[i-13],d=nA(e[i-30],e[i-29]),f=sA(e[i-30],e[i-29]),w=e[i-32],E=e[i-31];e[i]=K8(s,a,u,l,d,f,w,E),e[i+1]=V8(s,a,u,l,d,f,w,E)}},Bi.prototype._update=function(r,t){this._prepareBlock(r,t);var e=this.W,i=this.h[0],s=this.h[1],a=this.h[2],u=this.h[3],l=this.h[4],d=this.h[5],f=this.h[6],w=this.h[7],E=this.h[8],I=this.h[9],D=this.h[10],P=this.h[11],Y=this.h[12],G=this.h[13],tt=this.h[14],K=this.h[15];H8(this.k.length===e.length);for(var V=0;V<e.length;V+=2){var B=tt,$=K,z=rA(E,I),v=iA(E,I),T=Q8(E,I,D,P,Y),nt=J8(E,I,D,P,Y,G),ft=this.k[V],pt=this.k[V+1],mt=e[V],h=e[V+1],y=G8(B,$,z,v,T,nt,ft,pt,mt,h),b=W8(B,$,z,v,T,nt,ft,pt,mt,h);B=tA(i,s),$=eA(i,s),z=X8(i,s,a,u,l),v=Z8(i,s,a,u,l,d);var M=$h(B,$,z,v),C=zh(B,$,z,v);tt=Y,K=G,Y=D,G=P,D=E,P=I,E=$h(f,w,y,b),I=zh(w,w,y,b),f=l,w=d,l=a,d=u,a=i,u=s,i=$h(y,b,M,C),s=zh(y,b,M,C)}zn(this.h,0,i,s),zn(this.h,2,a,u),zn(this.h,4,l,d),zn(this.h,6,f,w),zn(this.h,8,E,I),zn(this.h,10,D,P),zn(this.h,12,Y,G),zn(this.h,14,tt,K)},Bi.prototype._digest=function(r){return r==="hex"?Kr.toHex32(this.h,"big"):Kr.split32(this.h,"big")};function Q8(r,t,e,i,s){var a=r&e^~r&s;return a<0&&(a+=4294967296),a}function J8(r,t,e,i,s,a){var u=t&i^~t&a;return u<0&&(u+=4294967296),u}function X8(r,t,e,i,s){var a=r&e^r&s^e&s;return a<0&&(a+=4294967296),a}function Z8(r,t,e,i,s,a){var u=t&i^t&a^i&a;return u<0&&(u+=4294967296),u}function tA(r,t){var e=sn(r,t,28),i=sn(t,r,2),s=sn(t,r,7),a=e^i^s;return a<0&&(a+=4294967296),a}function eA(r,t){var e=on(r,t,28),i=on(t,r,2),s=on(t,r,7),a=e^i^s;return a<0&&(a+=4294967296),a}function rA(r,t){var e=sn(r,t,14),i=sn(r,t,18),s=sn(t,r,9),a=e^i^s;return a<0&&(a+=4294967296),a}function iA(r,t){var e=on(r,t,14),i=on(r,t,18),s=on(t,r,9),a=e^i^s;return a<0&&(a+=4294967296),a}function nA(r,t){var e=sn(r,t,1),i=sn(r,t,8),s=_g(r,t,7),a=e^i^s;return a<0&&(a+=4294967296),a}function sA(r,t){var e=on(r,t,1),i=on(r,t,8),s=Eg(r,t,7),a=e^i^s;return a<0&&(a+=4294967296),a}function oA(r,t){var e=sn(r,t,19),i=sn(t,r,29),s=_g(r,t,6),a=e^i^s;return a<0&&(a+=4294967296),a}function aA(r,t){var e=on(r,t,19),i=on(t,r,29),s=Eg(r,t,6),a=e^i^s;return a<0&&(a+=4294967296),a}var Al=ve,Ig=Sg;function Dn(){if(!(this instanceof Dn))return new Dn;Ig.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Al.inherits(Dn,Ig);var cA=Dn;Dn.blockSize=1024,Dn.outSize=384,Dn.hmacStrength=192,Dn.padLength=128,Dn.prototype._digest=function(r){return r==="hex"?Al.toHex32(this.h.slice(0,12),"big"):Al.split32(this.h.slice(0,12),"big")},to.sha1=P8,to.sha224=z8,to.sha256=wg,to.sha384=cA,to.sha512=Sg;var Dg={},Is=ve,uA=vo,Dc=Is.rotl32,Xd=Is.sum32,Ho=Is.sum32_3,Zd=Is.sum32_4,xg=uA.BlockHash;function Yi(){if(!(this instanceof Yi))return new Yi;xg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Is.inherits(Yi,xg),Dg.ripemd160=Yi,Yi.blockSize=512,Yi.outSize=160,Yi.hmacStrength=192,Yi.padLength=64,Yi.prototype._update=function(r,t){for(var e=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4],l=e,d=i,f=s,w=a,E=u,I=0;I<80;I++){var D=Xd(Dc(Zd(e,tp(I,i,s,a),r[fA[I]+t],hA(I)),pA[I]),u);e=u,u=a,a=Dc(s,10),s=i,i=D,D=Xd(Dc(Zd(l,tp(79-I,d,f,w),r[dA[I]+t],lA(I)),gA[I]),E),l=E,E=w,w=Dc(f,10),f=d,d=D}D=Ho(this.h[1],s,w),this.h[1]=Ho(this.h[2],a,E),this.h[2]=Ho(this.h[3],u,l),this.h[3]=Ho(this.h[4],e,d),this.h[4]=Ho(this.h[0],i,f),this.h[0]=D},Yi.prototype._digest=function(r){return r==="hex"?Is.toHex32(this.h,"little"):Is.split32(this.h,"little")};function tp(r,t,e,i){return r<=15?t^e^i:r<=31?t&e|~t&i:r<=47?(t|~e)^i:r<=63?t&i|e&~i:t^(e|~i)}function hA(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function lA(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var fA=[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],dA=[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],pA=[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],gA=[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],mA=ve,vA=pa;function ao(r,t,e){if(!(this instanceof ao))return new ao(r,t,e);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(mA.toArray(t,e))}var yA=ao;ao.prototype._init=function(r){r.length>this.blockSize&&(r=new this.Hash().update(r).digest()),vA(r.length<=this.blockSize);for(var t=r.length;t<this.blockSize;t++)r.push(0);for(t=0;t<r.length;t++)r[t]^=54;for(this.inner=new this.Hash().update(r),t=0;t<r.length;t++)r[t]^=106;this.outer=new this.Hash().update(r)},ao.prototype.update=function(r,t){return this.inner.update(r,t),this},ao.prototype.digest=function(r){return this.outer.update(this.inner.digest()),this.outer.digest(r)},function(r){var t=r;t.utils=ve,t.common=vo,t.sha=to,t.ripemd=Dg,t.hmac=yA,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160}(Wi);function wo(r,t,e){return e={path:t,exports:{},require:function(i,s){return wA(i,s??e.path)}},r(e,e.exports),e.exports}function wA(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Wl=Mg;function Mg(r,t){if(!r)throw new Error(t||"Assertion failed")}Mg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var Li=wo(function(r,t){var e=t;function i(u,l){if(Array.isArray(u))return u.slice();if(!u)return[];var d=[];if(typeof u!="string"){for(var f=0;f<u.length;f++)d[f]=u[f]|0;return d}if(l==="hex"){u=u.replace(/[^a-z0-9]+/ig,""),u.length%2!==0&&(u="0"+u);for(var f=0;f<u.length;f+=2)d.push(parseInt(u[f]+u[f+1],16))}else for(var f=0;f<u.length;f++){var w=u.charCodeAt(f),E=w>>8,I=w&255;E?d.push(E,I):d.push(I)}return d}e.toArray=i;function s(u){return u.length===1?"0"+u:u}e.zero2=s;function a(u){for(var l="",d=0;d<u.length;d++)l+=s(u[d].toString(16));return l}e.toHex=a,e.encode=function(u,l){return l==="hex"?a(u):u}}),ni=wo(function(r,t){var e=t;e.assert=Wl,e.toArray=Li.toArray,e.zero2=Li.zero2,e.toHex=Li.toHex,e.encode=Li.encode;function i(d,f,w){var E=new Array(Math.max(d.bitLength(),w)+1);E.fill(0);for(var I=1<<f+1,D=d.clone(),P=0;P<E.length;P++){var Y,G=D.andln(I-1);D.isOdd()?(G>(I>>1)-1?Y=(I>>1)-G:Y=G,D.isubn(Y)):Y=0,E[P]=Y,D.iushrn(1)}return E}e.getNAF=i;function s(d,f){var w=[[],[]];d=d.clone(),f=f.clone();for(var E=0,I=0,D;d.cmpn(-E)>0||f.cmpn(-I)>0;){var P=d.andln(3)+E&3,Y=f.andln(3)+I&3;P===3&&(P=-1),Y===3&&(Y=-1);var G;P&1?(D=d.andln(7)+E&7,(D===3||D===5)&&Y===2?G=-P:G=P):G=0,w[0].push(G);var tt;Y&1?(D=f.andln(7)+I&7,(D===3||D===5)&&P===2?tt=-Y:tt=Y):tt=0,w[1].push(tt),2*E===G+1&&(E=1-E),2*I===tt+1&&(I=1-I),d.iushrn(1),f.iushrn(1)}return w}e.getJSF=s;function a(d,f,w){var E="_"+f;d.prototype[f]=function(){return this[E]!==void 0?this[E]:this[E]=w.call(this)}}e.cachedProperty=a;function u(d){return typeof d=="string"?e.toArray(d,"hex"):d}e.parseBytes=u;function l(d){return new ne(d,"hex","le")}e.intFromLE=l}),xc=ni.getNAF,bA=ni.getJSF,Qc=ni.assert;function Kn(r,t){this.type=r,this.p=new ne(t.p,16),this.red=t.prime?ne.red(t.prime):ne.mont(this.p),this.zero=new ne(0).toRed(this.red),this.one=new ne(1).toRed(this.red),this.two=new ne(2).toRed(this.red),this.n=t.n&&new ne(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.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 e=this.n&&this.p.div(this.n);!e||e.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ms=Kn;Kn.prototype.point=function(){throw new Error("Not implemented")},Kn.prototype.validate=function(){throw new Error("Not implemented")},Kn.prototype._fixedNafMul=function(r,t){Qc(r.precomputed);var e=r._getDoubles(),i=xc(t,1,this._bitLength),s=(1<<e.step+1)-(e.step%2===0?2:1);s/=3;var a=[],u,l;for(u=0;u<i.length;u+=e.step){l=0;for(var d=u+e.step-1;d>=u;d--)l=(l<<1)+i[d];a.push(l)}for(var f=this.jpoint(null,null,null),w=this.jpoint(null,null,null),E=s;E>0;E--){for(u=0;u<a.length;u++)l=a[u],l===E?w=w.mixedAdd(e.points[u]):l===-E&&(w=w.mixedAdd(e.points[u].neg()));f=f.add(w)}return f.toP()},Kn.prototype._wnafMul=function(r,t){var e=4,i=r._getNAFPoints(e);e=i.wnd;for(var s=i.points,a=xc(t,e,this._bitLength),u=this.jpoint(null,null,null),l=a.length-1;l>=0;l--){for(var d=0;l>=0&&a[l]===0;l--)d++;if(l>=0&&d++,u=u.dblp(d),l<0)break;var f=a[l];Qc(f!==0),r.type==="affine"?f>0?u=u.mixedAdd(s[f-1>>1]):u=u.mixedAdd(s[-f-1>>1].neg()):f>0?u=u.add(s[f-1>>1]):u=u.add(s[-f-1>>1].neg())}return r.type==="affine"?u.toP():u},Kn.prototype._wnafMulAdd=function(r,t,e,i,s){var a=this._wnafT1,u=this._wnafT2,l=this._wnafT3,d=0,f,w,E;for(f=0;f<i;f++){E=t[f];var I=E._getNAFPoints(r);a[f]=I.wnd,u[f]=I.points}for(f=i-1;f>=1;f-=2){var D=f-1,P=f;if(a[D]!==1||a[P]!==1){l[D]=xc(e[D],a[D],this._bitLength),l[P]=xc(e[P],a[P],this._bitLength),d=Math.max(l[D].length,d),d=Math.max(l[P].length,d);continue}var Y=[t[D],null,null,t[P]];t[D].y.cmp(t[P].y)===0?(Y[1]=t[D].add(t[P]),Y[2]=t[D].toJ().mixedAdd(t[P].neg())):t[D].y.cmp(t[P].y.redNeg())===0?(Y[1]=t[D].toJ().mixedAdd(t[P]),Y[2]=t[D].add(t[P].neg())):(Y[1]=t[D].toJ().mixedAdd(t[P]),Y[2]=t[D].toJ().mixedAdd(t[P].neg()));var G=[-3,-1,-5,-7,0,7,5,1,3],tt=bA(e[D],e[P]);for(d=Math.max(tt[0].length,d),l[D]=new Array(d),l[P]=new Array(d),w=0;w<d;w++){var K=tt[0][w]|0,V=tt[1][w]|0;l[D][w]=G[(K+1)*3+(V+1)],l[P][w]=0,u[D]=Y}}var B=this.jpoint(null,null,null),$=this._wnafT4;for(f=d;f>=0;f--){for(var z=0;f>=0;){var v=!0;for(w=0;w<i;w++)$[w]=l[w][f]|0,$[w]!==0&&(v=!1);if(!v)break;z++,f--}if(f>=0&&z++,B=B.dblp(z),f<0)break;for(w=0;w<i;w++){var T=$[w];T!==0&&(T>0?E=u[w][T-1>>1]:T<0&&(E=u[w][-T-1>>1].neg()),E.type==="affine"?B=B.mixedAdd(E):B=B.add(E))}}for(f=0;f<i;f++)u[f]=null;return s?B:B.toP()};function bi(r,t){this.curve=r,this.type=t,this.precomputed=null}Kn.BasePoint=bi,bi.prototype.eq=function(){throw new Error("Not implemented")},bi.prototype.validate=function(){return this.curve.validate(this)},Kn.prototype.decodePoint=function(r,t){r=ni.toArray(r,t);var e=this.p.byteLength();if((r[0]===4||r[0]===6||r[0]===7)&&r.length-1===2*e){r[0]===6?Qc(r[r.length-1]%2===0):r[0]===7&&Qc(r[r.length-1]%2===1);var i=this.point(r.slice(1,1+e),r.slice(1+e,1+2*e));return i}else if((r[0]===2||r[0]===3)&&r.length-1===e)return this.pointFromX(r.slice(1,1+e),r[0]===3);throw new Error("Unknown point format")},bi.prototype.encodeCompressed=function(r){return this.encode(r,!0)},bi.prototype._encode=function(r){var t=this.curve.p.byteLength(),e=this.getX().toArray("be",t);return r?[this.getY().isEven()?2:3].concat(e):[4].concat(e,this.getY().toArray("be",t))},bi.prototype.encode=function(r,t){return ni.encode(this._encode(t),r)},bi.prototype.precompute=function(r){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,r),t.beta=this._getBeta(),this.precomputed=t,this},bi.prototype._hasDoubles=function(r){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((r.bitLength()+1)/t.step):!1},bi.prototype._getDoubles=function(r,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var e=[this],i=this,s=0;s<t;s+=r){for(var a=0;a<r;a++)i=i.dbl();e.push(i)}return{step:r,points:e}},bi.prototype._getNAFPoints=function(r){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],e=(1<<r)-1,i=e===1?null:this.dbl(),s=1;s<e;s++)t[s]=t[s-1].add(i);return{wnd:r,points:t}},bi.prototype._getBeta=function(){return null},bi.prototype.dblp=function(r){for(var t=this,e=0;e<r;e++)t=t.dbl();return t};var Yl=wo(function(r){typeof Object.create=="function"?r.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,e){if(e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}}}),_A=ni.assert;function Ii(r){Ms.call(this,"short",r),this.a=new ne(r.a,16).toRed(this.red),this.b=new ne(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)}Yl(Ii,Ms);var EA=Ii;Ii.prototype._getEndomorphism=function(r){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,e;if(r.beta)t=new ne(r.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(r.lambda)e=new ne(r.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?e=s[0]:(e=s[1],_A(this.g.mul(e).x.cmp(this.g.x.redMul(t))===0))}var a;return r.basis?a=r.basis.map(function(u){return{a:new ne(u.a,16),b:new ne(u.b,16)}}):a=this._getEndoBasis(e),{beta:t,lambda:e,basis:a}}},Ii.prototype._getEndoRoots=function(r){var t=r===this.p?this.red:ne.mont(r),e=new ne(2).toRed(t).redInvm(),i=e.redNeg(),s=new ne(3).toRed(t).redNeg().redSqrt().redMul(e),a=i.redAdd(s).fromRed(),u=i.redSub(s).fromRed();return[a,u]},Ii.prototype._getEndoBasis=function(r){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),e=r,i=this.n.clone(),s=new ne(1),a=new ne(0),u=new ne(0),l=new ne(1),d,f,w,E,I,D,P,Y=0,G,tt;e.cmpn(0)!==0;){var K=i.div(e);G=i.sub(K.mul(e)),tt=u.sub(K.mul(s));var V=l.sub(K.mul(a));if(!w&&G.cmp(t)<0)d=P.neg(),f=s,w=G.neg(),E=tt;else if(w&&++Y===2)break;P=G,i=e,e=G,u=s,s=tt,l=a,a=V}I=G.neg(),D=tt;var B=w.sqr().add(E.sqr()),$=I.sqr().add(D.sqr());return $.cmp(B)>=0&&(I=d,D=f),w.negative&&(w=w.neg(),E=E.neg()),I.negative&&(I=I.neg(),D=D.neg()),[{a:w,b:E},{a:I,b:D}]},Ii.prototype._endoSplit=function(r){var t=this.endo.basis,e=t[0],i=t[1],s=i.b.mul(r).divRound(this.n),a=e.b.neg().mul(r).divRound(this.n),u=s.mul(e.a),l=a.mul(i.a),d=s.mul(e.b),f=a.mul(i.b),w=r.sub(u).sub(l),E=d.add(f).neg();return{k1:w,k2:E}},Ii.prototype.pointFromX=function(r,t){r=new ne(r,16),r.red||(r=r.toRed(this.red));var e=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=e.redSqrt();if(i.redSqr().redSub(e).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(r,i)},Ii.prototype.validate=function(r){if(r.inf)return!0;var t=r.x,e=r.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return e.redSqr().redISub(s).cmpn(0)===0},Ii.prototype._endoWnafMulAdd=function(r,t,e){for(var i=this._endoWnafT1,s=this._endoWnafT2,a=0;a<r.length;a++){var u=this._endoSplit(t[a]),l=r[a],d=l._getBeta();u.k1.negative&&(u.k1.ineg(),l=l.neg(!0)),u.k2.negative&&(u.k2.ineg(),d=d.neg(!0)),i[a*2]=l,i[a*2+1]=d,s[a*2]=u.k1,s[a*2+1]=u.k2}for(var f=this._wnafMulAdd(1,i,s,a*2,e),w=0;w<a*2;w++)i[w]=null,s[w]=null;return f};function hr(r,t,e,i){Ms.BasePoint.call(this,r,"affine"),t===null&&e===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new ne(t,16),this.y=new ne(e,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)}Yl(hr,Ms.BasePoint),Ii.prototype.point=function(r,t,e){return new hr(this,r,t,e)},Ii.prototype.pointFromJSON=function(r,t){return hr.fromJSON(this,r,t)},hr.prototype._getBeta=function(){if(this.curve.endo){var r=this.precomputed;if(r&&r.beta)return r.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(r){var e=this.curve,i=function(s){return e.point(s.x.redMul(e.endo.beta),s.y)};r.beta=t,t.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 t}},hr.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]},hr.fromJSON=function(r,t,e){typeof t=="string"&&(t=JSON.parse(t));var i=r.point(t[0],t[1],e);if(!t[2])return i;function s(u){return r.point(u[0],u[1],e)}var a=t[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},hr.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)+">"},hr.prototype.isInfinity=function(){return this.inf},hr.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 t=this.y.redSub(r.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(r.x).redInvm()));var e=t.redSqr().redISub(this.x).redISub(r.x),i=t.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,i)},hr.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 t=this.curve.a,e=this.x.redSqr(),i=r.redInvm(),s=e.redAdd(e).redIAdd(e).redIAdd(t).redMul(i),a=s.redSqr().redISub(this.x.redAdd(this.x)),u=s.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,u)},hr.prototype.getX=function(){return this.x.fromRed()},hr.prototype.getY=function(){return this.y.fromRed()},hr.prototype.mul=function(r){return r=new ne(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)},hr.prototype.mulAdd=function(r,t,e){var i=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},hr.prototype.jmulAdd=function(r,t,e){var i=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},hr.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)},hr.prototype.neg=function(r){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var e=this.precomputed,i=function(s){return s.neg()};t.precomputed={naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t},hr.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 dr(r,t,e,i){Ms.BasePoint.call(this,r,"jacobian"),t===null&&e===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ne(0)):(this.x=new ne(t,16),this.y=new ne(e,16),this.z=new ne(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}Yl(dr,Ms.BasePoint),Ii.prototype.jpoint=function(r,t,e){return new dr(this,r,t,e)},dr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),t=r.redSqr(),e=this.x.redMul(t),i=this.y.redMul(t).redMul(r);return this.curve.point(e,i)},dr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},dr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var t=r.z.redSqr(),e=this.z.redSqr(),i=this.x.redMul(t),s=r.x.redMul(e),a=this.y.redMul(t.redMul(r.z)),u=r.y.redMul(e.redMul(this.z)),l=i.redSub(s),d=a.redSub(u);if(l.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f=l.redSqr(),w=f.redMul(l),E=i.redMul(f),I=d.redSqr().redIAdd(w).redISub(E).redISub(E),D=d.redMul(E.redISub(I)).redISub(a.redMul(w)),P=this.z.redMul(r.z).redMul(l);return this.curve.jpoint(I,D,P)},dr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var t=this.z.redSqr(),e=this.x,i=r.x.redMul(t),s=this.y,a=r.y.redMul(t).redMul(this.z),u=e.redSub(i),l=s.redSub(a);if(u.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=u.redSqr(),f=d.redMul(u),w=e.redMul(d),E=l.redSqr().redIAdd(f).redISub(w).redISub(w),I=l.redMul(w.redISub(E)).redISub(s.redMul(f)),D=this.z.redMul(u);return this.curve.jpoint(E,I,D)},dr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var e=this;for(t=0;t<r;t++)e=e.dbl();return e}var i=this.curve.a,s=this.curve.tinv,a=this.x,u=this.y,l=this.z,d=l.redSqr().redSqr(),f=u.redAdd(u);for(t=0;t<r;t++){var w=a.redSqr(),E=f.redSqr(),I=E.redSqr(),D=w.redAdd(w).redIAdd(w).redIAdd(i.redMul(d)),P=a.redMul(E),Y=D.redSqr().redISub(P.redAdd(P)),G=P.redISub(Y),tt=D.redMul(G);tt=tt.redIAdd(tt).redISub(I);var K=f.redMul(l);t+1<r&&(d=d.redMul(I)),a=Y,l=K,f=tt}return this.curve.jpoint(a,f.redMul(s),l)},dr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},dr.prototype._zeroDbl=function(){var r,t,e;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(a);u=u.redIAdd(u);var l=i.redAdd(i).redIAdd(i),d=l.redSqr().redISub(u).redISub(u),f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),r=d,t=l.redMul(u.redISub(d)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.x.redSqr(),E=this.y.redSqr(),I=E.redSqr(),D=this.x.redAdd(E).redSqr().redISub(w).redISub(I);D=D.redIAdd(D);var P=w.redAdd(w).redIAdd(w),Y=P.redSqr(),G=I.redIAdd(I);G=G.redIAdd(G),G=G.redIAdd(G),r=Y.redISub(D).redISub(D),t=P.redMul(D.redISub(r)).redISub(G),e=this.y.redMul(this.z),e=e.redIAdd(e)}return this.curve.jpoint(r,t,e)},dr.prototype._threeDbl=function(){var r,t,e;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(a);u=u.redIAdd(u);var l=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),d=l.redSqr().redISub(u).redISub(u);r=d;var f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),t=l.redMul(u.redISub(d)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.z.redSqr(),E=this.y.redSqr(),I=this.x.redMul(E),D=this.x.redSub(w).redMul(this.x.redAdd(w));D=D.redAdd(D).redIAdd(D);var P=I.redIAdd(I);P=P.redIAdd(P);var Y=P.redAdd(P);r=D.redSqr().redISub(Y),e=this.y.redAdd(this.z).redSqr().redISub(E).redISub(w);var G=E.redSqr();G=G.redIAdd(G),G=G.redIAdd(G),G=G.redIAdd(G),t=D.redMul(P.redISub(r)).redISub(G)}return this.curve.jpoint(r,t,e)},dr.prototype._dbl=function(){var r=this.curve.a,t=this.x,e=this.y,i=this.z,s=i.redSqr().redSqr(),a=t.redSqr(),u=e.redSqr(),l=a.redAdd(a).redIAdd(a).redIAdd(r.redMul(s)),d=t.redAdd(t);d=d.redIAdd(d);var f=d.redMul(u),w=l.redSqr().redISub(f.redAdd(f)),E=f.redISub(w),I=u.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var D=l.redMul(E).redISub(I),P=e.redAdd(e).redMul(i);return this.curve.jpoint(w,D,P)},dr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var r=this.x.redSqr(),t=this.y.redSqr(),e=this.z.redSqr(),i=t.redSqr(),s=r.redAdd(r).redIAdd(r),a=s.redSqr(),u=this.x.redAdd(t).redSqr().redISub(r).redISub(i);u=u.redIAdd(u),u=u.redAdd(u).redIAdd(u),u=u.redISub(a);var l=u.redSqr(),d=i.redIAdd(i);d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var f=s.redIAdd(u).redSqr().redISub(a).redISub(l).redISub(d),w=t.redMul(f);w=w.redIAdd(w),w=w.redIAdd(w);var E=this.x.redMul(l).redISub(w);E=E.redIAdd(E),E=E.redIAdd(E);var I=this.y.redMul(f.redMul(d.redISub(f)).redISub(u.redMul(l)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var D=this.z.redAdd(u).redSqr().redISub(e).redISub(l);return this.curve.jpoint(E,I,D)},dr.prototype.mul=function(r,t){return r=new ne(r,t),this.curve._wnafMul(this,r)},dr.prototype.eq=function(r){if(r.type==="affine")return this.eq(r.toJ());if(this===r)return!0;var t=this.z.redSqr(),e=r.z.redSqr();if(this.x.redMul(e).redISub(r.x.redMul(t)).cmpn(0)!==0)return!1;var i=t.redMul(this.z),s=e.redMul(r.z);return this.y.redMul(s).redISub(r.y.redMul(i)).cmpn(0)===0},dr.prototype.eqXToP=function(r){var t=this.z.redSqr(),e=r.toRed(this.curve.red).redMul(t);if(this.x.cmp(e)===0)return!0;for(var i=r.clone(),s=this.curve.redN.redMul(t);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(s),this.x.cmp(e)===0)return!0}},dr.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)+">"},dr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Lc=wo(function(r,t){var e=t;e.base=Ms,e.short=EA,e.mont=null,e.edwards=null}),qc=wo(function(r,t){var e=t,i=ni.assert;function s(l){l.type==="short"?this.curve=new Lc.short(l):l.type==="edwards"?this.curve=new Lc.edwards(l):this.curve=new Lc.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=s;function a(l,d){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var f=new s(d);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:f}),f}})}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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=null.crash()}catch{u=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:Wi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})});function Vn(r){if(!(this instanceof Vn))return new Vn(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 t=Li.toArray(r.entropy,r.entropyEnc||"hex"),e=Li.toArray(r.nonce,r.nonceEnc||"hex"),i=Li.toArray(r.pers,r.persEnc||"hex");Wl(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,e,i)}var ep=Vn;Vn.prototype._init=function(r,t,e){var i=r.concat(t).concat(e);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},Vn.prototype._hmac=function(){return new Wi.hmac(this.hash,this.K)},Vn.prototype._update=function(r){var t=this._hmac().update(this.V).update([0]);r&&(t=t.update(r)),this.K=t.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())},Vn.prototype.reseed=function(r,t,e,i){typeof t!="string"&&(i=e,e=t,t=null),r=Li.toArray(r,t),e=Li.toArray(e,i),Wl(r.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(e||[])),this._reseed=1},Vn.prototype.generate=function(r,t,e,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=e,e=t,t=null),e&&(e=Li.toArray(e,i||"hex"),this._update(e));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(e),this._reseed++,Li.encode(a,t)};var kh=ni.assert;function _r(r,t){this.ec=r,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var Hh=_r;_r.fromPublic=function(r,t,e){return t instanceof _r?t:new _r(r,{pub:t,pubEnc:e})},_r.fromPrivate=function(r,t,e){return t instanceof _r?t:new _r(r,{priv:t,privEnc:e})},_r.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"}},_r.prototype.getPublic=function(r,t){return typeof r=="string"&&(t=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,r):this.pub},_r.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},_r.prototype._importPrivate=function(r,t){this.priv=new ne(r,t||16),this.priv=this.priv.umod(this.ec.curve.n)},_r.prototype._importPublic=function(r,t){if(r.x||r.y){this.ec.curve.type==="mont"?kh(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&kh(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,t)},_r.prototype.derive=function(r){return r.validate()||kh(r.validate(),"public point not validated"),r.mul(this.priv).getX()},_r.prototype.sign=function(r,t,e){return this.ec.sign(r,this,t,e)},_r.prototype.verify=function(r,t){return this.ec.verify(r,t,this)},_r.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var AA=ni.assert;function lu(r,t){if(r instanceof lu)return r;this._importDER(r,t)||(AA(r.r&&r.s,"Signature without r or s"),this.r=new ne(r.r,16),this.s=new ne(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var Mc=lu;function SA(){this.place=0}function Kh(r,t){var e=r[t.place++];if(!(e&128))return e;var i=e&15;if(i===0||i>4)return!1;for(var s=0,a=0,u=t.place;a<i;a++,u++)s<<=8,s|=r[u],s>>>=0;return s<=127?!1:(t.place=u,s)}function rp(r){for(var t=0,e=r.length-1;!r[t]&&!(r[t+1]&128)&&t<e;)t++;return t===0?r:r.slice(t)}lu.prototype._importDER=function(r,t){r=ni.toArray(r,t);var e=new SA;if(r[e.place++]!==48)return!1;var i=Kh(r,e);if(i===!1||i+e.place!==r.length||r[e.place++]!==2)return!1;var s=Kh(r,e);if(s===!1)return!1;var a=r.slice(e.place,s+e.place);if(e.place+=s,r[e.place++]!==2)return!1;var u=Kh(r,e);if(u===!1||r.length!==u+e.place)return!1;var l=r.slice(e.place,u+e.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new ne(a),this.s=new ne(l),this.recoveryParam=null,!0};function Vh(r,t){if(t<128){r.push(t);return}var e=1+(Math.log(t)/Math.LN2>>>3);for(r.push(e|128);--e;)r.push(t>>>(e<<3)&255);r.push(t)}lu.prototype.toDER=function(r){var t=this.r.toArray(),e=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),e[0]&128&&(e=[0].concat(e)),t=rp(t),e=rp(e);!e[0]&&!(e[1]&128);)e=e.slice(1);var i=[2];Vh(i,t.length),i=i.concat(t),i.push(2),Vh(i,e.length);var s=i.concat(e),a=[48];return Vh(a,s.length),a=a.concat(s),ni.encode(a,r)};var IA=function(){throw new Error("unsupported")},Cg=ni.assert;function Ai(r){if(!(this instanceof Ai))return new Ai(r);typeof r=="string"&&(Cg(Object.prototype.hasOwnProperty.call(qc,r),"Unknown curve "+r),r=qc[r]),r instanceof qc.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 DA=Ai;Ai.prototype.keyPair=function(r){return new Hh(this,r)},Ai.prototype.keyFromPrivate=function(r,t){return Hh.fromPrivate(this,r,t)},Ai.prototype.keyFromPublic=function(r,t){return Hh.fromPublic(this,r,t)},Ai.prototype.genKeyPair=function(r){r||(r={});for(var t=new ep({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||IA(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),e=this.n.byteLength(),i=this.n.sub(new ne(2));;){var s=new ne(t.generate(e));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Ai.prototype._truncateToN=function(r,t){var e=r.byteLength()*8-this.n.bitLength();return e>0&&(r=r.ushrn(e)),!t&&r.cmp(this.n)>=0?r.sub(this.n):r},Ai.prototype.sign=function(r,t,e,i){typeof e=="object"&&(i=e,e=null),i||(i={}),t=this.keyFromPrivate(t,e),r=this._truncateToN(new ne(r,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),u=r.toArray("be",s),l=new ep({hash:this.hash,entropy:a,nonce:u,pers:i.pers,persEnc:i.persEnc||"utf8"}),d=this.n.sub(new ne(1)),f=0;;f++){var w=i.k?i.k(f):new ne(l.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(d)>=0)){var E=this.g.mul(w);if(!E.isInfinity()){var I=E.getX(),D=I.umod(this.n);if(D.cmpn(0)!==0){var P=w.invm(this.n).mul(D.mul(t.getPrivate()).iadd(r));if(P=P.umod(this.n),P.cmpn(0)!==0){var Y=(E.getY().isOdd()?1:0)|(I.cmp(D)!==0?2:0);return i.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),Y^=1),new Mc({r:D,s:P,recoveryParam:Y})}}}}}},Ai.prototype.verify=function(r,t,e,i){r=this._truncateToN(new ne(r,16)),e=this.keyFromPublic(e,i),t=new Mc(t,"hex");var s=t.r,a=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),l=u.mul(r).umod(this.n),d=u.mul(s).umod(this.n),f;return this.curve._maxwellTrick?(f=this.g.jmulAdd(l,e.getPublic(),d),f.isInfinity()?!1:f.eqXToP(s)):(f=this.g.mulAdd(l,e.getPublic(),d),f.isInfinity()?!1:f.getX().umod(this.n).cmp(s)===0)},Ai.prototype.recoverPubKey=function(r,t,e,i){Cg((3&e)===e,"The recovery param is more than two bits"),t=new Mc(t,i);var s=this.n,a=new ne(r),u=t.r,l=t.s,d=e&1,f=e>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");f?u=this.curve.pointFromX(u.add(this.curve.n),d):u=this.curve.pointFromX(u,d);var w=t.r.invm(s),E=s.sub(a).mul(w).umod(s),I=l.mul(w).umod(s);return this.g.mulAdd(E,u,I)},Ai.prototype.getKeyRecoveryParam=function(r,t,e,i){if(t=new Mc(t,i),t.recoveryParam!==null)return t.recoveryParam;for(var s=0;s<4;s++){var a;try{a=this.recoverPubKey(r,t,s)}catch{continue}if(a.eq(e))return s}throw new Error("Unable to find valid recovery factor")};var xA=wo(function(r,t){var e=t;e.version="6.5.4",e.utils=ni,e.rand=function(){throw new Error("unsupported")},e.curve=Lc,e.curves=qc,e.ec=DA,e.eddsa=null}),MA=xA.ec;const CA="signing-key/5.7.0",Sl=new gr(CA);let Gh=null;function en(){return Gh||(Gh=new MA("secp256k1")),Gh}class PA{constructor(t){zo(this,"curve","secp256k1"),zo(this,"privateKey",Cr(t)),d5(this.privateKey)!==32&&Sl.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=en().keyFromPrivate(Ye(this.privateKey));zo(this,"publicKey","0x"+e.getPublic(!1,"hex")),zo(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),zo(this,"_isSigningKey",!0)}_addPoint(t){const e=en().keyFromPublic(Ye(this.publicKey)),i=en().keyFromPublic(Ye(t));return"0x"+e.pub.add(i.pub).encodeCompressed("hex")}signDigest(t){const e=en().keyFromPrivate(Ye(this.privateKey)),i=Ye(t);i.length!==32&&Sl.throwArgumentError("bad digest length","digest",t);const s=e.sign(i,{canonical:!0});return tg({recoveryParam:s.recoveryParam,r:rn("0x"+s.r.toString(16),32),s:rn("0x"+s.s.toString(16),32)})}computeSharedSecret(t){const e=en().keyFromPrivate(Ye(this.privateKey)),i=en().keyFromPublic(Ye(Pg(t)));return rn("0x"+e.derive(i.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function OA(r,t){const e=tg(t),i={r:Ye(e.r),s:Ye(e.s)};return"0x"+en().recoverPubKey(Ye(r),i,e.recoveryParam).encode("hex",!1)}function Pg(r,t){const e=Ye(r);if(e.length===32){const i=new PA(e);return t?"0x"+en().keyFromPrivate(e).getPublic(!0,"hex"):i.publicKey}else{if(e.length===33)return t?Cr(e):"0x"+en().keyFromPublic(e).getPublic(!1,"hex");if(e.length===65)return t?"0x"+en().keyFromPublic(e).getPublic(!0,"hex"):Cr(e)}return Sl.throwArgumentError("invalid public or private key","key","[REDACTED]")}var ip;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(ip||(ip={}));function NA(r){const t=Pg(r);return k5(zd(Kl(zd(t,1)),12))}function RA(r,t){return NA(OA(Ye(r),t))}const TA="https://rpc.walletconnect.com/v1";async function FA(r,t,e,i,s,a){switch(e.t){case"eip191":return UA(r,t,e.s);case"eip1271":return await BA(r,t,e.s,i,s,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${e.t}`)}}function UA(r,t,e){return RA(ug(t),e).toLowerCase()===r.toLowerCase()}async function BA(r,t,e,i,s,a){try{const u="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",d="0000000000000000000000000000000000000000000000000000000000000041",f=e.substring(2),w=ug(t).substring(2),E=u+w+l+d+f,I=await fetch(`${a||TA}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:LA(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:E},"latest"]})}),{result:D}=await I.json();return D?D.slice(0,u.length).toLowerCase()===u.toLowerCase():!1}catch(u){return console.error("isValidEip1271Signature: ",u),!1}}function LA(){return Date.now()+Math.floor(Math.random()*1e3)}var qA=Object.defineProperty,jA=Object.defineProperties,$A=Object.getOwnPropertyDescriptors,np=Object.getOwnPropertySymbols,zA=Object.prototype.hasOwnProperty,kA=Object.prototype.propertyIsEnumerable,sp=(r,t,e)=>t in r?qA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HA=(r,t)=>{for(var e in t||(t={}))zA.call(t,e)&&sp(r,e,t[e]);if(np)for(var e of np(t))kA.call(t,e)&&sp(r,e,t[e]);return r},KA=(r,t)=>jA(r,$A(t));const VA="did:pkh:",Ql=r=>r==null?void 0:r.split(":"),Og=r=>{const t=r&&Ql(r);if(t)return r.includes(VA)?t[3]:t[1]},op=r=>{const t=r&&Ql(r);if(t)return t[2]+":"+t[3]},Jc=r=>{const t=r&&Ql(r);if(t)return t.pop()};async function ap(r){const{cacao:t,projectId:e}=r,{s:i,p:s}=t,a=Ng(s,s.iss),u=Jc(s.iss);return await FA(u,a,i,Og(s.iss),e)}const Ng=(r,t)=>{const e=`${r.domain} wants you to sign in with your Ethereum account:`,i=Jc(t);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}`,u=`Version: ${r.version}`,l=`Chain ID: ${Og(t)}`,d=`Nonce: ${r.nonce}`,f=`Issued At: ${r.iat}`,w=r.resources?`Resources:${r.resources.map(I=>`
23
+ - ${I}`).join("")}`:void 0,E=jc(r.resources);if(E){const I=sa(E);s=e4(s,I)}return[e,i,"",s,"",a,u,l,d,f,w].filter(I=>I!=null).join(`
24
+ `)};function GA(r){return ua.from(JSON.stringify(r)).toString("base64")}function WA(r){return JSON.parse(ua.from(r,"base64").toString("utf-8"))}function Ds(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const t=Object.keys(r.att);if(!(t!=null&&t.length))throw new Error("No resources found in `att` property");t.forEach(e=>{const i=r.att[e];if(Array.isArray(i))throw new Error(`Resource must be an object: ${e}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${e}`);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(u=>{if(typeof u!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${u}`)})})})}function YA(r,t,e,i={}){return e==null||e.sort((s,a)=>s.localeCompare(a)),{att:{[r]:QA(t,e,i)}}}function QA(r,t,e={}){t=t==null?void 0:t.sort((s,a)=>s.localeCompare(a));const i=t.map(s=>({[`${r}/${s}`]:[e]}));return Object.assign({},...i)}function Rg(r){return Ds(r),`urn:recap:${GA(r).replace(/=/g,"")}`}function sa(r){const t=WA(r.replace("urn:recap:",""));return Ds(t),t}function JA(r,t,e){const i=YA(r,t,e);return Rg(i)}function XA(r){return r&&r.includes("urn:recap:")}function ZA(r,t){const e=sa(r),i=sa(t),s=t4(e,i);return Rg(s)}function t4(r,t){Ds(r),Ds(t);const e=Object.keys(r.att).concat(Object.keys(t.att)).sort((s,a)=>s.localeCompare(a)),i={att:{}};return e.forEach(s=>{var a,u;Object.keys(((a=r.att)==null?void 0:a[s])||{}).concat(Object.keys(((u=t.att)==null?void 0:u[s])||{})).sort((l,d)=>l.localeCompare(d)).forEach(l=>{var d,f;i.att[s]=KA(HA({},i.att[s]),{[l]:((d=r.att[s])==null?void 0:d[l])||((f=t.att[s])==null?void 0:f[l])})})}),i}function e4(r="",t){Ds(t);const e="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(e))return r;const i=[];let s=0;Object.keys(t.att).forEach(l=>{const d=Object.keys(t.att[l]).map(E=>({ability:E.split("/")[0],action:E.split("/")[1]}));d.sort((E,I)=>E.action.localeCompare(I.action));const f={};d.forEach(E=>{f[E.ability]||(f[E.ability]=[]),f[E.ability].push(E.action)});const w=Object.keys(f).map(E=>(s++,`(${s}) '${E}': '${f[E].join("', '")}' for '${l}'.`));i.push(w.join(", ").replace(".,","."))});const a=i.join(" "),u=`${e}${a}`;return`${r?r+" ":""}${u}`}function cp(r){var t;const e=sa(r);Ds(e);const i=(t=e.att)==null?void 0:t.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function up(r){const t=sa(r);Ds(t);const e=[];return Object.values(t.att).forEach(i=>{Object.values(i).forEach(s=>{var a;(a=s==null?void 0:s[0])!=null&&a.chains&&e.push(s[0].chains)})}),[...new Set(e.flat())]}function jc(r){if(!r)return;const t=r==null?void 0:r[r.length-1];return XA(t)?t:void 0}const Tg="base10",Nr="base16",Il="base64pad",Jl="utf8",Fg=0,Gn=1,r4=0,hp=1,Dl=12,Xl=32;function i4(){const r=Hl.generateKeyPair();return{privateKey:Rr(r.secretKey,Nr),publicKey:Rr(r.publicKey,Nr)}}function xl(){const r=fo.randomBytes(Xl);return Rr(r,Nr)}function n4(r,t){const e=Hl.sharedKey(Hr(r,Nr),Hr(t,Nr),!0),i=new L_(uu.SHA256,e).expand(Xl);return Rr(i,Nr)}function $c(r){const t=uu.hash(Hr(r,Nr));return Rr(t,Nr)}function As(r){const t=uu.hash(Hr(r,Jl));return Rr(t,Nr)}function s4(r){return Hr(`${r}`,Tg)}function ga(r){return Number(Rr(r,Tg))}function o4(r){const t=s4(typeof r.type<"u"?r.type:Fg);if(ga(t)===Gn&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const e=typeof r.senderPublicKey<"u"?Hr(r.senderPublicKey,Nr):void 0,i=typeof r.iv<"u"?Hr(r.iv,Nr):fo.randomBytes(Dl),s=new zl.ChaCha20Poly1305(Hr(r.symKey,Nr)).seal(i,Hr(r.message,Jl));return c4({type:t,sealed:s,iv:i,senderPublicKey:e})}function a4(r){const t=new zl.ChaCha20Poly1305(Hr(r.symKey,Nr)),{sealed:e,iv:i}=Xc(r.encoded),s=t.open(i,e);if(s===null)throw new Error("Failed to decrypt");return Rr(s,Jl)}function c4(r){if(ga(r.type)===Gn){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Rr(yl([r.type,r.senderPublicKey,r.iv,r.sealed]),Il)}return Rr(yl([r.type,r.iv,r.sealed]),Il)}function Xc(r){const t=Hr(r,Il),e=t.slice(r4,hp),i=hp;if(ga(e)===Gn){const l=i+Xl,d=l+Dl,f=t.slice(i,l),w=t.slice(l,d),E=t.slice(d);return{type:e,sealed:E,iv:w,senderPublicKey:f}}const s=i+Dl,a=t.slice(i,s),u=t.slice(s);return{type:e,sealed:u,iv:a}}function u4(r,t){const e=Xc(r);return Ug({type:ga(e.type),senderPublicKey:typeof e.senderPublicKey<"u"?Rr(e.senderPublicKey,Nr):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function Ug(r){const t=(r==null?void 0:r.type)||Fg;if(t===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:t,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function lp(r){return r.type===Gn&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}const h4="irn";function Ml(r){return(r==null?void 0:r.relay)||{protocol:h4}}function Qo(r){const t=$E[r];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${r}`);return t}var l4=Object.defineProperty,f4=Object.defineProperties,d4=Object.getOwnPropertyDescriptors,fp=Object.getOwnPropertySymbols,p4=Object.prototype.hasOwnProperty,g4=Object.prototype.propertyIsEnumerable,dp=(r,t,e)=>t in r?l4(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pp=(r,t)=>{for(var e in t||(t={}))p4.call(t,e)&&dp(r,e,t[e]);if(fp)for(var e of fp(t))g4.call(t,e)&&dp(r,e,t[e]);return r},m4=(r,t)=>f4(r,d4(t));function v4(r,t="-"){const e={},i="relay"+t;return Object.keys(r).forEach(s=>{if(s.startsWith(i)){const a=s.replace(i,""),u=r[s];e[a]=u}}),e}function gp(r){r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const t=r.indexOf(":"),e=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,t),s=r.substring(t+1,e).split("@"),a=typeof e<"u"?r.substring(e):"",u=ra.parse(a),l=typeof u.methods=="string"?u.methods.split(","):void 0;return{protocol:i,topic:y4(s[0]),version:parseInt(s[1],10),symKey:u.symKey,relay:v4(u),methods:l,expiryTimestamp:u.expiryTimestamp?parseInt(u.expiryTimestamp,10):void 0}}function y4(r){return r.startsWith("//")?r.substring(2):r}function w4(r,t="-"){const e="relay",i={};return Object.keys(r).forEach(s=>{const a=e+t+s;r[s]&&(i[a]=r[s])}),i}function b4(r){return`${r.protocol}:${r.topic}@${r.version}?`+ra.stringify(pp(m4(pp({symKey:r.symKey},w4(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function bo(r){const t=[];return r.forEach(e=>{const[i,s]=e.split(":");t.push(`${i}:${s}`)}),t}function _4(r){const t=[];return Object.values(r).forEach(e=>{t.push(...bo(e.accounts))}),t}function E4(r,t){const e=[];return Object.values(r).forEach(i=>{bo(i.accounts).includes(t)&&e.push(...i.methods)}),e}function A4(r,t){const e=[];return Object.values(r).forEach(i=>{bo(i.accounts).includes(t)&&e.push(...i.events)}),e}function Zl(r){return r.includes(":")}function Jo(r){return Zl(r)?r.split(":")[0]:r}function S4(r){const t={};return r==null||r.forEach(e=>{const[i,s]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[]}),t[i].accounts.push(e),t[i].chains.push(`${i}:${s}`)}),t}function mp(r,t){t=t.map(i=>i.replace("did:pkh:",""));const e=S4(t);for(const[i,s]of Object.entries(e))s.methods?s.methods=Uc(s.methods,r):s.methods=r,s.events=["chainChanged","accountsChanged"];return e}const I4={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}},D4={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 gt(r,t){const{message:e,code:i}=D4[r];return{message:t?`${e} ${t}`:e,code:i}}function Re(r,t){const{message:e,code:i}=I4[r];return{message:t?`${e} ${t}`:e,code:i}}function cn(r,t){return Array.isArray(r)?typeof t<"u"&&r.length?r.every(t):!0:!1}function oa(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Or(r){return typeof r>"u"}function tr(r,t){return t&&Or(r)?!0:typeof r=="string"&&!!r.trim().length}function tf(r,t){return t&&Or(r)?!0:typeof r=="number"&&!isNaN(r)}function x4(r,t){const{requiredNamespaces:e}=t,i=Object.keys(r.namespaces),s=Object.keys(e);let a=!0;return Es(s,i)?(i.forEach(u=>{const{accounts:l,methods:d,events:f}=r.namespaces[u],w=bo(l),E=e[u];(!Es(V1(u,E),w)||!Es(E.methods,d)||!Es(E.events,f))&&(a=!1)}),a):!1}function Zc(r){return tr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function M4(r){if(tr(r,!1)&&r.includes(":")){const t=r.split(":");if(t.length===3){const e=t[0]+":"+t[1];return!!t[2]&&Zc(e)}}return!1}function C4(r){if(tr(r,!1))try{return typeof new URL(r)<"u"}catch{return!1}return!1}function P4(r){var t;return(t=r==null?void 0:r.proposer)==null?void 0:t.publicKey}function O4(r){return r==null?void 0:r.topic}function N4(r,t){let e=null;return tr(r==null?void 0:r.publicKey,!1)||(e=gt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),e}function vp(r){let t=!0;return cn(r)?r.length&&(t=r.every(e=>tr(e,!1))):t=!1,t}function R4(r,t,e){let i=null;return cn(t)&&t.length?t.forEach(s=>{i||Zc(s)||(i=Re("UNSUPPORTED_CHAINS",`${e}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):Zc(r)||(i=Re("UNSUPPORTED_CHAINS",`${e}, 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 T4(r,t,e){let i=null;return Object.entries(r).forEach(([s,a])=>{if(i)return;const u=R4(s,V1(s,a),`${t} ${e}`);u&&(i=u)}),i}function F4(r,t){let e=null;return cn(r)?r.forEach(i=>{e||M4(i)||(e=Re("UNSUPPORTED_ACCOUNTS",`${t}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):e=Re("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),e}function U4(r,t){let e=null;return Object.values(r).forEach(i=>{if(e)return;const s=F4(i==null?void 0:i.accounts,`${t} namespace`);s&&(e=s)}),e}function B4(r,t){let e=null;return vp(r==null?void 0:r.methods)?vp(r==null?void 0:r.events)||(e=Re("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):e=Re("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),e}function Bg(r,t){let e=null;return Object.values(r).forEach(i=>{if(e)return;const s=B4(i,`${t}, namespace`);s&&(e=s)}),e}function L4(r,t,e){let i=null;if(r&&oa(r)){const s=Bg(r,t);s&&(i=s);const a=T4(r,t,e);a&&(i=a)}else i=gt("MISSING_OR_INVALID",`${t}, ${e} should be an object with data`);return i}function Wh(r,t){let e=null;if(r&&oa(r)){const i=Bg(r,t);i&&(e=i);const s=U4(r,t);s&&(e=s)}else e=gt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return e}function Lg(r){return tr(r.protocol,!0)}function q4(r,t){let e=!1;return t&&!r?e=!0:r&&cn(r)&&r.length&&r.forEach(i=>{e=Lg(i)}),e}function j4(r){return typeof r=="number"}function zr(r){return typeof r<"u"&&typeof r!==null}function $4(r){return!(!r||typeof r!="object"||!r.code||!tf(r.code,!1)||!r.message||!tr(r.message,!1))}function z4(r){return!(Or(r)||!tr(r.method,!1))}function k4(r){return!(Or(r)||Or(r.result)&&Or(r.error)||!tf(r.id,!1)||!tr(r.jsonrpc,!1))}function H4(r){return!(Or(r)||!tr(r.name,!1))}function yp(r,t){return!(!Zc(t)||!_4(r).includes(t))}function K4(r,t,e){return tr(e,!1)?E4(r,t).includes(e):!1}function V4(r,t,e){return tr(e,!1)?A4(r,t).includes(e):!1}function wp(r,t,e){let i=null;const s=G4(r),a=W4(t),u=Object.keys(s),l=Object.keys(a),d=bp(Object.keys(r)),f=bp(Object.keys(t)),w=d.filter(E=>!f.includes(E));return w.length&&(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces keys don't satisfy requiredNamespaces.
25
+ Required: ${w.toString()}
26
+ Received: ${Object.keys(t).toString()}`)),Es(u,l)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces chains don't satisfy required namespaces.
27
+ Required: ${u.toString()}
28
+ Approved: ${l.toString()}`)),Object.keys(t).forEach(E=>{if(!E.includes(":")||i)return;const I=bo(t[E].accounts);I.includes(E)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces accounts don't satisfy namespace accounts for ${E}
29
+ Required: ${E}
30
+ Approved: ${I.toString()}`))}),u.forEach(E=>{i||(Es(s[E].methods,a[E].methods)?Es(s[E].events,a[E].events)||(i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces events don't satisfy namespace events for ${E}`)):i=gt("NON_CONFORMING_NAMESPACES",`${e} namespaces methods don't satisfy namespace methods for ${E}`))}),i}function G4(r){const t={};return Object.keys(r).forEach(e=>{var i;e.includes(":")?t[e]=r[e]:(i=r[e].chains)==null||i.forEach(s=>{t[s]={methods:r[e].methods,events:r[e].events}})}),t}function bp(r){return[...new Set(r.map(t=>t.includes(":")?t.split(":")[0]:t))]}function W4(r){const t={};return Object.keys(r).forEach(e=>{if(e.includes(":"))t[e]=r[e];else{const i=bo(r[e].accounts);i==null||i.forEach(s=>{t[s]={accounts:r[e].accounts.filter(a=>a.includes(`${s}:`)),methods:r[e].methods,events:r[e].events}})}}),t}function Y4(r,t){return tf(r,!1)&&r<=t.max&&r>=t.min}function _p(){const r=da();return new Promise(t=>{switch(r){case ei.browser:t(Q4());break;case ei.reactNative:t(J4());break;case ei.node:t(X4());break;default:t(!0)}})}function Q4(){return go()&&(navigator==null?void 0:navigator.onLine)}async function J4(){if(po()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo){const r=await(Ie==null?void 0:Ie.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function X4(){return!0}function Z4(r){switch(da()){case ei.browser:tS(r);break;case ei.reactNative:eS(r);break}}function tS(r){!po()&&go()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function eS(r){var t;po()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo&&((t=Ie)==null||t.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Yh={};class Ko{static get(t){return Yh[t]}static set(t,e){Yh[t]=e}static delete(t){delete Yh[t]}}const rS=/"(?:_|\\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*:/,iS=/"(?: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*:/,nS=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function sS(r,t){if(r==="__proto__"||r==="constructor"&&t&&typeof t=="object"&&"prototype"in t){oS(r);return}return t}function oS(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Cc(r,t={}){if(typeof r!="string")return r;const e=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return e.slice(1,-1);if(e.length<=9){const i=e.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(!nS.test(r)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(rS.test(r)||iS.test(r)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,sS)}return JSON.parse(r)}catch(i){if(t.strict)throw i;return r}}function aS(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function lr(r,...t){try{return aS(r(...t))}catch(e){return Promise.reject(e)}}function cS(r){const t=typeof r;return r===null||t!=="object"&&t!=="function"}function uS(r){const t=Object.getPrototypeOf(r);return!t||t.isPrototypeOf(Object)}function zc(r){if(cS(r))return String(r);if(uS(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return zc(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function qg(){if(typeof ua===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const Cl="base64:";function hS(r){if(typeof r=="string")return r;qg();const t=ua.from(r).toString("base64");return Cl+t}function lS(r){return typeof r!="string"||!r.startsWith(Cl)?r:(qg(),ua.from(r.slice(Cl.length),"base64"))}function $r(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function fS(...r){return $r(r.join(":"))}function Pc(r){return r=$r(r),r?r+":":""}const dS="memory",pS=()=>{const r=new Map;return{name:dS,options:{},hasItem(t){return r.has(t)},getItem(t){return r.get(t)??null},getItemRaw(t){return r.get(t)??null},setItem(t,e){r.set(t,e)},setItemRaw(t,e){r.set(t,e)},removeItem(t){r.delete(t)},getKeys(){return Array.from(r.keys())},clear(){r.clear()},dispose(){r.clear()}}};function gS(r={}){const t={mounts:{"":r.driver||pS()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},e=f=>{for(const w of t.mountpoints)if(f.startsWith(w))return{base:w,relativeKey:f.slice(w.length),driver:t.mounts[w]};return{base:"",relativeKey:f,driver:t.mounts[""]}},i=(f,w)=>t.mountpoints.filter(E=>E.startsWith(f)||w&&f.startsWith(E)).map(E=>({relativeBase:f.length>E.length?f.slice(E.length):void 0,mountpoint:E,driver:t.mounts[E]})),s=(f,w)=>{if(t.watching){w=$r(w);for(const E of t.watchListeners)E(f,w)}},a=async()=>{if(!t.watching){t.watching=!0;for(const f in t.mounts)t.unwatch[f]=await Ep(t.mounts[f],s,f)}},u=async()=>{if(t.watching){for(const f in t.unwatch)await t.unwatch[f]();t.unwatch={},t.watching=!1}},l=(f,w,E)=>{const I=new Map,D=P=>{let Y=I.get(P.base);return Y||(Y={driver:P.driver,base:P.base,items:[]},I.set(P.base,Y)),Y};for(const P of f){const Y=typeof P=="string",G=$r(Y?P:P.key),tt=Y?void 0:P.value,K=Y||!P.options?w:{...w,...P.options},V=e(G);D(V).items.push({key:G,value:tt,relativeKey:V.relativeKey,options:K})}return Promise.all([...I.values()].map(P=>E(P))).then(P=>P.flat())},d={hasItem(f,w={}){f=$r(f);const{relativeKey:E,driver:I}=e(f);return lr(I.hasItem,E,w)},getItem(f,w={}){f=$r(f);const{relativeKey:E,driver:I}=e(f);return lr(I.getItem,E,w).then(D=>Cc(D))},getItems(f,w){return l(f,w,E=>E.driver.getItems?lr(E.driver.getItems,E.items.map(I=>({key:I.relativeKey,options:I.options})),w).then(I=>I.map(D=>({key:fS(E.base,D.key),value:Cc(D.value)}))):Promise.all(E.items.map(I=>lr(E.driver.getItem,I.relativeKey,I.options).then(D=>({key:I.key,value:Cc(D)})))))},getItemRaw(f,w={}){f=$r(f);const{relativeKey:E,driver:I}=e(f);return I.getItemRaw?lr(I.getItemRaw,E,w):lr(I.getItem,E,w).then(D=>lS(D))},async setItem(f,w,E={}){if(w===void 0)return d.removeItem(f);f=$r(f);const{relativeKey:I,driver:D}=e(f);D.setItem&&(await lr(D.setItem,I,zc(w),E),D.watch||s("update",f))},async setItems(f,w){await l(f,w,async E=>{if(E.driver.setItems)return lr(E.driver.setItems,E.items.map(I=>({key:I.relativeKey,value:zc(I.value),options:I.options})),w);E.driver.setItem&&await Promise.all(E.items.map(I=>lr(E.driver.setItem,I.relativeKey,zc(I.value),I.options)))})},async setItemRaw(f,w,E={}){if(w===void 0)return d.removeItem(f,E);f=$r(f);const{relativeKey:I,driver:D}=e(f);if(D.setItemRaw)await lr(D.setItemRaw,I,w,E);else if(D.setItem)await lr(D.setItem,I,hS(w),E);else return;D.watch||s("update",f)},async removeItem(f,w={}){typeof w=="boolean"&&(w={removeMeta:w}),f=$r(f);const{relativeKey:E,driver:I}=e(f);I.removeItem&&(await lr(I.removeItem,E,w),(w.removeMeta||w.removeMata)&&await lr(I.removeItem,E+"$",w),I.watch||s("remove",f))},async getMeta(f,w={}){typeof w=="boolean"&&(w={nativeOnly:w}),f=$r(f);const{relativeKey:E,driver:I}=e(f),D=Object.create(null);if(I.getMeta&&Object.assign(D,await lr(I.getMeta,E,w)),!w.nativeOnly){const P=await lr(I.getItem,E+"$",w).then(Y=>Cc(Y));P&&typeof P=="object"&&(typeof P.atime=="string"&&(P.atime=new Date(P.atime)),typeof P.mtime=="string"&&(P.mtime=new Date(P.mtime)),Object.assign(D,P))}return D},setMeta(f,w,E={}){return this.setItem(f+"$",w,E)},removeMeta(f,w={}){return this.removeItem(f+"$",w)},async getKeys(f,w={}){f=Pc(f);const E=i(f,!0);let I=[];const D=[];for(const P of E){const G=(await lr(P.driver.getKeys,P.relativeBase,w)).map(tt=>P.mountpoint+$r(tt)).filter(tt=>!I.some(K=>tt.startsWith(K)));D.push(...G),I=[P.mountpoint,...I.filter(tt=>!tt.startsWith(P.mountpoint))]}return f?D.filter(P=>P.startsWith(f)&&!P.endsWith("$")):D.filter(P=>!P.endsWith("$"))},async clear(f,w={}){f=Pc(f),await Promise.all(i(f,!1).map(async E=>{if(E.driver.clear)return lr(E.driver.clear,E.relativeBase,w);if(E.driver.removeItem){const I=await E.driver.getKeys(E.relativeBase||"",w);return Promise.all(I.map(D=>E.driver.removeItem(D,w)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(f=>Ap(f)))},async watch(f){return await a(),t.watchListeners.push(f),async()=>{t.watchListeners=t.watchListeners.filter(w=>w!==f),t.watchListeners.length===0&&await u()}},async unwatch(){t.watchListeners=[],await u()},mount(f,w){if(f=Pc(f),f&&t.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(t.mountpoints.push(f),t.mountpoints.sort((E,I)=>I.length-E.length)),t.mounts[f]=w,t.watching&&Promise.resolve(Ep(w,s,f)).then(E=>{t.unwatch[f]=E}).catch(console.error),d},async unmount(f,w=!0){f=Pc(f),!(!f||!t.mounts[f])&&(t.watching&&f in t.unwatch&&(t.unwatch[f](),delete t.unwatch[f]),w&&await Ap(t.mounts[f]),t.mountpoints=t.mountpoints.filter(E=>E!==f),delete t.mounts[f])},getMount(f=""){f=$r(f)+":";const w=e(f);return{driver:w.driver,base:w.base}},getMounts(f="",w={}){return f=$r(f),i(f,w.parents).map(I=>({driver:I.driver,base:I.mountpoint}))}};return d}function Ep(r,t,e){return r.watch?r.watch((i,s)=>t(i,e+s)):()=>{}}async function Ap(r){typeof r.dispose=="function"&&await lr(r.dispose)}function Cs(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function jg(r,t){const e=indexedDB.open(r);e.onupgradeneeded=()=>e.result.createObjectStore(t);const i=Cs(e);return(s,a)=>i.then(u=>a(u.transaction(t,s).objectStore(t)))}let Qh;function ma(){return Qh||(Qh=jg("keyval-store","keyval")),Qh}function Sp(r,t=ma()){return t("readonly",e=>Cs(e.get(r)))}function mS(r,t,e=ma()){return e("readwrite",i=>(i.put(t,r),Cs(i.transaction)))}function vS(r,t=ma()){return t("readwrite",e=>(e.delete(r),Cs(e.transaction)))}function yS(r=ma()){return r("readwrite",t=>(t.clear(),Cs(t.transaction)))}function wS(r,t){return r.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Cs(r.transaction)}function bS(r=ma()){return r("readonly",t=>{if(t.getAllKeys)return Cs(t.getAllKeys());const e=[];return wS(t,i=>e.push(i.key)).then(()=>e)})}const _S=r=>JSON.stringify(r,(t,e)=>typeof e=="bigint"?e.toString()+"n":e),ES=r=>{const t=/([\[:])?(\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,e=r.replace(t,'$1"$2n"$3');return JSON.parse(e,(i,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function va(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return ES(r)}catch{return r}}function xn(r){return typeof r=="string"?r:_S(r)||""}const AS="idb-keyval";var SS=(r={})=>{const t=r.base&&r.base.length>0?`${r.base}:`:"",e=s=>t+s;let i;return r.dbName&&r.storeName&&(i=jg(r.dbName,r.storeName)),{name:AS,options:r,async hasItem(s){return!(typeof await Sp(e(s),i)>"u")},async getItem(s){return await Sp(e(s),i)??null},setItem(s,a){return mS(e(s),a,i)},removeItem(s){return vS(e(s),i)},getKeys(){return bS(i)},clear(){return yS(i)}}};const IS="WALLET_CONNECT_V2_INDEXED_DB",DS="keyvaluestorage";let xS=class{constructor(){this.indexedDb=gS({driver:SS({dbName:IS,storeName:DS})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const e=await this.indexedDb.getItem(t);if(e!==null)return e}async setItem(t,e){await this.indexedDb.setItem(t,xn(e))}async removeItem(t){await this.indexedDb.removeItem(t)}};var Jh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},kc={exports:{}};(function(){let r;function t(){}r=t,r.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},r.prototype.setItem=function(e,i){this[e]=String(i)},r.prototype.removeItem=function(e){delete this[e]},r.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(i){e[i]=void 0,delete e[i]})},r.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Jh<"u"&&Jh.localStorage?kc.exports=Jh.localStorage:typeof window<"u"&&window.localStorage?kc.exports=window.localStorage:kc.exports=new t})();function MS(r){var t;return[r[0],va((t=r[1])!=null?t:"")]}class CS{constructor(){this.localStorage=kc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(MS)}async getItem(t){const e=this.localStorage.getItem(t);if(e!==null)return va(e)}async setItem(t,e){this.localStorage.setItem(t,xn(e))}async removeItem(t){this.localStorage.removeItem(t)}}const PS="wc_storage_version",Ip=1,OS=async(r,t,e)=>{const i=PS,s=await t.getItem(i);if(s&&s>=Ip){e(t);return}const a=await r.getKeys();if(!a.length){e(t);return}const u=[];for(;a.length;){const l=a.shift();if(!l)continue;const d=l.toLowerCase();if(d.includes("wc@")||d.includes("walletconnect")||d.includes("wc_")||d.includes("wallet_connect")){const f=await r.getItem(l);await t.setItem(l,f),u.push(l)}}await t.setItem(i,Ip),e(t),NS(r,u)},NS=async(r,t)=>{t.length&&t.forEach(async e=>{await r.removeItem(e)})};let RS=class{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const t=new CS;this.storage=t;try{const e=new xS;OS(t,e,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(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,e){return await this.initialize(),this.storage.setItem(t,e)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const e=setInterval(()=>{this.initialized&&(clearInterval(e),t())},20)})}};class Ps{}let TS=class extends Ps{constructor(t){super()}};const Dp=bt.FIVE_SECONDS,ya={pulse:"heartbeat_pulse"};let FS=class $g extends TS{constructor(t){super(t),this.events=new Di.EventEmitter,this.interval=Dp,this.interval=(t==null?void 0:t.interval)||Dp}static async init(t){const e=new $g(t);return await e.init(),e}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),bt.toMiliseconds(this.interval))}pulse(){this.events.emit(ya.pulse)}};function US(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var BS=LS;function LS(r,t,e){var i=e&&e.stringify||US,s=1;if(typeof r=="object"&&r!==null){var a=t.length+s;if(a===1)return r;var u=new Array(a);u[0]=i(r);for(var l=1;l<a;l++)u[l]=i(t[l]);return u.join(" ")}if(typeof r!="string")return r;var d=t.length;if(d===0)return r;for(var f="",w=1-s,E=-1,I=r&&r.length||0,D=0;D<I;){if(r.charCodeAt(D)===37&&D+1<I){switch(E=E>-1?E:0,r.charCodeAt(D+1)){case 100:case 102:if(w>=d||t[w]==null)break;E<D&&(f+=r.slice(E,D)),f+=Number(t[w]),E=D+2,D++;break;case 105:if(w>=d||t[w]==null)break;E<D&&(f+=r.slice(E,D)),f+=Math.floor(Number(t[w])),E=D+2,D++;break;case 79:case 111:case 106:if(w>=d||t[w]===void 0)break;E<D&&(f+=r.slice(E,D));var P=typeof t[w];if(P==="string"){f+="'"+t[w]+"'",E=D+2,D++;break}if(P==="function"){f+=t[w].name||"<anonymous>",E=D+2,D++;break}f+=i(t[w]),E=D+2,D++;break;case 115:if(w>=d)break;E<D&&(f+=r.slice(E,D)),f+=String(t[w]),E=D+2,D++;break;case 37:E<D&&(f+=r.slice(E,D)),f+="%",E=D+2,D++,w--;break}++w}++D}return E===-1?r:(E<I&&(f+=r.slice(E)),f)}const xp=BS;var eo=an;const aa=WS().console||{},qS={mapHttpRequest:Oc,mapHttpResponse:Oc,wrapRequestSerializer:Xh,wrapResponseSerializer:Xh,wrapErrorSerializer:Xh,req:Oc,res:Oc,err:HS};function jS(r,t){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(t):!1}function an(r){r=r||{},r.browser=r.browser||{};const t=r.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const e=r.browser.write||aa;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},s=jS(r.browser.serialize,i);let a=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(a=!1);const u=["error","fatal","warn","info","debug","trace"];typeof e=="function"&&(e.error=e.fatal=e.warn=e.info=e.debug=e.trace=e),r.enabled===!1&&(r.level="silent");const l=r.level||"info",d=Object.create(e);d.log||(d.log=ca),Object.defineProperty(d,"levelVal",{get:w}),Object.defineProperty(d,"level",{get:E,set:I});const f={transmit:t,serialize:s,asObject:r.browser.asObject,levels:u,timestamp:KS(r)};d.levels=an.levels,d.level=l,d.setMaxListeners=d.getMaxListeners=d.emit=d.addListener=d.on=d.prependListener=d.once=d.prependOnceListener=d.removeListener=d.removeAllListeners=d.listeners=d.listenerCount=d.eventNames=d.write=d.flush=ca,d.serializers=i,d._serialize=s,d._stdErrSerialize=a,d.child=D,t&&(d._logEvent=Pl());function w(){return this.level==="silent"?1/0:this.levels.values[this.level]}function E(){return this._level}function I(P){if(P!=="silent"&&!this.levels.values[P])throw Error("unknown level "+P);this._level=P,Js(f,d,"error","log"),Js(f,d,"fatal","error"),Js(f,d,"warn","error"),Js(f,d,"info","log"),Js(f,d,"debug","log"),Js(f,d,"trace","log")}function D(P,Y){if(!P)throw new Error("missing bindings for child Pino");Y=Y||{},s&&P.serializers&&(Y.serializers=P.serializers);const G=Y.serializers;if(s&&G){var tt=Object.assign({},i,G),K=r.browser.serialize===!0?Object.keys(tt):s;delete P.serializers,fu([P],K,tt,this._stdErrSerialize)}function V(B){this._childLevel=(B._childLevel|0)+1,this.error=Xs(B,P,"error"),this.fatal=Xs(B,P,"fatal"),this.warn=Xs(B,P,"warn"),this.info=Xs(B,P,"info"),this.debug=Xs(B,P,"debug"),this.trace=Xs(B,P,"trace"),tt&&(this.serializers=tt,this._serialize=K),t&&(this._logEvent=Pl([].concat(B._logEvent.bindings,P)))}return V.prototype=this,new V(this)}return d}an.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};an.stdSerializers=qS;an.stdTimeFunctions=Object.assign({},{nullTime:zg,epochTime:kg,unixTime:VS,isoTime:GS});function Js(r,t,e,i){const s=Object.getPrototypeOf(t);t[e]=t.levelVal>t.levels.values[e]?ca:s[e]?s[e]:aa[e]||aa[i]||ca,$S(r,t,e)}function $S(r,t,e){!r.transmit&&t[e]===ca||(t[e]=function(i){return function(){const a=r.timestamp(),u=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===aa?aa:this;for(var d=0;d<u.length;d++)u[d]=arguments[d];if(r.serialize&&!r.asObject&&fu(u,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(l,zS(this,e,u,a)):i.apply(l,u),r.transmit){const f=r.transmit.level||t.level,w=an.levels.values[f],E=an.levels.values[e];if(E<w)return;kS(this,{ts:a,methodLevel:e,methodValue:E,transmitLevel:f,transmitValue:an.levels.values[r.transmit.level||t.level],send:r.transmit.send,val:t.levelVal},u)}}}(t[e]))}function zS(r,t,e,i){r._serialize&&fu(e,r._serialize,r.serializers,r._stdErrSerialize);const s=e.slice();let a=s[0];const u={};i&&(u.time=i),u.level=an.levels.values[t];let l=(r._childLevel|0)+1;if(l<1&&(l=1),a!==null&&typeof a=="object"){for(;l--&&typeof s[0]=="object";)Object.assign(u,s.shift());a=s.length?xp(s.shift(),s):void 0}else typeof a=="string"&&(a=xp(s.shift(),s));return a!==void 0&&(u.msg=a),u}function fu(r,t,e,i){for(const s in r)if(i&&r[s]instanceof Error)r[s]=an.stdSerializers.err(r[s]);else if(typeof r[s]=="object"&&!Array.isArray(r[s]))for(const a in r[s])t&&t.indexOf(a)>-1&&a in e&&(r[s][a]=e[a](r[s][a]))}function Xs(r,t,e){return function(){const i=new Array(1+arguments.length);i[0]=t;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return r[e].apply(this,i)}}function kS(r,t,e){const i=t.send,s=t.ts,a=t.methodLevel,u=t.methodValue,l=t.val,d=r._logEvent.bindings;fu(e,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=s,r._logEvent.messages=e.filter(function(f){return d.indexOf(f)===-1}),r._logEvent.level.label=a,r._logEvent.level.value=u,i(a,r._logEvent,l),r._logEvent=Pl(d)}function Pl(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function HS(r){const t={type:r.constructor.name,msg:r.message,stack:r.stack};for(const e in r)t[e]===void 0&&(t[e]=r[e]);return t}function KS(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?zg:kg}function Oc(){return{}}function Xh(r){return r}function ca(){}function zg(){return!1}function kg(){return Date.now()}function VS(){return Math.round(Date.now()/1e3)}function GS(){return new Date(Date.now()).toISOString()}function WS(){function r(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return r(self)||r(window)||r(this)||{}}}const wa=Bl(eo),YS={level:"info"},ba="custom_context",ef=1e3*1024;let QS=class{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Mp=class{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0}append(t){const e=new QS(t);if(e.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${e.size}`);for(;this.size+e.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=e),this.tail=e):(this.head=e,this.tail=e),this.lengthInNodes++,this.sizeInBytes+=e.size}shift(){if(!this.head)return;const t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size}toArray(){const t=[];let e=this.head;for(;e!==null;)t.push(e.value),e=e.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return{next:()=>{if(!t)return{done:!0,value:null};const e=t.value;return t=t.next,{done:!1,value:e}}}}},Hg=class{constructor(t,e=ef){this.level=t??"error",this.levelValue=eo.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=e,this.logs=new Mp(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(t,e){e===eo.levels.values.error?console.error(t):e===eo.levels.values.warn?console.warn(t):e===eo.levels.values.debug?console.debug(t):e===eo.levels.values.trace?console.trace(t):console.log(t)}appendToLogs(t){this.logs.append(xn({timestamp:new Date().toISOString(),log:t}));const e=typeof t=="string"?JSON.parse(t).level:t.level;e>=this.levelValue&&this.forwardToConsole(t,e)}getLogs(){return this.logs}clearLogs(){this.logs=new Mp(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(t){const e=this.getLogArray();return e.push(xn({extraMetadata:t})),new Blob(e,{type:"application/json"})}},JS=class{constructor(t,e=ef){this.baseChunkLogger=new Hg(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){const e=URL.createObjectURL(this.logsToBlob(t)),i=document.createElement("a");i.href=e,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(e)}},XS=class{constructor(t,e=ef){this.baseChunkLogger=new Hg(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}};var ZS=Object.defineProperty,tI=Object.defineProperties,eI=Object.getOwnPropertyDescriptors,Cp=Object.getOwnPropertySymbols,rI=Object.prototype.hasOwnProperty,iI=Object.prototype.propertyIsEnumerable,Pp=(r,t,e)=>t in r?ZS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tu=(r,t)=>{for(var e in t||(t={}))rI.call(t,e)&&Pp(r,e,t[e]);if(Cp)for(var e of Cp(t))iI.call(t,e)&&Pp(r,e,t[e]);return r},eu=(r,t)=>tI(r,eI(t));function du(r){return eu(tu({},r),{level:(r==null?void 0:r.level)||YS.level})}function nI(r,t=ba){return r[t]||""}function sI(r,t,e=ba){return r[e]=t,r}function Vr(r,t=ba){let e="";return typeof r.bindings>"u"?e=nI(r,t):e=r.bindings().context||"",e}function oI(r,t,e=ba){const i=Vr(r,e);return i.trim()?`${i}/${t}`:t}function Gr(r,t,e=ba){const i=oI(r,t,e),s=r.child({context:i});return sI(s,i,e)}function aI(r){var t,e;const i=new JS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:wa(eu(tu({},r.opts),{level:"trace",browser:eu(tu({},(e=r.opts)==null?void 0:e.browser),{write:s=>i.write(s)})})),chunkLoggerController:i}}function cI(r){var t;const e=new XS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:wa(eu(tu({},r.opts),{level:"trace"}),e),chunkLoggerController:e}}function uI(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?aI(r):cI(r)}let hI=class extends Ps{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}},lI=class extends Ps{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}},fI=class{constructor(t,e){this.logger=t,this.core=e}},dI=class extends Ps{constructor(t,e){super(),this.relayer=t,this.logger=e}},pI=class extends Ps{constructor(t){super()}},gI=class{constructor(t,e,i,s){this.core=t,this.logger=e,this.name=i}},mI=class extends Ps{constructor(t,e){super(),this.relayer=t,this.logger=e}},vI=class extends Ps{constructor(t,e){super(),this.core=t,this.logger=e}},yI=class{constructor(t,e){this.projectId=t,this.logger=e}},wI=class{constructor(t,e){this.projectId=t,this.logger=e}},bI=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},_I=class{constructor(t){this.client=t}};var rf={},Kg={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=si;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function l(){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 l.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},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._tempHi),e.wipe(this._tempLo),this.reset()},l.prototype.update=function(d,f){if(f===void 0&&(f=d.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=d[w++],f--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,d,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=d[w++],f--;return this},l.prototype.finish=function(d){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,I=f<<3,D=f%128<112?128:256;this._buffer[w]=128;for(var P=w+1;P<D-8;P++)this._buffer[P]=0;t.writeUint32BE(E,this._buffer,D-8),t.writeUint32BE(I,this._buffer,D-4),a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,D),this._finished=!0}for(var P=0;P<this.digestLength/8;P++)t.writeUint32BE(this._stateHi[P],d,P*8),t.writeUint32BE(this._stateLo[P],d,P*8+4);return this},l.prototype.digest=function(){var d=new Uint8Array(this.digestLength);return this.finish(d),d},l.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}},l.prototype.restoreState=function(d){return this._stateHi.set(d.stateHi),this._stateLo.set(d.stateLo),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(d){e.wipe(d.stateHi),e.wipe(d.stateLo),d.buffer&&e.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},l}();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(l,d,f,w,E,I,D){for(var P=f[0],Y=f[1],G=f[2],tt=f[3],K=f[4],V=f[5],B=f[6],$=f[7],z=w[0],v=w[1],T=w[2],nt=w[3],ft=w[4],pt=w[5],mt=w[6],h=w[7],y,b,M,C,R,j,S,g;D>=128;){for(var N=0;N<16;N++){var it=8*N+I;l[N]=t.readUint32BE(E,it),d[N]=t.readUint32BE(E,it+4)}for(var N=0;N<80;N++){var lt=P,_=Y,Z=G,U=tt,L=K,k=V,p=B,F=$,et=z,ut=v,at=T,Mt=nt,Pt=ft,It=pt,Ee=mt,$t=h;if(y=$,b=h,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=(K>>>14|ft<<32-14)^(K>>>18|ft<<32-18)^(ft>>>41-32|K<<32-(41-32)),b=(ft>>>14|K<<32-14)^(ft>>>18|K<<32-18)^(K>>>41-32|ft<<32-(41-32)),R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,y=K&V^~K&B,b=ft&pt^~ft&mt,R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,y=s[N*2],b=s[N*2+1],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,y=l[N%16],b=d[N%16],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,M=S&65535|g<<16,C=R&65535|j<<16,y=M,b=C,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=(P>>>28|z<<32-28)^(z>>>34-32|P<<32-(34-32))^(z>>>39-32|P<<32-(39-32)),b=(z>>>28|P<<32-28)^(P>>>34-32|z<<32-(34-32))^(P>>>39-32|z<<32-(39-32)),R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,y=P&Y^P&G^Y&G,b=z&v^z&T^v&T,R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,F=S&65535|g<<16,$t=R&65535|j<<16,y=U,b=Mt,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=M,b=C,R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,U=S&65535|g<<16,Mt=R&65535|j<<16,Y=lt,G=_,tt=Z,K=U,V=L,B=k,$=p,P=F,v=et,T=ut,nt=at,ft=Mt,pt=Pt,mt=It,h=Ee,z=$t,N%16===15)for(var it=0;it<16;it++)y=l[it],b=d[it],R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=l[(it+9)%16],b=d[(it+9)%16],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,M=l[(it+1)%16],C=d[(it+1)%16],y=(M>>>1|C<<32-1)^(M>>>8|C<<32-8)^M>>>7,b=(C>>>1|M<<32-1)^(C>>>8|M<<32-8)^(C>>>7|M<<32-7),R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,M=l[(it+14)%16],C=d[(it+14)%16],y=(M>>>19|C<<32-19)^(C>>>61-32|M<<32-(61-32))^M>>>6,b=(C>>>19|M<<32-19)^(M>>>61-32|C<<32-(61-32))^(C>>>6|M<<32-6),R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,l[it]=S&65535|g<<16,d[it]=R&65535|j<<16}y=P,b=z,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[0],b=w[0],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[0]=P=S&65535|g<<16,w[0]=z=R&65535|j<<16,y=Y,b=v,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[1],b=w[1],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[1]=Y=S&65535|g<<16,w[1]=v=R&65535|j<<16,y=G,b=T,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[2],b=w[2],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[2]=G=S&65535|g<<16,w[2]=T=R&65535|j<<16,y=tt,b=nt,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[3],b=w[3],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[3]=tt=S&65535|g<<16,w[3]=nt=R&65535|j<<16,y=K,b=ft,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[4],b=w[4],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[4]=K=S&65535|g<<16,w[4]=ft=R&65535|j<<16,y=V,b=pt,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[5],b=w[5],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[5]=V=S&65535|g<<16,w[5]=pt=R&65535|j<<16,y=B,b=mt,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[6],b=w[6],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[6]=B=S&65535|g<<16,w[6]=mt=R&65535|j<<16,y=$,b=h,R=b&65535,j=b>>>16,S=y&65535,g=y>>>16,y=f[7],b=w[7],R+=b&65535,j+=b>>>16,S+=y&65535,g+=y>>>16,j+=R>>>16,S+=j>>>16,g+=S>>>16,f[7]=$=S&65535|g<<16,w[7]=h=R&65535|j<<16,I+=128,D-=128}return I}function u(l){var d=new i;d.update(l);var f=d.digest();return d.clean(),f}r.hash=u})(Kg);(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 t=fo,e=Kg,i=si;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function s(U){const L=new Float64Array(16);if(U)for(let k=0;k<U.length;k++)L[k]=U[k];return L}const a=new Uint8Array(32);a[0]=9;const u=s(),l=s([1]),d=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),I=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function D(U,L){for(let k=0;k<16;k++)U[k]=L[k]|0}function P(U){let L=1;for(let k=0;k<16;k++){let p=U[k]+L+65535;L=Math.floor(p/65536),U[k]=p-L*65536}U[0]+=L-1+37*(L-1)}function Y(U,L,k){const p=~(k-1);for(let F=0;F<16;F++){const et=p&(U[F]^L[F]);U[F]^=et,L[F]^=et}}function G(U,L){const k=s(),p=s();for(let F=0;F<16;F++)p[F]=L[F];P(p),P(p),P(p);for(let F=0;F<2;F++){k[0]=p[0]-65517;for(let ut=1;ut<15;ut++)k[ut]=p[ut]-65535-(k[ut-1]>>16&1),k[ut-1]&=65535;k[15]=p[15]-32767-(k[14]>>16&1);const et=k[15]>>16&1;k[14]&=65535,Y(p,k,1-et)}for(let F=0;F<16;F++)U[2*F]=p[F]&255,U[2*F+1]=p[F]>>8}function tt(U,L){let k=0;for(let p=0;p<32;p++)k|=U[p]^L[p];return(1&k-1>>>8)-1}function K(U,L){const k=new Uint8Array(32),p=new Uint8Array(32);return G(k,U),G(p,L),tt(k,p)}function V(U){const L=new Uint8Array(32);return G(L,U),L[0]&1}function B(U,L){for(let k=0;k<16;k++)U[k]=L[2*k]+(L[2*k+1]<<8);U[15]&=32767}function $(U,L,k){for(let p=0;p<16;p++)U[p]=L[p]+k[p]}function z(U,L,k){for(let p=0;p<16;p++)U[p]=L[p]-k[p]}function v(U,L,k){let p,F,et=0,ut=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=0,Bt=0,_t=0,Et=0,Vt=0,yt=0,At=0,Ut=0,wt=0,Ct=0,Lt=0,Ot=0,Nt=0,se=0,Tt=0,Rt=0,Ke=0,ce=0,pe=0,Ve=0,ye=0,_e=0,Er=0,Gt=k[0],zt=k[1],De=k[2],Wt=k[3],Kt=k[4],Ae=k[5],Jt=k[6],Xt=k[7],xe=k[8],Zt=k[9],Yt=k[10],Ce=k[11],Qt=k[12],qt=k[13],Te=k[14],te=k[15];p=L[0],et+=p*Gt,ut+=p*zt,at+=p*De,Mt+=p*Wt,Pt+=p*Kt,It+=p*Ae,Ee+=p*Jt,$t+=p*Xt,xt+=p*xe,Bt+=p*Zt,_t+=p*Yt,Et+=p*Ce,Vt+=p*Qt,yt+=p*qt,At+=p*Te,Ut+=p*te,p=L[1],ut+=p*Gt,at+=p*zt,Mt+=p*De,Pt+=p*Wt,It+=p*Kt,Ee+=p*Ae,$t+=p*Jt,xt+=p*Xt,Bt+=p*xe,_t+=p*Zt,Et+=p*Yt,Vt+=p*Ce,yt+=p*Qt,At+=p*qt,Ut+=p*Te,wt+=p*te,p=L[2],at+=p*Gt,Mt+=p*zt,Pt+=p*De,It+=p*Wt,Ee+=p*Kt,$t+=p*Ae,xt+=p*Jt,Bt+=p*Xt,_t+=p*xe,Et+=p*Zt,Vt+=p*Yt,yt+=p*Ce,At+=p*Qt,Ut+=p*qt,wt+=p*Te,Ct+=p*te,p=L[3],Mt+=p*Gt,Pt+=p*zt,It+=p*De,Ee+=p*Wt,$t+=p*Kt,xt+=p*Ae,Bt+=p*Jt,_t+=p*Xt,Et+=p*xe,Vt+=p*Zt,yt+=p*Yt,At+=p*Ce,Ut+=p*Qt,wt+=p*qt,Ct+=p*Te,Lt+=p*te,p=L[4],Pt+=p*Gt,It+=p*zt,Ee+=p*De,$t+=p*Wt,xt+=p*Kt,Bt+=p*Ae,_t+=p*Jt,Et+=p*Xt,Vt+=p*xe,yt+=p*Zt,At+=p*Yt,Ut+=p*Ce,wt+=p*Qt,Ct+=p*qt,Lt+=p*Te,Ot+=p*te,p=L[5],It+=p*Gt,Ee+=p*zt,$t+=p*De,xt+=p*Wt,Bt+=p*Kt,_t+=p*Ae,Et+=p*Jt,Vt+=p*Xt,yt+=p*xe,At+=p*Zt,Ut+=p*Yt,wt+=p*Ce,Ct+=p*Qt,Lt+=p*qt,Ot+=p*Te,Nt+=p*te,p=L[6],Ee+=p*Gt,$t+=p*zt,xt+=p*De,Bt+=p*Wt,_t+=p*Kt,Et+=p*Ae,Vt+=p*Jt,yt+=p*Xt,At+=p*xe,Ut+=p*Zt,wt+=p*Yt,Ct+=p*Ce,Lt+=p*Qt,Ot+=p*qt,Nt+=p*Te,se+=p*te,p=L[7],$t+=p*Gt,xt+=p*zt,Bt+=p*De,_t+=p*Wt,Et+=p*Kt,Vt+=p*Ae,yt+=p*Jt,At+=p*Xt,Ut+=p*xe,wt+=p*Zt,Ct+=p*Yt,Lt+=p*Ce,Ot+=p*Qt,Nt+=p*qt,se+=p*Te,Tt+=p*te,p=L[8],xt+=p*Gt,Bt+=p*zt,_t+=p*De,Et+=p*Wt,Vt+=p*Kt,yt+=p*Ae,At+=p*Jt,Ut+=p*Xt,wt+=p*xe,Ct+=p*Zt,Lt+=p*Yt,Ot+=p*Ce,Nt+=p*Qt,se+=p*qt,Tt+=p*Te,Rt+=p*te,p=L[9],Bt+=p*Gt,_t+=p*zt,Et+=p*De,Vt+=p*Wt,yt+=p*Kt,At+=p*Ae,Ut+=p*Jt,wt+=p*Xt,Ct+=p*xe,Lt+=p*Zt,Ot+=p*Yt,Nt+=p*Ce,se+=p*Qt,Tt+=p*qt,Rt+=p*Te,Ke+=p*te,p=L[10],_t+=p*Gt,Et+=p*zt,Vt+=p*De,yt+=p*Wt,At+=p*Kt,Ut+=p*Ae,wt+=p*Jt,Ct+=p*Xt,Lt+=p*xe,Ot+=p*Zt,Nt+=p*Yt,se+=p*Ce,Tt+=p*Qt,Rt+=p*qt,Ke+=p*Te,ce+=p*te,p=L[11],Et+=p*Gt,Vt+=p*zt,yt+=p*De,At+=p*Wt,Ut+=p*Kt,wt+=p*Ae,Ct+=p*Jt,Lt+=p*Xt,Ot+=p*xe,Nt+=p*Zt,se+=p*Yt,Tt+=p*Ce,Rt+=p*Qt,Ke+=p*qt,ce+=p*Te,pe+=p*te,p=L[12],Vt+=p*Gt,yt+=p*zt,At+=p*De,Ut+=p*Wt,wt+=p*Kt,Ct+=p*Ae,Lt+=p*Jt,Ot+=p*Xt,Nt+=p*xe,se+=p*Zt,Tt+=p*Yt,Rt+=p*Ce,Ke+=p*Qt,ce+=p*qt,pe+=p*Te,Ve+=p*te,p=L[13],yt+=p*Gt,At+=p*zt,Ut+=p*De,wt+=p*Wt,Ct+=p*Kt,Lt+=p*Ae,Ot+=p*Jt,Nt+=p*Xt,se+=p*xe,Tt+=p*Zt,Rt+=p*Yt,Ke+=p*Ce,ce+=p*Qt,pe+=p*qt,Ve+=p*Te,ye+=p*te,p=L[14],At+=p*Gt,Ut+=p*zt,wt+=p*De,Ct+=p*Wt,Lt+=p*Kt,Ot+=p*Ae,Nt+=p*Jt,se+=p*Xt,Tt+=p*xe,Rt+=p*Zt,Ke+=p*Yt,ce+=p*Ce,pe+=p*Qt,Ve+=p*qt,ye+=p*Te,_e+=p*te,p=L[15],Ut+=p*Gt,wt+=p*zt,Ct+=p*De,Lt+=p*Wt,Ot+=p*Kt,Nt+=p*Ae,se+=p*Jt,Tt+=p*Xt,Rt+=p*xe,Ke+=p*Zt,ce+=p*Yt,pe+=p*Ce,Ve+=p*Qt,ye+=p*qt,_e+=p*Te,Er+=p*te,et+=38*wt,ut+=38*Ct,at+=38*Lt,Mt+=38*Ot,Pt+=38*Nt,It+=38*se,Ee+=38*Tt,$t+=38*Rt,xt+=38*Ke,Bt+=38*ce,_t+=38*pe,Et+=38*Ve,Vt+=38*ye,yt+=38*_e,At+=38*Er,F=1,p=et+F+65535,F=Math.floor(p/65536),et=p-F*65536,p=ut+F+65535,F=Math.floor(p/65536),ut=p-F*65536,p=at+F+65535,F=Math.floor(p/65536),at=p-F*65536,p=Mt+F+65535,F=Math.floor(p/65536),Mt=p-F*65536,p=Pt+F+65535,F=Math.floor(p/65536),Pt=p-F*65536,p=It+F+65535,F=Math.floor(p/65536),It=p-F*65536,p=Ee+F+65535,F=Math.floor(p/65536),Ee=p-F*65536,p=$t+F+65535,F=Math.floor(p/65536),$t=p-F*65536,p=xt+F+65535,F=Math.floor(p/65536),xt=p-F*65536,p=Bt+F+65535,F=Math.floor(p/65536),Bt=p-F*65536,p=_t+F+65535,F=Math.floor(p/65536),_t=p-F*65536,p=Et+F+65535,F=Math.floor(p/65536),Et=p-F*65536,p=Vt+F+65535,F=Math.floor(p/65536),Vt=p-F*65536,p=yt+F+65535,F=Math.floor(p/65536),yt=p-F*65536,p=At+F+65535,F=Math.floor(p/65536),At=p-F*65536,p=Ut+F+65535,F=Math.floor(p/65536),Ut=p-F*65536,et+=F-1+37*(F-1),F=1,p=et+F+65535,F=Math.floor(p/65536),et=p-F*65536,p=ut+F+65535,F=Math.floor(p/65536),ut=p-F*65536,p=at+F+65535,F=Math.floor(p/65536),at=p-F*65536,p=Mt+F+65535,F=Math.floor(p/65536),Mt=p-F*65536,p=Pt+F+65535,F=Math.floor(p/65536),Pt=p-F*65536,p=It+F+65535,F=Math.floor(p/65536),It=p-F*65536,p=Ee+F+65535,F=Math.floor(p/65536),Ee=p-F*65536,p=$t+F+65535,F=Math.floor(p/65536),$t=p-F*65536,p=xt+F+65535,F=Math.floor(p/65536),xt=p-F*65536,p=Bt+F+65535,F=Math.floor(p/65536),Bt=p-F*65536,p=_t+F+65535,F=Math.floor(p/65536),_t=p-F*65536,p=Et+F+65535,F=Math.floor(p/65536),Et=p-F*65536,p=Vt+F+65535,F=Math.floor(p/65536),Vt=p-F*65536,p=yt+F+65535,F=Math.floor(p/65536),yt=p-F*65536,p=At+F+65535,F=Math.floor(p/65536),At=p-F*65536,p=Ut+F+65535,F=Math.floor(p/65536),Ut=p-F*65536,et+=F-1+37*(F-1),U[0]=et,U[1]=ut,U[2]=at,U[3]=Mt,U[4]=Pt,U[5]=It,U[6]=Ee,U[7]=$t,U[8]=xt,U[9]=Bt,U[10]=_t,U[11]=Et,U[12]=Vt,U[13]=yt,U[14]=At,U[15]=Ut}function T(U,L){v(U,L,L)}function nt(U,L){const k=s();let p;for(p=0;p<16;p++)k[p]=L[p];for(p=253;p>=0;p--)T(k,k),p!==2&&p!==4&&v(k,k,L);for(p=0;p<16;p++)U[p]=k[p]}function ft(U,L){const k=s();let p;for(p=0;p<16;p++)k[p]=L[p];for(p=250;p>=0;p--)T(k,k),p!==1&&v(k,k,L);for(p=0;p<16;p++)U[p]=k[p]}function pt(U,L){const k=s(),p=s(),F=s(),et=s(),ut=s(),at=s(),Mt=s(),Pt=s(),It=s();z(k,U[1],U[0]),z(It,L[1],L[0]),v(k,k,It),$(p,U[0],U[1]),$(It,L[0],L[1]),v(p,p,It),v(F,U[3],L[3]),v(F,F,f),v(et,U[2],L[2]),$(et,et,et),z(ut,p,k),z(at,et,F),$(Mt,et,F),$(Pt,p,k),v(U[0],ut,at),v(U[1],Pt,Mt),v(U[2],Mt,at),v(U[3],ut,Pt)}function mt(U,L,k){for(let p=0;p<4;p++)Y(U[p],L[p],k)}function h(U,L){const k=s(),p=s(),F=s();nt(F,L[2]),v(k,L[0],F),v(p,L[1],F),G(U,p),U[31]^=V(k)<<7}function y(U,L,k){D(U[0],u),D(U[1],l),D(U[2],l),D(U[3],u);for(let p=255;p>=0;--p){const F=k[p/8|0]>>(p&7)&1;mt(U,L,F),pt(L,U),pt(U,U),mt(U,L,F)}}function b(U,L){const k=[s(),s(),s(),s()];D(k[0],w),D(k[1],E),D(k[2],l),v(k[3],w,E),y(U,k,L)}function M(U){if(U.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const L=(0,e.hash)(U);L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(32),p=[s(),s(),s(),s()];b(p,L),h(k,p);const F=new Uint8Array(64);return F.set(U),F.set(k,32),{publicKey:k,secretKey:F}}r.generateKeyPairFromSeed=M;function C(U){const L=(0,t.randomBytes)(32,U),k=M(L);return(0,i.wipe)(L),k}r.generateKeyPair=C;function R(U){if(U.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(U.subarray(32))}r.extractPublicKeyFromSecretKey=R;const j=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 S(U,L){let k,p,F,et;for(p=63;p>=32;--p){for(k=0,F=p-32,et=p-12;F<et;++F)L[F]+=k-16*L[p]*j[F-(p-32)],k=Math.floor((L[F]+128)/256),L[F]-=k*256;L[F]+=k,L[p]=0}for(k=0,F=0;F<32;F++)L[F]+=k-(L[31]>>4)*j[F],k=L[F]>>8,L[F]&=255;for(F=0;F<32;F++)L[F]-=k*j[F];for(p=0;p<32;p++)L[p+1]+=L[p]>>8,U[p]=L[p]&255}function g(U){const L=new Float64Array(64);for(let k=0;k<64;k++)L[k]=U[k];for(let k=0;k<64;k++)U[k]=0;S(U,L)}function N(U,L){const k=new Float64Array(64),p=[s(),s(),s(),s()],F=(0,e.hash)(U.subarray(0,32));F[0]&=248,F[31]&=127,F[31]|=64;const et=new Uint8Array(64);et.set(F.subarray(32),32);const ut=new e.SHA512;ut.update(et.subarray(32)),ut.update(L);const at=ut.digest();ut.clean(),g(at),b(p,at),h(et,p),ut.reset(),ut.update(et.subarray(0,32)),ut.update(U.subarray(32)),ut.update(L);const Mt=ut.digest();g(Mt);for(let Pt=0;Pt<32;Pt++)k[Pt]=at[Pt];for(let Pt=0;Pt<32;Pt++)for(let It=0;It<32;It++)k[Pt+It]+=Mt[Pt]*F[It];return S(et.subarray(32),k),et}r.sign=N;function it(U,L){const k=s(),p=s(),F=s(),et=s(),ut=s(),at=s(),Mt=s();return D(U[2],l),B(U[1],L),T(F,U[1]),v(et,F,d),z(F,F,U[2]),$(et,U[2],et),T(ut,et),T(at,ut),v(Mt,at,ut),v(k,Mt,F),v(k,k,et),ft(k,k),v(k,k,F),v(k,k,et),v(k,k,et),v(U[0],k,et),T(p,U[0]),v(p,p,et),K(p,F)&&v(U[0],U[0],I),T(p,U[0]),v(p,p,et),K(p,F)?-1:(V(U[0])===L[31]>>7&&z(U[0],u,U[0]),v(U[3],U[0],U[1]),0)}function lt(U,L,k){const p=new Uint8Array(32),F=[s(),s(),s(),s()],et=[s(),s(),s(),s()];if(k.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(it(et,U))return!1;const ut=new e.SHA512;ut.update(k.subarray(0,32)),ut.update(U),ut.update(L);const at=ut.digest();return g(at),y(F,et,at),b(et,k.subarray(32)),pt(F,et),h(p,F),!tt(k,p)}r.verify=lt;function _(U){let L=[s(),s(),s(),s()];if(it(L,U))throw new Error("Ed25519: invalid public key");let k=s(),p=s(),F=L[1];$(k,l,F),z(p,l,F),nt(p,p),v(k,k,p);let et=new Uint8Array(32);return G(et,k),et}r.convertPublicKeyToX25519=_;function Z(U){const L=(0,e.hash)(U.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(L.subarray(0,32));return(0,i.wipe)(L),k}r.convertSecretKeyToX25519=Z})(rf);const EI="EdDSA",AI="JWT",Vg=".",Gg="base64url",SI="utf8",II="utf8",DI=":",xI="did",MI="key",Op="base58btc",CI="z",PI="K36",OI=32;function ru(r){return Rr(Hr(xn(r),SI),Gg)}function Wg(r){const t=Hr(PI,Op),e=CI+Rr(yl([t,r]),Op);return[xI,MI,e].join(DI)}function NI(r){return Rr(r,Gg)}function RI(r){return Hr([ru(r.header),ru(r.payload)].join(Vg),II)}function TI(r){return[ru(r.header),ru(r.payload),NI(r.signature)].join(Vg)}function Np(r=fo.randomBytes(OI)){return rf.generateKeyPairFromSeed(r)}async function FI(r,t,e,i,s=bt.fromMiliseconds(Date.now())){const a={alg:EI,typ:AI},u=Wg(i.publicKey),l=s+e,d={iss:u,sub:r,aud:t,iat:s,exp:l},f=RI({header:a,payload:d}),w=rf.sign(i.secretKey,f);return TI({header:a,payload:d,signature:w})}const UI="PARSE_ERROR",BI="INVALID_REQUEST",LI="METHOD_NOT_FOUND",qI="INVALID_PARAMS",Yg="INTERNAL_ERROR",nf="SERVER_ERROR",jI=[-32700,-32600,-32601,-32602,-32603],ta={[UI]:{code:-32700,message:"Parse error"},[BI]:{code:-32600,message:"Invalid Request"},[LI]:{code:-32601,message:"Method not found"},[qI]:{code:-32602,message:"Invalid params"},[Yg]:{code:-32603,message:"Internal error"},[nf]:{code:-32e3,message:"Server error"}},Qg=nf;function $I(r){return jI.includes(r)}function Rp(r){return Object.keys(ta).includes(r)?ta[r]:ta[Qg]}function zI(r){const t=Object.values(ta).find(e=>e.code===r);return t||ta[Qg]}function Jg(r,t,e){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${e} RPC url at ${t}`):r}var Xg={},_n={},Tp;function kI(){if(Tp)return _n;Tp=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.isBrowserCryptoAvailable=_n.getSubtleCrypto=_n.getBrowerCrypto=void 0;function r(){return(Xi===null||Xi===void 0?void 0:Xi.crypto)||(Xi===null||Xi===void 0?void 0:Xi.msCrypto)||{}}_n.getBrowerCrypto=r;function t(){const i=r();return i.subtle||i.webkitSubtle}_n.getSubtleCrypto=t;function e(){return!!r()&&!!t()}return _n.isBrowserCryptoAvailable=e,_n}var En={},Fp;function HI(){if(Fp)return En;Fp=1,Object.defineProperty(En,"__esModule",{value:!0}),En.isBrowser=En.isNode=En.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}En.isReactNative=r;function t(){return typeof ri<"u"&&typeof ri.versions<"u"&&typeof ri.versions.node<"u"}En.isNode=t;function e(){return!r()&&!t()}return En.isBrowser=e,En}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=ha;t.__exportStar(kI(),r),t.__exportStar(HI(),r)})(Xg);function Hn(r=3){const t=Date.now()*Math.pow(10,r),e=Math.floor(Math.random()*Math.pow(10,r));return t+e}function Ss(r=6){return BigInt(Hn(r))}function co(r,t,e){return{id:e||Hn(),jsonrpc:"2.0",method:r,params:t}}function pu(r,t){return{id:r,jsonrpc:"2.0",result:t}}function gu(r,t,e){return{id:r,jsonrpc:"2.0",error:KI(t,e)}}function KI(r,t){return typeof r>"u"?Rp(Yg):(typeof r=="string"&&(r=Object.assign(Object.assign({},Rp(nf)),{message:r})),typeof t<"u"&&(r.data=t),$I(r.code)&&(r=zI(r.code)),r)}class VI{}class GI extends VI{constructor(){super()}}class WI extends GI{constructor(t){super()}}const YI="^https?:",QI="^wss?:";function JI(r){const t=r.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function Zg(r,t){const e=JI(r);return typeof e>"u"?!1:new RegExp(t).test(e)}function Up(r){return Zg(r,YI)}function Bp(r){return Zg(r,QI)}function XI(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function tm(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function sf(r){return tm(r)&&"method"in r}function mu(r){return tm(r)&&(Qi(r)||Si(r))}function Qi(r){return"result"in r}function Si(r){return"error"in r}class Mn extends WI{constructor(t){super(t),this.events=new Di.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(co(t.method,t.params||[],t.id||Ss().toString()),e)}async requestStrict(t,e){return new Promise(async(i,s)=>{if(!this.connection.connected)try{await this.open()}catch(a){s(a)}this.events.on(`${t.id}`,a=>{Si(a)?s(a.error):i(a.result)});try{await this.connection.send(t,e)}catch(a){s(a)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),mu(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const ZI=()=>typeof WebSocket<"u"?WebSocket:typeof Ie<"u"&&typeof Ie.WebSocket<"u"?Ie.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),tD=()=>typeof WebSocket<"u"||typeof Ie<"u"&&typeof Ie.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Lp=r=>r.split("?")[0],qp=10,eD=ZI();let rD=class{constructor(t){if(this.url=t,this.events=new Di.EventEmitter,this.registering=!1,!Bp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,e)=>{if(typeof this.socket>"u"){e(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(xn(t))}catch(e){this.onError(t.id,e)}}register(t=this.url){if(!Bp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+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=t,this.registering=!0,new Promise((e,i)=>{const s=new URLSearchParams(t).get("origin"),a=Xg.isReactNative()?{headers:{origin:s}}:{rejectUnauthorized:!XI(t)},u=new eD(t,[],a);tD()?u.onerror=l=>{const d=l;i(this.emitError(d.error))}:u.on("error",l=>{i(this.emitError(l))}),u.onopen=()=>{this.onOpen(u),e(u)}})}onOpen(t){t.onmessage=e=>this.onPayload(e),t.onclose=e=>this.onClose(e),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?va(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const i=this.parseError(e),s=i.message||i.toString(),a=gu(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Jg(t,Lp(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>qp&&this.events.setMaxListeners(qp)}emitError(t){const e=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Lp(this.url)}`));return this.events.emit("register_error",e),e}};var iu={exports:{}};iu.exports;(function(r,t){var e=200,i="__lodash_hash_undefined__",s=1,a=2,u=9007199254740991,l="[object Arguments]",d="[object Array]",f="[object AsyncFunction]",w="[object Boolean]",E="[object Date]",I="[object Error]",D="[object Function]",P="[object GeneratorFunction]",Y="[object Map]",G="[object Number]",tt="[object Null]",K="[object Object]",V="[object Promise]",B="[object Proxy]",$="[object RegExp]",z="[object Set]",v="[object String]",T="[object Symbol]",nt="[object Undefined]",ft="[object WeakMap]",pt="[object ArrayBuffer]",mt="[object DataView]",h="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",M="[object Int16Array]",C="[object Int32Array]",R="[object Uint8Array]",j="[object Uint8ClampedArray]",S="[object Uint16Array]",g="[object Uint32Array]",N=/[\\^$.*+?()[\]{}|]/g,it=/^\[object .+?Constructor\]$/,lt=/^(?:0|[1-9]\d*)$/,_={};_[h]=_[y]=_[b]=_[M]=_[C]=_[R]=_[j]=_[S]=_[g]=!0,_[l]=_[d]=_[pt]=_[w]=_[mt]=_[E]=_[I]=_[D]=_[Y]=_[G]=_[K]=_[$]=_[z]=_[v]=_[ft]=!1;var Z=typeof Xi=="object"&&Xi&&Xi.Object===Object&&Xi,U=typeof self=="object"&&self&&self.Object===Object&&self,L=Z||U||Function("return this")(),k=t&&!t.nodeType&&t,p=k&&!0&&r&&!r.nodeType&&r,F=p&&p.exports===k,et=F&&Z.process,ut=function(){try{return et&&et.binding&&et.binding("util")}catch{}}(),at=ut&&ut.isTypedArray;function Mt(q,Q){for(var ht=-1,St=q==null?0:q.length,Be=0,re=[];++ht<St;){var $e=q[ht];Q($e,ht,q)&&(re[Be++]=$e)}return re}function Pt(q,Q){for(var ht=-1,St=Q.length,Be=q.length;++ht<St;)q[Be+ht]=Q[ht];return q}function It(q,Q){for(var ht=-1,St=q==null?0:q.length;++ht<St;)if(Q(q[ht],ht,q))return!0;return!1}function Ee(q,Q){for(var ht=-1,St=Array(q);++ht<q;)St[ht]=Q(ht);return St}function $t(q){return function(Q){return q(Q)}}function xt(q,Q){return q.has(Q)}function Bt(q,Q){return q==null?void 0:q[Q]}function _t(q){var Q=-1,ht=Array(q.size);return q.forEach(function(St,Be){ht[++Q]=[Be,St]}),ht}function Et(q,Q){return function(ht){return q(Q(ht))}}function Vt(q){var Q=-1,ht=Array(q.size);return q.forEach(function(St){ht[++Q]=St}),ht}var yt=Array.prototype,At=Function.prototype,Ut=Object.prototype,wt=L["__core-js_shared__"],Ct=At.toString,Lt=Ut.hasOwnProperty,Ot=function(){var q=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||"");return q?"Symbol(src)_1."+q:""}(),Nt=Ut.toString,se=RegExp("^"+Ct.call(Lt).replace(N,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tt=F?L.Buffer:void 0,Rt=L.Symbol,Ke=L.Uint8Array,ce=Ut.propertyIsEnumerable,pe=yt.splice,Ve=Rt?Rt.toStringTag:void 0,ye=Object.getOwnPropertySymbols,_e=Tt?Tt.isBuffer:void 0,Er=Et(Object.keys,Object),Gt=Wr(L,"DataView"),zt=Wr(L,"Map"),De=Wr(L,"Promise"),Wt=Wr(L,"Set"),Kt=Wr(L,"WeakMap"),Ae=Wr(Object,"create"),Jt=hn(Gt),Xt=hn(zt),xe=hn(De),Zt=hn(Wt),Yt=hn(Kt),Ce=Rt?Rt.prototype:void 0,Qt=Ce?Ce.valueOf:void 0;function qt(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function Te(){this.__data__=Ae?Ae(null):{},this.size=0}function te(q){var Q=this.has(q)&&delete this.__data__[q];return this.size-=Q?1:0,Q}function Pe(q){var Q=this.__data__;if(Ae){var ht=Q[q];return ht===i?void 0:ht}return Lt.call(Q,q)?Q[q]:void 0}function xi(q){var Q=this.__data__;return Ae?Q[q]!==void 0:Lt.call(Q,q)}function Oe(q,Q){var ht=this.__data__;return this.size+=this.has(q)?0:1,ht[q]=Ae&&Q===void 0?i:Q,this}qt.prototype.clear=Te,qt.prototype.delete=te,qt.prototype.get=Pe,qt.prototype.has=xi,qt.prototype.set=Oe;function le(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function oi(){this.__data__=[],this.size=0}function ai(q){var Q=this.__data__,ht=ss(Q,q);if(ht<0)return!1;var St=Q.length-1;return ht==St?Q.pop():pe.call(Q,ht,1),--this.size,!0}function ci(q){var Q=this.__data__,ht=ss(Q,q);return ht<0?void 0:Q[ht][1]}function ui(q){return ss(this.__data__,q)>-1}function hi(q,Q){var ht=this.__data__,St=ss(ht,q);return St<0?(++this.size,ht.push([q,Q])):ht[St][1]=Q,this}le.prototype.clear=oi,le.prototype.delete=ai,le.prototype.get=ci,le.prototype.has=ui,le.prototype.set=hi;function ar(q){var Q=-1,ht=q==null?0:q.length;for(this.clear();++Q<ht;){var St=q[Q];this.set(St[0],St[1])}}function qi(){this.size=0,this.__data__={hash:new qt,map:new(zt||le),string:new qt}}function Xn(q){var Q=Nn(this,q).delete(q);return this.size-=Q?1:0,Q}function ji(q){return Nn(this,q).get(q)}function Zn(q){return Nn(this,q).has(q)}function ts(q,Q){var ht=Nn(this,q),St=ht.size;return ht.set(q,Q),this.size+=ht.size==St?0:1,this}ar.prototype.clear=qi,ar.prototype.delete=Xn,ar.prototype.get=ji,ar.prototype.has=Zn,ar.prototype.set=ts;function $i(q){var Q=-1,ht=q==null?0:q.length;for(this.__data__=new ar;++Q<ht;)this.add(q[Q])}function Pn(q){return this.__data__.set(q,i),this}function On(q){return this.__data__.has(q)}$i.prototype.add=$i.prototype.push=Pn,$i.prototype.has=On;function Ar(q){var Q=this.__data__=new le(q);this.size=Q.size}function es(){this.__data__=new le,this.size=0}function rs(q){var Q=this.__data__,ht=Q.delete(q);return this.size=Q.size,ht}function is(q){return this.__data__.get(q)}function ns(q){return this.__data__.has(q)}function Ea(q,Q){var ht=this.__data__;if(ht instanceof le){var St=ht.__data__;if(!zt||St.length<e-1)return St.push([q,Q]),this.size=++ht.size,this;ht=this.__data__=new ar(St)}return ht.set(q,Q),this.size=ht.size,this}Ar.prototype.clear=es,Ar.prototype.delete=rs,Ar.prototype.get=is,Ar.prototype.has=ns,Ar.prototype.set=Ea;function Aa(q,Q){var ht=Fs(q),St=!ht&&Fa(q),Be=!ht&&!St&&Ao(q),re=!ht&&!St&&!Be&&La(q),$e=ht||St||Be||re,er=$e?Ee(q.length,String):[],we=er.length;for(var Le in q)(Q||Lt.call(q,Le))&&!($e&&(Le=="length"||Be&&(Le=="offset"||Le=="parent")||re&&(Le=="buffer"||Le=="byteLength"||Le=="byteOffset")||Pa(Le,we)))&&er.push(Le);return er}function ss(q,Q){for(var ht=q.length;ht--;)if(Ta(q[ht][0],Q))return ht;return-1}function _o(q,Q,ht){var St=Q(q);return Fs(q)?St:Pt(St,ht(q))}function os(q){return q==null?q===void 0?nt:tt:Ve&&Ve in Object(q)?Ma(q):_u(q)}function Eo(q){return cs(q)&&os(q)==l}function as(q,Q,ht,St,Be){return q===Q?!0:q==null||Q==null||!cs(q)&&!cs(Q)?q!==q&&Q!==Q:Sa(q,Q,ht,St,as,Be)}function Sa(q,Q,ht,St,Be,re){var $e=Fs(q),er=Fs(Q),we=$e?d:zi(q),Le=er?d:zi(Q);we=we==l?K:we,Le=Le==l?K:Le;var Qe=we==K,Fr=Le==K,rr=we==Le;if(rr&&Ao(q)){if(!Ao(Q))return!1;$e=!0,Qe=!1}if(rr&&!Qe)return re||(re=new Ar),$e||La(q)?Rs(q,Q,ht,St,Be,re):bu(q,Q,we,ht,St,Be,re);if(!(ht&s)){var ze=Qe&&Lt.call(q,"__wrapped__"),Sr=Fr&&Lt.call(Q,"__wrapped__");if(ze||Sr){var Mi=ze?q.value():q,li=Sr?Q.value():Q;return re||(re=new Ar),Be(Mi,li,ht,St,re)}}return rr?(re||(re=new Ar),xa(q,Q,ht,St,Be,re)):!1}function wu(q){if(!Ba(q)||Na(q))return!1;var Q=Us(q)?se:it;return Q.test(hn(q))}function Ia(q){return cs(q)&&Ua(q.length)&&!!_[os(q)]}function Da(q){if(!Ra(q))return Er(q);var Q=[];for(var ht in Object(q))Lt.call(q,ht)&&ht!="constructor"&&Q.push(ht);return Q}function Rs(q,Q,ht,St,Be,re){var $e=ht&s,er=q.length,we=Q.length;if(er!=we&&!($e&&we>er))return!1;var Le=re.get(q);if(Le&&re.get(Q))return Le==Q;var Qe=-1,Fr=!0,rr=ht&a?new $i:void 0;for(re.set(q,Q),re.set(Q,q);++Qe<er;){var ze=q[Qe],Sr=Q[Qe];if(St)var Mi=$e?St(Sr,ze,Qe,Q,q,re):St(ze,Sr,Qe,q,Q,re);if(Mi!==void 0){if(Mi)continue;Fr=!1;break}if(rr){if(!It(Q,function(li,ki){if(!xt(rr,ki)&&(ze===li||Be(ze,li,ht,St,re)))return rr.push(ki)})){Fr=!1;break}}else if(!(ze===Sr||Be(ze,Sr,ht,St,re))){Fr=!1;break}}return re.delete(q),re.delete(Q),Fr}function bu(q,Q,ht,St,Be,re,$e){switch(ht){case mt:if(q.byteLength!=Q.byteLength||q.byteOffset!=Q.byteOffset)return!1;q=q.buffer,Q=Q.buffer;case pt:return!(q.byteLength!=Q.byteLength||!re(new Ke(q),new Ke(Q)));case w:case E:case G:return Ta(+q,+Q);case I:return q.name==Q.name&&q.message==Q.message;case $:case v:return q==Q+"";case Y:var er=_t;case z:var we=St&s;if(er||(er=Vt),q.size!=Q.size&&!we)return!1;var Le=$e.get(q);if(Le)return Le==Q;St|=a,$e.set(q,Q);var Qe=Rs(er(q),er(Q),St,Be,re,$e);return $e.delete(q),Qe;case T:if(Qt)return Qt.call(q)==Qt.call(Q)}return!1}function xa(q,Q,ht,St,Be,re){var $e=ht&s,er=Ts(q),we=er.length,Le=Ts(Q),Qe=Le.length;if(we!=Qe&&!$e)return!1;for(var Fr=we;Fr--;){var rr=er[Fr];if(!($e?rr in Q:Lt.call(Q,rr)))return!1}var ze=re.get(q);if(ze&&re.get(Q))return ze==Q;var Sr=!0;re.set(q,Q),re.set(Q,q);for(var Mi=$e;++Fr<we;){rr=er[Fr];var li=q[rr],ki=Q[rr];if(St)var So=$e?St(ki,li,rr,Q,q,re):St(li,ki,rr,q,Q,re);if(!(So===void 0?li===ki||Be(li,ki,ht,St,re):So)){Sr=!1;break}Mi||(Mi=rr=="constructor")}if(Sr&&!Mi){var us=q.constructor,cr=Q.constructor;us!=cr&&"constructor"in q&&"constructor"in Q&&!(typeof us=="function"&&us instanceof us&&typeof cr=="function"&&cr instanceof cr)&&(Sr=!1)}return re.delete(q),re.delete(Q),Sr}function Ts(q){return _o(q,Su,Ca)}function Nn(q,Q){var ht=q.__data__;return Oa(Q)?ht[typeof Q=="string"?"string":"hash"]:ht.map}function Wr(q,Q){var ht=Bt(q,Q);return wu(ht)?ht:void 0}function Ma(q){var Q=Lt.call(q,Ve),ht=q[Ve];try{q[Ve]=void 0;var St=!0}catch{}var Be=Nt.call(q);return St&&(Q?q[Ve]=ht:delete q[Ve]),Be}var Ca=ye?function(q){return q==null?[]:(q=Object(q),Mt(ye(q),function(Q){return ce.call(q,Q)}))}:Ue,zi=os;(Gt&&zi(new Gt(new ArrayBuffer(1)))!=mt||zt&&zi(new zt)!=Y||De&&zi(De.resolve())!=V||Wt&&zi(new Wt)!=z||Kt&&zi(new Kt)!=ft)&&(zi=function(q){var Q=os(q),ht=Q==K?q.constructor:void 0,St=ht?hn(ht):"";if(St)switch(St){case Jt:return mt;case Xt:return Y;case xe:return V;case Zt:return z;case Yt:return ft}return Q});function Pa(q,Q){return Q=Q??u,!!Q&&(typeof q=="number"||lt.test(q))&&q>-1&&q%1==0&&q<Q}function Oa(q){var Q=typeof q;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?q!=="__proto__":q===null}function Na(q){return!!Ot&&Ot in q}function Ra(q){var Q=q&&q.constructor,ht=typeof Q=="function"&&Q.prototype||Ut;return q===ht}function _u(q){return Nt.call(q)}function hn(q){if(q!=null){try{return Ct.call(q)}catch{}try{return q+""}catch{}}return""}function Ta(q,Q){return q===Q||q!==q&&Q!==Q}var Fa=Eo(function(){return arguments}())?Eo:function(q){return cs(q)&&Lt.call(q,"callee")&&!ce.call(q,"callee")},Fs=Array.isArray;function Eu(q){return q!=null&&Ua(q.length)&&!Us(q)}var Ao=_e||Fe;function Au(q,Q){return as(q,Q)}function Us(q){if(!Ba(q))return!1;var Q=os(q);return Q==D||Q==P||Q==f||Q==B}function Ua(q){return typeof q=="number"&&q>-1&&q%1==0&&q<=u}function Ba(q){var Q=typeof q;return q!=null&&(Q=="object"||Q=="function")}function cs(q){return q!=null&&typeof q=="object"}var La=at?$t(at):Ia;function Su(q){return Eu(q)?Aa(q):Da(q)}function Ue(){return[]}function Fe(){return!1}r.exports=Au})(iu,iu.exports);var iD=iu.exports;const nD=Bl(iD);function sD(r,t){return t=t||{},new Promise(function(e,i){var s=new XMLHttpRequest,a=[],u=[],l={},d=function(){return{ok:(s.status/100|0)==2,statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:d,headers:{keys:function(){return a},entries:function(){return u},get:function(w){return l[w.toLowerCase()]},has:function(w){return w.toLowerCase()in l}}}};for(var f in s.open(t.method||"get",r,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(w,E,I){a.push(E=E.toLowerCase()),u.push([E,I]),l[E]=l[E]?l[E]+","+I:I}),e(d())},s.onerror=i,s.withCredentials=t.credentials=="include",t.headers)s.setRequestHeader(f,t.headers[f]);s.send(t.body||null)})}const oD=Object.freeze(Object.defineProperty({__proto__:null,default:sD},Symbol.toStringTag,{value:"Module"})),jp=S1(oD);var aD=self.fetch||(self.fetch=jp.default||jp);const cD=Bl(aD);function uD(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),i=0;i<e.length;i++)e[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),u=a.charCodeAt(0);if(e[u]!==255)throw new TypeError(a+" is ambiguous");e[u]=s}var l=r.length,d=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var Y=0,G=0,tt=0,K=P.length;tt!==K&&P[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var $=P[tt],z=0,v=V-1;($!==0||z<G)&&v!==-1;v--,z++)$+=256*B[v]>>>0,B[v]=$%l>>>0,$=$/l>>>0;if($!==0)throw new Error("Non-zero carry");G=z,tt++}for(var T=V-G;T!==V&&B[T]===0;)T++;for(var nt=d.repeat(Y);T<V;++T)nt+=r.charAt(B[T]);return nt}function I(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var Y=0;if(P[Y]!==" "){for(var G=0,tt=0;P[Y]===d;)G++,Y++;for(var K=(P.length-Y)*f+1>>>0,V=new Uint8Array(K);P[Y];){var B=e[P.charCodeAt(Y)];if(B===255)return;for(var $=0,z=K-1;(B!==0||$<tt)&&z!==-1;z--,$++)B+=l*V[z]>>>0,V[z]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=$,Y++}if(P[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(G+(K-v)),nt=G;v!==K;)T[nt++]=V[v++];return T}}}function D(P){var Y=I(P);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:I,decode:D}}var hD=uD,lD=hD;const em=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")},fD=r=>new TextEncoder().encode(r),dD=r=>new TextDecoder().decode(r);class pD{constructor(t,e,i){this.name=t,this.prefix=e,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}let gD=class{constructor(t,e,i){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return rm(this,t)}},mD=class{constructor(t){this.decoders=t}or(t){return rm(this,t)}decode(t){const e=t[0],i=this.decoders[e];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const rm=(r,t)=>new mD({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});let vD=class{constructor(t,e,i,s){this.name=t,this.prefix=e,this.baseEncode=i,this.baseDecode=s,this.encoder=new pD(t,e,i),this.decoder=new gD(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const vu=({name:r,prefix:t,encode:e,decode:i})=>new vD(r,t,e,i),_a=({prefix:r,name:t,alphabet:e})=>{const{encode:i,decode:s}=lD(e,t);return vu({prefix:r,name:t,encode:i,decode:a=>em(s(a))})},yD=(r,t,e,i)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const u=new Uint8Array(a*e/8|0);let l=0,d=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);d=d<<e|E,l+=e,l>=8&&(l-=8,u[f++]=255&d>>l)}if(l>=e||255&d<<8-l)throw new SyntaxError("Unexpected end of data");return u},wD=(r,t,e)=>{const i=t[t.length-1]==="=",s=(1<<e)-1;let a="",u=0,l=0;for(let d=0;d<r.length;++d)for(l=l<<8|r[d],u+=8;u>e;)u-=e,a+=t[s&l>>u];if(u&&(a+=t[s&l<<e-u]),i)for(;a.length*e&7;)a+="=";return a},vr=({name:r,prefix:t,bitsPerChar:e,alphabet:i})=>vu({prefix:t,name:r,encode(s){return wD(s,i,e)},decode(s){return yD(s,i,e,r)}}),bD=vu({prefix:"\0",name:"identity",encode:r=>dD(r),decode:r=>fD(r)});var _D=Object.freeze({__proto__:null,identity:bD});const ED=vr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var AD=Object.freeze({__proto__:null,base2:ED});const SD=vr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ID=Object.freeze({__proto__:null,base8:SD});const DD=_a({prefix:"9",name:"base10",alphabet:"0123456789"});var xD=Object.freeze({__proto__:null,base10:DD});const MD=vr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),CD=vr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var PD=Object.freeze({__proto__:null,base16:MD,base16upper:CD});const OD=vr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ND=vr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),RD=vr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),TD=vr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),FD=vr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),UD=vr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),BD=vr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),LD=vr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qD=vr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jD=Object.freeze({__proto__:null,base32:OD,base32upper:ND,base32pad:RD,base32padupper:TD,base32hex:FD,base32hexupper:UD,base32hexpad:BD,base32hexpadupper:LD,base32z:qD});const $D=_a({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zD=_a({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var kD=Object.freeze({__proto__:null,base36:$D,base36upper:zD});const HD=_a({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KD=_a({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var VD=Object.freeze({__proto__:null,base58btc:HD,base58flickr:KD});const GD=vr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),WD=vr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),YD=vr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),QD=vr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var JD=Object.freeze({__proto__:null,base64:GD,base64pad:WD,base64url:YD,base64urlpad:QD});const im=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),XD=im.reduce((r,t,e)=>(r[e]=t,r),[]),ZD=im.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function tx(r){return r.reduce((t,e)=>(t+=XD[e],t),"")}function ex(r){const t=[];for(const e of r){const i=ZD[e.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(i)}return new Uint8Array(t)}const rx=vu({prefix:"🚀",name:"base256emoji",encode:tx,decode:ex});var ix=Object.freeze({__proto__:null,base256emoji:rx}),nx=nm,$p=128,sx=127,ox=~sx,ax=Math.pow(2,31);function nm(r,t,e){t=t||[],e=e||0;for(var i=e;r>=ax;)t[e++]=r&255|$p,r/=128;for(;r&ox;)t[e++]=r&255|$p,r>>>=7;return t[e]=r|0,nm.bytes=e-i+1,t}var cx=Ol,ux=128,zp=127;function Ol(r,i){var e=0,i=i||0,s=0,a=i,u,l=r.length;do{if(a>=l)throw Ol.bytes=0,new RangeError("Could not decode varint");u=r[a++],e+=s<28?(u&zp)<<s:(u&zp)*Math.pow(2,s),s+=7}while(u>=ux);return Ol.bytes=a-i,e}var hx=Math.pow(2,7),lx=Math.pow(2,14),fx=Math.pow(2,21),dx=Math.pow(2,28),px=Math.pow(2,35),gx=Math.pow(2,42),mx=Math.pow(2,49),vx=Math.pow(2,56),yx=Math.pow(2,63),wx=function(r){return r<hx?1:r<lx?2:r<fx?3:r<dx?4:r<px?5:r<gx?6:r<mx?7:r<vx?8:r<yx?9:10},bx={encode:nx,decode:cx,encodingLength:wx},sm=bx;const kp=(r,t,e=0)=>(sm.encode(r,t,e),t),Hp=r=>sm.encodingLength(r),Nl=(r,t)=>{const e=t.byteLength,i=Hp(r),s=i+Hp(e),a=new Uint8Array(s+e);return kp(r,a,0),kp(e,a,i),a.set(t,s),new _x(r,e,t,a)};class _x{constructor(t,e,i,s){this.code=t,this.size=e,this.digest=i,this.bytes=s}}const om=({name:r,code:t,encode:e})=>new Ex(r,t,e);class Ex{constructor(t,e,i){this.name=t,this.code=e,this.encode=i}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Nl(this.code,e):e.then(i=>Nl(this.code,i))}else throw Error("Unknown type, must be binary type")}}const am=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),Ax=om({name:"sha2-256",code:18,encode:am("SHA-256")}),Sx=om({name:"sha2-512",code:19,encode:am("SHA-512")});var Ix=Object.freeze({__proto__:null,sha256:Ax,sha512:Sx});const cm=0,Dx="identity",um=em,xx=r=>Nl(cm,um(r)),Mx={code:cm,name:Dx,encode:um,digest:xx};var Cx=Object.freeze({__proto__:null,identity:Mx});new TextEncoder,new TextDecoder;const Kp={..._D,...AD,...ID,...xD,...PD,...jD,...kD,...VD,...JD,...ix};({...Ix,...Cx});function Px(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function hm(r,t,e,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:i}}}const Vp=hm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Zh=hm("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=Px(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ox={utf8:Vp,"utf-8":Vp,hex:Kp.base16,latin1:Zh,ascii:Zh,binary:Zh,...Kp};function Nx(r,t="utf8"){const e=Ox[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):e.decoder.decode(`${e.prefix}${r}`)}const lm="wc",Rx=2,of="core",Wn=`${lm}@2:${of}:`,Tx={name:of,logger:"error"},Fx={database:":memory:"},Ux="crypto",Gp="client_ed25519_seed",Bx=bt.ONE_DAY,Lx="keychain",qx="0.3",jx="messages",$x="0.3",zx=bt.SIX_HOURS,kx="publisher",fm="irn",Hx="error",dm="wss://relay.walletconnect.com",Wp="wss://relay.walletconnect.org",Kx="relayer",kr={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"},Vx="_subscription",_i={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Gx=bt.ONE_SECOND,Wx="2.13.0",Yx=1e4,Qx="0.3",Jx="WALLETCONNECT_CLIENT_ID",Ji={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Xx="subscription",Zx="0.3",t7=bt.FIVE_SECONDS*1e3,e7="pairing",r7="0.3",Vo={wc_pairingDelete:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:bt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:bt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:0},res:{ttl:bt.ONE_DAY,prompt:!1,tag:0}}},io={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ti={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},i7="history",n7="0.3",s7="expirer",Ei={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},o7="0.3",tl="verify-api",no="https://verify.walletconnect.com",Rl="https://verify.walletconnect.org",a7=[no,Rl],c7="echo",u7="https://echo.walletconnect.com";class h7{constructor(t,e){this.core=t,this.logger=e,this.keychain=new Map,this.name=Lx,this.version=qx,this.initialized=!1,this.storagePrefix=Wn,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}=gt("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=t,this.logger=Gr(e,this.name)}get context(){return Vr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,G1(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?W1(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class l7{constructor(t,e,i){this.core=t,this.logger=e,this.name=Ux,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=Np(s);return Wg(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=i4();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const a=await this.getClientSeed(),u=Np(a),l=xl();return await FI(l,s,Bx,u)},this.generateSharedKey=(s,a,u)=>{this.isInitialized();const l=this.getPrivateKey(s),d=n4(l,a);return this.setSymKey(d,u)},this.setSymKey=async(s,a)=>{this.isInitialized();const u=a||$c(s);return await this.keychain.set(u,s),u},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,u)=>{this.isInitialized();const l=Ug(u),d=xn(a);if(lp(l)){const I=l.senderPublicKey,D=l.receiverPublicKey;s=await this.generateSharedKey(I,D)}const f=this.getSymKey(s),{type:w,senderPublicKey:E}=l;return o4({type:w,symKey:f,message:d,senderPublicKey:E})},this.decode=async(s,a,u)=>{this.isInitialized();const l=u4(a,u);if(lp(l)){const d=l.receiverPublicKey,f=l.senderPublicKey;s=await this.generateSharedKey(d,f)}try{const d=this.getSymKey(s),f=a4({symKey:d,encoded:a});return va(f)}catch(d){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(d)}},this.getPayloadType=s=>{const a=Xc(s);return ga(a.type)},this.getPayloadSenderPublicKey=s=>{const a=Xc(s);return a.senderPublicKey?Rr(a.senderPublicKey,Nr):void 0},this.core=t,this.logger=Gr(e,this.name),this.keychain=i||new h7(this.core,this.logger)}get context(){return Vr(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(Gp)}catch{t=xl(),await this.keychain.set(Gp,t)}return Nx(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class f7 extends fI{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name=jx,this.version=$x,this.initialized=!1,this.storagePrefix=Wn,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=As(s);let u=this.messages.get(i);return typeof u>"u"&&(u={}),typeof u[a]<"u"||(u[a]=s,this.messages.set(i,u),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),u=As(s);return typeof a[u]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Gr(t,this.name),this.core=e}get context(){return Vr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,G1(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?W1(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class d7 extends dI{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new Di.EventEmitter,this.name=kx,this.queue=new Map,this.publishTimeout=bt.toMiliseconds(bt.ONE_MINUTE),this.failedPublishTimeout=bt.toMiliseconds(bt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,s,a)=>{var u;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:a}});const l=(a==null?void 0:a.ttl)||zx,d=Ml(a),f=(a==null?void 0:a.prompt)||!1,w=(a==null?void 0:a.tag)||0,E=(a==null?void 0:a.id)||Ss().toString(),I={topic:i,message:s,opts:{ttl:l,relay:d,prompt:f,tag:w,id:E}},D=`Failed to publish payload, please try again. id:${E} tag:${w}`,P=Date.now();let Y,G=1;try{for(;Y===void 0;){if(Date.now()-P>this.publishTimeout)throw new Error(D);this.logger.trace({id:E,attempts:G},`publisher.publish - attempt ${G}`),Y=await await so(this.rpcPublish(i,s,l,d,f,w,E).catch(tt=>this.logger.warn(tt)),this.publishTimeout,D),G++,Y||await new Promise(tt=>setTimeout(tt,this.failedPublishTimeout))}this.relayer.events.emit(kr.publish,I),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:E,topic:i,message:s,opts:a}})}catch(tt){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(tt),(u=a==null?void 0:a.internal)!=null&&u.throwOnFailedPublish)throw tt;this.queue.set(E,I)}},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=t,this.logger=Gr(e,this.name),this.registerEventListeners()}get context(){return Vr(this.logger)}rpcPublish(t,e,i,s,a,u,l){var d,f,w,E;const I={method:Qo(s.protocol).publish,params:{topic:t,message:e,ttl:i,prompt:a,tag:u},id:l};return Or((d=I.params)==null?void 0:d.prompt)&&((f=I.params)==null||delete f.prompt),Or((w=I.params)==null?void 0:w.tag)&&((E=I.params)==null||delete E.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:e,message:i,opts:s}=t;await this.publish(e,i,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(ya.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(kr.connection_stalled);return}this.checkQueue()}),this.relayer.on(kr.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class p7{constructor(){this.map=new Map,this.set=(t,e)=>{const i=this.get(t);this.exists(t,e)||this.map.set(t,[...i,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const i=this.get(t);if(!this.exists(t,e))return;const s=i.filter(a=>a!==e);if(!s.length){this.map.delete(t);return}this.map.set(t,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var g7=Object.defineProperty,m7=Object.defineProperties,v7=Object.getOwnPropertyDescriptors,Yp=Object.getOwnPropertySymbols,y7=Object.prototype.hasOwnProperty,w7=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?g7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Go=(r,t)=>{for(var e in t||(t={}))y7.call(t,e)&&Qp(r,e,t[e]);if(Yp)for(var e of Yp(t))w7.call(t,e)&&Qp(r,e,t[e]);return r},el=(r,t)=>m7(r,v7(t));class b7 extends mI{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new p7,this.events=new Di.EventEmitter,this.name=Xx,this.version=Zx,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Wn,this.subscribeTimeout=bt.toMiliseconds(bt.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const a=Ml(s),u={topic:i,relay:a};this.pending.set(i,u);const l=await this.rpcSubscribe(i,a);return typeof l=="string"&&(this.onSubscribe(l,u),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),l}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,u)=>{const l=new bt.Watch;l.start(s);const d=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(d),l.stop(s),a(!0)),l.elapsed(s)>=t7&&(clearInterval(d),l.stop(s),u(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=t,this.logger=Gr(e,this.name),this.clientId=""}get context(){return Vr(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(t,e){let i=!1;try{i=this.getSubscription(t).topic===e}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const i=this.topicMap.get(t);await Promise.all(i.map(async s=>await this.unsubscribeById(t,s,e)))}async unsubscribeById(t,e,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:i}});try{const s=Ml(i);await this.rpcUnsubscribe(t,e,s);const a=Re("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(t,e){const i={method:Qo(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await so(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)?As(t+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(kr.connection_stalled)}return null}async rpcBatchSubscribe(t){if(!t.length)return;const e=t[0].relay,i={method:Qo(e.protocol).batchSubscribe,params:{topics:t.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await so(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(kr.connection_stalled)}}async rpcBatchFetchMessages(t){if(!t.length)return;const e=t[0].relay,i={method:Qo(e.protocol).batchFetchMessages,params:{topics:t.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 so(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(kr.connection_stalled)}return s}rpcUnsubscribe(t,e,i){const s={method:Qo(i.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(t,e){this.setSubscription(t,el(Go({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach(e=>{this.setSubscription(e.id,Go({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(t,e,i){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,i),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,Go({},e)),this.topicMap.set(e.topic,t),this.events.emit(Ji.created,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(i)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const i=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(i.topic,t),this.events.emit(Ji.deleted,el(Go({},i),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ji.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e<t;e++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(Ji.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);cn(e)&&this.onBatchSubscribe(e.map((i,s)=>el(Go({},t[s]),{id:i})))}async batchFetchMessages(t){if(!t.length)return;this.logger.trace(`Fetching batch messages for ${t.length} subscriptions`);const e=await this.rpcBatchFetchMessages(t);e&&e.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(e.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const t=[];this.pending.forEach(e=>{t.push(e)}),await this.batchSubscribe(t),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(ya.pulse,async()=>{await this.checkPending()}),this.events.on(Ji.created,async t=>{const e=Ji.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}),this.events.on(Ji.deleted,async t=>{const e=Ji.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.restartInProgress||(clearInterval(e),t())},this.pollingInterval)})}}var _7=Object.defineProperty,Jp=Object.getOwnPropertySymbols,E7=Object.prototype.hasOwnProperty,A7=Object.prototype.propertyIsEnumerable,Xp=(r,t,e)=>t in r?_7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,S7=(r,t)=>{for(var e in t||(t={}))E7.call(t,e)&&Xp(r,e,t[e]);if(Jp)for(var e of Jp(t))A7.call(t,e)&&Xp(r,e,t[e]);return r};class I7 extends pI{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Di.EventEmitter,this.name=Kx,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=bt.toMiliseconds(bt.THIRTY_SECONDS+bt.ONE_SECOND),this.request=async e=>{var i,s;this.logger.debug("Publishing Request Payload");const a=e.id||Ss().toString();await this.toEstablishConnection();try{const u=this.provider.request(e);this.requestsInFlight.set(a,{promise:u,request:e}),this.logger.trace({id:a,method:e.method,topic:(i=e.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const l=await new Promise(async(d,f)=>{const w=()=>{f(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(_i.disconnect,w);const E=await u;this.provider.off(_i.disconnect,w),d(E)});return this.logger.trace({id:a,method:e.method,topic:(s=e.params)==null?void 0:s.topic},"relayer.request - published"),l}catch(u){throw this.logger.debug(`Failed to Publish Request: ${a}`),u}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(ia())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,i,s;(s=(i=(e=this.provider)==null?void 0:e.connection)==null?void 0:i.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e)}},this.onPayloadHandler=e=>{this.onProviderPayload(e),this.resetPingTimeout()},this.onConnectHandler=()=>{this.startPingTimeout(),this.events.emit(kr.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit(kr.error,e),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(_i.payload,this.onPayloadHandler),this.provider.on(_i.connect,this.onConnectHandler),this.provider.on(_i.disconnect,this.onDisconnectHandler),this.provider.on(_i.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Gr(t.logger,this.name):wa(du({level:t.logger||Hx})),this.messages=new f7(this.logger,t.core),this.subscriber=new b7(this,this.logger),this.publisher=new d7(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||dm,this.projectId=t.projectId,this.bundleId=WE(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Wp}...`),await this.restartTransport(Wp)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&this.subscriber.pending.size===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},Yx)}get context(){return Vr(this.logger)}get connected(){var t,e,i;return((i=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:i.readyState)===1}get connecting(){var t,e,i;return((i=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:i.readyState)===0}async publish(t,e,i){this.isInitialized(),await this.publisher.publish(t,e,i),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(t))==null?void 0:i[0])||"",a;const u=l=>{l.topic===t&&(this.subscriber.off(Ji.created,u),a())};return await Promise.all([new Promise(l=>{a=l,this.subscriber.on(Ji.created,u)}),new Promise(async l=>{s=await this.subscriber.subscribe(t,e)||s,l()})]),s}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await so(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(e,i)=>{const s=()=>{this.provider.off(_i.disconnect,s),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(_i.disconnect,s),await so(this.provider.connect(),bt.toMiliseconds(bt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}),await this.subscriber.start(),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){this.logger.error(e);const i=e;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw e}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await _p())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(t){if((t==null?void 0:t.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const e=t.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.trace(`Batch of ${e.length} message events sorted`);for(const i of e)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s)}this.logger.trace(`Batch of ${e.length} message events processed`)}startPingTimeout(){var t,e,i,s,a;if(ia())try{(e=(t=this.provider)==null?void 0:t.connection)!=null&&e.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(u){this.logger.warn(u)}}isConnectionStalled(t){return this.staleConnectionErrors.some(e=>t.includes(e))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Mn(new rD(t5({sdkVersion:Wx,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:i}=t;await this.messages.set(e,i)}async shouldIgnoreMessageEvent(t){const{topic:e,message:i}=t;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const s=this.messages.has(e,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),sf(t)){if(!t.method.endsWith(Vx))return;const e=t.params,{topic:i,message:s,publishedAt:a}=e.data,u={topic:i,message:s,publishedAt:a};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(S7({type:"event",event:e.id},u)),this.events.emit(e.id,u),await this.acknowledgePayload(t),await this.onMessageEvent(u)}else mu(t)&&this.events.emit(kr.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(kr.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=pu(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(_i.payload,this.onPayloadHandler),this.provider.off(_i.connect,this.onConnectHandler),this.provider.off(_i.disconnect,this.onDisconnectHandler),this.provider.off(_i.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let t=await _p();Z4(async e=>{t!==e&&(t=e,e?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(kr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&setTimeout(async()=>{await this.transportOpen().catch(t=>this.logger.error(t))},bt.toMiliseconds(Gx))}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.connected&&(clearInterval(e),t())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var D7=Object.defineProperty,Zp=Object.getOwnPropertySymbols,x7=Object.prototype.hasOwnProperty,M7=Object.prototype.propertyIsEnumerable,t1=(r,t,e)=>t in r?D7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e1=(r,t)=>{for(var e in t||(t={}))x7.call(t,e)&&t1(r,e,t[e]);if(Zp)for(var e of Zp(t))M7.call(t,e)&&t1(r,e,t[e]);return r};class Os extends gI{constructor(t,e,i,s=Wn,a=void 0){super(t,e,i,s),this.core=t,this.logger=e,this.name=i,this.map=new Map,this.version=Qx,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(u=>{this.getKey&&u!==null&&!Or(u)?this.map.set(this.getKey(u),u):P4(u)?this.map.set(u.id,u):O4(u)&&this.map.set(u.topic,u)}),this.cached=[],this.initialized=!0)},this.set=async(u,l)=>{this.isInitialized(),this.map.has(u)?await this.update(u,l):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:u,value:l}),this.map.set(u,l),await this.persist())},this.get=u=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:u}),this.getData(u)),this.getAll=u=>(this.isInitialized(),u?this.values.filter(l=>Object.keys(u).every(d=>nD(l[d],u[d]))):this.values),this.update=async(u,l)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:u,update:l});const d=e1(e1({},this.getData(u)),l);this.map.set(u,d),await this.persist()},this.delete=async(u,l)=>{this.isInitialized(),this.map.has(u)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:u,reason:l}),this.map.delete(u),this.addToRecentlyDeleted(u),await this.persist())},this.logger=Gr(e,this.name),this.storagePrefix=s,this.getKey=a}get context(){return Vr(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(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){const{message:s}=gt("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(i),new Error(i)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class C7{constructor(t,e){this.core=t,this.logger=e,this.name=e7,this.version=r7,this.events=new Ll,this.initialized=!1,this.storagePrefix=Wn,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=xl(),a=await this.core.crypto.setSymKey(s),u=pr(bt.FIVE_MINUTES),l={protocol:fm},d={topic:a,expiry:u,relay:l,active:!1},f=b4({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:l,expiryTimestamp:u,methods:i==null?void 0:i.methods});return this.core.expirer.set(a,u),await this.pairings.set(a,d),await this.core.relayer.subscribe(a),{topic:a,uri:f}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:a,relay:u,expiryTimestamp:l,methods:d}=gp(i.uri);let f;if(this.pairings.keys.includes(s)&&(f=this.pairings.get(s),f.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const w=l||pr(bt.FIVE_MINUTES),E={topic:s,relay:u,expiry:w,active:!1,methods:d};return this.core.expirer.set(s,w),await this.pairings.set(s,E),i.activatePairing&&await this.activate({topic:s}),this.events.emit(io.create,E),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(a,s),await this.core.relayer.subscribe(s,{relay:u}),E},this.activate=async({topic:i})=>{this.isInitialized();const s=pr(bt.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:u,resolve:l,reject:d}=_s();this.events.once(de("pairing_ping",a),({error:f})=>{f?d(f):l()}),await u()}},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",Re("USER_DISCONNECTED")),await this.deletePairing(s))},this.sendRequest=async(i,s,a)=>{const u=co(s,a),l=await this.core.crypto.encode(i,u),d=Vo[s].req;return this.core.history.set(i,u),this.core.relayer.publish(i,l,d),u.id},this.sendResult=async(i,s,a)=>{const u=pu(i,a),l=await this.core.crypto.encode(s,u),d=await this.core.history.get(s,i),f=Vo[d.request.method].res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(u)},this.sendError=async(i,s,a)=>{const u=gu(i,a),l=await this.core.crypto.encode(s,u),d=await this.core.history.get(s,i),f=Vo[d.request.method]?Vo[d.request.method].res:Vo.unregistered_method.res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(u)},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Re("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=>kn(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,u=(await this.core.history.get(s,a.id)).request.method;switch(u){case"wc_pairingPing":return this.onPairingPingResponse(s,a);default:return this.onUnknownRpcMethodResponse(u)}},this.onPairingPingRequest=async(i,s)=>{const{id:a}=s;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(io.ping,{id:a,topic:i})}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onPairingPingResponse=(i,s)=>{const{id:a}=s;setTimeout(()=>{Qi(s)?this.events.emit(de("pairing_ping",a),{}):Si(s)&&this.events.emit(de("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(io.delete,{id:a,topic:i})}catch(u){await this.sendError(a,i,u),this.logger.error(u)}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:a,method:u}=s;try{if(this.registeredMethods.includes(u))return;const l=Re("WC_METHOD_UNSUPPORTED",u);await this.sendError(a,i,l),this.logger.error(l)}catch(l){await this.sendError(a,i,l),this.logger.error(l)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Re("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=i=>{var s;if(!zr(i)){const{message:u}=gt("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(u)}if(!C4(i.uri)){const{message:u}=gt("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(u)}const a=gp(i.uri);if(!((s=a==null?void 0:a.relay)!=null&&s.protocol)){const{message:u}=gt("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(u)}if(!(a!=null&&a.symKey)){const{message:u}=gt("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(u)}if(a!=null&&a.expiryTimestamp&&bt.toMiliseconds(a==null?void 0:a.expiryTimestamp)<Date.now()){const{message:u}=gt("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(u)}},this.isValidPing=async i=>{if(!zr(i)){const{message:a}=gt("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidDisconnect=async i=>{if(!zr(i)){const{message:a}=gt("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:s}=i;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async i=>{if(!tr(i,!1)){const{message:s}=gt("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=gt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(kn(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=gt("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=t,this.logger=Gr(e,this.name),this.pairings=new Os(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Vr(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(kr.message,async t=>{const{topic:e,message:i}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(e,i);try{sf(s)?(this.core.history.set(e,s),this.onRelayEventRequest({topic:e,payload:s})):mu(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:e,payload:s}),this.core.history.delete(e,s.id))}catch(a){this.logger.error(a)}})}registerExpirerEvents(){this.core.expirer.on(Ei.expired,async t=>{const{topic:e}=Q1(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit(io.expire,{topic:e}))})}}class P7 extends lI{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new Di.EventEmitter,this.name=i7,this.version=n7,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,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 u={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:a,expiry:pr(bt.THIRTY_DAYS)};this.records.set(u.id,u),this.persist(),this.events.emit(Ti.created,u)},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=Si(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(Ti.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(Ti.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=Gr(e,this.name)}get context(){return Vr(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 t=[];return this.values.forEach(e=>{if(typeof e.response<"u")return;const i={topic:e.topic,request:co(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(i)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(i)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ti.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Ti.created,t=>{const e=Ti.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.updated,t=>{const e=Ti.updated;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.deleted,t=>{const e=Ti.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.core.heartbeat.on(ya.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(e=>{bt.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(Ti.deleted,e,!1),t=!0)}),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class O7 extends vI{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new Di.EventEmitter,this.name=s7,this.version=o7,this.cached=[],this.initialized=!1,this.storagePrefix=Wn,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),u={target:a,expiry:s};this.expirations.set(a,u),this.checkExpiry(a,u),this.events.emit(Ei.created,{target:a,expiration:u})},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(Ei.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=Gr(e,this.name)}get context(){return Vr(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(t){if(typeof t=="string")return e5(t);if(typeof t=="number")return r5(t);const{message:e}=gt("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ei.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:e}=gt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:i}=gt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(i),new Error(i)}return e}checkExpiry(t,e){const{expiry:i}=e;bt.toMiliseconds(i)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Ei.expired,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,e)=>this.checkExpiry(e,t))}registerEventListeners(){this.core.heartbeat.on(ya.pulse,()=>this.checkExpirations()),this.events.on(Ei.created,t=>{const e=Ei.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.expired,t=>{const e=Ei.expired;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.deleted,t=>{const e=Ei.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class N7 extends yI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=tl,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||po()||!go())return;const s=this.getVerifyUrl(i==null?void 0:i.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Rl;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a),this.verifyDisabled=!0}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init())},this.resolve=async i=>{if(this.isDevEnv)return"";const s=this.getVerifyUrl(i==null?void 0:i.verifyUrl);let a;try{a=await this.fetchAttestation(i.attestationId,s)}catch(u){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(u),a=await this.fetchAttestation(i.attestationId,Rl)}return a},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const a=this.startAbortTimer(bt.ONE_SECOND*2),u=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(a),u.status===200?await u.json():void 0},this.addToQueue=i=>{this.queue.push(i)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[])},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let i;const s=a=>{a.data==="verify_ready"&&(this.onInit(),window.removeEventListener("message",s),i())};await Promise.race([new Promise(a=>{const u=document.getElementById(tl);if(u)return this.iframe=u,this.onInit(),a();window.addEventListener("message",s);const l=document.createElement("iframe");l.id=tl,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,i=a}),new Promise((a,u)=>setTimeout(()=>{window.removeEventListener("message",s),u("verify iframe load timeout")},bt.toMiliseconds(bt.FIVE_SECONDS)))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=i=>{let s=i||no;return a7.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${no}`),s=no),s},this.logger=Gr(e,this.name),this.verifyUrl=no,this.abortController=new AbortController,this.isDevEnv=ia()&&{}.IS_VITEST}get context(){return Vr(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),bt.toMiliseconds(t))}}let R7=class extends wI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context=c7,this.registerDeviceToken=async i=>{const{clientId:s,token:a,notificationType:u,enableEncrypted:l=!1}=i,d=`${u7}/${this.projectId}/clients`;await cD(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:u,token:a,always_raw:l})})},this.logger=Gr(e,this.context)}};var T7=Object.defineProperty,r1=Object.getOwnPropertySymbols,F7=Object.prototype.hasOwnProperty,U7=Object.prototype.propertyIsEnumerable,i1=(r,t,e)=>t in r?T7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,n1=(r,t)=>{for(var e in t||(t={}))F7.call(t,e)&&i1(r,e,t[e]);if(r1)for(var e of r1(t))U7.call(t,e)&&i1(r,e,t[e]);return r};let B7=class pm extends hI{constructor(t){var e;super(t),this.protocol=lm,this.version=Rx,this.name=of,this.events=new Di.EventEmitter,this.initialized=!1,this.on=(u,l)=>this.events.on(u,l),this.once=(u,l)=>this.events.once(u,l),this.off=(u,l)=>this.events.off(u,l),this.removeListener=(u,l)=>this.events.removeListener(u,l),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||dm,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const i=du({level:typeof(t==null?void 0:t.logger)=="string"&&t.logger?t.logger:Tx.logger}),{logger:s,chunkLoggerController:a}=uI({opts:i,maxSizeInBytes:t==null?void 0:t.maxLogBlobSizeInBytes,loggerOverride:t==null?void 0:t.logger});this.logChunkController=a,(e=this.logChunkController)!=null&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var u,l;(u=this.logChunkController)!=null&&u.downloadLogsBlobInBrowser&&((l=this.logChunkController)==null||l.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Gr(s,this.name),this.heartbeat=new FS,this.crypto=new l7(this,this.logger,t==null?void 0:t.keychain),this.history=new P7(this,this.logger),this.expirer=new O7(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new RS(n1(n1({},Fx),t==null?void 0:t.storageOptions)),this.relayer=new I7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new C7(this,this.logger),this.verify=new N7(this.projectId||"",this.logger),this.echoClient=new R7(this.projectId||"",this.logger)}static async init(t){const e=new pm(t);await e.initialize();const i=await e.crypto.getClientId();return await e.storage.setItem(Jx,i),e}get context(){return Vr(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return(t=this.logChunkController)==null?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}};const L7=B7,gm="wc",mm=2,vm="client",af=`${gm}@${mm}:${vm}:`,rl={name:vm,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},s1="WALLETCONNECT_DEEPLINK_CHOICE",q7="proposal",ym="Proposal expired",j7="session",Zs=bt.SEVEN_DAYS,$7="engine",ti={wc_sessionPropose:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:bt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:bt.ONE_HOUR,prompt:!1,tag:1117}}},il={min:bt.FIVE_MINUTES,max:bt.SEVEN_DAYS},An={idle:"IDLE",active:"ACTIVE"},z7="request",k7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"],H7="wc",K7="auth",V7="authKeys",G7="pairingTopics",W7="requests",yu=`${H7}@${1.5}:${K7}:`,Hc=`${yu}:PUB_KEY`;var Y7=Object.defineProperty,Q7=Object.defineProperties,J7=Object.getOwnPropertyDescriptors,o1=Object.getOwnPropertySymbols,X7=Object.prototype.hasOwnProperty,Z7=Object.prototype.propertyIsEnumerable,a1=(r,t,e)=>t in r?Y7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sr=(r,t)=>{for(var e in t||(t={}))X7.call(t,e)&&a1(r,e,t[e]);if(o1)for(var e of o1(t))Z7.call(t,e)&&a1(r,e,t[e]);return r},bs=(r,t)=>Q7(r,J7(t));class t9 extends _I{constructor(t){super(t),this.name=$7,this.events=new Ll,this.initialized=!1,this.requestQueue={state:An.idle,queue:[]},this.sessionRequestQueue={state:An.idle,queue:[]},this.requestQueueDelay=bt.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(ti)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},bt.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const i=bs(sr({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:l,relays:d}=i;let f=s,w,E=!1;try{f&&(E=this.client.core.pairing.pairings.get(f).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${f}) failed`),B}if(!f||!E){const{topic:B,uri:$}=await this.client.core.pairing.create();f=B,w=$}if(!f){const{message:B}=gt("NO_MATCHING_KEY",`connect() pairing topic: ${f}`);throw new Error(B)}const I=await this.client.core.crypto.generateKeyPair(),D=ti.wc_sessionPropose.req.ttl||bt.FIVE_MINUTES,P=pr(D),Y=sr({requiredNamespaces:a,optionalNamespaces:u,relays:d??[{protocol:fm}],proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:P},l&&{sessionProperties:l}),{reject:G,resolve:tt,done:K}=_s(D,ym);this.events.once(de("session_connect"),async({error:B,session:$})=>{if(B)G(B);else if($){$.self.publicKey=I;const z=bs(sr({},$),{requiredNamespaces:Y.requiredNamespaces,optionalNamespaces:Y.optionalNamespaces});await this.client.session.set($.topic,z),await this.setExpiry($.topic,$.expiry),f&&await this.client.core.pairing.updateMetadata({topic:f,metadata:$.peer.metadata}),tt(z)}});const V=await this.sendRequest({topic:f,method:"wc_sessionPropose",params:Y,throwOnFailedPublish:!0});return await this.setProposal(V,sr({id:V},Y)),{uri:w,approval:K}},this.pair=async e=>{await this.isInitialized();try{return await this.client.core.pairing.pair(e)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async e=>{await this.isInitialized();try{await this.isValidApprove(e)}catch(K){throw this.client.logger.error("approve() -> isValidApprove() failed"),K}const{id:i,relayProtocol:s,namespaces:a,sessionProperties:u,sessionConfig:l}=e;let d;try{d=this.client.proposal.get(i)}catch(K){throw this.client.logger.error(`approve() -> proposal.get(${i}) failed`),K}let{pairingTopic:f,proposer:w,requiredNamespaces:E,optionalNamespaces:I}=d;f=f||"";const D=await this.client.core.crypto.generateKeyPair(),P=w.publicKey,Y=await this.client.core.crypto.generateSharedKey(D,P),G=sr(sr({relay:{protocol:s??"irn"},namespaces:a,pairingTopic:f,controller:{publicKey:D,metadata:this.client.metadata},expiry:pr(Zs)},u&&{sessionProperties:u}),l&&{sessionConfig:l});await this.client.core.relayer.subscribe(Y);const tt=bs(sr({},G),{topic:Y,requiredNamespaces:E,optionalNamespaces:I,pairingTopic:f,acknowledged:!1,self:G.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:D});await this.client.session.set(Y,tt);try{await this.sendResult({id:i,topic:f,result:{relay:{protocol:s??"irn"},responderPublicKey:D},throwOnFailedPublish:!0}),await this.sendRequest({topic:Y,method:"wc_sessionSettle",params:G,throwOnFailedPublish:!0})}catch(K){throw this.client.logger.error(K),this.client.session.delete(Y,Re("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(Y),K}return await this.client.core.pairing.updateMetadata({topic:f,metadata:w.metadata}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(Y,pr(Zs)),{topic:Y,acknowledged:()=>new Promise(K=>setTimeout(()=>K(this.client.session.get(Y)),500))}},this.reject=async e=>{await this.isInitialized();try{await this.isValidReject(e)}catch(u){throw this.client.logger.error("reject() -> isValidReject() failed"),u}const{id:i,reason:s}=e;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(u){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),u}a&&(await this.sendError({id:i,topic:a,error:s}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized();try{await this.isValidUpdate(e)}catch(E){throw this.client.logger.error("update() -> isValidUpdate() failed"),E}const{topic:i,namespaces:s}=e,{done:a,resolve:u,reject:l}=_s(),d=Hn(),f=Ss().toString(),w=this.client.session.get(i).namespaces;return this.events.once(de("session_update",d),({error:E})=>{E?l(E):u()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:d,relayRpcId:f}).catch(E=>{this.client.logger.error(E),this.client.session.update(i,{namespaces:w}),l(E)}),{acknowledged:a}},this.extend=async e=>{await this.isInitialized();try{await this.isValidExtend(e)}catch(d){throw this.client.logger.error("extend() -> isValidExtend() failed"),d}const{topic:i}=e,s=Hn(),{done:a,resolve:u,reject:l}=_s();return this.events.once(de("session_extend",s),({error:d})=>{d?l(d):u()}),await this.setExpiry(i,pr(Zs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(d=>{l(d)}),{acknowledged:a}},this.request=async e=>{await this.isInitialized();try{await this.isValidRequest(e)}catch(D){throw this.client.logger.error("request() -> isValidRequest() failed"),D}const{chainId:i,request:s,topic:a,expiry:u=ti.wc_sessionRequest.req.ttl}=e,l=this.client.session.get(a),d=Hn(),f=Ss().toString(),{done:w,resolve:E,reject:I}=_s(u,"Request expired. Please try again.");return this.events.once(de("session_request",d),({error:D,result:P})=>{D?I(D):E(P)}),await Promise.all([new Promise(async D=>{await this.sendRequest({clientRpcId:d,relayRpcId:f,topic:a,method:"wc_sessionRequest",params:{request:bs(sr({},s),{expiryTimestamp:pr(u)}),chainId:i},expiry:u,throwOnFailedPublish:!0}).catch(P=>I(P)),this.client.events.emit("session_request_sent",{topic:a,request:s,chainId:i,id:d}),D()}),new Promise(async D=>{var P;if(!((P=l.sessionConfig)!=null&&P.disableDeepLink)){const Y=await n5(this.client.core.storage,s1);i5({id:d,topic:a,wcDeepLink:Y})}D()}),w()]).then(D=>D[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:i,response:s}=e,{id:a}=s;Qi(s)?await this.sendResult({id:a,topic:i,result:s.result,throwOnFailedPublish:!0}):Si(s)&&await this.sendError({id:a,topic:i,error:s.error}),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized();try{await this.isValidPing(e)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=e;if(this.client.session.keys.includes(i)){const s=Hn(),a=Ss().toString(),{done:u,resolve:l,reject:d}=_s();this.events.once(de("session_ping",s),({error:f})=>{f?d(f):l()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:a}),u()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:i,event:s,chainId:a}=e,u=Ss().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:a},throwOnFailedPublish:!0,relayRpcId:u})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:i}=e;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Re("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}=gt("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(i=>x4(i,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async e=>{this.isInitialized(),this.isValidAuthenticate(e);const{chains:i,statement:s="",uri:a,domain:u,nonce:l,type:d,exp:f,nbf:w,methods:E=[],expiry:I}=e,D=[...e.resources||[]],{topic:P,uri:Y}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"]});this.client.logger.info({message:"Generated new pairing",pairing:{topic:P,uri:Y}});const G=await this.client.core.crypto.generateKeyPair(),tt=$c(G);if(await Promise.all([this.client.auth.authKeys.set(Hc,{responseTopic:tt,publicKey:G}),this.client.auth.pairingTopics.set(tt,{topic:tt,pairingTopic:P})]),await this.client.core.relayer.subscribe(tt),this.client.logger.info(`sending request to new pairing topic: ${P}`),E.length>0){const{namespace:h}=Fc(i[0]);let y=JA(h,"request",E);jc(D)&&(y=ZA(y,D.pop())),D.push(y)}const K=I&&I>ti.wc_sessionAuthenticate.req.ttl?I:ti.wc_sessionAuthenticate.req.ttl,V={authPayload:{type:d??"caip122",chains:i,statement:s,aud:a,domain:u,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:w,resources:D},requester:{publicKey:G,metadata:this.client.metadata},expiryTimestamp:pr(K)},B={eip155:{chains:i,methods:[...new Set(["personal_sign",...E])],events:["chainChanged","accountsChanged"]}},$={requiredNamespaces:{},optionalNamespaces:B,relays:[{protocol:"irn"}],proposer:{publicKey:G,metadata:this.client.metadata},expiryTimestamp:pr(ti.wc_sessionPropose.req.ttl)},{done:z,resolve:v,reject:T}=_s(K,"Request expired"),nt=async({error:h,session:y})=>{if(this.events.off(de("session_request",pt),ft),h)T(h);else if(y){y.self.publicKey=G,await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),P&&await this.client.core.pairing.updateMetadata({topic:P,metadata:y.peer.metadata});const b=this.client.session.get(y.topic);await this.deleteProposal(mt),v({session:b})}},ft=async h=>{if(await this.deletePendingAuthRequest(pt,{message:"fulfilled",code:0}),h.error){const S=Re("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return h.error.code===S.code?void 0:(this.events.off(de("session_connect"),nt),T(h.error.message))}await this.deleteProposal(mt),this.events.off(de("session_connect"),nt);const{cacaos:y,responder:b}=h.result,M=[],C=[];for(const S of y){await ap({cacao:S,projectId:this.client.core.projectId})||(this.client.logger.error(S,"Signature verification failed"),T(Re("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:g}=S,N=jc(g.resources),it=[op(g.iss)],lt=Jc(g.iss);if(N){const _=cp(N),Z=up(N);M.push(..._),it.push(...Z)}for(const _ of it)C.push(`${_}:${lt}`)}const R=await this.client.core.crypto.generateSharedKey(G,b.publicKey);let j;M.length>0&&(j={topic:R,acknowledged:!0,self:{publicKey:G,metadata:this.client.metadata},peer:b,controller:b.publicKey,expiry:pr(Zs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:P,namespaces:mp([...new Set(M)],[...new Set(C)])},await this.client.core.relayer.subscribe(R),await this.client.session.set(R,j),j=this.client.session.get(R)),v({auths:y,session:j})},pt=Hn(),mt=Hn();this.events.once(de("session_connect"),nt),this.events.once(de("session_request",pt),ft);try{await Promise.all([this.sendRequest({topic:P,method:"wc_sessionAuthenticate",params:V,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:pt}),this.sendRequest({topic:P,method:"wc_sessionPropose",params:$,expiry:ti.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:mt})])}catch(h){throw this.events.off(de("session_connect"),nt),this.events.off(de("session_request",pt),ft),h}return await this.setProposal(mt,sr({id:mt},$)),await this.setAuthRequest(pt,{request:bs(sr({},V),{verifyContext:{}}),pairingTopic:P}),{uri:Y,response:z}},this.approveSessionAuthenticate=async e=>{this.isInitialized();const{id:i,auths:s}=e,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);const u=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=$c(u),f={type:Gn,receiverPublicKey:u,senderPublicKey:l},w=[],E=[];for(const P of s){if(!await ap({cacao:P,projectId:this.client.core.projectId})){const V=Re("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:d,error:V,encodeOpts:f}),new Error(V.message)}const{p:Y}=P,G=jc(Y.resources),tt=[op(Y.iss)],K=Jc(Y.iss);if(G){const V=cp(G),B=up(G);w.push(...V),tt.push(...B)}for(const V of tt)E.push(`${V}:${K}`)}const I=await this.client.core.crypto.generateSharedKey(l,u);let D;return(w==null?void 0:w.length)>0&&(D={topic:I,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:u,metadata:a.requester.metadata},controller:u,expiry:pr(Zs),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:"",namespaces:mp([...new Set(w)],[...new Set(E)])},await this.client.core.relayer.subscribe(I),await this.client.session.set(I,D)),await this.sendResult({topic:d,id:i,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:f,throwOnFailedPublish:!0}),await this.client.auth.requests.delete(i,{message:"fullfilled",code:0}),await this.client.core.pairing.activate({topic:a.pairingTopic}),{session:D}},this.rejectSessionAuthenticate=async e=>{await this.isInitialized();const{id:i,reason:s}=e,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);const u=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=$c(u),f={type:Gn,receiverPublicKey:u,senderPublicKey:l};await this.sendError({id:i,topic:d,error:s,encodeOpts:f}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Re("USER_DISCONNECTED"))},this.formatAuthMessage=e=>{this.isInitialized();const{request:i,iss:s}=e;return Ng(i,s)},this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const i=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(a=>{var u,l;return((u=a.peerMetadata)==null?void 0:u.url)&&((l=a.peerMetadata)==null?void 0:l.url)===e.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 e=>{const{topic:i,expirerHasDeleted:s=!1,emitEvent:a=!0,id:u=0}=e,{self:l}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,Re("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem(s1).catch(d=>this.client.logger.warn(d)),this.getPendingSessionRequests().forEach(d=>{d.topic===i&&this.deletePendingSessionRequest(d.id,Re("USER_DISCONNECTED"))}),a&&this.client.events.emit("session_delete",{id:u,topic:i})},this.deleteProposal=async(e,i)=>{await Promise.all([this.client.proposal.delete(e,Re("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")},this.deletePendingSessionRequest=async(e,i,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,i),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==e),s&&(this.sessionRequestQueue.state=An.idle,this.client.events.emit("session_request_expire",{id:e}))},this.deletePendingAuthRequest=async(e,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,i),s?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,i)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,i),await this.client.session.update(e,{expiry:i}))},this.setProposal=async(e,i)=>{this.client.core.expirer.set(e,pr(ti.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,i)},this.setAuthRequest=async(e,i)=>{const{request:s,pairingTopic:a}=i;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:a,verifyContext:s.verifyContext})},this.setPendingSessionRequest=async e=>{const{id:i,topic:s,params:a,verifyContext:u}=e,l=a.request.expiryTimestamp||pr(ti.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,l),await this.client.pendingRequest.set(i,{id:i,topic:s,params:a,verifyContext:u})},this.sendRequest=async e=>{const{topic:i,method:s,params:a,expiry:u,relayRpcId:l,clientRpcId:d,throwOnFailedPublish:f}=e,w=co(s,a,d);if(go()&&k7.includes(s)){const D=As(JSON.stringify(w));this.client.core.verify.register({attestationId:D})}let E;try{E=await this.client.core.crypto.encode(i,w)}catch(D){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),D}const I=ti[s].req;return u&&(I.ttl=u),l&&(I.id=l),this.client.core.history.set(i,w),f?(I.internal=bs(sr({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,E,I)):this.client.core.relayer.publish(i,E,I).catch(D=>this.client.logger.error(D)),w.id},this.sendResult=async e=>{const{id:i,topic:s,result:a,throwOnFailedPublish:u,encodeOpts:l}=e,d=pu(i,a);let f;try{f=await this.client.core.crypto.encode(s,d,l)}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),I}let w;try{w=await this.client.core.history.get(s,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),I}const E=ti[w.request.method].res;u?(E.internal=bs(sr({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,f,E)):this.client.core.relayer.publish(s,f,E).catch(I=>this.client.logger.error(I)),await this.client.core.history.resolve(d)},this.sendError=async e=>{const{id:i,topic:s,error:a,encodeOpts:u}=e,l=gu(i,a);let d;try{d=await this.client.core.crypto.encode(s,l,u)}catch(E){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),E}let f;try{f=await this.client.core.history.get(s,i)}catch(E){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),E}const w=ti[f.request.method].res;this.client.core.relayer.publish(s,d,w),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const e=[],i=[];this.client.session.getAll().forEach(s=>{let a=!1;kn(s.expiry)&&(a=!0),this.client.core.crypto.keychain.has(s.topic)||(a=!0),a&&e.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{kn(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...e.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===An.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=An.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(i=>setTimeout(i,300))}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=An.idle},this.processRequest=e=>{const{topic:i,payload:s}=e,a=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:a}))switch(a){case"wc_sessionPropose":return this.onSessionProposeRequest(i,s);case"wc_sessionSettle":return this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return this.onSessionExtendRequest(i,s);case"wc_sessionPing":return this.onSessionPingRequest(i,s);case"wc_sessionDelete":return this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return this.onSessionRequest(i,s);case"wc_sessionEvent":return this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateRequest(i,s);default:return this.client.logger.info(`Unsupported request method ${a}`)}},this.onRelayEventResponse=async e=>{const{topic:i,payload:s}=e,a=(await this.client.core.history.get(i,s.id)).request.method;switch(a){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s);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 ${a}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:i}=e,{message:s}=gt("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=e=>{const{topic:i,requestMethod:s}=e,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(e,i)=>{const{params:s,id:a}=i;try{this.isValidConnect(sr({},i.params));const u=s.expiryTimestamp||pr(ti.wc_sessionPropose.req.ttl),l=sr({id:a,pairingTopic:e,expiryTimestamp:u},s);await this.setProposal(a,l);const d=As(JSON.stringify(i)),f=await this.getVerifyContext(d,l.proposer.metadata);this.client.events.emit("session_proposal",{id:a,params:l,verifyContext:f})}catch(u){await this.sendError({id:a,topic:e,error:u}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(e,i)=>{const{id:s}=i;if(Qi(i)){const{result:a}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:a});const u=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:u});const l=u.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const d=a.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:d});const f=await this.client.core.crypto.generateSharedKey(l,d);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const w=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:w}),await this.client.core.pairing.activate({topic:e})}else if(Si(i)){await this.client.proposal.delete(s,Re("USER_DISCONNECTED"));const a=de("session_connect");if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners, 954`);this.events.emit(de("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(e,i)=>{const{id:s,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:u,controller:l,expiry:d,namespaces:f,sessionProperties:w,pairingTopic:E,sessionConfig:I}=i.params,D=sr(sr({topic:e,relay:u,expiry:d,namespaces:f,acknowledged:!0,pairingTopic:E,requiredNamespaces:{},optionalNamespaces:{},controller:l.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:l.publicKey,metadata:l.metadata}},w&&{sessionProperties:w}),I&&{sessionConfig:I});await this.sendResult({id:i.id,topic:e,result:!0,throwOnFailedPublish:!0});const P=de("session_connect");if(this.events.listenerCount(P)===0)throw new Error(`emitting ${P} without any listeners 997`);this.events.emit(de("session_connect"),{session:D}),this.cleanupDuplicatePairings(D)}catch(u){await this.sendError({id:s,topic:e,error:u}),this.client.logger.error(u)}},this.onSessionSettleResponse=async(e,i)=>{const{id:s}=i;Qi(i)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(de("session_approve",s),{})):Si(i)&&(await this.client.session.delete(e,Re("USER_DISCONNECTED")),this.events.emit(de("session_approve",s),{error:i.error}))},this.onSessionUpdateRequest=async(e,i)=>{const{params:s,id:a}=i;try{const u=`${e}_session_update`,l=Ko.get(u);if(l&&this.isRequestOutOfSync(l,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:e,error:Re("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(sr({topic:e},s));try{Ko.set(u,a),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:a,topic:e,result:!0,throwOnFailedPublish:!0})}catch(d){throw Ko.delete(u),d}this.client.events.emit("session_update",{id:a,topic:e,params:s})}catch(u){await this.sendError({id:a,topic:e,error:u}),this.client.logger.error(u)}},this.isRequestOutOfSync=(e,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,i)=>{const{id:s}=i,a=de("session_update",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(i)?this.events.emit(de("session_update",s),{}):Si(i)&&this.events.emit(de("session_update",s),{error:i.error})},this.onSessionExtendRequest=async(e,i)=>{const{id:s}=i;try{this.isValidExtend({topic:e}),await this.setExpiry(e,pr(Zs)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(e,i)=>{const{id:s}=i,a=de("session_extend",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(i)?this.events.emit(de("session_extend",s),{}):Si(i)&&this.events.emit(de("session_extend",s),{error:i.error})},this.onSessionPingRequest=async(e,i)=>{const{id:s}=i;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(e,i)=>{const{id:s}=i,a=de("session_ping",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{Qi(i)?this.events.emit(de("session_ping",s),{}):Si(i)&&this.events.emit(de("session_ping",s),{error:i.error})},500)},this.onSessionDeleteRequest=async(e,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:e,reason:i.params}),await Promise.all([new Promise(a=>{this.client.core.relayer.once(kr.publish,async()=>{a(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:Re("USER_DISCONNECTED")})])}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async(e,i)=>{var s;const{id:a,params:u}=i;try{await this.isValidRequest(sr({topic:e},u));const l=As(JSON.stringify(co("wc_sessionRequest",u,a))),d=this.client.session.get(e),f=await this.getVerifyContext(l,d.peer.metadata),w={id:a,topic:e,params:u,verifyContext:f};await this.setPendingSessionRequest(w),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue())}catch(l){await this.sendError({id:a,topic:e,error:l}),this.client.logger.error(l)}},this.onSessionRequestResponse=(e,i)=>{const{id:s}=i,a=de("session_request",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(i)?this.events.emit(de("session_request",s),{result:i.result}):Si(i)&&this.events.emit(de("session_request",s),{error:i.error})},this.onSessionEventRequest=async(e,i)=>{const{id:s,params:a}=i;try{const u=`${e}_session_event_${a.event.name}`,l=Ko.get(u);if(l&&this.isRequestOutOfSync(l,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(sr({topic:e},a)),this.client.events.emit("session_event",{id:s,topic:e,params:a}),Ko.set(u,s)}catch(u){await this.sendError({id:s,topic:e,error:u}),this.client.logger.error(u)}},this.onSessionAuthenticateResponse=(e,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:i}),Qi(i)?this.events.emit(de("session_request",s),{result:i.result}):Si(i)&&this.events.emit(de("session_request",s),{error:i.error})},this.onSessionAuthenticateRequest=async(e,i)=>{const{requester:s,authPayload:a,expiryTimestamp:u}=i.params,l=As(JSON.stringify(i)),d=await this.getVerifyContext(l,this.client.metadata),f={requester:s,pairingTopic:e,id:i.id,authPayload:a,verifyContext:d,expiryTimestamp:u};await this.setAuthRequest(i.id,{request:f,pairingTopic:e}),this.client.events.emit("session_authenticate",{topic:e,params:i.params,id:i.id})},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=An.idle,this.processSessionRequestQueue()},bt.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:e,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(a=>a.topic===e&&a.request.method==="wc_sessionRequest").forEach(a=>{const u=a.request.id,l=de("session_request",u);if(this.events.listenerCount(l)===0)throw new Error(`emitting ${l} without any listeners`);this.events.emit(de("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===An.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=An.active,this.emitSessionRequest(e)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=e=>{this.client.events.emit("session_request",e)},this.onPairingCreated=e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===e.topic);i&&this.onSessionProposeRequest(e.topic,co("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id))},this.isValidConnect=async e=>{if(!zr(e)){const{message:d}=gt("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(d)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:a,sessionProperties:u,relays:l}=e;if(Or(i)||await this.isValidPairingTopic(i),!q4(l,!0)){const{message:d}=gt("MISSING_OR_INVALID",`connect() relays: ${l}`);throw new Error(d)}!Or(s)&&oa(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!Or(a)&&oa(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),Or(u)||this.validateSessionProps(u,"sessionProperties")},this.validateNamespaces=(e,i)=>{const s=L4(e,"connect()",i);if(s)throw new Error(s.message)},this.isValidApprove=async e=>{if(!zr(e))throw new Error(gt("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:i,namespaces:s,relayProtocol:a,sessionProperties:u}=e;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const l=this.client.proposal.get(i),d=Wh(s,"approve()");if(d)throw new Error(d.message);const f=wp(l.requiredNamespaces,s,"approve()");if(f)throw new Error(f.message);if(!tr(a,!0)){const{message:w}=gt("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(w)}Or(u)||this.validateSessionProps(u,"sessionProperties")},this.isValidReject=async e=>{if(!zr(e)){const{message:a}=gt("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(a)}const{id:i,reason:s}=e;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!$4(s)){const{message:a}=gt("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidSessionSettleRequest=e=>{if(!zr(e)){const{message:f}=gt("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(f)}const{relay:i,controller:s,namespaces:a,expiry:u}=e;if(!Lg(i)){const{message:f}=gt("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const l=N4(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);const d=Wh(a,"onSessionSettleRequest()");if(d)throw new Error(d.message);if(kn(u)){const{message:f}=gt("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async e=>{if(!zr(e)){const{message:d}=gt("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(d)}const{topic:i,namespaces:s}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),u=Wh(s,"update()");if(u)throw new Error(u.message);const l=wp(a.requiredNamespaces,s,"update()");if(l)throw new Error(l.message)},this.isValidExtend=async e=>{if(!zr(e)){const{message:s}=gt("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(s)}const{topic:i}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async e=>{if(!zr(e)){const{message:d}=gt("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(d)}const{topic:i,request:s,chainId:a,expiry:u}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:l}=this.client.session.get(i);if(!yp(l,a)){const{message:d}=gt("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(d)}if(!z4(s)){const{message:d}=gt("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(d)}if(!K4(l,a,s.method)){const{message:d}=gt("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(d)}if(u&&!Y4(u,il)){const{message:d}=gt("MISSING_OR_INVALID",`request() expiry: ${u}. Expiry must be a number (in seconds) between ${il.min} and ${il.max}`);throw new Error(d)}},this.isValidRespond=async e=>{var i;if(!zr(e)){const{message:u}=gt("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(u)}const{topic:s,response:a}=e;try{await this.isValidSessionTopic(s)}catch(u){throw(i=e==null?void 0:e.response)!=null&&i.id&&this.cleanupAfterResponse(e),u}if(!k4(a)){const{message:u}=gt("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(u)}},this.isValidPing=async e=>{if(!zr(e)){const{message:s}=gt("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(s)}const{topic:i}=e;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async e=>{if(!zr(e)){const{message:l}=gt("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(l)}const{topic:i,event:s,chainId:a}=e;await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!yp(u,a)){const{message:l}=gt("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(l)}if(!H4(s)){const{message:l}=gt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}if(!V4(u,a,s.name)){const{message:l}=gt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}},this.isValidDisconnect=async e=>{if(!zr(e)){const{message:s}=gt("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(s)}const{topic:i}=e;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=e=>{const{chains:i,uri:s,domain:a,nonce:u}=e;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!tr(s,!1))throw new Error("uri is required parameter");if(!tr(a,!1))throw new Error("domain is required parameter");if(!tr(u,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(d=>Fc(d).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:l}=Fc(i[0]);if(l!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async(e,i)=>{const s={verified:{verifyUrl:i.verifyUrl||no,validation:"UNKNOWN",origin:i.url||""}};try{const a=await this.client.core.verify.resolve({attestationId:e,verifyUrl:i.verifyUrl});a&&(s.verified.origin=a.origin,s.verified.isScam=a.isScam,s.verified.validation=a.origin===new URL(i.url).origin?"VALID":"INVALID")}catch(a){this.client.logger.info(a)}return this.client.logger.info(`Verify context: ${JSON.stringify(s)}`),s},this.validateSessionProps=(e,i)=>{Object.values(e).forEach(s=>{if(!tr(s,!1)){const{message:a}=gt("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(s)}`);throw new Error(a)}})},this.getPendingAuthRequest=e=>{const i=this.client.auth.requests.get(e);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(e,i)=>{if(this.recentlyDeletedMap.set(e,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const a=this.recentlyDeletedLimit/2;for(const u of this.recentlyDeletedMap.keys()){if(s++>=a)break;this.recentlyDeletedMap.delete(u)}}},this.checkRecentlyDeleted=e=>{const i=this.recentlyDeletedMap.get(e);if(i){const{message:s}=gt("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${e}`);throw new Error(s)}}}async isInitialized(){if(!this.initialized){const{message:t}=gt("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(kr.message,async t=>{const{topic:e,message:i}=t,{publicKey:s}=this.client.auth.authKeys.keys.includes(Hc)?this.client.auth.authKeys.get(Hc):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(e,i,{receiverPublicKey:s});try{sf(a)?(this.client.core.history.set(e,a),this.onRelayEventRequest({topic:e,payload:a})):mu(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:e,payload:a}),this.client.core.history.delete(e,a.id)):this.onRelayEventUnknownPayload({topic:e,payload:a})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(Ei.expired,async t=>{const{topic:e,id:i}=Q1(t.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,gt("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,gt("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(io.create,t=>this.onPairingCreated(t)),this.client.core.pairing.events.on(io.delete,t=>{this.addToRecentlyDeleted(t.topic,"pairing")})}isValidPairingTopic(t){if(!tr(t,!1)){const{message:e}=gt("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(kn(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=gt("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!tr(t,!1)){const{message:e}=gt("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(this.checkRecentlyDeleted(t),!this.client.session.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(kn(this.client.session.get(t).expiry)){await this.deleteSession({topic:t});const{message:e}=gt("EXPIRED",`session topic: ${t}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(t)){const{message:e}=gt("MISSING_OR_INVALID",`session topic does not exist in keychain: ${t}`);throw await this.deleteSession({topic:t}),new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.checkRecentlyDeleted(t),this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(tr(t,!1)){const{message:e}=gt("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}else{const{message:e}=gt("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}async isValidProposalId(t){if(!j4(t)){const{message:e}=gt("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=gt("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(kn(this.client.proposal.get(t).expiryTimestamp)){await this.deleteProposal(t);const{message:e}=gt("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class e9 extends Os{constructor(t,e){super(t,e,q7,af),this.core=t,this.logger=e}}class r9 extends Os{constructor(t,e){super(t,e,j7,af),this.core=t,this.logger=e}}class i9 extends Os{constructor(t,e){super(t,e,z7,af,i=>i.id),this.core=t,this.logger=e}}class n9 extends Os{constructor(t,e){super(t,e,V7,yu,()=>Hc),this.core=t,this.logger=e}}class s9 extends Os{constructor(t,e){super(t,e,G7,yu),this.core=t,this.logger=e}}class o9 extends Os{constructor(t,e){super(t,e,W7,yu,i=>i.id),this.core=t,this.logger=e}}class a9{constructor(t,e){this.core=t,this.logger=e,this.authKeys=new n9(this.core,this.logger),this.pairingTopics=new s9(this.core,this.logger),this.requests=new o9(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class cf extends bI{constructor(t){super(t),this.protocol=gm,this.version=mm,this.name=rl.name,this.events=new Di.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=>{try{return await this.engine.authenticate(i)}catch(s){throw this.logger.error(s.message),s}},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=(t==null?void 0:t.name)||rl.name,this.metadata=(t==null?void 0:t.metadata)||QE(),this.signConfig=t==null?void 0:t.signConfig;const e=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:wa(du({level:(t==null?void 0:t.logger)||rl.logger}));this.core=(t==null?void 0:t.core)||new L7(t),this.logger=Gr(e,this.name),this.session=new r9(this.core,this.logger),this.proposal=new e9(this.core,this.logger),this.pendingRequest=new i9(this.core,this.logger),this.engine=new t9(this),this.auth=new a9(this.core,this.logger)}static async init(t){const e=new cf(t);return await e.initialize(),e}get context(){return Vr(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),await this.auth.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}}var c9=Object.defineProperty,u9=Object.defineProperties,h9=Object.getOwnPropertyDescriptors,c1=Object.getOwnPropertySymbols,l9=Object.prototype.hasOwnProperty,f9=Object.prototype.propertyIsEnumerable,u1=(r,t,e)=>t in r?c9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h1=(r,t)=>{for(var e in t||(t={}))l9.call(t,e)&&u1(r,e,t[e]);if(c1)for(var e of c1(t))f9.call(t,e)&&u1(r,e,t[e]);return r},l1=(r,t)=>u9(r,h9(t));const d9={Accept:"application/json","Content-Type":"application/json"},p9="POST",f1={headers:d9,method:p9},d1=10;class Jn{constructor(t,e=!1){if(this.url=t,this.disableProviderPing=e,this.events=new Di.EventEmitter,this.isAvailable=!1,this.registering=!1,!Up(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const e=xn(t),i=await(await hd(this.url,l1(h1({},f1),{body:e}))).json();this.onPayload({data:i})}catch(e){this.onError(t.id,e)}}async register(t=this.url){if(!Up(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+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=t,this.registering=!0;try{if(!this.disableProviderPing){const e=xn({id:1,jsonrpc:"2.0",method:"test",params:[]});await hd(t,l1(h1({},f1),{body:e}))}this.onOpen()}catch(e){const i=this.parseError(e);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(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?va(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const i=this.parseError(e),s=i.message||i.toString(),a=gu(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Jg(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>d1&&this.events.setMaxListeners(d1)}}const p1="error",g9="wss://relay.walletconnect.com",m9="wc",v9="universal_provider",g1=`${m9}@2:${v9}:`,y9="https://rpc.walletconnect.com/v1/",Cn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Wo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},Tl={exports:{}};/**
31
+ * @license
32
+ * Lodash <https://lodash.com/>
33
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
34
+ * Released under MIT license <https://lodash.com/license>
35
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
36
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
37
+ */(function(r,t){(function(){var e,i="4.17.21",s=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",l="Invalid `variable` option passed into `_.template`",d="__lodash_hash_undefined__",f=500,w="__lodash_placeholder__",E=1,I=2,D=4,P=1,Y=2,G=1,tt=2,K=4,V=8,B=16,$=32,z=64,v=128,T=256,nt=512,ft=30,pt="...",mt=800,h=16,y=1,b=2,M=3,C=1/0,R=9007199254740991,j=17976931348623157e292,S=0/0,g=4294967295,N=g-1,it=g>>>1,lt=[["ary",v],["bind",G],["bindKey",tt],["curry",V],["curryRight",B],["flip",nt],["partial",$],["partialRight",z],["rearg",T]],_="[object Arguments]",Z="[object Array]",U="[object AsyncFunction]",L="[object Boolean]",k="[object Date]",p="[object DOMException]",F="[object Error]",et="[object Function]",ut="[object GeneratorFunction]",at="[object Map]",Mt="[object Number]",Pt="[object Null]",It="[object Object]",Ee="[object Promise]",$t="[object Proxy]",xt="[object RegExp]",Bt="[object Set]",_t="[object String]",Et="[object Symbol]",Vt="[object Undefined]",yt="[object WeakMap]",At="[object WeakSet]",Ut="[object ArrayBuffer]",wt="[object DataView]",Ct="[object Float32Array]",Lt="[object Float64Array]",Ot="[object Int8Array]",Nt="[object Int16Array]",se="[object Int32Array]",Tt="[object Uint8Array]",Rt="[object Uint8ClampedArray]",Ke="[object Uint16Array]",ce="[object Uint32Array]",pe=/\b__p \+= '';/g,Ve=/\b(__p \+=) '' \+/g,ye=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_e=/&(?:amp|lt|gt|quot|#39);/g,Er=/[&<>"']/g,Gt=RegExp(_e.source),zt=RegExp(Er.source),De=/<%-([\s\S]+?)%>/g,Wt=/<%([\s\S]+?)%>/g,Kt=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jt=/^\w*$/,Xt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xe=/[\\^$.*+?()[\]{}|]/g,Zt=RegExp(xe.source),Yt=/^\s+/,Ce=/\s/,Qt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,qt=/\{\n\/\* \[wrapped with (.+)\] \*/,Te=/,? & /,te=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pe=/[()=,{}\[\]\/\s]/,xi=/\\(\\)?/g,Oe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,le=/\w*$/,oi=/^[-+]0x[0-9a-f]+$/i,ai=/^0b[01]+$/i,ci=/^\[object .+?Constructor\]$/,ui=/^0o[0-7]+$/i,hi=/^(?:0|[1-9]\d*)$/,ar=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,qi=/($^)/,Xn=/['\n\r\u2028\u2029\\]/g,ji="\\ud800-\\udfff",Zn="\\u0300-\\u036f",ts="\\ufe20-\\ufe2f",$i="\\u20d0-\\u20ff",Pn=Zn+ts+$i,On="\\u2700-\\u27bf",Ar="a-z\\xdf-\\xf6\\xf8-\\xff",es="\\xac\\xb1\\xd7\\xf7",rs="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",is="\\u2000-\\u206f",ns=" \\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",Ea="A-Z\\xc0-\\xd6\\xd8-\\xde",Aa="\\ufe0e\\ufe0f",ss=es+rs+is+ns,_o="['’]",os="["+ji+"]",Eo="["+ss+"]",as="["+Pn+"]",Sa="\\d+",wu="["+On+"]",Ia="["+Ar+"]",Da="[^"+ji+ss+Sa+On+Ar+Ea+"]",Rs="\\ud83c[\\udffb-\\udfff]",bu="(?:"+as+"|"+Rs+")",xa="[^"+ji+"]",Ts="(?:\\ud83c[\\udde6-\\uddff]){2}",Nn="[\\ud800-\\udbff][\\udc00-\\udfff]",Wr="["+Ea+"]",Ma="\\u200d",Ca="(?:"+Ia+"|"+Da+")",zi="(?:"+Wr+"|"+Da+")",Pa="(?:"+_o+"(?:d|ll|m|re|s|t|ve))?",Oa="(?:"+_o+"(?:D|LL|M|RE|S|T|VE))?",Na=bu+"?",Ra="["+Aa+"]?",_u="(?:"+Ma+"(?:"+[xa,Ts,Nn].join("|")+")"+Ra+Na+")*",hn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ta="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Fa=Ra+Na+_u,Fs="(?:"+[wu,Ts,Nn].join("|")+")"+Fa,Eu="(?:"+[xa+as+"?",as,Ts,Nn,os].join("|")+")",Ao=RegExp(_o,"g"),Au=RegExp(as,"g"),Us=RegExp(Rs+"(?="+Rs+")|"+Eu+Fa,"g"),Ua=RegExp([Wr+"?"+Ia+"+"+Pa+"(?="+[Eo,Wr,"$"].join("|")+")",zi+"+"+Oa+"(?="+[Eo,Wr+Ca,"$"].join("|")+")",Wr+"?"+Ca+"+"+Pa,Wr+"+"+Oa,Ta,hn,Sa,Fs].join("|"),"g"),Ba=RegExp("["+Ma+ji+Pn+Aa+"]"),cs=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,La=["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"],Su=-1,Ue={};Ue[Ct]=Ue[Lt]=Ue[Ot]=Ue[Nt]=Ue[se]=Ue[Tt]=Ue[Rt]=Ue[Ke]=Ue[ce]=!0,Ue[_]=Ue[Z]=Ue[Ut]=Ue[L]=Ue[wt]=Ue[k]=Ue[F]=Ue[et]=Ue[at]=Ue[Mt]=Ue[It]=Ue[xt]=Ue[Bt]=Ue[_t]=Ue[yt]=!1;var Fe={};Fe[_]=Fe[Z]=Fe[Ut]=Fe[wt]=Fe[L]=Fe[k]=Fe[Ct]=Fe[Lt]=Fe[Ot]=Fe[Nt]=Fe[se]=Fe[at]=Fe[Mt]=Fe[It]=Fe[xt]=Fe[Bt]=Fe[_t]=Fe[Et]=Fe[Tt]=Fe[Rt]=Fe[Ke]=Fe[ce]=!0,Fe[F]=Fe[et]=Fe[yt]=!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"},Q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ht={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Be=parseFloat,re=parseInt,$e=typeof Wo=="object"&&Wo&&Wo.Object===Object&&Wo,er=typeof self=="object"&&self&&self.Object===Object&&self,we=$e||er||Function("return this")(),Le=t&&!t.nodeType&&t,Qe=Le&&!0&&r&&!r.nodeType&&r,Fr=Qe&&Qe.exports===Le,rr=Fr&&$e.process,ze=function(){try{var J=Qe&&Qe.require&&Qe.require("util").types;return J||rr&&rr.binding&&rr.binding("util")}catch{}}(),Sr=ze&&ze.isArrayBuffer,Mi=ze&&ze.isDate,li=ze&&ze.isMap,ki=ze&&ze.isRegExp,So=ze&&ze.isSet,us=ze&&ze.isTypedArray;function cr(J,st,rt){switch(rt.length){case 0:return J.call(st);case 1:return J.call(st,rt[0]);case 2:return J.call(st,rt[0],rt[1]);case 3:return J.call(st,rt[0],rt[1],rt[2])}return J.apply(st,rt)}function _m(J,st,rt,Dt){for(var ee=-1,Se=J==null?0:J.length;++ee<Se;){var ir=J[ee];st(Dt,ir,rt(ir),J)}return Dt}function fi(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt&&st(J[rt],rt,J)!==!1;);return J}function Em(J,st){for(var rt=J==null?0:J.length;rt--&&st(J[rt],rt,J)!==!1;);return J}function lf(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(!st(J[rt],rt,J))return!1;return!0}function Rn(J,st){for(var rt=-1,Dt=J==null?0:J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];st(ir,rt,J)&&(Se[ee++]=ir)}return Se}function qa(J,st){var rt=J==null?0:J.length;return!!rt&&Bs(J,st,0)>-1}function Iu(J,st,rt){for(var Dt=-1,ee=J==null?0:J.length;++Dt<ee;)if(rt(st,J[Dt]))return!0;return!1}function ke(J,st){for(var rt=-1,Dt=J==null?0:J.length,ee=Array(Dt);++rt<Dt;)ee[rt]=st(J[rt],rt,J);return ee}function Tn(J,st){for(var rt=-1,Dt=st.length,ee=J.length;++rt<Dt;)J[ee+rt]=st[rt];return J}function Du(J,st,rt,Dt){var ee=-1,Se=J==null?0:J.length;for(Dt&&Se&&(rt=J[++ee]);++ee<Se;)rt=st(rt,J[ee],ee,J);return rt}function Am(J,st,rt,Dt){var ee=J==null?0:J.length;for(Dt&&ee&&(rt=J[--ee]);ee--;)rt=st(rt,J[ee],ee,J);return rt}function xu(J,st){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(st(J[rt],rt,J))return!0;return!1}var Sm=Mu("length");function Im(J){return J.split("")}function Dm(J){return J.match(te)||[]}function ff(J,st,rt){var Dt;return rt(J,function(ee,Se,ir){if(st(ee,Se,ir))return Dt=Se,!1}),Dt}function ja(J,st,rt,Dt){for(var ee=J.length,Se=rt+(Dt?1:-1);Dt?Se--:++Se<ee;)if(st(J[Se],Se,J))return Se;return-1}function Bs(J,st,rt){return st===st?Lm(J,st,rt):ja(J,df,rt)}function xm(J,st,rt,Dt){for(var ee=rt-1,Se=J.length;++ee<Se;)if(Dt(J[ee],st))return ee;return-1}function df(J){return J!==J}function pf(J,st){var rt=J==null?0:J.length;return rt?Pu(J,st)/rt:S}function Mu(J){return function(st){return st==null?e:st[J]}}function Cu(J){return function(st){return J==null?e:J[st]}}function gf(J,st,rt,Dt,ee){return ee(J,function(Se,ir,qe){rt=Dt?(Dt=!1,Se):st(rt,Se,ir,qe)}),rt}function Mm(J,st){var rt=J.length;for(J.sort(st);rt--;)J[rt]=J[rt].value;return J}function Pu(J,st){for(var rt,Dt=-1,ee=J.length;++Dt<ee;){var Se=st(J[Dt]);Se!==e&&(rt=rt===e?Se:rt+Se)}return rt}function Ou(J,st){for(var rt=-1,Dt=Array(J);++rt<J;)Dt[rt]=st(rt);return Dt}function Cm(J,st){return ke(st,function(rt){return[rt,J[rt]]})}function mf(J){return J&&J.slice(0,bf(J)+1).replace(Yt,"")}function Yr(J){return function(st){return J(st)}}function Nu(J,st){return ke(st,function(rt){return J[rt]})}function Io(J,st){return J.has(st)}function vf(J,st){for(var rt=-1,Dt=J.length;++rt<Dt&&Bs(st,J[rt],0)>-1;);return rt}function yf(J,st){for(var rt=J.length;rt--&&Bs(st,J[rt],0)>-1;);return rt}function Pm(J,st){for(var rt=J.length,Dt=0;rt--;)J[rt]===st&&++Dt;return Dt}var Om=Cu(q),Nm=Cu(Q);function Rm(J){return"\\"+St[J]}function Tm(J,st){return J==null?e:J[st]}function Ls(J){return Ba.test(J)}function Fm(J){return cs.test(J)}function Um(J){for(var st,rt=[];!(st=J.next()).done;)rt.push(st.value);return rt}function Ru(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt,ee){rt[++st]=[ee,Dt]}),rt}function wf(J,st){return function(rt){return J(st(rt))}}function Fn(J,st){for(var rt=-1,Dt=J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];(ir===st||ir===w)&&(J[rt]=w,Se[ee++]=rt)}return Se}function $a(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++st]=Dt}),rt}function Bm(J){var st=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++st]=[Dt,Dt]}),rt}function Lm(J,st,rt){for(var Dt=rt-1,ee=J.length;++Dt<ee;)if(J[Dt]===st)return Dt;return-1}function qm(J,st,rt){for(var Dt=rt+1;Dt--;)if(J[Dt]===st)return Dt;return Dt}function qs(J){return Ls(J)?$m(J):Sm(J)}function Ci(J){return Ls(J)?zm(J):Im(J)}function bf(J){for(var st=J.length;st--&&Ce.test(J.charAt(st)););return st}var jm=Cu(ht);function $m(J){for(var st=Us.lastIndex=0;Us.test(J);)++st;return st}function zm(J){return J.match(Us)||[]}function km(J){return J.match(Ua)||[]}var Hm=function J(st){st=st==null?we:js.defaults(we.Object(),st,js.pick(we,La));var rt=st.Array,Dt=st.Date,ee=st.Error,Se=st.Function,ir=st.Math,qe=st.Object,Tu=st.RegExp,Km=st.String,di=st.TypeError,za=rt.prototype,Vm=Se.prototype,$s=qe.prototype,ka=st["__core-js_shared__"],Ha=Vm.toString,Ne=$s.hasOwnProperty,Gm=0,_f=function(){var n=/[^.]+$/.exec(ka&&ka.keys&&ka.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),Ka=$s.toString,Wm=Ha.call(qe),Ym=we._,Qm=Tu("^"+Ha.call(Ne).replace(xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Va=Fr?st.Buffer:e,Un=st.Symbol,Ga=st.Uint8Array,Ef=Va?Va.allocUnsafe:e,Wa=wf(qe.getPrototypeOf,qe),Af=qe.create,Sf=$s.propertyIsEnumerable,Ya=za.splice,If=Un?Un.isConcatSpreadable:e,Do=Un?Un.iterator:e,hs=Un?Un.toStringTag:e,Qa=function(){try{var n=gs(qe,"defineProperty");return n({},"",{}),n}catch{}}(),Jm=st.clearTimeout!==we.clearTimeout&&st.clearTimeout,Xm=Dt&&Dt.now!==we.Date.now&&Dt.now,Zm=st.setTimeout!==we.setTimeout&&st.setTimeout,Ja=ir.ceil,Xa=ir.floor,Fu=qe.getOwnPropertySymbols,tv=Va?Va.isBuffer:e,Df=st.isFinite,ev=za.join,rv=wf(qe.keys,qe),nr=ir.max,yr=ir.min,iv=Dt.now,nv=st.parseInt,xf=ir.random,sv=za.reverse,Uu=gs(st,"DataView"),xo=gs(st,"Map"),Bu=gs(st,"Promise"),zs=gs(st,"Set"),Mo=gs(st,"WeakMap"),Co=gs(qe,"create"),Za=Mo&&new Mo,ks={},ov=ms(Uu),av=ms(xo),cv=ms(Bu),uv=ms(zs),hv=ms(Mo),tc=Un?Un.prototype:e,Po=tc?tc.valueOf:e,Mf=tc?tc.toString:e;function x(n){if(We(n)&&!ie(n)&&!(n instanceof ge)){if(n instanceof pi)return n;if(Ne.call(n,"__wrapped__"))return C0(n)}return new pi(n)}var Hs=function(){function n(){}return function(o){if(!Ge(o))return{};if(Af)return Af(o);n.prototype=o;var c=new n;return n.prototype=e,c}}();function ec(){}function pi(n,o){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}x.templateSettings={escape:De,evaluate:Wt,interpolate:Kt,variable:"",imports:{_:x}},x.prototype=ec.prototype,x.prototype.constructor=x,pi.prototype=Hs(ec.prototype),pi.prototype.constructor=pi;function ge(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=g,this.__views__=[]}function lv(){var n=new ge(this.__wrapped__);return n.__actions__=Ur(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Ur(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Ur(this.__views__),n}function fv(){if(this.__filtered__){var n=new ge(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function dv(){var n=this.__wrapped__.value(),o=this.__dir__,c=ie(n),m=o<0,A=c?n.length:0,O=Iy(0,A,this.__views__),H=O.start,W=O.end,X=W-H,ot=m?W:H-1,ct=this.__iteratees__,dt=ct.length,vt=0,Ft=yr(X,this.__takeCount__);if(!c||!m&&A==X&&Ft==X)return Xf(n,this.__actions__);var kt=[];t:for(;X--&&vt<Ft;){ot+=o;for(var ue=-1,Ht=n[ot];++ue<dt;){var fe=ct[ue],be=fe.iteratee,Xr=fe.type,xr=be(Ht);if(Xr==b)Ht=xr;else if(!xr){if(Xr==y)continue t;break t}}kt[vt++]=Ht}return kt}ge.prototype=Hs(ec.prototype),ge.prototype.constructor=ge;function ls(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var m=n[o];this.set(m[0],m[1])}}function pv(){this.__data__=Co?Co(null):{},this.size=0}function gv(n){var o=this.has(n)&&delete this.__data__[n];return this.size-=o?1:0,o}function mv(n){var o=this.__data__;if(Co){var c=o[n];return c===d?e:c}return Ne.call(o,n)?o[n]:e}function vv(n){var o=this.__data__;return Co?o[n]!==e:Ne.call(o,n)}function yv(n,o){var c=this.__data__;return this.size+=this.has(n)?0:1,c[n]=Co&&o===e?d:o,this}ls.prototype.clear=pv,ls.prototype.delete=gv,ls.prototype.get=mv,ls.prototype.has=vv,ls.prototype.set=yv;function ln(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var m=n[o];this.set(m[0],m[1])}}function wv(){this.__data__=[],this.size=0}function bv(n){var o=this.__data__,c=rc(o,n);if(c<0)return!1;var m=o.length-1;return c==m?o.pop():Ya.call(o,c,1),--this.size,!0}function _v(n){var o=this.__data__,c=rc(o,n);return c<0?e:o[c][1]}function Ev(n){return rc(this.__data__,n)>-1}function Av(n,o){var c=this.__data__,m=rc(c,n);return m<0?(++this.size,c.push([n,o])):c[m][1]=o,this}ln.prototype.clear=wv,ln.prototype.delete=bv,ln.prototype.get=_v,ln.prototype.has=Ev,ln.prototype.set=Av;function fn(n){var o=-1,c=n==null?0:n.length;for(this.clear();++o<c;){var m=n[o];this.set(m[0],m[1])}}function Sv(){this.size=0,this.__data__={hash:new ls,map:new(xo||ln),string:new ls}}function Iv(n){var o=pc(this,n).delete(n);return this.size-=o?1:0,o}function Dv(n){return pc(this,n).get(n)}function xv(n){return pc(this,n).has(n)}function Mv(n,o){var c=pc(this,n),m=c.size;return c.set(n,o),this.size+=c.size==m?0:1,this}fn.prototype.clear=Sv,fn.prototype.delete=Iv,fn.prototype.get=Dv,fn.prototype.has=xv,fn.prototype.set=Mv;function fs(n){var o=-1,c=n==null?0:n.length;for(this.__data__=new fn;++o<c;)this.add(n[o])}function Cv(n){return this.__data__.set(n,d),this}function Pv(n){return this.__data__.has(n)}fs.prototype.add=fs.prototype.push=Cv,fs.prototype.has=Pv;function Pi(n){var o=this.__data__=new ln(n);this.size=o.size}function Ov(){this.__data__=new ln,this.size=0}function Nv(n){var o=this.__data__,c=o.delete(n);return this.size=o.size,c}function Rv(n){return this.__data__.get(n)}function Tv(n){return this.__data__.has(n)}function Fv(n,o){var c=this.__data__;if(c instanceof ln){var m=c.__data__;if(!xo||m.length<s-1)return m.push([n,o]),this.size=++c.size,this;c=this.__data__=new fn(m)}return c.set(n,o),this.size=c.size,this}Pi.prototype.clear=Ov,Pi.prototype.delete=Nv,Pi.prototype.get=Rv,Pi.prototype.has=Tv,Pi.prototype.set=Fv;function Cf(n,o){var c=ie(n),m=!c&&vs(n),A=!c&&!m&&$n(n),O=!c&&!m&&!A&&Ws(n),H=c||m||A||O,W=H?Ou(n.length,Km):[],X=W.length;for(var ot in n)(o||Ne.call(n,ot))&&!(H&&(ot=="length"||A&&(ot=="offset"||ot=="parent")||O&&(ot=="buffer"||ot=="byteLength"||ot=="byteOffset")||mn(ot,X)))&&W.push(ot);return W}function Pf(n){var o=n.length;return o?n[Wu(0,o-1)]:e}function Uv(n,o){return gc(Ur(n),ds(o,0,n.length))}function Bv(n){return gc(Ur(n))}function Lu(n,o,c){(c!==e&&!Oi(n[o],c)||c===e&&!(o in n))&&dn(n,o,c)}function Oo(n,o,c){var m=n[o];(!(Ne.call(n,o)&&Oi(m,c))||c===e&&!(o in n))&&dn(n,o,c)}function rc(n,o){for(var c=n.length;c--;)if(Oi(n[c][0],o))return c;return-1}function Lv(n,o,c,m){return Bn(n,function(A,O,H){o(m,A,c(A),H)}),m}function Of(n,o){return n&&Ki(o,ur(o),n)}function qv(n,o){return n&&Ki(o,Lr(o),n)}function dn(n,o,c){o=="__proto__"&&Qa?Qa(n,o,{configurable:!0,enumerable:!0,value:c,writable:!0}):n[o]=c}function qu(n,o){for(var c=-1,m=o.length,A=rt(m),O=n==null;++c<m;)A[c]=O?e:wh(n,o[c]);return A}function ds(n,o,c){return n===n&&(c!==e&&(n=n<=c?n:c),o!==e&&(n=n>=o?n:o)),n}function gi(n,o,c,m,A,O){var H,W=o&E,X=o&I,ot=o&D;if(c&&(H=A?c(n,m,A,O):c(n)),H!==e)return H;if(!Ge(n))return n;var ct=ie(n);if(ct){if(H=xy(n),!W)return Ur(n,H)}else{var dt=wr(n),vt=dt==et||dt==ut;if($n(n))return e0(n,W);if(dt==It||dt==_||vt&&!A){if(H=X||vt?{}:b0(n),!W)return X?my(n,qv(H,n)):gy(n,Of(H,n))}else{if(!Fe[dt])return A?n:{};H=My(n,dt,W)}}O||(O=new Pi);var Ft=O.get(n);if(Ft)return Ft;O.set(n,H),Y0(n)?n.forEach(function(Ht){H.add(gi(Ht,o,c,Ht,n,O))}):G0(n)&&n.forEach(function(Ht,fe){H.set(fe,gi(Ht,o,c,fe,n,O))});var kt=ot?X?sh:nh:X?Lr:ur,ue=ct?e:kt(n);return fi(ue||n,function(Ht,fe){ue&&(fe=Ht,Ht=n[fe]),Oo(H,fe,gi(Ht,o,c,fe,n,O))}),H}function jv(n){var o=ur(n);return function(c){return Nf(c,n,o)}}function Nf(n,o,c){var m=c.length;if(n==null)return!m;for(n=qe(n);m--;){var A=c[m],O=o[A],H=n[A];if(H===e&&!(A in n)||!O(H))return!1}return!0}function Rf(n,o,c){if(typeof n!="function")throw new di(u);return Lo(function(){n.apply(e,c)},o)}function No(n,o,c,m){var A=-1,O=qa,H=!0,W=n.length,X=[],ot=o.length;if(!W)return X;c&&(o=ke(o,Yr(c))),m?(O=Iu,H=!1):o.length>=s&&(O=Io,H=!1,o=new fs(o));t:for(;++A<W;){var ct=n[A],dt=c==null?ct:c(ct);if(ct=m||ct!==0?ct:0,H&&dt===dt){for(var vt=ot;vt--;)if(o[vt]===dt)continue t;X.push(ct)}else O(o,dt,m)||X.push(ct)}return X}var Bn=o0(Hi),Tf=o0($u,!0);function $v(n,o){var c=!0;return Bn(n,function(m,A,O){return c=!!o(m,A,O),c}),c}function ic(n,o,c){for(var m=-1,A=n.length;++m<A;){var O=n[m],H=o(O);if(H!=null&&(W===e?H===H&&!Jr(H):c(H,W)))var W=H,X=O}return X}function zv(n,o,c,m){var A=n.length;for(c=ae(c),c<0&&(c=-c>A?0:A+c),m=m===e||m>A?A:ae(m),m<0&&(m+=A),m=c>m?0:J0(m);c<m;)n[c++]=o;return n}function Ff(n,o){var c=[];return Bn(n,function(m,A,O){o(m,A,O)&&c.push(m)}),c}function fr(n,o,c,m,A){var O=-1,H=n.length;for(c||(c=Py),A||(A=[]);++O<H;){var W=n[O];o>0&&c(W)?o>1?fr(W,o-1,c,m,A):Tn(A,W):m||(A[A.length]=W)}return A}var ju=a0(),Uf=a0(!0);function Hi(n,o){return n&&ju(n,o,ur)}function $u(n,o){return n&&Uf(n,o,ur)}function nc(n,o){return Rn(o,function(c){return vn(n[c])})}function ps(n,o){o=qn(o,n);for(var c=0,m=o.length;n!=null&&c<m;)n=n[Vi(o[c++])];return c&&c==m?n:e}function Bf(n,o,c){var m=o(n);return ie(n)?m:Tn(m,c(n))}function Ir(n){return n==null?n===e?Vt:Pt:hs&&hs in qe(n)?Sy(n):By(n)}function zu(n,o){return n>o}function kv(n,o){return n!=null&&Ne.call(n,o)}function Hv(n,o){return n!=null&&o in qe(n)}function Kv(n,o,c){return n>=yr(o,c)&&n<nr(o,c)}function ku(n,o,c){for(var m=c?Iu:qa,A=n[0].length,O=n.length,H=O,W=rt(O),X=1/0,ot=[];H--;){var ct=n[H];H&&o&&(ct=ke(ct,Yr(o))),X=yr(ct.length,X),W[H]=!c&&(o||A>=120&&ct.length>=120)?new fs(H&&ct):e}ct=n[0];var dt=-1,vt=W[0];t:for(;++dt<A&&ot.length<X;){var Ft=ct[dt],kt=o?o(Ft):Ft;if(Ft=c||Ft!==0?Ft:0,!(vt?Io(vt,kt):m(ot,kt,c))){for(H=O;--H;){var ue=W[H];if(!(ue?Io(ue,kt):m(n[H],kt,c)))continue t}vt&&vt.push(kt),ot.push(Ft)}}return ot}function Vv(n,o,c,m){return Hi(n,function(A,O,H){o(m,c(A),O,H)}),m}function Ro(n,o,c){o=qn(o,n),n=S0(n,o);var m=n==null?n:n[Vi(vi(o))];return m==null?e:cr(m,n,c)}function Lf(n){return We(n)&&Ir(n)==_}function Gv(n){return We(n)&&Ir(n)==Ut}function Wv(n){return We(n)&&Ir(n)==k}function To(n,o,c,m,A){return n===o?!0:n==null||o==null||!We(n)&&!We(o)?n!==n&&o!==o:Yv(n,o,c,m,To,A)}function Yv(n,o,c,m,A,O){var H=ie(n),W=ie(o),X=H?Z:wr(n),ot=W?Z:wr(o);X=X==_?It:X,ot=ot==_?It:ot;var ct=X==It,dt=ot==It,vt=X==ot;if(vt&&$n(n)){if(!$n(o))return!1;H=!0,ct=!1}if(vt&&!ct)return O||(O=new Pi),H||Ws(n)?v0(n,o,c,m,A,O):Ey(n,o,X,c,m,A,O);if(!(c&P)){var Ft=ct&&Ne.call(n,"__wrapped__"),kt=dt&&Ne.call(o,"__wrapped__");if(Ft||kt){var ue=Ft?n.value():n,Ht=kt?o.value():o;return O||(O=new Pi),A(ue,Ht,c,m,O)}}return vt?(O||(O=new Pi),Ay(n,o,c,m,A,O)):!1}function Qv(n){return We(n)&&wr(n)==at}function Hu(n,o,c,m){var A=c.length,O=A,H=!m;if(n==null)return!O;for(n=qe(n);A--;){var W=c[A];if(H&&W[2]?W[1]!==n[W[0]]:!(W[0]in n))return!1}for(;++A<O;){W=c[A];var X=W[0],ot=n[X],ct=W[1];if(H&&W[2]){if(ot===e&&!(X in n))return!1}else{var dt=new Pi;if(m)var vt=m(ot,ct,X,n,o,dt);if(!(vt===e?To(ct,ot,P|Y,m,dt):vt))return!1}}return!0}function qf(n){if(!Ge(n)||Ny(n))return!1;var o=vn(n)?Qm:ci;return o.test(ms(n))}function Jv(n){return We(n)&&Ir(n)==xt}function Xv(n){return We(n)&&wr(n)==Bt}function Zv(n){return We(n)&&_c(n.length)&&!!Ue[Ir(n)]}function jf(n){return typeof n=="function"?n:n==null?qr:typeof n=="object"?ie(n)?kf(n[0],n[1]):zf(n):cd(n)}function Ku(n){if(!Bo(n))return rv(n);var o=[];for(var c in qe(n))Ne.call(n,c)&&c!="constructor"&&o.push(c);return o}function ty(n){if(!Ge(n))return Uy(n);var o=Bo(n),c=[];for(var m in n)m=="constructor"&&(o||!Ne.call(n,m))||c.push(m);return c}function Vu(n,o){return n<o}function $f(n,o){var c=-1,m=Br(n)?rt(n.length):[];return Bn(n,function(A,O,H){m[++c]=o(A,O,H)}),m}function zf(n){var o=ah(n);return o.length==1&&o[0][2]?E0(o[0][0],o[0][1]):function(c){return c===n||Hu(c,n,o)}}function kf(n,o){return uh(n)&&_0(o)?E0(Vi(n),o):function(c){var m=wh(c,n);return m===e&&m===o?bh(c,n):To(o,m,P|Y)}}function sc(n,o,c,m,A){n!==o&&ju(o,function(O,H){if(A||(A=new Pi),Ge(O))ey(n,o,H,c,sc,m,A);else{var W=m?m(lh(n,H),O,H+"",n,o,A):e;W===e&&(W=O),Lu(n,H,W)}},Lr)}function ey(n,o,c,m,A,O,H){var W=lh(n,c),X=lh(o,c),ot=H.get(X);if(ot){Lu(n,c,ot);return}var ct=O?O(W,X,c+"",n,o,H):e,dt=ct===e;if(dt){var vt=ie(X),Ft=!vt&&$n(X),kt=!vt&&!Ft&&Ws(X);ct=X,vt||Ft||kt?ie(W)?ct=W:Je(W)?ct=Ur(W):Ft?(dt=!1,ct=e0(X,!0)):kt?(dt=!1,ct=r0(X,!0)):ct=[]:qo(X)||vs(X)?(ct=W,vs(W)?ct=X0(W):(!Ge(W)||vn(W))&&(ct=b0(X))):dt=!1}dt&&(H.set(X,ct),A(ct,X,m,O,H),H.delete(X)),Lu(n,c,ct)}function Hf(n,o){var c=n.length;if(c)return o+=o<0?c:0,mn(o,c)?n[o]:e}function Kf(n,o,c){o.length?o=ke(o,function(O){return ie(O)?function(H){return ps(H,O.length===1?O[0]:O)}:O}):o=[qr];var m=-1;o=ke(o,Yr(jt()));var A=$f(n,function(O,H,W){var X=ke(o,function(ot){return ot(O)});return{criteria:X,index:++m,value:O}});return Mm(A,function(O,H){return py(O,H,c)})}function ry(n,o){return Vf(n,o,function(c,m){return bh(n,m)})}function Vf(n,o,c){for(var m=-1,A=o.length,O={};++m<A;){var H=o[m],W=ps(n,H);c(W,H)&&Fo(O,qn(H,n),W)}return O}function iy(n){return function(o){return ps(o,n)}}function Gu(n,o,c,m){var A=m?xm:Bs,O=-1,H=o.length,W=n;for(n===o&&(o=Ur(o)),c&&(W=ke(n,Yr(c)));++O<H;)for(var X=0,ot=o[O],ct=c?c(ot):ot;(X=A(W,ct,X,m))>-1;)W!==n&&Ya.call(W,X,1),Ya.call(n,X,1);return n}function Gf(n,o){for(var c=n?o.length:0,m=c-1;c--;){var A=o[c];if(c==m||A!==O){var O=A;mn(A)?Ya.call(n,A,1):Ju(n,A)}}return n}function Wu(n,o){return n+Xa(xf()*(o-n+1))}function ny(n,o,c,m){for(var A=-1,O=nr(Ja((o-n)/(c||1)),0),H=rt(O);O--;)H[m?O:++A]=n,n+=c;return H}function Yu(n,o){var c="";if(!n||o<1||o>R)return c;do o%2&&(c+=n),o=Xa(o/2),o&&(n+=n);while(o);return c}function he(n,o){return fh(A0(n,o,qr),n+"")}function sy(n){return Pf(Ys(n))}function oy(n,o){var c=Ys(n);return gc(c,ds(o,0,c.length))}function Fo(n,o,c,m){if(!Ge(n))return n;o=qn(o,n);for(var A=-1,O=o.length,H=O-1,W=n;W!=null&&++A<O;){var X=Vi(o[A]),ot=c;if(X==="__proto__"||X==="constructor"||X==="prototype")return n;if(A!=H){var ct=W[X];ot=m?m(ct,X,W):e,ot===e&&(ot=Ge(ct)?ct:mn(o[A+1])?[]:{})}Oo(W,X,ot),W=W[X]}return n}var Wf=Za?function(n,o){return Za.set(n,o),n}:qr,ay=Qa?function(n,o){return Qa(n,"toString",{configurable:!0,enumerable:!1,value:Eh(o),writable:!0})}:qr;function cy(n){return gc(Ys(n))}function mi(n,o,c){var m=-1,A=n.length;o<0&&(o=-o>A?0:A+o),c=c>A?A:c,c<0&&(c+=A),A=o>c?0:c-o>>>0,o>>>=0;for(var O=rt(A);++m<A;)O[m]=n[m+o];return O}function uy(n,o){var c;return Bn(n,function(m,A,O){return c=o(m,A,O),!c}),!!c}function oc(n,o,c){var m=0,A=n==null?m:n.length;if(typeof o=="number"&&o===o&&A<=it){for(;m<A;){var O=m+A>>>1,H=n[O];H!==null&&!Jr(H)&&(c?H<=o:H<o)?m=O+1:A=O}return A}return Qu(n,o,qr,c)}function Qu(n,o,c,m){var A=0,O=n==null?0:n.length;if(O===0)return 0;o=c(o);for(var H=o!==o,W=o===null,X=Jr(o),ot=o===e;A<O;){var ct=Xa((A+O)/2),dt=c(n[ct]),vt=dt!==e,Ft=dt===null,kt=dt===dt,ue=Jr(dt);if(H)var Ht=m||kt;else ot?Ht=kt&&(m||vt):W?Ht=kt&&vt&&(m||!Ft):X?Ht=kt&&vt&&!Ft&&(m||!ue):Ft||ue?Ht=!1:Ht=m?dt<=o:dt<o;Ht?A=ct+1:O=ct}return yr(O,N)}function Yf(n,o){for(var c=-1,m=n.length,A=0,O=[];++c<m;){var H=n[c],W=o?o(H):H;if(!c||!Oi(W,X)){var X=W;O[A++]=H===0?0:H}}return O}function Qf(n){return typeof n=="number"?n:Jr(n)?S:+n}function Qr(n){if(typeof n=="string")return n;if(ie(n))return ke(n,Qr)+"";if(Jr(n))return Mf?Mf.call(n):"";var o=n+"";return o=="0"&&1/n==-C?"-0":o}function Ln(n,o,c){var m=-1,A=qa,O=n.length,H=!0,W=[],X=W;if(c)H=!1,A=Iu;else if(O>=s){var ot=o?null:by(n);if(ot)return $a(ot);H=!1,A=Io,X=new fs}else X=o?[]:W;t:for(;++m<O;){var ct=n[m],dt=o?o(ct):ct;if(ct=c||ct!==0?ct:0,H&&dt===dt){for(var vt=X.length;vt--;)if(X[vt]===dt)continue t;o&&X.push(dt),W.push(ct)}else A(X,dt,c)||(X!==W&&X.push(dt),W.push(ct))}return W}function Ju(n,o){return o=qn(o,n),n=S0(n,o),n==null||delete n[Vi(vi(o))]}function Jf(n,o,c,m){return Fo(n,o,c(ps(n,o)),m)}function ac(n,o,c,m){for(var A=n.length,O=m?A:-1;(m?O--:++O<A)&&o(n[O],O,n););return c?mi(n,m?0:O,m?O+1:A):mi(n,m?O+1:0,m?A:O)}function Xf(n,o){var c=n;return c instanceof ge&&(c=c.value()),Du(o,function(m,A){return A.func.apply(A.thisArg,Tn([m],A.args))},c)}function Xu(n,o,c){var m=n.length;if(m<2)return m?Ln(n[0]):[];for(var A=-1,O=rt(m);++A<m;)for(var H=n[A],W=-1;++W<m;)W!=A&&(O[A]=No(O[A]||H,n[W],o,c));return Ln(fr(O,1),o,c)}function Zf(n,o,c){for(var m=-1,A=n.length,O=o.length,H={};++m<A;){var W=m<O?o[m]:e;c(H,n[m],W)}return H}function Zu(n){return Je(n)?n:[]}function th(n){return typeof n=="function"?n:qr}function qn(n,o){return ie(n)?n:uh(n,o)?[n]:M0(Me(n))}var hy=he;function jn(n,o,c){var m=n.length;return c=c===e?m:c,!o&&c>=m?n:mi(n,o,c)}var t0=Jm||function(n){return we.clearTimeout(n)};function e0(n,o){if(o)return n.slice();var c=n.length,m=Ef?Ef(c):new n.constructor(c);return n.copy(m),m}function eh(n){var o=new n.constructor(n.byteLength);return new Ga(o).set(new Ga(n)),o}function ly(n,o){var c=o?eh(n.buffer):n.buffer;return new n.constructor(c,n.byteOffset,n.byteLength)}function fy(n){var o=new n.constructor(n.source,le.exec(n));return o.lastIndex=n.lastIndex,o}function dy(n){return Po?qe(Po.call(n)):{}}function r0(n,o){var c=o?eh(n.buffer):n.buffer;return new n.constructor(c,n.byteOffset,n.length)}function i0(n,o){if(n!==o){var c=n!==e,m=n===null,A=n===n,O=Jr(n),H=o!==e,W=o===null,X=o===o,ot=Jr(o);if(!W&&!ot&&!O&&n>o||O&&H&&X&&!W&&!ot||m&&H&&X||!c&&X||!A)return 1;if(!m&&!O&&!ot&&n<o||ot&&c&&A&&!m&&!O||W&&c&&A||!H&&A||!X)return-1}return 0}function py(n,o,c){for(var m=-1,A=n.criteria,O=o.criteria,H=A.length,W=c.length;++m<H;){var X=i0(A[m],O[m]);if(X){if(m>=W)return X;var ot=c[m];return X*(ot=="desc"?-1:1)}}return n.index-o.index}function n0(n,o,c,m){for(var A=-1,O=n.length,H=c.length,W=-1,X=o.length,ot=nr(O-H,0),ct=rt(X+ot),dt=!m;++W<X;)ct[W]=o[W];for(;++A<H;)(dt||A<O)&&(ct[c[A]]=n[A]);for(;ot--;)ct[W++]=n[A++];return ct}function s0(n,o,c,m){for(var A=-1,O=n.length,H=-1,W=c.length,X=-1,ot=o.length,ct=nr(O-W,0),dt=rt(ct+ot),vt=!m;++A<ct;)dt[A]=n[A];for(var Ft=A;++X<ot;)dt[Ft+X]=o[X];for(;++H<W;)(vt||A<O)&&(dt[Ft+c[H]]=n[A++]);return dt}function Ur(n,o){var c=-1,m=n.length;for(o||(o=rt(m));++c<m;)o[c]=n[c];return o}function Ki(n,o,c,m){var A=!c;c||(c={});for(var O=-1,H=o.length;++O<H;){var W=o[O],X=m?m(c[W],n[W],W,c,n):e;X===e&&(X=n[W]),A?dn(c,W,X):Oo(c,W,X)}return c}function gy(n,o){return Ki(n,ch(n),o)}function my(n,o){return Ki(n,y0(n),o)}function cc(n,o){return function(c,m){var A=ie(c)?_m:Lv,O=o?o():{};return A(c,n,jt(m,2),O)}}function Ks(n){return he(function(o,c){var m=-1,A=c.length,O=A>1?c[A-1]:e,H=A>2?c[2]:e;for(O=n.length>3&&typeof O=="function"?(A--,O):e,H&&Dr(c[0],c[1],H)&&(O=A<3?e:O,A=1),o=qe(o);++m<A;){var W=c[m];W&&n(o,W,m,O)}return o})}function o0(n,o){return function(c,m){if(c==null)return c;if(!Br(c))return n(c,m);for(var A=c.length,O=o?A:-1,H=qe(c);(o?O--:++O<A)&&m(H[O],O,H)!==!1;);return c}}function a0(n){return function(o,c,m){for(var A=-1,O=qe(o),H=m(o),W=H.length;W--;){var X=H[n?W:++A];if(c(O[X],X,O)===!1)break}return o}}function vy(n,o,c){var m=o&G,A=Uo(n);function O(){var H=this&&this!==we&&this instanceof O?A:n;return H.apply(m?c:this,arguments)}return O}function c0(n){return function(o){o=Me(o);var c=Ls(o)?Ci(o):e,m=c?c[0]:o.charAt(0),A=c?jn(c,1).join(""):o.slice(1);return m[n]()+A}}function Vs(n){return function(o){return Du(od(sd(o).replace(Ao,"")),n,"")}}function Uo(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 c=Hs(n.prototype),m=n.apply(c,o);return Ge(m)?m:c}}function yy(n,o,c){var m=Uo(n);function A(){for(var O=arguments.length,H=rt(O),W=O,X=Gs(A);W--;)H[W]=arguments[W];var ot=O<3&&H[0]!==X&&H[O-1]!==X?[]:Fn(H,X);if(O-=ot.length,O<c)return d0(n,o,uc,A.placeholder,e,H,ot,e,e,c-O);var ct=this&&this!==we&&this instanceof A?m:n;return cr(ct,this,H)}return A}function u0(n){return function(o,c,m){var A=qe(o);if(!Br(o)){var O=jt(c,3);o=ur(o),c=function(W){return O(A[W],W,A)}}var H=n(o,c,m);return H>-1?A[O?o[H]:H]:e}}function h0(n){return gn(function(o){var c=o.length,m=c,A=pi.prototype.thru;for(n&&o.reverse();m--;){var O=o[m];if(typeof O!="function")throw new di(u);if(A&&!H&&dc(O)=="wrapper")var H=new pi([],!0)}for(m=H?m:c;++m<c;){O=o[m];var W=dc(O),X=W=="wrapper"?oh(O):e;X&&hh(X[0])&&X[1]==(v|V|$|T)&&!X[4].length&&X[9]==1?H=H[dc(X[0])].apply(H,X[3]):H=O.length==1&&hh(O)?H[W]():H.thru(O)}return function(){var ot=arguments,ct=ot[0];if(H&&ot.length==1&&ie(ct))return H.plant(ct).value();for(var dt=0,vt=c?o[dt].apply(this,ot):ct;++dt<c;)vt=o[dt].call(this,vt);return vt}})}function uc(n,o,c,m,A,O,H,W,X,ot){var ct=o&v,dt=o&G,vt=o&tt,Ft=o&(V|B),kt=o&nt,ue=vt?e:Uo(n);function Ht(){for(var fe=arguments.length,be=rt(fe),Xr=fe;Xr--;)be[Xr]=arguments[Xr];if(Ft)var xr=Gs(Ht),Zr=Pm(be,xr);if(m&&(be=n0(be,m,A,Ft)),O&&(be=s0(be,O,H,Ft)),fe-=Zr,Ft&&fe<ot){var Xe=Fn(be,xr);return d0(n,o,uc,Ht.placeholder,c,be,Xe,W,X,ot-fe)}var Ni=dt?c:this,wn=vt?Ni[n]:n;return fe=be.length,W?be=Ly(be,W):kt&&fe>1&&be.reverse(),ct&&X<fe&&(be.length=X),this&&this!==we&&this instanceof Ht&&(wn=ue||Uo(wn)),wn.apply(Ni,be)}return Ht}function l0(n,o){return function(c,m){return Vv(c,n,o(m),{})}}function hc(n,o){return function(c,m){var A;if(c===e&&m===e)return o;if(c!==e&&(A=c),m!==e){if(A===e)return m;typeof c=="string"||typeof m=="string"?(c=Qr(c),m=Qr(m)):(c=Qf(c),m=Qf(m)),A=n(c,m)}return A}}function rh(n){return gn(function(o){return o=ke(o,Yr(jt())),he(function(c){var m=this;return n(o,function(A){return cr(A,m,c)})})})}function lc(n,o){o=o===e?" ":Qr(o);var c=o.length;if(c<2)return c?Yu(o,n):o;var m=Yu(o,Ja(n/qs(o)));return Ls(o)?jn(Ci(m),0,n).join(""):m.slice(0,n)}function wy(n,o,c,m){var A=o&G,O=Uo(n);function H(){for(var W=-1,X=arguments.length,ot=-1,ct=m.length,dt=rt(ct+X),vt=this&&this!==we&&this instanceof H?O:n;++ot<ct;)dt[ot]=m[ot];for(;X--;)dt[ot++]=arguments[++W];return cr(vt,A?c:this,dt)}return H}function f0(n){return function(o,c,m){return m&&typeof m!="number"&&Dr(o,c,m)&&(c=m=e),o=yn(o),c===e?(c=o,o=0):c=yn(c),m=m===e?o<c?1:-1:yn(m),ny(o,c,m,n)}}function fc(n){return function(o,c){return typeof o=="string"&&typeof c=="string"||(o=yi(o),c=yi(c)),n(o,c)}}function d0(n,o,c,m,A,O,H,W,X,ot){var ct=o&V,dt=ct?H:e,vt=ct?e:H,Ft=ct?O:e,kt=ct?e:O;o|=ct?$:z,o&=~(ct?z:$),o&K||(o&=~(G|tt));var ue=[n,o,A,Ft,dt,kt,vt,W,X,ot],Ht=c.apply(e,ue);return hh(n)&&I0(Ht,ue),Ht.placeholder=m,D0(Ht,n,o)}function ih(n){var o=ir[n];return function(c,m){if(c=yi(c),m=m==null?0:yr(ae(m),292),m&&Df(c)){var A=(Me(c)+"e").split("e"),O=o(A[0]+"e"+(+A[1]+m));return A=(Me(O)+"e").split("e"),+(A[0]+"e"+(+A[1]-m))}return o(c)}}var by=zs&&1/$a(new zs([,-0]))[1]==C?function(n){return new zs(n)}:Ih;function p0(n){return function(o){var c=wr(o);return c==at?Ru(o):c==Bt?Bm(o):Cm(o,n(o))}}function pn(n,o,c,m,A,O,H,W){var X=o&tt;if(!X&&typeof n!="function")throw new di(u);var ot=m?m.length:0;if(ot||(o&=~($|z),m=A=e),H=H===e?H:nr(ae(H),0),W=W===e?W:ae(W),ot-=A?A.length:0,o&z){var ct=m,dt=A;m=A=e}var vt=X?e:oh(n),Ft=[n,o,c,m,A,ct,dt,O,H,W];if(vt&&Fy(Ft,vt),n=Ft[0],o=Ft[1],c=Ft[2],m=Ft[3],A=Ft[4],W=Ft[9]=Ft[9]===e?X?0:n.length:nr(Ft[9]-ot,0),!W&&o&(V|B)&&(o&=~(V|B)),!o||o==G)var kt=vy(n,o,c);else o==V||o==B?kt=yy(n,o,W):(o==$||o==(G|$))&&!A.length?kt=wy(n,o,c,m):kt=uc.apply(e,Ft);var ue=vt?Wf:I0;return D0(ue(kt,Ft),n,o)}function g0(n,o,c,m){return n===e||Oi(n,$s[c])&&!Ne.call(m,c)?o:n}function m0(n,o,c,m,A,O){return Ge(n)&&Ge(o)&&(O.set(o,n),sc(n,o,e,m0,O),O.delete(o)),n}function _y(n){return qo(n)?e:n}function v0(n,o,c,m,A,O){var H=c&P,W=n.length,X=o.length;if(W!=X&&!(H&&X>W))return!1;var ot=O.get(n),ct=O.get(o);if(ot&&ct)return ot==o&&ct==n;var dt=-1,vt=!0,Ft=c&Y?new fs:e;for(O.set(n,o),O.set(o,n);++dt<W;){var kt=n[dt],ue=o[dt];if(m)var Ht=H?m(ue,kt,dt,o,n,O):m(kt,ue,dt,n,o,O);if(Ht!==e){if(Ht)continue;vt=!1;break}if(Ft){if(!xu(o,function(fe,be){if(!Io(Ft,be)&&(kt===fe||A(kt,fe,c,m,O)))return Ft.push(be)})){vt=!1;break}}else if(!(kt===ue||A(kt,ue,c,m,O))){vt=!1;break}}return O.delete(n),O.delete(o),vt}function Ey(n,o,c,m,A,O,H){switch(c){case wt:if(n.byteLength!=o.byteLength||n.byteOffset!=o.byteOffset)return!1;n=n.buffer,o=o.buffer;case Ut:return!(n.byteLength!=o.byteLength||!O(new Ga(n),new Ga(o)));case L:case k:case Mt:return Oi(+n,+o);case F:return n.name==o.name&&n.message==o.message;case xt:case _t:return n==o+"";case at:var W=Ru;case Bt:var X=m&P;if(W||(W=$a),n.size!=o.size&&!X)return!1;var ot=H.get(n);if(ot)return ot==o;m|=Y,H.set(n,o);var ct=v0(W(n),W(o),m,A,O,H);return H.delete(n),ct;case Et:if(Po)return Po.call(n)==Po.call(o)}return!1}function Ay(n,o,c,m,A,O){var H=c&P,W=nh(n),X=W.length,ot=nh(o),ct=ot.length;if(X!=ct&&!H)return!1;for(var dt=X;dt--;){var vt=W[dt];if(!(H?vt in o:Ne.call(o,vt)))return!1}var Ft=O.get(n),kt=O.get(o);if(Ft&&kt)return Ft==o&&kt==n;var ue=!0;O.set(n,o),O.set(o,n);for(var Ht=H;++dt<X;){vt=W[dt];var fe=n[vt],be=o[vt];if(m)var Xr=H?m(be,fe,vt,o,n,O):m(fe,be,vt,n,o,O);if(!(Xr===e?fe===be||A(fe,be,c,m,O):Xr)){ue=!1;break}Ht||(Ht=vt=="constructor")}if(ue&&!Ht){var xr=n.constructor,Zr=o.constructor;xr!=Zr&&"constructor"in n&&"constructor"in o&&!(typeof xr=="function"&&xr instanceof xr&&typeof Zr=="function"&&Zr instanceof Zr)&&(ue=!1)}return O.delete(n),O.delete(o),ue}function gn(n){return fh(A0(n,e,N0),n+"")}function nh(n){return Bf(n,ur,ch)}function sh(n){return Bf(n,Lr,y0)}var oh=Za?function(n){return Za.get(n)}:Ih;function dc(n){for(var o=n.name+"",c=ks[o],m=Ne.call(ks,o)?c.length:0;m--;){var A=c[m],O=A.func;if(O==null||O==n)return A.name}return o}function Gs(n){var o=Ne.call(x,"placeholder")?x:n;return o.placeholder}function jt(){var n=x.iteratee||Ah;return n=n===Ah?jf:n,arguments.length?n(arguments[0],arguments[1]):n}function pc(n,o){var c=n.__data__;return Oy(o)?c[typeof o=="string"?"string":"hash"]:c.map}function ah(n){for(var o=ur(n),c=o.length;c--;){var m=o[c],A=n[m];o[c]=[m,A,_0(A)]}return o}function gs(n,o){var c=Tm(n,o);return qf(c)?c:e}function Sy(n){var o=Ne.call(n,hs),c=n[hs];try{n[hs]=e;var m=!0}catch{}var A=Ka.call(n);return m&&(o?n[hs]=c:delete n[hs]),A}var ch=Fu?function(n){return n==null?[]:(n=qe(n),Rn(Fu(n),function(o){return Sf.call(n,o)}))}:Dh,y0=Fu?function(n){for(var o=[];n;)Tn(o,ch(n)),n=Wa(n);return o}:Dh,wr=Ir;(Uu&&wr(new Uu(new ArrayBuffer(1)))!=wt||xo&&wr(new xo)!=at||Bu&&wr(Bu.resolve())!=Ee||zs&&wr(new zs)!=Bt||Mo&&wr(new Mo)!=yt)&&(wr=function(n){var o=Ir(n),c=o==It?n.constructor:e,m=c?ms(c):"";if(m)switch(m){case ov:return wt;case av:return at;case cv:return Ee;case uv:return Bt;case hv:return yt}return o});function Iy(n,o,c){for(var m=-1,A=c.length;++m<A;){var O=c[m],H=O.size;switch(O.type){case"drop":n+=H;break;case"dropRight":o-=H;break;case"take":o=yr(o,n+H);break;case"takeRight":n=nr(n,o-H);break}}return{start:n,end:o}}function Dy(n){var o=n.match(qt);return o?o[1].split(Te):[]}function w0(n,o,c){o=qn(o,n);for(var m=-1,A=o.length,O=!1;++m<A;){var H=Vi(o[m]);if(!(O=n!=null&&c(n,H)))break;n=n[H]}return O||++m!=A?O:(A=n==null?0:n.length,!!A&&_c(A)&&mn(H,A)&&(ie(n)||vs(n)))}function xy(n){var o=n.length,c=new n.constructor(o);return o&&typeof n[0]=="string"&&Ne.call(n,"index")&&(c.index=n.index,c.input=n.input),c}function b0(n){return typeof n.constructor=="function"&&!Bo(n)?Hs(Wa(n)):{}}function My(n,o,c){var m=n.constructor;switch(o){case Ut:return eh(n);case L:case k:return new m(+n);case wt:return ly(n,c);case Ct:case Lt:case Ot:case Nt:case se:case Tt:case Rt:case Ke:case ce:return r0(n,c);case at:return new m;case Mt:case _t:return new m(n);case xt:return fy(n);case Bt:return new m;case Et:return dy(n)}}function Cy(n,o){var c=o.length;if(!c)return n;var m=c-1;return o[m]=(c>1?"& ":"")+o[m],o=o.join(c>2?", ":" "),n.replace(Qt,`{
38
+ /* [wrapped with `+o+`] */
39
+ `)}function Py(n){return ie(n)||vs(n)||!!(If&&n&&n[If])}function mn(n,o){var c=typeof n;return o=o??R,!!o&&(c=="number"||c!="symbol"&&hi.test(n))&&n>-1&&n%1==0&&n<o}function Dr(n,o,c){if(!Ge(c))return!1;var m=typeof o;return(m=="number"?Br(c)&&mn(o,c.length):m=="string"&&o in c)?Oi(c[o],n):!1}function uh(n,o){if(ie(n))return!1;var c=typeof n;return c=="number"||c=="symbol"||c=="boolean"||n==null||Jr(n)?!0:Jt.test(n)||!Ae.test(n)||o!=null&&n in qe(o)}function Oy(n){var o=typeof n;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?n!=="__proto__":n===null}function hh(n){var o=dc(n),c=x[o];if(typeof c!="function"||!(o in ge.prototype))return!1;if(n===c)return!0;var m=oh(c);return!!m&&n===m[0]}function Ny(n){return!!_f&&_f in n}var Ry=ka?vn:xh;function Bo(n){var o=n&&n.constructor,c=typeof o=="function"&&o.prototype||$s;return n===c}function _0(n){return n===n&&!Ge(n)}function E0(n,o){return function(c){return c==null?!1:c[n]===o&&(o!==e||n in qe(c))}}function Ty(n){var o=wc(n,function(m){return c.size===f&&c.clear(),m}),c=o.cache;return o}function Fy(n,o){var c=n[1],m=o[1],A=c|m,O=A<(G|tt|v),H=m==v&&c==V||m==v&&c==T&&n[7].length<=o[8]||m==(v|T)&&o[7].length<=o[8]&&c==V;if(!(O||H))return n;m&G&&(n[2]=o[2],A|=c&G?0:K);var W=o[3];if(W){var X=n[3];n[3]=X?n0(X,W,o[4]):W,n[4]=X?Fn(n[3],w):o[4]}return W=o[5],W&&(X=n[5],n[5]=X?s0(X,W,o[6]):W,n[6]=X?Fn(n[5],w):o[6]),W=o[7],W&&(n[7]=W),m&v&&(n[8]=n[8]==null?o[8]:yr(n[8],o[8])),n[9]==null&&(n[9]=o[9]),n[0]=o[0],n[1]=A,n}function Uy(n){var o=[];if(n!=null)for(var c in qe(n))o.push(c);return o}function By(n){return Ka.call(n)}function A0(n,o,c){return o=nr(o===e?n.length-1:o,0),function(){for(var m=arguments,A=-1,O=nr(m.length-o,0),H=rt(O);++A<O;)H[A]=m[o+A];A=-1;for(var W=rt(o+1);++A<o;)W[A]=m[A];return W[o]=c(H),cr(n,this,W)}}function S0(n,o){return o.length<2?n:ps(n,mi(o,0,-1))}function Ly(n,o){for(var c=n.length,m=yr(o.length,c),A=Ur(n);m--;){var O=o[m];n[m]=mn(O,c)?A[O]:e}return n}function lh(n,o){if(!(o==="constructor"&&typeof n[o]=="function")&&o!="__proto__")return n[o]}var I0=x0(Wf),Lo=Zm||function(n,o){return we.setTimeout(n,o)},fh=x0(ay);function D0(n,o,c){var m=o+"";return fh(n,Cy(m,qy(Dy(m),c)))}function x0(n){var o=0,c=0;return function(){var m=iv(),A=h-(m-c);if(c=m,A>0){if(++o>=mt)return arguments[0]}else o=0;return n.apply(e,arguments)}}function gc(n,o){var c=-1,m=n.length,A=m-1;for(o=o===e?m:o;++c<o;){var O=Wu(c,A),H=n[O];n[O]=n[c],n[c]=H}return n.length=o,n}var M0=Ty(function(n){var o=[];return n.charCodeAt(0)===46&&o.push(""),n.replace(Xt,function(c,m,A,O){o.push(A?O.replace(xi,"$1"):m||c)}),o});function Vi(n){if(typeof n=="string"||Jr(n))return n;var o=n+"";return o=="0"&&1/n==-C?"-0":o}function ms(n){if(n!=null){try{return Ha.call(n)}catch{}try{return n+""}catch{}}return""}function qy(n,o){return fi(lt,function(c){var m="_."+c[0];o&c[1]&&!qa(n,m)&&n.push(m)}),n.sort()}function C0(n){if(n instanceof ge)return n.clone();var o=new pi(n.__wrapped__,n.__chain__);return o.__actions__=Ur(n.__actions__),o.__index__=n.__index__,o.__values__=n.__values__,o}function jy(n,o,c){(c?Dr(n,o,c):o===e)?o=1:o=nr(ae(o),0);var m=n==null?0:n.length;if(!m||o<1)return[];for(var A=0,O=0,H=rt(Ja(m/o));A<m;)H[O++]=mi(n,A,A+=o);return H}function $y(n){for(var o=-1,c=n==null?0:n.length,m=0,A=[];++o<c;){var O=n[o];O&&(A[m++]=O)}return A}function zy(){var n=arguments.length;if(!n)return[];for(var o=rt(n-1),c=arguments[0],m=n;m--;)o[m-1]=arguments[m];return Tn(ie(c)?Ur(c):[c],fr(o,1))}var ky=he(function(n,o){return Je(n)?No(n,fr(o,1,Je,!0)):[]}),Hy=he(function(n,o){var c=vi(o);return Je(c)&&(c=e),Je(n)?No(n,fr(o,1,Je,!0),jt(c,2)):[]}),Ky=he(function(n,o){var c=vi(o);return Je(c)&&(c=e),Je(n)?No(n,fr(o,1,Je,!0),e,c):[]});function Vy(n,o,c){var m=n==null?0:n.length;return m?(o=c||o===e?1:ae(o),mi(n,o<0?0:o,m)):[]}function Gy(n,o,c){var m=n==null?0:n.length;return m?(o=c||o===e?1:ae(o),o=m-o,mi(n,0,o<0?0:o)):[]}function Wy(n,o){return n&&n.length?ac(n,jt(o,3),!0,!0):[]}function Yy(n,o){return n&&n.length?ac(n,jt(o,3),!0):[]}function Qy(n,o,c,m){var A=n==null?0:n.length;return A?(c&&typeof c!="number"&&Dr(n,o,c)&&(c=0,m=A),zv(n,o,c,m)):[]}function P0(n,o,c){var m=n==null?0:n.length;if(!m)return-1;var A=c==null?0:ae(c);return A<0&&(A=nr(m+A,0)),ja(n,jt(o,3),A)}function O0(n,o,c){var m=n==null?0:n.length;if(!m)return-1;var A=m-1;return c!==e&&(A=ae(c),A=c<0?nr(m+A,0):yr(A,m-1)),ja(n,jt(o,3),A,!0)}function N0(n){var o=n==null?0:n.length;return o?fr(n,1):[]}function Jy(n){var o=n==null?0:n.length;return o?fr(n,C):[]}function Xy(n,o){var c=n==null?0:n.length;return c?(o=o===e?1:ae(o),fr(n,o)):[]}function Zy(n){for(var o=-1,c=n==null?0:n.length,m={};++o<c;){var A=n[o];m[A[0]]=A[1]}return m}function R0(n){return n&&n.length?n[0]:e}function tw(n,o,c){var m=n==null?0:n.length;if(!m)return-1;var A=c==null?0:ae(c);return A<0&&(A=nr(m+A,0)),Bs(n,o,A)}function ew(n){var o=n==null?0:n.length;return o?mi(n,0,-1):[]}var rw=he(function(n){var o=ke(n,Zu);return o.length&&o[0]===n[0]?ku(o):[]}),iw=he(function(n){var o=vi(n),c=ke(n,Zu);return o===vi(c)?o=e:c.pop(),c.length&&c[0]===n[0]?ku(c,jt(o,2)):[]}),nw=he(function(n){var o=vi(n),c=ke(n,Zu);return o=typeof o=="function"?o:e,o&&c.pop(),c.length&&c[0]===n[0]?ku(c,e,o):[]});function sw(n,o){return n==null?"":ev.call(n,o)}function vi(n){var o=n==null?0:n.length;return o?n[o-1]:e}function ow(n,o,c){var m=n==null?0:n.length;if(!m)return-1;var A=m;return c!==e&&(A=ae(c),A=A<0?nr(m+A,0):yr(A,m-1)),o===o?qm(n,o,A):ja(n,df,A,!0)}function aw(n,o){return n&&n.length?Hf(n,ae(o)):e}var cw=he(T0);function T0(n,o){return n&&n.length&&o&&o.length?Gu(n,o):n}function uw(n,o,c){return n&&n.length&&o&&o.length?Gu(n,o,jt(c,2)):n}function hw(n,o,c){return n&&n.length&&o&&o.length?Gu(n,o,e,c):n}var lw=gn(function(n,o){var c=n==null?0:n.length,m=qu(n,o);return Gf(n,ke(o,function(A){return mn(A,c)?+A:A}).sort(i0)),m});function fw(n,o){var c=[];if(!(n&&n.length))return c;var m=-1,A=[],O=n.length;for(o=jt(o,3);++m<O;){var H=n[m];o(H,m,n)&&(c.push(H),A.push(m))}return Gf(n,A),c}function dh(n){return n==null?n:sv.call(n)}function dw(n,o,c){var m=n==null?0:n.length;return m?(c&&typeof c!="number"&&Dr(n,o,c)?(o=0,c=m):(o=o==null?0:ae(o),c=c===e?m:ae(c)),mi(n,o,c)):[]}function pw(n,o){return oc(n,o)}function gw(n,o,c){return Qu(n,o,jt(c,2))}function mw(n,o){var c=n==null?0:n.length;if(c){var m=oc(n,o);if(m<c&&Oi(n[m],o))return m}return-1}function vw(n,o){return oc(n,o,!0)}function yw(n,o,c){return Qu(n,o,jt(c,2),!0)}function ww(n,o){var c=n==null?0:n.length;if(c){var m=oc(n,o,!0)-1;if(Oi(n[m],o))return m}return-1}function bw(n){return n&&n.length?Yf(n):[]}function _w(n,o){return n&&n.length?Yf(n,jt(o,2)):[]}function Ew(n){var o=n==null?0:n.length;return o?mi(n,1,o):[]}function Aw(n,o,c){return n&&n.length?(o=c||o===e?1:ae(o),mi(n,0,o<0?0:o)):[]}function Sw(n,o,c){var m=n==null?0:n.length;return m?(o=c||o===e?1:ae(o),o=m-o,mi(n,o<0?0:o,m)):[]}function Iw(n,o){return n&&n.length?ac(n,jt(o,3),!1,!0):[]}function Dw(n,o){return n&&n.length?ac(n,jt(o,3)):[]}var xw=he(function(n){return Ln(fr(n,1,Je,!0))}),Mw=he(function(n){var o=vi(n);return Je(o)&&(o=e),Ln(fr(n,1,Je,!0),jt(o,2))}),Cw=he(function(n){var o=vi(n);return o=typeof o=="function"?o:e,Ln(fr(n,1,Je,!0),e,o)});function Pw(n){return n&&n.length?Ln(n):[]}function Ow(n,o){return n&&n.length?Ln(n,jt(o,2)):[]}function Nw(n,o){return o=typeof o=="function"?o:e,n&&n.length?Ln(n,e,o):[]}function ph(n){if(!(n&&n.length))return[];var o=0;return n=Rn(n,function(c){if(Je(c))return o=nr(c.length,o),!0}),Ou(o,function(c){return ke(n,Mu(c))})}function F0(n,o){if(!(n&&n.length))return[];var c=ph(n);return o==null?c:ke(c,function(m){return cr(o,e,m)})}var Rw=he(function(n,o){return Je(n)?No(n,o):[]}),Tw=he(function(n){return Xu(Rn(n,Je))}),Fw=he(function(n){var o=vi(n);return Je(o)&&(o=e),Xu(Rn(n,Je),jt(o,2))}),Uw=he(function(n){var o=vi(n);return o=typeof o=="function"?o:e,Xu(Rn(n,Je),e,o)}),Bw=he(ph);function Lw(n,o){return Zf(n||[],o||[],Oo)}function qw(n,o){return Zf(n||[],o||[],Fo)}var jw=he(function(n){var o=n.length,c=o>1?n[o-1]:e;return c=typeof c=="function"?(n.pop(),c):e,F0(n,c)});function U0(n){var o=x(n);return o.__chain__=!0,o}function $w(n,o){return o(n),n}function mc(n,o){return o(n)}var zw=gn(function(n){var o=n.length,c=o?n[0]:0,m=this.__wrapped__,A=function(O){return qu(O,n)};return o>1||this.__actions__.length||!(m instanceof ge)||!mn(c)?this.thru(A):(m=m.slice(c,+c+(o?1:0)),m.__actions__.push({func:mc,args:[A],thisArg:e}),new pi(m,this.__chain__).thru(function(O){return o&&!O.length&&O.push(e),O}))});function kw(){return U0(this)}function Hw(){return new pi(this.value(),this.__chain__)}function Kw(){this.__values__===e&&(this.__values__=Q0(this.value()));var n=this.__index__>=this.__values__.length,o=n?e:this.__values__[this.__index__++];return{done:n,value:o}}function Vw(){return this}function Gw(n){for(var o,c=this;c instanceof ec;){var m=C0(c);m.__index__=0,m.__values__=e,o?A.__wrapped__=m:o=m;var A=m;c=c.__wrapped__}return A.__wrapped__=n,o}function Ww(){var n=this.__wrapped__;if(n instanceof ge){var o=n;return this.__actions__.length&&(o=new ge(this)),o=o.reverse(),o.__actions__.push({func:mc,args:[dh],thisArg:e}),new pi(o,this.__chain__)}return this.thru(dh)}function Yw(){return Xf(this.__wrapped__,this.__actions__)}var Qw=cc(function(n,o,c){Ne.call(n,c)?++n[c]:dn(n,c,1)});function Jw(n,o,c){var m=ie(n)?lf:$v;return c&&Dr(n,o,c)&&(o=e),m(n,jt(o,3))}function Xw(n,o){var c=ie(n)?Rn:Ff;return c(n,jt(o,3))}var Zw=u0(P0),tb=u0(O0);function eb(n,o){return fr(vc(n,o),1)}function rb(n,o){return fr(vc(n,o),C)}function ib(n,o,c){return c=c===e?1:ae(c),fr(vc(n,o),c)}function B0(n,o){var c=ie(n)?fi:Bn;return c(n,jt(o,3))}function L0(n,o){var c=ie(n)?Em:Tf;return c(n,jt(o,3))}var nb=cc(function(n,o,c){Ne.call(n,c)?n[c].push(o):dn(n,c,[o])});function sb(n,o,c,m){n=Br(n)?n:Ys(n),c=c&&!m?ae(c):0;var A=n.length;return c<0&&(c=nr(A+c,0)),Ec(n)?c<=A&&n.indexOf(o,c)>-1:!!A&&Bs(n,o,c)>-1}var ob=he(function(n,o,c){var m=-1,A=typeof o=="function",O=Br(n)?rt(n.length):[];return Bn(n,function(H){O[++m]=A?cr(o,H,c):Ro(H,o,c)}),O}),ab=cc(function(n,o,c){dn(n,c,o)});function vc(n,o){var c=ie(n)?ke:$f;return c(n,jt(o,3))}function cb(n,o,c,m){return n==null?[]:(ie(o)||(o=o==null?[]:[o]),c=m?e:c,ie(c)||(c=c==null?[]:[c]),Kf(n,o,c))}var ub=cc(function(n,o,c){n[c?0:1].push(o)},function(){return[[],[]]});function hb(n,o,c){var m=ie(n)?Du:gf,A=arguments.length<3;return m(n,jt(o,4),c,A,Bn)}function lb(n,o,c){var m=ie(n)?Am:gf,A=arguments.length<3;return m(n,jt(o,4),c,A,Tf)}function fb(n,o){var c=ie(n)?Rn:Ff;return c(n,bc(jt(o,3)))}function db(n){var o=ie(n)?Pf:sy;return o(n)}function pb(n,o,c){(c?Dr(n,o,c):o===e)?o=1:o=ae(o);var m=ie(n)?Uv:oy;return m(n,o)}function gb(n){var o=ie(n)?Bv:cy;return o(n)}function mb(n){if(n==null)return 0;if(Br(n))return Ec(n)?qs(n):n.length;var o=wr(n);return o==at||o==Bt?n.size:Ku(n).length}function vb(n,o,c){var m=ie(n)?xu:uy;return c&&Dr(n,o,c)&&(o=e),m(n,jt(o,3))}var yb=he(function(n,o){if(n==null)return[];var c=o.length;return c>1&&Dr(n,o[0],o[1])?o=[]:c>2&&Dr(o[0],o[1],o[2])&&(o=[o[0]]),Kf(n,fr(o,1),[])}),yc=Xm||function(){return we.Date.now()};function wb(n,o){if(typeof o!="function")throw new di(u);return n=ae(n),function(){if(--n<1)return o.apply(this,arguments)}}function q0(n,o,c){return o=c?e:o,o=n&&o==null?n.length:o,pn(n,v,e,e,e,e,o)}function j0(n,o){var c;if(typeof o!="function")throw new di(u);return n=ae(n),function(){return--n>0&&(c=o.apply(this,arguments)),n<=1&&(o=e),c}}var gh=he(function(n,o,c){var m=G;if(c.length){var A=Fn(c,Gs(gh));m|=$}return pn(n,m,o,c,A)}),$0=he(function(n,o,c){var m=G|tt;if(c.length){var A=Fn(c,Gs($0));m|=$}return pn(o,m,n,c,A)});function z0(n,o,c){o=c?e:o;var m=pn(n,V,e,e,e,e,e,o);return m.placeholder=z0.placeholder,m}function k0(n,o,c){o=c?e:o;var m=pn(n,B,e,e,e,e,e,o);return m.placeholder=k0.placeholder,m}function H0(n,o,c){var m,A,O,H,W,X,ot=0,ct=!1,dt=!1,vt=!0;if(typeof n!="function")throw new di(u);o=yi(o)||0,Ge(c)&&(ct=!!c.leading,dt="maxWait"in c,O=dt?nr(yi(c.maxWait)||0,o):O,vt="trailing"in c?!!c.trailing:vt);function Ft(Xe){var Ni=m,wn=A;return m=A=e,ot=Xe,H=n.apply(wn,Ni),H}function kt(Xe){return ot=Xe,W=Lo(fe,o),ct?Ft(Xe):H}function ue(Xe){var Ni=Xe-X,wn=Xe-ot,ud=o-Ni;return dt?yr(ud,O-wn):ud}function Ht(Xe){var Ni=Xe-X,wn=Xe-ot;return X===e||Ni>=o||Ni<0||dt&&wn>=O}function fe(){var Xe=yc();if(Ht(Xe))return be(Xe);W=Lo(fe,ue(Xe))}function be(Xe){return W=e,vt&&m?Ft(Xe):(m=A=e,H)}function Xr(){W!==e&&t0(W),ot=0,m=X=A=W=e}function xr(){return W===e?H:be(yc())}function Zr(){var Xe=yc(),Ni=Ht(Xe);if(m=arguments,A=this,X=Xe,Ni){if(W===e)return kt(X);if(dt)return t0(W),W=Lo(fe,o),Ft(X)}return W===e&&(W=Lo(fe,o)),H}return Zr.cancel=Xr,Zr.flush=xr,Zr}var bb=he(function(n,o){return Rf(n,1,o)}),_b=he(function(n,o,c){return Rf(n,yi(o)||0,c)});function Eb(n){return pn(n,nt)}function wc(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new di(u);var c=function(){var m=arguments,A=o?o.apply(this,m):m[0],O=c.cache;if(O.has(A))return O.get(A);var H=n.apply(this,m);return c.cache=O.set(A,H)||O,H};return c.cache=new(wc.Cache||fn),c}wc.Cache=fn;function bc(n){if(typeof n!="function")throw new di(u);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 Ab(n){return j0(2,n)}var Sb=hy(function(n,o){o=o.length==1&&ie(o[0])?ke(o[0],Yr(jt())):ke(fr(o,1),Yr(jt()));var c=o.length;return he(function(m){for(var A=-1,O=yr(m.length,c);++A<O;)m[A]=o[A].call(this,m[A]);return cr(n,this,m)})}),mh=he(function(n,o){var c=Fn(o,Gs(mh));return pn(n,$,e,o,c)}),K0=he(function(n,o){var c=Fn(o,Gs(K0));return pn(n,z,e,o,c)}),Ib=gn(function(n,o){return pn(n,T,e,e,e,o)});function Db(n,o){if(typeof n!="function")throw new di(u);return o=o===e?o:ae(o),he(n,o)}function xb(n,o){if(typeof n!="function")throw new di(u);return o=o==null?0:nr(ae(o),0),he(function(c){var m=c[o],A=jn(c,0,o);return m&&Tn(A,m),cr(n,this,A)})}function Mb(n,o,c){var m=!0,A=!0;if(typeof n!="function")throw new di(u);return Ge(c)&&(m="leading"in c?!!c.leading:m,A="trailing"in c?!!c.trailing:A),H0(n,o,{leading:m,maxWait:o,trailing:A})}function Cb(n){return q0(n,1)}function Pb(n,o){return mh(th(o),n)}function Ob(){if(!arguments.length)return[];var n=arguments[0];return ie(n)?n:[n]}function Nb(n){return gi(n,D)}function Rb(n,o){return o=typeof o=="function"?o:e,gi(n,D,o)}function Tb(n){return gi(n,E|D)}function Fb(n,o){return o=typeof o=="function"?o:e,gi(n,E|D,o)}function Ub(n,o){return o==null||Nf(n,o,ur(o))}function Oi(n,o){return n===o||n!==n&&o!==o}var Bb=fc(zu),Lb=fc(function(n,o){return n>=o}),vs=Lf(function(){return arguments}())?Lf:function(n){return We(n)&&Ne.call(n,"callee")&&!Sf.call(n,"callee")},ie=rt.isArray,qb=Sr?Yr(Sr):Gv;function Br(n){return n!=null&&_c(n.length)&&!vn(n)}function Je(n){return We(n)&&Br(n)}function jb(n){return n===!0||n===!1||We(n)&&Ir(n)==L}var $n=tv||xh,$b=Mi?Yr(Mi):Wv;function zb(n){return We(n)&&n.nodeType===1&&!qo(n)}function kb(n){if(n==null)return!0;if(Br(n)&&(ie(n)||typeof n=="string"||typeof n.splice=="function"||$n(n)||Ws(n)||vs(n)))return!n.length;var o=wr(n);if(o==at||o==Bt)return!n.size;if(Bo(n))return!Ku(n).length;for(var c in n)if(Ne.call(n,c))return!1;return!0}function Hb(n,o){return To(n,o)}function Kb(n,o,c){c=typeof c=="function"?c:e;var m=c?c(n,o):e;return m===e?To(n,o,e,c):!!m}function vh(n){if(!We(n))return!1;var o=Ir(n);return o==F||o==p||typeof n.message=="string"&&typeof n.name=="string"&&!qo(n)}function Vb(n){return typeof n=="number"&&Df(n)}function vn(n){if(!Ge(n))return!1;var o=Ir(n);return o==et||o==ut||o==U||o==$t}function V0(n){return typeof n=="number"&&n==ae(n)}function _c(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=R}function Ge(n){var o=typeof n;return n!=null&&(o=="object"||o=="function")}function We(n){return n!=null&&typeof n=="object"}var G0=li?Yr(li):Qv;function Gb(n,o){return n===o||Hu(n,o,ah(o))}function Wb(n,o,c){return c=typeof c=="function"?c:e,Hu(n,o,ah(o),c)}function Yb(n){return W0(n)&&n!=+n}function Qb(n){if(Ry(n))throw new ee(a);return qf(n)}function Jb(n){return n===null}function Xb(n){return n==null}function W0(n){return typeof n=="number"||We(n)&&Ir(n)==Mt}function qo(n){if(!We(n)||Ir(n)!=It)return!1;var o=Wa(n);if(o===null)return!0;var c=Ne.call(o,"constructor")&&o.constructor;return typeof c=="function"&&c instanceof c&&Ha.call(c)==Wm}var yh=ki?Yr(ki):Jv;function Zb(n){return V0(n)&&n>=-R&&n<=R}var Y0=So?Yr(So):Xv;function Ec(n){return typeof n=="string"||!ie(n)&&We(n)&&Ir(n)==_t}function Jr(n){return typeof n=="symbol"||We(n)&&Ir(n)==Et}var Ws=us?Yr(us):Zv;function t2(n){return n===e}function e2(n){return We(n)&&wr(n)==yt}function r2(n){return We(n)&&Ir(n)==At}var i2=fc(Vu),n2=fc(function(n,o){return n<=o});function Q0(n){if(!n)return[];if(Br(n))return Ec(n)?Ci(n):Ur(n);if(Do&&n[Do])return Um(n[Do]());var o=wr(n),c=o==at?Ru:o==Bt?$a:Ys;return c(n)}function yn(n){if(!n)return n===0?n:0;if(n=yi(n),n===C||n===-C){var o=n<0?-1:1;return o*j}return n===n?n:0}function ae(n){var o=yn(n),c=o%1;return o===o?c?o-c:o:0}function J0(n){return n?ds(ae(n),0,g):0}function yi(n){if(typeof n=="number")return n;if(Jr(n))return S;if(Ge(n)){var o=typeof n.valueOf=="function"?n.valueOf():n;n=Ge(o)?o+"":o}if(typeof n!="string")return n===0?n:+n;n=mf(n);var c=ai.test(n);return c||ui.test(n)?re(n.slice(2),c?2:8):oi.test(n)?S:+n}function X0(n){return Ki(n,Lr(n))}function s2(n){return n?ds(ae(n),-R,R):n===0?n:0}function Me(n){return n==null?"":Qr(n)}var o2=Ks(function(n,o){if(Bo(o)||Br(o)){Ki(o,ur(o),n);return}for(var c in o)Ne.call(o,c)&&Oo(n,c,o[c])}),Z0=Ks(function(n,o){Ki(o,Lr(o),n)}),Ac=Ks(function(n,o,c,m){Ki(o,Lr(o),n,m)}),a2=Ks(function(n,o,c,m){Ki(o,ur(o),n,m)}),c2=gn(qu);function u2(n,o){var c=Hs(n);return o==null?c:Of(c,o)}var h2=he(function(n,o){n=qe(n);var c=-1,m=o.length,A=m>2?o[2]:e;for(A&&Dr(o[0],o[1],A)&&(m=1);++c<m;)for(var O=o[c],H=Lr(O),W=-1,X=H.length;++W<X;){var ot=H[W],ct=n[ot];(ct===e||Oi(ct,$s[ot])&&!Ne.call(n,ot))&&(n[ot]=O[ot])}return n}),l2=he(function(n){return n.push(e,m0),cr(td,e,n)});function f2(n,o){return ff(n,jt(o,3),Hi)}function d2(n,o){return ff(n,jt(o,3),$u)}function p2(n,o){return n==null?n:ju(n,jt(o,3),Lr)}function g2(n,o){return n==null?n:Uf(n,jt(o,3),Lr)}function m2(n,o){return n&&Hi(n,jt(o,3))}function v2(n,o){return n&&$u(n,jt(o,3))}function y2(n){return n==null?[]:nc(n,ur(n))}function w2(n){return n==null?[]:nc(n,Lr(n))}function wh(n,o,c){var m=n==null?e:ps(n,o);return m===e?c:m}function b2(n,o){return n!=null&&w0(n,o,kv)}function bh(n,o){return n!=null&&w0(n,o,Hv)}var _2=l0(function(n,o,c){o!=null&&typeof o.toString!="function"&&(o=Ka.call(o)),n[o]=c},Eh(qr)),E2=l0(function(n,o,c){o!=null&&typeof o.toString!="function"&&(o=Ka.call(o)),Ne.call(n,o)?n[o].push(c):n[o]=[c]},jt),A2=he(Ro);function ur(n){return Br(n)?Cf(n):Ku(n)}function Lr(n){return Br(n)?Cf(n,!0):ty(n)}function S2(n,o){var c={};return o=jt(o,3),Hi(n,function(m,A,O){dn(c,o(m,A,O),m)}),c}function I2(n,o){var c={};return o=jt(o,3),Hi(n,function(m,A,O){dn(c,A,o(m,A,O))}),c}var D2=Ks(function(n,o,c){sc(n,o,c)}),td=Ks(function(n,o,c,m){sc(n,o,c,m)}),x2=gn(function(n,o){var c={};if(n==null)return c;var m=!1;o=ke(o,function(O){return O=qn(O,n),m||(m=O.length>1),O}),Ki(n,sh(n),c),m&&(c=gi(c,E|I|D,_y));for(var A=o.length;A--;)Ju(c,o[A]);return c});function M2(n,o){return ed(n,bc(jt(o)))}var C2=gn(function(n,o){return n==null?{}:ry(n,o)});function ed(n,o){if(n==null)return{};var c=ke(sh(n),function(m){return[m]});return o=jt(o),Vf(n,c,function(m,A){return o(m,A[0])})}function P2(n,o,c){o=qn(o,n);var m=-1,A=o.length;for(A||(A=1,n=e);++m<A;){var O=n==null?e:n[Vi(o[m])];O===e&&(m=A,O=c),n=vn(O)?O.call(n):O}return n}function O2(n,o,c){return n==null?n:Fo(n,o,c)}function N2(n,o,c,m){return m=typeof m=="function"?m:e,n==null?n:Fo(n,o,c,m)}var rd=p0(ur),id=p0(Lr);function R2(n,o,c){var m=ie(n),A=m||$n(n)||Ws(n);if(o=jt(o,4),c==null){var O=n&&n.constructor;A?c=m?new O:[]:Ge(n)?c=vn(O)?Hs(Wa(n)):{}:c={}}return(A?fi:Hi)(n,function(H,W,X){return o(c,H,W,X)}),c}function T2(n,o){return n==null?!0:Ju(n,o)}function F2(n,o,c){return n==null?n:Jf(n,o,th(c))}function U2(n,o,c,m){return m=typeof m=="function"?m:e,n==null?n:Jf(n,o,th(c),m)}function Ys(n){return n==null?[]:Nu(n,ur(n))}function B2(n){return n==null?[]:Nu(n,Lr(n))}function L2(n,o,c){return c===e&&(c=o,o=e),c!==e&&(c=yi(c),c=c===c?c:0),o!==e&&(o=yi(o),o=o===o?o:0),ds(yi(n),o,c)}function q2(n,o,c){return o=yn(o),c===e?(c=o,o=0):c=yn(c),n=yi(n),Kv(n,o,c)}function j2(n,o,c){if(c&&typeof c!="boolean"&&Dr(n,o,c)&&(o=c=e),c===e&&(typeof o=="boolean"?(c=o,o=e):typeof n=="boolean"&&(c=n,n=e)),n===e&&o===e?(n=0,o=1):(n=yn(n),o===e?(o=n,n=0):o=yn(o)),n>o){var m=n;n=o,o=m}if(c||n%1||o%1){var A=xf();return yr(n+A*(o-n+Be("1e-"+((A+"").length-1))),o)}return Wu(n,o)}var $2=Vs(function(n,o,c){return o=o.toLowerCase(),n+(c?nd(o):o)});function nd(n){return _h(Me(n).toLowerCase())}function sd(n){return n=Me(n),n&&n.replace(ar,Om).replace(Au,"")}function z2(n,o,c){n=Me(n),o=Qr(o);var m=n.length;c=c===e?m:ds(ae(c),0,m);var A=c;return c-=o.length,c>=0&&n.slice(c,A)==o}function k2(n){return n=Me(n),n&&zt.test(n)?n.replace(Er,Nm):n}function H2(n){return n=Me(n),n&&Zt.test(n)?n.replace(xe,"\\$&"):n}var K2=Vs(function(n,o,c){return n+(c?"-":"")+o.toLowerCase()}),V2=Vs(function(n,o,c){return n+(c?" ":"")+o.toLowerCase()}),G2=c0("toLowerCase");function W2(n,o,c){n=Me(n),o=ae(o);var m=o?qs(n):0;if(!o||m>=o)return n;var A=(o-m)/2;return lc(Xa(A),c)+n+lc(Ja(A),c)}function Y2(n,o,c){n=Me(n),o=ae(o);var m=o?qs(n):0;return o&&m<o?n+lc(o-m,c):n}function Q2(n,o,c){n=Me(n),o=ae(o);var m=o?qs(n):0;return o&&m<o?lc(o-m,c)+n:n}function J2(n,o,c){return c||o==null?o=0:o&&(o=+o),nv(Me(n).replace(Yt,""),o||0)}function X2(n,o,c){return(c?Dr(n,o,c):o===e)?o=1:o=ae(o),Yu(Me(n),o)}function Z2(){var n=arguments,o=Me(n[0]);return n.length<3?o:o.replace(n[1],n[2])}var t3=Vs(function(n,o,c){return n+(c?"_":"")+o.toLowerCase()});function e3(n,o,c){return c&&typeof c!="number"&&Dr(n,o,c)&&(o=c=e),c=c===e?g:c>>>0,c?(n=Me(n),n&&(typeof o=="string"||o!=null&&!yh(o))&&(o=Qr(o),!o&&Ls(n))?jn(Ci(n),0,c):n.split(o,c)):[]}var r3=Vs(function(n,o,c){return n+(c?" ":"")+_h(o)});function i3(n,o,c){return n=Me(n),c=c==null?0:ds(ae(c),0,n.length),o=Qr(o),n.slice(c,c+o.length)==o}function n3(n,o,c){var m=x.templateSettings;c&&Dr(n,o,c)&&(o=e),n=Me(n),o=Ac({},o,m,g0);var A=Ac({},o.imports,m.imports,g0),O=ur(A),H=Nu(A,O),W,X,ot=0,ct=o.interpolate||qi,dt="__p += '",vt=Tu((o.escape||qi).source+"|"+ct.source+"|"+(ct===Kt?Oe:qi).source+"|"+(o.evaluate||qi).source+"|$","g"),Ft="//# sourceURL="+(Ne.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Su+"]")+`
40
+ `;n.replace(vt,function(Ht,fe,be,Xr,xr,Zr){return be||(be=Xr),dt+=n.slice(ot,Zr).replace(Xn,Rm),fe&&(W=!0,dt+=`' +
41
+ __e(`+fe+`) +
42
+ '`),xr&&(X=!0,dt+=`';
43
+ `+xr+`;
44
+ __p += '`),be&&(dt+=`' +
45
+ ((__t = (`+be+`)) == null ? '' : __t) +
46
+ '`),ot=Zr+Ht.length,Ht}),dt+=`';
47
+ `;var kt=Ne.call(o,"variable")&&o.variable;if(!kt)dt=`with (obj) {
48
+ `+dt+`
49
+ }
50
+ `;else if(Pe.test(kt))throw new ee(l);dt=(X?dt.replace(pe,""):dt).replace(Ve,"$1").replace(ye,"$1;"),dt="function("+(kt||"obj")+`) {
51
+ `+(kt?"":`obj || (obj = {});
52
+ `)+"var __t, __p = ''"+(W?", __e = _.escape":"")+(X?`, __j = Array.prototype.join;
53
+ function print() { __p += __j.call(arguments, '') }
54
+ `:`;
55
+ `)+dt+`return __p
56
+ }`;var ue=ad(function(){return Se(O,Ft+"return "+dt).apply(e,H)});if(ue.source=dt,vh(ue))throw ue;return ue}function s3(n){return Me(n).toLowerCase()}function o3(n){return Me(n).toUpperCase()}function a3(n,o,c){if(n=Me(n),n&&(c||o===e))return mf(n);if(!n||!(o=Qr(o)))return n;var m=Ci(n),A=Ci(o),O=vf(m,A),H=yf(m,A)+1;return jn(m,O,H).join("")}function c3(n,o,c){if(n=Me(n),n&&(c||o===e))return n.slice(0,bf(n)+1);if(!n||!(o=Qr(o)))return n;var m=Ci(n),A=yf(m,Ci(o))+1;return jn(m,0,A).join("")}function u3(n,o,c){if(n=Me(n),n&&(c||o===e))return n.replace(Yt,"");if(!n||!(o=Qr(o)))return n;var m=Ci(n),A=vf(m,Ci(o));return jn(m,A).join("")}function h3(n,o){var c=ft,m=pt;if(Ge(o)){var A="separator"in o?o.separator:A;c="length"in o?ae(o.length):c,m="omission"in o?Qr(o.omission):m}n=Me(n);var O=n.length;if(Ls(n)){var H=Ci(n);O=H.length}if(c>=O)return n;var W=c-qs(m);if(W<1)return m;var X=H?jn(H,0,W).join(""):n.slice(0,W);if(A===e)return X+m;if(H&&(W+=X.length-W),yh(A)){if(n.slice(W).search(A)){var ot,ct=X;for(A.global||(A=Tu(A.source,Me(le.exec(A))+"g")),A.lastIndex=0;ot=A.exec(ct);)var dt=ot.index;X=X.slice(0,dt===e?W:dt)}}else if(n.indexOf(Qr(A),W)!=W){var vt=X.lastIndexOf(A);vt>-1&&(X=X.slice(0,vt))}return X+m}function l3(n){return n=Me(n),n&&Gt.test(n)?n.replace(_e,jm):n}var f3=Vs(function(n,o,c){return n+(c?" ":"")+o.toUpperCase()}),_h=c0("toUpperCase");function od(n,o,c){return n=Me(n),o=c?e:o,o===e?Fm(n)?km(n):Dm(n):n.match(o)||[]}var ad=he(function(n,o){try{return cr(n,e,o)}catch(c){return vh(c)?c:new ee(c)}}),d3=gn(function(n,o){return fi(o,function(c){c=Vi(c),dn(n,c,gh(n[c],n))}),n});function p3(n){var o=n==null?0:n.length,c=jt();return n=o?ke(n,function(m){if(typeof m[1]!="function")throw new di(u);return[c(m[0]),m[1]]}):[],he(function(m){for(var A=-1;++A<o;){var O=n[A];if(cr(O[0],this,m))return cr(O[1],this,m)}})}function g3(n){return jv(gi(n,E))}function Eh(n){return function(){return n}}function m3(n,o){return n==null||n!==n?o:n}var v3=h0(),y3=h0(!0);function qr(n){return n}function Ah(n){return jf(typeof n=="function"?n:gi(n,E))}function w3(n){return zf(gi(n,E))}function b3(n,o){return kf(n,gi(o,E))}var _3=he(function(n,o){return function(c){return Ro(c,n,o)}}),E3=he(function(n,o){return function(c){return Ro(n,c,o)}});function Sh(n,o,c){var m=ur(o),A=nc(o,m);c==null&&!(Ge(o)&&(A.length||!m.length))&&(c=o,o=n,n=this,A=nc(o,ur(o)));var O=!(Ge(c)&&"chain"in c)||!!c.chain,H=vn(n);return fi(A,function(W){var X=o[W];n[W]=X,H&&(n.prototype[W]=function(){var ot=this.__chain__;if(O||ot){var ct=n(this.__wrapped__),dt=ct.__actions__=Ur(this.__actions__);return dt.push({func:X,args:arguments,thisArg:n}),ct.__chain__=ot,ct}return X.apply(n,Tn([this.value()],arguments))})}),n}function A3(){return we._===this&&(we._=Ym),this}function Ih(){}function S3(n){return n=ae(n),he(function(o){return Hf(o,n)})}var I3=rh(ke),D3=rh(lf),x3=rh(xu);function cd(n){return uh(n)?Mu(Vi(n)):iy(n)}function M3(n){return function(o){return n==null?e:ps(n,o)}}var C3=f0(),P3=f0(!0);function Dh(){return[]}function xh(){return!1}function O3(){return{}}function N3(){return""}function R3(){return!0}function T3(n,o){if(n=ae(n),n<1||n>R)return[];var c=g,m=yr(n,g);o=jt(o),n-=g;for(var A=Ou(m,o);++c<n;)o(c);return A}function F3(n){return ie(n)?ke(n,Vi):Jr(n)?[n]:Ur(M0(Me(n)))}function U3(n){var o=++Gm;return Me(n)+o}var B3=hc(function(n,o){return n+o},0),L3=ih("ceil"),q3=hc(function(n,o){return n/o},1),j3=ih("floor");function $3(n){return n&&n.length?ic(n,qr,zu):e}function z3(n,o){return n&&n.length?ic(n,jt(o,2),zu):e}function k3(n){return pf(n,qr)}function H3(n,o){return pf(n,jt(o,2))}function K3(n){return n&&n.length?ic(n,qr,Vu):e}function V3(n,o){return n&&n.length?ic(n,jt(o,2),Vu):e}var G3=hc(function(n,o){return n*o},1),W3=ih("round"),Y3=hc(function(n,o){return n-o},0);function Q3(n){return n&&n.length?Pu(n,qr):0}function J3(n,o){return n&&n.length?Pu(n,jt(o,2)):0}return x.after=wb,x.ary=q0,x.assign=o2,x.assignIn=Z0,x.assignInWith=Ac,x.assignWith=a2,x.at=c2,x.before=j0,x.bind=gh,x.bindAll=d3,x.bindKey=$0,x.castArray=Ob,x.chain=U0,x.chunk=jy,x.compact=$y,x.concat=zy,x.cond=p3,x.conforms=g3,x.constant=Eh,x.countBy=Qw,x.create=u2,x.curry=z0,x.curryRight=k0,x.debounce=H0,x.defaults=h2,x.defaultsDeep=l2,x.defer=bb,x.delay=_b,x.difference=ky,x.differenceBy=Hy,x.differenceWith=Ky,x.drop=Vy,x.dropRight=Gy,x.dropRightWhile=Wy,x.dropWhile=Yy,x.fill=Qy,x.filter=Xw,x.flatMap=eb,x.flatMapDeep=rb,x.flatMapDepth=ib,x.flatten=N0,x.flattenDeep=Jy,x.flattenDepth=Xy,x.flip=Eb,x.flow=v3,x.flowRight=y3,x.fromPairs=Zy,x.functions=y2,x.functionsIn=w2,x.groupBy=nb,x.initial=ew,x.intersection=rw,x.intersectionBy=iw,x.intersectionWith=nw,x.invert=_2,x.invertBy=E2,x.invokeMap=ob,x.iteratee=Ah,x.keyBy=ab,x.keys=ur,x.keysIn=Lr,x.map=vc,x.mapKeys=S2,x.mapValues=I2,x.matches=w3,x.matchesProperty=b3,x.memoize=wc,x.merge=D2,x.mergeWith=td,x.method=_3,x.methodOf=E3,x.mixin=Sh,x.negate=bc,x.nthArg=S3,x.omit=x2,x.omitBy=M2,x.once=Ab,x.orderBy=cb,x.over=I3,x.overArgs=Sb,x.overEvery=D3,x.overSome=x3,x.partial=mh,x.partialRight=K0,x.partition=ub,x.pick=C2,x.pickBy=ed,x.property=cd,x.propertyOf=M3,x.pull=cw,x.pullAll=T0,x.pullAllBy=uw,x.pullAllWith=hw,x.pullAt=lw,x.range=C3,x.rangeRight=P3,x.rearg=Ib,x.reject=fb,x.remove=fw,x.rest=Db,x.reverse=dh,x.sampleSize=pb,x.set=O2,x.setWith=N2,x.shuffle=gb,x.slice=dw,x.sortBy=yb,x.sortedUniq=bw,x.sortedUniqBy=_w,x.split=e3,x.spread=xb,x.tail=Ew,x.take=Aw,x.takeRight=Sw,x.takeRightWhile=Iw,x.takeWhile=Dw,x.tap=$w,x.throttle=Mb,x.thru=mc,x.toArray=Q0,x.toPairs=rd,x.toPairsIn=id,x.toPath=F3,x.toPlainObject=X0,x.transform=R2,x.unary=Cb,x.union=xw,x.unionBy=Mw,x.unionWith=Cw,x.uniq=Pw,x.uniqBy=Ow,x.uniqWith=Nw,x.unset=T2,x.unzip=ph,x.unzipWith=F0,x.update=F2,x.updateWith=U2,x.values=Ys,x.valuesIn=B2,x.without=Rw,x.words=od,x.wrap=Pb,x.xor=Tw,x.xorBy=Fw,x.xorWith=Uw,x.zip=Bw,x.zipObject=Lw,x.zipObjectDeep=qw,x.zipWith=jw,x.entries=rd,x.entriesIn=id,x.extend=Z0,x.extendWith=Ac,Sh(x,x),x.add=B3,x.attempt=ad,x.camelCase=$2,x.capitalize=nd,x.ceil=L3,x.clamp=L2,x.clone=Nb,x.cloneDeep=Tb,x.cloneDeepWith=Fb,x.cloneWith=Rb,x.conformsTo=Ub,x.deburr=sd,x.defaultTo=m3,x.divide=q3,x.endsWith=z2,x.eq=Oi,x.escape=k2,x.escapeRegExp=H2,x.every=Jw,x.find=Zw,x.findIndex=P0,x.findKey=f2,x.findLast=tb,x.findLastIndex=O0,x.findLastKey=d2,x.floor=j3,x.forEach=B0,x.forEachRight=L0,x.forIn=p2,x.forInRight=g2,x.forOwn=m2,x.forOwnRight=v2,x.get=wh,x.gt=Bb,x.gte=Lb,x.has=b2,x.hasIn=bh,x.head=R0,x.identity=qr,x.includes=sb,x.indexOf=tw,x.inRange=q2,x.invoke=A2,x.isArguments=vs,x.isArray=ie,x.isArrayBuffer=qb,x.isArrayLike=Br,x.isArrayLikeObject=Je,x.isBoolean=jb,x.isBuffer=$n,x.isDate=$b,x.isElement=zb,x.isEmpty=kb,x.isEqual=Hb,x.isEqualWith=Kb,x.isError=vh,x.isFinite=Vb,x.isFunction=vn,x.isInteger=V0,x.isLength=_c,x.isMap=G0,x.isMatch=Gb,x.isMatchWith=Wb,x.isNaN=Yb,x.isNative=Qb,x.isNil=Xb,x.isNull=Jb,x.isNumber=W0,x.isObject=Ge,x.isObjectLike=We,x.isPlainObject=qo,x.isRegExp=yh,x.isSafeInteger=Zb,x.isSet=Y0,x.isString=Ec,x.isSymbol=Jr,x.isTypedArray=Ws,x.isUndefined=t2,x.isWeakMap=e2,x.isWeakSet=r2,x.join=sw,x.kebabCase=K2,x.last=vi,x.lastIndexOf=ow,x.lowerCase=V2,x.lowerFirst=G2,x.lt=i2,x.lte=n2,x.max=$3,x.maxBy=z3,x.mean=k3,x.meanBy=H3,x.min=K3,x.minBy=V3,x.stubArray=Dh,x.stubFalse=xh,x.stubObject=O3,x.stubString=N3,x.stubTrue=R3,x.multiply=G3,x.nth=aw,x.noConflict=A3,x.noop=Ih,x.now=yc,x.pad=W2,x.padEnd=Y2,x.padStart=Q2,x.parseInt=J2,x.random=j2,x.reduce=hb,x.reduceRight=lb,x.repeat=X2,x.replace=Z2,x.result=P2,x.round=W3,x.runInContext=J,x.sample=db,x.size=mb,x.snakeCase=t3,x.some=vb,x.sortedIndex=pw,x.sortedIndexBy=gw,x.sortedIndexOf=mw,x.sortedLastIndex=vw,x.sortedLastIndexBy=yw,x.sortedLastIndexOf=ww,x.startCase=r3,x.startsWith=i3,x.subtract=Y3,x.sum=Q3,x.sumBy=J3,x.template=n3,x.times=T3,x.toFinite=yn,x.toInteger=ae,x.toLength=J0,x.toLower=s3,x.toNumber=yi,x.toSafeInteger=s2,x.toString=Me,x.toUpper=o3,x.trim=a3,x.trimEnd=c3,x.trimStart=u3,x.truncate=h3,x.unescape=l3,x.uniqueId=U3,x.upperCase=f3,x.upperFirst=_h,x.each=B0,x.eachRight=L0,x.first=R0,Sh(x,function(){var n={};return Hi(x,function(o,c){Ne.call(x.prototype,c)||(n[c]=o)}),n}(),{chain:!1}),x.VERSION=i,fi(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){x[n].placeholder=x}),fi(["drop","take"],function(n,o){ge.prototype[n]=function(c){c=c===e?1:nr(ae(c),0);var m=this.__filtered__&&!o?new ge(this):this.clone();return m.__filtered__?m.__takeCount__=yr(c,m.__takeCount__):m.__views__.push({size:yr(c,g),type:n+(m.__dir__<0?"Right":"")}),m},ge.prototype[n+"Right"]=function(c){return this.reverse()[n](c).reverse()}}),fi(["filter","map","takeWhile"],function(n,o){var c=o+1,m=c==y||c==M;ge.prototype[n]=function(A){var O=this.clone();return O.__iteratees__.push({iteratee:jt(A,3),type:c}),O.__filtered__=O.__filtered__||m,O}}),fi(["head","last"],function(n,o){var c="take"+(o?"Right":"");ge.prototype[n]=function(){return this[c](1).value()[0]}}),fi(["initial","tail"],function(n,o){var c="drop"+(o?"":"Right");ge.prototype[n]=function(){return this.__filtered__?new ge(this):this[c](1)}}),ge.prototype.compact=function(){return this.filter(qr)},ge.prototype.find=function(n){return this.filter(n).head()},ge.prototype.findLast=function(n){return this.reverse().find(n)},ge.prototype.invokeMap=he(function(n,o){return typeof n=="function"?new ge(this):this.map(function(c){return Ro(c,n,o)})}),ge.prototype.reject=function(n){return this.filter(bc(jt(n)))},ge.prototype.slice=function(n,o){n=ae(n);var c=this;return c.__filtered__&&(n>0||o<0)?new ge(c):(n<0?c=c.takeRight(-n):n&&(c=c.drop(n)),o!==e&&(o=ae(o),c=o<0?c.dropRight(-o):c.take(o-n)),c)},ge.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},ge.prototype.toArray=function(){return this.take(g)},Hi(ge.prototype,function(n,o){var c=/^(?:filter|find|map|reject)|While$/.test(o),m=/^(?:head|last)$/.test(o),A=x[m?"take"+(o=="last"?"Right":""):o],O=m||/^find/.test(o);A&&(x.prototype[o]=function(){var H=this.__wrapped__,W=m?[1]:arguments,X=H instanceof ge,ot=W[0],ct=X||ie(H),dt=function(fe){var be=A.apply(x,Tn([fe],W));return m&&vt?be[0]:be};ct&&c&&typeof ot=="function"&&ot.length!=1&&(X=ct=!1);var vt=this.__chain__,Ft=!!this.__actions__.length,kt=O&&!vt,ue=X&&!Ft;if(!O&&ct){H=ue?H:new ge(this);var Ht=n.apply(H,W);return Ht.__actions__.push({func:mc,args:[dt],thisArg:e}),new pi(Ht,vt)}return kt&&ue?n.apply(this,W):(Ht=this.thru(dt),kt?m?Ht.value()[0]:Ht.value():Ht)})}),fi(["pop","push","shift","sort","splice","unshift"],function(n){var o=za[n],c=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",m=/^(?:pop|shift)$/.test(n);x.prototype[n]=function(){var A=arguments;if(m&&!this.__chain__){var O=this.value();return o.apply(ie(O)?O:[],A)}return this[c](function(H){return o.apply(ie(H)?H:[],A)})}}),Hi(ge.prototype,function(n,o){var c=x[o];if(c){var m=c.name+"";Ne.call(ks,m)||(ks[m]=[]),ks[m].push({name:o,func:c})}}),ks[uc(e,tt).name]=[{name:"wrapper",func:e}],ge.prototype.clone=lv,ge.prototype.reverse=fv,ge.prototype.value=dv,x.prototype.at=zw,x.prototype.chain=kw,x.prototype.commit=Hw,x.prototype.next=Kw,x.prototype.plant=Gw,x.prototype.reverse=Ww,x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=Yw,x.prototype.first=x.prototype.head,Do&&(x.prototype[Do]=Vw),x},js=Hm();Qe?((Qe.exports=js)._=js,Le._=js):we._=js}).call(Wo)})(Tl,Tl.exports);var w9=Object.defineProperty,b9=Object.defineProperties,_9=Object.getOwnPropertyDescriptors,m1=Object.getOwnPropertySymbols,E9=Object.prototype.hasOwnProperty,A9=Object.prototype.propertyIsEnumerable,v1=(r,t,e)=>t in r?w9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nc=(r,t)=>{for(var e in t||(t={}))E9.call(t,e)&&v1(r,e,t[e]);if(m1)for(var e of m1(t))A9.call(t,e)&&v1(r,e,t[e]);return r},S9=(r,t)=>b9(r,_9(t));function Yn(r,t,e){var i;const s=Fc(r);return((i=t.rpcMap)==null?void 0:i[s.reference])||`${y9}?chainId=${s.namespace}:${s.reference}&projectId=${e}`}function Ns(r){return r.includes(":")?r.split(":")[1]:r}function wm(r){return r.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function I9(r,t){const e=Object.keys(t.namespaces).filter(s=>s.includes(r));if(!e.length)return[];const i=[];return e.forEach(s=>{const a=t.namespaces[s].accounts;i.push(...a)}),i}function nl(r={},t={}){const e=y1(r),i=y1(t);return Tl.exports.merge(e,i)}function y1(r){var t,e,i,s;const a={};if(!oa(r))return a;for(const[u,l]of Object.entries(r)){const d=Zl(u)?[u]:l.chains,f=l.methods||[],w=l.events||[],E=l.rpcMap||{},I=Jo(u);a[I]=S9(Nc(Nc({},a[I]),l),{chains:Uc(d,(t=a[I])==null?void 0:t.chains),methods:Uc(f,(e=a[I])==null?void 0:e.methods),events:Uc(w,(i=a[I])==null?void 0:i.events),rpcMap:Nc(Nc({},E),(s=a[I])==null?void 0:s.rpcMap)})}return a}function D9(r){return r.includes(":")?r.split(":")[2]:r}function w1(r){const t={};for(const[e,i]of Object.entries(r)){const s=i.methods||[],a=i.events||[],u=i.accounts||[],l=Zl(e)?[e]:i.chains?i.chains:wm(i.accounts);t[e]={chains:l,methods:s,events:a,accounts:u}}return t}function sl(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 bm={},He=r=>bm[r],ol=(r,t)=>{bm[r]=t};class x9{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class M9{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const i=e||Yn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=parseInt(Ns(e));t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,i;let s=t.request.params?(e=t.request.params[0])==null?void 0:e.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:t.topic,request:{method:t.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(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class C9{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class P9{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class O9{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const i=this.getCardanoRPCUrl(e),s=Ns(e);t[s]=this.createHttpProvider(s,i)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||this.getCardanoRPCUrl(t);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class N9{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class R9{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const s=Ns(e);t[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new Mn(new Jn(i,He("disableProviderPing")))}}class T9{constructor(t){this.name="near",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const i=e||Yn(`${this.name}:${t}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,i)}this.events.emit(Cn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;t[e]=this.createHttpProvider(e,(i=this.namespace.rpcMap)==null?void 0:i[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i)}createHttpProvider(t,e){const i=e||Yn(t,this.namespace);return typeof i>"u"?void 0:new Mn(new Jn(i,He("disableProviderPing")))}}var F9=Object.defineProperty,U9=Object.defineProperties,B9=Object.getOwnPropertyDescriptors,b1=Object.getOwnPropertySymbols,L9=Object.prototype.hasOwnProperty,q9=Object.prototype.propertyIsEnumerable,_1=(r,t,e)=>t in r?F9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rc=(r,t)=>{for(var e in t||(t={}))L9.call(t,e)&&_1(r,e,t[e]);if(b1)for(var e of b1(t))q9.call(t,e)&&_1(r,e,t[e]);return r},al=(r,t)=>U9(r,B9(t));class uf{constructor(t){this.events=new Ll,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:wa(du({level:(t==null?void 0:t.logger)||p1})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new uf(t);return await e.initialize(),e}async request(t,e,i){const[s,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Rc({},t),chainId:`${s}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(t,e,i,s){const a=new Date().getTime();this.request(t,i,s).then(u=>e(null,pu(a,u))).catch(u=>e(u,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 t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Re("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:i}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const s=await i();if(this.session=s.session,this.session){const a=w1(this.session.namespaces);this.namespaces=nl(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:s}=await this.client.connect({pairingTopic:t,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 u=w1(a.namespaces);this.namespaces=nl(this.namespaces,u),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==ym)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[i,s]=this.validateChain(t);this.getProvider(i).setDefaultChain(s,e)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(cn(e)){for(const i of e)t.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${e.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 t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await cf.init({logger:this.providerOpts.logger||p1,relayUrl:this.providerOpts.relayUrl||g9,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),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 t=[...new Set(Object.keys(this.session.namespaces).map(e=>Jo(e)))];ol("client",this.client),ol("events",this.events),ol("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const i=I9(e,this.session),s=wm(i),a=nl(this.namespaces,this.optionalNamespaces),u=al(Rc({},a[e]),{accounts:i,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new M9({namespace:u});break;case"solana":this.rpcProviders[e]=new C9({namespace:u});break;case"cosmos":this.rpcProviders[e]=new P9({namespace:u});break;case"polkadot":this.rpcProviders[e]=new x9({namespace:u});break;case"cip34":this.rpcProviders[e]=new O9({namespace:u});break;case"elrond":this.rpcProviders[e]=new N9({namespace:u});break;case"multiversx":this.rpcProviders[e]=new R9({namespace:u});break;case"near":this.rpcProviders[e]=new T9({namespace:u});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:i}=e;if(i.name==="accountsChanged"){const s=i.data;s&&cn(s)&&this.events.emit("accountsChanged",s.map(D9))}else if(i.name==="chainChanged"){const s=e.chainId,a=e.event.data,u=Jo(s),l=sl(s)!==sl(a)?`${u}:${sl(a)}`:s;this.onChainChanged(l)}else this.events.emit(i.name,i.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var i;const{namespaces:s}=e,a=(i=this.client)==null?void 0:i.session.get(t);this.session=al(Rc({},a),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",al(Rc({},Re("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Cn.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:i,sessionProperties:s}=t;e&&Object.keys(e).length&&(this.namespaces=e),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.persist("namespaces",e),this.persist("optionalNamespaces",i)}validateChain(t){const[e,i]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,i];if(e&&!Object.keys(this.namespaces||{}).map(u=>Jo(u)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&i)return[e,i];const s=Jo(Object.keys(this.namespaces)[0]),a=this.rpcProviders[s].getDefaultChain();return[s,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(t);s&&(e||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(t,e){this.client.core.storage.setItem(`${g1}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${g1}/${t}`)}}const j9=uf,$9="wc",z9="ethereum_provider",k9=`${$9}@2:${z9}:`,H9="https://rpc.walletconnect.com/v1/",Fl=["eth_sendTransaction","personal_sign"],K9=["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"],Ul=["chainChanged","accountsChanged"],V9=["chainChanged","accountsChanged","message","disconnect","connect"];var G9=Object.defineProperty,W9=Object.defineProperties,Y9=Object.getOwnPropertyDescriptors,E1=Object.getOwnPropertySymbols,Q9=Object.prototype.hasOwnProperty,J9=Object.prototype.propertyIsEnumerable,A1=(r,t,e)=>t in r?G9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ro=(r,t)=>{for(var e in t||(t={}))Q9.call(t,e)&&A1(r,e,t[e]);if(E1)for(var e of E1(t))J9.call(t,e)&&A1(r,e,t[e]);return r},cl=(r,t)=>W9(r,Y9(t));function nu(r){return Number(r[0].split(":")[1])}function Tc(r){return`0x${r.toString(16)}`}function X9(r){const{chains:t,optionalChains:e,methods:i,optionalMethods:s,events:a,optionalEvents:u,rpcMap:l}=r;if(!cn(t))throw new Error("Invalid chains");const d={chains:t,methods:i||Fl,events:a||Ul,rpcMap:ro({},t.length?{[nu(t)]:l[nu(t)]}:{})},f=a==null?void 0:a.filter(D=>!Ul.includes(D)),w=i==null?void 0:i.filter(D=>!Fl.includes(D));if(!e&&!u&&!s&&!(f!=null&&f.length)&&!(w!=null&&w.length))return{required:t.length?d:void 0};const E=(f==null?void 0:f.length)&&(w==null?void 0:w.length)||!e,I={chains:[...new Set(E?d.chains.concat(e||[]):e)],methods:[...new Set(d.methods.concat(s!=null&&s.length?s:K9))],events:[...new Set(d.events.concat(u!=null&&u.length?u:V9))],rpcMap:l};return{required:t.length?d:void 0,optional:e.length?I:void 0}}class hf{constructor(){this.events=new Di.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=k9,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new hf;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,i){this.signer.sendAsync(t,e,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(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:i}=X9(this.rpc);try{const s=await new Promise(async(u,l)=>{var d;this.rpc.showQrModal&&((d=this.modal)==null||d.subscribeModal(f=>{!f.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),l(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(cl(ro({namespaces:ro({},e&&{[this.namespace]:e})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(f=>{u(f)}).catch(f=>{l(new Error(f.message))})});if(!s)return;const a=Nd(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Tc(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(s,a)=>{var u;this.rpc.showQrModal&&((u=this.modal)==null||u.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(cl(ro({},t),{chains:this.rpc.chains})).then(l=>{s(l)}).catch(l=>{a(new Error(l.message))})}),i=e.session;if(i){const s=Nd(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:Tc(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}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",t=>{const{params:e}=t,{event:i}=e;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",t)}),this.signer.on("chainChanged",t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Tc(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",cl(ro({},Re("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,i;this.rpc.showQrModal&&((e=this.modal)==null||e.closeModal(),(i=this.modal)==null||i.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Tc(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,i,s]=t.split(":");return{chainId:`${e}:${i}`,address:s}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,i;const s=(e=t==null?void 0:t.chains)!=null?e:[],a=(i=t==null?void 0:t.optionalChains)!=null?i:[],u=s.concat(a);if(!u.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const l=s.length?(t==null?void 0:t.methods)||Fl:[],d=s.length?(t==null?void 0:t.events)||Ul:[],f=(t==null?void 0:t.optionalMethods)||[],w=(t==null?void 0:t.optionalEvents)||[],E=(t==null?void 0:t.rpcMap)||this.buildRpcMap(u,t.projectId),I=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(D=>this.formatChainId(D)),optionalChains:a.map(D=>this.formatChainId(D)),methods:l,events:d,optionalMethods:f,optionalEvents:w,rpcMap:E,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:I,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const i={};return t.forEach(s=>{i[s]=this.getRpcUrl(s,e)}),i}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?nu(this.rpc.chains):nu(this.rpc.optionalChains),this.signer=await j9.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:i}=await t6(()=>import("./index-0608a65f.js").then(s=>s.i),["assets/index-0608a65f.js","assets/index-25febcc8.js","assets/index-2dd288f5.css"]);e=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(ro({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:i,rpcMap:s}=t;e&&cn(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)})),i&&cn(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(t,e){var i;return((i=this.rpc.rpcMap)==null?void 0:i[t])||`${H9}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(e=>this.parseAccount(e))}}const IM=hf;export{IM as EthereumProvider,V9 as OPTIONAL_EVENTS,K9 as OPTIONAL_METHODS,Ul as REQUIRED_EVENTS,Fl as REQUIRED_METHODS,hf as default};