@walletconnect/utils
Version:
Utilities for WalletConnect Protocol
15 lines (13 loc) • 259 kB
JavaScript
(function(w,ft){typeof exports=="object"&&typeof module<"u"?ft(exports):typeof define=="function"&&define.amd?define(["exports"],ft):(w=typeof globalThis<"u"?globalThis:w||self,ft(w["@walletconnect/utils"]={}))})(this,function(w){"use strict";const ft=":";function ri(e){const[t,n]=e.split(ft);return{namespace:t,reference:n}}function Is(e){const{namespace:t,reference:n}=e;return[t,n].join(ft)}function ii(e){const[t,n,r]=e.split(ft);return{namespace:t,reference:n,address:r}}function Us(e){const{namespace:t,reference:n,address:r}=e;return[t,n,r].join(ft)}function oi(e,t){const n=[];return e.forEach(r=>{const i=t(r);n.includes(i)||n.push(i)}),n}function Os(e){const{address:t}=ii(e);return t}function Cs(e){const{namespace:t,reference:n}=ii(e);return Is({namespace:t,reference:n})}function Jl(e,t){const{namespace:n,reference:r}=ri(t);return Us({namespace:n,reference:r,address:e})}function Ql(e){return oi(e,Os)}function Ts(e){return oi(e,Cs)}function ed(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...i.accounts)}),n}function td(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...Ts(i.accounts))}),n}function nd(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...ar(r,i))}),n}function ar(e,t){return e.includes(":")?[e]:t.chains||[]}var Ns=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))},rd=function(){function e(t,n,r){this.name=t,this.version=n,this.os=r,this.type="browser"}return e}(),id=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),od=function(){function e(t,n,r,i){this.name=t,this.version=n,this.os=r,this.bot=i,this.type="bot-device"}return e}(),sd=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),cd=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),ad=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,fd=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,$s=3,ud=[["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",ad]],Rs=[["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 ld(e){return e?Fs(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new cd:typeof navigator<"u"?Fs(navigator.userAgent):gd()}function dd(e){return e!==""&&ud.reduce(function(t,n){var r=n[0],i=n[1];if(t)return t;var o=i.exec(e);return!!o&&[r,o]},!1)}function Fs(e){var t=dd(e);if(!t)return null;var n=t[0],r=t[1];if(n==="searchbot")return new sd;var i=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);i?i.length<$s&&(i=Ns(Ns([],i,!0),bd($s-i.length),!0)):i=[];var o=i.join("."),s=hd(e),c=fd.exec(e);return c&&c[1]?new od(n,o,s,c[1]):new rd(n,o,s)}function hd(e){for(var t=0,n=Rs.length;t<n;t++){var r=Rs[t],i=r[0],o=r[1],s=o.exec(e);if(s)return i}return null}function gd(){var e=typeof process<"u"&&process.version;return e?new id(process.version.slice(1)):null}function bd(e){for(var t=[],n=0;n<e;n++)t.push("0");return t}function pd(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var Mt={};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var si=function(e,t){return si=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},si(e,t)};function wd(e,t){si(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ci=function(){return ci=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ci.apply(this,arguments)};function yd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function md(e,t,n,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(o=(i<3?s(o):i>3?s(t,n,o):s(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}function Ed(e,t){return function(n,r){t(n,r,e)}}function xd(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function vd(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(f){try{u(r.next(f))}catch(l){s(l)}}function a(f){try{u(r.throw(f))}catch(l){s(l)}}function u(f){f.done?o(f.value):i(f.value).then(c,a)}u((r=r.apply(e,t||[])).next())})}function Dd(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(u){return function(f){return a([u,f])}}function a(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){n.label=u[1];break}if(u[0]===6&&n.label<o[1]){n.label=o[1],o=u;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(u);break}o[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(f){u=[6,f],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Ad(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Bd(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function ai(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ps(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function Sd(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ps(arguments[t]));return e}function _d(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],s=0,c=o.length;s<c;s++,i++)r[i]=o[s];return r}function yn(e){return this instanceof yn?(this.v=e,this):new yn(e)}function Id(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(d){r[d]&&(i[d]=function(b){return new Promise(function(h,g){o.push([d,b,h,g])>1||c(d,b)})})}function c(d,b){try{a(r[d](b))}catch(h){l(o[0][3],h)}}function a(d){d.value instanceof yn?Promise.resolve(d.value.v).then(u,f):l(o[0][2],d)}function u(d){c("next",d)}function f(d){c("throw",d)}function l(d,b){d(b),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ud(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,o){t[i]=e[i]?function(s){return(n=!n)?{value:yn(e[i](s)),done:i==="return"}:o?o(s):s}:o}}function Od(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ai=="function"?ai(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(s){return new Promise(function(c,a){s=e[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(u){o({value:u,done:c})},s)}}function Cd(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Td(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function Nd(e){return e&&e.__esModule?e:{default:e}}function $d(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Rd(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var Fd=Object.freeze({__proto__:null,__extends:wd,get __assign(){return ci},__rest:yd,__decorate:md,__param:Ed,__metadata:xd,__awaiter:vd,__generator:Dd,__createBinding:Ad,__exportStar:Bd,__values:ai,__read:Ps,__spread:Sd,__spreadArrays:_d,__await:yn,__asyncGenerator:Id,__asyncDelegator:Ud,__asyncValues:Od,__makeTemplateObject:Cd,__importStar:Td,__importDefault:Nd,__classPrivateFieldGet:$d,__classPrivateFieldSet:Rd}),fr=pd(Fd),fi={},mn={},Ls;function Pd(){if(Ls)return mn;Ls=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return mn.delay=e,mn}var zt={},ui={},Ht={},ks;function Ld(){return ks||(ks=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.ONE_THOUSAND=Ht.ONE_HUNDRED=void 0,Ht.ONE_HUNDRED=100,Ht.ONE_THOUSAND=1e3),Ht}var li={},Ms;function kd(){return Ms||(Ms=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=e.ONE_MINUTE*5,e.TEN_MINUTES=e.ONE_MINUTE*10,e.THIRTY_MINUTES=e.ONE_MINUTE*30,e.SIXTY_MINUTES=e.ONE_MINUTE*60,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=e.ONE_HOUR*3,e.SIX_HOURS=e.ONE_HOUR*6,e.TWELVE_HOURS=e.ONE_HOUR*12,e.TWENTY_FOUR_HOURS=e.ONE_HOUR*24,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=e.ONE_DAY*3,e.FIVE_DAYS=e.ONE_DAY*5,e.SEVEN_DAYS=e.ONE_DAY*7,e.THIRTY_DAYS=e.ONE_DAY*30,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=e.ONE_WEEK*2,e.THREE_WEEKS=e.ONE_WEEK*3,e.FOUR_WEEKS=e.ONE_WEEK*4,e.ONE_YEAR=e.ONE_DAY*365}(li)),li}var zs;function Hs(){return zs||(zs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(Ld(),e),t.__exportStar(kd(),e)}(ui)),ui}var js;function Md(){if(js)return zt;js=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.fromMiliseconds=zt.toMiliseconds=void 0;const e=Hs();function t(r){return r*e.ONE_THOUSAND}zt.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return zt.fromMiliseconds=n,zt}var Vs;function zd(){return Vs||(Vs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(Pd(),e),t.__exportStar(Md(),e)}(fi)),fi}var tn={},qs;function Hd(){if(qs)return tn;qs=1,Object.defineProperty(tn,"__esModule",{value:!0}),tn.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(n){if(this.timestamps.has(n))throw new Error(`Watch already started for label: ${n}`);this.timestamps.set(n,{started:Date.now()})}stop(n){const r=this.get(n);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${n}`);const i=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:i})}get(n){const r=this.timestamps.get(n);if(typeof r>"u")throw new Error(`No timestamp found for label: ${n}`);return r}elapsed(n){const r=this.get(n);return r.elapsed||Date.now()-r.started}}return tn.Watch=e,tn.default=e,tn}var di={},En={},Ks;function jd(){if(Ks)return En;Ks=1,Object.defineProperty(En,"__esModule",{value:!0}),En.IWatch=void 0;class e{}return En.IWatch=e,En}var Ws;function Vd(){return Ws||(Ws=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),fr.__exportStar(jd(),e)}(di)),di}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(zd(),e),t.__exportStar(Hd(),e),t.__exportStar(Vd(),e),t.__exportStar(Hs(),e)})(Mt);var Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.getLocalStorage=Q.getLocalStorageOrThrow=Q.getCrypto=Q.getCryptoOrThrow=gi=Q.getLocation=Q.getLocationOrThrow=hi=Q.getNavigator=Q.getNavigatorOrThrow=rn=Q.getDocument=Q.getDocumentOrThrow=Q.getFromWindowOrThrow=Q.getFromWindow=void 0;function jt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}Q.getFromWindow=jt;function nn(e){const t=jt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Q.getFromWindowOrThrow=nn;function qd(){return nn("document")}Q.getDocumentOrThrow=qd;function Kd(){return jt("document")}var rn=Q.getDocument=Kd;function Wd(){return nn("navigator")}Q.getNavigatorOrThrow=Wd;function Zd(){return jt("navigator")}var hi=Q.getNavigator=Zd;function Gd(){return nn("location")}Q.getLocationOrThrow=Gd;function Yd(){return jt("location")}var gi=Q.getLocation=Yd;function Xd(){return nn("crypto")}Q.getCryptoOrThrow=Xd;function Jd(){return jt("crypto")}Q.getCrypto=Jd;function Qd(){return nn("localStorage")}Q.getLocalStorageOrThrow=Qd;function eh(){return jt("localStorage")}Q.getLocalStorage=eh;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});var Zs=bi.getWindowMetadata=void 0;const Gs=Q;function th(){let e,t;try{e=Gs.getDocumentOrThrow(),t=Gs.getLocationOrThrow()}catch{return null}function n(){const l=e.getElementsByTagName("link"),d=[];for(let b=0;b<l.length;b++){const h=l[b],g=h.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const E=h.getAttribute("href");if(E)if(E.toLowerCase().indexOf("https:")===-1&&E.toLowerCase().indexOf("http:")===-1&&E.indexOf("//")!==0){let C=t.protocol+"//"+t.host;if(E.indexOf("/")===0)C+=E;else{const P=t.pathname.split("/");P.pop();const x=P.join("/");C+=x+"/"+E}d.push(C)}else if(E.indexOf("//")===0){const C=t.protocol+E;d.push(C)}else d.push(E)}}return d}function r(...l){const d=e.getElementsByTagName("meta");for(let b=0;b<d.length;b++){const h=d[b],g=["itemprop","property","name"].map(E=>h.getAttribute(E)).filter(E=>E?l.includes(E):!1);if(g.length&&g){const E=h.getAttribute("content");if(E)return E}}return""}function i(){let l=r("name","og:site_name","og:title","twitter:title");return l||(l=e.title),l}function o(){return r("description","og:description","twitter:description","keywords")}const s=i(),c=o(),a=t.origin,u=n();return{description:c,url:a,icons:u,name:s}}Zs=bi.getWindowMetadata=th;var nh=Object.defineProperty,rh=Object.defineProperties,ih=Object.getOwnPropertyDescriptors,Ys=Object.getOwnPropertySymbols,oh=Object.prototype.hasOwnProperty,sh=Object.prototype.propertyIsEnumerable,Xs=(e,t,n)=>t in e?nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Js=(e,t)=>{for(var n in t||(t={}))oh.call(t,n)&&Xs(e,n,t[n]);if(Ys)for(var n of Ys(t))sh.call(t,n)&&Xs(e,n,t[n]);return e},ch=(e,t)=>rh(e,ih(t));const Qs="ReactNative",we={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},ur=" ",ah=":",ec="/",pi=2,fh=1e3,tc="js";function wi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ut(){return!rn()&&!!hi()&&navigator.product===Qs}function uh(){return ut()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function lh(){return ut()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function on(){return!wi()&&!!hi()&&!!rn()}function Vt(){return ut()?we.reactNative:wi()?we.node:on()?we.browser:we.unknown}function dh(){var e;try{return ut()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(e=global.Application)==null?void 0:e.applicationId:void 0}catch{return}}function nc(e,t){const n=new URLSearchParams(e);for(const r of Object.keys(t).sort())if(t.hasOwnProperty(r)){const i=t[r];i!==void 0&&n.set(r,i)}return n.toString()}function hh(e){var t,n;const r=rc();try{return e!=null&&e.url&&r.url&&new URL(e.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),e.url=r.url),(t=e?.icons)!=null&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(i=>i!=="")),ch(Js(Js({},r),e),{url:e?.url||r.url,name:e?.name||r.name,description:e?.description||r.description,icons:(n=e?.icons)!=null&&n.length&&e.icons.length>0?e.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),e||r}}function rc(){return Zs()||{name:"",description:"",url:"",icons:[""]}}function gh(e,t){var n;const r=Vt(),i={protocol:e,version:t,env:r};return r==="browser"&&(i.host=((n=gi())==null?void 0:n.host)||"unknown"),i}function ic(){if(Vt()===we.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:n,Version:r}=global.Platform;return[n,r].join("-")}const e=ld();if(e===null)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return e.type==="browser"?[t,e.name,e.version].join("-"):[t,e.version].join("-")}function oc(){var e;const t=Vt();return t===we.browser?[t,((e=gi())==null?void 0:e.host)||"unknown"].join(":"):t}function sc(e,t,n){const r=ic(),i=oc();return[[e,t].join("-"),[tc,n].join("-"),r,i].join("/")}function bh({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:i,projectId:o,useOnCloseEvent:s,bundleId:c,packageName:a}){const u=n.split("?"),f=sc(e,t,r),l={auth:i,ua:f,projectId:o,useOnCloseEvent:s||void 0,packageName:a||void 0,bundleId:c||void 0},d=nc(u[1]||"",l);return u[0]+"?"+d}function ph(e){let t=(e.match(/^[^:]+(?=:\/\/)/gi)||[])[0];const n=typeof t<"u"?e.split("://")[1]:e;return t=t==="wss"?"https":"http",[t,n].join("://")}function wh(e,t,n){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function cc(e,t=pi){return ac(e.split(ec),t)}function yh(e){return cc(e).join(ur)}function lt(e,t){return e.filter(n=>t.includes(n)).length===e.length}function ac(e,t=pi){return e.slice(Math.max(e.length-t,0))}function mh(e){return Object.fromEntries(e.entries())}function Eh(e){return new Map(Object.entries(e))}function xh(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=t(e[r])}),n}const vh=e=>e;function fc(e){return e.trim().replace(/^\w/,t=>t.toUpperCase())}function Dh(e){return e.split(ur).map(t=>fc(t)).join(ur)}function Ah(e=Mt.FIVE_MINUTES,t){const n=Mt.toMiliseconds(e||Mt.FIVE_MINUTES);let r,i,o,s;return{resolve:c=>{o&&r&&(clearTimeout(o),r(c),s=Promise.resolve(c))},reject:c=>{o&&i&&(clearTimeout(o),i(c))},done:()=>new Promise((c,a)=>{if(s)return c(s);o=setTimeout(()=>{const u=new Error(t);s=Promise.reject(u),a(u)},n),r=c,i=a})}}function Bh(e,t,n){return new Promise(async(r,i)=>{const o=setTimeout(()=>i(new Error(n)),t);try{const s=await e;r(s)}catch(s){i(s)}clearTimeout(o)})}function yi(e,t){if(typeof t=="string"&&t.startsWith(`${e}:`))return t;if(e.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(e.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: ${e}`)}function Sh(e){return yi("topic",e)}function _h(e){return yi("id",e)}function Ih(e){const[t,n]=e.split(":"),r={id:void 0,topic:void 0};if(t==="topic"&&typeof n=="string")r.topic=n;else if(t==="id"&&Number.isInteger(Number(n)))r.id=Number(n);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${n}`);return r}function Uh(e,t){return Mt.fromMiliseconds((t||Date.now())+Mt.toMiliseconds(e))}function Oh(e){return Date.now()>=Mt.toMiliseconds(e)}function Ch(e,t){return`${e}${t?`:${t}`:""}`}function Ne(e=[],t=[]){return[...new Set([...e,...t])]}async function Th({id:e,topic:t,wcDeepLink:n}){var r;try{if(!n)return;const i=typeof n=="string"?JSON.parse(n):n,o=i?.href;if(typeof o!="string")return;const s=uc(o,e,t),c=Vt();if(c===we.browser){if(!((r=rn())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}lc(s)}else c===we.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(i){console.error(i)}}function uc(e,t,n){const r=`requestId=${t}&sessionTopic=${n}`;e.endsWith("/")&&(e=e.slice(0,-1));let i=`${e}`;if(e.startsWith("https://t.me")){const o=e.includes("?")?"&startapp=":"?startapp=";i=`${i}${o}${gc(r,!0)}`}else i=`${i}/wc?${r}`;return i}function lc(e){let t="_self";hc()?t="_top":(dc()||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"),window.open(e,t,"noreferrer noopener")}async function Nh(e,t){let n="";try{if(on()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch(r){console.error(r)}return n}function mi(e,t){return e.filter(n=>t.includes(n))}function $h(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),r=n.indexOf(t);return n[r+2]}function Rh(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Fh(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function dc(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function hc(){try{return window.self!==window.top}catch{return!1}}function gc(e,t=!1){const n=Buffer.from(e).toString("base64");return t?n.replace(/[=]/g,""):n}function Ei(e){return Buffer.from(e,"base64").toString("utf-8")}function Ph(e){return new Promise(t=>setTimeout(t,e))}const lr=BigInt(2**32-1),bc=BigInt(32);function pc(e,t=!1){return t?{h:Number(e&lr),l:Number(e>>bc&lr)}:{h:Number(e>>bc&lr)|0,l:Number(e&lr)|0}}function wc(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:s,l:c}=pc(e[o],t);[r[o],i[o]]=[s,c]}return[r,i]}const yc=(e,t,n)=>e>>>n,mc=(e,t,n)=>e<<32-n|t>>>n,dt=(e,t,n)=>e>>>n|t<<32-n,ht=(e,t,n)=>e<<32-n|t>>>n,xn=(e,t,n)=>e<<64-n|t>>>n-32,vn=(e,t,n)=>e>>>n-32|t<<64-n,Lh=(e,t)=>t,kh=(e,t)=>e,Mh=(e,t,n)=>e<<n|t>>>32-n,zh=(e,t,n)=>t<<n|e>>>32-n,Hh=(e,t,n)=>t<<n-32|e>>>64-n,jh=(e,t,n)=>e<<n-32|t>>>64-n;function ze(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const xi=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),vi=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Vh=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),qh=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Kh=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Wh=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0,sn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Di(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ke(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function $e(e,...t){if(!Di(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ai(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ke(e.outputLen),Ke(e.blockLen)}function gt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Bi(e,t){$e(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Dn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Re(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Si(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function We(e,t){return e<<32-t|e>>>t}const Ec=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xc(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Qe=Ec?e=>e:e=>xc(e);function Zh(e){for(let t=0;t<e.length;t++)e[t]=xc(e[t]);return e}const bt=Ec?e=>e:Zh,vc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Gh=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function An(e){if($e(e),vc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Gh[e[n]];return t}const et={_0:48,_9:57,A:65,F:70,a:97,f:102};function Dc(e){if(e>=et._0&&e<=et._9)return e-et._0;if(e>=et.A&&e<=et.F)return e-(et.A-10);if(e>=et.a&&e<=et.f)return e-(et.a-10)}function _i(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(vc)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let i=0,o=0;i<n;i++,o+=2){const s=Dc(e.charCodeAt(o)),c=Dc(e.charCodeAt(o+1));if(s===void 0||c===void 0){const a=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}r[i]=s*16+c}return r}function Yh(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function He(e){return typeof e=="string"&&(e=Yh(e)),$e(e),e}function pt(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];$e(i),t+=i.length}const n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const o=e[r];n.set(o,i),i+=o.length}return n}class dr{}function Bn(e){const t=r=>e().update(He(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Xh(e){const t=(r,i)=>e(i).update(He(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function wt(e=32){if(sn&&typeof sn.getRandomValues=="function")return sn.getRandomValues(new Uint8Array(e));if(sn&&typeof sn.randomBytes=="function")return Uint8Array.from(sn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const Jh=BigInt(0),Sn=BigInt(1),Qh=BigInt(2),e0=BigInt(7),t0=BigInt(256),n0=BigInt(113),Ac=[],Bc=[],Sc=[];for(let e=0,t=Sn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Ac.push(2*(5*r+n)),Bc.push((e+1)*(e+2)/2%64);let i=Jh;for(let o=0;o<7;o++)t=(t<<Sn^(t>>e0)*n0)%t0,t&Qh&&(i^=Sn<<(Sn<<BigInt(o))-Sn);Sc.push(i)}const _c=wc(Sc,!0),r0=_c[0],i0=_c[1],Ic=(e,t,n)=>n>32?Hh(e,t,n):Mh(e,t,n),Uc=(e,t,n)=>n>32?jh(e,t,n):zh(e,t,n);function o0(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,a=(s+2)%10,u=n[a],f=n[a+1],l=Ic(u,f,1)^n[c],d=Uc(u,f,1)^n[c+1];for(let b=0;b<50;b+=10)e[s+b]^=l,e[s+b+1]^=d}let i=e[2],o=e[3];for(let s=0;s<24;s++){const c=Bc[s],a=Ic(i,o,c),u=Uc(i,o,c),f=Ac[s];i=e[f],o=e[f+1],e[f]=a,e[f+1]=u}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=r0[r],e[1]^=i0[r]}Re(n)}class Ii extends dr{constructor(t,n,r,i=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=o,Ke(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Dn(this.state)}clone(){return this._cloneInto()}keccak(){bt(this.state32),o0(this.state32,this.rounds),bt(this.state32),this.posOut=0,this.pos=0}update(t){gt(this),t=He(t),$e(t);const{blockLen:n,state:r}=this,i=t.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);for(let c=0;c<s;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){gt(this,!1),$e(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,o=t.length;i<o;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,o-i);t.set(n.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ke(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Bi(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Re(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:o,enableXOF:s}=this;return t||(t=new Ii(n,r,i,s,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=i,t.enableXOF=s,t.destroyed=this.destroyed,t}}const s0=(e,t,n)=>Bn(()=>new Ii(t,e,n)),Ui=s0(1,136,256/8);function _n(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function Oi(e){return _n(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Oc="2.31.0";let Ci={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${Oc}`};class qt extends Error{constructor(t,n={}){const r=n.cause instanceof qt?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof qt&&n.cause.docsPath||n.docsPath,o=Ci.getDocsUrl?.({...n,docsPath:i}),s=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...r?[`Details: ${r}`]:[],...Ci.version?[`Version: ${Ci.version}`]:[]].join(`
`);super(s,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Oc}walk(t){return Cc(this,t)}}function Cc(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Cc(e.cause,t):t?null:e}class Tc extends qt{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function cn(e,{dir:t,size:n=32}={}){return typeof e=="string"?c0(e,{dir:t,size:n}):a0(e,{dir:t,size:n})}function c0(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new Tc({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function a0(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Tc({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let i=0;i<n;i++){const o=t==="right";r[o?i:n-i-1]=e[o?i:e.length-i-1]}return r}class f0 extends qt{constructor({max:t,min:n,signed:r,size:i,value:o}){super(`Number "${o}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class u0 extends qt{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function an(e,{size:t}){if(Oi(e)>t)throw new u0({givenSize:Oi(e),maxSize:t})}function Ti(e,t={}){const{signed:n}=t;t.size&&an(e,{size:t.size});const r=BigInt(e);if(!n)return r;const i=(e.length-2)/2,o=(1n<<BigInt(i)*8n-1n)-1n;return r<=o?r:r-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function l0(e,t={}){return Number(Ti(e,t))}const d0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ni(e,t={}){return typeof e=="number"||typeof e=="bigint"?$i(e,t):typeof e=="string"?b0(e,t):typeof e=="boolean"?h0(e,t):Nc(e,t)}function h0(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(an(n,{size:t.size}),cn(n,{size:t.size})):n}function Nc(e,t={}){let n="";for(let i=0;i<e.length;i++)n+=d0[e[i]];const r=`0x${n}`;return typeof t.size=="number"?(an(r,{size:t.size}),cn(r,{dir:"right",size:t.size})):r}function $i(e,t={}){const{signed:n,size:r}=t,i=BigInt(e);let o;r?n?o=(1n<<BigInt(r)*8n-1n)-1n:o=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof o=="bigint"&&n?-o-1n:0;if(o&&i>o||i<s){const a=typeof e=="bigint"?"n":"";throw new f0({max:o?`${o}${a}`:void 0,min:`${s}${a}`,signed:n,size:r,value:`${e}${a}`})}const c=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?cn(c,{size:r}):c}const g0=new TextEncoder;function b0(e,t={}){const n=g0.encode(e);return Nc(n,t)}const p0=new TextEncoder;function w0(e,t={}){return typeof e=="number"||typeof e=="bigint"?m0(e,t):typeof e=="boolean"?y0(e,t):_n(e)?Rc(e,t):Fc(e,t)}function y0(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(an(n,{size:t.size}),cn(n,{size:t.size})):n}const tt={zero:48,nine:57,A:65,F:70,a:97,f:102};function $c(e){if(e>=tt.zero&&e<=tt.nine)return e-tt.zero;if(e>=tt.A&&e<=tt.F)return e-(tt.A-10);if(e>=tt.a&&e<=tt.f)return e-(tt.a-10)}function Rc(e,t={}){let n=e;t.size&&(an(n,{size:t.size}),n=cn(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,o=new Uint8Array(i);for(let s=0,c=0;s<i;s++){const a=$c(r.charCodeAt(c++)),u=$c(r.charCodeAt(c++));if(a===void 0||u===void 0)throw new qt(`Invalid byte sequence ("${r[c-2]}${r[c-1]}" in "${r}").`);o[s]=a*16+u}return o}function m0(e,t){const n=$i(e,t);return Rc(n)}function Fc(e,t={}){const n=p0.encode(e);return typeof t.size=="number"?(an(n,{size:t.size}),cn(n,{dir:"right",size:t.size})):n}function Pc(e,t){const n=t||"hex",r=Ui(_n(e,{strict:!1})?w0(e):e);return n==="bytes"?r:Ni(r)}class Lc extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Ri=new Lc(8192);function E0(e,t){if(Ri.has(`${e}.${t}`))return Ri.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Pc(Fc(n),"bytes"),i=(t?n.substring(`${t}0x`.length):n).split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const o=`0x${i.join("")}`;return Ri.set(`${e}.${t}`,o),o}function x0(e){const t=Pc(`0x${e.substring(4)}`).substring(26);return E0(`0x${t}`)}async function v0({hash:e,signature:t}){const n=_n(e)?e:Ni(e),{secp256k1:r}=await Promise.resolve().then(function(){return Q1});return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:u,s:f,v:l,yParity:d}=t,b=Number(d??l),h=kc(b);return new r.Signature(Ti(u),Ti(f)).addRecoveryBit(h)}const s=_n(t)?t:Ni(t);if(Oi(s)!==65)throw new Error("invalid signature length");const c=l0(`0x${s.slice(130)}`),a=kc(c);return r.Signature.fromCompact(s.substring(2,130)).addRecoveryBit(a)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function kc(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function D0({hash:e,signature:t}){return x0(await v0({hash:e,signature:t}))}function A0(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),c=Number(n&o),a=r?4:0,u=r?0:4;e.setUint32(t+a,s,r),e.setUint32(t+u,c,r)}function B0(e,t,n){return e&t^~e&n}function S0(e,t,n){return e&t^e&n^t&n}class Mc extends dr{constructor(t,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Si(this.buffer)}update(t){gt(this),t=He(t),$e(t);const{view:n,buffer:r,blockLen:i}=this,o=t.length;for(let s=0;s<o;){const c=Math.min(i-this.pos,o-s);if(c===i){const a=Si(t);for(;i<=o-s;s+=i)this.process(a,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){gt(this),Bi(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,Re(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(r,0),s=0);for(let l=s;l<i;l++)n[l]=0;A0(r,i-8,BigInt(this.length*8),o),this.process(r,0);const c=Si(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,f[l],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=o,t.length=i,t.pos=c,i%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const yt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),de=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),he=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),_0=Uint32Array.from([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]),mt=new Uint32Array(64);class I0 extends Mc{constructor(t=32){super(64,t,8,!1),this.A=yt[0]|0,this.B=yt[1]|0,this.C=yt[2]|0,this.D=yt[3]|0,this.E=yt[4]|0,this.F=yt[5]|0,this.G=yt[6]|0,this.H=yt[7]|0}get(){const{A:t,B:n,C:r,D:i,E:o,F:s,G:c,H:a}=this;return[t,n,r,i,o,s,c,a]}set(t,n,r,i,o,s,c,a){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,n){for(let l=0;l<16;l++,n+=4)mt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=mt[l-15],b=mt[l-2],h=We(d,7)^We(d,18)^d>>>3,g=We(b,17)^We(b,19)^b>>>10;mt[l]=g+mt[l-7]+h+mt[l-16]|0}let{A:r,B:i,C:o,D:s,E:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){const d=We(c,6)^We(c,11)^We(c,25),b=f+d+B0(c,a,u)+_0[l]+mt[l]|0,g=(We(r,2)^We(r,13)^We(r,22))+S0(r,i,o)|0;f=u,u=a,a=c,c=s+b|0,s=o,o=i,i=r,r=b+g|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,i,o,s,c,a,u,f)}roundClean(){Re(mt)}destroy(){this.set(0,0,0,0,0,0,0,0),Re(this.buffer)}}const zc=wc(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),U0=zc[0],O0=zc[1],Et=new Uint32Array(80),xt=new Uint32Array(80);class Fi extends Mc{constructor(t=64){super(128,t,16,!1),this.Ah=he[0]|0,this.Al=he[1]|0,this.Bh=he[2]|0,this.Bl=he[3]|0,this.Ch=he[4]|0,this.Cl=he[5]|0,this.Dh=he[6]|0,this.Dl=he[7]|0,this.Eh=he[8]|0,this.El=he[9]|0,this.Fh=he[10]|0,this.Fl=he[11]|0,this.Gh=he[12]|0,this.Gl=he[13]|0,this.Hh=he[14]|0,this.Hl=he[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:i,Ch:o,Cl:s,Dh:c,Dl:a,Eh:u,El:f,Fh:l,Fl:d,Gh:b,Gl:h,Hh:g,Hl:E}=this;return[t,n,r,i,o,s,c,a,u,f,l,d,b,h,g,E]}set(t,n,r,i,o,s,c,a,u,f,l,d,b,h,g,E){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=b|0,this.Gl=h|0,this.Hh=g|0,this.Hl=E|0}process(t,n){for(let x=0;x<16;x++,n+=4)Et[x]=t.getUint32(n),xt[x]=t.getUint32(n+=4);for(let x=16;x<80;x++){const v=Et[x-15]|0,B=xt[x-15]|0,R=dt(v,B,1)^dt(v,B,8)^yc(v,B,7),F=ht(v,B,1)^ht(v,B,8)^mc(v,B,7),T=Et[x-2]|0,m=xt[x-2]|0,O=dt(T,m,19)^xn(T,m,61)^yc(T,m,6),A=ht(T,m,19)^vn(T,m,61)^mc(T,m,6),_=Vh(F,A,xt[x-7],xt[x-16]),U=qh(_,R,O,Et[x-7],Et[x-16]);Et[x]=U|0,xt[x]=_|0}let{Ah:r,Al:i,Bh:o,Bl:s,Ch:c,Cl:a,Dh:u,Dl:f,Eh:l,El:d,Fh:b,Fl:h,Gh:g,Gl:E,Hh:C,Hl:P}=this;for(let x=0;x<80;x++){const v=dt(l,d,14)^dt(l,d,18)^xn(l,d,41),B=ht(l,d,14)^ht(l,d,18)^vn(l,d,41),R=l&b^~l&g,F=d&h^~d&E,T=Kh(P,B,F,O0[x],xt[x]),m=Wh(T,C,v,R,U0[x],Et[x]),O=T|0,A=dt(r,i,28)^xn(r,i,34)^xn(r,i,39),_=ht(r,i,28)^vn(r,i,34)^vn(r,i,39),U=r&o^r&c^o&c,L=i&s^i&a^s&a;C=g|0,P=E|0,g=b|0,E=h|0,b=l|0,h=d|0,{h:l,l:d}=ze(u|0,f|0,m|0,O|0),u=c|0,f=a|0,c=o|0,a=s|0,o=r|0,s=i|0;const y=xi(O,_,L);r=vi(y,m,A,U),i=y|0}({h:r,l:i}=ze(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:s}=ze(this.Bh|0,this.Bl|0,o|0,s|0),{h:c,l:a}=ze(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l:f}=ze(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=ze(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:h}=ze(this.Fh|0,this.Fl|0,b|0,h|0),{h:g,l:E}=ze(this.Gh|0,this.Gl|0,g|0,E|0),{h:C,l:P}=ze(this.Hh|0,this.Hl|0,C|0,P|0),this.set(r,i,o,s,c,a,u,f,l,d,b,h,g,E,C,P)}roundClean(){Re(Et,xt)}destroy(){Re(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class C0 extends Fi{constructor(){super(48),this.Ah=de[0]|0,this.Al=de[1]|0,this.Bh=de[2]|0,this.Bl=de[3]|0,this.Ch=de[4]|0,this.Cl=de[5]|0,this.Dh=de[6]|0,this.Dl=de[7]|0,this.Eh=de[8]|0,this.El=de[9]|0,this.Fh=de[10]|0,this.Fl=de[11]|0,this.Gh=de[12]|0,this.Gl=de[13]|0,this.Hh=de[14]|0,this.Hl=de[15]|0}}const ge=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class T0 extends Fi{constructor(){super(32),this.Ah=ge[0]|0,this.Al=ge[1]|0,this.Bh=ge[2]|0,this.Bl=ge[3]|0,this.Ch=ge[4]|0,this.Cl=ge[5]|0,this.Dh=ge[6]|0,this.Dl=ge[7]|0,this.Eh=ge[8]|0,this.El=ge[9]|0,this.Fh=ge[10]|0,this.Fl=ge[11]|0,this.Gh=ge[12]|0,this.Gl=ge[13]|0,this.Hh=ge[14]|0,this.Hl=ge[15]|0}}const vt=Bn(()=>new I0),N0=Bn(()=>new Fi),$0=Bn(()=>new C0),R0=Bn(()=>new T0),hr=vt,Pi=BigInt(0),Li=BigInt(1);function gr(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function br(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Hc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Pi:BigInt("0x"+e)}function pr(e){return Hc(An(e))}function wr(e){return $e(e),Hc(An(Uint8Array.from(e).reverse()))}function ki(e,t){return _i(e.toString(16).padStart(t*2,"0"))}function Mi(e,t){return ki(e,t).reverse()}function ve(e,t,n){let r;if(typeof t=="string")try{r=_i(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Di(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const zi=e=>typeof e=="bigint"&&Pi<=e;function F0(e,t,n){return zi(e)&&zi(t)&&zi(n)&&t<=e&&e<n}function Hi(e,t,n,r){if(!F0(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function P0(e){let t;for(t=0;e>Pi;e>>=Li,t+=1);return t}const yr=e=>(Li<<BigInt(e))-Li;function L0(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=b=>new Uint8Array(b),i=b=>Uint8Array.of(b);let o=r(e),s=r(e),c=0;const a=()=>{o.fill(1),s.fill(0),c=0},u=(...b)=>n(s,o,...b),f=(b=r(0))=>{s=u(i(0),b),o=u(),b.length!==0&&(s=u(i(1),b),o=u())},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const h=[];for(;b<t;){o=u();const g=o.slice();h.push(g),b+=o.length}return pt(...h)};return(b,h)=>{a(),f(b);let g;for(;!(g=h