UNPKG

@walletconnect/core

Version:
14 lines (12 loc) 409 kB
(function(V,Tt){typeof exports=="object"&&typeof module<"u"?Tt(exports):typeof define=="function"&&define.amd?define(["exports"],Tt):(V=typeof globalThis<"u"?globalThis:V||self,Tt(V["@walletconnect/core"]={}))})(this,function(V){"use strict";var Tt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jc(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var lt={exports:{}},ir=typeof Reflect=="object"?Reflect:null,Qc=ir&&typeof ir.apply=="function"?ir.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Ui;ir&&typeof ir.ownKeys=="function"?Ui=ir.ownKeys:Object.getOwnPropertySymbols?Ui=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Ui=function(t){return Object.getOwnPropertyNames(t)};function up(e){console&&console.warn&&console.warn(e)}var ef=Number.isNaN||function(t){return t!==t};function ae(){ae.init.call(this)}lt.exports=ae,lt.exports.once=gp,ae.EventEmitter=ae,ae.prototype._events=void 0,ae.prototype._eventsCount=0,ae.prototype._maxListeners=void 0;var tf=10;function Fi(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(ae,"defaultMaxListeners",{enumerable:!0,get:function(){return tf},set:function(e){if(typeof e!="number"||e<0||ef(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");tf=e}}),ae.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},ae.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||ef(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function nf(e){return e._maxListeners===void 0?ae.defaultMaxListeners:e._maxListeners}ae.prototype.getMaxListeners=function(){return nf(this)},ae.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")Qc(c,this,n);else for(var f=c.length,u=cf(c,f),r=0;r<f;++r)Qc(u[r],this,n);return!0};function rf(e,t,n,r){var i,s,o;if(Fi(n),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),o===void 0)o=s[t]=n,++e._eventsCount;else if(typeof o=="function"?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),i=nf(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,up(a)}return e}ae.prototype.addListener=function(t,n){return rf(this,t,n,!1)},ae.prototype.on=ae.prototype.addListener,ae.prototype.prependListener=function(t,n){return rf(this,t,n,!0)};function lp(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function sf(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=lp.bind(r);return i.listener=n,r.wrapFn=i,i}ae.prototype.once=function(t,n){return Fi(n),this.on(t,sf(this,t,n)),this},ae.prototype.prependOnceListener=function(t,n){return Fi(n),this.prependListener(t,sf(this,t,n)),this},ae.prototype.removeListener=function(t,n){var r,i,s,o,a;if(Fi(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===n||r[o].listener===n){a=r[o].listener,s=o;break}if(s<0)return this;s===0?r.shift():hp(r,s),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||n)}return this},ae.prototype.off=ae.prototype.removeListener,ae.prototype.removeAllListeners=function(t){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var s=Object.keys(r),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function of(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?dp(i):cf(i,i.length)}ae.prototype.listeners=function(t){return of(this,t,!0)},ae.prototype.rawListeners=function(t){return of(this,t,!1)},ae.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):af.call(e,t)},ae.prototype.listenerCount=af;function af(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}ae.prototype.eventNames=function(){return this._eventsCount>0?Ui(this._events):[]};function cf(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function hp(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function dp(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function gp(e,t){return new Promise(function(n,r){function i(o){e.removeListener(t,s),r(o)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}ff(e,t,s,{once:!0}),t!=="error"&&pp(e,i,{once:!0})})}function pp(e,t,n){typeof e.on=="function"&&ff(e,"error",t,n)}function ff(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(s){r.once&&e.removeEventListener(t,i),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var W={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var co=function(e,t){return co=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},co(e,t)};function bp(e,t){co(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var fo=function(){return fo=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},fo.apply(this,arguments)};function yp(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function wp(e,t,n,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function mp(e,t){return function(n,r){t(n,r,e)}}function Ep(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function vp(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{f(r.next(u))}catch(d){o(d)}}function c(u){try{f(r.throw(u))}catch(d){o(d)}}function f(u){u.done?s(u.value):i(u.value).then(a,c)}f((r=r.apply(e,t||[])).next())})}function _p(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(u){return c([f,u])}}function c(f){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){n.label=f[1];break}if(f[0]===6&&n.label<s[1]){n.label=s[1],s=f;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(f);break}s[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(u){f=[6,u],i=0}finally{r=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function xp(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Sp(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function uo(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function uf(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Ip(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(uf(arguments[t]));return e}function Op(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function qr(e){return this instanceof qr?(this.v=e,this):new qr(e)}function Bp(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(h){r[h]&&(i[h]=function(l){return new Promise(function(g,w){s.push([h,l,g,w])>1||a(h,l)})})}function a(h,l){try{c(r[h](l))}catch(g){d(s[0][3],g)}}function c(h){h.value instanceof qr?Promise.resolve(h.value.v).then(f,u):d(s[0][2],h)}function f(h){a("next",h)}function u(h){a("throw",h)}function d(h,l){h(l),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Ap(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(o){return(n=!n)?{value:qr(e[i](o)),done:i==="return"}:s?s(o):o}:s}}function Dp(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof uo=="function"?uo(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function Tp(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Rp(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function Np(e){return e&&e.__esModule?e:{default:e}}function Cp(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Pp(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var $p=Object.freeze({__proto__:null,__extends:bp,get __assign(){return fo},__rest:yp,__decorate:wp,__param:mp,__metadata:Ep,__awaiter:vp,__generator:_p,__createBinding:xp,__exportStar:Sp,__values:uo,__read:uf,__spread:Ip,__spreadArrays:Op,__await:qr,__asyncGenerator:Bp,__asyncDelegator:Ap,__asyncValues:Dp,__makeTemplateObject:Tp,__importStar:Rp,__importDefault:Np,__classPrivateFieldGet:Cp,__classPrivateFieldSet:Pp}),ji=Jc($p),lo={},Hr={},lf;function Lp(){if(lf)return Hr;lf=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return Hr.delay=e,Hr}var Pn={},ho={},$n={},hf;function Up(){return hf||(hf=1,Object.defineProperty($n,"__esModule",{value:!0}),$n.ONE_THOUSAND=$n.ONE_HUNDRED=void 0,$n.ONE_HUNDRED=100,$n.ONE_THOUSAND=1e3),$n}var go={},df;function Fp(){return df||(df=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=e.ONE_MINUTE*5,e.TEN_MINUTES=e.ONE_MINUTE*10,e.THIRTY_MINUTES=e.ONE_MINUTE*30,e.SIXTY_MINUTES=e.ONE_MINUTE*60,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=e.ONE_HOUR*3,e.SIX_HOURS=e.ONE_HOUR*6,e.TWELVE_HOURS=e.ONE_HOUR*12,e.TWENTY_FOUR_HOURS=e.ONE_HOUR*24,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=e.ONE_DAY*3,e.FIVE_DAYS=e.ONE_DAY*5,e.SEVEN_DAYS=e.ONE_DAY*7,e.THIRTY_DAYS=e.ONE_DAY*30,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=e.ONE_WEEK*2,e.THREE_WEEKS=e.ONE_WEEK*3,e.FOUR_WEEKS=e.ONE_WEEK*4,e.ONE_YEAR=e.ONE_DAY*365}(go)),go}var gf;function pf(){return gf||(gf=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=ji;t.__exportStar(Up(),e),t.__exportStar(Fp(),e)}(ho)),ho}var bf;function jp(){if(bf)return Pn;bf=1,Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.fromMiliseconds=Pn.toMiliseconds=void 0;const e=pf();function t(r){return r*e.ONE_THOUSAND}Pn.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return Pn.fromMiliseconds=n,Pn}var yf;function Mp(){return yf||(yf=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=ji;t.__exportStar(Lp(),e),t.__exportStar(jp(),e)}(lo)),lo}var sr={},wf;function kp(){if(wf)return sr;wf=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(n){if(this.timestamps.has(n))throw new Error(`Watch already started for label: ${n}`);this.timestamps.set(n,{started:Date.now()})}stop(n){const r=this.get(n);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${n}`);const i=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:i})}get(n){const r=this.timestamps.get(n);if(typeof r>"u")throw new Error(`No timestamp found for label: ${n}`);return r}elapsed(n){const r=this.get(n);return r.elapsed||Date.now()-r.started}}return sr.Watch=e,sr.default=e,sr}var po={},Vr={},mf;function zp(){if(mf)return Vr;mf=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.IWatch=void 0;class e{}return Vr.IWatch=e,Vr}var Ef;function qp(){return Ef||(Ef=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),ji.__exportStar(zp(),e)}(po)),po}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=ji;t.__exportStar(Mp(),e),t.__exportStar(kp(),e),t.__exportStar(qp(),e),t.__exportStar(pf(),e)})(W);class Ln{}class Hp extends Ln{constructor(t){super()}}const vf=W.FIVE_SECONDS,Un={pulse:"heartbeat_pulse"};class bo extends Hp{constructor(t){super(t),this.events=new lt.exports.EventEmitter,this.interval=vf,this.interval=t?.interval||vf}static async init(t){const n=new bo(t);return await n.init(),n}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(t,n){this.events.on(t,n)}once(t,n){this.events.once(t,n)}off(t,n){this.events.off(t,n)}removeListener(t,n){this.events.removeListener(t,n)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),W.toMiliseconds(this.interval))}pulse(){this.events.emit(Un.pulse)}}const Vp=/"(?:_|\\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*:/,Kp=/"(?: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*:/,Gp=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Zp(e,t){if(e==="__proto__"||e==="constructor"&&t&&typeof t=="object"&&"prototype"in t){Yp(e);return}return t}function Yp(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function Mi(e,t={}){if(typeof e!="string")return e;if(e[0]==='"'&&e[e.length-1]==='"'&&e.indexOf("\\")===-1)return e.slice(1,-1);const n=e.trim();if(n.length<=9)switch(n.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(!Gp.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(Vp.test(e)||Kp.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,Zp)}return JSON.parse(e)}catch(r){if(t.strict)throw r;return e}}function Wp(e){return!e||typeof e.then!="function"?Promise.resolve(e):e}function ve(e,...t){try{return Wp(e(...t))}catch(n){return Promise.reject(n)}}function Xp(e){const t=typeof e;return e===null||t!=="object"&&t!=="function"}function Jp(e){const t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}function ki(e){if(Xp(e))return String(e);if(Jp(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON=="function")return ki(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const yo="base64:";function Qp(e){return typeof e=="string"?e:yo+n1(e)}function e1(e){return typeof e!="string"||!e.startsWith(yo)?e:t1(e.slice(yo.length))}function t1(e){return globalThis.Buffer?Buffer.from(e,"base64"):Uint8Array.from(globalThis.atob(e),t=>t.codePointAt(0))}function n1(e){return globalThis.Buffer?Buffer.from(e).toString("base64"):globalThis.btoa(String.fromCodePoint(...e))}function Ke(e){return e&&e.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function r1(...e){return Ke(e.join(":"))}function zi(e){return e=Ke(e),e?e+":":""}function i1(e,t){if(t===void 0)return!0;let n=0,r=e.indexOf(":");for(;r>-1;)n++,r=e.indexOf(":",r+1);return n<=t}function s1(e,t){return t?e.startsWith(t)&&e[e.length-1]!=="$":e[e.length-1]!=="$"}function wx(e){return e}const o1="memory",a1=()=>{const e=new Map;return{name:o1,getInstance:()=>e,hasItem(t){return e.has(t)},getItem(t){return e.get(t)??null},getItemRaw(t){return e.get(t)??null},setItem(t,n){e.set(t,n)},setItemRaw(t,n){e.set(t,n)},removeItem(t){e.delete(t)},getKeys(){return[...e.keys()]},clear(){e.clear()},dispose(){e.clear()}}};function c1(e={}){const t={mounts:{"":e.driver||a1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},n=f=>{for(const u of t.mountpoints)if(f.startsWith(u))return{base:u,relativeKey:f.slice(u.length),driver:t.mounts[u]};return{base:"",relativeKey:f,driver:t.mounts[""]}},r=(f,u)=>t.mountpoints.filter(d=>d.startsWith(f)||u&&f.startsWith(d)).map(d=>({relativeBase:f.length>d.length?f.slice(d.length):void 0,mountpoint:d,driver:t.mounts[d]})),i=(f,u)=>{if(t.watching){u=Ke(u);for(const d of t.watchListeners)d(f,u)}},s=async()=>{if(!t.watching){t.watching=!0;for(const f in t.mounts)t.unwatch[f]=await _f(t.mounts[f],i,f)}},o=async()=>{if(t.watching){for(const f in t.unwatch)await t.unwatch[f]();t.unwatch={},t.watching=!1}},a=(f,u,d)=>{const h=new Map,l=g=>{let w=h.get(g.base);return w||(w={driver:g.driver,base:g.base,items:[]},h.set(g.base,w)),w};for(const g of f){const w=typeof g=="string",v=Ke(w?g:g.key),A=w?void 0:g.value,C=w||!g.options?u:{...u,...g.options},x=n(v);l(x).items.push({key:v,value:A,relativeKey:x.relativeKey,options:C})}return Promise.all([...h.values()].map(g=>d(g))).then(g=>g.flat())},c={hasItem(f,u={}){f=Ke(f);const{relativeKey:d,driver:h}=n(f);return ve(h.hasItem,d,u)},getItem(f,u={}){f=Ke(f);const{relativeKey:d,driver:h}=n(f);return ve(h.getItem,d,u).then(l=>Mi(l))},getItems(f,u={}){return a(f,u,d=>d.driver.getItems?ve(d.driver.getItems,d.items.map(h=>({key:h.relativeKey,options:h.options})),u).then(h=>h.map(l=>({key:r1(d.base,l.key),value:Mi(l.value)}))):Promise.all(d.items.map(h=>ve(d.driver.getItem,h.relativeKey,h.options).then(l=>({key:h.key,value:Mi(l)})))))},getItemRaw(f,u={}){f=Ke(f);const{relativeKey:d,driver:h}=n(f);return h.getItemRaw?ve(h.getItemRaw,d,u):ve(h.getItem,d,u).then(l=>e1(l))},async setItem(f,u,d={}){if(u===void 0)return c.removeItem(f);f=Ke(f);const{relativeKey:h,driver:l}=n(f);l.setItem&&(await ve(l.setItem,h,ki(u),d),l.watch||i("update",f))},async setItems(f,u){await a(f,u,async d=>{if(d.driver.setItems)return ve(d.driver.setItems,d.items.map(h=>({key:h.relativeKey,value:ki(h.value),options:h.options})),u);d.driver.setItem&&await Promise.all(d.items.map(h=>ve(d.driver.setItem,h.relativeKey,ki(h.value),h.options)))})},async setItemRaw(f,u,d={}){if(u===void 0)return c.removeItem(f,d);f=Ke(f);const{relativeKey:h,driver:l}=n(f);if(l.setItemRaw)await ve(l.setItemRaw,h,u,d);else if(l.setItem)await ve(l.setItem,h,Qp(u),d);else return;l.watch||i("update",f)},async removeItem(f,u={}){typeof u=="boolean"&&(u={removeMeta:u}),f=Ke(f);const{relativeKey:d,driver:h}=n(f);h.removeItem&&(await ve(h.removeItem,d,u),(u.removeMeta||u.removeMata)&&await ve(h.removeItem,d+"$",u),h.watch||i("remove",f))},async getMeta(f,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),f=Ke(f);const{relativeKey:d,driver:h}=n(f),l=Object.create(null);if(h.getMeta&&Object.assign(l,await ve(h.getMeta,d,u)),!u.nativeOnly){const g=await ve(h.getItem,d+"$",u).then(w=>Mi(w));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(l,g))}return l},setMeta(f,u,d={}){return this.setItem(f+"$",u,d)},removeMeta(f,u={}){return this.removeItem(f+"$",u)},async getKeys(f,u={}){f=zi(f);const d=r(f,!0);let h=[];const l=[];let g=!0;for(const v of d){v.driver.flags?.maxDepth||(g=!1);const A=await ve(v.driver.getKeys,v.relativeBase,u);for(const C of A){const x=v.mountpoint+Ke(C);h.some(_=>x.startsWith(_))||l.push(x)}h=[v.mountpoint,...h.filter(C=>!C.startsWith(v.mountpoint))]}const w=u.maxDepth!==void 0&&!g;return l.filter(v=>(!w||i1(v,u.maxDepth))&&s1(v,f))},async clear(f,u={}){f=zi(f),await Promise.all(r(f,!1).map(async d=>{if(d.driver.clear)return ve(d.driver.clear,d.relativeBase,u);if(d.driver.removeItem){const h=await d.driver.getKeys(d.relativeBase||"",u);return Promise.all(h.map(l=>d.driver.removeItem(l,u)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(f=>xf(f)))},async watch(f){return await s(),t.watchListeners.push(f),async()=>{t.watchListeners=t.watchListeners.filter(u=>u!==f),t.watchListeners.length===0&&await o()}},async unwatch(){t.watchListeners=[],await o()},mount(f,u){if(f=zi(f),f&&t.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(t.mountpoints.push(f),t.mountpoints.sort((d,h)=>h.length-d.length)),t.mounts[f]=u,t.watching&&Promise.resolve(_f(u,i,f)).then(d=>{t.unwatch[f]=d}).catch(console.error),c},async unmount(f,u=!0){f=zi(f),!(!f||!t.mounts[f])&&(t.watching&&f in t.unwatch&&(t.unwatch[f]?.(),delete t.unwatch[f]),u&&await xf(t.mounts[f]),t.mountpoints=t.mountpoints.filter(d=>d!==f),delete t.mounts[f])},getMount(f=""){f=Ke(f)+":";const u=n(f);return{driver:u.driver,base:u.base}},getMounts(f="",u={}){return f=Ke(f),r(f,u.parents).map(h=>({driver:h.driver,base:h.mountpoint}))},keys:(f,u={})=>c.getKeys(f,u),get:(f,u={})=>c.getItem(f,u),set:(f,u,d={})=>c.setItem(f,u,d),has:(f,u={})=>c.hasItem(f,u),del:(f,u={})=>c.removeItem(f,u),remove:(f,u={})=>c.removeItem(f,u)};return c}function _f(e,t,n){return e.watch?e.watch((r,i)=>t(r,n+i)):()=>{}}async function xf(e){typeof e.dispose=="function"&&await ve(e.dispose)}function Fn(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Sf(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=Fn(n);return(i,s)=>r.then(o=>s(o.transaction(t,i).objectStore(t)))}let wo;function Kr(){return wo||(wo=Sf("keyval-store","keyval")),wo}function If(e,t=Kr()){return t("readonly",n=>Fn(n.get(e)))}function f1(e,t,n=Kr()){return n("readwrite",r=>(r.put(t,e),Fn(r.transaction)))}function u1(e,t=Kr()){return t("readwrite",n=>(n.delete(e),Fn(n.transaction)))}function l1(e=Kr()){return e("readwrite",t=>(t.clear(),Fn(t.transaction)))}function h1(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Fn(e.transaction)}function d1(e=Kr()){return e("readonly",t=>{if(t.getAllKeys)return Fn(t.getAllKeys());const n=[];return h1(t,r=>n.push(r.key)).then(()=>n)})}const g1=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString()+"n":n),p1=e=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,n=e.replace(t,'$1"$2n"$3');return JSON.parse(n,(r,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function or(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return p1(e)}catch{return e}}function jn(e){return typeof e=="string"?e:g1(e)||""}const b1="idb-keyval";var y1=(e={})=>{const t=e.base&&e.base.length>0?`${e.base}:`:"",n=i=>t+i;let r;return e.dbName&&e.storeName&&(r=Sf(e.dbName,e.storeName)),{name:b1,options:e,async hasItem(i){return!(typeof await If(n(i),r)>"u")},async getItem(i){return await If(n(i),r)??null},setItem(i,s){return f1(n(i),s,r)},removeItem(i){return u1(n(i),r)},getKeys(){return d1(r)},clear(){return l1(r)}}};const w1="WALLET_CONNECT_V2_INDEXED_DB",m1="keyvaluestorage";class E1{constructor(){this.indexedDb=c1({driver:y1({dbName:w1,storeName:m1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const n=await this.indexedDb.getItem(t);if(n!==null)return n}async setItem(t,n){await this.indexedDb.setItem(t,jn(n))}async removeItem(t){await this.indexedDb.removeItem(t)}}var mo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},qi={exports:{}};(function(){let e;function t(){}e=t,e.prototype.getItem=function(n){return this.hasOwnProperty(n)?String(this[n]):null},e.prototype.setItem=function(n,r){this[n]=String(r)},e.prototype.removeItem=function(n){delete this[n]},e.prototype.clear=function(){const n=this;Object.keys(n).forEach(function(r){n[r]=void 0,delete n[r]})},e.prototype.key=function(n){return n=n||0,Object.keys(this)[n]},e.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof mo<"u"&&mo.localStorage?qi.exports=mo.localStorage:typeof window<"u"&&window.localStorage?qi.exports=window.localStorage:qi.exports=new t})();function v1(e){var t;return[e[0],or((t=e[1])!=null?t:"")]}class _1{constructor(){this.localStorage=qi.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(v1)}async getItem(t){const n=this.localStorage.getItem(t);if(n!==null)return or(n)}async setItem(t,n){this.localStorage.setItem(t,jn(n))}async removeItem(t){this.localStorage.removeItem(t)}}const x1="wc_storage_version",Of=1,S1=async(e,t,n)=>{const r=x1,i=await t.getItem(r);if(i&&i>=Of){n(t);return}const s=await e.getKeys();if(!s.length){n(t);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const f=await e.getItem(a);await t.setItem(a,f),o.push(a)}}await t.setItem(r,Of),n(t),I1(e,o)},I1=async(e,t)=>{t.length&&t.forEach(async n=>{await e.removeItem(n)})};class O1{constructor(){this.initialized=!1,this.setInitialized=n=>{this.storage=n,this.initialized=!0};const t=new _1;this.storage=t;try{const n=new E1;S1(t,n,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,n){return await this.initialize(),this.storage.setItem(t,n)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const n=setInterval(()=>{this.initialized&&(clearInterval(n),t())},20)})}}function B1(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}var A1=D1;function D1(e,t,n){var r=n&&n.stringify||B1,i=1;if(typeof e=="object"&&e!==null){var s=t.length+i;if(s===1)return e;var o=new Array(s);o[0]=r(e);for(var a=1;a<s;a++)o[a]=r(t[a]);return o.join(" ")}if(typeof e!="string")return e;var c=t.length;if(c===0)return e;for(var f="",u=1-i,d=-1,h=e&&e.length||0,l=0;l<h;){if(e.charCodeAt(l)===37&&l+1<h){switch(d=d>-1?d:0,e.charCodeAt(l+1)){case 100:case 102:if(u>=c||t[u]==null)break;d<l&&(f+=e.slice(d,l)),f+=Number(t[u]),d=l+2,l++;break;case 105:if(u>=c||t[u]==null)break;d<l&&(f+=e.slice(d,l)),f+=Math.floor(Number(t[u])),d=l+2,l++;break;case 79:case 111:case 106:if(u>=c||t[u]===void 0)break;d<l&&(f+=e.slice(d,l));var g=typeof t[u];if(g==="string"){f+="'"+t[u]+"'",d=l+2,l++;break}if(g==="function"){f+=t[u].name||"<anonymous>",d=l+2,l++;break}f+=r(t[u]),d=l+2,l++;break;case 115:if(u>=c)break;d<l&&(f+=e.slice(d,l)),f+=String(t[u]),d=l+2,l++;break;case 37:d<l&&(f+=e.slice(d,l)),f+="%",d=l+2,l++,u--;break}++u}++l}return d===-1?e:(d<h&&(f+=e.slice(d)),f)}const Bf=A1;var Mn=Rt;const Gr=j1().console||{},T1={mapHttpRequest:Vi,mapHttpResponse:Vi,wrapRequestSerializer:vo,wrapResponseSerializer:vo,wrapErrorSerializer:vo,req:Vi,res:Vi,err:$1};function R1(e,t){return Array.isArray(e)?e.filter(function(r){return r!=="!stdSerializers.err"}):e===!0?Object.keys(t):!1}function Rt(e){e=e||{},e.browser=e.browser||{};const t=e.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const n=e.browser.write||Gr;e.browser.write&&(e.browser.asObject=!0);const r=e.serializers||{},i=R1(e.browser.serialize,r);let s=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof n=="function"&&(n.error=n.fatal=n.warn=n.info=n.debug=n.trace=n),e.enabled===!1&&(e.level="silent");const a=e.level||"info",c=Object.create(n);c.log||(c.log=Zr),Object.defineProperty(c,"levelVal",{get:u}),Object.defineProperty(c,"level",{get:d,set:h});const f={transmit:t,serialize:i,asObject:e.browser.asObject,levels:o,timestamp:L1(e)};c.levels=Rt.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=Zr,c.serializers=r,c._serialize=i,c._stdErrSerialize=s,c.child=l,t&&(c._logEvent=Eo());function u(){return this.level==="silent"?1/0:this.levels.values[this.level]}function d(){return this._level}function h(g){if(g!=="silent"&&!this.levels.values[g])throw Error("unknown level "+g);this._level=g,ar(f,c,"error","log"),ar(f,c,"fatal","error"),ar(f,c,"warn","error"),ar(f,c,"info","log"),ar(f,c,"debug","log"),ar(f,c,"trace","log")}function l(g,w){if(!g)throw new Error("missing bindings for child Pino");w=w||{},i&&g.serializers&&(w.serializers=g.serializers);const v=w.serializers;if(i&&v){var A=Object.assign({},r,v),C=e.browser.serialize===!0?Object.keys(A):i;delete g.serializers,Hi([g],C,A,this._stdErrSerialize)}function x(_){this._childLevel=(_._childLevel|0)+1,this.error=cr(_,g,"error"),this.fatal=cr(_,g,"fatal"),this.warn=cr(_,g,"warn"),this.info=cr(_,g,"info"),this.debug=cr(_,g,"debug"),this.trace=cr(_,g,"trace"),A&&(this.serializers=A,this._serialize=C),t&&(this._logEvent=Eo([].concat(_._logEvent.bindings,g)))}return x.prototype=this,new x(this)}return c}Rt.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"}},Rt.stdSerializers=T1,Rt.stdTimeFunctions=Object.assign({},{nullTime:Af,epochTime:Df,unixTime:U1,isoTime:F1});function ar(e,t,n,r){const i=Object.getPrototypeOf(t);t[n]=t.levelVal>t.levels.values[n]?Zr:i[n]?i[n]:Gr[n]||Gr[r]||Zr,N1(e,t,n)}function N1(e,t,n){!e.transmit&&t[n]===Zr||(t[n]=function(r){return function(){const s=e.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Gr?Gr:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(e.serialize&&!e.asObject&&Hi(o,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?r.call(a,C1(this,n,o,s)):r.apply(a,o),e.transmit){const f=e.transmit.level||t.level,u=Rt.levels.values[f],d=Rt.levels.values[n];if(d<u)return;P1(this,{ts:s,methodLevel:n,methodValue:d,transmitLevel:f,transmitValue:Rt.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},o)}}}(t[n]))}function C1(e,t,n,r){e._serialize&&Hi(n,e._serialize,e.serializers,e._stdErrSerialize);const i=n.slice();let s=i[0];const o={};r&&(o.time=r),o.level=Rt.levels.values[t];let a=(e._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof i[0]=="object";)Object.assign(o,i.shift());s=i.length?Bf(i.shift(),i):void 0}else typeof s=="string"&&(s=Bf(i.shift(),i));return s!==void 0&&(o.msg=s),o}function Hi(e,t,n,r){for(const i in e)if(r&&e[i]instanceof Error)e[i]=Rt.stdSerializers.err(e[i]);else if(typeof e[i]=="object"&&!Array.isArray(e[i]))for(const s in e[i])t&&t.indexOf(s)>-1&&s in n&&(e[i][s]=n[s](e[i][s]))}function cr(e,t,n){return function(){const r=new Array(1+arguments.length);r[0]=t;for(var i=1;i<r.length;i++)r[i]=arguments[i-1];return e[n].apply(this,r)}}function P1(e,t,n){const r=t.send,i=t.ts,s=t.methodLevel,o=t.methodValue,a=t.val,c=e._logEvent.bindings;Hi(n,e._serialize||Object.keys(e.serializers),e.serializers,e._stdErrSerialize===void 0?!0:e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter(function(f){return c.indexOf(f)===-1}),e._logEvent.level.label=s,e._logEvent.level.value=o,r(s,e._logEvent,a),e._logEvent=Eo(c)}function Eo(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function $1(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)t[n]===void 0&&(t[n]=e[n]);return t}function L1(e){return typeof e.timestamp=="function"?e.timestamp:e.timestamp===!1?Af:Df}function Vi(){return{}}function vo(e){return e}function Zr(){}function Af(){return!1}function Df(){return Date.now()}function U1(){return Math.round(Date.now()/1e3)}function F1(){return new Date(Date.now()).toISOString()}function j1(){function e(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return e(self)||e(window)||e(this)||{}}}const M1={level:"info"},Yr="custom_context",_o=1e3*1024;class k1{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class Tf{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0}append(t){const n=new k1(t);if(n.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${n.size}`);for(;this.size+n.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=n),this.tail=n):(this.head=n,this.tail=n),this.lengthInNodes++,this.sizeInBytes+=n.size}shift(){if(!this.head)return;const t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size}toArray(){const t=[];let n=this.head;for(;n!==null;)t.push(n.value),n=n.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return{next:()=>{if(!t)return{done:!0,value:null};const n=t.value;return t=t.next,{done:!1,value:n}}}}}class Rf{constructor(t,n=_o){this.level=t??"error",this.levelValue=Mn.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=n,this.logs=new Tf(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(t,n){n===Mn.levels.values.error?console.error(t):n===Mn.levels.values.warn?console.warn(t):n===Mn.levels.values.debug?console.debug(t):n===Mn.levels.values.trace?console.trace(t):console.log(t)}appendToLogs(t){this.logs.append(jn({timestamp:new Date().toISOString(),log:t}));const n=typeof t=="string"?JSON.parse(t).level:t.level;n>=this.levelValue&&this.forwardToConsole(t,n)}getLogs(){return this.logs}clearLogs(){this.logs=new Tf(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(t){const n=this.getLogArray();return n.push(jn({extraMetadata:t})),new Blob(n,{type:"application/json"})}}class z1{constructor(t,n=_o){this.baseChunkLogger=new Rf(t,n)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){const n=URL.createObjectURL(this.logsToBlob(t)),r=document.createElement("a");r.href=n,r.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}}class q1{constructor(t,n=_o){this.baseChunkLogger=new Rf(t,n)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}}var H1=Object.defineProperty,V1=Object.defineProperties,K1=Object.getOwnPropertyDescriptors,Nf=Object.getOwnPropertySymbols,G1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable,Cf=(e,t,n)=>t in e?H1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ki=(e,t)=>{for(var n in t||(t={}))G1.call(t,n)&&Cf(e,n,t[n]);if(Nf)for(var n of Nf(t))Z1.call(t,n)&&Cf(e,n,t[n]);return e},Gi=(e,t)=>V1(e,K1(t));function Y1(e){return Gi(Ki({},e),{level:e?.level||M1.level})}function W1(e,t=Yr){return e[t]||""}function X1(e,t,n=Yr){return e[n]=t,e}function rt(e,t=Yr){let n="";return typeof e.bindings>"u"?n=W1(e,t):n=e.bindings().context||"",n}function J1(e,t,n=Yr){const r=rt(e,n);return r.trim()?`${r}/${t}`:t}function it(e,t,n=Yr){const r=J1(e,t,n),i=e.child({context:r});return X1(i,r,n)}function Q1(e){var t,n;const r=new z1((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return{logger:Mn(Gi(Ki({},e.opts),{level:"trace",browser:Gi(Ki({},(n=e.opts)==null?void 0:n.browser),{write:i=>r.write(i)})})),chunkLoggerController:r}}function eb(e){var t;const n=new q1((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return{logger:Mn(Gi(Ki({},e.opts),{level:"trace"})),chunkLoggerController:n}}function Pf(e){return typeof e.loggerOverride<"u"&&typeof e.loggerOverride!="string"?{logger:e.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Q1(e):eb(e)}var tb=Object.defineProperty,nb=(e,t,n)=>t in e?tb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$f=(e,t,n)=>nb(e,typeof t!="symbol"?t+"":t,n);class rb extends Ln{constructor(t){super(),this.opts=t,$f(this,"protocol","wc"),$f(this,"version",2)}}var ib=Object.defineProperty,sb=(e,t,n)=>t in e?ib(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ob=(e,t,n)=>sb(e,typeof t!="symbol"?t+"":t,n);class ab extends Ln{constructor(t,n){super(),this.core=t,this.logger=n,ob(this,"records",new Map)}}class cb{constructor(t,n){this.logger=t,this.core=n}}class fb extends Ln{constructor(t,n){super(),this.relayer=t,this.logger=n}}class ub extends Ln{constructor(t){super()}}class lb{constructor(t,n,r,i){this.core=t,this.logger=n,this.name=r}}class hb extends Ln{constructor(t,n){super(),this.relayer=t,this.logger=n}}class db extends Ln{constructor(t,n){super(),this.core=t,this.logger=n}}class gb{constructor(t,n,r){this.core=t,this.logger=n,this.store=r}}class pb{constructor(t,n){this.projectId=t,this.logger=n}}class bb{constructor(t,n,r){this.core=t,this.logger=n,this.telemetryEnabled=r}}const xo="wc",So=2,Wr="core",Et=`${xo}@2:${Wr}:`,Lf={name:Wr,logger:"error"},Uf={database:":memory:"},Ff="crypto",Io="client_ed25519_seed",jf=W.ONE_DAY,Mf="keychain",kf="0.3",zf="messages",qf="0.3",Hf=W.SIX_HOURS,Vf="publisher",Kf="irn",Gf="error",Oo="wss://relay.walletconnect.org",Zf="relayer",be={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"},Yf="_subscription",st={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Wf=.1,yb={database:":memory:"},Zi="2.22.2",wb=1e4,kn={link_mode:"link_mode",relay:"relay"},Xr={inbound:"inbound",outbound:"outbound"},Xf="0.3",Jf="WALLETCONNECT_CLIENT_ID",Bo="WALLETCONNECT_LINK_MODE_APPS",Ge={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},mb=W.THIRTY_DAYS,Qf="subscription",eu="0.3",Eb=W.FIVE_SECONDS*1e3,tu="pairing",nu="0.3",vb=W.THIRTY_DAYS,fr={wc_pairingDelete:{req:{ttl:W.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:W.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:W.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:W.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:W.ONE_DAY,prompt:!1,tag:0},res:{ttl:W.ONE_DAY,prompt:!1,tag:0}}},ur={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},ht={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},ru="history",iu="0.3",su="expirer",dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},ou="0.3",_b=W.ONE_DAY,au="verify-api",xb="https://verify.walletconnect.com",cu="https://verify.walletconnect.org",Jr=cu,fu=`${Jr}/v3`,uu=[xb,cu],lu="echo",hu="https://echo.walletconnect.com",Sb="event-client",Nt={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"},jt={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"},Ib={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",session_request_response_started:"session_request_response_started",session_request_response_validation_success:"session_request_response_validation_success",session_request_response_publish_started:"session_request_response_publish_started"},Ob={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",session_request_response_validation_failure:"session_request_response_validation_failure",session_request_response_publish_failure:"session_request_response_publish_failure"},Bb={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"},Ab={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"},du=.1,gu="event-client",pu=86400,bu="https://pulse.walletconnect.org/batch";function Db(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yu(e,...t){if(!Db(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function wu(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Tb(e,t){yu(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const lr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ao=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function Rb(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function mu(e){return typeof e=="string"&&(e=Rb(e)),yu(e),e}class Nb{clone(){return this._cloneInto()}}function Cb(e){const t=r=>e().update(mu(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Eu(e=32){if(lr&&typeof lr.getRandomValues=="function")return lr.getRandomValues(new Uint8Array(e));if(lr&&typeof lr.randomBytes=="function")return lr.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function Pb(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,f=r?0:4;e.setUint