PageSourceSearch

https://spore.earth/assets/index.es-81c497b5.js

js spore.earth collected 2026-10-07 10:29:17 UTC 417,467 bytes, 38 lines download raw bytes

vendor: 10,957 bytes, lines 1-14
1import{k as ih,_ as rh,g as sh,m as vt}from"./index-ed92e2ed.js";import{e as it,N as So}from"./events-1708fc8d.js";import{c as Ld,g as sa,s as qd,d as kd,k as Md,a as zd}from"./index-accd8060.js";var na=globalThis&&globalThis.__spreadArray||function(t,e,i){if(i||arguments.length===2)for(var r=0,s=e.length,n;r<s;r++)(n||!(r in e))&&(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))},Hd=function(){function t(e,i,r){this.name=e,this.version=i,this.os=r,this.type="browser"}return t}(),Vd=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Kd=function(){function t(e,i,r,s){this.name=e,this.version=i,this.os=r,this.bot=s,this.type="bot-device"}return t}(),Wd=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Gd=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Yd=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Jd=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,oa=3,Zd=[["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",Yd]],aa=[["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 Qd(t){return t?ca(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Gd:typeof navigator<"u"?ca(navigator.userAgent):tp()}function Xd(t){return t!==""&&Zd.reduce(function(e,i){var r=i[0],s=i[1];if(e)return e;var n=s.exec(t);return!!n&&[r,n]},!1)}function ca(t){var e=Xd(t);if(!e)return null;var i=e[0],r=e[1];if(i==="searchbot")return new Wd;var s=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);s?s.length<oa&&(s=na(na([],s,!0),ip(oa-s.length),!0)):s=[];var n=s.join("."),o=ep(t),a=Jd.exec(t);return a&&a[1]?new Kd(i,n,o,a[1]):new Hd(i,n,o)}function ep(t){for(var e=0,i=aa.length;e<i;e++){var r=aa[e],s=r[0],n=r[1],o=n.exec(t);if(o)return s}return null}function tp(){var t=typeof process<"u"&&process.version;return t?new Vd(process.version.slice(1)):null}function ip(t){for(var e=[],i=0;i<t;i++)e.push("0");return e}var N={};/*! *****************************************************************************
2Copyright (c) Microsoft Corporation.
3
4Permission to use, copy, modify, and/or distribute this software for any
5purpose with or without fee is hereby granted.
6
7THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13PERFORMANCE OF THIS SOFTWARE.
14***************************************************************************** */var Fn=function(t,e){return Fn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)r.hasOwnProperty(s)&&(i[s]=r[s])},Fn(t,e)};function rp(t,e){Fn(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}var Bn=function(){return Bn=Object.assign||function(e){for(var i,r=1,s=arguments.length;r<s;r++){i=arguments[r];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},Bn.apply(this,arguments)};function sp(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]]);return i}function np(t,e,i,r){var s=arguments.length,n=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,i):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,i,n):o(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n}function op(t,e){return function(i,r){e(i,r,t)}}function ap(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function cp(t,e,i,r){function s(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function a(h){try{u(r.next(h))}catch(l){o(l)}}function c(h){try{u(r.throw(h))}catch(l){o(l)}}function u(h){h.done?n(h.value):s(h.value).then(a,c)}u((r=r.apply(t,e||[])).next())})}function up(t,e){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(h){return c([u,h])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,s&&(n=u[0]&2?s.return:u[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,u[1])).done)return n;switch(s=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(n=i.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){i.label=u[1];break}if(u[0]===6&&i.label<n[1]){i.label=n[1],n=u;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(u);break}n[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(h){u=[6,h],s=0}finally{r=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function hp(t,e,i,r){r===void 0&&(r=i),t[r]=e[i]}function lp(t,e){for(var i in t)i!=="default"&&!e.hasOwnProperty(i)&&(e[i]=t[i])}function jn(t){var e=typeof Symbol=="function"&&Symbol.iterator,i=e&&t[e],r=0;if(i)return i.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function nh(t,e){var i=typeof Symbol=="function"&&t[Symbol.iterator];if(!i)return t;var r=i.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return n}function dp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(nh(arguments[e]));return t}function pp(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;for(var r=Array(t),s=0,e=0;e<i;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)r[s]=n[o];return r}function Dr(t){return this instanceof Dr?(this.v=t,this):new Dr(t)}function fp(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(d){r[d]&&(s[d]=function(f){return new Promise(function(p,y){n.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(r[d](f))}catch(p){l(n[0][3],p)}}function c(d){d.value instanceof Dr?Promise.resolve(d.value.v).then(u,h):l(n[0][2],d)}function u(d){a("next",d)}function h(d){a("throw",d)}function l(d,f){d(f),n.shift(),n.length&&a(n[0][0],n[0][1])}}function gp(t){var e,i;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,n){e[s]=t[s]?function(o){return(i=!i)?{value:Dr(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function yp(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],i;return e?e.call(t):(t=typeof jn=="function"?jn(t):t[Symbol.iterator](),i={},r("next"),r("throw"),r("return"),i[Symbol.asyncIterator]=function(){return this},i);function r(n){i[n]=t[n]&&function(o){return new Promise(function(a,c){o=t[n](o),s(a,c,o.done,o.value)})}}function s(n,o,a,c){Promise.resolve(c).then(function(u){n({value:u,done:a})},o)}}function mp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function wp(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}function bp(t){return t&&t.__esModule?t:{default:t}}function vp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Ep(t,e,i){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,i),i}const _p=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Bn}
14,__asyncDelegator:gp,__asyncGenerator:fp,__asyncValues:yp,__await:Dr,__awaiter:cp,__classPrivateFieldGet:vp,__classPrivateFieldSet:Ep,__createBinding:hp,__decorate:np,__exportStar:lp,__extends:rp,__generator:up,__importDefault:bp,__importStar:wp,__makeTemplateObject:mp,__metadata:ap,__param:op,__read:nh,__rest:sp,__spread:dp,__spreadArrays:pp,__values:jn},Symbol.toStringTag,{value:"Module"})),As=ih(_p);var Js={},or={},ua;function Ip(){if(ua)return or;ua=1,Object.defineProperty(or,"__esModule",{value:!0}),or.delay=void 0;function t(e){return new Promise(i=>{setTimeout(()=>{i(!0)},e)})}return or.delay=t,or}var Gt={},Zs={},Yt={},ha;function $p(){return ha||(ha=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.ONE_THOUSAND=Yt.ONE_HUNDRED=void 0,Yt.ONE_HUNDRED=100,Yt.ONE_THOUSAND=1e3),Yt}var Qs={},la;function Dp(){return la||(la=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Qs)),Qs}var da;function oh(){return da||(da=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar($p(),t),e.__exportStar(Dp(),t)}(Zs)),Zs}var pa;function Sp(){if(pa)return Gt;pa=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.fromMiliseconds=Gt.toMiliseconds=void 0;const t=oh();function e(r){return r*t.ONE_THOUSAND}Gt.toMiliseconds=e;function i(r){return Math.floor(r/t.ONE_THOUSAND)}return Gt.fromMiliseconds=i,Gt}var fa;function Op(){return fa||(fa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar(Ip(),t),e.__exportStar(Sp(),t)}(Js)),Js}var bi={},ga;function Pp(){if(ga)return bi;ga=1,Object.defineProperty(bi,"__esModule",{value:!0}),bi.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(i){if(this.timestamps.has(i))throw new Error(`Watch already started for label: ${i}`);this.timestamps.set(i,{started:Date.now()})}stop(i){const r=this.get(i);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${i}`);const s=Date.now()-r.started;this.timestamps.set(i,{started:r.started,elapsed:s})}get(i){const r=this.timestamps.get(i);if(typeof r>"u")throw new Error(`No timestamp found for label: ${i}`);return r}elapsed(i){const r=this.get(i);return r.elapsed||Date.now()-r.started}}return bi.Watch=t,bi.default=t,bi}var Xs={},ar={},ya;function Ap(){if(ya)return ar;ya=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.IWatch=void 0;class t{}return ar.IWatch=t,ar}var ma;function xp(){return ma||(ma=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),As.__exportStar(Ap(),t)}(Xs)),Xs}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar(Op(),t),e.__exportStar(Pp(),t),e.__exportStar(xp(),t),e.__exportStar(oh(),t)})(N);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});oe.getLocalStorage=oe.getLocalStorageOrThrow=oe.getCrypto=oe.getCryptoOrThrow=ah=oe.getLocation=oe.getLocationOrThrow=Oo=oe.getNavigator=oe.getNavigatorOrThrow=ai=oe.getDocument=oe.getDocumentOrThrow=oe.getFromWindowOrThrow=oe.getFromWindow=void 0;function pi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}oe.getFromWindow=pi;function Qi(t){const e=pi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}oe.getFromWindowOrThrow=Qi;function Cp(){return Qi("document")}oe.getDocumentOrThrow=Cp;function Tp(){return pi("document")}var ai=oe.getDocument=Tp;function Rp(){return Qi("navigator")}oe.getNavigatorOrThrow=Rp;function Np(){return pi("navigator")}var Oo=oe.getNavigator=Np;function Fp(){return Qi("location")}oe.getLocationOrThrow=Fp;function Bp(){return pi("location")}var ah=oe.getLocation=Bp;function jp(){return Qi("crypto")}oe.getCryptoOrThrow=jp;function Up(){return pi("crypto")}oe.getCrypto=Up;function Lp(){return Qi("localStorage")}oe.getLocalStorageOrThrow=Lp;function qp(){return pi("localStorage")}oe.getLocalStorage=qp;var Po={};Object.defineProperty(Po,"__esModule",{value:!0});var ch=Po.getWindowMetadata=void 0;const wa=oe;function kp(){let t,e;try{t=wa.getDocumentOrThrow(),e=wa.getLocationOrThrow()}catch{return null}function i(){const l=t.getElementsByTagName("link"),d=[];for(let f=0;f<l.length;f++){const p=l[f],y=p.getAttribute("rel");if(y&&y.toLowerCase().indexOf("icon")>-1){const w=p.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(w.indexOf("/")===0)v+=w;else{const b=e.pathname.split("/");b.pop();const E=b.join("/");v+=E+"/"+w}d.push(v)}else if(w.indexOf("//")===0){const v=e.protocol+w;d.push(v)}else d.push(w)}}return d}function r(...l){const d=t.getElementsByTagName("meta");for(let f=0;f<d.length;f++){const p=d[f],y=["itemprop","property","name"].map(w=>p.getAttribute(w)).filter(w=>w?l.includes(w):!1);if(y.length&&y){const w=p.getAttribute("content");
14if(w)return w}}return""}function s(){let l=r("name","og:site_name","og:title","twitter:title");return l||(l=t.title),l}function n(){return r("description","og:description","twitter:description","keywords")}const o=s(),a=n(),c=e.origin,u=i();return{description:a,url:c,icons:u,name:o}}ch=Po.getWindowMetadata=kp;function Sr(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ba(t){return Sr(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const uh="2.23.2";let cr={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:i})=>e?`${t??"https://viem.sh"}${e}${i?`#${i}`:""}`:void 0,version:`viem@${uh}`};class ci extends Error{constructor(e,i={}){var a;const r=(()=>{var c;return i.cause instanceof ci?i.cause.details:(c=i.cause)!=null&&c.message?i.cause.message:i.details})(),s=(()=>i.cause instanceof ci&&i.cause.docsPath||i.docsPath)(),n=(a=cr.getDocsUrl)==null?void 0:a.call(cr,{...i,docsPath:s}),o=[e||"An error occurred.","",...i.metaMessages?[...i.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...r?[`Details: ${r}`]:[],...cr.version?[`Version: ${cr.version}`]:[]].join(`
15`);super(o,i.cause?{cause:i.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=s,this.metaMessages=i.metaMessages,this.name=i.name??this.name,this.shortMessage=e,this.version=uh}walk(e){return hh(this,e)}}function hh(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?hh(t.cause,e):e?null:t}class lh extends ci{constructor({size:e,targetSize:i,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${i}).`,{name:"SizeExceedsPaddingSizeError"})}}function Xi(t,{dir:e,size:i=32}={}){return typeof t=="string"?Mp(t,{dir:e,size:i}):zp(t,{dir:e,size:i})}function Mp(t,{dir:e,size:i=32}={}){if(i===null)return t;const r=t.replace("0x","");if(r.length>i*2)throw new lh({size:Math.ceil(r.length/2),targetSize:i,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](i*2,"0")}`}function zp(t,{dir:e,size:i=32}={}){if(i===null)return t;if(t.length>i)throw new lh({size:t.length,targetSize:i,type:"bytes"});const r=new Uint8Array(i);for(let s=0;s<i;s++){const n=e==="right";r[n?s:i-s-1]=t[n?s:t.length-s-1]}return r}class Hp extends ci{constructor({max:e,min:i,signed:r,size:s,value:n}){super(`Number "${n}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${i} to ${e})`:`(above ${i})`}`,{name:"IntegerOutOfRangeError"})}}class Vp extends ci{constructor({givenSize:e,maxSize:i}){super(`Size cannot exceed ${i} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function er(t,{size:e}){if(ba(t)>e)throw new Vp({givenSize:ba(t),maxSize:e})}function Un(t,e={}){const{signed:i}=e;e.size&&er(t,{size:e.size});const r=BigInt(t);if(!i)return r;const s=(t.length-2)/2,n=(1n<<BigInt(s)*8n-1n)-1n;return r<=n?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Kp(t,e={}){return Number(Un(t,e))}const Wp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ln(t,e={}){return typeof t=="number"||typeof t=="bigint"?ph(t,e):typeof t=="string"?Jp(t,e):typeof t=="boolean"?Gp(t,e):dh(t,e)}function Gp(t,e={}){const i=`0x${Number(t)}`;return typeof e.size=="number"?(er(i,{size:e.size}),Xi(i,{size:e.size})):i}function dh(t,e={}){let i="";for(let s=0;s<t.length;s++)i+=Wp[t[s]];const r=`0x${i}`;return typeof e.size=="number"?(er(r,{size:e.size}),Xi(r,{dir:"right",size:e.size})):r}function ph(t,e={}){const{signed:i,size:r}=e,s=BigInt(t);let n;r?i?n=(1n<<BigInt(r)*8n-1n)-1n:n=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&i?-n-1n:0;if(n&&s>n||s<o){const c=typeof t=="bigint"?"n":"";throw new Hp({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:i,size:r,value:`${t}${c}`})}const a=`0x${(i&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?Xi(a,{size:r}):a}const Yp=new TextEncoder;function Jp(t,e={}){const i=Yp.encode(t);return dh(i,e)}const Zp=new TextEncoder;function Qp(t,e={}){return typeof t=="number"||typeof t=="bigint"?ef(t,e):typeof t=="boolean"?Xp(t,e):Sr(t)?fh(t,e):gh(t,e)}function Xp(t,e={}){const i=new Uint8Array(1);return i[0]=Number(t),typeof e.size=="number"?(er(i,{size:e.size}),Xi(i,{size:e.size})):i}const Dt={zero:48,nine:57,A:65,F:70,a:97,f:102};function va(t){if(t>=Dt.zero&&t<=Dt.nine)return t-Dt.zero;if(t>=Dt.A&&t<=Dt.F)return t-(Dt.A-10);if(t>=Dt.a&&t<=Dt.f)return t-(Dt.a-10)}function fh(t,e={}){let i=t;e.size&&(er(i,{size:e.size}),i=Xi(i,{dir:"right",size:e.size}));let r=i.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,n=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const c=va(r.charCodeAt(a++)),u=va(r.charCodeAt(a++));if(c===void 0||u===void 0)throw new ci(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);n[o]=c*16+u}return n}function ef(t,e){const i=ph(t,e);return fh(i)}function gh(t,e={}){const i=Zp.encode(t);return typeof e.size=="number"?(er(i,{size:e.size}),Xi(i,{dir:"right",size:e.size})):i}function ys(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function xs(t,...e){if(!tf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function qO(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ys(t.outputLen),ys(t.blockLen)}function Ea(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function rf(t,e){xs(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const Kr=BigInt(2**32-1),_a=BigInt(32);function sf(t,e=!1){return e?{h:Number(t&Kr),l:Number(t>>_a&Kr)}:{h:Number(t>>_a&Kr)|0,l:Number(t&Kr)|0}}
15function nf(t,e=!1){let i=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=sf(t[s],e);[i[s],r[s]]=[n,o]}return[i,r]}const of=(t,e,i)=>t<<i|e>>>32-i,af=(t,e,i)=>e<<i|t>>>32-i,cf=(t,e,i)=>e<<i-32|t>>>64-i,uf=(t,e,i)=>t<<i-32|e>>>64-i,vi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function hf(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function kO(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function MO(t,e){return t<<32-e|t>>>e}const Ia=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function lf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function $a(t){for(let e=0;e<t.length;e++)t[e]=lf(t[e])}function df(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function yh(t){return typeof t=="string"&&(t=df(t)),xs(t),t}function zO(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];xs(s),e+=s.length}const i=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const n=t[r];i.set(n,s),s+=n.length}return i}class pf{clone(){return this._cloneInto()}}function ff(t){const e=r=>t().update(yh(r)).digest(),i=t();return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=()=>t(),e}function HO(t=32){if(vi&&typeof vi.getRandomValues=="function")return vi.getRandomValues(new Uint8Array(t));if(vi&&typeof vi.randomBytes=="function")return vi.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const mh=[],wh=[],bh=[],gf=BigInt(0),ur=BigInt(1),yf=BigInt(2),mf=BigInt(7),wf=BigInt(256),bf=BigInt(113);for(let t=0,e=ur,i=1,r=0;t<24;t++){[i,r]=[r,(2*i+3*r)%5],mh.push(2*(5*r+i)),wh.push((t+1)*(t+2)/2%64);let s=gf;for(let n=0;n<7;n++)e=(e<<ur^(e>>mf)*bf)%wf,e&yf&&(s^=ur<<(ur<<BigInt(n))-ur);bh.push(s)}const[vf,Ef]=nf(bh,!0),Da=(t,e,i)=>i>32?cf(t,e,i):of(t,e,i),Sa=(t,e,i)=>i>32?uf(t,e,i):af(t,e,i);function _f(t,e=24){const i=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)i[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=i[c],h=i[c+1],l=Da(u,h,1)^i[a],d=Sa(u,h,1)^i[a+1];for(let f=0;f<50;f+=10)t[o+f]^=l,t[o+f+1]^=d}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=wh[o],c=Da(s,n,a),u=Sa(s,n,a),h=mh[o];s=t[h],n=t[h+1],t[h]=c,t[h+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)i[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~i[(a+2)%10]&i[(a+4)%10]}t[0]^=vf[r],t[1]^=Ef[r]}i.fill(0)}class Ao extends pf{constructor(e,i,r,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=i,this.outputLen=r,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ys(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=hf(this.state)}keccak(){Ia||$a(this.state32),_f(this.state32,this.rounds),Ia||$a(this.state32),this.posOut=0,this.pos=0}update(e){Ea(this);const{blockLen:i,state:r}=this;e=yh(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(i-this.pos,s-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===i&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:i,pos:r,blockLen:s}=this;e[r]^=i,i&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ea(this,!1),xs(e),this.finish();const i=this.state,{blockLen:r}=this;for(let s=0,n=e.length;s<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-s);e.set(i.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ys(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(rf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:i,suffix:r,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new Ao(i,r,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const If=(t,e,i)=>ff(()=>new Ao(e,t,i)),$f=If(1,136,256/8);function vh(t,e){const i=e||"hex",r=$f(Sr(t,{strict:!1})?Qp(t):t);return i==="bytes"?r:Ln(r)}class Df extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const i=super.get(e);return super.has(e)&&i!==void 0&&(this.delete(e),super.set(e,i)),i}set(e,i){if(super.set(e,i),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const en=new Df(8192);function Sf(t,e){if(en.has(`${t}.${e}`))return en.get(`${t}.${e}`);const i=e?`${e}${t.toLowerCase()}`:t.substring(2).toLowerCase(),r=vh(gh(i),"bytes"),s=(e?i.substring(`${e}0x`.length):i).split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const n=`0x${s.join("")}`;return en.set(`${t}.${e}`,n),n}function Of(t){const e=vh(`0x${t.substring(4)}`).substring(26);return Sf(`0x${e}`)}async function Pf({hash:t,signature:e}){const i=Sr(t)?t:Ln(t),{secp256k1:r}=await rh(()=>import("./secp256k1-10dc44b4.js"),["assets/secp256k1-10dc44b4.js","assets/index-ed92e2ed.js","assets/index-4840a3af.css","assets/events-1708fc8d.js","assets/index-accd8060.js"]);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:u,s:h,v:l,yParity:d}=e,f=Number(d??l),p=Oa(f);return new r.Signature(Un(u),Un(h)).addRecoveryBit(p)}const o=Sr(e)?e:Ln(e),a=Kp(`0x${o.slice(130)}`),c=Oa(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(i.substring(2)).toHex(!1)}`}function Oa(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Af({hash:t,signature:e}){return Of(await Pf({hash:t,signature:e}))}function xf(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let u=0;u<e.length;u++)e[u]=255;for(let u=0;u<t.length;
15u++){const h=t.charAt(u),l=h.charCodeAt(0);if(e[l]!==255)throw new TypeError(h+" is ambiguous");e[l]=u}const i=t.length,r=t.charAt(0),s=Math.log(i)/Math.log(256),n=Math.log(256)/Math.log(i);function o(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";let h=0,l=0,d=0;const f=u.length;for(;d!==f&&u[d]===0;)d++,h++;const p=(f-d)*n+1>>>0,y=new Uint8Array(p);for(;d!==f;){let b=u[d],E=0;for(let I=p-1;(b!==0||E<l)&&I!==-1;I--,E++)b+=256*y[I]>>>0,y[I]=b%i>>>0,b=b/i>>>0;if(b!==0)throw new Error("Non-zero carry");l=E,d++}let w=p-l;for(;w!==p&&y[w]===0;)w++;let v=r.repeat(h);for(;w<p;++w)v+=t.charAt(y[w]);return v}function a(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;let h=0,l=0,d=0;for(;u[h]===r;)l++,h++;const f=(u.length-h)*s+1>>>0,p=new Uint8Array(f);for(;h<u.length;){const b=u.charCodeAt(h);if(b>255)return;let E=e[b];if(E===255)return;let I=0;for(let P=f-1;(E!==0||I<d)&&P!==-1;P--,I++)E+=i*p[P]>>>0,p[P]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");d=I,h++}let y=f-d;for(;y!==f&&p[y]===0;)y++;const w=new Uint8Array(l+(f-y));let v=l;for(;y!==f;)w[v++]=p[y++];return w}function c(u){const h=a(u);if(h)return h;throw new Error("Non-base"+i+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var Cf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Tf=xf(Cf),Rf=t=>JSON.stringify(t,(e,i)=>typeof i=="bigint"?i.toString()+"n":i),Nf=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=t.replace(e,'$1"$2n"$3');return JSON.parse(i,(r,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function ui(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Nf(t)}catch{return t}}function Bt(t){return typeof t=="string"?t:Rf(t)||""}function Ff(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Eh(t,...e){if(!Ff(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Pa(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Bf(t,e){Eh(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const Ei=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function jf(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function _h(t){return typeof t=="string"&&(t=jf(t)),Eh(t),t}let Uf=class{clone(){return this._cloneInto()}};function Lf(t){const e=r=>t().update(_h(r)).digest(),i=t();return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=()=>t(),e}function Ih(t=32){if(Ei&&typeof Ei.getRandomValues=="function")return Ei.getRandomValues(new Uint8Array(t));if(Ei&&typeof Ei.randomBytes=="function")return Ei.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function qf(t,e,i,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,i,r);const s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}let kf=class extends Uf{constructor(e,i,r,s){super(),this.blockLen=e,this.outputLen=i,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=tn(this.buffer)}update(e){Pa(this);const{view:i,buffer:r,blockLen:s}=this;e=_h(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const c=tn(e);for(;s<=n-o;o+=s)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(i,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pa(this),Bf(e,this),this.finished=!0;const{buffer:i,view:r,blockLen:s,isLE:n}=this;let{pos:o}=this;i[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let l=o;l<s;l++)i[l]=0;qf(r,s-8,BigInt(this.length*8),n),this.process(r,0);const a=tn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,h[l],n)}digest(){const{buffer:e,outputLen:i}=this;this.digestInto(e);const r=e.slice(0,i);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:i,buffer:r,length:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%i&&e.buffer.set(r),e}};const Wr=BigInt(2**32-1),qn=BigInt(32);function $h(t,e=!1){return e?{h:Number(t&Wr),l:Number(t>>qn&Wr)}:{h:Number(t>>qn&Wr)|0,l:Number(t&Wr)|0}}
vendor: 2,050 bytes, line 15
15function Mf(t,e=!1){let i=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=$h(t[s],e);[i[s],r[s]]=[n,o]}return[i,r]}const zf=(t,e)=>BigInt(t>>>0)<<qn|BigInt(e>>>0),Hf=(t,e,i)=>t>>>i,Vf=(t,e,i)=>t<<32-i|e>>>i,Kf=(t,e,i)=>t>>>i|e<<32-i,Wf=(t,e,i)=>t<<32-i|e>>>i,Gf=(t,e,i)=>t<<64-i|e>>>i-32,Yf=(t,e,i)=>t>>>i-32|e<<64-i,Jf=(t,e)=>e,Zf=(t,e)=>t,Qf=(t,e,i)=>t<<i|e>>>32-i,Xf=(t,e,i)=>e<<i|t>>>32-i,eg=(t,e,i)=>e<<i-32|t>>>64-i,tg=(t,e,i)=>t<<i-32|e>>>64-i;function ig(t,e,i,r){const s=(e>>>0)+(r>>>0);return{h:t+i+(s/2**32|0)|0,l:s|0}}const rg=(t,e,i)=>(t>>>0)+(e>>>0)+(i>>>0),sg=(t,e,i,r)=>e+i+r+(t/2**32|0)|0,ng=(t,e,i,r)=>(t>>>0)+(e>>>0)+(i>>>0)+(r>>>0),og=(t,e,i,r,s)=>e+i+r+s+(t/2**32|0)|0,ag=(t,e,i,r,s)=>(t>>>0)+(e>>>0)+(i>>>0)+(r>>>0)+(s>>>0),cg=(t,e,i,r,s,n)=>e+i+r+s+n+(t/2**32|0)|0,V={fromBig:$h,split:Mf,toBig:zf,shrSH:Hf,shrSL:Vf,rotrSH:Kf,rotrSL:Wf,rotrBH:Gf,rotrBL:Yf,rotr32H:Jf,rotr32L:Zf,rotlSH:Qf,rotlSL:Xf,rotlBH:eg,rotlBL:tg,add:ig,add3L:rg,add3H:sg,add4L:ng,add4H:og,add5H:cg,add5L:ag},[ug,hg]=(()=>V.split(["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","0xf40e3585
155771202a","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(t=>BigInt(t))))(),jt=new Uint32Array(80),Ut=new Uint32Array(80);let lg=class extends kf{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:i,Bh:r,Bl:s,Ch:n,Cl:o,Dh:a,Dl:c,Eh:u,El:h,Fh:l,Fl:
vendor: 25,152 bytes, line 15
15d,Gh:f,Gl:p,Hh:y,Hl:w}=this;return[e,i,r,s,n,o,a,c,u,h,l,d,f,p,y,w]}set(e,i,r,s,n,o,a,c,u,h,l,d,f,p,y,w){this.Ah=e|0,this.Al=i|0,this.Bh=r|0,this.Bl=s|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=h|0,this.Fh=l|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=w|0}process(e,i){for(let E=0;E<16;E++,i+=4)jt[E]=e.getUint32(i),Ut[E]=e.getUint32(i+=4);for(let E=16;E<80;E++){const I=jt[E-15]|0,P=Ut[E-15]|0,A=V.rotrSH(I,P,1)^V.rotrSH(I,P,8)^V.shrSH(I,P,7),O=V.rotrSL(I,P,1)^V.rotrSL(I,P,8)^V.shrSL(I,P,7),C=jt[E-2]|0,D=Ut[E-2]|0,k=V.rotrSH(C,D,19)^V.rotrBH(C,D,61)^V.shrSH(C,D,6),j=V.rotrSL(C,D,19)^V.rotrBL(C,D,61)^V.shrSL(C,D,6),B=V.add4L(O,j,Ut[E-7],Ut[E-16]),M=V.add4H(B,A,k,jt[E-7],jt[E-16]);jt[E]=M|0,Ut[E]=B|0}let{Ah:r,Al:s,Bh:n,Bl:o,Ch:a,Cl:c,Dh:u,Dl:h,Eh:l,El:d,Fh:f,Fl:p,Gh:y,Gl:w,Hh:v,Hl:b}=this;for(let E=0;E<80;E++){const I=V.rotrSH(l,d,14)^V.rotrSH(l,d,18)^V.rotrBH(l,d,41),P=V.rotrSL(l,d,14)^V.rotrSL(l,d,18)^V.rotrBL(l,d,41),A=l&f^~l&y,O=d&p^~d&w,C=V.add5L(b,P,O,hg[E],Ut[E]),D=V.add5H(C,v,I,A,ug[E],jt[E]),k=C|0,j=V.rotrSH(r,s,28)^V.rotrBH(r,s,34)^V.rotrBH(r,s,39),B=V.rotrSL(r,s,28)^V.rotrBL(r,s,34)^V.rotrBL(r,s,39),M=r&n^r&a^n&a,T=s&o^s&c^o&c;v=y|0,b=w|0,y=f|0,w=p|0,f=l|0,p=d|0,{h:l,l:d}=V.add(u|0,h|0,D|0,k|0),u=a|0,h=c|0,a=n|0,c=o|0,n=r|0,o=s|0;const g=V.add3L(k,B,T);r=V.add3H(g,D,j,M),s=g|0}({h:r,l:s}=V.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:n,l:o}=V.add(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:c}=V.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:h}=V.add(this.Dh|0,this.Dl|0,u|0,h|0),{h:l,l:d}=V.add(this.Eh|0,this.El|0,l|0,d|0),{h:f,l:p}=V.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:w}=V.add(this.Gh|0,this.Gl|0,y|0,w|0),{h:v,l:b}=V.add(this.Hh|0,this.Hl|0,v|0,b|0),this.set(r,s,n,o,a,c,u,h,l,d,f,p,y,w,v,b)}roundClean(){jt.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const dg=Lf(()=>new lg);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xo=BigInt(0),Dh=BigInt(1),pg=BigInt(2);function Co(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function To(t){if(!Co(t))throw new Error("Uint8Array expected")}function rn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const fg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ro(t){To(t);let e="";for(let i=0;i<t.length;i++)e+=fg[t[i]];return e}function Sh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?xo:BigInt("0x"+t)}const St={_0:48,_9:57,A:65,F:70,a:97,f:102};function Aa(t){if(t>=St._0&&t<=St._9)return t-St._0;if(t>=St.A&&t<=St.F)return t-(St.A-10);if(t>=St.a&&t<=St.f)return t-(St.a-10)}function Oh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,i=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(i);for(let s=0,n=0;s<i;s++,n+=2){const o=Aa(t.charCodeAt(n)),a=Aa(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[s]=o*16+a}return r}function gg(t){return Sh(Ro(t))}function us(t){return To(t),Sh(Ro(Uint8Array.from(t).reverse()))}function Ph(t,e){return Oh(t.toString(16).padStart(e*2,"0"))}function kn(t,e){return Ph(t,e).reverse()}function Ot(t,e,i){let r;if(typeof e=="string")try{r=Oh(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(Co(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof i=="number"&&s!==i)throw new Error(t+" of length "+i+" expected, got "+s);return r}function xa(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];To(s),e+=s.length}const i=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const n=t[r];i.set(n,s),s+=n.length}return i}const sn=t=>typeof t=="bigint"&&xo<=t;function yg(t,e,i){return sn(t)&&sn(e)&&sn(i)&&e<=t&&t<i}function hr(t,e,i,r){if(!yg(e,i,r))throw new Error("expected valid "+t+": "+i+" <= n < "+r+", got "+e)}function mg(t){let e;for(e=0;t>xo;t>>=Dh,e+=1);return e}const wg=t=>(pg<<BigInt(t-1))-Dh,bg={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Co(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function No(t,e,i={}){const r=(s,n,o)=>{const a=bg[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[s];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+c)};for(const[s,n]of Object.entries(e))r(s,n,!1);for(const[s,n]of Object.entries(i))r(s,n,!0);return t}function Ca(t){const e=new WeakMap;return(i,...r)=>{const s=e.get(i);if(s!==void 0)return s;const n=t(i,...r);return e.set(i,n),n}}const be=BigInt(0),ce=BigInt(1),ei=BigInt(2),vg=BigInt(3),Mn=BigInt(4),Ta=BigInt(5),Ra=BigInt(8);function pe(t,e){const i=t%e;return i>=be?i:e+i}function Eg(t,e,i){if(e<be)throw new Error("invalid exponent, negatives unsupported");if(i<=be)throw new Error("invalid modulus");if(i===ce)return be;let r=ce;for(;e>be;)e&ce&&(r=r*t%i),t=t*t%i,e>>=ce;return r}function pt(t,e,i){let r=t;for(;e-- >be;)r*=r,r%=i;return r}function Na(t,e){if(t===be)throw new Error("invert: expected non-zero number");if(e<=be)throw new Error("invert: expected positive modulus, got "+e);let i=pe(t,e),r=e,s=be,n=ce;for(;i!==be;){const o=r/i,a=r%i,c=s-n*o;r=i,i=a,s=n,n=c}if(r!==ce)throw new Error("invert: does not exist");return pe(s,e)}function _g(t){const e=(t-ce)/ei;let i,r,s;for(i=t-ce,r=0;i%ei===be;i/=ei,r++);for(s=ei;s<t&&Eg(s,e,t)!==t-ce;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+ce)/Mn;return function(a,c){const u=a.pow(c,o);if(!a.eql(a.sqr(u),c))throw new Error("Cannot find square root");return u}}const n=(i+ce)/ei;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,u=o.pow(o.mul(o.ONE,s),i),h=o.pow(a,n),l=o.pow(a,i);for(;!o.eql(l,o.ONE);){if(o.eql(l,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(l);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(u,ce<<BigInt(c-d-1));u=o.sqr(f),h=o.mul(h,f),l=o.mul(l,u),c=d}return h}}function Ig(t){if(t%Mn===vg){const e=(t+ce)/Mn;return function(i,r){const s=i.pow(r,e);if(!i.eql(i.sqr(s),r))throw new Error("Cannot find square root");return s}}if(t%Ra===Ta){const e=(t-Ta)/Ra;return function(i,r){const s=i.mul(r,ei),n=i.pow(s,e),o=i.mul(r,n),a=i.mul(i.mul(o,ei),n),c=i.mul(o,i.sub(a,i.ONE));if(!i.eql(i.sqr(c),r))throw new Error("Cannot find square root");return c}}return _g(t)}const $g=(t,e)=>(pe(t,e)&ce)===ce,Dg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Sg(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},i=Dg.reduce((r,s)=>(r[s]="function",r),e);return No(t,i)}function Og(t,e,i){if(i<be)throw new Error("invalid exponent, negatives unsupported");if(i===be)return t.ONE;if(i===ce)return e;let r=t.ONE,s=e;for(;i>be;)i&ce&&(r=t.mul(r,s)),s=t.sqr(s),i>>=ce;return r}function Pg(t,e){const i=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(i[a]=n,t.mul(n,o)),t.ONE),s=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(i[a]=t.mul(n,i[a]),t.mul(n,o)),s),i}function Ah(t,e){const i=e!==void 0?e:t.toString(2).length,r=Math.ceil(i/8);return{nBitLength:i,nByteLength:r}}function xh(t,e,i=!1,r={}){if(t<=be)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:n}=Ah(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:i,BITS:s,BYTES:n,MASK:wg(s),ZERO:be,ONE:ce,create:c=>pe(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return be<=c&&c<t},is0:c=>c===be,isOdd:c=>(c&ce)===ce,neg:c=>pe(-c,t),eql:(c,u)=>c===u,sqr:c=>pe(c*c,t),add:(c,u)=>pe(c+u,t),sub:(c,u)=>pe(c-u,t),mul:(c,u)=>pe(c*u,t),pow:(c,u)=>Og(a,c,u),div:(c,u)=>pe(c*Na(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Na(c,t),sqrt:r.sqrt||(c=>(o||(o=Ig(t)),o(a,c))),invertBatch:c=>Pg(a,c),cmov:(c,u,h)=>h?u:c,toBytes:c=>i?kn(c,n):Ph(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return i?us(c):gg(c)}});return Object.freeze(a)}const Fa=BigInt(0),Gr=BigInt(1);function nn(t,e){const i=e.negate();return t?i:e}function Ch(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function on(t,e){Ch(t,e);const i=Math.ceil(e/t)+1,r=2**(t-1);return{windows:i,windowSize:r}}function Ag(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((i,r)=>{if(!(i instanceof e))throw new Error("invalid point at index "+r)})}function xg(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((i,r)=>{if(!e.isValid(i))throw new Error("invalid scalar at index "+r)})}const an=new WeakMap,Th=new WeakMap;function cn(t){return Th.get(t)||1}function Cg(t,e){return{constTimeNegate:nn,hasPrecomputes(i){return cn(i)!==1},unsafeLadder(i,r,s=t.ZERO){let n=i;for(;r>Fa;)r&Gr&&(s=s.add(n)),n=n.double(),r>>=Gr;return s},precomputeWindow(i,r){const{windows:s,windowSize:n}=on(r,e),o=[];let a=i,c=a;for(let u=0;u<s;u++){c=a,o.push(c);for(let h=1;h<n;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(i,r,s){const{windows:n,windowSize:o}=on(i,e);let a=t.ZERO,c=t.BASE;const u=BigInt(2**i-1),h=2**i,l=BigInt(i);for(let d=0;d<n;d++){const f=d*o;let p=Number(s&u);s>>=l,p>o&&(p-=h,s+=Gr);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(nn(v,r[y])):a=a.add(nn(b,r[w]))}return{p:a,f:c}},wNAFUnsafe(i,r,s,n=t.ZERO){const{windows:o,windowSize:a}=on(i,e),c=BigInt(2**i-1),u=2**i,h=BigInt(i);for(let l=0;l<o;l++){const d=l*a;if(s===Fa)break;let f=Number(s&c);if(s>>=h,f>a&&(f-=u,s+=Gr),f===0)continue;let p=r[d+Math.abs(f)-1];f<0&&(p=p.negate()),n=n.add(p)}return n},getPrecomputes(i,r,s){let n=an.get(r);return n||(n=this.precomputeWindow(r,i),i!==1&&an.set(r,s(n))),n},wNAFCached(i,r,s){const n=cn(i);return this.wNAF(n,this.getPrecomputes(n,i,s),r)},wNAFCachedUnsafe(i,r,s,n){const o=cn(i);return o===1?this.unsafeLadder(i,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,i,s),r,n)},setWindowSize(i,r){Ch(r,e),Th.set(i,r),an.delete(i)}}}function Tg(t,e,i,r){if(Ag(i,t),xg(r,e),i.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,n=mg(BigInt(i.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(s),u=Math.floor((e.BITS-1)/o)*o;let h=s;for(let l=u;l>=0;l-=o){c.fill(s);for(let f=0;f<r.length;f++){const p=r[f],y=Number(p>>BigInt(l)&BigInt(a));c[y]=c[y].add(i[f])}let d=s;for(let f=c.length-1,p=s;f>0;f--)p=p.add(c[f]),d=d.add(p);if(h=h.add(d),l!==0)for(let f=0;f<o;f++)h=h.double()}return h}function Rg(t){return Sg(t.Fp),No(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ah(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const nt=BigInt(0),Fe=BigInt(1),Yr=BigInt(2),Ng=BigInt(8),Fg={zip215:!0};function Bg(t){const e=Rg(t);return No(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function jg(t){const e=Bg(t),{Fp:i,n:r,prehash:s,hash:n,randomBytes:o,nByteLength:a,h:c}=e,u=Yr<<BigInt(a*8)-Fe,h=i.create,l=xh(e.n,e.nBitLength),d=e.uvRatio||((g,m)=>{try{return{isValid:!0,value:i.sqrt(g*i.inv(m))}}catch{return{isValid:!1,value:nt}}}),f=e.adjustScalarBytes||(g=>g),p=e.domain||((g,m,_)=>{if(rn("phflag",_),m.length||_)throw new Error("Contexts/pre-hash are not supported");return g});function y(g,m){hr("coordinate "+g,m,nt,u)}function w(g){if(!(g instanceof E))throw new Error("ExtendedPoint expected")}const v=Ca((g,m)=>{const{ex:_,ey:S,ez:$}=g,x=g.is0();m==null&&(m=x?Ng:i.inv($));const U=h(_*m),q=h(S*m),z=h($*m);if(x)return{x:nt,y:Fe};if(z!==Fe)throw new Error("invZ was invalid");return{x:U,y:q}}),b=Ca(g=>{const{a:m,d:_}=e;if(g.is0())throw new Error("bad point: ZERO");const{ex:S,ey:$,ez:x,et:U}=g,q=h(S*S),z=h($*$),L=h(x*x),H=h(L*L),G=h(q*m),se=h(L*h(G+z)),ee=h(H+h(_*h(q*z)));if(se!==ee)throw new Error("bad point: equation left != right (1)");const Y=h(S*$),Ae=h(x*U);if(Y!==Ae)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(m,_,S,$){this.ex=m,this.ey=_,this.ez=S,this.et=$,y("x",m),y("y",_),y("z",S),y("t",$),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof E)throw new Error("extended point not allowed");const{x:_,y:S}=m||{};return y("x",_),y("y",S),new E(_,S,Fe,h(_*S))}static normalizeZ(m){const _=i.invertBatch(m.map(S=>S.ez));return m.map((S,$)=>S.toAffine(_[$])).map(E.fromAffine)}static msm(m,_){return Tg(E,l,m,_)}_setWindowSize(m){A.setWindowSize(this,m)}assertValidity(){b(this)}equals(m){w(m);const{ex:_,ey:S,ez:$}=this,{ex:x,ey:U,ez:q}=m,z=h(_*q),L=h(x*$),H=h(S*q),G=h(U*$);return z===L&&H===G}is0(){return this.equals(E.ZERO)}negate(){return new E(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:m}=e,{ex:_,ey:S,ez:$}=this,x=h(_*_),U=h(S*S),q=h(Yr*h($*$)),z=h(m*x),L=_+S,H=h(h(L*L)-x-U),G=z+U,se=G-q,ee=z-U,Y=h(H*se),Ae=h(G*ee),Ee=h(H*ee),Ce=h(se*G);return new E(Y,Ae,Ce,Ee)}add(m){w(m);const{a:_,d:S}=e,{ex:$,ey:x,ez:U,et:q}=this,{ex:z,ey:L,ez:H,et:G}=m;if(_===BigInt(-1)){const Zo=h((x-$)*(L+z)),Qo=h((x+$)*(L-z)),Ys=h(Qo-Zo);if(Ys===nt)return this.double();const Xo=h(U*Yr*G),ea=h(q*Yr*H),ta=ea+Xo,ia=Qo+Zo,ra=ea-Xo,Fd=h(ta*Ys),Bd=h(ia*ra),jd=h(ta*ra),Ud=h(Ys*ia);return new E(Fd,Bd,Ud,jd)}const se=h($*z),ee=h(x*L),Y=h(q*S*G),Ae=h(U*H),Ee=h(($+x)*(z+L)-se-ee),Ce=Ae-Y,Ye=Ae+Y,Je=h(ee-_*se),wi=h(Ee*Ce),Td=h(Ye*Je),Rd=h(Ee*Je),Nd=h(Ce*Ye);return new E(wi,Td,Nd,Rd)}subtract(m){return this.add(m.negate())}wNAF(m){return A.wNAFCached(this,m,E.normalizeZ)}multiply(m){const _=m;hr("scalar",_,Fe,r);const{p:S,f:$}=this.wNAF(_);return E.normalizeZ([S,$])[0]}multiplyUnsafe(m,_=E.ZERO){const S=m;return hr("scalar",S,nt,r),S===nt?P:this.is0()||S===Fe?this:A.wNAFCachedUnsafe(this,S,E.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return A.unsafeLadder(this,r).is0()}toAffine(m){return v(this,m)}clearCofactor(){const{h:m}=e;return m===Fe?this:this.multiplyUnsafe(m)}static fromHex(m,_=!1){const{d:S,a:$}=e,x=i.BYTES;m=Ot("pointHex",m,x),rn("zip215",_);const U=m.slice(),q=m[x-1];U[x-1]=q&-129;const z=us(U),L=_?u:i.ORDER;hr("pointHex.y",z,nt,L);const H=h(z*z),G=h(H-Fe),se=h(S*H-$);let{isValid:ee,value:Y}=d(G,se);if(!ee)throw new Error("Point.fromHex: invalid y coordinate");const Ae=(Y&Fe)===Fe,Ee=(q&128)!==0;if(!_&&Y===nt&&Ee)throw new Error("Point.fromHex: x=0 and x_0=1");return Ee!==Ae&&(Y=h(-Y)),E.fromAffine({x:Y,y:z})}static fromPrivateKey(m){return D(m).point}toRawBytes(){const{x:m,y:_}=this.toAffine(),S=kn(_,i.BYTES);return S[S.length-1]|=m&Fe?128:0,S}toHex(){return Ro(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Fe,h(e.Gx*e.Gy)),E.ZERO=new E(nt,Fe,Fe,nt);const{BASE:I,ZERO:P}=E,A=Cg(E,a*8);function O(g){return pe(g,r)}function C(g){return O(us(g))}function D(g){const m=i.BYTES;g=Ot("private key",g,m);const _=Ot("hashed private key",n(g),2*m),S=f(_.slice(0,m)),$=_.slice(m,2*m),x=C(S),U=I.multiply(x),q=U.toRawBytes();return{head:S,prefix:$,scalar:x,point:U,pointBytes:q}}function k(g){return D(g).pointBytes}function j(g=new Uint8Array,...m){const _=xa(...m);return C(n(p(_,Ot("context",g),!!s)))}function B(g,m,_={}){g=Ot("message",g),s&&(g=s(g));const{prefix:S,scalar:$,pointBytes:x}=D(m),U=j(_.context,S,g),q=I.multiply(U).toRawBytes(),z=j(_.context,q,x,g),L=O(U+z*$);hr("signature.s",L,nt,r);const H=xa(q,kn(L,i.BYTES));return Ot("result",H,i.BYTES*2)}const M=Fg;function T(g,m,_,S=M){const{context:$,zip215:x}=S,U=i.BYTES;g=Ot("signature",g,2*U),m=Ot("message",m),_=Ot("publicKey",_,U),x!==void 0&&rn("zip215",x),s&&(m=s(m));const q=us(g.slice(U,2*U));let z,L,H;try{z=E.fromHex(_,x),L=E.fromHex(g.slice(0,U),x),H=I.multiplyUnsafe(q)}catch{return!1}if(!x&&z.isSmallOrder())return!1;const G=j($,L.toRawBytes(),z.toRawBytes(),m);return L.add(z.multiplyUnsafe(G)).subtract(H).clearCofactor().equals(E.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:k,sign:B,verify:T,ExtendedPoint:E,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>o(i.BYTES),precompute(g=8,m=E.BASE){return m._setWindowSize(g),m.multiply(BigInt(3)),m}}}}BigInt(0),BigInt(1);const Fo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ba=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Ug=BigInt(1),ja=BigInt(2);BigInt(3);const Lg=BigInt(5),qg=BigInt(8);function kg(t){const e=BigInt(10),i=BigInt(20),r=BigInt(40),s=BigInt(80),n=Fo,o=t*t%n*t%n,a=pt(o,ja,n)*o%n,c=pt(a,Ug,n)*t%n,u=pt(c,Lg,n)*c%n,h=pt(u,e,n)*u%n,l=pt(h,i,n)*h%n,d=pt(l,r,n)*l%n,f=pt(d,s,n)*d%n,p=pt(f,s,n)*d%n,y=pt(p,e,n)*u%n;return{pow_p_5_8:pt(y,ja,n)*t%n,b2:o}}function Mg(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function zg(t,e){const i=Fo,r=pe(e*e*e,i),s=pe(r*r*e,i),n=kg(t*s).pow_p_5_8;let o=pe(t*r*n,i);const a=pe(e*o*o,i),c=o,u=pe(o*Ba,i),h=a===t,l=a===pe(-t,i),d=a===pe(-t*Ba,i);return h&&(o=c),(l||d)&&(o=u),$g(o,i)&&(o=pe(-o,i)),{isValid:h||l,value:o}}const Hg=(()=>xh(Fo,void 0,!0))(),Vg=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Hg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:qg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:dg,randomBytes:Ih,adjustScalarBytes:Mg,uvRatio:zg}))(),Rh=(()=>jg(Vg))(),Kg="EdDSA",Wg="JWT",ms=".",Cs="base64url",Nh="utf8",Fh="utf8",Gg=":",Yg="did",Jg="key",Ua="base58btc",Zg="z",Qg="K36",Xg=32;function Bo(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Bh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Bo(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function jh(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const i=Bh(e);let r=0;for(const s of t)i.set(s,r),r+=s.length;return Bo(i)}function ey(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(i[o]!==255)throw new TypeError(n+" is ambiguous");i[o]=s}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*h+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var I=i[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var ty=ey,iy=ty;const Uh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},ry=t=>new TextEncoder().encode(t),sy=t=>new TextDecoder().decode(t);let ny=class{constructor(e,i,r){this.name=e,this.prefix=i,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},oy=class{constructor(e,i,r){if(this.name=e,this.prefix=i,i.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Lh(this,e)}},ay=class{constructor(e){this.decoders=e}or(e){return Lh(this,e)}decode(e){const i=e[0],r=this.decoders[i];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Lh=(t,e)=>new ay({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let cy=class{constructor(e,i,r,s){this.name=e,this.prefix=i,this.baseEncode=r,this.baseDecode=s,this.encoder=new ny(e,i,r),this.decoder=new oy(e,i,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Ts=({name:t,prefix:e,encode:i,decode:r})=>new cy(t,e,i,r),Fr=({prefix:t,name:e,alphabet:i})=>{const{encode:r,decode:s}=iy(i,e);return Ts({prefix:t,name:e,encode:r,decode:n=>Uh(s(n))})},uy=(t,e,i,r)=>{const s={};for(let h=0;h<e.length;++h)s[e[h]]=h;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*i/8|0);let a=0,c=0,u=0;for(let h=0;h<n;++h){const l=s[t[h]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<i|l,a+=i,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},hy=(t,e,i)=>{const r=e[e.length-1]==="=",s=(1<<i)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>i;)o-=i,n+=e[s&a>>o];if(o&&(n+=e[s&a<<i-o]),r)for(;n.length*i&7;)n+="=";return n},Se=({name:t,prefix:e,bitsPerChar:i,alphabet:r})=>Ts({prefix:e,name:t,encode(s){return hy(s,r,i)},decode(s){return uy(s,r,i,t)}}),ly=Ts({prefix:"\0",name:"identity",encode:t=>sy(t),decode:t=>ry(t)});var dy=Object.freeze({__proto__:null,identity:ly});const py=Se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var fy=Object.freeze({__proto__:null,base2:py});const gy=Se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var yy=Object.freeze({__proto__:null,base8:gy});const my=Fr({prefix:"9",name:"base10",alphabet:"0123456789"});var wy=Object.freeze({__proto__:null,base10:my});const by=Se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vy=Se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ey=Object.freeze({__proto__:null,base16:by,base16upper:vy});const _y=Se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Iy=Se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$y=Se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dy=Se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Sy=Se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Oy=Se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Py=Se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ay=Se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xy=Se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Cy=Object.freeze({__proto__:null,base32:_y,base32upper:Iy,base32pad:$y,base32padupper:Dy,base32hex:Sy,base32hexupper:Oy,base32hexpad:Py,base32hexpadupper:Ay,base32z:xy});const Ty=Fr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ry=Fr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ny=Object.freeze({__proto__:null,base36:Ty,base36upper:Ry});const Fy=Fr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),By=Fr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jy=Object.freeze({__proto__:null,base58btc:Fy,base58flickr:By});const Uy=Se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
15+/",bitsPerChar:6}),Ly=Se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qy=Se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ky=Se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var My=Object.freeze({__proto__:null,base64:Uy,base64pad:Ly,base64url:qy,base64urlpad:ky});const qh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),zy=qh.reduce((t,e,i)=>(t[i]=e,t),[]),Hy=qh.reduce((t,e,i)=>(t[e.codePointAt(0)]=i,t),[]);function Vy(t){return t.reduce((e,i)=>(e+=zy[i],e),"")}function Ky(t){const e=[];for(const i of t){const r=Hy[i.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${i}`);e.push(r)}return new Uint8Array(e)}const Wy=Ts({prefix:"🚀",name:"base256emoji",encode:Vy,decode:Ky});var Gy=Object.freeze({__proto__:null,base256emoji:Wy}),Yy=kh,La=128,Jy=127,Zy=~Jy,Qy=Math.pow(2,31);function kh(t,e,i){e=e||[],i=i||0;for(var r=i;t>=Qy;)e[i++]=t&255|La,t/=128;for(;t&Zy;)e[i++]=t&255|La,t>>>=7;return e[i]=t|0,kh.bytes=i-r+1,e}var Xy=zn,em=128,qa=127;function zn(t,r){var i=0,r=r||0,s=0,n=r,o,a=t.length;do{if(n>=a)throw zn.bytes=0,new RangeError("Could not decode varint");o=t[n++],i+=s<28?(o&qa)<<s:(o&qa)*Math.pow(2,s),s+=7}while(o>=em);return zn.bytes=n-r,i}var tm=Math.pow(2,7),im=Math.pow(2,14),rm=Math.pow(2,21),sm=Math.pow(2,28),nm=Math.pow(2,35),om=Math.pow(2,42),am=Math.pow(2,49),cm=Math.pow(2,56),um=Math.pow(2,63),hm=function(t){return t<tm?1:t<im?2:t<rm?3:t<sm?4:t<nm?5:t<om?6:t<am?7:t<cm?8:t<um?9:10},lm={encode:Yy,decode:Xy,encodingLength:hm},Mh=lm;const ka=(t,e,i=0)=>(Mh.encode(t,e,i),e),Ma=t=>Mh.encodingLength(t),Hn=(t,e)=>{const i=e.byteLength,r=Ma(t),s=r+Ma(i),n=new Uint8Array(s+i);return ka(t,n,0),ka(i,n,r),n.set(e,s),new dm(t,i,e,n)};let dm=class{constructor(e,i,r,s){this.code=e,this.size=i,this.digest=r,this.bytes=s}};const zh=({name:t,code:e,encode:i})=>new pm(t,e,i);let pm=class{constructor(e,i,r){this.name=e,this.code=i,this.encode=r}digest(e){if(e instanceof Uint8Array){const i=this.encode(e);return i instanceof Uint8Array?Hn(this.code,i):i.then(r=>Hn(this.code,r))}else throw Error("Unknown type, must be binary type")}};const Hh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),fm=zh({name:"sha2-256",code:18,encode:Hh("SHA-256")}),gm=zh({name:"sha2-512",code:19,encode:Hh("SHA-512")});var ym=Object.freeze({__proto__:null,sha256:fm,sha512:gm});const Vh=0,mm="identity",Kh=Uh,wm=t=>Hn(Vh,Kh(t)),bm={code:Vh,name:mm,encode:Kh,digest:wm};var vm=Object.freeze({__proto__:null,identity:bm});new TextEncoder,new TextDecoder;const za={...dy,...fy,...yy,...wy,...Ey,...Cy,...Ny,...jy,...My,...Gy};({...ym,...vm});function Wh(t,e,i,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:i},decoder:{decode:r}}}const Ha=Wh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),un=Wh("ascii","a",t=>{let e="a";for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return e},t=>{t=t.substring(1);const e=Bh(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}),Gh={utf8:Ha,"utf-8":Ha,hex:za.base16,latin1:un,ascii:un,binary:un,...za};function Rs(t,e="utf8"){const i=Gh[e];if(!i)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):i.encoder.encode(t).substring(1)}function tr(t,e="utf8"){const i=Gh[e];if(!i)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Bo(globalThis.Buffer.from(t,"utf-8")):i.decoder.decode(`${i.prefix}${t}`)}function Va(t){return ui(Rs(tr(t,Cs),Nh))}function ws(t){return Rs(tr(Bt(t),Nh),Cs)}function Yh(t){const e=tr(Qg,Ua),i=Zg+Rs(jh([e,t]),Ua);return[Yg,Jg,i].join(Gg)}function Em(t){return Rs(t,Cs)}function _m(t){return tr(t,Cs)}function Im(t){return tr([ws(t.header),ws(t.payload)].join(ms),Fh)}function $m(t){return[ws(t.header),ws(t.payload),Em(t.signature)].join(ms)}function Vn(t){const e=t.split(ms),i=Va(e[0]),r=Va(e[1]),s=_m(e[2]),n=tr(e.slice(0,2).join(ms),Fh);return{header:i,payload:r,signature:s,data:n}}function Ka(t=Ih(Xg)){const e=Rh.getPublicKey(t);return{secretKey:jh([t,e]),publicKey:e}}async function Dm(t,e,i,r,s=N.fromMiliseconds(Date.now())){const n={alg:Kg,typ:Wg},o=Yh(r.publicKey),a=s+i,c={iss:o,sub:t,aud:e,iat:s,exp:a},u=Im({header:n,payload:c}),h=Rh.sign(u,r.secretKey.slice(0,32));return $m({header:n,payload:c,signature:h})}function Jh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function vr(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const i=Jh(e);let r=0;for(const s of t)i.set(s,r),r+=s.length;return i}function Sm(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(i[o]!==255)throw new TypeError(n+" is ambiguous");i[o]=s}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*h+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;
vendor: 6,190 bytes, line 15
15O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var I=i[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var Om=Sm,Pm=Om;const Am=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},xm=t=>new TextEncoder().encode(t),Cm=t=>new TextDecoder().decode(t);class Tm{constructor(e,i,r){this.name=e,this.prefix=i,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Rm{constructor(e,i,r){if(this.name=e,this.prefix=i,i.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Zh(this,e)}}class Nm{constructor(e){this.decoders=e}or(e){return Zh(this,e)}decode(e){const i=e[0],r=this.decoders[i];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Zh=(t,e)=>new Nm({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Fm{constructor(e,i,r,s){this.name=e,this.prefix=i,this.baseEncode=r,this.baseDecode=s,this.encoder=new Tm(e,i,r),this.decoder=new Rm(e,i,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ns=({name:t,prefix:e,encode:i,decode:r})=>new Fm(t,e,i,r),Br=({prefix:t,name:e,alphabet:i})=>{const{encode:r,decode:s}=Pm(i,e);return Ns({prefix:t,name:e,encode:r,decode:n=>Am(s(n))})},Bm=(t,e,i,r)=>{const s={};for(let h=0;h<e.length;++h)s[e[h]]=h;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*i/8|0);let a=0,c=0,u=0;for(let h=0;h<n;++h){const l=s[t[h]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<i|l,a+=i,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},jm=(t,e,i)=>{const r=e[e.length-1]==="=",s=(1<<i)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>i;)o-=i,n+=e[s&a>>o];if(o&&(n+=e[s&a<<i-o]),r)for(;n.length*i&7;)n+="=";return n},Oe=({name:t,prefix:e,bitsPerChar:i,alphabet:r})=>Ns({prefix:e,name:t,encode(s){return jm(s,r,i)},decode(s){return Bm(s,r,i,t)}}),Um=Ns({prefix:"\0",name:"identity",encode:t=>Cm(t),decode:t=>xm(t)}),Lm=Object.freeze(Object.defineProperty({__proto__:null,identity:Um},Symbol.toStringTag,{value:"Module"})),qm=Oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),km=Object.freeze(Object.defineProperty({__proto__:null,base2:qm},Symbol.toStringTag,{value:"Module"})),Mm=Oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),zm=Object.freeze(Object.defineProperty({__proto__:null,base8:Mm},Symbol.toStringTag,{value:"Module"})),Hm=Br({prefix:"9",name:"base10",alphabet:"0123456789"}),Vm=Object.freeze(Object.defineProperty({__proto__:null,base10:Hm},Symbol.toStringTag,{value:"Module"})),Km=Oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wm=Oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Gm=Object.freeze(Object.defineProperty({__proto__:null,base16:Km,base16upper:Wm},Symbol.toStringTag,{value:"Module"})),Ym=Oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jm=Oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zm=Oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qm=Oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xm=Oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ew=Oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tw=Oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iw=Oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rw=Oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sw=Object.freeze(Object.defineProperty({__proto__:null,base32:Ym,base32hex:Xm,base32hexpad:tw,base32hexpadupper:iw,base32hexupper:ew,base32pad:Zm,base32padupper:Qm,base32upper:Jm,base32z:rw},Symbol.toStringTag,{value:"Module"})),nw=Br({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ow=Br({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),aw=Object.freeze(Object.defineProperty({__proto__:null,base36:nw,base36upper:ow},Symbol.toStringTag,{value:"Module"})),cw=Br({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uw=Br({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hw=Object.freeze(Object.defineProperty({__proto__:null,base58btc:cw,base58flickr:uw},Symbol.toStringTag,{value:"Module"})),lw=Oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
15+/",bitsPerChar:6}),dw=Oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pw=Oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fw=Oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),gw=Object.freeze(Object.defineProperty({__proto__:null,base64:lw,base64pad:dw,base64url:pw,base64urlpad:fw},Symbol.toStringTag,{value:"Module"})),Qh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),yw=Qh.reduce((t,e,i)=>(t[i]=e,t),[]),mw=Qh.reduce((t,e,i)=>(t[e.codePointAt(0)]=i,t),[]);function ww(t){return t.reduce((e,i)=>(e+=yw[i],e),"")}function bw(t){const e=[];for(const i of t){const r=mw[i.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${i}`);e.push(r)}return new Uint8Array(e)}const vw=Ns({prefix:"🚀",name:"base256emoji",encode:ww,decode:bw}),Ew=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:vw},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Wa={...Lm,...km,...zm,...Vm,...Gm,...sw,...aw,...hw,...gw,...Ew};function Xh(t,e,i,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:i},decoder:{decode:r}}}const Ga=Xh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),hn=Xh("ascii","a",t=>{let e="a";for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return e},t=>{t=t.substring(1);const e=Jh(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}),el={utf8:Ga,"utf-8":Ga,hex:Wa.base16,latin1:hn,ascii:hn,binary:hn,...Wa};function tt(t,e="utf8"){const i=el[e];if(!i)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):i.decoder.decode(`${i.prefix}${t}`)}function qe(t,e="utf8"){const i=el[e];if(!i)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):i.encoder.encode(t).substring(1)}const _w={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},Iw=":";function Hi(t){const[e,i]=t.split(Iw);return{namespace:e,reference:i}}function Ya(t,e=[]){const i=[];return Object.keys(t).forEach(r=>{if(e.length&&!e.includes(r))return;const s=t[r];
15i.push(...s.accounts)}),i}function tl(t,e){return t.includes(":")?[t]:e.chains||[]}var $w=Object.defineProperty,Dw=Object.defineProperties,Sw=Object.getOwnPropertyDescriptors,Ja=Object.getOwnPropertySymbols,Ow=Object.prototype.hasOwnProperty,Pw=Object.prototype.propertyIsEnumerable,Za=(t,e,i)=>e in t?$w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Qa=(t,e)=>{for(var i in e||(e={}))Ow.call(e,i)&&Za(t,i,e[i]);if(Ja)for(var i of Ja(e))Pw.call(e,i)&&Za(t,i,e[i]);return t},Aw=(t,e)=>Dw(t,Sw(e));const xw="ReactNative",We={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Cw="js";function bs(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Wt(){return!ai()&&!!Oo()&&navigator.product===xw}function Tw(){return Wt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Rw(){return Wt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ir(){return!bs()&&!!Oo()&&!!ai()}function jr(){return Wt()?We.reactNative:bs()?We.node:ir()?We.browser:We.unknown}function Xa(){var t;try{return Wt()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Nw(t,e){const i=new URLSearchParams(t);for(const r of Object.keys(e).sort())if(e.hasOwnProperty(r)){const s=e[r];s!==void 0&&i.set(r,s)}return i.toString()}function Fw(t){var e,i;const r=il();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(s=>s!=="")),Aw(Qa(Qa({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(i=t==null?void 0:t.icons)!=null&&i.length&&t.icons.length>0?t.icons:r.icons})}catch(s){return console.warn("Error populating app metadata",s),t||r}}function il(){return ch()||{name:"",description:"",url:"",icons:[""]}}function Bw(){if(jr()===We.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:i,Version:r}=global.Platform;return[i,r].join("-")}const t=Qd();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function jw(){var t;const e=jr();return e===We.browser?[e,((t=ah())==null?void 0:t.host)||"unknown"].join(":"):e}function rl(t,e,i){const r=Bw(),s=jw();return[[t,e].join("-"),[Cw,i].join("-"),r,s].join("/")}function Uw({protocol:t,version:e,relayUrl:i,sdkVersion:r,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const u=i.split("?"),h=rl(t,e,r),l={auth:s,ua:h,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=Nw(u[1]||"",l);return u[0]+"?"+d}function si(t,e){return t.filter(i=>e.includes(i)).length===t.length}function Kn(t){return Object.fromEntries(t.entries())}function Wn(t){return new Map(Object.entries(t))}function Qt(t=N.FIVE_MINUTES,e){const i=N.toMiliseconds(t||N.FIVE_MINUTES);let r,s,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&s&&(clearTimeout(n),s(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const u=new Error(e);o=Promise.reject(u),c(u)},i),r=a,s=c})}}function zt(t,e,i){return new Promise(async(r,s)=>{const n=setTimeout(()=>s(new Error(i)),e);try{const o=await t;r(o)}catch(o){s(o)}clearTimeout(n)})}function sl(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function Lw(t){return sl("topic",t)}function qw(t){return sl("id",t)}function nl(t){const[e,i]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof i=="string")r.topic=i;else if(e==="id"&&Number.isInteger(Number(i)))r.id=Number(i);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${i}`);return r}function de(t,e){return N.fromMiliseconds((e||Date.now())+N.toMiliseconds(t))}function kt(t){return Date.now()>=N.toMiliseconds(t)}function X(t,e){return`${t}${e?`:${e}`:""}`}function _t(t=[],e=[]){return[...new Set([...t,...e])]}async function kw({id:t,topic:e,wcDeepLink:i}){var r;try{if(!i)return;const s=typeof i=="string"?JSON.parse(i):i,n=s==null?void 0:s.href;
vendor: 38,537 bytes, lines 15-18
15if(typeof n!="string")return;const o=Mw(n,t,e),a=jr();if(a===We.browser){if(!((r=ai())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}zw(o)}else a===We.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(s){console.error(s)}}function Mw(t,e,i){const r=`requestId=${e}&sessionTopic=${i}`;t.endsWith("/")&&(t=t.slice(0,-1));let s=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${Ww(r,!0)}`}else s=`${s}/wc?${r}`;return s}function zw(t){let e="_self";Kw()?e="_top":(Vw()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Hw(t,e){let i="";try{if(ir()&&(i=localStorage.getItem(e),i))return i;i=await t.getItem(e)}catch(r){console.error(r)}return i}function ec(t,e){if(!t.includes(e))return null;const i=t.split(/([&,?,=])/),r=i.indexOf(e);return i[r+2]}function tc(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function jo(){return typeof process<"u"&&{}.IS_VITEST==="true"}function Vw(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Kw(){try{return window.self!==window.top}catch{return!1}}function Ww(t,e=!1){const i=Buffer.from(t).toString("base64");return e?i.replace(/[=]/g,""):i}function ol(t){return Buffer.from(t,"base64").toString("utf-8")}function Gw(t){return new Promise(e=>setTimeout(e,t))}function Or(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Yw(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ur(t,...e){if(!Yw(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Uo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Or(t.outputLen),Or(t.blockLen)}function Vi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function al(t,e){Ur(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const Jr=BigInt(2**32-1),ic=BigInt(32);function Jw(t,e=!1){return e?{h:Number(t&Jr),l:Number(t>>ic&Jr)}:{h:Number(t>>ic&Jr)|0,l:Number(t&Jr)|0}}function Zw(t,e=!1){let i=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=Jw(t[s],e);[i[s],r[s]]=[n,o]}return[i,r]}const Qw=(t,e,i)=>t<<i|e>>>32-i,Xw=(t,e,i)=>e<<i|t>>>32-i,eb=(t,e,i)=>e<<i-32|t>>>64-i,tb=(t,e,i)=>t<<i-32|e>>>64-i,_i=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ib(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ln(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ft(t,e){return t<<32-e|t>>>e}const rc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function rb(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function sc(t){for(let e=0;e<t.length;e++)t[e]=rb(t[e])}function sb(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Ki(t){return typeof t=="string"&&(t=sb(t)),Ur(t),t}function nb(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];Ur(s),e+=s.length}const i=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const n=t[r];i.set(n,s),s+=n.length}return i}let Lo=class{clone(){return this._cloneInto()}};function cl(t){const e=r=>t().update(Ki(r)).digest(),i=t();return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=()=>t(),e}function rr(t=32){if(_i&&typeof _i.getRandomValues=="function")return _i.getRandomValues(new Uint8Array(t));if(_i&&typeof _i.randomBytes=="function")return _i.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ul=[],hl=[],ll=[],ob=BigInt(0),lr=BigInt(1),ab=BigInt(2),cb=BigInt(7),ub=BigInt(256),hb=BigInt(113);for(let t=0,e=lr,i=1,r=0;t<24;t++){[i,r]=[r,(2*i+3*r)%5],ul.push(2*(5*r+i)),hl.push((t+1)*(t+2)/2%64);let s=ob;for(let n=0;n<7;n++)e=(e<<lr^(e>>cb)*hb)%ub,e&ab&&(s^=lr<<(lr<<BigInt(n))-lr);ll.push(s)}const[lb,db]=Zw(ll,!0),nc=(t,e,i)=>i>32?eb(t,e,i):Qw(t,e,i),oc=(t,e,i)=>i>32?tb(t,e,i):Xw(t,e,i);function pb(t,e=24){const i=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)i[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=i[c],h=i[c+1],l=nc(u,h,1)^i[a],d=oc(u,h,1)^i[a+1];for(let f=0;f<50;f+=10)t[o+f]^=l,t[o+f+1]^=d}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=hl[o],c=nc(s,n,a),u=oc(s,n,a),h=ul[o];s=t[h],n=t[h+1],t[h]=c,t[h+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)i[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~i[(a+2)%10]&i[(a+4)%10]}t[0]^=lb[r],t[1]^=db[r]}i.fill(0)}let fb=class dl extends Lo{constructor(e,i,r,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=i,this.outputLen=r,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Or(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ib(this.state)}keccak(){rc||sc(this.state32),pb(this.state32,this.rounds),rc||sc(this.state32),this.posOut=0,this.pos=0}update(e){Vi(this);const{blockLen:i,state:r}=this;e=Ki(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(i-this.pos,s-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===i&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:i,pos:r,blockLen:s}=this;e[r]^=i,i&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Vi(this,!1),Ur(e),this.finish();const i=this.state,{blockLen:r}=this;for(let s=0,n=e.length;s<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-s);e.set(i.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Or(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(al(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:i,suffix:r,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new dl(i,r,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const gb=(t,e,i)=>cl(()=>new fb(e,t,i)),yb=gb(1,136,256/8),mb="https://rpc.walletconnect.org/v1";function pl(t){const e=`�Ethereum Signed Message:
16${t.length}`,i=new TextEncoder().encode(e+t);return"0x"+Buffer.from(yb(i)).toString("hex")}async function wb(t,e,i,r,s,n){switch(i.t){case"eip191":return await bb(t,e,i.s);case"eip1271":return await vb(t,e,i.s,r,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${i.t}`)}}async function bb(t,e,i){return(await Af({hash:pl(e),signature:i})).toLowerCase()===t.toLowerCase()}async function vb(t,e,i,r,s,n){const o=Hi(r);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",h=i.substring(2),l=pl(e).substring(2),d=a+l+c+u+h,f=await fetch(`${n||mb}/?chainId=${r}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:Eb(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Eb(){return Date.now()+Math.floor(Math.random()*1e3)}function _b(t){const e=atob(t),i=new Uint8Array(e.length);for(let o=0;o<e.length;o++)i[o]=e.charCodeAt(o);const r=i[0];if(r===0)throw new Error("No signatures found");const s=1+r*64;if(i.length<s)throw new Error("Transaction data too short for claimed signature count");if(i.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return Tf.encode(n)}var Ib=Object.defineProperty,$b=Object.defineProperties,Db=Object.getOwnPropertyDescriptors,ac=Object.getOwnPropertySymbols,Sb=Object.prototype.hasOwnProperty,Ob=Object.prototype.propertyIsEnumerable,cc=(t,e,i)=>e in t?Ib(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pb=(t,e)=>{for(var i in e||(e={}))Sb.call(e,i)&&cc(t,i,e[i]);if(ac)for(var i of ac(e))Ob.call(e,i)&&cc(t,i,e[i]);return t},Ab=(t,e)=>$b(t,Db(e));const xb="did:pkh:",qo=t=>t==null?void 0:t.split(":"),Cb=t=>{const e=t&&qo(t);if(e)return t.includes(xb)?e[3]:e[1]},Gn=t=>{const e=t&&qo(t);if(e)return e[2]+":"+e[3]},vs=t=>{const e=t&&qo(t);if(e)return e.pop()};async function uc(t){const{cacao:e,projectId:i}=t,{s:r,p:s}=e,n=fl(s,s.iss),o=vs(s.iss);return await wb(o,n,r,Gn(s.iss),i)}const fl=(t,e)=>{const i=`${t.domain} wants you to sign in with your Ethereum account:`,r=vs(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${Cb(e)}`,c=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,h=t.exp?`Expiration Time: ${t.exp}`:void 0,l=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,f=t.resources?`Resources:${t.resources.map(y=>`
17- ${y}`).join("")}`:void 0,p=hs(t.resources);if(p){const y=Pr(p);s=qb(s,y)}return[i,r,"",s,"",n,o,a,c,u,h,l,d,f].filter(y=>y!=null).join(`
18`)};function Tb(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Rb(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function hi(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(i=>{const r=t.att[i];if(Array.isArray(r))throw new Error(`Resource must be an object: ${i}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${i}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${i}`);Object.keys(r).forEach(s=>{const n=r[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function Nb(t,e,i,r={}){return i==null||i.sort((s,n)=>s.localeCompare(n)),{att:{[t]:Fb(e,i,r)}}}function Fb(t,e,i={}){e=e==null?void 0:e.sort((s,n)=>s.localeCompare(n));const r=e.map(s=>({[`${t}/${s}`]:[i]}));return Object.assign({},...r)}function gl(t){return hi(t),`urn:recap:${Tb(t).replace(/=/g,"")}`}function Pr(t){const e=Rb(t.replace("urn:recap:",""));return hi(e),e}function Bb(t,e,i){const r=Nb(t,e,i);return gl(r)}function jb(t){return t&&t.includes("urn:recap:")}function Ub(t,e){const i=Pr(t),r=Pr(e),s=Lb(i,r);return gl(s)}function Lb(t,e){hi(t),hi(e);const i=Object.keys(t.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),r={att:{}};return i.forEach(s=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,u;r.att[s]=Ab(Pb({},r.att[s]),{[a]:((c=t.att[s])==null?void 0:c[a])||((u=e.att[s])==null?void 0:u[a])})})}),r}function qb(t="",e){hi(e);const i="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(i))return t;const r=[];let s=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));c.sort((l,d)=>l.action.localeCompare(d.action));const u={};c.forEach(l=>{u[l.ability]||(u[l.ability]=[]),u[l.ability].push(l.action)});const h=Object.keys(u).map(l=>(s++,`(${s}) '${l}': '${u[l].join("', '")}' for '${a}'.`));r.push(h.join(", ").replace(".,","."))});const n=r.join(" "),o=`${i}${n}`;return`${t?t+" ":""}${o}`}function hc(t){var e;const i=Pr(t);hi(i);const r=(e=i.att)==null?void 0:e.eip155;return r?Object.keys(r).map(s=>s.split("/")[1]):[]}function lc(t){const e=Pr(t);hi(e);const i=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(s=>{var n;(n=s==null?void 0:s[0])!=null&&n.chains&&i.push(s[0].chains)})}),[...new Set(i.flat())]}function hs(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return jb(e)?e:void 0}function dn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function yl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ke(t,...e){if(!yl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function dc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kb(t,e){Ke(t);const i=e.outputLen;if(t.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}function pc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Vt=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Mb=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),zb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zb)throw new Error("Non little-endian hardware is not supported");function Hb(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Yn(t){if(typeof t=="string")t=Hb(t);else if(yl(t))t=Jn(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Vb(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Kb(t,e){if(t.length!==e.length)return!1;let i=0;for(let r=0;r<t.length;r++)i|=t[r]^e[r];return i===0}const Wb=(t,e)=>{function i(r,...s){if(Ke(r),t.nonceLength!==void 0){const u=s[0];if(!u)throw new Error("nonce / iv required");t.varSizeNonce?Ke(u):Ke(u,t.nonceLength)}const n=t.tagLength;n&&s[1]!==void 0&&Ke(s[1]);const o=e(r,...s),a=(u,h)=>{if(h!==void 0){if(u!==2)throw new Error("cipher output not supported");Ke(h)}};let c=!1;return{encrypt(u,h){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Ke(u),a(o.encrypt.length,h),o.encrypt(u,h)},decrypt(u,h){if(Ke(u),n&&u.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(u,h)}}}return Object.assign(i,t),i};function fc(t,e,i=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(i&&!Gb(e))throw new Error("invalid output, must be aligned");return e}function gc(t,e,i,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,i,r);const s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}function Gb(t){return t.byteOffset%4===0}function Jn(t){return Uint8Array.from(t)}function Wi(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const ml=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Yb=ml("expand 16-byte k"),Jb=ml("expand 32-byte k"),Zb=Vt(Yb),Qb=Vt(Jb);function J(t,e){return t<<e|t>>>32-e}function Zn(t){return t.byteOffset%4===0}const Zr=64,Xb=16,wl=2**32-1,yc=new Uint32Array;function e0(t,e,i,r,s,n,o,a){const c=s.length,u=new Uint8Array(Zr),h=Vt(u),l=Zn(s)&&Zn(n),d=l?Vt(s):yc,f=l?Vt(n):yc;for(let p=0;p<c;o++){if(t(e,i,r,h,o,a),o>=wl)throw new Error("arx: counter overflow");const y=Math.min(Zr,c-p);if(l&&y===Zr){const w=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let v=0,b;v<Xb;v++)b=w+v,f[b]=d[b]^h[v];p+=Zr;continue}for(let w=0,v;w<y;w++)v=p+w,n[v]=s[v]^u[w];p+=y}}function t0(t,e){const{allowShortKeys:i,extendNonceFn:r,counterLength:s,counterRight:n,rounds:o}=Vb({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return dn(s),dn(o),pc(n),pc(i),(a,c,u,h,l=0)=>{Ke(a),Ke(c),Ke(u);const d=u.length;if(h===void 0&&(h=new Uint8Array(d)),Ke(h),dn(l),l<0||l>=wl)throw new Error("arx: counter overflow");if(h.length<d)throw new Error(`arx: output (${h.length}) is shorter than data (${d})`);const f=[];let p=a.length,y,w;if(p===32)f.push(y=Jn(a)),w=Qb;else if(p===16&&i)y=new Uint8Array(32),y.set(a),y.set(a,16),w=Zb,f.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Zn(c)||f.push(c=Jn(c));const v=Vt(y);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(w,v,Vt(c.subarray(0,16)),v),c=c.subarray(16)}const b=16-s;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const I=new Uint8Array(12);I.set(c,n?0:12-c.length),c=I,f.push(c)}const E=Vt(c);return e0(t,w,v,E,u,h,l,o),Wi(...f),h}}const _e=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class i0{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Yn(e),Ke(e,32);const i=_e(e,0),r=_e(e,2),s=_e(e,4),n=_e(e,6),o=_e(e,8),a=_e(e,10),c=_e(e,12),u=_e(e,14);this.r[0]=i&8191,this.r[1]=(i>>>13|r<<3)&8191,this.r[2]=(r>>>10|s<<6)&7939,this.r[3]=(s>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let h=0;h<8;h++)this.pad[h]=_e(e,16+2*h)}process(e,i,r=!1){const s=r?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],u=o[2],h=o[3],l=o[4],d=o[5],f=o[6],p=o[7],y=o[8],w=o[9],v=_e(e,i+0),b=_e(e,i+2),E=_e(e,i+4),I=_e(e,i+6),P=_e(e,i+8),A=_e(e,i+10),O=_e(e,i+12),C=_e(e,i+14);let D=n[0]+(v&8191),k=n[1]+((v>>>13|b<<3)&8191),j=n[2]+((b>>>10|E<<6)&8191),B=n[3]+((E>>>7|I<<9)&8191),M=n[4]+((I>>>4|P<<12)&8191),T=n[5]+(P>>>1&8191),g=n[6]+((P>>>14|A<<2)&8191),m=n[7]+((A>>>11|O<<5)&8191),_=n[8]+((O>>>8|C<<8)&8191),S=n[9]+(C>>>5|s),$=0,x=$+D*a+k*(5*w)+j*(5*y)+B*(5*p)+M*(5*f);$=x>>>13,x&=8191,x+=T*(5*d)+g*(5*l)+m*(5*h)+_*(5*u)+S*(5*c),$+=x>>>13,x&=8191;let U=$+D*c+k*a+j*(5*w)+B*(5*y)+M*(5*p);$=U>>>13,U&=8191,U+=T*(5*f)+g*(5*d)+m*(5*l)+_*(5*h)+S*(5*u),$+=U>>>13,U&=8191;let q=$+D*u+k*c+j*a+B*(5*w)+M*(5*y);$=q>>>13,q&=8191,q+=T*(5*p)+g*(5*f)+m*(5*d)+_*(5*l)+S*(5*h),$+=q>>>13,q&=8191;let z=$+D*h+k*u+j*c+B*a+M*(5*w);$=z>>>13,z&=8191,z+=T*(5*y)+g*(5*p)+m*(5*f)+_*(5*d)+S*(5*l),$+=z>>>13,z&=8191;let L=$+D*l+k*h+j*u+B*c+M*a;$=L>>>13,L&=8191,L+=T*(5*w)+g*(5*y)+m*(5*p)+_*(5*f)+S*(5*d),$+=L>>>13,L&=8191;let H=$+D*d+k*l+j*h+B*u+M*c;$=H>>>13,H&=8191,H+=T*a+g*(5*w)+m*(5*y)+_*(5*p)+S*(5*f),$+=H>>>13,H&=8191;let G=$+D*f+k*d+j*l+B*h+M*u;$=G>>>13,G&=8191,G+=T*c+g*a+m*(5*w)+_*(5*y)+S*(5*p),$+=G>>>13,G&=8191;let se=$+D*p+k*f+j*d+B*l+M*h;$=se>>>13,se&=8191,se+=T*u+g*c+m*a+_*(5*w)+S*(5*y),$+=se>>>13,se&=8191;let ee=$+D*y+k*p+j*f+B*d+M*l;$=ee>>>13,ee&=8191,ee+=T*h+g*u+m*c+_*a+S*(5*w),$+=ee>>>13,ee&=8191;let Y=$+D*w+k*y+j*p+B*f+M*d;$=Y>>>13,Y&=8191,Y+=T*l+g*h+m*u+_*c+S*a,$+=Y>>>13,Y&=8191,$=($<<2)+$|0,$=$+x|0,x=$&8191,$=$>>>13,U+=$,n[0]=x,n[1]=U,n[2]=q,n[3]=z,n[4]=L,n[5]=H,n[6]=G,n[7]=se,n[8]=ee,n[9]=Y}finalize(){const{h:e,pad:i}=this,r=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=s,s=e[a]>>>13,e[a]&=8191;e[0]+=s*5,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,r[0]=e[0]+5,s=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+s,s=r[a]>>>13,r[a]&=8191;r[9]-=8192;let n=(s^1)-1;for(let a=0;a<10;a++)r[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|r[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+i[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+i[a]|0)+(o>>>16)|0,e[a]=o&65535;Wi(r)}update(e){dc(this);const{buffer:i,blockLen:r}=this;e=Yn(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);if(o===r){for(;r<=s-n;n+=r)this.process(e,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(i,0,!1),this.pos=0)}return this}destroy(){Wi(this.h,this.r,this.buffer,this.pad)}digestInto(e){dc(this),kb(e,this),this.finished=!0;const{buffer:i,h:r}=this;let{pos:s}=this;if(s){for(i[s++]=1;s<16;s++)i[s]=0;this.process(i,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:i}=this;this.digestInto(e);const r=e.slice(0,i);return this.destroy(),r}}function r0(t){const e=(r,s)=>t(s).update(Yn(r)).digest(),i=t(new Uint8Array(32));return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.create=r=>t(r),e}const s0=r0(t=>new i0(t));function n0(t,e,i,r,s,n=20){let o=t[0],a=t[1],c=t[2],u=t[3],h=e[0],l=e[1],d=e[2],f=e[3],p=e[4],y=e[5],w=e[6],v=e[7],b=s,E=i[0],I=i[1],P=i[2],A=o,O=a,C=c,D=u,k=h,j=l,B=d,M=f,T=p,g=y,m=w,_=v,S=b,$=E,x=I,U=P;for(let z=0;z<n;z+=2)A=A+k|0,S=J(S^A,16),T=T+S|0,k=J(k^T,12),A=A+k|0,S=J(S^A,8),T=T+S|0,k=J(k^T,7),O=O+j|0,$=J($^O,16),g=g+$|0,j=J(j^g,12),O=O+j|0,$=J($^O,8),g=g+$|0,j=J(j^g,7),C=C+B|0,x=J(x^C,16),m=m+x|0,B=J(B^m,12),C=C+B|0,x=J(x^C,8),m=m+x|0,B=J(B^m,7),D=D+M|0,U=J(U^D,16),_=_+U|0,M=J(M^_,12),D=D+M|0,U=J(U^D,8),_=_+U|0,M=J(M^_,7),A=A+j|0,U=J(U^A,16),m=m+U|0,j=J(j^m,12),A=A+j|0,U=J(U^A,8),m=m+U|0,j=J(j^m,7),O=O+B|0,S=J(S^O,16),_=_+S|0,B=J(B^_,12),O=O+B|0,S=J(S^O,8),_=_+S|0,B=J(B^_,7),C=C+M|0,$=J($^C,16),T=T+$|0,M=J(M^T,12),C=C+M|0,$=J($^C,8),T=T+$|0,M=J(M^T,7),D=D+k|0,x=J(x^D,16),g=g+x|0,k=J(k^g,12),D=D+k|0,x=J(x^D,8),g=g+x|0,k=J(k^g,7);let q=0;r[q++]=o+A|0,r[q++]=a+O|0,r[q++]=c+C|0,r[q++]=u+D|0,r[q++]=h+k|0,r[q++]=l+j|0,r[q++]=d+B|0,r[q++]=f+M|0,r[q++]=p+T|0,r[q++]=y+g|0,r[q++]=w+m|0,r[q++]=v+_|0,r[q++]=b+S|0,r[q++]=E+$|0,r[q++]=I+x|0,r[q++]=P+U|0}const o0=t0(n0,{counterRight:!1,counterLength:4,allowShortKeys:!1}),a0=new Uint8Array(16),mc=(t,e)=>{t.update(e);const i=e.length%16;i&&t.update(a0.subarray(i))},c0=new Uint8Array(32);function wc(t,e,i,r,s){const n=t(e,i,c0),o=s0.create(n);s&&mc(o,s),mc(o,r);const a=new Uint8Array(16),c=Mb(a);gc(c,0,BigInt(s?s.length:0),!0),gc(c,8,BigInt(r.length),!0),o.update(a);const u=o.digest();return Wi(n,a),u}const u0=t=>(e,i,r)=>({encrypt(s,n){const o=s.length;n=fc(o+16,n,!1),n.set(s);const a=n.subarray(0,-16);t(e,i,a,a,1);const c=wc(t,e,i,a,r);return n.set(c,o),Wi(c),n},decrypt(s,n){n=fc(s.length-16,n,!1);const o=s.subarray(0,-16),a=s.subarray(-16),c=wc(t,e,i,o,r);if(!Kb(a,c))throw new Error("invalid tag");return n.set(s.subarray(0,-16)),t(e,i,n,n,1),Wi(c),n}}),bl=Wb({blockSize:64,nonceLength:12,tagLength:16},u0(o0));let vl=class extends Lo{constructor(e,i){super(),this.finished=!1,this.destroyed=!1,Uo(e);const r=Ki(i);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,n=new Uint8Array(s);n.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return Vi(this),this.iHash.update(e),this}digestInto(e){Vi(this),Ur(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:i,iHash:r,finished:s,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=i._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Fs=(t,e,i)=>new vl(t,e).update(i).digest();Fs.create=(t,e)=>new vl(t,e);function h0(t,e,i){return Uo(t),i===void 0&&(i=new Uint8Array(t.outputLen)),Fs(t,Ki(i),Ki(e))}const pn=new Uint8Array([0]),bc=new Uint8Array;function l0(t,e,i,r=32){if(Uo(t),Or(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/t.outputLen);i===void 0&&(i=bc);const n=new Uint8Array(s*t.outputLen),o=Fs.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let u=0;u<s;u++)pn[0]=u+1,a.update(u===0?bc:c).update(i).update(pn).digestInto(c),n.set(c,t.outputLen*u),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),pn.fill(0),n.slice(0,r)}const d0=(t,e,i,r,s)=>l0(t,h0(t,e,i),r,s);function p0(t,e,i,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,i,r);const s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,u=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+u,a,r)}function f0(t,e,i){return t&e^~t&i}function g0(t,e,i){return t&e^t&i^e&i}let y0=class extends Lo{constructor(e,i,r,s){super(),this.blockLen=e,this.outputLen=i,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ln(this.buffer)}update(e){Vi(this);const{view:i,buffer:r,blockLen:s}=this;e=Ki(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const c=ln(e);for(;s<=n-o;o+=s)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(i,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Vi(this),al(e,this),this.finished=!0;const{buffer:i,view:r,blockLen:s,isLE:n}=this;let{pos:o}=this;i[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let l=o;l<s;l++)i[l]=0;p0(r,s-8,BigInt(this.length*8),n),this.process(r,0);const a=ln(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,h[l],n)}digest(){const{buffer:e,outputLen:i}=this;this.digestInto(e);const r=e.slice(0,i);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:i,buffer:r,length:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%i&&e.buffer.set(r),e}};const m0=new Uint32Array([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]),Lt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qt=new Uint32Array(64);class w0 extends y0{constructor(){super(64,32,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[7]|0}get(){const{A:e,B:i,C:r,D:s,E:n,F:o,G:a,H:c}=this;return[e,i,r,s,n,o,a,c]}set(e,i,r,s,n,o,a,c){this.A=e|0,this.B=i|0,this.C=r|0,this.D=s|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,i){for(let l=0;l<16;l++,i+=4)qt[l]=e.getUint32(i,!1);for(let l=16;l<64;l++){const d=qt[l-15],f=qt[l-2],p=ft(d,7)^ft(d,18)^d>>>3,y=ft(f,17)^ft(f,19)^f>>>10;qt[l]=y+qt[l-7]+p+qt[l-16]|0}let{A:r,B:s,C:n,D:o,E:a,F:c,G:u,H:h}=this;for(let l=0;l<64;l++){const d=ft(a,6)^ft(a,11)^ft(a,25),f=h+d+f0(a,c,u)+m0[l]+qt[l]|0,p=(ft(r,2)^ft(r,13)^ft(r,22))+g0(r,s,n)|0;h=u,u=c,c=a,a=o+f|0,o=n,n=s,s=r,r=f+p|0}r=r+this.A|0,s=s+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,s,n,o,a,c,u,h)}roundClean(){qt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Lr=cl(()=>new w0);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bs=BigInt(0),js=BigInt(1),b0=BigInt(2);function li(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function qr(t){if(!li(t))throw new Error("Uint8Array expected")}function Gi(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const v0=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Yi(t){qr(t);let e="";for(let i=0;i<t.length;i++)e+=v0[t[i]];return e}function ki(t){const e=t.toString(16);return e.length&1?"0"+e:e}function ko(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Bs:BigInt("0x"+t)}const Pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function vc(t){if(t>=Pt._0&&t<=Pt._9)return t-Pt._0;if(t>=Pt.A&&t<=Pt.F)return t-(Pt.A-10);if(t>=Pt.a&&t<=Pt.f)return t-(Pt.a-10)}function Ji(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,i=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(i);for(let s=0,n=0;s<i;s++,n+=2){const o=vc(t.charCodeAt(n)),a=vc(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[s]=o*16+a}return r}function oi(t){return ko(Yi(t))}function Ar(t){return qr(t),ko(Yi(Uint8Array.from(t).reverse()))}function Zi(t,e){return Ji(t.toString(16).padStart(e*2,"0"))}function Us(t,e){return Zi(t,e).reverse()}function E0(t){return Ji(ki(t))}function Ve(t,e,i){let r;if(typeof e=="string")try{r=Ji(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(li(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof i=="number"&&s!==i)throw new Error(t+" of length "+i+" expected, got "+s);return r}function xr(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];qr(s),e+=s.length}const i=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const n=t[r];i.set(n,s),s+=n.length}return i}function _0(t,e){if(t.length!==e.length)return!1;let i=0;for(let r=0;r<t.length;r++)i|=t[r]^e[r];return i===0}function I0(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const fn=t=>typeof t=="bigint"&&Bs<=t;function Ls(t,e,i){return fn(t)&&fn(e)&&fn(i)&&e<=t&&t<i}function Nt(t,e,i,r){if(!Ls(e,i,r))throw new Error("expected valid "+t+": "+i+" <= n < "+r+", got "+e)}function El(t){let e;for(e=0;t>Bs;t>>=js,e+=1);return e}function $0(t,e){return t>>BigInt(e)&js}function D0(t,e,i){return t|(i?js:Bs)<<BigInt(e)}const Mo=t=>(b0<<BigInt(t-1))-js,gn=t=>new Uint8Array(t),Ec=t=>Uint8Array.from(t);function _l(t,e,i){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof i!="function")throw new Error("hmacFn must be a function");let r=gn(t),s=gn(t),n=0;const o=()=>{r.fill(1),s.fill(0),n=0},a=(...h)=>i(s,r,...h),c=(h=gn())=>{s=a(Ec([0]),h),r=a(),h.length!==0&&(s=a(Ec([1]),h),r=a())},u=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const l=[];for(;h<e;){r=a();const d=r.slice();l.push(d),h+=r.length}return xr(...l)};return(h,l)=>{o(),c(h);let d;for(;!(d=l(u()));)c();return o(),d}}const S0={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||li(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function sr(t,e,i={}){const r=(s,n,o)=>{const a=S0[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[s];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+c)};for(const[s,n]of Object.entries(e))r(s,n,!1);for(const[s,n]of Object.entries(i))r(s,n,!0);return t}const O0=()=>{throw new Error("not implemented")};function Qn(t){const e=new WeakMap;return(i,...r)=>{const s=e.get(i);if(s!==void 0)return s;const n=t(i,...r);return e.set(i,n),n}}var P0=Object.freeze({__proto__:null,isBytes:li,abytes:qr,abool:Gi,bytesToHex:Yi,numberToHexUnpadded:ki,hexToNumber:ko,hexToBytes:Ji,bytesToNumberBE:oi,bytesToNumberLE:Ar,numberToBytesBE:Zi,numberToBytesLE:Us,numberToVarBytesBE:E0,ensureBytes:Ve,concatBytes:xr,equalBytes:_0,utf8ToBytes:I0,inRange:Ls,aInRange:Nt,bitLen:El,bitGet:$0,bitSet:D0,bitMask:Mo,createHmacDrbg:_l,validateObject:sr,notImplemented:O0,memoized:Qn});const ve=BigInt(0),ue=BigInt(1),ti=BigInt(2),A0=BigInt(3),Xn=BigInt(4),_c=BigInt(5),Ic=BigInt(8);function Le(t,e){const i=t%e;return i>=ve?i:e+i}function Il(t,e,i){if(e<ve)throw new Error("invalid exponent, negatives unsupported");if(i<=ve)throw new Error("invalid modulus");if(i===ue)return ve;let r=ue;for(;e>ve;)e&ue&&(r=r*t%i),t=t*t%i,e>>=ue;return r}function ut(t,e,i){let r=t;for(;e-- >ve;)r*=r,r%=i;return r}function eo(t,e){if(t===ve)throw new Error("invert: expected non-zero number");if(e<=ve)throw new Error("invert: expected positive modulus, got "+e);let i=Le(t,e),r=e,s=ve,n=ue;for(;i!==ve;){const o=r/i,a=r%i,c=s-n*o;r=i,i=a,s=n,n=c}if(r!==ue)throw new Error("invert: does not exist");return Le(s,e)}function x0(t){const e=(t-ue)/ti;let i,r,s;for(i=t-ue,r=0;i%ti===ve;i/=ti,r++);for(s=ti;s<t&&Il(s,e,t)!==t-ue;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+ue)/Xn;return function(a,c){const u=a.pow(c,o);if(!a.eql(a.sqr(u),c))throw new Error("Cannot find square root");return u}}const n=(i+ue)/ti;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,u=o.pow(o.mul(o.ONE,s),i),h=o.pow(a,n),l=o.pow(a,i);for(;!o.eql(l,o.ONE);){if(o.eql(l,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(l);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(u,ue<<BigInt(c-d-1));u=o.sqr(f),h=o.mul(h,f),l=o.mul(l,u),c=d}return h}}function C0(t){if(t%Xn===A0){const e=(t+ue)/Xn;return function(i,r){const s=i.pow(r,e);if(!i.eql(i.sqr(s),r))throw new Error("Cannot find square root");return s}}if(t%Ic===_c){const e=(t-_c)/Ic;return function(i,r){const s=i.mul(r,ti),n=i.pow(s,e),o=i.mul(r,n),a=i.mul(i.mul(o,ti),n),c=i.mul(o,i.sub(a,i.ONE));if(!i.eql(i.sqr(c),r))throw new Error("Cannot find square root");return c}}return x0(t)}const T0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function R0(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},i=T0.reduce((r,s)=>(r[s]="function",r),e);return sr(t,i)}function N0(t,e,i){if(i<ve)throw new Error("invalid exponent, negatives unsupported");if(i===ve)return t.ONE;if(i===ue)return e;let r=t.ONE,s=e;for(;i>ve;)i&ue&&(r=t.mul(r,s)),s=t.sqr(s),i>>=ue;return r}function F0(t,e){const i=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(i[a]=n,t.mul(n,o)),t.ONE),s=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(i[a]=t.mul(n,i[a]),t.mul(n,o)),s),i}function $l(t,e){const i=e!==void 0?e:t.toString(2).length,r=Math.ceil(i/8);return{nBitLength:i,nByteLength:r}}function Dl(t,e,i=!1,r={}){if(t<=ve)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:n}=$l(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:i,BITS:s,BYTES:n,MASK:Mo(s),ZERO:ve,ONE:ue,create:c=>Le(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ve<=c&&c<t},is0:c=>c===ve,isOdd:c=>(c&ue)===ue,neg:c=>Le(-c,t),eql:(c,u)=>c===u,sqr:c=>Le(c*c,t),add:(c,u)=>Le(c+u,t),sub:(c,u)=>Le(c-u,t),mul:(c,u)=>Le(c*u,t),pow:(c,u)=>N0(a,c,u),div:(c,u)=>Le(c*eo(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>eo(c,t),sqrt:r.sqrt||(c=>(o||(o=C0(t)),o(a,c))),invertBatch:c=>F0(a,c),cmov:(c,u,h)=>h?u:c,toBytes:c=>i?Us(c,n):Zi(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return i?Ar(c):oi(c)}});return Object.freeze(a)}function Sl(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ol(t){const e=Sl(t);return e+Math.ceil(e/2)}function B0(t,e,i=!1){const r=t.length,s=Sl(e),n=Ol(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=i?Ar(t):oi(t),a=Le(o,e-ue)+ue;return i?Us(a,s):Zi(a,s)}const $c=BigInt(0),Qr=BigInt(1);function yn(t,e){const i=e.negate();return t?i:e}function Pl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function mn(t,e){Pl(t,e);const i=Math.ceil(e/t)+1,r=2**(t-1);return{windows:i,windowSize:r}}function j0(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((i,r)=>{if(!(i instanceof e))throw new Error("invalid point at index "+r)})}function U0(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((i,r)=>{if(!e.isValid(i))throw new Error("invalid scalar at index "+r)})}const wn=new WeakMap,Al=new WeakMap;function bn(t){return Al.get(t)||1}function L0(t,e){return{constTimeNegate:yn,hasPrecomputes(i){return bn(i)!==1},unsafeLadder(i,r,s=t.ZERO){let n=i;for(;r>$c;)r&Qr&&(s=s.add(n)),n=n.double(),r>>=Qr;return s},precomputeWindow(i,r){const{windows:s,windowSize:n}=mn(r,e),o=[];let a=i,c=a;for(let u=0;u<s;u++){c=a,o.push(c);for(let h=1;h<n;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(i,r,s){const{windows:n,windowSize:o}=mn(i,e);let a=t.ZERO,c=t.BASE;
18const u=BigInt(2**i-1),h=2**i,l=BigInt(i);for(let d=0;d<n;d++){const f=d*o;let p=Number(s&u);s>>=l,p>o&&(p-=h,s+=Qr);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(yn(v,r[y])):a=a.add(yn(b,r[w]))}return{p:a,f:c}},wNAFUnsafe(i,r,s,n=t.ZERO){const{windows:o,windowSize:a}=mn(i,e),c=BigInt(2**i-1),u=2**i,h=BigInt(i);for(let l=0;l<o;l++){const d=l*a;if(s===$c)break;let f=Number(s&c);if(s>>=h,f>a&&(f-=u,s+=Qr),f===0)continue;let p=r[d+Math.abs(f)-1];f<0&&(p=p.negate()),n=n.add(p)}return n},getPrecomputes(i,r,s){let n=wn.get(r);return n||(n=this.precomputeWindow(r,i),i!==1&&wn.set(r,s(n))),n},wNAFCached(i,r,s){const n=bn(i);return this.wNAF(n,this.getPrecomputes(n,i,s),r)},wNAFCachedUnsafe(i,r,s,n){const o=bn(i);return o===1?this.unsafeLadder(i,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,i,s),r,n)},setWindowSize(i,r){Pl(r,e),Al.set(i,r),wn.delete(i)}}}function q0(t,e,i,r){if(j0(i,t),U0(r,e),i.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,n=El(BigInt(i.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(s),u=Math.floor((e.BITS-1)/o)*o;let h=s;for(let l=u;l>=0;l-=o){c.fill(s);for(let f=0;f<r.length;f++){const p=r[f],y=Number(p>>BigInt(l)&BigInt(a));c[y]=c[y].add(i[f])}let d=s;for(let f=c.length-1,p=s;f>0;f--)p=p.add(c[f]),d=d.add(p);if(h=h.add(d),l!==0)for(let f=0;f<o;f++)h=h.double()}return h}function xl(t){return R0(t.Fp),sr(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...$l(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Ii=BigInt(0),vn=BigInt(1);function k0(t){return sr(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function M0(t){const e=k0(t),{P:i}=e,r=b=>Le(b,i),s=e.montgomeryBits,n=Math.ceil(s/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>Il(b,i-BigInt(2),i));function u(b,E,I){const P=r(b*(E-I));return E=r(E-P),I=r(I+P),[E,I]}const h=(e.a-BigInt(2))/BigInt(4);function l(b,E){Nt("u",b,Ii,i),Nt("scalar",E,Ii,i);const I=E,P=b;let A=vn,O=Ii,C=b,D=vn,k=Ii,j;for(let M=BigInt(s-1);M>=Ii;M--){const T=I>>M&vn;k^=T,j=u(k,A,C),A=j[0],C=j[1],j=u(k,O,D),O=j[0],D=j[1],k=T;const g=A+O,m=r(g*g),_=A-O,S=r(_*_),$=m-S,x=C+D,U=C-D,q=r(U*g),z=r(x*_),L=q+z,H=q-z;C=r(L*L),D=r(P*r(H*H)),A=r(m*S),O=r($*(m+r(h*$)))}j=u(k,A,C),A=j[0],C=j[1],j=u(k,O,D),O=j[0],D=j[1];const B=c(O);return r(A*B)}function d(b){return Us(r(b),n)}function f(b){const E=Ve("u coordinate",b,n);return o===32&&(E[31]&=127),Ar(E)}function p(b){const E=Ve("scalar",b),I=E.length;if(I!==n&&I!==o){let P=""+n+" or "+o;throw new Error("invalid scalar, expected "+P+" bytes, got "+I)}return Ar(a(E))}function y(b,E){const I=f(E),P=p(b),A=l(I,P);if(A===Ii)throw new Error("invalid private or public key received");return d(A)}const w=d(e.Gu);function v(b){return y(b,w)}return{scalarMult:y,scalarMultBase:v,getSharedSecret:(b,E)=>y(b,E),getPublicKey:b=>v(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:w}}const to=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const z0=BigInt(1),Dc=BigInt(2),H0=BigInt(3),V0=BigInt(5);BigInt(8);function K0(t){const e=BigInt(10),i=BigInt(20),r=BigInt(40),s=BigInt(80),n=to,o=t*t%n*t%n,a=ut(o,Dc,n)*o%n,c=ut(a,z0,n)*t%n,u=ut(c,V0,n)*c%n,h=ut(u,e,n)*u%n,l=ut(h,i,n)*h%n,d=ut(l,r,n)*l%n,f=ut(d,s,n)*d%n,p=ut(f,s,n)*d%n,y=ut(p,e,n)*u%n;return{pow_p_5_8:ut(y,Dc,n)*t%n,b2:o}}function W0(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const io=M0({P:to,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=to,{pow_p_5_8:i,b2:r}=K0(t);return Le(ut(i,H0,e)*r,e)},adjustScalarBytes:W0,randomBytes:rr});function Sc(t){t.lowS!==void 0&&Gi("lowS",t.lowS),t.prehash!==void 0&&Gi("prehash",t.prehash)}function G0(t){const e=xl(t);sr(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});
vendor: 7,698 bytes, line 18
18const{endo:i,Fp:r,a:s}=e;if(i){if(!r.eql(s,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof i!="object"||typeof i.beta!="bigint"||typeof i.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Y0,hexToBytes:J0}=P0;class Z0 extends Error{constructor(e=""){super(e)}}const Tt={Err:Z0,_tlv:{encode:(t,e)=>{const{Err:i}=Tt;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(e.length&1)throw new i("tlv.encode: unpadded data");const r=e.length/2,s=ki(r);if(s.length/2&128)throw new i("tlv.encode: long form length too big");const n=r>127?ki(s.length/2|128):"";return ki(t)+n+s+e},decode(t,e){const{Err:i}=Tt;let r=0;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new i("tlv.decode: wrong tlv");const s=e[r++],n=!!(s&128);let o=0;if(!n)o=s;else{const c=s&127;if(!c)throw new i("tlv.decode(long): indefinite length not supported");if(c>4)throw new i("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+c);if(u.length!==c)throw new i("tlv.decode: length bytes not complete");if(u[0]===0)throw new i("tlv.decode(long): zero leftmost byte");for(const h of u)o=o<<8|h;if(r+=c,o<128)throw new i("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new i("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=Tt;if(t<Rt)throw new e("integer: negative integers are not allowed");let i=ki(t);if(Number.parseInt(i[0],16)&8&&(i="00"+i),i.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return i},decode(t){const{Err:e}=Tt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Y0(t)}},toSig(t){const{Err:e,_int:i,_tlv:r}=Tt,s=typeof t=="string"?J0(t):t;qr(s);const{v:n,l:o}=r.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:u,l:h}=r.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:i.decode(a),s:i.decode(u)}},hexFromSig(t){const{_tlv:e,_int:i}=Tt,r=e.encode(2,i.encode(t.r)),s=e.encode(2,i.encode(t.s)),n=r+s;return e.encode(48,n)}},Rt=BigInt(0),me=BigInt(1);BigInt(2);const Oc=BigInt(3);BigInt(4);function Q0(t){const e=G0(t),{Fp:i}=e,r=Dl(e.n,e.nBitLength),s=e.toBytes||((y,w,v)=>{const b=w.toAffine();return xr(Uint8Array.from([4]),i.toBytes(b.x),i.toBytes(b.y))}),n=e.fromBytes||(y=>{const w=y.subarray(1),v=i.fromBytes(w.subarray(0,i.BYTES)),b=i.fromBytes(w.subarray(i.BYTES,2*i.BYTES));return{x:v,y:b}});function o(y){const{a:w,b:v}=e,b=i.sqr(y),E=i.mul(b,y);return i.add(i.add(E,i.mul(y,w)),v)}if(!i.eql(i.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Ls(y,me,e.n)}function c(y){const{allowedPrivateKeyLengths:w,nByteLength:v,wrapPrivateKey:b,n:E}=e;if(w&&typeof y!="bigint"){if(li(y)&&(y=Yi(y)),typeof y!="string"||!w.includes(y.length))throw new Error("invalid private key");y=y.padStart(v*2,"0")}let I;try{I=typeof y=="bigint"?y:oi(Ve("private key",y,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof y)}return b&&(I=Le(I,E)),Nt("private key",I,me,E),I}function u(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}const h=Qn((y,w)=>{const{px:v,py:b,pz:E}=y;if(i.eql(E,i.ONE))return{x:v,y:b};const I=y.is0();w==null&&(w=I?i.ONE:i.inv(E));const P=i.mul(v,w),A=i.mul(b,w),O=i.mul(E,w);if(I)return{x:i.ZERO,y:i.ZERO};if(!i.eql(O,i.ONE))throw new Error("invZ was invalid");return{x:P,y:A}}),l=Qn(y=>{if(y.is0()){if(e.allowInfinityPoint&&!i.is0(y.py))return;throw new Error("bad point: ZERO")}const{x:w,y:v}=y.toAffine();if(!i.isValid(w)||!i.isValid(v))throw new Error("bad point: x or y not FE");const b=i.sqr(v),E=o(w);if(!i.eql(b,E))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(w,v,b){if(this.px=w,this.py=v,this.pz=b,w==null||!i.isValid(w))throw new Error("x required");if(v==null||!i.isValid(v))throw new Error("y required");if(b==null||!i.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(w){const{x:v,y:b}=w||{};if(!w||!i.isValid(v)||!i.isValid(b))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");const E=I=>i.eql(I,i.ZERO);return E(v)&&E(b)?d.ZERO:new d(v,b,i.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const v=i.invertBatch(w.map(b=>b.pz));return w.map((b,E)=>b.toAffine(v[E])).map(d.fromAffine)}static fromHex(w){const v=d.fromAffine(n(Ve("pointHex",w)));return v.assertValidity(),v}static fromPrivateKey(w){return d.BASE.multiply(c(w))}static msm(w,v){return q0(d,r,w,v)}_setWindowSize(w){p.setWindowSize(this,w)}assertValidity(){l(this)}hasEvenY(){const{y:w}=this.toAffine();if(i.isOdd)return!i.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){u(w);const{px:v,py:b,pz:E}=this,{px:I,py:P,pz:A}=w,O=i.eql(i.mul(v,A),i.mul(I,E)),C=i.eql(i.mul(b,A),i.mul(P,E));return O&&C}negate(){return new d(this.px,i.neg(this.py),this.pz)}double(){const{a:w,b:v}=e,b=i.mul(v,Oc),{px:E,py:I,pz:P}=this;let A=i.ZERO,O=i.ZERO,C=i.ZERO,D=i.mul(E,E),k=i.mul(I,I),j=i.mul(P,P),B=i.mul(E,I);return B=i.add(B,B),C=i.mul(E,P),C=i.add(C,C),A=i.mul(w,C),O=i.mul(b,j),O=i.add(A,O),A=i.sub(k,O),O=i.add(k,O),O=i.mul(A,O),A=i.mul(B,A),C=i.mul(b,C),j=i.mul(w,j),B=i.sub(D,j),B=i.mul(w,B),B=i.add(B,C),C=i.add(D,D),D=i.add(C,D),D=i.add(D,j),D=i.mul(D,B),O=i.add(O,D),j=i.mul(I,P),j=i.add(j,j),D=i.mul(j,B),A=i.sub(A,D),C=i.mul(j,k),C=i.add(C,C),C=i.add(C,C),new d(A,O,C)}add(w){u(w);const{px:v,py:b,pz:E}=this,{px:I,py:P,pz:A}=w;let O=i.ZERO,C=i.ZERO,D=i.ZERO;const k=e.a,j=i.mul(e.b,Oc);let B=i.mul(v,I),M=i.mul(b,P),T=i.mul(E,A),g=i.add(v,b),m=i.add(I,P);g=i.mul(g,m),m=i.add(B,M),g=i.sub(g,m),m=i.add(v,E);let _=i.add(I,A);return m=i.mul(m,_),_=i.add(B,T),m=i.sub(m,_),_=i.add(b,E),O=i.add(P,A),_=i.mul(_,O),O=i.add(M,T),_=i.sub(_,O),D=i.mul(k,m),O=i.mul(j,T),D=i.add(O,D),O=i.sub(M,D),D=i.add(M,D),C=i.mul(O,D),M=i.add(B,B),M=i.add(M,B),T=i.mul(k,T),m=i.mul(j,m),M=i.add(M,T),T=i.sub(B,T),T=i.mul(k,T),m=i.add(m,T),B=i.mul(M,m),C=i.add(C,B),B=i.mul(_,m),O=i.mul(g,O),O=i.sub(O,B),B=i.mul(g,M),D=i.mul(_,D),D=i.add(D,B),new d(O,C,D)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return p.wNAFCached(this,w,d.normalizeZ)}multiplyUnsafe(w){const{endo:v,n:b}=e;Nt("scalar",w,Rt,b);const E=d.ZERO;if(w===Rt)return E;if(this.is0()||w===me)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,w,d.normalizeZ);let{k1neg:I,k1:P,k2neg:A,k2:O}=v.splitScalar(w),C=E,D=E,k=this;for(;P>Rt||O>Rt;)P&me&&(C=C.add(k)),O&me&&(D=D.add(k)),k=k.double(),P>>=me,O>>=me;return I&&(C=C.negate()),A&&(D=D.negate()),D=new d(i.mul(D.px,v.beta),D.py,D.pz),C.add(D)}multiply(w){const{endo:v,n:b}=e;Nt("scalar",w,me,b);let E,I;if(v){const{k1neg:P,k1:A,k2neg:O,k2:C}=v.splitScalar(w);let{p:D,f:k}=this.wNAF(A),{p:j,f:B}=this.wNAF(C);D=p.constTimeNegate(P,D),j=p.constTimeNegate(O,j),j=new d(i.mul(j.px,v.beta),j.py,j.pz),E=D.add(j),I=k.add(B)}else{const{p:P,f:A}=this.wNAF(w);E=P,I=A}return d.normalizeZ([E,I])[0]}multiplyAndAddUnsafe(w,v,b){const E=d.BASE,I=(A,O)=>O===Rt||O===me||!A.equals(E)?A.multiplyUnsafe(O):A.multiply(O),P=I(this,v).add(I(w,b));return P.is0()?void 0:P}toAffine(w){return h(this,w)}isTorsionFree(){const{h:w,isTorsionFree:v}=e;if(w===me)return!0;
18if(v)return v(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:v}=e;return w===me?this:v?v(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return Gi("isCompressed",w),this.assertValidity(),s(d,this,w)}toHex(w=!0){return Gi("isCompressed",w),Yi(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,i.ONE),d.ZERO=new d(i.ZERO,i.ONE,i.ZERO);const f=e.nBitLength,p=L0(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function X0(t){const e=xl(t);return sr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ev(t){const e=X0(t),{Fp:i,n:r}=e,s=i.BYTES+1,n=2*i.BYTES+1;function o(T){return Le(T,r)}function a(T){return eo(T,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:h,isWithinCurveOrder:l}=Q0({...e,toBytes(T,g,m){const _=g.toAffine(),S=i.toBytes(_.x),$=xr;return Gi("isCompressed",m),m?$(Uint8Array.from([g.hasEvenY()?2:3]),S):$(Uint8Array.from([4]),S,i.toBytes(_.y))},fromBytes(T){const g=T.length,m=T[0],_=T.subarray(1);if(g===s&&(m===2||m===3)){const S=oi(_);if(!Ls(S,me,i.ORDER))throw new Error("Point is not on curve");const $=h(S);let x;try{x=i.sqrt($)}catch(q){const z=q instanceof Error?": "+q.message:"";throw new Error("Point is not on curve"+z)}const U=(x&me)===me;return(m&1)===1!==U&&(x=i.neg(x)),{x:S,y:x}}else if(g===n&&m===4){const S=i.fromBytes(_.subarray(0,i.BYTES)),$=i.fromBytes(_.subarray(i.BYTES,2*i.BYTES));return{x:S,y:$}}else{const S=s,$=n;throw new Error("invalid Point, expected length of "+S+", or uncompressed "+$+", got "+g)}}}),d=T=>Yi(Zi(T,e.nByteLength));function f(T){const g=r>>me;return T>g}function p(T){return f(T)?o(-T):T}const y=(T,g,m)=>oi(T.slice(g,m));class w{constructor(g,m,_){this.r=g,this.s=m,this.recovery=_,this.assertValidity()}static fromCompact(g){const m=e.nByteLength;return g=Ve("compactSignature",g,m*2),new w(y(g,0,m),y(g,m,2*m))}static fromDER(g){const{r:m,s:_}=Tt.toSig(Ve("DER",g));return new w(m,_)}assertValidity(){Nt("r",this.r,me,r),Nt("s",this.s,me,r)}addRecoveryBit(g){return new w(this.r,this.s,g)}recoverPublicKey(g){const{r:m,s:_,recovery:S}=this,$=A(Ve("msgHash",g));if(S==null||![0,1,2,3].includes(S))throw new Error("recovery id invalid");const x=S===2||S===3?m+e.n:m;if(x>=i.ORDER)throw new Error("recovery id 2 or 3 invalid");const U=S&1?"03":"02",q=c.fromHex(U+d(x)),z=a(x),L=o(-$*z),H=o(_*z),G=c.BASE.multiplyAndAddUnsafe(q,L,H);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ji(this.toDERHex())}toDERHex(){return Tt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ji(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const v={isValidPrivateKey(T){try{return u(T),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const T=Ol(e.n);return B0(e.randomBytes(T),e.n)},precompute(T=8,g=c.BASE){return g._setWindowSize(T),g.multiply(BigInt(3)),g}};function b(T,g=!0){return c.fromPrivateKey(T).toRawBytes(g)}function E(T){const g=li(T),m=typeof T=="string",_=(g||m)&&T.length;return g?_===s||_===n:m?_===2*s||_===2*n:T instanceof c}function I(T,g,m=!0){if(E(T))throw new Error("first arg must be private key");if(!E(g))throw new Error("second arg must be public key");return c.fromHex(g).multiply(u(T)).toRawBytes(m)}const P=e.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");const g=oi(T),m=T.length*8-e.nBitLength;return m>0?g>>BigInt(m):g},A=e.bits2int_modN||function(T){return o(P(T))},O=Mo(e.nBitLength);function C(T){return Nt("num < 2^"+e.nBitLength,T,Rt,O),Zi(T,e.nByteLength)}function D(T,g,m=k){if(["recovered","canonical"].some(ee=>ee in m))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:S}=e;let{lowS:$,prehash:x,extraEntropy:U}=m;$==null&&($=!0),T=Ve("msgHash",T),Sc(m),x&&(T=Ve("prehashed msgHash",_(T)));const q=A(T),z=u(g),L=[C(z),C(q)];if(U!=null&&U!==!1){const ee=U===!0?S(i.BYTES):U;L.push(Ve("extraEntropy",ee))}const H=xr(...L),G=q;function se(ee){const Y=P(ee);if(!l(Y))return;const Ae=a(Y),Ee=c.BASE.multiply(Y).toAffine(),Ce=o(Ee.x);if(Ce===Rt)return;const Ye=o(Ae*o(G+Ce*z));if(Ye===Rt)return;let Je=(Ee.x===Ce?0:2)|Number(Ee.y&me),wi=Ye;return $&&f(Ye)&&(wi=p(Ye),Je^=1),new w(Ce,wi,Je)}return{seed:H,k2sig:se}}const k={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function B(T,g,m=k){const{seed:_,k2sig:S}=D(T,g,m),$=e;return _l($.hash.outputLen,$.nByteLength,$.hmac)(_,S)}c.BASE._setWindowSize(8);function M(T,g,m,_=j){var Ye;const S=T;g=Ve("msgHash",g),m=Ve("publicKey",m);const{lowS:$,prehash:x,format:U}=_;if(Sc(_),"strict"in _)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");const q=typeof S=="string"||li(S),z=!q&&!U&&typeof S=="object"&&S!==null&&typeof S.r
18=="bigint"&&typeof S.s=="bigint";if(!q&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let L,H;try{if(z&&(L=new w(S.r,S.s)),q){try{U!=="compact"&&(L=w.fromDER(S))}catch(Je){if(!(Je instanceof Tt.Err))throw Je}!L&&U!=="der"&&(L=w.fromCompact(S))}H=c.fromHex(m)}catch{return!1}if(!L||$&&L.hasHighS())return!1;x&&(g=e.hash(g));const{r:G,s:se}=L,ee=A(g),Y=a(se),Ae=o(ee*Y),Ee=o(G*Y),Ce=(Ye=c.BASE.multiplyAndAddUnsafe(H,Ae,Ee))==null?void 0:Ye.toAffine();return Ce?o(Ce.x)===G:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:I,sign:B,verify:M,ProjectivePoint:c,Signature:w,utils:v}}function tv(t){return{hash:t,hmac:(e,...i)=>Fs(t,e,nb(...i)),randomBytes:rr}}function iv(t,e){const i=r=>ev({...t,...tv(r)});return{...i(e),create:i}}const Cl=Dl(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),rv=Cl.create(BigInt("-3")),sv=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),nv=iv({a:rv,b:sv,Fp:Cl,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Lr),Tl="base10",Re="base16",ht="base64pad",Mt="base64url",kr="utf8",Rl=0,Ft=1,Mr=2,ov=0,Pc=1,Er=12,zo=32;function av(){const t=io.utils.randomPrivateKey(),e=io.getPublicKey(t);return{privateKey:qe(t,Re),publicKey:qe(e,Re)}}function ro(){const t=rr(zo);return qe(t,Re)}function cv(t,e){const i=io.getSharedSecret(tt(t,Re),tt(e,Re)),r=d0(Lr,
18i,void 0,void 0,zo);return qe(r,Re)}function ls(t){const e=Lr(tt(t,Re));return qe(e,Re)}function Et(t){const e=Lr(tt(t,kr));return qe(e,Re)}function Nl(t){return tt(`${t}`,Tl)}function di(t){return Number(qe(t,Tl))}function Fl(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Bl(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),i=(4-e.length%4)%4;return e+"=".repeat(i)}function uv(t){const e=Nl(typeof t.type<"u"?t.type:Rl);if(di(e)===Ft&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const i=typeof t.senderPublicKey<"u"?tt(t.senderPublicKey,Re):void 0,r=typeof t.iv<"u"?tt(t.iv,Re):rr(Er),s=tt(t.symKey,Re),n=bl(s,r).encrypt(tt(t.message,kr)),o=jl({type:e,sealed:n,iv:r,senderPublicKey:i});return t.encoding===Mt?Fl(o):o}function hv(t){const e=tt(t.symKey,Re),{sealed:i,iv:r}=Cr({encoded:t.encoded,encoding:t.encoding}),s=bl(e,r).decrypt(i);if(s===null)throw new Error("Failed to decrypt");return qe(s,kr)}function lv(t,e){const i=Nl(Mr),r=rr(Er),s=tt(t,kr),n=jl({type:i,sealed:s,iv:r});return e===Mt?Fl(n):n}function dv(t,e){const{sealed:i}=Cr({encoded:t,encoding:e});return qe(i,kr)}function jl(t){if(di(t.type)===Mr)return qe(vr([t.type,t.sealed]),ht);if(di(t.type)===Ft){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return qe(vr([t.type,t.senderPublicKey,t.iv,t.sealed]),ht)}return qe(vr([t.type,t.iv,t.sealed]),ht)}function Cr(t){const e=(t.encoding||ht)===Mt?Bl(t.encoded):t.encoded,i=tt(e,ht),r=i.slice(ov,Pc),s=Pc;if(di(r)===Ft){const c=s+zo,u=c+Er,h=i.slice(s,c),l=i.slice(c,u),d=i.slice(u);return{type:r,sealed:d,iv:l,senderPublicKey:h}}if(di(r)===Mr){const c=i.slice(s),u=rr(Er);return{type:r,sealed:c,iv:u}}const n=s+Er,o=i.slice(s,n),a=i.slice(n);return{type:r,sealed:a,iv:o}}function pv(t,e){const i=Cr({encoded:t,encoding:e==null?void 0:e.encoding});return Ul({type:di(i.type),senderPublicKey:typeof i.senderPublicKey<"u"?qe(i.senderPublicKey,Re):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Ul(t){const e=(t==null?void 0:t.type)||Rl;if(e===Ft){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function Ac(t){return t.type===Ft&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function xc(t){return t.type===Mr}function fv(t){const e=Buffer.from(t.x,"base64"),i=Buffer.from(t.y,"base64");return vr([new Uint8Array([4]),e,i])}function gv(t,e){const[i,r,s]=t.split("."),n=Buffer.from(Bl(s),"base64");if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=`${i}.${r}`,u=Lr(c),h=fv(e);if(!nv.verify(vr([o,a]),u,h))throw new Error("Invalid signature");return Vn(t).payload}const yv="irn";function Es(t){return(t==null?void 0:t.relay)||{protocol:yv}}function wr(t){const e=_w[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function mv(t,e="-"){const i={},r="relay"+e;return Object.keys(t).forEach(s=>{if(s.startsWith(r)){const n=s.replace(r,""),o=t[s];i[n]=o}}),i}function Cc(t){if(!t.includes("wc:")){const u=ol(t);u!=null&&u.includes("wc:")&&(t=u)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),i=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),s=t.substring(e+1,i).split("@"),n=typeof i<"u"?t.substring(i):"",o=new URLSearchParams(n),a={};o.forEach((u,h)=>{a[h]=u});
18const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:r,topic:wv(s[0]),version:parseInt(s[1],10),symKey:a.symKey,relay:mv(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function wv(t){return t.startsWith("//")?t.substring(2):t}function bv(t,e="-"){const i="relay",r={};return Object.keys(t).forEach(s=>{const n=s,o=i+e+n;t[n]&&(r[o]=t[n])}),r}function Tc(t){const e=new URLSearchParams,i=bv(t.relay);Object.keys(i).sort().forEach(s=>{e.set(s,i[s])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const r=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${r}`}function Xr(t,e,i){return`${t}?wc_ev=${i}&topic=${e}`}var vv=Object.defineProperty,Ev=Object.defineProperties,_v=Object.getOwnPropertyDescriptors,Rc=Object.getOwnPropertySymbols,Iv=Object.prototype.hasOwnProperty,$v=Object.prototype.propertyIsEnumerable,Nc=(t,e,i)=>e in t?vv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dv=(t,e)=>{for(var i in e||(e={}))Iv.call(e,i)&&Nc(t,i,e[i]);if(Rc)for(var i of Rc(e))$v.call(e,i)&&Nc(t,i,e[i]);return t},Sv=(t,e)=>Ev(t,_v(e));function nr(t){const e=[];return t.forEach(i=>{const[r,s]=i.split(":");e.push(`${r}:${s}`)}),e}function Ov(t){const e=[];return Object.values(t).forEach(i=>{e.push(...nr(i.accounts))}),e}function Pv(t,e){const i=[];return Object.values(t).forEach(r=>{nr(r.accounts).includes(e)&&i.push(...r.methods)}),i}function Av(t,e){const i=[];return Object.values(t).forEach(r=>{nr(r.accounts).includes(e)&&i.push(...r.events)}),i}function qs(t){return t.includes(":")}function Mi(t){return qs(t)?t.split(":")[0]:t}function Fc(t){var e,i,r;const s={};if(!Kt(t))return s;for(const[n,o]of Object.entries(t)){const a=qs(n)?[n]:o.chains,c=o.methods||[],u=o.events||[],h=Mi(n);s[h]=Sv(Dv({},s[h]),{chains:_t(a,(e=s[h])==null?void 0:e.chains),methods:_t(c,(i=s[h])==null?void 0:i.methods),events:_t(u,(r=s[h])==null?void 0:r.events)})}return s}function xv(t){const e={};return t==null||t.forEach(i=>{var r;const[s,n]=i.split(":");e[s]||(e[s]={accounts:[],chains:[],events:[],methods:[]}),e[s].accounts.push(i),(r=e[s].chains)==null||r.push(`${s}:${n}`)}),e}function Bc(t,e){e=e.map(r=>r.replace("did:pkh:",""));const i=xv(e);for(const[r,s]of Object.entries(i))s.methods?s.methods=_t(s.methods,t):s.methods=t,s.events=["chainChanged","accountsChanged"];return i}function Cv(t,e){var i,r,s,n,o,a;const c=Fc(t),u=Fc(e),h={},l=Object.keys(c).concat(Object.keys(u));for(const d of l)h[d]={chains:_t((i=c[d])==null?void 0:i.chains,(r=u[d])==null?void 0:r.chains),methods:_t((s=c[d])==null?void 0:s.methods,(n=u[d])==null?void 0:n.methods),events:_t((o=c[d])==null?void 0:o.events,(a=u[d])==null?void 0:a.events)};return h}const Tv={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Rv={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function F(t,e){const{message:i,code:r}=Rv[t];return{message:e?`${i} ${e}`:i,code:r}}function te(t,e){const{message:i,code:r}=Tv[t];return{message:e?`${i} ${e}`:i,code:r}}function lt(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Kt(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function De(t){return typeof t>"u"}function le(t,e){return e&&De(t)?!0:typeof t=="string"&&!!t.trim().length}function Ho(t,e){return e&&De(t)?!0:typeof t=="number"&&!isNaN(t)}function Nv(t,e){const{requiredNamespaces:i}=e,r=Object.keys(t.namespaces),s=Object.keys(i);let n=!0;return si(s,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:u}=t.namespaces[o],h=nr(a),l=i[o];
vendor: 4,360 bytes, lines 18-24
18(!si(tl(o,l),h)||!si(l.methods,c)||!si(l.events,u))&&(n=!1)}),n):!1}function _s(t){return le(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Fv(t){if(le(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const i=e[0]+":"+e[1];return!!e[2]&&_s(i)}}return!1}function Bv(t){function e(i){try{return typeof new URL(i)<"u"}catch{return!1}}try{if(le(t,!1)){if(e(t))return!0;const i=ol(t);return e(i)}}catch{}return!1}function jv(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function Uv(t){return t==null?void 0:t.topic}function Lv(t,e){let i=null;return le(t==null?void 0:t.publicKey,!1)||(i=F("MISSING_OR_INVALID",`${e} controller public key should be a string`)),i}function jc(t){let e=!0;return lt(t)?t.length&&(e=t.every(i=>le(i,!1))):e=!1,e}function qv(t,e,i){let r=null;return lt(e)&&e.length?e.forEach(s=>{r||_s(s)||(r=te("UNSUPPORTED_CHAINS",`${i}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):_s(t)||(r=te("UNSUPPORTED_CHAINS",`${i}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}function kv(t,e,i){let r=null;return Object.entries(t).forEach(([s,n])=>{if(r)return;const o=qv(s,tl(s,n),`${e} ${i}`);o&&(r=o)}),r}function Mv(t,e){let i=null;return lt(t)?t.forEach(r=>{i||Fv(r)||(i=te("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):i=te("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),i}function zv(t,e){let i=null;return Object.values(t).forEach(r=>{if(i)return;const s=Mv(r==null?void 0:r.accounts,`${e} namespace`);s&&(i=s)}),i}function Hv(t,e){let i=null;return jc(t==null?void 0:t.methods)?jc(t==null?void 0:t.events)||(i=te("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):i=te("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),i}function Ll(t,e){let i=null;return Object.values(t).forEach(r=>{if(i)return;const s=Hv(r,`${e}, namespace`);s&&(i=s)}),i}function Vv(t,e,i){let r=null;if(t&&Kt(t)){const s=Ll(t,e);s&&(r=s);const n=kv(t,e,i);n&&(r=n)}else r=F("MISSING_OR_INVALID",`${e}, ${i} should be an object with data`);return r}function En(t,e){let i=null;if(t&&Kt(t)){const r=Ll(t,e);r&&(i=r);const s=zv(t,e);s&&(i=s)}else i=F("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return i}function ql(t){return le(t.protocol,!0)}function Kv(t,e){let i=!1;return e&&!t?i=!0:t&&lt(t)&&t.length&&t.forEach(r=>{i=ql(r)}),i}function Wv(t){return typeof t=="number"}function Ue(t){return typeof t<"u"&&typeof t!==null}function Gv(t){return!(!t||typeof t!="object"||!t.code||!Ho(t.code,!1)||!t.message||!le(t.message,!1))}function Yv(t){return!(De(t)||!le(t.method,!1))}function Jv(t){return!(De(t)||De(t.result)&&De(t.error)||!Ho(t.id,!1)||!le(t.jsonrpc,!1))}function Zv(t){return!(De(t)||!le(t.name,!1))}function Uc(t,e){return!(!_s(e)||!Ov(t).includes(e))}function Qv(t,e,i){return le(i,!1)?Pv(t,e).includes(i):!1}function Xv(t,e,i){return le(i,!1)?Av(t,e).includes(i):!1}function Lc(t,e,i){let r=null;const s=e1(t),n=t1(e),o=Object.keys(s),a=Object.keys(n),c=qc(Object.keys(t)),u=qc(Object.keys(e)),h=c.filter(l=>!u.includes(l));return h.length&&(r=F("NON_CONFORMING_NAMESPACES",`${i} namespaces keys don't satisfy requiredNamespaces.
19      Required: ${h.toString()}
20      Received: ${Object.keys(e).toString()}`)),si(o,a)||(r=F("NON_CONFORMING_NAMESPACES",`${i} namespaces chains don't satisfy required namespaces.
21      Required: ${o.toString()}
22      Approved: ${a.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||r)return;const d=nr(e[l].accounts);d.includes(l)||(r=F("NON_CONFORMING_NAMESPACES",`${i} namespaces accounts don't satisfy namespace accounts for ${l}
23        Required: ${l}
24        Approved: ${d.toString()}`))}),o.forEach(l=>{r||(si(s[l].methods,n[l].methods)?si(s[l].events,n[l].events)||(r=F("NON_CONFORMING_NAMESPACES",`${i} namespaces events don't satisfy namespace events for ${l}`)):r=F("NON_CONFORMING_NAMESPACES",`${i} namespaces methods don't satisfy namespace methods for ${l}`))}),r}function e1(t){const e={};return Object.keys(t).forEach(i=>
24{var r;i.includes(":")?e[i]=t[i]:(r=t[i].chains)==null||r.forEach(s=>{e[s]={methods:t[i].methods,events:t[i].events}})}),e}function qc(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function t1(t){const e={};return Object.keys(t).forEach(i=>{if(i.includes(":"))e[i]=t[i];else{const r=nr(t[i].accounts);r==null||r.forEach(s=>{e[s]={accounts:t[i].accounts.filter(n=>n.includes(`${s}:`)),methods:t[i].methods,events:t[i].events}})}}),e}function i1(t,e){return Ho(t,!1)&&t<=e.max&&t>=e.min}function kc(){const t=jr();return new Promise(e=>{switch(t){case We.browser:e(r1());break;case We.reactNative:e(s1());break;case We.node:e(n1());break;default:e(!0)}})}function r1(){return ir()&&(navigator==null?void 0:navigator.onLine)}async function s1(){if(Wt()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function n1(){return!0}function o1(t){switch(jr()){case We.browser:a1(t);break;case We.reactNative:c1(t);break}}function a1(t){!Wt()&&ir()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function c1(t){Wt()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}function u1(){var t;return ir()&&ai()?((t=ai())==null?void 0:t.visibilityState)==="visible":!0}const _n={};class dr{static get(e){return _n[e]}static set(e,i){_n[e]=i}static delete(e){delete _n[e]}}class fi{}let h1=class extends fi{constructor(e){super()}};const Mc=N.FIVE_SECONDS,gi={pulse:"heartbeat_pulse"};let l1=class kl extends h1{constructor(e){super(e),this.events=new it.EventEmitter,this.interval=Mc,this.interval=(e==null?void 0:e.interval)||Mc}static async init(e){const i=new kl(e);return await i.init(),i}
vendor: 13,914 bytes, line 24
24async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,i){this.events.on(e,i)}once(e,i){this.events.once(e,i)}off(e,i){this.events.off(e,i)}removeListener(e,i){this.events.removeListener(e,i)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),N.toMiliseconds(this.interval))}pulse(){this.events.emit(gi.pulse)}};const d1=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,p1=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,f1=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function g1(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){y1(t);return}return e}function y1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function es(t,e={}){if(typeof t!="string")return t;if(t[0]==='"'&&t[t.length-1]==='"'&&t.indexOf("\\")===-1)return t.slice(1,-1);const i=t.trim();if(i.length<=9)switch(i.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!f1.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(d1.test(t)||p1.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,g1)}return JSON.parse(t)}catch(r){if(e.strict)throw r;return t}}function m1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ye(t,...e){try{return m1(t(...e))}catch(i){return Promise.reject(i)}}function w1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function b1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function ds(t){if(w1(t))return String(t);if(b1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return ds(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const so="base64:";function v1(t){return typeof t=="string"?t:so+I1(t)}function E1(t){return typeof t!="string"||!t.startsWith(so)?t:_1(t.slice(so.length))}function _1(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function I1(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function je(t){var e;return t&&((e=t.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function $1(...t){return je(t.join(":"))}function ts(t){return t=je(t),t?t+":":""}function D1(t,e){if(e===void 0)return!0;let i=0,r=t.indexOf(":");for(;r>-1;)i++,r=t.indexOf(":",r+1);return i<=e}function S1(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const O1="memory",P1=()=>{const t=new Map;return{name:O1,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,i){t.set(e,i)},setItemRaw(e,i){t.set(e,i)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function A1(t={}){const e={mounts:{"":t.driver||P1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},i=u=>{for(const h of e.mountpoints)if(u.startsWith(h))return{base:h,relativeKey:u.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:u,driver:e.mounts[""]}},r=(u,h)=>e.mountpoints.filter(l=>l.startsWith(u)||h&&u.startsWith(l)).map(l=>({relativeBase:u.length>l.length?u.slice(l.length):void 0,mountpoint:l,driver:e.mounts[l]})),s=(u,h)=>{if(e.watching){h=je(h);for(const l of e.watchListeners)l(u,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await zc(e.mounts[u],s,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,h,l)=>{const d=new Map,f=p=>{let y=d.get(p.base);return y||(y={driver:p.driver,base:p.base,items:[]},d.set(p.base,y)),y};for(const p of u){const y=typeof p=="string",w=je(y?p:p.key),v=y?void 0:p.value,b=y||!p.options?h:{...h,...p.options},E=i(w);f(E).items.push({key:w,value:v,relativeKey:E.relativeKey,options:b})}return Promise.all([...d.values()].map(p=>l(p))).then(p=>p.flat())},c={hasItem(u,h={}){u=je(u);const{relativeKey:l,driver:d}=i(u);return ye(d.hasItem,l,h)},getItem(u,h={}){u=je(u);const{relativeKey:l,driver:d}=i(u);return ye(d.getItem,l,h).then(f=>es(f))},getItems(u,h={}){return a(u,h,l=>l.driver.getItems?ye(l.driver.getItems,l.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:$1(l.base,f.key),value:es(f.value)}))):Promise.all(l.items.map(d=>ye(l.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:es(f)})))))},getItemRaw(u,h={}){u=je(u);const{relativeKey:l,driver:d}=i(u);return d.getItemRaw?ye(d.getItemRaw,l,h):ye(d.getItem,l,h).then(f=>E1(f))},async setItem(u,h,l={}){if(h===void 0)return c.removeItem(u);u=je(u);const{relativeKey:d,driver:f}=i(u);f.setItem&&(await ye(f.setItem,d,ds(h),l),f.watch||s("update",u))},async setItems(u,h){await a(u,h,async l=>{if(l.driver.setItems)return ye(l.driver.setItems,l.items.map(d=>({key:d.relativeKey,value:ds(d.value),options:d.options})),h);l.driver.setItem&&await Promise.all(l.items.map(d=>ye(l.driver.setItem,d.relativeKey,ds(d.value),d.options)))})},async setItemRaw(u,h,l={}){if(h===void 0)return c.removeItem(u,l);u=je(u);const{relativeKey:d,driver:f}=i(u);if(f.setItemRaw)await ye(f.setItemRaw,d,h,l);else if(f.setItem)await ye(f.setItem,d,v1(h),l);else return;f.watch||s("update",u)},async removeItem(u,h={}){typeof h=="boolean"&&(h={removeMeta:h}),u=je(u);const{relativeKey:l,driver:d}=i(u);d.removeItem&&(await ye(d.removeItem,l,h),(h.removeMeta||h.removeMata)&&await ye(d.removeItem,l+"$",h),d.watch||s("remove",u))},async getMeta(u,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),u=je(u);const{relativeKey:l,driver:d}=i(u),f=Object.create(null);if(d.getMeta&&Object.assign(f,await ye(d.getMeta,l,h)),!h.nativeOnly){const p=await ye(d.getItem,l+"$",h).then(y=>es(y));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(u,h,l={}){return this.setItem(u+"$",h,l)},removeMeta(u,h={}){return this.removeItem(u+"$",h)},async getKeys(u,h={}){var w;u=ts(u);const l=r(u,!0);let d=[];const f=[];let p=!0;for(const v of l){(w=v.driver.flags)!=null&&w.maxDepth||(p=!1);const b=await ye(v.driver.getKeys,v.relativeBase,h);for(const E of b){const I=v.mountpoint+je(E);d.some(P=>I.startsWith(P))||f.push(I)}d=[v.mountpoint,...d.filter(E=>!E.startsWith(v.mountpoint))]}const y=h.maxDepth!==void 0&&!p;return f.filter(v=>(!y||D1(v,h.maxDepth))&&S1(v,u))},async clear(u,h={}){u=ts(u),await Promise.all(r(u,!1).map(async l=>{if(l.driver.clear)return ye(l.driver.clear,l.relativeBase,h);if(l.driver.removeItem){const d=await l.driver.getKeys(l.relativeBase||"",h);return Promise.all(d.map(f=>l.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>Hc(u)))},async watch(u){return await n(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,h){if(u=ts(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((l,d)=>d.length-l.length)),e.mounts[u]=h,e.watching&&Promise.resolve(zc(h,s,u)).then(l=>{e.unwatch[u]=l}).catch(console.error),c},async unmount(u,h=!0){var l,d;u=ts(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&((d=(l=e.unwatch)[u])==null||d.call(l),delete e.unwatch[u]),h&&await Hc(e.mounts[u]),e.mountpoints=e.mountpoints.filter(f=>f!==u),delete e.mounts[u])},getMount(u=""){u=je(u)+":";const h=i(u);return{driver:h.driver,base:h.base}},getMounts(u="",h={}){return u=je(u),r(u,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(u,h={})=>c.getKeys(u,h),get:(u,h={})=>c.getItem(u,h),set:(u,h,l={})=>c.setItem(u,h,l),has:(u,h={})=>c.hasItem(u,h),del:(u,h={})=>c.removeItem(u,h),remove:(u,h={})=>c.removeItem(u,h)};return c}function zc(t,e,i){return t.watch?t.watch((r,s)=>e(r,i+s)):()=>{}}async function Hc(t){typeof t.dispose=="function"&&await ye(t.dispose)}const x1="idb-keyval";var C1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",i=s=>e+s;let r;return t.dbName&&t.storeName&&(r=Ld(t.dbName,t.storeName)),{name:x1,options:t,async hasItem(s){return!(typeof await sa(i(s),r)>"u")},async getItem(s){return await sa(i(s),r)??null},setItem(s,n){return qd(i(s),n,r)},removeItem(s){return kd(i(s),r)},getKeys(){return Md(r)},clear(){return zd(r)}}};const T1="WALLET_CONNECT_V2_INDEXED_DB",R1="keyvaluestorage";let N1=class{constructor(){this.indexedDb=A1({driver:C1({dbName:T1,storeName:R1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const i=await this.indexedDb.getItem(e);if(i!==null)return i}async setItem(e,i){await this.indexedDb.setItem(e,Bt(i))}async removeItem(e){await this.indexedDb.removeItem(e)}};var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ps={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(i){return this.hasOwnProperty(i)?String(this[i]):null},t.prototype.setItem=function(i,r){this[i]=String(r)},t.prototype.removeItem=function(i){delete this[i]},t.prototype.clear=function(){const i=this;Object.keys(i).forEach(function(r){i[r]=void 0,delete i[r]})},t.prototype.key=function(i){return i=i||0,Object.keys(this)[i]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof In<"u"&&In.localStorage?ps.exports=In.localStorage:typeof window<"u"&&window.localStorage?ps.exports=window.localStorage:ps.exports=new e})();function F1(t){var e;return[t[0],ui((e=t[1])!=null?e:"")]}let B1=class{constructor(){this.localStorage=ps.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(F1)}async getItem(e){const i=this.localStorage.getItem(e);if(i!==null)return ui(i)}async setItem(e,i){this.localStorage.setItem(e,Bt(i))}async removeItem(e){this.localStorage.removeItem(e)}};const j1="wc_storage_version",Vc=1,U1=async(t,e,i)=>{const r=j1,s=await e.getItem(r);if(s&&s>=Vc){i(e);return}const n=await t.getKeys();if(!n.length){i(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const u=await t.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(r,Vc),i(e),L1(t,o)},L1=async(t,e)=>{e.length&&e.forEach(async i=>{await t.removeItem(i)})};let q1=class{constructor(){this.initialized=!1,this.setInitialized=i=>{this.storage=i,this.initialized=!0};const e=new B1;this.storage=e;try{const i=new N1;U1(e,i,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,i){return await this.initialize(),this.storage.setItem(e,i)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),e())},20)})}};function k1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var M1=z1;function z1(t,e,i){var r=i&&i.stringify||k1,s=1;if(typeof t=="object"&&t!==null){var n=e.length+s;if(n===1)return t;var o=new Array(n);o[0]=r(t);for(var a=1;a<n;a++)o[a]=r(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var u="",h=1-s,l=-1,d=t&&t.length||0,f=0;f<d;){if(t.charCodeAt(f)===37&&f+1<d){switch(l=l>-1?l:0,t.charCodeAt(f+1)){case 100:case 102:if(h>=c||e[h]==null)break;l<f&&(u+=t.slice(l,f)),u+=Number(e[h]),l=f+2,f++;break;case 105:if(h>=c||e[h]==null)break;l<f&&(u+=t.slice(l,f)),u+=Math.floor(Number(e[h])),l=f+2,f++;break;case 79:case 111:case 106:if(h>=c||e[h]===void 0)break;l<f&&(u+=t.slice(l,f));var p=typeof e[h];if(p==="string"){u+="'"+e[h]+"'",l=f+2,f++;break}if(p==="function"){u+=e[h].name||"<anonymous>",l=f+2,f++;break}u+=r(e[h]),l=f+2,f++;break;case 115:if(h>=c)break;l<f&&(u+=t.slice(l,f)),u+=String(e[h]),l=f+2,f++;break;case 37:l<f&&(u+=t.slice(l,f)),u+="%",l=f+2,f++,h--;break}++h}++f}return l===-1?t:(l<d&&(u+=t.slice(l)),u)}const Kc=M1;var Li=It;const Tr=X1().console||{},H1={mapHttpRequest:is,mapHttpResponse:is,wrapRequestSerializer:$n,wrapResponseSerializer:$n,wrapErrorSerializer:$n,req:is,res:is,err:Y1};function V1(t,e){return Array.isArray(t)?t.filter(function(r){return r!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function It(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const i=t.browser.write||Tr;t.browser.write&&(t.browser.asObject=!0);const r=t.serializers||{},s=V1(t.browser.serialize,r);let n=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(n=!1);const o=["error","fatal","warn","info","debug","trace"];typeof i=="function"&&(i.error=i.fatal=i.warn=i.info=i.debug=i.trace=i),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(i);c.log||(c.log=Rr),Object.defineProperty(c,"levelVal",{get:h}),Object.defineProperty(c,"level",{get:l,set:d});const u={transmit:e,serialize:s,asObject:t.browser.asObject,levels:o,timestamp:J1(t)};
24c.levels=It.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=Rr,c.serializers=r,c._serialize=s,c._stdErrSerialize=n,c.child=f,e&&(c._logEvent=no());function h(){return this.level==="silent"?1/0:this.levels.values[this.level]}function l(){return this._level}function d(p){if(p!=="silent"&&!this.levels.values[p])throw Error("unknown level "+p);this._level=p,$i(u,c,"error","log"),$i(u,c,"fatal","error"),$i(u,c,"warn","error"),$i(u,c,"info","log"),$i(u,c,"debug","log"),$i(u,c,"trace","log")}function f(p,y){if(!p)throw new Error("missing bindings for child Pino");y=y||{},s&&p.serializers&&(y.serializers=p.serializers);const w=y.serializers;if(s&&w){var v=Object.assign({},r,w),b=t.browser.serialize===!0?Object.keys(v):s;delete p.serializers,ks([p],b,v,this._stdErrSerialize)}function E(I){this._childLevel=(I._childLevel|0)+1,this.error=Di(I,p,"error"),this.fatal=Di(I,p,"fatal"),this.warn=Di(I,p,"warn"),this.info=Di(I,p,"info"),this.debug=Di(I,p,"debug"),this.trace=Di(I,p,"trace"),v&&(this.serializers=v,this._serialize=b),e&&(this._logEvent=no([].concat(I._logEvent.bindings,p)))}return E.prototype=this,new E(this)}return c}It.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};It.stdSerializers=H1;It.stdTimeFunctions=Object.assign({},{nullTime:Ml,epochTime:zl,unixTime:Z1,isoTime:Q1});function $i(t,e,i,r){const s=Object.getPrototypeOf(e);e[i]=e.levelVal>e.levels.values[i]?Rr:s[i]?s[i]:Tr[i]||Tr[r]||Rr,K1(t,e,i)}function K1(t,e,i){!t.transmit&&e[i]===Rr||(e[i]=function(r){return function(){const n=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Tr?Tr:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&ks(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?r.call(a,W1(this,i,o,n)):r.apply(a,o),t.transmit){const u=t.transmit.level||e.level,h=It.levels.values[u],l=It.levels.values[i];if(l<h)return;G1(this,{ts:n,methodLevel:i,methodValue:l,transmitLevel:u,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[i]))}function W1(t,e,i,r){t._serialize&&ks(i,t._serialize,t.serializers,t._stdErrSerialize);const s=i.slice();let n=s[0];const o={};r&&(o.time=r),o.level=It.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),n!==null&&typeof n=="object"){for(;a--&&typeof s[0]=="object";)Object.assign(o,s.shift());n=s.length?Kc(s.shift(),s):void 0}else typeof n=="string"&&(n=Kc(s.shift(),s));return n!==void 0&&(o.msg=n),o}function ks(t,e,i,r){for(const s in t)if(r&&t[s]instanceof Error)t[s]=It.stdSerializers.err(t[s]);else if(typeof t[s]=="object"&&!Array.isArray(t[s]))for(const n in t[s])e&&e.indexOf(n)>-1&&n in i&&(t[s][n]=i[n](t[s][n]))}function Di(t,e,i){return function(){const r=new Array(1+arguments.length);r[0]=e;for(var s=1;s<r.length;s++)r[s]=arguments[s-1];return t[i].apply(this,r)}}function G1(t,e,i){const r=e.send,s=e.ts,n=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;ks(i,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=s,t._logEvent.messages=i.filter(function(u){return c.indexOf(u)===-1}),t._logEvent.level.label=n,t._logEvent.level.value=o,r(n,t._logEvent,a),t._logEvent=no(c)}function no(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Y1(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const i in t)e[i]===void 0&&(e[i]=t[i]);return e}function J1(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ml:zl}function is(){return{}}function $n(t){return t}function Rr(){}function Ml(){return!1}function zl(){return Date.now()}function Z1(){return Math.round(Date.now()/1e3)}function Q1(){return new Date(Date.now()).toISOString()}function X1(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const zr=sh(Li),eE={level:"info"},Hr="custom_context",Vo=1e3*1024;let tE=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Wc=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const i=new tE(e);if(i.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${i.size}`);for(;this.size+i.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=i),this.tail=i):(this.head=i,this.tail=i),this.lengthInNodes++,this.sizeInBytes+=i.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let i=this.head;for(;i!==null;)e.push(i.value),i=i.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const i=e.value;return e=e.next,{done:!1,value:i}}}}},Hl=class{constructor(e,i=Vo){this.level=e??"error",this.levelValue=Li.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=i,this.logs=new Wc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,i){i===Li.levels.values.error?console.error(e):i===Li.levels.values.warn?console.warn(e):i===Li.levels.values.debug?console.debug(e):i===Li.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Bt({timestamp:new Date().toISOString(),log:e}));const i=typeof e=="string"?JSON.parse(e).level:e.level;i>=this.levelValue&&this.forwardToConsole(e,i)}getLogs(){return this.logs}clearLogs(){this.logs=new Wc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const i=this.getLogArray();return i.push(Bt({extraMetadata:e})),new Blob(i,{type:"application/json"})}},iE=class{constructor(e,i=Vo){this.baseChunkLogger=new Hl(e,i)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const i=URL.createObjectURL(this.logsToBlob(e)),r=document.createElement("a");r.href=i,r.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}},rE=class{constructor(e,i=Vo){this.baseChunkLogger=new Hl(e,i)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var sE=Object.defineProperty,nE=Object.defineProperties,oE=Object.getOwnPropertyDescriptors,Gc=Object.getOwnPropertySymbols,aE=Object.prototype.hasOwnProperty,cE=Object.prototype.propertyIsEnumerable,Yc=(t,e,
24i)=>e in t?sE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Is=(t,e)=>{for(var i in e||(e={}))aE.call(e,i)&&Yc(t,i,e[i]);if(Gc)for(var i of Gc(e))cE.call(e,i)&&Yc(t,i,e[i]);return t},$s=(t,e)=>nE(t,oE(e));function Ms(t){return $s(Is({},t),{level:(t==null?void 0:t.level)||eE.level})}function uE(t,e=Hr){return t[e]||""}function hE(t,e,i=Hr){return t[i]=e,t}function ke(t,e=Hr){let i="";return typeof t.bindings>"u"?i=uE(t,e):i=t.bindings().context||"",i}function lE(t,e,i=Hr){const r=ke(t,i);return r.trim()?`${r}/${e}`:e}function Ne(t,e,i=Hr){const r=lE(t,e,i),s=t.child({context:r});return hE(s,r,i)}function dE(t){var e,i;const r=new iE((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:zr($s(Is({},t.opts),{level:"trace",browser:$s(Is({},(i=t.opts)==null?void 0:i.browser),{write:s=>r.write(s)})})),chunkLoggerController:r}}function pE(t){var e;const i=new rE((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:zr($s(Is({},t.opts),{level:"trace"}),i),chunkLoggerController:i}}function fE(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?dE(t):pE(t)}var gE=Object.defineProperty,yE=(t,e,i)=>e in t?gE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Jc=(t,e,i)=>yE(t,typeof e!="symbol"?e+"":e,i);let mE=class extends fi{constructor(e){super(),this.opts=e,Jc(this,"protocol","wc"),Jc(this,"version",2)}};var wE=Object.defineProperty,bE=(t,e,i)=>e in t?wE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vE=(t,e,i)=>bE(t,typeof e!="symbol"?e+"":e,i);let EE=class extends fi{constructor(e,i){super(),this.core=e,this.logger=i,vE(this,"records",new Map)}},_E=class{constructor(e,i){this.logger=e,this.core=i}};class IE extends fi{constructor(e,i){super(),this.relayer=e,this.logger=i}}let $E=class extends fi{constructor(e){super()}},DE=class{constructor(e,i,r,s){this.core=e,this.logger=i,this.name=r}},SE=class extends fi{constructor(e,i){super(),this.relayer=e,this.logger=i}},OE=class extends fi{constructor(e,i){super(),this.core=e,this.logger=i}},PE=class{constructor(e,i,r){this.core=e,this.logger=i,this.store=r}},AE=class{constructor(e,i){this.projectId=e,this.logger=i}},xE=class{constructor(e,i,r){this.core=e,this.logger=i,this.telemetryEnabled=r}};var CE=Object.defineProperty,TE=(t,e,i)=>e in t?CE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Zc=(t,e,i)=>TE(t,typeof e!="symbol"?e+"":e,i);let RE=class{constructor(e){this.opts=e,Zc(this,"protocol","wc"),Zc(this,"version",2)}},NE=class{constructor(e){this.client=e}};const FE="PARSE_ERROR",BE="INVALID_REQUEST",jE="METHOD_NOT_FOUND",UE="INVALID_PARAMS",Vl="INTERNAL_ERROR",Ko="SERVER_ERROR",LE=[-32700,-32600,-32601,-32602,-32603],_r={[FE]:{code:-32700,message:"Parse error"},[BE]:{code:-32600,message:"Invalid Request"},[jE]:{code:-32601,message:"Method not found"},[UE]:{code:-32602,message:"Invalid params"},[Vl]:{code:-32603,message:"Internal error"},[Ko]:{code:-32e3,message:"Server error"}},Kl=Ko;function qE(t){return LE.includes(t)}function Qc(t){return Object.keys(_r).includes(t)?_r[t]:_r[Kl]}function kE(t){const e=Object.values(_r).find(i=>i.code===t);return e||_r[Kl]}function Wl(t,e,i){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${i} RPC url at ${e}`):t}var Gl={};/*! *****************************************************************************
25Copyright (c) Microsoft Corporation.
26
27Permission to use, copy, modify, and/or distribute this software for any
28purpose with or without fee is hereby granted.
29
30THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
31REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
35OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36PERFORMANCE OF THIS SOFTWARE.
37***************************************************************************** */var oo=function(t,e){return oo=Object.
vendor: 5,915 bytes, line 37
37setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)r.hasOwnProperty(s)&&(i[s]=r[s])},oo(t,e)};function ME(t,e){oo(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}var ao=function(){return ao=Object.assign||function(e){for(var i,r=1,s=arguments.length;r<s;r++){i=arguments[r];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},ao.apply(this,arguments)};function zE(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]]);return i}function HE(t,e,i,r){var s=arguments.length,n=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,i):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,i,n):o(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n}function VE(t,e){return function(i,r){e(i,r,t)}}function KE(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function WE(t,e,i,r){function s(n){return n instanceof i?n:new i(function(o){o(n)})}return new(i||(i=Promise))(function(n,o){function a(h){try{u(r.next(h))}catch(l){o(l)}}function c(h){try{u(r.throw(h))}catch(l){o(l)}}function u(h){h.done?n(h.value):s(h.value).then(a,c)}u((r=r.apply(t,e||[])).next())})}function GE(t,e){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},r,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(h){return c([u,h])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,s&&(n=u[0]&2?s.return:u[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,u[1])).done)return n;switch(s=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(n=i.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){i.label=u[1];break}if(u[0]===6&&i.label<n[1]){i.label=n[1],n=u;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(u);break}n[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(h){u=[6,h],s=0}finally{r=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function YE(t,e,i,r){r===void 0&&(r=i),t[r]=e[i]}function JE(t,e){for(var i in t)i!=="default"&&!e.hasOwnProperty(i)&&(e[i]=t[i])}function co(t){var e=typeof Symbol=="function"&&Symbol.iterator,i=e&&t[e],r=0;if(i)return i.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Yl(t,e){var i=typeof Symbol=="function"&&t[Symbol.iterator];if(!i)return t;var r=i.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return n}function ZE(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Yl(arguments[e]));return t}function QE(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;for(var r=Array(t),s=0,e=0;e<i;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)r[s]=n[o];return r}function Nr(t){return this instanceof Nr?(this.v=t,this):new Nr(t)}function XE(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=i.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(d){r[d]&&(s[d]=function(f){return new Promise(function(p,y){n.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(r[d](f))}catch(p){l(n[0][3],p)}}function c(d){d.value instanceof Nr?Promise.resolve(d.value.v).then(u,h):l(n[0][2],d)}function u(d){a("next",d)}function h(d){a("throw",d)}function l(d,f){d(f),n.shift(),n.length&&a(n[0][0],n[0][1])}}function e_(t){var e,i;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,n){e[s]=t[s]?function(o){return(i=!i)?{value:Nr(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function t_(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],i;return e?e.call(t):(t=typeof co=="function"?co(t):t[Symbol.iterator](),i={},r("next"),r("throw"),r("return"),i[Symbol.asyncIterator]=function(){return this},i);function r(n){i[n]=t[n]&&function(o){return new Promise(function(a,c){o=t[n](o),s(a,c,o.done,o.value)})}}function s(n,o,a,c){Promise.resolve(c).then(function(u){n({value:u,done:a})},o)}}function i_(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function r_(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}function s_(t){return t&&t.__esModule?t:{default:t}}function n_(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function o_(t,e,i){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,i),i}const a_=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return ao},__asyncDelegator:e_,__asyncGenerator:XE,__asyncValues:t_,__await:Nr,__awaiter:WE,__classPrivateFieldGet:n_,__classPrivateFieldSet:o_,__createBinding:YE,__decorate:HE,__exportStar:JE,__extends:ME,__generator:GE,__importDefault:s_,__importStar:r_,__makeTemplateOb
37ject:i_,__metadata:KE,__param:VE,__read:Yl,__rest:zE,__spread:ZE,__spreadArrays:QE,__values:co},Symbol.toStringTag,{value:"Module"})),c_=ih(a_);var At={},Xc;function u_(){if(Xc)return At;Xc=1,Object.defineProperty(At,"__esModule",{value:!0}),At.isBrowserCryptoAvailable=At.getSubtleCrypto=At.getBrowerCrypto=void 0;function t(){return(vt===null||vt===void 0?void 0:vt.crypto)||(vt===null||vt===void 0?void 0:vt.msCrypto)||{}}At.getBrowerCrypto=t;function e(){const r=t();return r.subtle||r.webkitSubtle}At.getSubtleCrypto=e;function i(){return!!t()&&!!e()}return At.isBrowserCryptoAvailable=i,At}var xt={},eu;function h_(){if(eu)return xt;eu=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.isBrowser=xt.isNode=xt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}xt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}xt.isNode=e;function i(){return!t()&&!e()}return xt.isBrowser=i,xt}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=c_;e.__exportStar(u_(),t),e.__exportStar(h_(),t)})(Gl);function wt(t=3){const e=Date.now()*Math.pow(10,t),i=Math.floor(Math.random()*Math.pow(10,t));return e+i}function ni(t=6){return BigInt(wt(t))}function Ht(t,e,i){return{id:i||wt(),jsonrpc:"2.0",method:t,params:e}}function zs(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Hs(t,e,i){return{id:t,jsonrpc:"2.0",error:l_(e,i)}}function l_(t,e){return typeof t>"u"?Qc(Vl):(typeof t=="string"&&(t=Object.assign(Object.assign({},Qc(Ko)),{message:t})),typeof e<"u"&&(t.data=e),qE(t.code)&&(t=kE(t.code)),t)}class d_{}class p_ extends d_{constructor(){super()}}class f_ extends p_{constructor(e){super()}}const g_="^https?:",y_="^wss?:";function m_(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Jl(t,e){const i=m_(t);return typeof i>"u"?!1:new RegExp(e).test(i)}function tu(t){return Jl(t,g_)}function iu(t){return Jl(t,y_)}function w_(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Zl(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Wo(t){return Zl(t)&&"method"in t}function Vs(t){return Zl(t)&&(bt(t)||et(t))}function bt(t){return"result"in t}function et(t){return"error"in t}let rt=class extends f_{constructor(e){super(e),this.events=new it.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,i){this.events.on(e,i)}
vendor: 16,263 bytes, line 37
37once(e,i){this.events.once(e,i)}off(e,i){this.events.off(e,i)}removeListener(e,i){this.events.removeListener(e,i)}async request(e,i){return this.requestStrict(Ht(e.method,e.params||[],e.id||ni().toString()),i)}async requestStrict(e,i){return new Promise(async(r,s)=>{if(!this.connection.connected)try{await this.open()}catch(n){s(n)}this.events.on(`${e.id}`,n=>{et(n)?s(n.error):r(n.result)});try{await this.connection.send(e,i)}catch(n){s(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Vs(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const b_=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),v_=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",ru=t=>t.split("?")[0],su=10,E_=b_();let __=class{constructor(e){if(this.url=e,this.events=new it.EventEmitter,this.registering=!1,!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,i){this.events.on(e,i)}once(e,i){this.events.once(e,i)}off(e,i){this.events.off(e,i)}removeListener(e,i){this.events.removeListener(e,i)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,i)=>{if(typeof this.socket>"u"){i(new Error("Connection already closed"));return}this.socket.onclose=r=>{this.onClose(r),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Bt(e))}catch(i){this.onError(e.id,i)}}register(e=this.url){if(!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((r,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));r(this.socket)})})}return this.url=e,this.registering=!0,new Promise((i,r)=>{const s=Gl.isReactNative()?void 0:{rejectUnauthorized:!w_(e)},n=new E_(e,[],s);v_()?n.onerror=o=>{const a=o;r(this.emitError(a.error))}:n.on("error",o=>{r(this.emitError(o))}),n.onopen=()=>{this.onOpen(n),i(n)}})}onOpen(e){e.onmessage=i=>this.onPayload(i),e.onclose=i=>this.onClose(i),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const i=typeof e.data=="string"?ui(e.data):e.data;this.events.emit("payload",i)}onError(e,i){const r=this.parseError(i),s=r.message||r.toString(),n=Hs(e,s);this.events.emit("payload",n)}parseError(e,i=this.url){return Wl(e,ru(i),"WS")}resetMaxListeners(){this.events.getMaxListeners()>su&&this.events.setMaxListeners(su)}emitError(e){const i=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${ru(this.url)}`));return this.events.emit("register_error",i),i}};const Ql="wc",Xl=2,Ds="core",$t=`${Ql}@2:${Ds}:`,I_={name:Ds,logger:"error"},$_={database:":memory:"},D_="crypto",nu="client_ed25519_seed",S_=N.ONE_DAY,O_="keychain",P_="0.3",A_="messages",x_="0.3",ou=N.SIX_HOURS,C_="publisher",ed="irn",T_="error",td="wss://relay.walletconnect.org",R_="relayer",we={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},N_="_subscription",Ze={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},F_=.1,uo="2.21.1",ae={link_mode:"link_mode",relay:"relay"},fs={inbound:"inbound",outbound:"outbound"},B_="0.3",j_="WALLETCONNECT_CLIENT_ID",au="WALLETCONNECT_LINK_MODE_APPS",He={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},U_="subscription",L_="0.3",q_="pairing",k_="0.3",pr={wc_pairingDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:N.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:N.ONE_DAY,prompt:!1,tag:0},res:{ttl:N.ONE_DAY,prompt:!1,tag:0}}},ii={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},ot={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},M_="history",z_="0.3",H_="expirer",Xe={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},V_="0.3",K_="verify-api",W_="https://verify.walletconnect.com",id="https://verify.walletconnect.org",Ir=id,G_=`${Ir}/v3`,Y_=[W_,id],J_="echo",Z_="https://echo.walletconnect.com",mt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Ct={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},at={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Jt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Zt={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},fr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Q_=.1,X_="event-client",e2=86400,t2="https://pulse.walletconnect.org/batch";function i2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(i[o]!==255)throw new TypeError(n+" is ambiguous");i[o]=s}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*h+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*u+1>>>0,E=new Uint8Array(b);p[y];){var I=i[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var r2=i2,s2=r2;const rd=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},n2=t=>new TextEncoder().encode(t),o2=t=>new TextDecoder().decode(t);class a2{constructor(e,i,r){this.name=e,this.prefix=i,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class c2{constructor(e,i,r){if(this.name=e,this.prefix=i,i.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return sd(this,e)}}class u2{constructor(e){this.decoders=e}or(e){return sd(this,e)}decode(e){const i=e[0],r=this.decoders[i];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const sd=(t,e)=>new u2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class h2{constructor(e,i,r,s){this.name=e,this.prefix=i,this.baseEncode=r,this.baseDecode=s,this.encoder=new a2(e,i,r),this.decoder=new c2(e,i,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ks=({name:t,prefix:e,encode:i,decode:r})=>new h2(t,e,i,r),Vr=({prefix:t,name:e,alphabet:i})=>{const{encode:r,decode:s}=s2(i,e);return Ks({prefix:t,name:e,encode:r,decode:n=>rd(s(n))})},l2=(t,e,i,r)=>{const s={};for(let h=0;h<e.length;++h)s[e[h]]=h;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*i/8|0);let a=0,c=0,u=0;for(let h=0;h<n;++h){const l=s[t[h]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<i|l,a+=i,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},d2=(t,e,i)=>{const r=e[e.length-1]==="=",s=(1<<i)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>i;)o-=i,n+=e[s&a>>o];if(o&&(n+=e[s&a<<i-o]),r)for(;n.length*i&7;)n+="=";return n},Pe=({name:t,prefix:e,bitsPerChar:i,alphabet:r})=>Ks({prefix:e,name:t,encode(s){return d2(s,r,i)},decode(s){return l2(s,r,i,t)}}),p2=Ks({prefix:"\0",name:"identity",encode:t=>o2(t),decode:t=>n2(t)});var f2=Object.freeze({__proto__:null,identity:p2});const g2=Pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var y2=Object.freeze({__proto__:null,base2:g2});const m2=Pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var w2=Object.freeze({__proto__:null,base8:m2});const b2=Vr({prefix:"9",name:"base10",alphabet:"0123456789"});var v2=Object.freeze({__proto__:null,base10:b2});const E2=Pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_2=Pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var I2=Object.freeze({__proto__:null,base16:E2,base16upper:_2});const $2=Pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),D2=Pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),S2=Pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),O2=Pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),P2=Pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),A2=Pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),x2=Pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C2=Pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),T2=Pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var R2=Object.freeze({__proto__:null,base32:$2,base32upper:D2,base32pad:S2,base32padupper:O2,base32hex:P2,base32hexupper:A2,base32hexpad:x2,base32hexpadupper:C2,base32z:T2});const N2=Vr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),F2=Vr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var B2=Object.freeze({__proto__:null,base36:N2,base36upper:F2});const j2=Vr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),U2=Vr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var L2=Object.freeze({__proto__:null,base58btc:j2,base58flickr:U2});const q2=Pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
37+/",bitsPerChar:6}),k2=Pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),M2=Pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),z2=Pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var H2=Object.freeze({__proto__:null,base64:q2,base64pad:k2,base64url:M2,base64urlpad:z2});const nd=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),V2=nd.reduce((t,e,i)=>(t[i]=e,t),[]),K2=nd.reduce((t,e,i)=>(t[e.codePointAt(0)]=i,t),[]);function W2(t){return t.reduce((e,i)=>(e+=V2[i],e),"")}function G2(t){const e=[];for(const i of t){const r=K2[i.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${i}`);e.push(r)}return new Uint8Array(e)}const Y2=Ks({prefix:"🚀",name:"base256emoji",encode:W2,decode:G2});var J2=Object.freeze({__proto__:null,base256emoji:Y2}),Z2=od,cu=128,Q2=127,X2=~Q2,eI=Math.pow(2,31);function od(t,e,i){e=e||[],i=i||0;for(var r=i;t>=eI;)e[i++]=t&255|cu,t/=128;for(;t&X2;)e[i++]=t&255|cu,t>>>=7;return e[i]=t|0,od.bytes=i-r+1,e}var tI=ho,iI=128,uu=127;function ho(t,r){var i=0,r=r||0,s=0,n=r,o,a=t.length;do{if(n>=a)throw ho.bytes=0,new RangeError("Could not decode varint");o=t[n++],i+=s<28?(o&uu)<<s:(o&uu)*Math.pow(2,s),s+=7}while(o>=iI);return ho.bytes=n-r,i}var rI=Math.pow(2,7),sI=Math.pow(2,14),nI=Math.pow(2,21),oI=Math.pow(2,28),aI=Math.pow(2,35),cI=Math.pow(2,42),uI=Math.pow(2,49),hI=Math.pow(2,56),lI=Math.pow(2,63),dI=function(t){return t<rI?1:t<sI?2:t<nI?3:t<oI?4:t<aI?5:t<cI?6:t<uI?7:t<hI?8:t<lI?9:10},pI={encode:Z2,decode:tI,encodingLength:dI},ad=pI;const hu=(t,e,i=0)=>(ad.encode(t,e,i),e),lu=t=>ad.encodingLength(t),lo=(t,e)=>{const i=e.byteLength,r=lu(t),s=r+lu(i),n=new Uint8Array(s+i);return hu(t,n,0),hu(i,n,r),n.set(e,s),new fI(t,i,e,n)};class fI{constructor(e,i,r,s){this.code=e,this.size=i,this.digest=r,this.bytes=s}}const cd=({name:t,code:e,encode:i})=>new gI(t,e,i);class gI{constructor(e,i,r){this.name=e,this.code=i,this.encode=r}digest(e){if(e instanceof Uint8Array){const i=this.encode(e);return i instanceof Uint8Array?lo(this.code,i):i.then(r=>lo(this.code,r))}else throw Error("Unknown type, must be binary type")}}const ud=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),yI=cd({name:"sha2-256",code:18,encode:ud("SHA-256")}),mI=cd({name:"sha2-512",code:19,encode:ud("SHA-512")});var wI=Object.freeze({__proto__:null,sha256:yI,sha512:mI});const hd=0,bI="identity",ld=rd,vI=t=>lo(hd,ld(t)),EI={code:hd,name:bI,encode:ld,digest:vI};var _I=Object.freeze({__proto__:null,identity:EI});new TextEncoder,new TextDecoder;const du={...f2,...y2,...w2,...v2,...I2,...R2,...B2,...L2,...H2,...J2};({...wI,..._I});function II(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function dd(t,e,i,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:i},decoder:{decode:r}}}const pu=dd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Dn=dd("ascii","a",t=>{let e="a";for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return e},t=>{t=t.substring(1);const e=II(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}),$I={utf8:pu,"utf-8":pu,hex:du.base16,latin1:Dn,ascii:Dn,binary:Dn,...du};function DI(t,e="utf8"){const i=$I[e];if(!i)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):i.decoder.decode(`${i.prefix}${t}`)}var SI=Object.defineProperty,OI=(t,e,i)=>e in t?SI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,gt=(t,e,i)=>OI(t,typeof e!="symbol"?e+"":e,i);class PI{constructor(e,i){this.core=e,this.logger=i,gt(this,"keychain",new Map),gt(this,"name",O_),gt(this,"version",P_),gt(this,"initialized",!1),gt(this,"storagePrefix",$t),gt(this,"init",async()=>
vendor: 4,649 bytes, line 37
37{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),gt(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),gt(this,"set",async(r,s)=>{this.isInitialized(),this.keychain.set(r,s),await this.persist()}),gt(this,"get",r=>{this.isInitialized();const s=this.keychain.get(r);if(typeof s>"u"){const{message:n}=F("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return s}),gt(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=Ne(i,this.name)}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Kn(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Wn(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var AI=Object.defineProperty,xI=(t,e,i)=>e in t?AI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ie=(t,e,i)=>xI(t,typeof e!="symbol"?e+"":e,i);class CI{constructor(e,i,r){this.core=e,this.logger=i,Ie(this,"name",D_),Ie(this,"keychain"),Ie(this,"randomSessionIdentifier",ro()),Ie(this,"initialized",!1),Ie(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ie(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),Ie(this,"getClientId",async()=>{this.isInitialized();const s=await this.getClientSeed(),n=Ka(s);return Yh(n.publicKey)}),Ie(this,"generateKeyPair",()=>{this.isInitialized();const s=av();return this.setPrivateKey(s.publicKey,s.privateKey)}),Ie(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=Ka(n),a=this.randomSessionIdentifier;return await Dm(a,s,S_,o)}),Ie(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),c=cv(a,n);return this.setSymKey(c,o)}),Ie(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||ls(s);return await this.keychain.set(o,s),o}),Ie(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s)}),Ie(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s)}),Ie(this,"encode",async(s,n,o)=>{this.isInitialized();const a=Ul(o),c=Bt(n);if(xc(a))return lv(c,o==null?void 0:o.encoding);if(Ac(a)){const d=a.senderPublicKey,f=a.receiverPublicKey;s=await this.generateSharedKey(d,f)}const u=this.getSymKey(s),{type:h,senderPublicKey:l}=a;return uv({type:h,symKey:u,message:c,senderPublicKey:l,encoding:o==null?void 0:o.encoding})}),Ie(this,"decode",async(s,n,o)=>{this.isInitialized();const a=pv(n,o);if(xc(a)){const c=dv(n,o==null?void 0:o.encoding);return ui(c)}if(Ac(a)){const c=a.receiverPublicKey,u=a.senderPublicKey;s=await this.generateSharedKey(c,u)}try{const c=this.getSymKey(s),u=hv({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return ui(u)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Ie(this,"getPayloadType",(s,n=ht)=>{const o=Cr({encoded:s,encoding:n});return di(o.type)}),Ie(this,"getPayloadSenderPublicKey",(s,n=ht)=>{const o=Cr({encoded:s,encoding:n});return o.senderPublicKey?qe(o.senderPublicKey,Re):void 0}),this.core=e,this.logger=Ne(i,this.name),this.keychain=r||new PI(this.core,this.logger)}get context(){return ke(this.logger)}async setPrivateKey(e,i){return await this.keychain.set(e,i),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(nu)}catch{e=ro(),await this.keychain.set(nu,e)}return DI(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var TI=Object.defineProperty,RI=Object.defineProperties,NI=Object.getOwnPropertyDescriptors,fu=Object.getOwnPropertySymbols,FI=Object.prototype.hasOwnProperty,BI=Object.prototype.propertyIsEnumerable,po=(t,e,i)=>e in t?TI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,jI=(t,e)=>{for(var i in e||(e={}))FI.call(e,i)&&po(t,i,e[i]);if(fu)for(var i of fu(e))BI.call(e,i)&&po(t,i,e[i]);return t},UI=(t,e)=>RI(t,NI(e)),Me=(t,e,i)=>po(t,typeof e!="symbol"?e+"":e,i);class LI extends _E{constructor(e,i){super(e,i),this.logger=e,this.core=i,Me(this,"messages",new Map),Me(this,"messagesWithoutClientAck",new Map),Me(this,"name",A_),Me(this,"version",x_),Me(this,"initialized",!1),Me(this,"storagePrefix",$t),Me(this,"init",async()=>
37{if(!this.initialized){this.logger.trace("Initialized");try{const r=await this.getRelayerMessages();typeof r<"u"&&(this.messages=r);const s=await this.getRelayerMessagesWithoutClientAck();typeof s<"u"&&(this.messagesWithoutClientAck=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}finally{this.initialized=!0}}}),Me(this,"set",async(r,s,n)=>{this.isInitialized();const o=Et(s);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=s,this.messages.set(r,a),n===fs.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,UI(jI({},c),{[o]:s}))}return await this.persist(),o}),Me(this,"get",r=>{this.isInitialized();let s=this.messages.get(r);return typeof s>"u"&&(s={}),s}),Me(this,"getWithoutAck",r=>{this.isInitialized();const s={};for(const n of r){const o=this.messagesWithoutClientAck.get(n)||{};s[n]=Object.values(o)}return s}),Me(this,"has",(r,s)=>{this.isInitialized();const n=this.get(r),o=Et(s);return typeof n[o]<"u"}),Me(this,"ack",async(r,s)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=Et(s);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),Me(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=Ne(e,this.name),this.core=i}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Kn(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,Kn(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Wn(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Wn(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var qI=Object.defineProperty,kI=Object.defineProperties,MI=Object.getOwnPropertyDescriptors,gu=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,HI=Object.prototype.propertyIsEnumerable,fo=(t,e,i)=>e in t?qI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rs=(t,e)=>{for(var i in e||(e={}))zI.call(e,i)&&fo(t,i,e[i]);if(gu)for(var i of gu(e))HI.call(e,i)&&fo(t,i,e[i]);return t},Sn=(t,e)=>kI(t,MI(e)),ct=(t,e,i)=>fo(t,typeof e!="symbol"?e+"":e,i);class VI extends IE{constructor(e,i){super(e,i),this.relayer=e,this.logger=i,ct(this,"events",new it.EventEmitter),ct(this,"name",C_),ct(this,"queue",new Map),ct(this,"publishTimeout",N.toMiliseconds(N.ONE_MINUTE)),ct(this,"initialPublishTimeout",N.toMiliseconds(N.ONE_SECOND*15)),ct(this,"needsTransportRestart",!1),ct(this,"publish",async(r,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:r,message:s,opts:n}});const a=(n==null?void 0:n.ttl)||ou,c=Es(n),u=(n==null?void 0:n.prompt)||!1,h=(n==null?void 0:n.tag)||0,l=(n==null?void 0:n.id)||ni().toString(),d={topic:r,message:s,opts:{ttl:a,relay:c,prompt:u,tag:h,id:l,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},f=`Failed to publish payload, please try again. id:${l} tag:${h}`;try{const p=new Promise(async y=>{const w=({id:b})=>{d.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(we.publish,w),y(d))};this.relayer.events.on(we.publish,w);const v=zt(new Promise((b,E)=>{this.rpcPublish({topic:r,message:s,ttl:a,prompt:u,tag:h,id:l,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(b).catch(I=>{this.logger.warn(I,I==null?void 0:I.message),E(I)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${h}`);try{await v,this.events.removeListener(we.publish,w)}catch(b){this.queue.set(l,Sn(rs({},d),{attempt:1})),this.logger.warn(b,b==null?void 0:b.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:r,message:s,opts:n}}),await zt(p,this.publishTimeout,f)}catch(p){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(p),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw p}finally{this.queue.delete(l)}}),ct(this,"on",(r,s)=>{this.events.on(r,s)}),ct(this,"once",(r,s)=>{this.events.once(r,s)}),ct(this,"off",(r,s)=>{this.events.off(r,s)}),ct(this,"removeListener",(r,s)=>{this.events.removeListener(r,s)}),this.relayer=e,this.logger=Ne(i,this.name),this.registerEventListeners()}get context(){return ke(this.logger)}async rpcPublish(e){var i,r,s,n;const{topic:o,message:a,ttl:c=ou,prompt:u,tag:h,id:l,attestation:d,tvf:f}=e,p={method:wr(Es().protocol).publish,params:rs({topic:o,message:a,ttl:c,prompt:u,tag:h,attestation:d},f),id:l};De((i=p.params)==null?void 0:i.prompt)&&((r=p.params)==null||delete r.prompt),De((s=p.params)==null?void 0:s.tag)&&((n=p.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});const y=await this.relayer.request(p);return this.relayer.events.emit(we.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,i)=>{const r=e.attempt+1;this.queue.set(i,Sn(rs({},e),{attempt:r}));const{topic:s,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(Sn(rs({},e),{topic:s,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(gi.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(we.connection_stalled);return}this.checkQueue()}),this.relayer.on(we.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var KI=Object.defineProperty,WI=(t,e,i)=>e in t?KI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Si=(t,e,i)=>WI(t,typeof e!="symbol"?e+"":e,i);class GI{constructor(){Si(this,"map",new Map),Si(this,"set",(e,i)=>{const r=this.get(e);this.exists(e,i)||this.map.set(e,[...r,i])}),Si(this,"get",e=>
vendor: 9,949 bytes, line 37
37this.map.get(e)||[]),Si(this,"exists",(e,i)=>this.get(e).includes(i)),Si(this,"delete",(e,i)=>{if(typeof i>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,i))return;const s=r.filter(n=>n!==i);if(!s.length){this.map.delete(e);return}this.map.set(e,s)}),Si(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var YI=Object.defineProperty,JI=Object.defineProperties,ZI=Object.getOwnPropertyDescriptors,yu=Object.getOwnPropertySymbols,QI=Object.prototype.hasOwnProperty,XI=Object.prototype.propertyIsEnumerable,go=(t,e,i)=>e in t?YI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,gr=(t,e)=>{for(var i in e||(e={}))QI.call(e,i)&&go(t,i,e[i]);if(yu)for(var i of yu(e))XI.call(e,i)&&go(t,i,e[i]);return t},On=(t,e)=>JI(t,ZI(e)),ie=(t,e,i)=>go(t,typeof e!="symbol"?e+"":e,i);class e$ extends SE{constructor(e,i){super(e,i),this.relayer=e,this.logger=i,ie(this,"subscriptions",new Map),ie(this,"topicMap",new GI),ie(this,"events",new it.EventEmitter),ie(this,"name",U_),ie(this,"version",L_),ie(this,"pending",new Map),ie(this,"cached",[]),ie(this,"initialized",!1),ie(this,"storagePrefix",$t),ie(this,"subscribeTimeout",N.toMiliseconds(N.ONE_MINUTE)),ie(this,"initialSubscribeTimeout",N.toMiliseconds(N.ONE_SECOND*15)),ie(this,"clientId"),ie(this,"batchSubscribeTopicsLimit",500),ie(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ie(this,"subscribe",async(r,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:s}});try{const n=Es(s),o={topic:r,relay:n,transportType:s==null?void 0:s.transportType};this.pending.set(r,o);const a=await this.rpcSubscribe(r,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),ie(this,"unsubscribe",async(r,s)=>{this.isInitialized(),typeof(s==null?void 0:s.id)<"u"?await this.unsubscribeById(r,s.id,s):await this.unsubscribeByTopic(r,s)}),ie(this,"isSubscribed",r=>new Promise(s=>{s(this.topicMap.topics.includes(r))})),ie(this,"isKnownTopic",r=>new Promise(s=>{s(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),ie(this,"on",(r,s)=>{this.events.on(r,s)}),ie(this,"once",(r,s)=>{this.events.once(r,s)}),ie(this,"off",(r,s)=>{this.events.off(r,s)}),ie(this,"removeListener",(r,s)=>{this.events.removeListener(r,s)}),ie(this,"start",async()=>{await this.onConnect()}),ie(this,"stop",async()=>{await this.onDisconnect()}),ie(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ie(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const r=[];this.pending.forEach(s=>{r.push(s)}),await this.batchSubscribe(r)}),ie(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(gi.pulse,async()=>{await this.checkPending()}),this.events.on(He.created,async r=>{const s=He.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:r}),await this.persist()}),this.events.on(He.deleted,async r=>{const s=He.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:r}),await this.persist()})}),this.relayer=e,this.logger=Ne(i,this.name),this.clientId=""}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,i){let r=!1;try{r=this.getSubscription(e).topic===i}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,i){const r=this.topicMap.get(e);await Promise.all(r.map(async s=>await this.unsubscribeById(e,s,i)))}async unsubscribeById(e,i,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:i,opts:r}});try{const s=Es(r);await this.restartToComplete({topic:e,id:i,relay:s}),await this.rpcUnsubscribe(e,i,s);const n=te("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,i,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:i,opts:r}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,i,r){var s;(!r||(r==null?void 0:r.transportType)===ae.relay)&&await this.restartToComplete({topic:e,id:e,relay:i});const n={method:wr(i.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(s=r==null?void 0:r.internal)==null?void 0:s.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((r==null?void 0:r.transportType)===ae.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},N.toMiliseconds(N.ONE_SECOND)),a;const c=new Promise(async h=>{const l=d=>{d.topic===e&&(this.events.removeListener(He.created,l),h(d.id))};this.events.on(He.created,l);try{const d=await zt(new Promise((f,p)=>{this.relayer.request(n).catch(y=>{this.logger.warn(y,y==null?void 0:y.message),p(y)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(He.created,l),h(d)}catch{}}),u=await zt(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(we.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const i=e[0].relay,r={method:wr(i.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await zt(new Promise(s=>{this.relayer.request(r).catch(n=>this.logger.warn(n)).then(s)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(we.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const i=e[0].relay,r={method:wr(i.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let s;try{s=await await zt(new Promise((n,o)=>{this.relayer.request(r).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(we.connection_stalled)}return s}rpcUnsubscribe(e,i,r){const s={method:wr(r.protocol).unsubscribe,params:{topic:e,id:i}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,i){this.setSubscription(e,On(gr({},i),{id:e})),this.pending.delete(i.topic)}onBatchSubscribe(e){e.length&&e.forEach(i=>{this.setSubscription(i.id,gr({},i)),this.pending.delete(i.topic)})}async onUnsubscribe(e,i,r){this.events.removeAllListeners(i),this.hasSubscription(i,e)&&this.deleteSubscription(i,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,i){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:i}),this.addSubscription(e,i)}addSubscription(e,i){this.subscriptions.set(e,gr({},i)),this.topicMap.set(i.topic,e),this.events.emit(He.created,i)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const i=this.subscriptions.get(e);if(!i){const{message:r}=F("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return i}deleteSubscription(e,i){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:i});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(He.deleted,On(gr({},r),{reason:i}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(He.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],i=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<i;r++){const s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(He.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:i}=F("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(i)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async i=>On(gr({}
37,i),{id:await this.getSubscriptionId(i.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const i=await this.rpcBatchFetchMessages(e);i&&i.messages&&(await Gw(N.toMiliseconds(N.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(i.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Et(e+await this.getClientId())}}var t$=Object.defineProperty,mu=Object.getOwnPropertySymbols,i$=Object.prototype.hasOwnProperty,r$=Object.prototype.propertyIsEnumerable,yo=(t,e,i)=>e in t?t$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,wu=(t,e)=>{for(var i in e||(e={}))i$.call(e,i)&&yo(t,i,e[i]);if(mu)for(var i of mu(e))r$.call(e,i)&&yo(t,i,e[i]);return t},Z=(t,e,i)=>yo(t,typeof e!="symbol"?e+"":e,i);class s$ extends $E{constructor(e){super(e),Z(this,"protocol","wc"),Z(this,"version",2),Z(this,"core"),Z(this,"logger"),Z(this,"events",new it.EventEmitter),Z(this,"provider"),Z(this,"messages"),Z(this,"subscriber"),Z(this,"publisher"),Z(this,"name",R_),Z(this,"transportExplicitlyClosed",!1),Z(this,"initialized",!1),Z(this,"connectionAttemptInProgress",!1),Z(this,"relayUrl"),Z(this,"projectId"),Z(this,"packageName"),Z(this,"bundleId"),Z(this,"hasExperiencedNetworkDisruption",!1),Z(this,"pingTimeout"),Z(this,"heartBeatTimeout",N.toMiliseconds(N.THIRTY_SECONDS+N.FIVE_SECONDS)),Z(this,"reconnectTimeout"),Z(this,"connectPromise"),Z(this,"reconnectInProgress",!1),Z(this,"requestsInFlight",[]),Z(this,"connectTimeout",N.toMiliseconds(N.ONE_SECOND*15)),Z(this,"request",async i=>{var r,s;this.logger.debug("Publishing Request Payload");const n=i.id||ni().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:i.method,topic:(r=i.params)==null?void 0:r.topic},"relayer.request - publishing...");const o=`${n}:${((s=i.params)==null?void 0:s.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(i);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),Z(this,"resetPingTimeout",()=>{bs()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var i,r,s,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(s=(r=(i=this.provider)==null?void 0:i.connection)==null?void 0:r.socket)==null?void 0:s.terminate)==null||n.call(s)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),Z(this,"onPayloadHandler",i=>{this.onProviderPayload(i),this.resetPingTimeout()}),Z(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(we.connect)}),Z(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Z(this,"onProviderErrorHandler",i=>{this.logger.fatal(`Fatal socket error: ${i.message}`),this.events.emit(we.error,i),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Z(this,"registerProviderListeners",()=>{this.provider.on(Ze.payload,this.onPayloadHandler),this.provider.on(Ze.connect,this.onConnectHandler),this.provider.on(Ze.disconnect,this.onDisconnectHandler),this.provider.on(Ze.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ne(e.logger,this.name):zr(Ms({level:e.logger||T_})),this.messages=new LI(this.logger,e.core),this.subscriber=new e$(this,this.logger),this.publisher=new VI(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||td,this.projectId=e.projectId,Tw()?this.packageName=Xa():Rw()&&(this.bundleId=Xa()),this.provider={}}
37async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return ke(this.logger)}get connected(){var e,i,r;return((r=(i=(e=this.provider)==null?void 0:e.connection)==null?void 0:i.socket)==null?void 0:r.readyState)===1||!1}get connecting(){var e,i,r;return((r=(i=(e=this.provider)==null?void 0:e.connection)==null?void 0:i.socket)==null?void 0:r.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,i,r){this.isInitialized(),await this.publisher.publish(e,i,r),await this.recordMessageEvent({topic:e,message:i,publishedAt:Date.now(),transportType:ae.relay},fs.outbound)}async subscribe(e,i){var r,s,n;this.isInitialized(),(!(i!=null&&i.transportType)||(i==null?void 0:i.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((r=i==null?void 0:i.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(s=i==null?void 0:i.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const u=h=>{h.topic===e&&(this.subscriber.off(He.created,u),c())};return await Promise.all([new Promise(h=>{c=h,this.subscriber.on(He.created,u)}),new Promise(async(h,l)=>{a=await this.subscriber.subscribe(e,wu({internal:{throwOnFailedPublish:o}},i)).catch(d=>{o&&l(d)})||a,h()})]),a}async unsubscribe(e,i){this.isInitialized(),await this.subscriber.unsubscribe(e,i)}on(e,i){this.events.on(e,i)}
vendor: 27,843 bytes, line 37
37once(e,i){this.events.once(e,i)}off(e,i){this.events.off(e,i)}removeListener(e,i){this.events.removeListener(e,i)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await zt(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(i,r)=>{await this.connect(e).then(i).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await kc())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const i=e.sort((r,s)=>r.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${i.length} message events sorted`);for(const r of i)try{await this.onMessageEvent(r)}catch(s){this.logger.warn(s,"Error while processing batch message event: "+(s==null?void 0:s.message))}this.logger.trace(`Batch of ${i.length} message events processed`)}async onLinkMessageEvent(e,i){const{topic:r}=e;if(!i.sessionExists){const s=de(N.FIVE_MINUTES),n={topic:r,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(we.message,e),await this.recordMessageEvent(e,fs.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let i=1;for(;i<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${i}...`),await this.createProvider(),await new Promise(async(r,s)=>{const n=()=>{s(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ze.disconnect,n),await zt(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o)}).finally(()=>{this.provider.off(Ze.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ze.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ze.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){await this.subscriber.stop();const s=r;this.logger.warn({},s.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${i}`);break}await new Promise(r=>setTimeout(r,N.toMiliseconds(i*1))),i++}}startPingTimeout(){var e,i,r,s,n;if(bs())try{(i=(e=this.provider)==null?void 0:e.connection)!=null&&i.socket&&((n=(s=(r=this.provider)==null?void 0:r.connection)==null?void 0:s.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new rt(new __(Uw({sdkVersion:uo,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,i){const{topic:r,message:s}=e;await this.messages.set(r,s,i)}async shouldIgnoreMessageEvent(e){const{topic:i,message:r}=e;if(!r||r.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(i))return this.logger.warn(`Ignoring message for unknown topic ${i}`),!0;const s=this.messages.has(i,r);return s&&this.logger.warn(`Ignoring duplicate message: ${r}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Wo(e)){if(!e.method.endsWith(N_))return;const i=e.params,{topic:r,message:s,publishedAt:n,attestation:o}=i.data,a={topic:r,message:s,publishedAt:n,transportType:ae.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(wu({type:"event",event:i.id},a)),this.events.emit(i.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Vs(e)&&this.events.emit(we.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,fs.inbound),this.events.emit(we.message,e))}async acknowledgePayload(e){const i=zs(e.id,!0);await this.provider.connection.send(i)}unregisterProviderListeners(){this.provider.off(Ze.payload,this.onPayloadHandler),this.provider.off(Ze.connect,this.onConnectHandler),this.provider.off(Ze.disconnect,this.onDisconnectHandler),this.provider.off(Ze.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await kc();o1(async i=>{e!==i&&(e=i,i?await this.transportOpen().catch(r=>this.logger.error(r,r==null?void 0:r.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(gi.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&u1())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(i){this.logger.warn(i,i==null?void 0:i.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(we.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},N.toMiliseconds(F_)))))}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function n$(){}function bu(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function vu(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Eu(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const o$="[object RegExp]",a$="[object String]",c$="[object Number]",u$="[object Boolean]",_u="[object Arguments]",h$="[object Symbol]",l$="[object Date]",d$="[object Map]",p$="[object Set]",f$="[object Array]",g$="[object Function]",y$="[object ArrayBuffer]",Pn="[object Object]",m$="[object Error]",w$="[object DataView]",b$="[object Uint8Array]",v$="[object Uint8ClampedArray]",E$="[object Uint16Array]",_$="[object Uint32Array]",I$="[object BigUint64Array]",$$="[object Int8Array]",D$="[object Int16Array]",S$="[object Int32Array]",O$="[object BigInt64Array]",P$="[object Float32Array]",A$="[object Float64Array]";function x$(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function C$(t,e,i){return br(t,e,void 0,void 0,void 0,void 0,i)}function br(t,e,i,r,s,n,o){const a=o(t,e,i,r,s,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return $r(t,e,n,o)}return $r(t,e,n,o)}function $r(t,e,i,r){if(Object.is(t,e))return!0;let s=Eu(t),n=Eu(e);if(s===_u&&(s=Pn),n===_u&&(n=Pn),s!==n)return!1;switch(s){case a$:return t.toString()===e.toString();case c$:{const c=t.valueOf(),u=e.valueOf();return x$(c,u)}case u$:case l$:case h$:return Object.is(t.valueOf(),e.valueOf());case o$:return t.source===e.source&&t.flags===e.flags;case g$:return t===e}i=i??new Map;const o=i.get(t),a=i.get(e);if(o!=null&&a!=null)return o===e;i.set(t,e),i.set(e,t);try{switch(s){case d$:{if(t.size!==e.size)return!1;for(const[c,u]of t.entries())if(!e.has(c)||!br(u,e.get(c),c,t,e,i,r))return!1;return!0}case p$:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),u=Array.from(e.values());for(let h=0;h<c.length;h++){const l=c[h],d=u.findIndex(f=>br(l,f,void 0,t,e,i,r));if(d===-1)return!1;u.splice(d,1)}return!0}case f$:case b$:case v$:case E$:case _$:case I$:case $$:case D$:case S$:case O$:case P$:case A$:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!br(t[c],e[c],c,t,e,i,r))return!1;return!0}case y$:return t.byteLength!==e.byteLength?!1:$r(new Uint8Array(t),new Uint8Array(e),i,r);case w$:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:$r(new Uint8Array(t),new Uint8Array(e),i,r);case m$:return t.name===e.name&&t.message===e.message;case Pn:{if(!($r(t.constructor,e.constructor,i,r)||bu(t)&&bu(e)))return!1;const c=[...Object.keys(t),...vu(t)],u=[...Object.keys(e),...vu(e)];if(c.length!==u.length)return!1;for(let h=0;h<c.length;h++){const l=c[h],d=t[l];if(!Object.hasOwn(e,l))return!1;const f=e[l];if(!br(d,f,l,t,e,i,r))return!1}return!0}default:return!1}}finally{i.delete(t),i.delete(e)}}function T$(t,e){return C$(t,e,n$)}var R$=Object.defineProperty,Iu=Object.getOwnPropertySymbols,N$=Object.prototype.hasOwnProperty,F$=Object.prototype.propertyIsEnumerable,mo=(t,e,i)=>e in t?R$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,$u=(t,e)=>{for(var i in e||(e={}))N$.call(e,i)&&mo(t,i,e[i]);if(Iu)for(var i of Iu(e))F$.call(e,i)&&mo(t,i,e[i]);return t},Be=(t,e,i)=>mo(t,typeof e!="symbol"?e+"":e,i);class yi extends DE{constructor(e,i,r,s=$t,n=void 0){super(e,i,r,s),this.core=e,this.logger=i,this.name=r,Be(this,"map",new Map),Be(this,"version",B_),Be(this,"cached",[]),Be(this,"initialized",!1),Be(this,"getKey"),Be(this,"storagePrefix",$t),Be(this,"recentlyDeleted",[]),Be(this,"recentlyDeletedLimit",200),Be(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!De(o)?this.map.set(this.getKey(o),o):jv(o)?this.map.set(o.id,o):Uv(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Be(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Be(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Be(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>T$(a[c],o[c]))):this.values)),Be(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=$u($u({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Be(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Ne(i,this.name),this.storagePrefix=s,this.getKey=n}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const i=this.map.get(e);if(!i){if(this.recentlyDeleted.includes(e)){const{message:s}=F("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:r}=F("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}return i}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:i}=F("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var B$=Object.defineProperty,j$=(t,e,i)=>e in t?B$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,K=(t,e,i)=>j$(t,typeof e!="symbol"?e+"":e,i);class U${constructor(e,i){this.core=e,this.logger=i,K(this,"name",q_),K(this,"version",k_),K(this,"events",new So),K(this,"pairings"),K(this,"initialized",!1),K(this,"storagePrefix",$t),K(this,"ignoredPayloadTypes",[Ft]),K(this,"registeredMethods",[]),K(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),K(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),K(this,"create",async r=>{this.isInitialized();const s=ro(),n=await this.core.crypto.setSymKey(s),o=de(N.FIVE_MINUTES),a={protocol:ed},c={topic:n,expiry:o,relay:a,active:!1,methods:r==null?void 0:r.methods},u=Tc({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:r==null?void 0:r.methods});return this.events.emit(ii.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r==null?void 0:r.transportType}),{topic:n,uri:u}}),K(this,"pair",async r=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:r==null?void 0:r.uri,trace:[mt.pairing_started]}});this.isValidPair(r,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:u}=Cc(r.uri);s.props.properties.topic=n,s.addTrace(mt.pairing_uri_validation_success),s.addTrace(mt.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(n)){if(h=this.pairings.get(n),s.addTrace(mt.existing_pairing),h.active)throw s.setError(Ct.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(mt.pairing_not_expired)}const l=c||de(N.FIVE_MINUTES),d={topic:n,relay:a,expiry:l,active:!1,methods:u};this.core.expirer.set(n,l),await this.pairings.set(n,d),s.addTrace(mt.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(ii.create,d),s.addTrace(mt.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(mt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(Ct.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw s.setError(Ct.subscribe_pairing_topic_failure),f}return s.addTrace(mt.subscribe_pairing_topic_success),d}),K(this,"activate",async({topic:r})=>{this.isInitialized();const s=de(N.FIVE_MINUTES);this.core.expirer.set(r,s),await this.pairings.update(r,{active:!0,expiry:s})}),K(this,"ping",async r=>{this.isInitialized(),await this.isValidPing(r),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:s}=r;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Qt();this.events.once(X("pairing_ping",n),({error:u})=>{u?c(u):a()}),await o()}}),K(this,"updateExpiry",async({topic:r,expiry:s})=>{this.isInitialized(),await this.pairings.update(r,{expiry:s})}),K(this,"updateMetadata",async({topic:r,metadata:s})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:s})}),K(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),K(this,"disconnect",async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",te("USER_DISCONNECTED")),await this.deletePairing(s))}),K(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(s);return Tc({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),K(this,"sendRequest",async(r,s,n)=>{const o=Ht(s,n),a=await this.core.crypto.encode(r,o),c=pr[s].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),K(this,"sendResult",async(r,s,n)=>{const o=zs(r,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,r)).request.method,u=pr[c].res;await this.core.relayer.publish(s,a,u),await this.core.history.resolve(o)}),K(this,"sendError",async(r,s,n)=>{const o=Hs(r,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,r)).request.method,u=pr[c]?pr[c].res:pr.unregistered_method.res;await this.core.relayer.publish(s,a,u),await this.core.history.resolve(o)}),K(this,"deletePairing",async(r,s)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,te("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),s?Promise.resolve():this.core.expirer.del(r)])}),K(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(s=>kt(s.expiry));await Promise.all(r.map(s=>this.deletePairing(s.topic)))}),K(this,"onRelayEventRequest",async r=>{const{topic:s,payload:n}=r;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(s,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(s,n);default:return await this.onUnknownRpcMethodRequest(s,n)}}),K(this,"onRelayEventResponse",async r=>{const{topic:s,payload:n}=r,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}}),K(this,"onPairingPingRequest",async(r,s)=>{const{id:n}=s;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(ii.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),K(this,"onPairingPingResponse",(r,s)=>{const{id:n}=s;setTimeout(()=>{bt(s)?this.events.emit(X("pairing_ping",n),{}):et(s)&&this.events.emit(X("pairing_ping",n),{error:s.error})},500)}),K(this,"onPairingDeleteRequest",async(r,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(ii.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),K(this,"onUnknownRpcMethodRequest",async(r,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=te("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,r,a),this.logger.error(a)}catch(a){await this.sendError(n,r,a),this.logger.error(a)}}),K(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(te("WC_METHOD_UNSUPPORTED",r))}),K(this,"isValidPair",(r,s)=>{var n;if(!Ue(r)){const{message:a}=F("MISSING_OR_INVALID",`pair() params: ${r}`);throw s.setError(Ct.malformed_pairing_uri),new Error(a)}if(!Bv(r.uri)){const{message:a}=F("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw s.setError(Ct.malformed_pairing_uri),new Error(a)}const o=Cc(r==null?void 0:r.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=F("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(Ct.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=F("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(Ct.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&N.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){s.setError(Ct.pairing_expired);const{message:a}=F("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),K(this,"isValidPing",async r=>{if(!Ue(r)){const{message:n}=F("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:s}=r;await this.isValidPairingTopic(s)}),K(this,"isValidDisconnect",async r=>{if(!Ue(r)){const{message:n}=F("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:s}=r;await this.isValidPairingTopic(s)}),K(this,"isValidPairingTopic",async r=>{if(!le(r,!1)){const{message:s}=F("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(s)}if(!this.pairings.keys.includes(r)){const{message:s}=F("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(s)}if(kt(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:s}=F("EXPIRED",`pairing topic: ${r}`);throw new Error(s)}}),this.core=e,this.logger=Ne(i,this.name),this.pairings=new yi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return ke(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(we.message,async e=>{const{topic:i,message:r,transportType:s}=e;if(this.pairings.keys.includes(i)&&s!==ae.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(i,r);Wo(n)?(this.core.history.set(i,n),await this.onRelayEventRequest({topic:i,payload:n})):Vs(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:i,payload:n}),this.core.history.delete(i,n.id)),await this.core.relayer.messages.ack(i,r)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(Xe.expired,async e=>{const{topic:i}=nl(e.target);i&&this.pairings.keys.includes(i)&&(await this.deletePairing(i,!0),this.events.emit(ii.expire,{topic:i}))})}}var L$=Object.defineProperty,q$=(t,e,i)=>e in t?L$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,$e=(t,e,i)=>q$(t,typeof e!="symbol"?e+"":e,i);class k$ extends EE{constructor(e,i){super(e,i),this.core=e,this.logger=i,$e(this,"records",new Map),$e(this,"events",new it.EventEmitter),$e(this,"name",M_),$e(this,"version",z_),$e(this,"cached",[]),$e(this,"initialized",!1),$e(this,"storagePrefix",$t),$e(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.records.set(r.id,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),$e(this,"set",(r,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:r,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:r,request:{method:s.method,params:s.params||null},chainId:n,expiry:de(N.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(ot.created,o)}),$e(this,"resolve",async r=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:r}),!this.records.has(r.id))return;const s=await this.getRecord(r.id);typeof s.response>"u"&&(s.response=et(r)?{error:r.error}:{result:r.result},this.records.set(s.id,s),this.persist(),this.events.emit(ot.updated,s))}),$e(this,"get",async(r,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:r,id:s}),await this.getRecord(s))),$e(this,"delete",(r,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===r){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(ot.deleted,n)}}),this.persist()}),$e(this,"exists",async(r,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===r:!1)),$e(this,"on",(r,s)=>{this.events.on(r,s)}),$e(this,"once",(r,s)=>{this.events.once(r,s)}),$e(this,"off",(r,s)=>{this.events.off(r,s)}),$e(this,"removeListener",(r,s)=>{this.events.removeListener(r,s)}),this.logger=Ne(i,this.name)}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(i=>{if(typeof i.response<"u")return;const r={topic:i.topic,request:Ht(i.request.method,i.request.params,i.id),chainId:i.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const i=this.records.get(e);if(!i){const{message:r}=F("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return i}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(ot.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:i}=F("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(ot.created,e=>{const i=ot.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:e})}),this.events.on(ot.updated,e=>{const i=ot.updated;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:e})}),this.events.on(ot.deleted,e=>{const i=ot.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:e})}),this.core.heartbeat.on(gi.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(i=>{N.toMiliseconds(i.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${i.id}`),this.records.delete(i.id),this.events.emit(ot.deleted,i,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var M$=Object.defineProperty,z$=(t,e,i)=>e in t?M$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xe=(t,e,i)=>z$(t,typeof e!="symbol"?e+"":e,i);class H$ extends OE{constructor(e,i){super(e,i),this.core=e,this.logger=i,xe(this,"expirations",new Map),xe(this,"events",new it.EventEmitter),xe(this,"name",H_),xe(this,"version",V_),xe(this,"cac
37hed",[]),xe(this,"initialized",!1),xe(this,"storagePrefix",$t),xe(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.expirations.set(r.target,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),xe(this,"has",r=>{try{const s=this.formatTarget(r);return typeof this.getExpiration(s)<"u"}catch{return!1}}),xe(this,"set",(r,s)=>{this.isInitialized();const n=this.formatTarget(r),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Xe.created,{target:n,expiration:o})}),xe(this,"get",r=>{this.isInitialized();const s=this.formatTarget(r);return this.getExpiration(s)}),xe(this,"del",r=>{if(this.isInitialized(),this.has(r)){const s=this.formatTarget(r),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Xe.deleted,{target:s,expiration:n})}}),xe(this,"on",(r,s)=>{this.events.on(r,s)}),xe(this,"once",(r,s)=>{this.events.once(r,s)}),xe(this,"off",(r,s)=>{this.events.off(r,s)}),xe(this,"removeListener",(r,s)=>{this.events.removeListener(r,s)}),this.logger=Ne(i,this.name)}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Lw(e);if(typeof e=="number")return qw(e);const{message:i}=F("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(i)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Xe.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:i}=F("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const i=this.expirations.get(e);if(!i){const{message:r}=F("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return i}checkExpiry(e,i){const{expiry:r}=i;N.toMiliseconds(r)-Date.now()<=0&&this.expire(e,i)}expire(e,i){this.expirations.delete(e),this.events.emit(Xe.expired,{target:e,expiration:i})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,i)=>this.checkExpiry(i,e))}registerEventListeners(){this.core.heartbeat.on(gi.pulse,()=>this.checkExpirations()),this.events.on(Xe.created,e=>{const i=Xe.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:e}),this.persist()}),this.events.on(Xe.expired,e=>{const i=Xe.expired;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:e}),this.persist()}),this.events.on(Xe.deleted,e=>{const i=Xe.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}}var V$=Object.defineProperty,K$=(t,e,i)=>e in t?V$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,he=(t,e,i)=>K$(t,typeof e!="symbol"?e+"":e,i);class W$ extends PE{constructor(e,i,r){super(e,i,r),this.core=e,this.logger=i,this.store=r,he(this,"name",K_),he(this,"abortController"),he(this,"isDevEnv"),he(this,"verifyUrlV3",G_),he(this,"storagePrefix",$t),he(this,"version",Xl),he(this,"publicKey"),he(this,"fetchPromise"),he(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&N.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),he(this,"register",async s=>{if(!ir()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const u=ai(),h=this.startAbortTimer(N.ONE_SECOND*5),l=await new Promise((d,f)=>{const p=()=>{window.removeEventListener("message",w),u.body.removeChild(y),f("attestation aborted")};this.abortController.signal.addEventListener("abort",p);const y=u.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",p,{signal:this.abortController.signal});const w=v=>
vendor: 8,753 bytes, line 37
37{if(v.data&&typeof v.data=="string")try{const b=JSON.parse(v.data);if(b.type==="verify_attestation"){if(Vn(b.attestation).payload.id!==o)return;clearInterval(h),u.body.removeChild(y),this.abortController.signal.removeEventListener("abort",p),window.removeEventListener("message",w),d(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};u.body.appendChild(y),window.addEventListener("message",w,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",l),l}catch(u){this.logger.warn(u)}return""}),he(this,"resolve",async s=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(Vn(n).payload.id!==a)return;const u=await this.isValidJwtAttestation(n);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;const c=this.getVerifyUrl(s==null?void 0:s.verifyUrl);return this.fetchAttestation(o,c)}),he(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(N.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),he(this,"getVerifyUrl",s=>{let n=s||Ir;return Y_.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Ir}`),n=Ir),n}),he(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(N.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}}),he(this,"persistPublicKey",async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s}),he(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),he(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),he(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),he(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),he(this,"validateAttestation",(s,n)=>{const o=gv(s,n.publicKey),a={hasExpired:N.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Ne(i,this.name),this.abortController=new AbortController,this.isDevEnv=jo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return ke(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),N.toMiliseconds(e))}}var G$=Object.defineProperty,Y$=(t,e,i)=>e in t?G$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Du=(t,e,i)=>Y$(t,typeof e!="symbol"?e+"":e,i);class J$ extends AE{constructor(e,i){super(e,i),this.projectId=e,this.logger=i,Du(this,"context",J_),Du(this,"registerDeviceToken",async r=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${Z_}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})}),this.logger=Ne(i,this.context)}}var Z$=Object.defineProperty,Su=Object.getOwnPropertySymbols,Q$=Object.prototype.hasOwnProperty,X$=Object.prototype.propertyIsEnumerable,wo=(t,e,i)=>e in t?Z$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,yr=(t,e)=>{for(var i in e||(e={}))Q$.call(e,i)&&wo(t,i,e[i]);if(Su)for(var i of Su(e))X$.call(e,i)&&wo(t,i,e[i]);return t},fe=(t,e,i)=>wo(t,typeof e!="symbol"?e+"":e,i);class eD extends xE{constructor(e,i,r=!0){super(e,i,r),this.core=e,this.logger=i,fe(this,"context",X_),fe(this,"storagePrefix",$t),fe(this,"storageVersion",Q_),fe(this,"events",new Map),fe(this,"shouldPersist",!1),fe(this,"init",async()=>{if(!jo())try{const s={eventId:tc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:rl(this.core.relayer.protocol,this.core.relayer.version,uo)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}}),fe(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,u=tc(),h=this.core.projectId||"",l=Date.now(),d=yr({eventId:u,timestamp:l,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:h,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,d),this.shouldPersist=!0),d}),fe(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return yr(yr({},a),this.setMethods(a.eventId))}),fe(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0}),fe(this,"setEventListeners",()=>{this.core.heartbeat.on(gi.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{N.fromMiliseconds(Date.now())-N.fromMiliseconds(s.timestamp)>e2&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})}),fe(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),fe(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)}),fe(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)}),fe(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),fe(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,yr(yr({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}}),fe(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),fe(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${t2}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${uo}${n}`,{method:"POST",body:JSON.stringify(s)})}),fe(this,"getAppDomain",()=>il().url),this.logger=Ne(i,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var tD=Object.defineProperty,Ou=Object.getOwnPropertySymbols,iD=Object.prototype.hasOwnProperty,rD=Object.prototype.propertyIsEnumerable,bo=(t,e,i)=>e in t?tD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pu=(t,e)=>{for(var i in e||(e={}))iD.call(e,i)&&bo(t,i,e[i]);if(Ou)for(var i of Ou(e))rD.call(e,i)&&bo(t,i,e[i]);return t},ne=(t,e,i)=>bo(t,typeof e!="symbol"?e+"":e,i);let sD=class pd extends mE{constructor(e){var i;super(e),ne(this,"protocol",Ql),ne(this,"version",Xl),ne(this,"name",Ds),ne(this,"relayUrl"),ne(this,"projectId"),ne(this,"customStoragePrefix"),ne(this,"events",new it.EventEmitter),ne(this,"logger"),ne(this,"heartbeat"),ne(this,"relayer"),ne(this,"crypto"),ne(this,"storage"),ne(this,"history"),ne(this,"expirer"),ne(this,"pairing"),ne(this,"verify"),ne(this,"echoClient"),ne(this,"linkModeSupportedApps"),ne(this,"eventClient"),ne(this,"initialized",!1),ne(this,"logChunkController"),ne(this,"on",(a,c)=>this.events.on(a,c)),ne(this,"once",(a,c)=>this.events.once(a,c)),ne(this,"off",(a,c)=>this.events.off(a,c)),ne(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),ne(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:u})=>
37{if(!a||!c)return;const h={topic:a,message:c,publishedAt:Date.now(),transportType:ae.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:u})});const r=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||td,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=Ms({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:I_.logger,name:Ds}),{logger:n,chunkLoggerController:o}=fE({opts:s,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(i=this.logChunkController)!=null&&i.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ne(n,this.name),this.heartbeat=new l1,this.crypto=new CI(this,this.logger,e==null?void 0:e.keychain),this.history=new k$(this,this.logger),this.expirer=new H$(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new q1(Pu(Pu({},$_),e==null?void 0:e.storageOptions)),this.relayer=new s$({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new U$(this,this.logger),this.verify=new W$(this,this.logger,this.storage),this.echoClient=new J$(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new eD(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const i=new pd(e);await i.initialize();const r=await i.crypto.getClientId();return await i.storage.setItem(j_,r),i}get context(){return ke(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(au,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(au)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${e}`,r=`${i}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[i]}catch(i){console.warn("Failed to get global WalletConnect core",i);return}}setGlobalCore(e){var i;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${((i=e.opts)==null?void 0:i.customStoragePrefix)||""}`;globalThis[r]=e}catch(r){console.warn("Failed to set global WalletConnect core",r)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&{}.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const nD=sD,fd="wc",gd=2,yd="client",Go=`${fd}@${gd}:${yd}:`,An={name:yd,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Au="WALLETCONNECT_DEEPLINK_CHOICE",oD="proposal",xu="Proposal expired",aD="session",Oi=N.SEVEN_DAYS,cD="engine",ge={wc_sessionPropose:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1104},res:{ttl:N.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1106},res:{ttl:N.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1112},res:{ttl:N.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1114},res:{ttl:N.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:N.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:N.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1119}}},xn={min:N.FIVE_MINUTES,max:N.SEVEN_DAYS},yt={idle:"IDLE",active:"ACTIVE"},Cu={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},uD="request",hD=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],lD="wc",dD="auth",pD="authKeys",fD="pairingTopics",gD="requests",Ws=`${lD}@${1.5}:${dD}:`,gs=`${Ws}:PUB_KEY`;var yD=Object.defineProperty,mD=Object.defineProperties,wD=Object.getOwnPropertyDescriptors,Tu=Object.getOwnPropertySymbols,bD=Object.prototype.hasOwnProperty,vD=Object.prototype.propertyIsEnumerable,vo=(t,e,i)=>e in t?yD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,re=(t,e)=>{for(var i in e||(e={}))bD.call(e,i)&&vo(t,i,e[i]);if(Tu)for(var i of Tu(e))vD.call(e,i)&&vo(t,i,e[i]);return t},Te=(t,e)=>mD(t,wD(e)),R=(t,e,i)=>vo(t,typeof e!="symbol"?e+"":e,i);class ED extends NE{constructor(e){super(e),R(this,"name",cD),R(this,"events",new So),R(this,"initialized",!1),R(this,"requestQueue",{state:yt.idle,queue:[]}),R(this,"sessionRequestQueue",{state:yt.idle,queue:[]}),R(this,"requestQueueDelay",N.ONE_SECOND),R(this,"expectedPairingMethodMap",new Map),R(this,"recentlyDeletedMap",new Map),R(this,"recentlyDeletedLimit",200),R(this,"relayMessageCache",[]),R(this,"pendingSessions",new Map),R(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(ge)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay)))}),R(this,"connect",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const r=Te(re({},i),{requiredNamespaces:i.requiredNamespaces||{},optionalNamespaces:i.optionalNamespaces||{}});await this.isValidConnect(r),r.optionalNamespaces=Cv(r.requiredNamespaces,r.optionalNamespaces),r.requiredNamespaces={};const{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:u}=r;let h=s,l,d=!1;try{if(h){const A=this.client.core.pairing.pairings.get(h);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=A.active}}catch(A){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),A}if(!h||!d){const{topic:A,uri:O}=await this.client.core.pairing.create();h=A,l=O}if(!h){const{message:A}=F("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(A)}const f=await this.client.core.crypto.generateKeyPair(),p=ge.wc_sessionPropose.req.ttl||N.FIVE_MINUTES,y=de(p),w=Te(re(re({requiredNamespaces:n,optionalNamespaces:o,relays:u??[{protocol:ed}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:h},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:wt()}),v=X("session_connect",w.id),{reject:b,resolve:E,done:I}=Qt(p,xu),P=({id:A})=>{A===w.id&&(this.client.events.off("proposal_expire",P),this.pendingSessions.delete(w.id),this.events.emit(v,{error:{message:xu,code:0}}))};return this.client.events.on("proposal_expire",P),this.events.once(v,({error:A,session:O})=>{this.client.events.off("proposal_expire",P),A?b(A):O&&E(O)}),await this.sendRequest({topic:h,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:l,approval:I}}),R(this,"pair",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(i)}catch(r){throw this.client.logger.error("pair() failed"),r}}),R(this,"approve",async i=>{var r,s,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(r=i==null?void 0:i.id)==null?void 0:r.toString(),trace:[at.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(D){throw o.setError(Jt.no_internet_connection),D}try{await this.isValidProposalId(i==null?void 0:i.id)}catch(D){throw this.client.logger.error(`approve() -> proposal.get(${i==null?void 0:i.id}) failed`),o.setError(Jt.proposal_not_found),D}try{await this.isValidApprove(i)}catch(D){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Jt.session_approve_namespace_validation_failure),D}const{id:a,relayProtocol:c,namespaces:u,sessionProperties:h,scopedProperties:l,sessionConfig:d}=i,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:p,proposer:y,requiredNamespaces:w,optionalNamespaces:v}=f;let b=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:p});b||(b=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:at.session_approve_started,properties:{topic:p,trace:[at.session_approve_started,at.session_namespaces_validation_success]}}));const E=await this.client.core.crypto.generateKeyPair(),I=y.publicKey,P=await this.client.core.crypto.generateSharedKey(E,I),A=re(re(re({relay:{protocol:c??"irn"},namespaces:u,controller:{publicKey:E,metadata:this.client.metadata},expiry:de(Oi)},h&&{sessionProperties:h}),l&&{scopedProperties:l}),d&&{sessionConfig:d}),O=ae.relay;b.addTrace(at.subscribing_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:O})}catch(D){throw b.setError(Jt.subscribe_session_topic_failure),D}b.addTrace(at.subscribe_session_topic_success);const C=Te(re({},A),{topic:P,requiredNamespaces:w,optionalNamespaces:v,pairingTopic:p,acknowledged:!1,self:A.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:E,transportType:ae.relay});await this.client.session.set(P,C),b.addTrace(at.store_session);try{b.addTrace(at.publishing_session_settle),await this.sendRequest({topic:P,method:"wc_sessionSettle",params:A,throwOnFailedPublish:!0}).catch(D=>{throw b==null||b.setError(Jt.session_settle_publish_failure),D}),b.addTrace(at.session_settle_publish_success),b.addTrace(at.publishing_session_approve),await this.sendResult({id:a,topic:p,result:{relay:{protocol:c??"irn"},responderPublicKey:E},throwOnFailedPublish:!0}).catch(D=>{throw b==null||b.setError(Jt.session_approve_publish_failure),D}),b.addTrace(at.session_approve_publish_success)}catch(D){throw this.client.logger.error(D),this.client.session.delete(P,te("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(P),D}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:y.metadata}),await this.client.proposal.delete(a,te("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(P,de(Oi)),{topic:P,acknowledged:()=>Promise.resolve(this.client.session.get(P))}}),R(this,"reject",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(i)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:r,reason:s}=i;let n;try{n=this.client.proposal.get(r).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),o}
37n&&(await this.sendError({id:r,topic:n,error:s,rpcOpts:ge.wc_sessionPropose.reject}),await this.client.proposal.delete(r,te("USER_DISCONNECTED")))}),R(this,"update",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(i)}catch(l){throw this.client.logger.error("update() -> isValidUpdate() failed"),l}const{topic:r,namespaces:s}=i,{done:n,resolve:o,reject:a}=Qt(),c=wt(),u=ni().toString(),h=this.client.session.get(r).namespaces;return this.events.once(X("session_update",c),({error:l})=>{l?a(l):o()}),await this.client.session.update(r,{namespaces:s}),await this.sendRequest({topic:r,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:u}).catch(l=>{this.client.logger.error(l),this.client.session.update(r,{namespaces:h}),a(l)}),{acknowledged:n}}),R(this,"extend",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(i)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:r}=i,s=wt(),{done:n,resolve:o,reject:a}=Qt();return this.events.once(X("session_extend",s),({error:c})=>{c?a(c):o()}),await this.setExpiry(r,de(Oi)),this.sendRequest({topic:r,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),R(this,"request",async i=>{this.isInitialized();try{await this.isValidRequest(i)}catch(v){throw this.client.logger.error("request() -> isValidRequest() failed"),v}const{chainId:r,request:s,topic:n,expiry:o=ge.wc_sessionRequest.req.ttl}=i,a=this.client.session.get(n);(a==null?void 0:a.transportType)===ae.relay&&await this.confirmOnlineStateOrThrow();const c=wt(),u=ni().toString(),{done:h,resolve:l,reject:d}=Qt(o,"Request expired. Please try again.");this.events.once(X("session_request",c),({error:v,result:b})=>{v?d(v):l(b)});const f="wc_sessionRequest",p=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(p)return await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:n,method:f,params:{request:Te(re({},s),{expiryTimestamp:de(o)}),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:p}).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:r,id:c}),await h();const y={request:Te(re({},s),{expiryTimestamp:de(o)}),chainId:r},w=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async v=>{await this.sendRequest(re({clientRpcId:c,relayRpcId:u,topic:n,method:f,params:y,expiry:o,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,y)})).catch(b=>d(b)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:r,id:c}),v()}),new Promise(async v=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const E=await Hw(this.client.core.storage,Au);await kw({id:c,topic:n,wcDeepLink:E})}v()}),h()]).then(v=>v[2])}),R(this,"respond",async i=>{this.isInitialized(),await this.isValidRespond(i);const{topic:r,response:s}=i,{id:n}=s,o=this.client.session.get(r);o.transportType===ae.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);bt(s)?await this.sendResult({id:n,topic:r,result:s.result,throwOnFailedPublish:!0,appLink:a}):et(s)&&await this.sendError({id:n,topic:r,error:s.error,appLink:a}),this.cleanupAfterResponse(i)}),R(this,"ping",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(i)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:r}=i;if(this.client.session.keys.includes(r)){const s=wt(),n=ni().toString(),{done:o,resolve:a,reject:c}=Qt();this.events.once(X("session_ping",s),({error:u})=>{u?c(u):a()}),await Promise.all([this.sendRequest({topic:r,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(r)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:r}))}),R(this,"emit",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(i);const{topic:r,event:s,chainId:n}=i,o=ni().toString(),a=wt();await this.sendRequest({topic:r,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),R(this,"disconnect",async i=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(i);const{topic:r}=i;if(this.client.session.keys.includes(r))await this.sendRequest({topic:r,method:"wc_sessionDelete",params:te("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:r,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(r))await this.client.core.pairing.disconnect({topic:r});else{const{message:s}=F("MISMATCHED_TOPIC",`Session or pairing topic not found: ${r}`);throw new Error(s)}}),R(this,"find",i=>(this.isInitialized(),this.client.session.getAll().filter(r=>Nv(r,i)))),R(this,"getPendingSessionRequests",()=>
vendor: 9,775 bytes, line 37
37this.client.pendingRequest.getAll()),R(this,"authenticate",async(i,r)=>{var s;this.isInitialized(),this.isValidAuthenticate(i);const n=r&&this.client.core.linkModeSupportedApps.includes(r)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?ae.link_mode:ae.relay;o===ae.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:u,domain:h,nonce:l,type:d,exp:f,nbf:p,methods:y=[],expiry:w}=i,v=[...i.resources||[]],{topic:b,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:E}});const I=await this.client.core.crypto.generateKeyPair(),P=ls(I);if(await Promise.all([this.client.auth.authKeys.set(gs,{responseTopic:P,publicKey:I}),this.client.auth.pairingTopics.set(P,{topic:P,pairingTopic:b})]),await this.client.core.relayer.subscribe(P,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),y.length>0){const{namespace:$}=Hi(a[0]);let x=Bb($,"request",y);hs(v)&&(x=Ub(x,v.pop())),v.push(x)}const A=w&&w>ge.wc_sessionAuthenticate.req.ttl?w:ge.wc_sessionAuthenticate.req.ttl,O={authPayload:{type:d??"caip122",chains:a,statement:c,aud:u,domain:h,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:p,resources:v},requester:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:de(A)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},D={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:de(ge.wc_sessionPropose.req.ttl),id:wt()},{done:k,resolve:j,reject:B}=Qt(A,"Request expired"),M=wt(),T=X("session_connect",D.id),g=X("session_request",M),m=async({error:$,session:x})=>{this.events.off(g,_),$?B($):x&&j({session:x})},_=async $=>{var x,U,q;if(await this.deletePendingAuthRequest(M,{message:"fulfilled",code:0}),$.error){const Y=te("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return $.error.code===Y.code?void 0:(this.events.off(T,m),B($.error.message))}await this.deleteProposal(D.id),this.events.off(T,m);const{cacaos:z,responder:L}=$.result,H=[],G=[];for(const Y of z){await uc({cacao:Y,projectId:this.client.core.projectId})||(this.client.logger.error(Y,"Signature verification failed"),B(te("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Ae}=Y,Ee=hs(Ae.resources),Ce=[Gn(Ae.iss)],Ye=vs(Ae.iss);if(Ee){const Je=hc(Ee),wi=lc(Ee);H.push(...Je),Ce.push(...wi)}for(const Je of Ce)G.push(`${Je}:${Ye}`)}const se=await this.client.core.crypto.generateSharedKey(I,L.publicKey);let ee;H.length>0&&(ee={topic:se,acknowledged:!0,self:{publicKey:I,metadata:this.client.metadata},peer:L,controller:L.publicKey,expiry:de(Oi),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:Bc([...new Set(H)],[...new Set(G)]),transportType:o},await this.client.core.relayer.subscribe(se,{transportType:o}),await this.client.session.set(se,ee),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:L.metadata}),ee=this.client.session.get(se)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(U=L.metadata.redirect)!=null&&U.linkMode&&(q=L.metadata.redirect)!=null&&q.universal&&r&&(this.client.core.addLinkModeSupportedApp(L.metadata.redirect.universal),this.client.session.update(se,{transportType:ae.link_mode})),j({auths:z,session:ee})};this.events.once(T,m),this.events.once(g,_);let S;try{if(n){const $=Ht("wc_sessionAuthenticate",O,M);this.client.core.history.set(b,$);const x=await this.client.core.crypto.encode("",$,{type:Mr,encoding:Mt});S=Xr(r,b,x)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:O,expiry:i.expiry,throwOnFailedPublish:!0,clientRpcId:M}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:D,expiry:ge.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:D.id})])}catch($){throw this.events.off(T,m),this.events.off(g,_),$}return await this.setProposal(D.id,D),await this.setAuthRequest(M,{request:Te(re({},O),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:S??E,response:k}}),R(this,"approveSessionAuthenticate",async i=>{const{id:r,auths:s}=i,n=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:[Zt.authenticated_session_approve_started]}});try{this.isInitialized()}catch(w){throw n.setError(fr.no_internet_connection),w}const o=this.getPendingAuthRequest(r);if(!o)throw n.setError(fr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${r}`);const a=o.transportType||ae.relay;a===ae.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),h=ls(c),l={type:Ft,receiverPublicKey:c,senderPublicKey:u},d=[],f=[];for(const w of s){if(!await uc({cacao:w,projectId:this.client.core.projectId})){n.setError(fr.invalid_cacao);const P=te("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:r,topic:h,error:P,encodeOpts:l}),new Error(P.message)}n.addTrace(Zt.cacaos_verified);const{p:v}=w,b=hs(v.resources),E=[Gn(v.iss)],I=vs(v.iss);if(b){const P=hc(b),A=lc(b);d.push(...P),E.push(...A)}for(const P of E)f.push(`${P}:${I}`)}const p=await this.client.core.crypto.generateSharedKey(u,c);n.addTrace(Zt.create_authenticated_session_topic);let y;if((d==null?void 0:d.length)>0){y={topic:p,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:de(Oi),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Bc([...new Set(d)],[...new Set(f)]),transportType:a},n.addTrace(Zt.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:a})}catch(w){throw n.setError(fr.subscribe_authenticated_session_topic_failure),w}n.addTrace(Zt.subscribe_authenticated_session_topic_success),await this.client.session.set(p,y),n.addTrace(Zt.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Zt.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:r,result:{cacaos:s,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(w){throw n.setError(fr.authenticated_session_approve_publish_failure),w}return await this.client.auth.requests.delete(r,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:y}}),R(this,"rejectSessionAuthenticate",async i=>{this.isInitialized();const{id:r,reason:s}=i,n=this.getPendingAuthRequest(r);if(!n)throw new Error(`Could not find pending auth request with id ${r}`);n.transportType===ae.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ls(o),u={type:Ft,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:c,error:s,encodeOpts:u,rpcOpts:ge.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(r,{message:"rejected",code:0}),await this.client.proposal.delete(r,te("USER_DISCONNECTED"))}),R(this,"formatAuthMessage",i=>{this.isInitialized();const{request:r,iss:s}=i;return fl(r,s)}),R(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const i=this.relayMessageCache.shift();i&&await this.onRelayMessage(i)}catch(i){this.client.logger.error(i)}},50)}),R(this,"cleanupDuplicatePairings",async i=>{if(i.pairingTopic)try{const r=this.client.core.pairing.pairings.get(i.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===i.peer.metadata.url&&n.topic&&n.topic!==r.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(r){this.client.logger.error(r)}}),R(this,"deleteSession",async i=>{var r;const{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=i,{self:c}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,te("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(Au).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===s&&this.deletePendingSessionRequest(u.id,te("USER_DISCONNECTED"))}),s===((r=this.sessionRequestQueue.queue[0])==null?void 0:r.topic)&&(this.sessionRequestQueue.state=yt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})}),R(this,"deleteProposal",async(i,r)=>{if(r)try{const s=this.client.proposal.get(i),n=this.client.core.eventClient.getEvent({topic:s.pairingTopic});n==null||n.setError(Jt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(i,te("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(i)]),this.addToRecentlyDeleted(i,"proposal")}),R(this,"deletePendingSessionRequest",async(i,r,s=!1)=>
37{await Promise.all([this.client.pendingRequest.delete(i,r),s?Promise.resolve():this.client.core.expirer.del(i)]),this.addToRecentlyDeleted(i,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==i),s&&(this.sessionRequestQueue.state=yt.idle,this.client.events.emit("session_request_expire",{id:i}))}),R(this,"deletePendingAuthRequest",async(i,r,s=!1)=>{await Promise.all([this.client.auth.requests.delete(i,r),s?Promise.resolve():this.client.core.expirer.del(i)])}),R(this,"setExpiry",async(i,r)=>{this.client.session.keys.includes(i)&&(this.client.core.expirer.set(i,r),await this.client.session.update(i,{expiry:r}))}),R(this,"setProposal",async(i,r)=>{this.client.core.expirer.set(i,de(ge.wc_sessionPropose.req.ttl)),await this.client.proposal.set(i,r)}),R(this,"setAuthRequest",async(i,r)=>{const{request:s,pairingTopic:n,transportType:o=ae.relay}=r;this.client.core.expirer.set(i,s.expiryTimestamp),await this.client.auth.requests.set(i,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:i,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})}),R(this,"setPendingSessionRequest",async i=>{const{id:r,topic:s,params:n,verifyContext:o}=i,a=n.request.expiryTimestamp||de(ge.wc_sessionRequest.req.ttl);this.client.core.expirer.set(r,a),await this.client.pendingRequest.set(r,{id:r,topic:s,params:n,verifyContext:o})}),R(this,"sendRequest",async i=>{const{topic:r,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:u,appLink:h,tvf:l}=i,d=Ht(s,n,c);let f;const p=!!h;try{const v=p?Mt:ht;f=await this.client.core.crypto.encode(r,d,{encoding:v})}catch(v){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),v}let y;if(hD.includes(s)){const v=Et(JSON.stringify(d)),b=Et(f);y=await this.client.core.verify.register({id:b,decryptedId:v})}const w=ge[s].req;if(w.attestation=y,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(r,d),p){const v=Xr(h,r,f);await global.Linking.openURL(v,this.client.name)}else{const v=ge[s].req;o&&(v.ttl=o),a&&(v.id=a),v.tvf=Te(re({},l),{correlationId:d.id}),u?(v.internal=Te(re({},v.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,f,v)):this.client.core.relayer.publish(r,f,v).catch(b=>this.client.logger.error(b))}return d.id}),R(this,"sendResult",async i=>{const{id:r,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=i,u=zs(r,n);let h;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=l?Mt:ht;h=await this.client.core.crypto.encode(s,u,Te(re({},a||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),p}let d,f;try{d=await this.client.core.history.get(s,r);const p=d.request;try{this.shouldSetTVF(p.method,p.params)&&(f=this.getTVFParams(r,p.params,n))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(p){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${r}) failed`),p}if(l){const p=Xr(c,s,h);await global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,y=ge[p].res;y.tvf=Te(re({},f),{correlationId:r}),o?(y.internal=Te(re({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,h,y)):this.client.core.relayer.publish(s,h,y).catch(w=>this.client.logger.error(w))}await this.client.core.history.resolve(u)}),R(this,"sendError",async i=>{const{id:r,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=i,u=Hs(r,n);let h;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=l?Mt:ht;h=await this.client.core.crypto.encode(s,u,Te(re({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),f}let d;try{d=await this.client.core.history.get(s,r)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${s}, ${r}) failed`),f}if(l){const f=Xr(c,s,h);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,p=a||ge[f].res;this.client.core.relayer.publish(s,h,p)}await this.client.core.history.resolve(u)}),R(this,"cleanup",async()=>{const i=[],r=[];
vendor: 21,479 bytes, line 37
37this.client.session.getAll().forEach(s=>{let n=!1;kt(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&i.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{kt(s.expiryTimestamp)&&r.push(s.id)}),await Promise.all([...i.map(s=>this.deleteSession({topic:s})),...r.map(s=>this.deleteProposal(s))])}),R(this,"onProviderMessageEvent",async i=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(i):await this.onRelayMessage(i)}),R(this,"onRelayEventRequest",async i=>{this.requestQueue.queue.push(i),await this.processRequestsQueue()}),R(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===yt.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=yt.active;const i=this.requestQueue.queue.shift();if(i)try{await this.processRequest(i)}catch(r){this.client.logger.warn(r)}}this.requestQueue.state=yt.idle}),R(this,"processRequest",async i=>{const{topic:r,payload:s,attestation:n,transportType:o,encryptedId:a}=i,c=s.method;if(!this.shouldIgnorePairingRequest({topic:r,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:r,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(r,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(r,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(r,s);case"wc_sessionPing":return await this.onSessionPingRequest(r,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(r,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:r,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(r,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:r,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),R(this,"onRelayEventResponse",async i=>{const{topic:r,payload:s,transportType:n}=i,o=(await this.client.core.history.get(r,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(r,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(r,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(r,s);case"wc_sessionExtend":return this.onSessionExtendResponse(r,s);case"wc_sessionPing":return this.onSessionPingResponse(r,s);case"wc_sessionRequest":return this.onSessionRequestResponse(r,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(r,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),R(this,"onRelayEventUnknownPayload",i=>{const{topic:r}=i,{message:s}=F("MISSING_OR_INVALID",`Decoded payload on topic ${r} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),R(this,"shouldIgnorePairingRequest",i=>{const{topic:r,requestMethod:s}=i,n=this.expectedPairingMethodMap.get(r);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),R(this,"onSessionProposeRequest",async i=>{const{topic:r,payload:s,attestation:n,encryptedId:o}=i,{params:a,id:c}=s;try{const u=this.client.core.eventClient.getEvent({topic:r});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u==null||u.setError(Ct.proposal_listener_not_found)),this.isValidConnect(re({},s.params));const h=a.expiryTimestamp||de(ge.wc_sessionPropose.req.ttl),l=re({id:c,pairingTopic:r,expiryTimestamp:h},a);await this.setProposal(c,l);const d=await this.getVerifyContext({attestationId:n,hash:Et(JSON.stringify(s)),encryptedId:o,metadata:l.proposer.metadata});u==null||u.addTrace(mt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:d})}catch(u){await this.sendError({id:c,topic:r,error:u,rpcOpts:ge.wc_sessionPropose.autoReject}),this.client.logger.error(u)}}),R(this,"onSessionProposeResponse",async(i,r,s)=>{const{id:n}=r;if(bt(r)){const{result:o}=r;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const h=await this.client.core.crypto.generateSharedKey(c,u);this.pendingSessions.set(n,{sessionTopic:h,pairingTopic:i,proposalId:n,publicKey:c});const l=await this.client.core.relayer.subscribe(h,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:i})}else if(et(r)){await this.client.proposal.delete(n,te("USER_DISCONNECTED"));const o=X("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:r.error})}}),R(this,"onSessionSettleRequest",async(i,r)=>{const{id:s,params:n}=r;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:u,sessionProperties:h,scopedProperties:l,sessionConfig:d}=r.params,f=[...this.pendingSessions.values()].find(w=>w.sessionTopic===i);if(!f)return this.client.logger.error(`Pending session not found for topic ${i}`);const p=this.client.proposal.get(f.proposalId),y=Te(re(re(re({topic:i,relay:o,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},h&&{sessionProperties:h}),l&&{scopedProperties:l}),d&&{sessionConfig:d}),{transportType:ae.relay});await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit(X("session_connect",f.proposalId),{session:y}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(y),await this.sendResult({id:r.id,topic:i,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:i,error:o}),this.client.logger.error(o)}}),R(this,"onSessionSettleResponse",async(i,r)=>{const{id:s}=r;bt(r)?(await this.client.session.update(i,{acknowledged:!0}),this.events.emit(X("session_approve",s),{})):et(r)&&(await this.client.session.delete(i,te("USER_DISCONNECTED")),this.events.emit(X("session_approve",s),{error:r.error}))}),R(this,"onSessionUpdateRequest",async(i,r)=>{const{params:s,id:n}=r;try{const o=`${i}_session_update`,a=dr.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:i,error:te("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(re({topic:i},s));try{dr.set(o,n),await this.client.session.update(i,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:i,result:!0,throwOnFailedPublish:!0})}catch(c){throw dr.delete(o),c}this.client.events.emit("session_update",{id:n,topic:i,params:s})}catch(o){await this.sendError({id:n,topic:i,error:o}),this.client.logger.error(o)}}),R(this,"isRequestOutOfSync",(i,r)=>r.toString().slice(0,-3)<i.toString().slice(0,-3)),R(this,"onSessionUpdateResponse",(i,r)=>{const{id:s}=r,n=X("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(r)?this.events.emit(X("session_update",s),{}):et(r)&&this.events.emit(X("session_update",s),{error:r.error})}),R(this,"onSessionExtendRequest",async(i,r)=>{const{id:s}=r;try{this.isValidExtend({topic:i}),await this.setExpiry(i,de(Oi)),await this.sendResult({id:s,topic:i,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:i})}catch(n){await this.sendError({id:s,topic:i,error:n}),this.client.logger.error(n)}}),R(this,"onSessionExtendResponse",(i,r)=>{const{id:s}=r,n=X("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(r)?this.events.emit(X("session_extend",s),{}):et(r)&&this.events.emit(X("session_extend",s),{error:r.error})}),R(this,"onSessionPingRequest",async(i,r)=>{const{id:s}=r;try{this.isValidPing({topic:i}),await this.sendResult({id:s,topic:i,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:i})}catch(n){await this.sendError({id:s,topic:i,error:n}),this.client.logger.error(n)}}),R(this,"onSessionPingResponse",(i,r)=>{const{id:s}=r,n=X("session_ping",s);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);bt(r)?this.events.emit(X("session_ping",s),{}):et(r)&&this.events.emit(X("session_ping",s),{error:r.error})},500)}),R(this,"onSessionDeleteRequest",async(i,r)=>{const{id:s}=r;try{this.isValidDisconnect({topic:i,reason:r.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(we.publish,async()=>{n(await this.deleteSession({topic:i,id:s}))})}),this.sendResult({id:s,topic:i,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:i,error:te("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),R(this,"onSessionRequest",async i=>{var r,s,n;const{topic:o,payload:a,attestation:c,encryptedId:u,transportType:h}=i,{id:l,params:d}=a;try{await this.isValidRequest(re({topic:o},d));const f=this.client.session.get(o),p=await this.getVerifyContext({attestationId:c,hash:Et(JSON.stringify(Ht("wc_sessionRequest",d,l))),encryptedId:u,metadata:f.peer.metadata,transportType:h}),y={id:l,topic:o,params:d,verifyContext:p};await this.setPendingSessionRequest(y),h===ae.link_mode&&(r=f.peer.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp((s=f.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(f){await this.sendError({id:l,topic:o,error:f}),this.client.logger.error(f)}}),R(this,"onSessionRequestResponse",(i,r)=>{const{id:s}=r,n=X("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(r)?this.events.emit(X("session_request",s),{result:r.result}):et(r)&&this.events.emit(X("session_request",s),{error:r.error})}),R(this,"onSessionEventRequest",async(i,r)=>{const{id:s,params:n}=r;try{const o=`${i}_session_event_${n.event.name}`,a=dr.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(re({topic:i},n)),this.client.events.emit("session_event",{id:s,topic:i,params:n}),dr.set(o,s)}catch(o){await this.sendError({id:s,topic:i,error:o}),this.client.logger.error(o)}}),R(this,"onSessionAuthenticateResponse",(i,r)=>{const{id:s}=r;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:i,payload:r}),bt(r)?this.events.emit(X("session_request",s),{result:r.result}):et(r)&&this.events.emit(X("session_request",s),{error:r.error})}),R(this,"onSessionAuthenticateRequest",async i=>{var r;const{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=i;try{const{requester:u,authPayload:h,expiryTimestamp:l}=n.params,d=await this.getVerifyContext({attestationId:o,hash:Et(JSON.stringify(n)),encryptedId:a,metadata:u.metadata,transportType:c}),f={requester:u,pairingTopic:s,id:n.id,authPayload:h,verifyContext:d,expiryTimestamp:l};await this.setAuthRequest(n.id,{request:f,pairingTopic:s,transportType:c}),c===ae.link_mode&&(r=u.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:d})}catch(u){this.client.logger.error(u);const h=n.params.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:Ft,receiverPublicKey:h,senderPublicKey:l};await this.sendError({id:n.id,topic:s,error:u,encodeOpts:f,rpcOpts:ge.wc_sessionAuthenticate.autoReject,appLink:d})}}),R(this,"addSessionRequestToSessionRequestQueue",i=>{this.sessionRequestQueue.queue.push(i)}),R(this,"cleanupAfterResponse",i=>{this.deletePendingSessionRequest(i.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=yt.idle,this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay))}),R(this,"cleanupPendingSentRequestsForTopic",({topic:i,error:r})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===i&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=X("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(X("session_request",n.request.id),{error:r})})}),R(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===yt.active){this.client.logger.info("session request queue is already active.");return}const i=this.sessionRequestQueue.queue[0];if(!i){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=yt.active,this.emitSessionRequest(i)}catch(r){this.client.logger.error(r)}}),R(this,"emitSessionRequest",i=>{this.client.events.emit("session_request",i)}),R(this,"onPairingCreated",i=>{if(i.methods&&this.expectedPairingMethodMap.set(i.topic,i.methods),i.active)return;const r=this.client.proposal.getAll().find(s=>s.pairingTopic===i.topic);r&&this.onSessionProposeRequest({topic:i.topic,payload:Ht("wc_sessionPropose",Te(re({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces,relays:r.relays,proposer:r.proposer,sessionProperties:r.sessionProperties,scopedProperties:r.scopedProperties}),r.id)})}),R(this,"isValidConnect",async i=>{if(!Ue(i)){const{message:u}=F("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(i)}`);throw new Error(u)}const{pairingTopic:r,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:c}=i;if(De(r)||await this.isValidPairingTopic(r),!Kv(c,!0)){const{message:u}=F("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(u)}if(!De(s)&&Kt(s)!==0){const u="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(u):this.client.logger.warn(u),this.validateNamespaces(s,"requiredNamespaces")}if(!De(n)&&Kt(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),De(o)||this.validateSessionProps(o,"sessionProperties"),!De(a)){this.validateSessionProps(a,"scopedProperties");const u=Object.keys(s||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(h=>u.includes(h)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(u)}`)}}),R(this,"validateNamespaces",(i,r)=>{const s=Vv(i,"connect()",r);if(s)throw new Error(s.message)}),R(this,"isValidApprove",async i=>{if(!Ue(i))throw new Error(F("MISSING_OR_INVALID",`approve() params: ${i}`).message);const{id:r,namespaces:s,relayProtocol:n,sessionProperties:o,scopedProperties:a}=i;this.checkRecentlyDeleted(r),await this.isValidProposalId(r);const c=this.client.proposal.get(r),u=En(s,"approve()");if(u)throw new Error(u.message);const h=Lc(c.requiredNamespaces,s,"approve()");if(h)throw new Error(h.message);if(!le(n,!0)){const{message:l}=F("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(l)}if(De(o)||this.validateSessionProps(o,"sessionProperties"),!De(a)){this.validateSessionProps(a,"scopedProperties");const l=new Set(Object.keys(s));if(!Object.keys(a).every(d=>l.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(l).join(", ")}`)}}),R(this,"isValidReject",async i=>{if(!Ue(i)){const{message:n}=F("MISSING_OR_INVALID",`reject() params: ${i}`);throw new Error(n)}const{id:r,reason:s}=i;if(this.checkRecentlyDeleted(r),await this.isValidProposalId(r),!Gv(s)){const{message:n}=F("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}}),R(this,"isValidSessionSettleRequest",i=>{if(!Ue(i)){const{message:u}=F("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${i}`);throw new Error(u)}const{relay:r,controller:s,namespaces:n,expiry:o}=i;if(!ql(r)){const{message:u}=F("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const a=Lv(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=En(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(kt(o)){const{message:u}=F("EXPIRED","onSessionSettleRequest()");throw new Error(u)}}),R(this,"isValidUpdate",async i=>{if(!Ue(i)){const{message:c}=F("MISSING_OR_INVALID",`update() params: ${i}`);throw new Error(c)}const{topic:r,namespaces:s}=i;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const n=this.client.session.get(r),o=En(s,"update()");if(o)throw new Error(o.message);const a=Lc(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)}),R(this,"isValidExtend",async i=>{if(!Ue(i)){const{message:s}=F("MISSING_OR_INVALID",`extend() params: ${i}`);throw new Error(s)}const{topic:r}=i;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r)}),R(this,"isValidRequest",async i=>{if(!Ue(i)){const{message:c}=F("MISSING_OR_INVALID",`request() params: ${i}`);throw new Error(c)}const{topic:r,request:s,chainId:n,expiry:o}=i;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const{namespaces:a}=this.client.session.get(r);if(!Uc(a,n)){const{message:c}=F("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!Yv(s)){const{message:c}=F("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(c)}if(!Qv(a,n,s.method)){const{message:c}=F("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(c)}if(o&&!i1(o,xn)){const{message:c}=F("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${xn.min} and ${xn.max}`);throw new Error(c)}}),R(this,"isValidRespond",async i=>{var r;if(!Ue(i)){const{message:o}=F("MISSING_OR_INVALID",`respond() params: ${i}`);throw new Error(o)}const{topic:s,response:n}=i;try{await this.isValidSessionTopic(s)}catch(o){throw(r=i==null?void 0:i.response)!=null&&r.id&&this.cleanupAfterResponse(i),o}if(!Jv(n)){const{message:o}=F("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),R(this,"isValidPing",async i=>{if(!Ue(i)){const{message:s}=F("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:r}=i;await this.isValidSessionOrPairingTopic(r)}),R(this,"isValidEmit",async i=>{if(!Ue(i)){const{message:a}=F("MISSING_OR_INVALID",`emit() params: ${i}`);throw new Error(a)}const{topic:r,event:s,chainId:n}=i;await this.isValidSessionTopic(r);const{namespaces:o}=this.client.session.get(r);if(!Uc(o,n)){const{message:a}=F("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!Zv(s)){const{message:a}=F("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!Xv(o,n,s.name)){const{message:a}=F("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}}),R(this,"isValidDisconnect",async i=>{if(!Ue(i)){const{message:s}=F("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:r}=i;await this.isValidSessionOrPairingTopic(r)}),R(this,"isValidAuthenticate",i=>{const{chains:r,uri:s,domain:n,nonce:o}=i;if(!Array.isArray(r)||r.length===0)throw new Error("chains is required and must be a non-empty array");if(!le(s,!1))throw new Error("uri is required parameter");if(!le(n,!1))throw new Error("domain is required parameter");if(!le(o,!1))throw new Error("nonce is required parameter");if([...new Set(r.map(c=>Hi(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Hi(r[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),R(this,"getVerifyContext",async i=>{const{attestationId:r,hash:s,encryptedId:n,metadata:o,transportType:a}=i,c={verified:{verifyUrl:o.verifyUrl||Ir,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ae.link_mode){const h=this.getAppLinkIfEnabled(o,a);return c.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",c}const u=await this.client.core.verify.resolve({attestationId:r,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});u&&(c.verified.origin=u.origin,c.verified.isScam=u.isScam,c.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),R(this,"validateSessionProps",(i,r)=>
37{Object.values(i).forEach((s,n)=>{if(s==null){const{message:o}=F("MISSING_OR_INVALID",`${r} must contain an existing value for each key. Received: ${s} for key ${Object.keys(i)[n]}`);throw new Error(o)}})}),R(this,"getPendingAuthRequest",i=>{const r=this.client.auth.requests.get(i);return typeof r=="object"?r:void 0}),R(this,"addToRecentlyDeleted",(i,r)=>{if(this.recentlyDeletedMap.set(i,r),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}}),R(this,"checkRecentlyDeleted",i=>{const r=this.recentlyDeletedMap.get(i);if(r){const{message:s}=F("MISSING_OR_INVALID",`Record was recently deleted - ${r}: ${i}`);throw new Error(s)}}),R(this,"isLinkModeEnabled",(i,r)=>{var s,n,o,a,c,u,h,l,d;return!i||r!==ae.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:u.universal)!==""&&((h=i==null?void 0:i.redirect)==null?void 0:h.universal)!==void 0&&((l=i==null?void 0:i.redirect)==null?void 0:l.universal)!==""&&((d=i==null?void 0:i.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(i.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),R(this,"getAppLinkIfEnabled",(i,r)=>{var s;return this.isLinkModeEnabled(i,r)?(s=i==null?void 0:i.redirect)==null?void 0:s.universal:void 0}),R(this,"handleLinkModeMessage",({url:i})=>{if(!i||!i.includes("wc_ev")||!i.includes("topic"))return;const r=ec(i,"topic")||"",s=decodeURIComponent(ec(i,"wc_ev")||""),n=this.client.session.keys.includes(r);n&&this.client.session.update(r,{transportType:ae.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:s,sessionExists:n})}),R(this,"registerLinkModeListeners",async()=>{var i;if(jo()||Wt()&&(i=this.client.metadata.redirect)!=null&&i.linkMode){const r=global==null?void 0:global.Linking;if(typeof r<"u"){r.addEventListener("url",this.handleLinkModeMessage,this.client.name);const s=await r.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}),R(this,"shouldSetTVF",(i,r)=>{if(!r||i!=="wc_sessionRequest")return!1;const{request:s}=r;return Object.keys(Cu).includes(s.method)}),R(this,"getTVFParams",(i,r,s)=>{var n,o;try{const a=r.request.method,c=this.extractTxHashesFromResult(a,s);return Te(re({correlationId:i,rpcMethods:[a],chainId:r.chainId},this.isValidContractData(r.request.params)&&{contractAddresses:[(o=(n=r.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),R(this,"isValidContractData",i=>{var r;if(!i)return!1;try{const s=(i==null?void 0:i.data)||((r=i==null?void 0:i[0])==null?void 0:r.data);if(!s.startsWith("0x"))return!1;const n=s.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),R(this,"extractTxHashesFromResult",(i,r)=>{try{const s=Cu[i];if(typeof r=="string")return[r];const n=r[s.key];if(lt(n))return i==="solana_signAllTransactions"?n.map(o=>_b(o)):n;if(typeof n=="string")return[n]}catch(s){this.client.logger.warn("Error extracting tx hashes from result",s)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,i=this.client.core.relayer.messages.getWithoutAck(e);for(const[r,s]of Object.entries(i))for(const n of s)try{await this.onProviderMessageEvent({topic:r,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${r}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=F("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(we.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:i,message:r,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(gs)?this.client.auth.authKeys.get(gs):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(i,r,{receiverPublicKey:o,encoding:n===ae.link_mode?Mt:ht});Wo(a)?(this.client.core.history.set(i,a),await this.onRelayEventRequest({topic:i,payload:a,attestation:s,transportType:n,encryptedId:Et(r)})):Vs(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:i,payload:a,transportType:n}),this.client.core.history.delete(i,a.id)):await this.onRelayEventUnknownPayload({topic:i,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(i,r)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(Xe.expired,async e=>{const{topic:i,id:r}=nl(e.target);
vendor: 3,543 bytes, line 37
37if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,F("EXPIRED"),!0);if(r&&this.client.auth.requests.keys.includes(r))return await this.deletePendingAuthRequest(r,F("EXPIRED"),!0);i?this.client.session.keys.includes(i)&&(await this.deleteSession({topic:i,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:i})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))})}registerPairingEvents(){this.client.core.pairing.events.on(ii.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(ii.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!le(e,!1)){const{message:i}=F("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(i)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:i}=F("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(i)}if(kt(this.client.core.pairing.pairings.get(e).expiry)){const{message:i}=F("EXPIRED",`pairing topic: ${e}`);throw new Error(i)}}async isValidSessionTopic(e){if(!le(e,!1)){const{message:i}=F("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(i)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:i}=F("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(i)}if(kt(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:i}=F("EXPIRED",`session topic: ${e}`);throw new Error(i)}if(!this.client.core.crypto.keychain.has(e)){const{message:i}=F("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(i)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(le(e,!1)){const{message:i}=F("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(i)}else{const{message:i}=F("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(i)}}async isValidProposalId(e){if(!Wv(e)){const{message:i}=F("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(i)}if(!this.client.proposal.keys.includes(e)){const{message:i}=F("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(i)}if(kt(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:i}=F("EXPIRED",`proposal id: ${e}`);throw new Error(i)}}}class _D extends yi{constructor(e,i){super(e,i,oD,Go),this.core=e,this.logger=i}}let ID=class extends yi{constructor(e,i){super(e,i,aD,Go),this.core=e,this.logger=i}};class $D extends yi{constructor(e,i){super(e,i,uD,Go,r=>r.id),this.core=e,this.logger=i}}class DD extends yi{constructor(e,i){super(e,i,pD,Ws,()=>gs),this.core=e,this.logger=i}}class SD extends yi{constructor(e,i){super(e,i,fD,Ws),this.core=e,this.logger=i}}class OD extends yi{constructor(e,i){super(e,i,gD,Ws,r=>r.id),this.core=e,this.logger=i}}var PD=Object.defineProperty,AD=(t,e,i)=>e in t?PD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Cn=(t,e,i)=>AD(t,typeof e!="symbol"?e+"":e,i);class xD{constructor(e,i){this.core=e,this.logger=i,Cn(this,"authKeys"),Cn(this,"pairingTopics"),Cn(this,"requests"),this.authKeys=new DD(this.core,this.logger),this.pairingTopics=new SD(this.core,this.logger),this.requests=new OD(this.core,this.logger)}
37async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var CD=Object.defineProperty,TD=(t,e,i)=>e in t?CD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,W=(t,e,i)=>TD(t,typeof e!="symbol"?e+"":e,i);let RD=class md extends RE{constructor(e){super(e),W(this,"protocol",fd),W(this,"version",gd),W(this,"name",An.name),W(this,"metadata"),W(this,"core"),W(this,"logger"),W(this,"events",new it.EventEmitter),W(this,"engine"),W(this,"session"),W(this,"proposal"),W(this,"pendingRequest"),W(this,"auth"),W(this,"signConfig"),W(this,"on",(r,s)=>this.events.on(r,s)),W(this,"once",(r,s)=>this.events.once(r,s)),W(this,"off",(r,s)=>this.events.off(r,s)),W(this,"removeListener",(r,s)=>this.events.removeListener(r,s)),W(this,"removeAllListeners",r=>this.events.removeAllListeners(r)),W(this,"connect",async r=>{try{return await this.engine.connect(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"pair",async r=>{try{return await this.engine.pair(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"approve",async r=>{try{return await this.engine.approve(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"reject",async r=>{try{return await this.engine.reject(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"update",async r=>{try{return await this.engine.update(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"extend",async r=>{try{return await this.engine.extend(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"request",async r=>{try{return await this.engine.request(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"respond",async r=>{try{return await this.engine.respond(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"ping",async r=>{try{return await this.engine.ping(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"emit",async r=>{try{return await this.engine.emit(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"disconnect",async r=>{try{return await this.engine.disconnect(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"find",r=>{try{return this.engine.find(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(r){throw this.logger.error(r.message),r}}),W(this,"authenticate",async(r,s)=>{try{return await this.engine.authenticate(r,s)}catch(n){throw this.logger.error(n.message),n}}),W(this,"formatAuthMessage",r=>{try{return this.engine.formatAuthMessage(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"approveSessionAuthenticate",async r=>{try{return await this.engine.approveSessionAuthenticate(r)}catch(s){throw this.logger.error(s.message),s}}),W(this,"rejectSessionAuthenticate",async r=>{try{return await this.engine.rejectSessionAuthenticate(r)}catch(s){throw this.logger.error(s.message),s}}),this.name=(e==null?void 0:e.name)||An.name,this.metadata=Fw(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const i=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:zr(Ms({level:(e==null?void 0:e.logger)||An.logger}));this.core=(e==null?void 0:e.core)||new nD(e),this.logger=Ne(i,this.name),this.session=new ID(this.core,this.logger),this.proposal=new _D(this.core,this.logger),this.pendingRequest=new $D(this.core,this.logger),this.engine=new ED(this),this.auth=new xD(this.core,this.logger)}static async init(e){const i=new md(e);return await i.initialize(),i}get context(){return ke(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},N.toMiliseconds(N.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var Eo={exports:{}};(function(t,e){var i=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof vt<"u"&&vt,r=function(){function n(){this.fetch=!1,this.DOMException=i.DOMException}return n.prototype=i,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof vt<"u"&&vt||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function u(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array
37]"],l=ArrayBuffer.isView||function(g){return g&&h.indexOf(Object.prototype.toString.call(g))>-1};function d(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(g)||g==="")throw new TypeError('Invalid character in header field name: "'+g+'"');return g.toLowerCase()}function f(g){return typeof g!="string"&&(g=String(g)),g}function p(g){var m={next:function(){var _=g.shift();return{done:_===void 0,value:_}}};return c.iterable&&(m[Symbol.iterator]=function(){return m}),m}function y(g){this.map={},g instanceof y?g.forEach(function(m,_){this.append(_,m)},this):Array.isArray(g)?g.forEach(function(m){if(m.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+m.length);this.append(m[0],m[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(m){this.append(m,g[m])},this)}y.prototype.append=function(g,m){g=d(g),m=f(m);var _=this.map[g];this.map[g]=_?_+", "+m:m},y.prototype.delete=function(g){delete this.map[d(g)]},y.prototype.get=function(g){return g=d(g),this.has(g)?this.map[g]:null},y.prototype.has=function(g){return this.map.hasOwnProperty(d(g))},y.prototype.set=function(g,m){this.map[d(g)]=f(m)},y.prototype.forEach=function(g,m){for(var _ in this.map)this.map.hasOwnProperty(_)&&g.call(m,this.map[_],_,this)},y.prototype.keys=function(){var g=[];return this.forEach(function(m,_){g.push(_)}),p(g)},y.prototype.values=function(){var g=[];return this.forEach(function(m){g.push(m)}),p(g)},y.prototype.entries=function(){var g=[];return this.forEach(function(m,_){g.push([_,m])}),p(g)},c.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function w(g){if(!g._noBody){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}}function v(g){return new Promise(function(m,_){g.onload=function(){m(g.result)},g.onerror=function(){_(g.error)}})}function b(g){var m=new FileReader,_=v(m);return m.readAsArrayBuffer(g),_}function E(g){var m=new FileReader,_=v(m),S=/charset=([A-Za-z0-9_-]+)/.exec(g.type),$=S?S[1]:"utf-8";return m.readAsText(g,$),_}function I(g){for(var m=new Uint8Array(g),_=new Array(m.length),S=0;S<m.length;S++)_[S]=String.fromCharCode(m[S]);return _.join("")}function P(g){if(g.slice)return g.slice(0);var m=new Uint8Array(g.byteLength);return m.set(new Uint8Array(g)),m.buffer}function A(){return this.bodyUsed=!1,this._initBody=function(g){this.bodyUsed=this.bodyUsed,this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:c.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:c.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():c.arrayBuffer&&c.blob&&u(g)?(this._bodyArrayBuffer=P(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=P(g):this._bodyText=g=Object.prototype.toString.call(g):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof g=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var g=w(this);return g||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(b);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return E(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var O=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function C(g){var m=g.toUpperCase();return O.indexOf(m)>-1?m:g}function D(g,m){if(!(this instanceof D))throw new TypeError('Please use the "new" operator, this DOM object c
37onstructor cannot be called as a function.');m=m||{};var _=m.body;if(g instanceof D){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,m.headers||(this.headers=new y(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!_&&g._bodyInit!=null&&(_=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new y(m.headers)),this.method=C(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal||function(){if("AbortController"in a){var x=new AbortController;return x.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(_),(this.method==="GET"||this.method==="HEAD")&&(m.cache==="no-store"||m.cache==="no-cache")){var S=/([?&])_=[^&]*/;if(S.test(this.url))this.url=this.url.replace(S,"$1_="+new Date().getTime());else{var $=/\?/;this.url+=($.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}D.prototype.clone=function(){return new D(this,{body:this._bodyInit})};function k(g){var m=new FormData;return g.trim().split("&").forEach(function(_){if(_){var S=_.split("="),$=S.shift().replace(/\+/g," "),x=S.join("=").replace(/\+/g," ");m.append(decodeURIComponent($),decodeURIComponent(x))}}),m}function j(g){var m=new y,_=g.replace(/\r?\n[\t ]+/g," ");return _.split("\r").map(function(S){return S.indexOf(`
38`)===0?S.substr(1,S.length):S}).forEach(function(S){var $=S.split(":"),x=$.shift().trim();if(x){var U=$.join(":").trim();try{m.append(x,U)}catch(q){console.warn("Response "+q.message)}}}),m}A.call(D.prototype);function B(g,m){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=m.statusText===void 0?"":""+m.statusText,this.headers=new y(m.headers),this.url=m.url||"",this._initBody(g)}A.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var g=new B(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var M=[301,302,303,307,308];B.redirect=function(g,m){if(M.indexOf(m)===-1)throw new RangeError("Invalid status code");return new B(null,{status:m,headers:{location:g}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,_){this.message=m,this.name=_;var S=Error(m);this.stack=S.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function T(g,m){return new Promise(function(_,S){var $=new D(g,m);if($.signal&&$.signal.aborted)return S(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function U(){x.abort()}x.onload=function(){var L={statusText:x.statusText,headers:j(x.getAllResponseHeaders()||"")};$.url.indexOf("file://")===0&&(x.status<200||x.status>599)?L.status=200:L.status=x.status,L.url="responseURL"in x?x.responseURL:L.headers.get("X-Request-URL");var H="response"in x?x.response:x.responseText;setTimeout(function(){_(new B(H,L))},0)},x.onerror=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},x.ontimeout=function(){setTimeout(function(){S(new TypeError("Network request timed out"))},0)},x.onabort=function(){setTimeout(function(){S(new o.DOMException("Aborted","AbortError"))},0)};function q(L){try{return L===""&&a.location.href?a.location.href:L}catch{return L}}if(x.open($.method,q($.url),!0),$.credentials==="include"?x.withCredentials=!0:$.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&(c.blob?x.responseType="blob":c.arrayBuffer&&(x.responseType="arraybuffer")),m&&typeof m.headers=="object"&&!(m.headers instanceof y||a.Headers&&m.headers instanceof a.Headers)){var z=[];
38Object.getOwnPropertyNames(m.headers).forEach(function(L){z.push(d(L)),x.setRequestHeader(L,f(m.headers[L]))}),$.headers.forEach(function(L,H){z.indexOf(H)===-1&&x.setRequestHeader(H,L)})}else $.headers.forEach(function(L,H){x.setRequestHeader(H,L)});$.signal&&($.signal.addEventListener("abort",U),x.onreadystatechange=function(){x.readyState===4&&$.signal.removeEventListener("abort",U)}),x.send(typeof $._bodyInit>"u"?null:$._bodyInit)})}return T.polyfill=!0,a.fetch||(a.fetch=T,a.Headers=y,a.Request=D,a.Response=B),o.Headers=y,o.Request=D,o.Response=B,o.fetch=T,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var s=i.fetch?i:r;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e})(Eo,Eo.exports);var ND=Eo.exports;const Ru=sh(ND);var FD=Object.defineProperty,BD=Object.defineProperties,jD=Object.getOwnPropertyDescriptors,Nu=Object.getOwnPropertySymbols,UD=Object.prototype.hasOwnProperty,LD=Object.prototype.propertyIsEnumerable,Fu=(t,e,i)=>e in t?FD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Bu=(t,e)=>{for(var i in e||(e={}))UD.call(e,i)&&Fu(t,i,e[i]);if(Nu)for(var i of Nu(e))LD.call(e,i)&&Fu(t,i,e[i]);return t},ju=(t,e)=>BD(t,jD(e));const qD={Accept:"application/json","Content-Type":"application/json"},kD="POST",Uu={headers:qD,method:kD},Lu=10;let dt=class{constructor(e,i=!1){if(this.url=e,this.disableProviderPing=i,this.events=new it.EventEmitter,this.isAvailable=!1,this.registering=!1,!tu(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=i}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,i){this.events.on(e,i)}
vendor: 4,787 bytes, line 38
38once(e,i){this.events.once(e,i)}off(e,i){this.events.off(e,i)}removeListener(e,i){this.events.removeListener(e,i)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const i=Bt(e),r=await(await Ru(this.url,ju(Bu({},Uu),{body:i}))).json();this.onPayload({data:r})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!tu(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((r,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));r()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const i=Bt({id:1,jsonrpc:"2.0",method:"test",params:[]});await Ru(e,ju(Bu({},Uu),{body:i}))}this.onOpen()}catch(i){const r=this.parseError(i);throw this.events.emit("register_error",r),this.onClose(),r}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const i=typeof e.data=="string"?ui(e.data):e.data;this.events.emit("payload",i)}onError(e,i){const r=this.parseError(i),s=r.message||r.toString(),n=Hs(e,s);this.events.emit("payload",n)}parseError(e,i=this.url){return Wl(e,i,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Lu&&this.events.setMaxListeners(Lu)}};const qu="error",MD="wss://relay.walletconnect.org",zD="wc",HD="universal_provider",ss=`${zD}@2:${HD}:`,wd="https://rpc.walletconnect.org/v1/",qi="generic",VD=`${wd}bundler`,st={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function KD(){}function Yo(t){return t==null||typeof t!="object"&&typeof t!="function"}function Jo(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function WD(t){if(Yo(t))return t;if(Array.isArray(t)||Jo(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),i=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new i(t);if(t instanceof RegExp){const r=new i(t);return r.lastIndex=t.lastIndex,r}if(t instanceof DataView)return new i(t.buffer.slice(0));if(t instanceof Error){const r=new i(t.message);return r.stack=t.stack,r.name=t.name,r.cause=t.cause,r}if(typeof File<"u"&&t instanceof File)return new i([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const r=Object.create(e);return Object.assign(r,t)}return t}function ku(t){return typeof t=="object"&&t!==null}function bd(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function vd(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const GD="[object RegExp]",Ed="[object String]",_d="[object Number]",Id="[object Boolean]",$d="[object Arguments]",YD="[object Symbol]",JD="[object Date]",ZD="[object Map]",QD="[object Set]",XD="[object Array]",eS="[object ArrayBuffer]",tS="[object Object]",iS="[object DataView]",rS="[object Uint8Array]",sS="[object Uint8ClampedArray]",nS="[object Uint16Array]",oS="[object Uint32Array]",aS="[object Int8Array]",cS="[object Int16Array]",uS="[object Int32Array]",hS="[object Float32Array]",lS="[object Float64Array]";function dS(t,e){return zi(t,void 0,t,new Map,e)}function zi(t,e,i,r=new Map,s=void 0){const n=s==null?void 0:s(t,e,i,r);if(n!=null)return n;if(Yo(t))return t;if(r.has(t))return r.get(t);if(Array.isArray(t)){const o=new Array(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=zi(t[a],a,i,r,s);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;r.set(t,o);for(const[a,c]of t)o.set(a,zi(c,a,i,r,s));return o}if(t instanceof Set){const o=new Set;r.set(t,o);for(const a of t)o.add(zi(a,void 0,i,r,s));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(Jo(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=zi(t[a],a,i,r,s);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);
38return r.set(t,o),ri(o,t,i,r,s),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return r.set(t,o),ri(o,t,i,r,s),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return r.set(t,o),ri(o,t,i,r,s),o}if(t instanceof Error){const o=new t.constructor;return r.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,ri(o,t,i,r,s),o}if(typeof t=="object"&&pS(t)){const o=Object.create(Object.getPrototypeOf(t));return r.set(t,o),ri(o,t,i,r,s),o}return t}function ri(t,e,i=t,r,s){const n=[...Object.keys(e),...bd(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=zi(e[a],a,i,r,s))}}function pS(t){switch(vd(t)){case $d:case XD:case eS:case iS:case Id:case JD:case hS:case lS:case aS:case cS:case uS:case ZD:case _d:case tS:case GD:case QD:case Ed:case YD:case rS:case sS:case nS:case oS:return!0;default:return!1}}function fS(t,e){return dS(t,(i,r,s,n)=>{const o=e==null?void 0:e(i,r,s,n);if(o!=null)return o;if(typeof t=="object")switch(Object.prototype.toString.call(t)){case _d:case Ed:case Id:{const a=new t.constructor(t==null?void 0:t.valueOf());return ri(a,t),a}case $d:{const a={};return ri(a,t),a.length=t.length,a[Symbol.iterator]=t[Symbol.iterator],a}default:return}})}function Mu(t){return fS(t)}function zu(t){return t!==null&&typeof t=="object"&&vd(t)==="[object Arguments]"}function gS(t){return Jo(t)}function yS(t){var i;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!((i=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&i.writable)?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function mS(t,...e){const i=e.slice(0,-1),r=e[e.length-1];let s=t;for(let n=0;n<i.length;n++){const o=i[n];s=_o(s,o,r,new Map)}return s}function _o(t,e,i,r){if(Yo(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(r.has(e))return WD(r.get(e));if(r.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const s=[...Object.keys(e),...bd(e)];for(let n=0;n<s.length;n++){const o=s[n];let a=e[o],c=t[o];if(zu(a)&&(a={...a}),zu(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Mu(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const h=[],l=Reflect.ownKeys(c);for(let d=0;d<l.length;d++){const f=l[d];h[f]=c[f]}c=h}else c=[];const u=i(c,a,o,t,e,r);u!=null?t[o]=u:Array.isArray(a)||ku(c)&&ku(a)?t[o]=_o(c,a,i,r):c==null&&yS(a)?t[o]=_o({},a,i,r):c==null&&gS(a)?t[o]=Mu(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function wS(t,...e){return mS(t,...e,KD)}var bS=Object.defineProperty,vS=Object.defineProperties,ES=Object.getOwnPropertyDescriptors,Hu=Object.getOwnPropertySymbols,_S=Object.prototype.hasOwnProperty,IS=Object.prototype.propertyIsEnumerable,Vu=(t,e,i)=>e in t?bS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ns=(t,e)=>{for(var i in e||(e={}))_S.call(e,i)&&Vu(t,i,e[i]);if(Hu)for(var i of Hu(e))IS.call(e,i)&&Vu(t,i,e[i]);return t},$S=(t,e)=>vS(t,ES(e));function Ge(t,e,i){var r;const s=Hi(t);return((r=e.rpcMap)==null?void 0:r[s.reference])||`${wd}?chainId=${s.namespace}:${s.reference}&projectId=${i}`}function mi(t){return t.includes(":")?t.split(":")[1]:t}function Dd(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function DS(t,e){const i=Object.keys(e.namespaces).filter(s=>s.includes(t));if(!i.length)return[];const r=[];return i.forEach(s=>{const n=e.namespaces[s].accounts;r.push(...n)}),r}function os(t={},e={}){const i=Ku(t),r=Ku(e);return wS(i,r)}function Ku(t){var e,i,r,s,n;const o={};if(!Kt(t))return o;for(const[a,c]of Object.entries(t)){const u=qs(a)?[a]:c.chains,h=c.methods||[],l=c.events||[],d=c.rpcMap||{},f=Mi(a);o[f]=$S(ns(ns({},o[f]),c),{chains:_t(u,(e=o[f])==null?void 0:e.chains),methods:_t(h,(i=o[f])==null?void 0:i.methods),events:_t(l,(r=o[f])==null?void 0:r.events)}),(Kt(d)||Kt(((s=o[f])==null?void 0:s.rpcMap)||{}))&&(o[f].rpcMap=ns(ns({},d),(n=o[f])==null?void 0:n.rpcMap))}return o}function Wu(t){return t.includes(":")?t.split(":")[2]:t}function Gu(t){const e={};for(const[i,r]of Object.entries(t)){const s=r.methods||[],n=r.events||[],o=r.accounts||[],a=qs(i)?[i]:r.chains?r.chains:Dd(r.accounts);e[i]={chains:a,methods:s,events:n,accounts:o}}return e}function Tn(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Sd={},Q=t=>Sd[t],Rn=(t,e)=>{Sd[t]=e};
38var SS=Object.defineProperty,OS=(t,e,i)=>e in t?SS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pi=(t,e,i)=>OS(t,typeof e!="symbol"?e+"":e,i);class PS{constructor(e){Pi(this,"name","polkadot"),Pi(this,"client"),Pi(this,"httpProviders"),Pi(this,"events"),Pi(this,"namespace"),Pi(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;const s=mi(i);e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var AS=Object.defineProperty,xS=Object.defineProperties,CS=Object.getOwnPropertyDescriptors,Yu=Object.getOwnPropertySymbols,TS=Object.prototype.hasOwnProperty,RS=Object.prototype.propertyIsEnumerable,Io=(t,e,i)=>e in t?AS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ju=(t,e)=>{for(var i in e||(e={}))TS.call(e,i)&&Io(t,i,e[i]);if(Yu)for(var i of Yu(e))RS.call(e,i)&&Io(t,i,e[i]);return t},Zu=(t,e)=>xS(t,CS(e)),Ai=(t,e,i)=>Io(t,typeof e!="symbol"?e+"":e,i);class NS{constructor(e){Ai(this,"name","eip155"),Ai(this,"client"),Ai(this,"chainId"),Ai(this,"namespace"),Ai(this,"httpProviders"),Ai(this,"events"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(parseInt(e),i),this.chainId=parseInt(e),this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,i){const r=i||Ge(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;const s=parseInt(mi(i));e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}async handleSwitchChain(e){var i,r;let s=e.request.params?(i=e.request.params[0])==null?void 0:i.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const n=parseInt(s,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(r=this.namespace.chains)==null?void 0:r[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var i,r,s,n,o;const a=(r=(i=e.request)==null?void 0:i.params)==null?void 0:r[0],c=((n=(s=e.request)==null?void 0:s.params)==null?void 0:n[1])||[],u=`${a}${c.join(",")}`;if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(e.topic),l=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(l!=null&&l[u])return l==null?void 0:l[u];const d=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Zu(Ju({},h.sessionProperties||{}),{capabilities:Zu(Ju({},l||{}),{[u]:d})})})}catch(f){console.warn("Failed to update session with capabilities",f)}return d}async getCallStatus(e){var i,r;const s=this.client.session.get(e.topic),n=(i=s.sessionProperties)==null?void 0:i.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(r=s.sessionProperties)==null?void 0:r.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,i){var r;const s=new URL(e),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ht("eth_getUserOperationReceipt",[(r=i.request.params)==null?void 0:r[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}
38getBundlerUrl(e,i){return`${VD}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${i}`}}var FS=Object.defineProperty,BS=(t,e,i)=>e in t?FS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xi=(t,e,i)=>BS(t,typeof e!="symbol"?e+"":e,i);class jS{constructor(e){xi(this,"name","solana"),xi(this,"client"),xi(this,"httpProviders"),xi(this,"events"),xi(this,"namespace"),xi(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;const s=mi(i);e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var US=Object.defineProperty,LS=(t,e,i)=>e in t?US(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ci=(t,e,i)=>LS(t,typeof e!="symbol"?e+"":e,i);class qS{constructor(e){Ci(this,"name","cosmos"),Ci(this,"client"),Ci(this,"httpProviders"),Ci(this,"events"),Ci(this,"namespace"),Ci(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;const s=mi(i);e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var kS=Object.defineProperty,MS=(t,e,i)=>e in t?kS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ti=(t,e,i)=>MS(t,typeof e!="symbol"?e+"":e,i);class zS{constructor(e){Ti(this,"name","algorand"),Ti(this,"client"),Ti(this,"httpProviders"),Ti(this,"events"),Ti(this,"namespace"),Ti(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){if(!this.httpProviders[e]){const r=i||Ge(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>
38{var r;e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new rt(new dt(r,Q("disableProviderPing")))}}var HS=Object.defineProperty,VS=(t,e,i)=>e in t?HS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ri=(t,e,i)=>VS(t,typeof e!="symbol"?e+"":e,i);class KS{constructor(e){Ri(this,"name","cip34"),Ri(this,"client"),Ri(this,"httpProviders"),Ri(this,"events"),Ri(this,"namespace"),Ri(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{const r=this.getCardanoRPCUrl(i),s=mi(i);e[s]=this.createHttpProvider(s,r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}getCardanoRPCUrl(e){const i=this.namespace.rpcMap;if(i)return i[e]}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var WS=Object.defineProperty,GS=(t,e,i)=>e in t?WS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ni=(t,e,i)=>GS(t,typeof e!="symbol"?e+"":e,i);class YS{constructor(e){Ni(this,"name","elrond"),Ni(this,"client"),Ni(this,"httpProviders"),Ni(this,"events"),Ni(this,"namespace"),Ni(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;const s=mi(i);e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var JS=Object.defineProperty,ZS=(t,e,i)=>e in t?JS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fi=(t,e,i)=>ZS(t,typeof e!="symbol"?e+"":e,i);class QS{constructor(e){Fi(this,"name","multiversx"),Fi(this,"client"),Fi(this,"httpProviders"),Fi(this,"events"),Fi(this,"namespace"),Fi(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>
38{var r;const s=mi(i);e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var XS=Object.defineProperty,eO=(t,e,i)=>e in t?XS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Bi=(t,e,i)=>eO(t,typeof e!="symbol"?e+"":e,i);class tO{constructor(e){Bi(this,"name","near"),Bi(this,"client"),Bi(this,"httpProviders"),Bi(this,"events"),Bi(this,"namespace"),Bi(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){if(this.chainId=e,!this.httpProviders[e]){const r=i||Ge(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{var r;e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[i])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace);return typeof r>"u"?void 0:new rt(new dt(r,Q("disableProviderPing")))}}var iO=Object.defineProperty,rO=(t,e,i)=>e in t?iO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ji=(t,e,i)=>rO(t,typeof e!="symbol"?e+"":e,i);class sO{constructor(e){ji(this,"name","tezos"),ji(this,"client"),ji(this,"httpProviders"),ji(this,"events"),ji(this,"namespace"),ji(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,i){if(this.chainId=e,!this.httpProviders[e]){const r=i||Ge(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(i=>{e[i]=this.createHttpProvider(i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace);return typeof r>"u"?void 0:new rt(new dt(r))}}var nO=Object.defineProperty,oO=(t,e,i)=>e in t?nO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ui=(t,e,i)=>oO(t,typeof e!="symbol"?e+"":e,i);class aO{constructor(e){Ui(this,"name",qi),Ui(this,"client"),Ui(this,"httpProviders"),Ui(this,"events"),Ui(this,"namespace"),Ui(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,i){this.httpProviders[e]||this.setHttpProvider(e,i),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){var e,i;const r={};return(i=(e=this.namespace)==null?void 0:e.accounts)==null||i.forEac
38h(s=>{const n=Hi(s);r[`${n.namespace}:${n.reference}`]=this.createHttpProvider(s)}),r}getHttpProvider(e){const i=this.httpProviders[e];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,i){const r=this.createHttpProvider(e,i);r&&(this.httpProviders[e]=r)}createHttpProvider(e,i){const r=i||Ge(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new rt(new dt(r,Q("disableProviderPing")))}}var cO=Object.defineProperty,uO=Object.defineProperties,hO=Object.getOwnPropertyDescriptors,Qu=Object.getOwnPropertySymbols,lO=Object.prototype.hasOwnProperty,dO=Object.prototype.propertyIsEnumerable,$o=(t,e,i)=>e in t?cO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,as=(t,e)=>{for(var i in e||(e={}))lO.call(e,i)&&$o(t,i,e[i]);if(Qu)for(var i of Qu(e))dO.call(e,i)&&$o(t,i,e[i]);return t},Nn=(t,e)=>uO(t,hO(e)),Qe=(t,e,i)=>$o(t,typeof e!="symbol"?e+"":e,i);let pO=class Od{constructor(e){Qe(this,"client"),Qe(this,"namespaces"),Qe(this,"optionalNamespaces"),Qe(this,"sessionProperties"),Qe(this,"scopedProperties"),Qe(this,"events",new So),Qe(this,"rpcProviders",{}),Qe(this,"session"),Qe(this,"providerOpts"),Qe(this,"logger"),Qe(this,"uri"),Qe(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:zr(Ms({level:(e==null?void 0:e.logger)||qu})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const i=new Od(e);return await i.initialize(),i}async request(e,i,r){const[s,n]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:as({},e),chainId:`${s}:${n}`,topic:this.session.topic,expiry:r})}sendAsync(e,i,r,s){const n=new Date().getTime();this.request(e,r,s).then(o=>i(null,zs(n,o))).catch(o=>i(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:te("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,i){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:r,response:s}=await this.client.authenticate(e,i);r&&(this.uri=r,this.events.emit("display_uri",r));const n=await s();if(this.session=n.session,this.session){const o=Gu(this.session.namespaces);this.namespaces=os(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,i){this.events.on(e,i)}
vendor: 5,189 bytes, line 38
38once(e,i){this.events.once(e,i)}removeListener(e,i){this.events.removeListener(e,i)}off(e,i){this.events.off(e,i)}get isWalletConnect(){return!0}async pair(e){const{uri:i,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});i&&(this.uri=i,this.events.emit("display_uri",i));const s=await r();this.session=s;const n=Gu(s.namespaces);return this.namespaces=os(this.namespaces,n),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,i){try{if(!this.session)return;const[r,s]=this.validateChain(e),n=this.getProvider(r);n.name===qi?n.setDefaultChain(`${r}:${s}`,i):n.setDefaultChain(s,i)}catch(r){if(!/Please call connect/.test(r.message))throw r}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(lt(i)){for(const r of i)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,i;if(this.client=this.providerOpts.client||await RD.init({core:this.providerOpts.core,logger:this.providerOpts.logger||qu,relayUrl:this.providerOpts.relayUrl||MD,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),new Error(`The provided session: ${(i=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:i.topic} doesn't exist in the Sign client`)}else{const r=this.client.session.getAll();this.session=r[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(i=>Mi(i)))];Rn("client",this.client),Rn("events",this.events),Rn("disableProviderPing",this.disableProviderPing),e.forEach(i=>{if(!this.session)return;const r=DS(i,this.session),s=Dd(r),n=os(this.namespaces,this.optionalNamespaces),o=Nn(as({},n[i]),{accounts:r,chains:s});switch(i){case"eip155":this.rpcProviders[i]=new NS({namespace:o});break;case"algorand":this.rpcProviders[i]=new zS({namespace:o});break;case"solana":this.rpcProviders[i]=new jS({namespace:o});break;case"cosmos":this.rpcProviders[i]=new qS({namespace:o});break;case"polkadot":this.rpcProviders[i]=new PS({namespace:o});break;case"cip34":this.rpcProviders[i]=new KS({namespace:o});break;case"elrond":this.rpcProviders[i]=new YS({namespace:o});break;case"multiversx":this.rpcProviders[i]=new QS({namespace:o});break;case"near":this.rpcProviders[i]=new tO({namespace:o});break;case"tezos":this.rpcProviders[i]=new sO({namespace:o});break;default:this.rpcProviders[qi]?this.rpcProviders[qi].updateNamespace(o):this.rpcProviders[qi]=new aO({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var i;const{topic:r}=e;r===((i=this.session)==null?void 0:i.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var i;const{params:r,topic:s}=e;if(s!==((i=this.session)==null?void 0:i.topic))return;const{event:n}=r;if(n.name==="accountsChanged"){const o=n.data;o&&lt(o)&&this.events.emit("accountsChanged",o.map(Wu))}else if(n.name==="chainChanged"){const o=r.chainId,a=r.event.data,c=Mi(o),u=Tn(o)!==Tn(a)?`${c}:${Tn(a)}`:o;this.onChainChanged(u)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:i})=>{var r,s;if(e!==((r=this.session)==null?void 0:r.topic))return;const{namespaces:n}=i,o=(s=this.client)==null?void 0:s.session.get(e);this.session=Nn(as({},o),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:i})}),this.client.on("session_delete",async e=>{var i;e.topic===((i=this.session)==null?void 0:i.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Nn(as({},te("USER_DISCONNECTED")),{data:e.topic})))}),this.on(st.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[qi]}
38onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var i;this.getProvider(e).updateNamespace((i=this.session)==null?void 0:i.namespaces[e])})}setNamespaces(e){const{namespaces:i={},optionalNamespaces:r={},sessionProperties:s,scopedProperties:n}=e;this.optionalNamespaces=os(i,r),this.sessionProperties=s,this.scopedProperties=n}validateChain(e){const[i,r]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[i,r];if(i&&!Object.keys(this.namespaces||{}).map(o=>Mi(o)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&r)return[i,r];const s=Mi(Object.keys(this.namespaces)[0]),n=this.rpcProviders[s].getDefaultChain();return[s,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,i=!1){if(!this.namespaces)return;const[r,s]=this.validateChain(e);if(!s)return;this.updateNamespaceChain(r,s),this.events.emit("chainChanged",s);const n=this.getProvider(r).getDefaultChain();i||this.getProvider(r).setDefaultChain(s),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:n,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:i,newChainId:r}){var s,n;try{if(i===r)return;const o=(n=(s=this.session)==null?void 0:s.namespaces[e])==null?void 0:n.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${r}:`)).map(Wu);if(!lt(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,i){if(!this.namespaces)return;const r=this.namespaces[e]?e:`${e}:${i}`,s={chains:[],methods:[],events:[],defaultChain:i};this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=i):this.namespaces[r]=s}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,i){var r;const s=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.setItem(`${ss}/${e}${s}`,i)}async getFromStore(e){var i;const r=((i=this.session)==null?void 0:i.topic)||"";return await this.client.core.storage.getItem(`${ss}/${e}${r}`)}async deleteFromStore(e){var i;const r=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.removeItem(`${ss}/${e}${r}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const i=await this.client.core.storage.getKeys();for(const r of i)r.startsWith(ss)&&await this.client.core.storage.removeItem(r)}catch(i){this.logger.warn("Failed to cleanup storage",i)}}};const fO=pO,gO="wc",yO="ethereum_provider",mO=`${gO}@2:${yO}:`,wO="https://rpc.walletconnect.org/v1/",Ss=["eth_sendTransaction","personal_sign"],Pd=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Os=["chainChanged","accountsChanged"],Ad=["chainChanged","accountsChanged","message","disconnect","connect"],bO=async()=>{const{createAppKit:t}=await rh(()=>import("./core-2270e6fb.js").then(e=>e.X),["assets/core-2270e6fb.js","assets/index-ed92e2ed.js","assets/index-4840a3af.css","assets/events-1708fc8d.js","assets/index-accd8060.js"]);return t};var vO=Object.defineProperty,EO=Object.defineProperties,_O=Object.getOwnPropertyDescriptors,Xu=Object.getOwnPropertySymbols,IO=Object.prototype.hasOwnProperty,$O=Object.prototype.propertyIsEnumerable,Do=(t,e,i)=>e in t?vO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Xt=(t,e)=>{for(var i in e||(e={}))IO.call(e,i)&&Do(t,i,e[i]);if(Xu)for(var i of Xu(e))$O.call(e,i)&&Do(t,i,e[i]);return t},mr=(t,e)=>EO(t,_O(e)),ze=(t,e,i)=>Do(t,typeof e!="symbol"?e+"":e,i);function Ps(t){return Number(t[0].split(":")[1])}function cs(t){return`0x${t.toString(16)}`}function DO(t){const{chains:e,optionalChains:i,methods:r,optionalMethods:s,events:n,optionalEvents:o,rpcMap:a}=t;if(!lt(e))throw new Error("Invalid chains");const c={chains:e,methods:r||Ss,events:n||Os,rpcMap:Xt({},e.length?{[Ps(e)]:a[Ps(e)]}:{})},u=n==null?void 0:n.filter(f=>!Os.includes(f)),h=r==null?void 0:r.filter(f=>!Ss.includes(f));if(!i&&!o&&!s&&!(u!=null&&u.length)&&!(h!=null&&h.length))return{required:e.length?c:void 0};const l=(u==null?void 0:u.length)&&(h==null?void 0:h.length)||!i,d={chains:[...new Set(l?c.chains.concat(i||[]):i)],methods:[...new Set(c.methods.concat(s!=null&&s.length?s:Pd))],events:[...new Set(c.events.concat(o!=null&&o.length?o:Ad))],rpcMap:a};return{required:e.length?c:void 0,optional:i.length?d:void 0}}class Gs{constructor(){ze(this,"events",new it.EventEmitter),ze(this,"namespace","eip155"),ze(this,"accounts",[]),ze(this,"signer"),ze(this,"chainId",1),ze(this,"modal"),ze(this,"rpc"),ze(this,"STORAGE_KEY",mO),ze(this,"on",(e,i)=>(this.events.on(e,i),this)),ze(this,"once",(e,i)=>(this.events.once(e,i),this)),ze(this,"removeListener",(e,i)=>(this.events.removeListener(e,i),this)),ze(this,"off",(e,i)=>(this.events.off(e,i),this)),ze(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const i=new Gs;return await i.initialize(e),i}async request(e,i){return await this.signer.request(e,this.formatChainId(this.chainId),i)}sendAsync(e,i,r){this.signer.sendAsync(e,i,this.formatChainId(this.chainId),r)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){var i;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:s}=DO(this.rpc);try{const n=await new Promise(async(a,c)=>{var u,h;this.rpc.showQrModal&&((u=this.modal)==null||u.open(),(h=this.modal)==null||h.subscribeState(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const l=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(mr(Xt({namespaces:Xt({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:e==null?void 0:e.pairingTopic,scopedProperties:l})).then(d=>{a(d)}).catch(d=>{var f;(f=this.modal)==null||f.showErrorMessage("Unable to connect"),c(new Error(d.message))})});if(!n)return;const o=Ya(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cs(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{(i=this.modal)==null||i.close()}}async authenticate(e,i){var r;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const s=await new Promise(async(o,a)=>{var c,u;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(u=this.modal)==null||u.subscribeState(h=>{!h.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(mr(Xt({},e),{chains:this.rpc.chains}),i).then(h=>{o(h)}).catch(h=>{var l;(l=this.modal)==null||l.showErrorMessage("Unable to connect"),a(new Error(h.message))})}),n=s.session;if(n){const o=Ya(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cs(this.chainId)})}return s}catch(s){throw this.signer.logger.error(s),s}finally{(r=this.modal)==null||r.close()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:i}=e,{event:r}=i;r.name==="accountsChanged"?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const i=parseInt(e);this.chainId=i,this.events.emit("chainChanged",cs(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",mr(Xt({},te("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const i=e.filter(r=>this.isCompatibleChainId(r)).map(r=>this.parseChainId(r));i.length&&(this.chainId=i[0],this.events.emit("chainChanged",cs(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const i=this.parseChainId(e);this.chainId=i,this.switchEthereumChain(i)}}parseAccountId(e){const[i,r,s]=e.split(":");return{chainId:`${i}:${r}`,address:s}}setAccounts(e){this.accounts=e.filter(i=>this.parseChainId(this.parseAccountId(i).chainId)===this.chainId).map(i=>this.parseAccountId(i).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var i,r;const s=(i=e==null?void 0:e.chains)!=null?i:[],n=(r=e==null?void 0:e.optionalChains)!=null?r:[],o=s.concat(n);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=s.length?(e==null?void 0:e.methods)||Ss:[],c=s.length?(e==null?void 0:e.events)||Os:[],u=(e==null?void 0:e.optionalMethods)||[],h=(e==null?void 0:e.optionalEvents)||[],l=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),d=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(f=>this.formatChainId(f)),optionalChains:n.map(f=>this.formatChainId(f)),methods:a,events:c,optionalMethods:u,optionalEvents:h,rpcMap:l,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,i){const r={};return e.forEach(s=>{r[s]=this.getRpcUrl(s,i)}),r}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Ps(this.rpc.chains):Ps(this.rpc.optionalChains),this.signer=await fO.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;
38try{const r=await bO(),{convertWCMToAppKitOptions:s}=await Promise.resolve().then(function(){return BO}),n=s(mr(Xt({},this.rpc.qrModalOptions),{chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId}));if(!n.networks.length)throw new Error("No networks found for WalletConnect·");i=r(mr(Xt({},n),{universalProvider:this.signer,manualWCControl:!0}))}catch(r){throw console.warn(r),new Error("To use QR modal, please install @reown/appkit package")}if(i)try{this.modal=i}catch(r){throw this.signer.logger.error(r),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:i,optionalChains:r,rpcMap:s}=e;i&&lt(i)&&(this.rpc.chains=i.map(n=>this.formatChainId(n)),i.forEach(n=>{this.rpc.rpcMap[n]=(s==null?void 0:s[n])||this.getRpcUrl(n)})),r&&lt(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=r==null?void 0:r.map(n=>this.formatChainId(n)),r.forEach(n=>{this.rpc.rpcMap[n]=(s==null?void 0:s[n])||this.getRpcUrl(n)}))}getRpcUrl(e,i){var r;return((r=this.rpc.rpcMap)==null?void 0:r[e])||`${wO}?chainId=eip155:${e}&projectId=${i||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),i=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:i==null?void 0:i.accounts),this.setAccounts(i==null?void 0:i.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(i=>this.signer.logger.warn(i))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(i=>this.parseAccount(i))}}const SO=Gs;var OO=Object.defineProperty,PO=Object.defineProperties,AO=Object.getOwnPropertyDescriptors,eh=Object.getOwnPropertySymbols,xO=Object.prototype.hasOwnProperty,CO=Object.prototype.propertyIsEnumerable,th=(t,e,i)=>e in t?OO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xd=(t,e)=>{for(var i in e||(e={}))xO.call(e,i)&&th(t,i,e[i]);if(eh)for(var i of eh(e))CO.call(e,i)&&th(t,i,e[i]);return t},TO=(t,e)=>PO(t,AO(e));function RO(t){if(t)return{"--w3m-font-family":t["--wcm-font-family"],"--w3m-accent":t["--wcm-accent-color"],"--w3m-color-mix":t["--wcm-background-color"],"--w3m-z-index":t["--wcm-z-index"]?Number(t["--wcm-z-index"]):void 0,"--w3m-qr-color":t["--wcm-accent-color"],"--w3m-font-size-master":t["--wcm-text-medium-regular-size"],"--w3m-border-radius-master":t["--wcm-container-border-radius"],"--w3m-color-mix-strength":0}}const NO=t=>{const[e,i]=t.split(":");return Cd({id:i,caipNetworkId:t,chainNamespace:e,name:"",nativeCurrency:{name:"",symbol:"",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}})};function FO(t){var e,i,r,s,n,o,a;const c=(e=t.chains)==null?void 0:e.map(NO).filter(Boolean);if(c.length===0)throw new Error("At least one chain must be specified");const u=c.find(l=>{var d;return l.id===((d=t.defaultChain)==null?void 0:d.id)}),h={projectId:t.projectId,networks:c,themeMode:t.themeMode,themeVariables:RO(t.themeVariables),chainImages:t.chainImages,connectorImages:t.walletImages,defaultNetwork:u,metadata:TO(xd({},t.metadata),{name:((i=t.metadata)==null?void 0:i.name)||"WalletConnect",description:((r=t.metadata)==null?void 0:r.description)||"Connect to WalletConnect-compatible wallets",url:((s=t.metadata)==null?void 0:s.url)||"https://walletconnect.org",icons:((n=t.metadata)==null?void 0:n.icons)||["https://walletconnect.org/walletconnect-logo.png"]}),showWallets:!0,featuredWalletIds:t.explorerRecommendedWalletIds==="NONE"?[]:Array.isArray(t.explorerRecommendedWalletIds)?t.explorerRecommendedWalletIds:[],excludeWalletIds:t.explorerExcludedWalletIds==="ALL"?[]:Array.isArray(t.explorerExcludedWalletIds)?t.explorerExcludedWalletIds:[],enableEIP6963:!1,enableInjected:!1,enableCoinbase:!0,enableWalletConnect:!0,features:{email:!1,socials:!1}};if((o=t.mobileWallets)!=null&&o.length||(a=t.desktopWallets)!=null&&a.length){const l=[...(t.mobileWallets||[]).map(p=>({id:p.id,name:p.name,links:p.links})),...(t.desktopWallets||[]).map(p=>({id:p.id,name:p.name,links:{native:p.links.native,universal:p.links.universal}}))],d=[...h.featuredWalletIds||[],...h.excludeWalletIds||[]],f=l.filter(p=>!d.includes(p.id));f.length&&(h.customWallets=f)}return h}function Cd(t){return xd({formatters:void 0,fees:void 0,serializers:void 0},t)}var BO=Object.freeze({__proto__:null,convertWCMToAppKitOptions:FO,defineChain:Cd});const PP=Object.freeze(Object.defineProperty({__proto__:null,EthereumProvider:SO,OPTIONAL_EVENTS:Ad,OPTIONAL_METHODS:Pd,REQUIRED_EVENTS:Os,REQUIRED_METHODS:Ss,default:Gs},Symbol.toStringTag,{value:"Module"}));
38export{fE as A,rt as B,_w as C,__ as D,Ne as E,Wo as F,Vs as G,pf as H,fi as I,zs as J,gi as K,Ht as L,Dm as M,ni as N,zr as O,Ka as P,Yh as Q,Hs as R,bt as S,et as T,wt as U,dt as V,PP as W,Ea as a,rf as b,kO as c,qO as d,xs as e,zO as f,HO as g,es as h,ui as i,ch as j,N as k,tt as l,qe as m,ai as n,Oo as o,Qd as p,ah as q,MO as r,Bt as s,yh as t,vr as u,Vn as v,ff as w,Ms as x,ke as y,l1 as z};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.