UNPKG

@walletconnect/utils

Version:

Utilities for WalletConnect Protocol

15 lines (13 loc) • 260 kB
(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 Us(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 Os(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 Cs(e){const{address:t}=ii(e);return t}function Ts(e){const{namespace:t,reference:n}=ii(e);return Us({namespace:t,reference:n})}function Ql(e,t){const{namespace:n,reference:r}=ri(t);return Os({namespace:n,reference:r,address:e})}function ed(e){return oi(e,Cs)}function Ns(e){return oi(e,Ts)}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(...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(...Ns(i.accounts))}),n}function rd(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 $s=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))},id=function(){function e(t,n,r){this.name=t,this.version=n,this.os=r,this.type="browser"}return e}(),od=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),sd=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}(),cd=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),ad=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),fd=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,ud=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Rs=3,ld=[["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",fd]],Fs=[["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 dd(e){return e?Ps(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ad:typeof navigator<"u"?Ps(navigator.userAgent):bd()}function hd(e){return e!==""&&ld.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 Ps(e){var t=hd(e);if(!t)return null;var n=t[0],r=t[1];if(n==="searchbot")return new cd;var i=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);i?i.length<Rs&&(i=$s($s([],i,!0),pd(Rs-i.length),!0)):i=[];var o=i.join("."),s=gd(e),c=ud.exec(e);return c&&c[1]?new sd(n,o,s,c[1]):new id(n,o,s)}function gd(e){for(var t=0,n=Fs.length;t<n;t++){var r=Fs[t],i=r[0],o=r[1],s=o.exec(e);if(s)return i}return null}function bd(){var e=typeof process<"u"&&process.version;return e?new od(process.version.slice(1)):null}function pd(e){for(var t=[],n=0;n<e;n++)t.push("0");return t}function wd(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 yd(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 md(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 Ed(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 xd(e,t){return function(n,r){t(n,r,e)}}function vd(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Dd(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 Ad(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 Bd(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Sd(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 Ls(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 _d(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ls(arguments[t]));return e}function Id(){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 Ud(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 Od(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 Cd(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 Td(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Nd(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 $d(e){return e&&e.__esModule?e:{default:e}}function Rd(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Fd(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 Pd=Object.freeze({__proto__:null,__extends:yd,get __assign(){return ci},__rest:md,__decorate:Ed,__param:xd,__metadata:vd,__awaiter:Dd,__generator:Ad,__createBinding:Bd,__exportStar:Sd,__values:ai,__read:Ls,__spread:_d,__spreadArrays:Id,__await:yn,__asyncGenerator:Ud,__asyncDelegator:Od,__asyncValues:Cd,__makeTemplateObject:Td,__importStar:Nd,__importDefault:$d,__classPrivateFieldGet:Rd,__classPrivateFieldSet:Fd}),fr=wd(Pd),fi={},mn={},ks;function Ld(){if(ks)return mn;ks=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={},Ms;function kd(){return Ms||(Ms=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={},zs;function Md(){return zs||(zs=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 Hs;function js(){return Hs||(Hs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(kd(),e),t.__exportStar(Md(),e)}(ui)),ui}var Vs;function zd(){if(Vs)return zt;Vs=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.fromMiliseconds=zt.toMiliseconds=void 0;const e=js();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 qs;function Hd(){return qs||(qs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(Ld(),e),t.__exportStar(zd(),e)}(fi)),fi}var tn={},Ks;function jd(){if(Ks)return tn;Ks=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={},Ws;function Vd(){if(Ws)return En;Ws=1,Object.defineProperty(En,"__esModule",{value:!0}),En.IWatch=void 0;class e{}return En.IWatch=e,En}var Zs;function qd(){return Zs||(Zs=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),fr.__exportStar(Vd(),e)}(di)),di}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=fr;t.__exportStar(Hd(),e),t.__exportStar(jd(),e),t.__exportStar(qd(),e),t.__exportStar(js(),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 Kd(){return nn("document")}Q.getDocumentOrThrow=Kd;function Wd(){return jt("document")}var rn=Q.getDocument=Wd;function Zd(){return nn("navigator")}Q.getNavigatorOrThrow=Zd;function Gd(){return jt("navigator")}var hi=Q.getNavigator=Gd;function Yd(){return nn("location")}Q.getLocationOrThrow=Yd;function Xd(){return jt("location")}var gi=Q.getLocation=Xd;function Jd(){return nn("crypto")}Q.getCryptoOrThrow=Jd;function Qd(){return jt("crypto")}Q.getCrypto=Qd;function eh(){return nn("localStorage")}Q.getLocalStorageOrThrow=eh;function th(){return jt("localStorage")}Q.getLocalStorage=th;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});var Gs=bi.getWindowMetadata=void 0;const Ys=Q;function nh(){let e,t;try{e=Ys.getDocumentOrThrow(),t=Ys.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 U=t.protocol+"//"+t.host;if(E.indexOf("/")===0)U+=E;else{const P=t.pathname.split("/");P.pop();const x=P.join("/");U+=x+"/"+E}d.push(U)}else if(E.indexOf("//")===0){const U=t.protocol+E;d.push(U)}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}}Gs=bi.getWindowMetadata=nh;var rh=Object.defineProperty,ih=Object.defineProperties,oh=Object.getOwnPropertyDescriptors,Xs=Object.getOwnPropertySymbols,sh=Object.prototype.hasOwnProperty,ch=Object.prototype.propertyIsEnumerable,pi=(e,t,n)=>t in e?rh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Js=(e,t)=>{for(var n in t||(t={}))sh.call(t,n)&&pi(e,n,t[n]);if(Xs)for(var n of Xs(t))ch.call(t,n)&&pi(e,n,t[n]);return e},ah=(e,t)=>ih(e,oh(t)),Qs=(e,t,n)=>pi(e,typeof t!="symbol"?t+"":t,n);const ec="ReactNative",we={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},ur=" ",fh=":",tc="/",wi=2,uh=1e3,nc="js";function yi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ut(){return!rn()&&!!hi()&&navigator.product===ec}function lh(){return ut()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function dh(){return ut()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function on(){return!yi()&&!!hi()&&!!rn()}function Vt(){return ut()?we.reactNative:yi()?we.node:on()?we.browser:we.unknown}function hh(){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 rc(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 gh(e){var t,n;const r=ic();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!=="")),ah(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 ic(){return Gs()||{name:"",description:"",url:"",icons:[""]}}function bh(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 oc(){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=dd();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 sc(){var e;const t=Vt();return t===we.browser?[t,((e=gi())==null?void 0:e.host)||"unknown"].join(":"):t}function cc(e,t,n){const r=oc(),i=sc();return[[e,t].join("-"),[nc,n].join("-"),r,i].join("/")}function ph({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:i,projectId:o,useOnCloseEvent:s,bundleId:c,packageName:a}){const u=n.split("?"),f=cc(e,t,r),l={auth:i,ua:f,projectId:o,useOnCloseEvent:s||void 0,packageName:a||void 0,bundleId:c||void 0},d=rc(u[1]||"",l);return u[0]+"?"+d}function wh(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 yh(e,t,n){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function ac(e,t=wi){return fc(e.split(tc),t)}function mh(e){return ac(e).join(ur)}function lt(e,t){return e.filter(n=>t.includes(n)).length===e.length}function fc(e,t=wi){return e.slice(Math.max(e.length-t,0))}function Eh(e){return Object.fromEntries(e.entries())}function xh(e){return new Map(Object.entries(e))}function vh(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=t(e[r])}),n}const Dh=e=>e;function uc(e){return e.trim().replace(/^\w/,t=>t.toUpperCase())}function Ah(e){return e.split(ur).map(t=>uc(t)).join(ur)}function Bh(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 Sh(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 mi(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 _h(e){return mi("topic",e)}function Ih(e){return mi("id",e)}function Uh(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 Oh(e,t){return Mt.fromMiliseconds((t||Date.now())+Mt.toMiliseconds(e))}function Ch(e){return Date.now()>=Mt.toMiliseconds(e)}function Th(e,t){return`${e}${t?`:${t}`:""}`}function Ne(e=[],t=[]){return[...new Set([...e,...t])]}async function Nh({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=lc(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}dc(s)}else c===we.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(i){console.error(i)}}function lc(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}${bc(r,!0)}`}else i=`${i}/wc?${r}`;return i}function dc(e){let t="_self";gc()?t="_top":(hc()||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"),window.open(e,t,"noreferrer noopener")}async function $h(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 Ei(e,t){return e.filter(n=>t.includes(n))}function Rh(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),r=n.indexOf(t);return n[r+2]}function Fh(){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 Ph(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function hc(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function gc(){try{return window.self!==window.top}catch{return!1}}function bc(e,t=!1){const n=Buffer.from(e).toString("base64");return t?n.replace(/[=]/g,""):n}function xi(e){return Buffer.from(e,"base64").toString("utf-8")}function Lh(e){return new Promise(t=>setTimeout(t,e))}class kh{constructor({limit:t}){Qs(this,"limit"),Qs(this,"set"),this.limit=t,this.set=new Set}add(t){if(!this.set.has(t)){if(this.set.size>=this.limit){const n=this.set.values().next().value;n&&this.set.delete(n)}this.set.add(t)}}has(t){return this.set.has(t)}}const lr=BigInt(2**32-1),pc=BigInt(32);function wc(e,t=!1){return t?{h:Number(e&lr),l:Number(e>>pc&lr)}:{h:Number(e>>pc&lr)|0,l:Number(e&lr)|0}}function yc(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}=wc(e[o],t);[r[o],i[o]]=[s,c]}return[r,i]}const mc=(e,t,n)=>e>>>n,Ec=(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,Mh=(e,t)=>t,zh=(e,t)=>e,Hh=(e,t,n)=>e<<n|t>>>32-n,jh=(e,t,n)=>t<<n|e>>>32-n,Vh=(e,t,n)=>t<<n-32|e>>>64-n,qh=(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 vi=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Di=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Kh=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Wh=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Zh=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Gh=(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 Ai(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(!Ai(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 Bi(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 Si(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 _i(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function We(e,t){return e<<32-t|e>>>t}const xc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vc(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Qe=xc?e=>e:e=>vc(e);function Yh(e){for(let t=0;t<e.length;t++)e[t]=vc(e[t]);return e}const bt=xc?e=>e:Yh,Dc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Xh=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function An(e){if($e(e),Dc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Xh[e[n]];return t}const et={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ac(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 Ii(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Dc)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=Ac(e.charCodeAt(o)),c=Ac(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 Jh(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=Jh(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 Qh(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 e0=BigInt(0),Sn=BigInt(1),t0=BigInt(2),n0=BigInt(7),r0=BigInt(256),i0=BigInt(113),Bc=[],Sc=[],_c=[];for(let e=0,t=Sn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Bc.push(2*(5*r+n)),Sc.push((e+1)*(e+2)/2%64);let i=e0;for(let o=0;o<7;o++)t=(t<<Sn^(t>>n0)*i0)%r0,t&t0&&(i^=Sn<<(Sn<<BigInt(o))-Sn);_c.push(i)}const Ic=yc(_c,!0),o0=Ic[0],s0=Ic[1],Uc=(e,t,n)=>n>32?Vh(e,t,n):Hh(e,t,n),Oc=(e,t,n)=>n>32?qh(e,t,n):jh(e,t,n);function c0(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=Uc(u,f,1)^n[c],d=Oc(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=Sc[s],a=Uc(i,o,c),u=Oc(i,o,c),f=Bc[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]^=o0[r],e[1]^=s0[r]}Re(n)}class Ui 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),c0(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(Si(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 Ui(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 a0=(e,t,n)=>Bn(()=>new Ui(t,e,n)),Oi=a0(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 Ci(e){return _n(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Cc="2.31.0";let Ti={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${Cc}`};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=Ti.getDocsUrl?.({...n,docsPath:i}),s=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...r?[`Details: ${r}`]:[],...Ti.version?[`Version: ${Ti.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=Cc}walk(t){return Tc(this,t)}}function Tc(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Tc(e.cause,t):t?null:e}class Nc 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"?f0(e,{dir:t,size:n}):u0(e,{dir:t,size:n})}function f0(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new Nc({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function u0(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Nc({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 l0 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 d0 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(Ci(e)>t)throw new d0({givenSize:Ci(e),maxSize:t})}function Ni(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 h0(e,t={}){return Number(Ni(e,t))}const g0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $i(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ri(e,t):typeof e=="string"?w0(e,t):typeof e=="boolean"?b0(e,t):$c(e,t)}function b0(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(an(n,{size:t.size}),cn(n,{size:t.size})):n}function $c(e,t={}){let n="";for(let i=0;i<e.length;i++)n+=g0[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 Ri(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 l0({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 p0=new TextEncoder;function w0(e,t={}){const n=p0.encode(e);return $c(n,t)}const y0=new TextEncoder;function m0(e,t={}){return typeof e=="number"||typeof e=="bigint"?x0(e,t):typeof e=="boolean"?E0(e,t):_n(e)?Fc(e,t):Pc(e,t)}function E0(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 Rc(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 Fc(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=Rc(r.charCodeAt(c++)),u=Rc(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 x0(e,t){const n=Ri(e,t);return Fc(n)}function Pc(e,t={}){const n=y0.encode(e);return typeof t.size=="number"?(an(n,{size:t.size}),cn(n,{dir:"right",size:t.size})):n}function Lc(e,t){const n=t||"hex",r=Oi(_n(e,{strict:!1})?m0(e):e);return n==="bytes"?r:$i(r)}class kc 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 Fi=new kc(8192);function v0(e,t){if(Fi.has(`${e}.${t}`))return Fi.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Lc(Pc(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 Fi.set(`${e}.${t}`,o),o}function D0(e){const t=Lc(`0x${e.substring(4)}`).substring(26);return v0(`0x${t}`)}async function A0({hash:e,signature:t}){const n=_n(e)?e:$i(e),{secp256k1:r}=await Promise.resolve().then(function(){return tg});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=Mc(b);return new r.Signature(Ni(u),Ni(f)).addRecoveryBit(h)}const s=_n(t)?t:$i(t);if(Ci(s)!==65)throw new Error("invalid signature length");const c=h0(`0x${s.slice(130)}`),a=Mc(c);return r.Signature.fromCompact(s.substring(2,130)).addRecoveryBit(a)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Mc(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 B0({hash:e,signature:t}){return D0(await A0({hash:e,signature:t}))}function S0(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 _0(e,t,n){return e&t^~e&n}function I0(e,t,n){return e&t^e&n^t&n}class zc 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=_i(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=_i(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),Si(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;S0(r,i-8,BigInt(this.length*8),o),this.process(r,0);const c=_i(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]),U0=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 O0 extends zc{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+_0(c,a,u)+U0[l]+mt[l]|0,g=(We(r,2)^We(r,13)^We(r,22))+I0(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 Hc=yc(["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))),C0=Hc[0],T0=Hc[1],Et=new Uint32Array(80),xt=new Uint32Array(80);class Pi extends zc{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 D=Et[x-15]|0,B=xt[x-15]|0,F=dt(D,B,1)^dt(D,B,8)^mc(D,B,7),R=ht(D,B,1)^ht(D,B,8)^Ec(D,B,7),T=Et[x-2]|0,m=xt[x-2]|0,C=dt(T,m,19)^xn(T,m,61)^mc(T,m,6),A=ht(T,m,19)^vn(T,m,61)^Ec(T,m,6),_=Kh(R,A,xt[x-7],xt[x-16]),O=Wh(_,F,C,Et[x-7],Et[x-16]);Et[x]=O|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:U,Hl:P}=this;for(let x=0;x<80;x++){const D=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),F=l&b^~l&g,R=d&h^~d&E,T=Zh(P,B,R,T0[x],xt[x]),m=Gh(T,U,D,F,C0[x],Et[x]),C=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),O=r&o^r&c^o&c,L=i&s^i&a^s&a;U=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,C|0),u=c|0,f=a|0,c=o|0,a=s|0,o=r|0,s=i|0;const y=vi(C,_,L);r=Di(y,m,A,O),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:U,l:P}=ze(this.Hh|0,this.Hl|0,U|0,P|0),this.set(r,i,o,s,c,a,u,f,l,d,b,h,g,E,U,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 N0 extends Pi{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 $0 extends Pi{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 O0),R0=Bn(()=>new Pi),F0=Bn(()=>new N0),P0=Bn(()=>new $0),hr=vt,Li=BigInt(0),ki=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 jc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Li:BigInt("0x"+e)}function pr(e){return jc(An(e))}function wr(e){return $e(e),jc(An(Uint8Array.from(e).reverse()))}function Mi(e,t){return Ii(e.toString(16).padStart(t*2,"0"))}function zi(e,t){return Mi(e,t).reverse()}function ve(e,t,n){let r;if(typeof t=="string")try{r=Ii(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Ai(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 Hi=e=>typeof e=="bigint"&&Li<=e;function L0(e,t,n){return Hi(e)&&Hi(t)&&Hi(n)&&t<=e&&e<n}function ji(e,t,n,r){if(!L0(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function k0(e){let t;for(t=0;e>Li;e>>=ki,t+=1);return t}const yr=e=>(ki<<BigInt(e))-ki;function M0(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=()=>{