UNPKG

@walletconnect/core

Version:
14 lines (12 loc) 329 kB
(function(j,ct){typeof exports=="object"&&typeof module<"u"?ct(exports):typeof define=="function"&&define.amd?define(["exports"],ct):(j=typeof globalThis<"u"?globalThis:j||self,ct(j["@walletconnect/core"]={}))})(this,function(j){"use strict";var ct=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function na(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var qe={exports:{}},gr=typeof Reflect=="object"?Reflect:null,ia=gr&&typeof gr.apply=="function"?gr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Pn;gr&&typeof gr.ownKeys=="function"?Pn=gr.ownKeys:Object.getOwnPropertySymbols?Pn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Pn=function(e){return Object.getOwnPropertyNames(e)};function hd(t){console&&console.warn&&console.warn(t)}var sa=Number.isNaN||function(e){return e!==e};function ee(){ee.init.call(this)}qe.exports=ee,qe.exports.once=yd,ee.EventEmitter=ee,ee.prototype._events=void 0,ee.prototype._eventsCount=0,ee.prototype._maxListeners=void 0;var oa=10;function $n(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ee,"defaultMaxListeners",{enumerable:!0,get:function(){return oa},set:function(t){if(typeof t!="number"||t<0||sa(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");oa=t}}),ee.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},ee.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||sa(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function aa(t){return t._maxListeners===void 0?ee.defaultMaxListeners:t._maxListeners}ee.prototype.getMaxListeners=function(){return aa(this)},ee.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")ia(c,this,r);else for(var u=c.length,l=ha(c,u),n=0;n<u;++n)ia(l[n],this,r);return!0};function ca(t,e,r,n){var i,s,o;if($n(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=aa(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,hd(a)}return t}ee.prototype.addListener=function(e,r){return ca(this,e,r,!1)},ee.prototype.on=ee.prototype.addListener,ee.prototype.prependListener=function(e,r){return ca(this,e,r,!0)};function dd(){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 ua(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=dd.bind(n);return i.listener=r,n.wrapFn=i,i}ee.prototype.once=function(e,r){return $n(r),this.on(e,ua(this,e,r)),this},ee.prototype.prependOnceListener=function(e,r){return $n(r),this.prependListener(e,ua(this,e,r)),this},ee.prototype.removeListener=function(e,r){var n,i,s,o,a;if($n(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():gd(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},ee.prototype.off=ee.prototype.removeListener,ee.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),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(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function la(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?pd(i):ha(i,i.length)}ee.prototype.listeners=function(e){return la(this,e,!0)},ee.prototype.rawListeners=function(e){return la(this,e,!1)},ee.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):fa.call(t,e)},ee.prototype.listenerCount=fa;function fa(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ee.prototype.eventNames=function(){return this._eventsCount>0?Pn(this._events):[]};function ha(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function gd(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function pd(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function yd(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}da(t,e,s,{once:!0}),e!=="error"&&bd(t,i,{once:!0})})}function bd(t,e,r){typeof t.on=="function"&&da(t,"error",e,r)}function da(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var V={};/*! ***************************************************************************** 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 Fi=function(t,e){return Fi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Fi(t,e)};function wd(t,e){Fi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var ji=function(){return ji=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},ji.apply(this,arguments)};function md(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Ed(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function vd(t,e){return function(r,n){e(r,n,t)}}function _d(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function xd(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{u(n.next(l))}catch(f){o(f)}}function c(l){try{u(n.throw(l))}catch(f){o(f)}}function u(l){l.done?s(l.value):i(l.value).then(a,c)}u((n=n.apply(t,e||[])).next())})}function Id(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,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(u){return function(l){return c([u,l])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,i=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],i=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Dd(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Sd(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function zi(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ga(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Od(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ga(arguments[e]));return t}function Ad(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function kr(t){return this instanceof kr?(this.v=t,this):new kr(t)}function Td(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(h){n[h]&&(i[h]=function(d){return new Promise(function(g,p){s.push([h,d,g,p])>1||a(h,d)})})}function a(h,d){try{c(n[h](d))}catch(g){f(s[0][3],g)}}function c(h){h.value instanceof kr?Promise.resolve(h.value.v).then(u,l):f(s[0][2],h)}function u(h){a("next",h)}function l(h){a("throw",h)}function f(h,d){h(d),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Bd(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:kr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Rd(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof zi=="function"?zi(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}function Cd(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Nd(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Pd(t){return t&&t.__esModule?t:{default:t}}function $d(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Ld(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var Ud=Object.freeze({__proto__:null,__extends:wd,get __assign(){return ji},__rest:md,__decorate:Ed,__param:vd,__metadata:_d,__awaiter:xd,__generator:Id,__createBinding:Dd,__exportStar:Sd,__values:zi,__read:ga,__spread:Od,__spreadArrays:Ad,__await:kr,__asyncGenerator:Td,__asyncDelegator:Bd,__asyncValues:Rd,__makeTemplateObject:Cd,__importStar:Nd,__importDefault:Pd,__classPrivateFieldGet:$d,__classPrivateFieldSet:Ld}),Ln=na(Ud),ki={},Mr={},pa;function Fd(){if(pa)return Mr;pa=1,Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Mr.delay=t,Mr}var Zt={},Mi={},Xt={},ya;function jd(){return ya||(ya=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.ONE_THOUSAND=Xt.ONE_HUNDRED=void 0,Xt.ONE_HUNDRED=100,Xt.ONE_THOUSAND=1e3),Xt}var Hi={},ba;function zd(){return ba||(ba=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}(Hi)),Hi}var wa;function ma(){return wa||(wa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Ln;e.__exportStar(jd(),t),e.__exportStar(zd(),t)}(Mi)),Mi}var Ea;function kd(){if(Ea)return Zt;Ea=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.fromMiliseconds=Zt.toMiliseconds=void 0;const t=ma();function e(n){return n*t.ONE_THOUSAND}Zt.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Zt.fromMiliseconds=r,Zt}var va;function Md(){return va||(va=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Ln;e.__exportStar(Fd(),t),e.__exportStar(kd(),t)}(ki)),ki}var pr={},_a;function Hd(){if(_a)return pr;_a=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return pr.Watch=t,pr.default=t,pr}var Vi={},Hr={},xa;function Vd(){if(xa)return Hr;xa=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.IWatch=void 0;class t{}return Hr.IWatch=t,Hr}var Ia;function Kd(){return Ia||(Ia=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Ln.__exportStar(Vd(),t)}(Vi)),Vi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Ln;e.__exportStar(Md(),t),e.__exportStar(Hd(),t),e.__exportStar(Kd(),t),e.__exportStar(ma(),t)})(V);class Jt{}class qd extends Jt{constructor(e){super()}}const Da=V.FIVE_SECONDS,Qt={pulse:"heartbeat_pulse"};class Ki extends qd{constructor(e){super(e),this.events=new qe.exports.EventEmitter,this.interval=Da,this.interval=e?.interval||Da}static async init(e){const r=new Ki(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),V.toMiliseconds(this.interval))}pulse(){this.events.emit(Qt.pulse)}}const Wd=/"(?:_|\\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*:/,Gd=/"(?: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*:/,Yd=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Zd(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Xd(t);return}return e}function Xd(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Un(t,e={}){if(typeof t!="string")return t;if(t[0]==='"'&&t[t.length-1]==='"'&&t.indexOf("\\")===-1)return t.slice(1,-1);const r=t.trim();if(r.length<=9)switch(r.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(!Yd.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Wd.test(t)||Gd.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Zd)}return JSON.parse(t)}catch(n){if(e.strict)throw n;return t}}function Jd(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function le(t,...e){try{return Jd(t(...e))}catch(r){return Promise.reject(r)}}function Qd(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function eg(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Fn(t){if(Qd(t))return String(t);if(eg(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Fn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const qi="base64:";function tg(t){return typeof t=="string"?t:qi+ig(t)}function rg(t){return typeof t!="string"||!t.startsWith(qi)?t:ng(t.slice(qi.length))}function ng(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function ig(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Ae(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function sg(...t){return Ae(t.join(":"))}function jn(t){return t=Ae(t),t?t+":":""}function og(t,e){if(e===void 0)return!0;let r=0,n=t.indexOf(":");for(;n>-1;)r++,n=t.indexOf(":",n+1);return r<=e}function ag(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}function h8(t){return t}const cg="memory",ug=()=>{const t=new Map;return{name:cg,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function lg(t={}){const e={mounts:{"":t.driver||ug()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const l of e.mountpoints)if(u.startsWith(l))return{base:l,relativeKey:u.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:u,driver:e.mounts[""]}},n=(u,l)=>e.mountpoints.filter(f=>f.startsWith(u)||l&&u.startsWith(f)).map(f=>({relativeBase:u.length>f.length?u.slice(f.length):void 0,mountpoint:f,driver:e.mounts[f]})),i=(u,l)=>{if(e.watching){l=Ae(l);for(const f of e.watchListeners)f(u,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await Sa(e.mounts[u],i,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,l,f)=>{const h=new Map,d=g=>{let p=h.get(g.base);return p||(p={driver:g.driver,base:g.base,items:[]},h.set(g.base,p)),p};for(const g of u){const p=typeof g=="string",m=Ae(p?g:g.key),B=p?void 0:g.value,L=p||!g.options?l:{...l,...g.options},E=r(m);d(E).items.push({key:m,value:B,relativeKey:E.relativeKey,options:L})}return Promise.all([...h.values()].map(g=>f(g))).then(g=>g.flat())},c={hasItem(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return le(h.hasItem,f,l)},getItem(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return le(h.getItem,f,l).then(d=>Un(d))},getItems(u,l={}){return a(u,l,f=>f.driver.getItems?le(f.driver.getItems,f.items.map(h=>({key:h.relativeKey,options:h.options})),l).then(h=>h.map(d=>({key:sg(f.base,d.key),value:Un(d.value)}))):Promise.all(f.items.map(h=>le(f.driver.getItem,h.relativeKey,h.options).then(d=>({key:h.key,value:Un(d)})))))},getItemRaw(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return h.getItemRaw?le(h.getItemRaw,f,l):le(h.getItem,f,l).then(d=>rg(d))},async setItem(u,l,f={}){if(l===void 0)return c.removeItem(u);u=Ae(u);const{relativeKey:h,driver:d}=r(u);d.setItem&&(await le(d.setItem,h,Fn(l),f),d.watch||i("update",u))},async setItems(u,l){await a(u,l,async f=>{if(f.driver.setItems)return le(f.driver.setItems,f.items.map(h=>({key:h.relativeKey,value:Fn(h.value),options:h.options})),l);f.driver.setItem&&await Promise.all(f.items.map(h=>le(f.driver.setItem,h.relativeKey,Fn(h.value),h.options)))})},async setItemRaw(u,l,f={}){if(l===void 0)return c.removeItem(u,f);u=Ae(u);const{relativeKey:h,driver:d}=r(u);if(d.setItemRaw)await le(d.setItemRaw,h,l,f);else if(d.setItem)await le(d.setItem,h,tg(l),f);else return;d.watch||i("update",u)},async removeItem(u,l={}){typeof l=="boolean"&&(l={removeMeta:l}),u=Ae(u);const{relativeKey:f,driver:h}=r(u);h.removeItem&&(await le(h.removeItem,f,l),(l.removeMeta||l.removeMata)&&await le(h.removeItem,f+"$",l),h.watch||i("remove",u))},async getMeta(u,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),u=Ae(u);const{relativeKey:f,driver:h}=r(u),d=Object.create(null);if(h.getMeta&&Object.assign(d,await le(h.getMeta,f,l)),!l.nativeOnly){const g=await le(h.getItem,f+"$",l).then(p=>Un(p));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(d,g))}return d},setMeta(u,l,f={}){return this.setItem(u+"$",l,f)},removeMeta(u,l={}){return this.removeItem(u+"$",l)},async getKeys(u,l={}){u=jn(u);const f=n(u,!0);let h=[];const d=[];let g=!0;for(const m of f){m.driver.flags?.maxDepth||(g=!1);const B=await le(m.driver.getKeys,m.relativeBase,l);for(const L of B){const E=m.mountpoint+Ae(L);h.some(v=>E.startsWith(v))||d.push(E)}h=[m.mountpoint,...h.filter(L=>!L.startsWith(m.mountpoint))]}const p=l.maxDepth!==void 0&&!g;return d.filter(m=>(!p||og(m,l.maxDepth))&&ag(m,u))},async clear(u,l={}){u=jn(u),await Promise.all(n(u,!1).map(async f=>{if(f.driver.clear)return le(f.driver.clear,f.relativeBase,l);if(f.driver.removeItem){const h=await f.driver.getKeys(f.relativeBase||"",l);return Promise.all(h.map(d=>f.driver.removeItem(d,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>Oa(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,l){if(u=jn(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((f,h)=>h.length-f.length)),e.mounts[u]=l,e.watching&&Promise.resolve(Sa(l,i,u)).then(f=>{e.unwatch[u]=f}).catch(console.error),c},async unmount(u,l=!0){u=jn(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u]?.(),delete e.unwatch[u]),l&&await Oa(e.mounts[u]),e.mountpoints=e.mountpoints.filter(f=>f!==u),delete e.mounts[u])},getMount(u=""){u=Ae(u)+":";const l=r(u);return{driver:l.driver,base:l.base}},getMounts(u="",l={}){return u=Ae(u),n(u,l.parents).map(h=>({driver:h.driver,base:h.mountpoint}))},keys:(u,l={})=>c.getKeys(u,l),get:(u,l={})=>c.getItem(u,l),set:(u,l,f={})=>c.setItem(u,l,f),has:(u,l={})=>c.hasItem(u,l),del:(u,l={})=>c.removeItem(u,l),remove:(u,l={})=>c.removeItem(u,l)};return c}function Sa(t,e,r){return t.watch?t.watch((n,i)=>e(n,r+i)):()=>{}}async function Oa(t){typeof t.dispose=="function"&&await le(t.dispose)}function er(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Aa(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const n=er(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}let Wi;function Vr(){return Wi||(Wi=Aa("keyval-store","keyval")),Wi}function Ta(t,e=Vr()){return e("readonly",r=>er(r.get(t)))}function fg(t,e,r=Vr()){return r("readwrite",n=>(n.put(e,t),er(n.transaction)))}function hg(t,e=Vr()){return e("readwrite",r=>(r.delete(t),er(r.transaction)))}function dg(t=Vr()){return t("readwrite",e=>(e.clear(),er(e.transaction)))}function gg(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},er(t.transaction)}function pg(t=Vr()){return t("readonly",e=>{if(e.getAllKeys)return er(e.getAllKeys());const r=[];return gg(e,n=>r.push(n.key)).then(()=>r)})}const yg=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),bg=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,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function yr(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return bg(t)}catch{return t}}function tr(t){return typeof t=="string"?t:yg(t)||""}const wg="idb-keyval";var mg=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=i=>e+i;let n;return t.dbName&&t.storeName&&(n=Aa(t.dbName,t.storeName)),{name:wg,options:t,async hasItem(i){return!(typeof await Ta(r(i),n)>"u")},async getItem(i){return await Ta(r(i),n)??null},setItem(i,s){return fg(r(i),s,n)},removeItem(i){return hg(r(i),n)},getKeys(){return pg(n)},clear(){return dg(n)}}};const Eg="WALLET_CONNECT_V2_INDEXED_DB",vg="keyvaluestorage";class _g{constructor(){this.indexedDb=lg({driver:mg({dbName:Eg,storeName:vg})})}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 r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,tr(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Gi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},zn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Gi<"u"&&Gi.localStorage?zn.exports=Gi.localStorage:typeof window<"u"&&window.localStorage?zn.exports=window.localStorage:zn.exports=new e})();function xg(t){var e;return[t[0],yr((e=t[1])!=null?e:"")]}class Ig{constructor(){this.localStorage=zn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(xg)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return yr(r)}async setItem(e,r){this.localStorage.setItem(e,tr(r))}async removeItem(e){this.localStorage.removeItem(e)}}const Dg="wc_storage_version",Ba=1,Sg=async(t,e,r)=>{const n=Dg,i=await e.getItem(n);if(i&&i>=Ba){r(e);return}const s=await t.getKeys();if(!s.length){r(e);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 u=await t.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(n,Ba),r(e),Og(t,o)},Og=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class Ag{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new Ig;this.storage=e;try{const r=new _g;Sg(e,r,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,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}function Tg(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Bg=Rg;function Rg(t,e,r){var n=r&&r.stringify||Tg,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var a=1;a<s;a++)o[a]=n(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var u="",l=1-i,f=-1,h=t&&t.length||0,d=0;d<h;){if(t.charCodeAt(d)===37&&d+1<h){switch(f=f>-1?f:0,t.charCodeAt(d+1)){case 100:case 102:if(l>=c||e[l]==null)break;f<d&&(u+=t.slice(f,d)),u+=Number(e[l]),f=d+2,d++;break;case 105:if(l>=c||e[l]==null)break;f<d&&(u+=t.slice(f,d)),u+=Math.floor(Number(e[l])),f=d+2,d++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;f<d&&(u+=t.slice(f,d));var g=typeof e[l];if(g==="string"){u+="'"+e[l]+"'",f=d+2,d++;break}if(g==="function"){u+=e[l].name||"<anonymous>",f=d+2,d++;break}u+=n(e[l]),f=d+2,d++;break;case 115:if(l>=c)break;f<d&&(u+=t.slice(f,d)),u+=String(e[l]),f=d+2,d++;break;case 37:f<d&&(u+=t.slice(f,d)),u+="%",f=d+2,d++,l--;break}++l}++d}return f===-1?t:(f<h&&(u+=t.slice(f)),u)}const Ra=Bg;var Rt=ut;const Kr=kg().console||{},Cg={mapHttpRequest:Mn,mapHttpResponse:Mn,wrapRequestSerializer:Zi,wrapResponseSerializer:Zi,wrapErrorSerializer:Zi,req:Mn,res:Mn,err:Ug};function Ng(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function ut(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 r=t.browser.write||Kr;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=Ng(t.browser.serialize,n);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=qr),Object.defineProperty(c,"levelVal",{get:l}),Object.defineProperty(c,"level",{get:f,set:h});const u={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:Fg(t)};c.levels=ut.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=qr,c.serializers=n,c._serialize=i,c._stdErrSerialize=s,c.child=d,e&&(c._logEvent=Yi());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function f(){return this._level}function h(g){if(g!=="silent"&&!this.levels.values[g])throw Error("unknown level "+g);this._level=g,br(u,c,"error","log"),br(u,c,"fatal","error"),br(u,c,"warn","error"),br(u,c,"info","log"),br(u,c,"debug","log"),br(u,c,"trace","log")}function d(g,p){if(!g)throw new Error("missing bindings for child Pino");p=p||{},i&&g.serializers&&(p.serializers=g.serializers);const m=p.serializers;if(i&&m){var B=Object.assign({},n,m),L=t.browser.serialize===!0?Object.keys(B):i;delete g.serializers,kn([g],L,B,this._stdErrSerialize)}function E(v){this._childLevel=(v._childLevel|0)+1,this.error=wr(v,g,"error"),this.fatal=wr(v,g,"fatal"),this.warn=wr(v,g,"warn"),this.info=wr(v,g,"info"),this.debug=wr(v,g,"debug"),this.trace=wr(v,g,"trace"),B&&(this.serializers=B,this._serialize=L),e&&(this._logEvent=Yi([].concat(v._logEvent.bindings,g)))}return E.prototype=this,new E(this)}return c}ut.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"}},ut.stdSerializers=Cg,ut.stdTimeFunctions=Object.assign({},{nullTime:Ca,epochTime:Na,unixTime:jg,isoTime:zg});function br(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?qr:i[r]?i[r]:Kr[r]||Kr[n]||qr,Pg(t,e,r)}function Pg(t,e,r){!t.transmit&&e[r]===qr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Kr?Kr:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&kn(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(a,$g(this,r,o,s)):n.apply(a,o),t.transmit){const u=t.transmit.level||e.level,l=ut.levels.values[u],f=ut.levels.values[r];if(f<l)return;Lg(this,{ts:s,methodLevel:r,methodValue:f,transmitLevel:u,transmitValue:ut.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function $g(t,e,r,n){t._serialize&&kn(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const o={};n&&(o.time=n),o.level=ut.levels.values[e];let a=(t._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?Ra(i.shift(),i):void 0}else typeof s=="string"&&(s=Ra(i.shift(),i));return s!==void 0&&(o.msg=s),o}function kn(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=ut.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(const s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function wr(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function Lg(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;kn(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(u){return c.indexOf(u)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,n(s,t._logEvent,a),t._logEvent=Yi(c)}function Yi(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Ug(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function Fg(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ca:Na}function Mn(){return{}}function Zi(t){return t}function qr(){}function Ca(){return!1}function Na(){return Date.now()}function jg(){return Math.round(Date.now()/1e3)}function zg(){return new Date(Date.now()).toISOString()}function kg(){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 Mg={level:"info"},Wr="custom_context",Xi=1e3*1024;class Hg{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}}class Pa{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new Hg(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.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 r=this.head;for(;r!==null;)e.push(r.value),r=r.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 r=e.value;return e=e.next,{done:!1,value:r}}}}}class $a{constructor(e,r=Xi){this.level=e??"error",this.levelValue=Rt.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Pa(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Rt.levels.values.error?console.error(e):r===Rt.levels.values.warn?console.warn(e):r===Rt.levels.values.debug?console.debug(e):r===Rt.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(tr({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Pa(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(tr({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class Vg{constructor(e,r=Xi){this.baseChunkLogger=new $a(e,r)}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 r=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=r,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}}class Kg{constructor(e,r=Xi){this.baseChunkLogger=new $a(e,r)}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 qg=Object.defineProperty,Wg=Object.defineProperties,Gg=Object.getOwnPropertyDescriptors,La=Object.getOwnPropertySymbols,Yg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?qg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hn=(t,e)=>{for(var r in e||(e={}))Yg.call(e,r)&&Ua(t,r,e[r]);if(La)for(var r of La(e))Zg.call(e,r)&&Ua(t,r,e[r]);return t},Vn=(t,e)=>Wg(t,Gg(e));function Fa(t){return Vn(Hn({},t),{level:t?.level||Mg.level})}function Xg(t,e=Wr){return t[e]||""}function Jg(t,e,r=Wr){return t[r]=e,t}function je(t,e=Wr){let r="";return typeof t.bindings>"u"?r=Xg(t,e):r=t.bindings().context||"",r}function Qg(t,e,r=Wr){const n=je(t,r);return n.trim()?`${n}/${e}`:e}function Te(t,e,r=Wr){const n=Qg(t,e,r),i=t.child({context:n});return Jg(i,n,r)}function ep(t){var e,r;const n=new Vg((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Rt(Vn(Hn({},t.opts),{level:"trace",browser:Vn(Hn({},(r=t.opts)==null?void 0:r.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function tp(t){var e;const r=new Kg((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Rt(Vn(Hn({},t.opts),{level:"trace"})),chunkLoggerController:r}}function rp(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?ep(t):tp(t)}var np=Object.defineProperty,ip=(t,e,r)=>e in t?np(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ja=(t,e,r)=>ip(t,typeof e!="symbol"?e+"":e,r);class sp extends Jt{constructor(e){super(),this.opts=e,ja(this,"protocol","wc"),ja(this,"version",2)}}var op=Object.defineProperty,ap=(t,e,r)=>e in t?op(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cp=(t,e,r)=>ap(t,typeof e!="symbol"?e+"":e,r);class up extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,cp(this,"records",new Map)}}class lp{constructor(e,r){this.logger=e,this.core=r}}class fp extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class hp extends Jt{constructor(e){super()}}class dp{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class gp extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pp extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}class yp{constructor(e,r,n){this.core=e,this.logger=r,this.store=n}}class bp{constructor(e,r){this.projectId=e,this.logger=r}}class wp{constructor(e,r,n){this.core=e,this.logger=r,this.telemetryEnabled=n}}const Ji="wc",Qi=2,Gr="core",rt=`${Ji}@2:${Gr}:`,za={name:Gr,logger:"error"},ka={database:":memory:"},Ma="crypto",es="client_ed25519_seed",Ha=V.ONE_DAY,Va="keychain",Ka="0.3",qa="messages",Wa="0.3",Ga=V.SIX_HOURS,Ya="publisher",Za="irn",Xa="error",ts="wss://relay.walletconnect.org",Ja="relayer",oe={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"},Qa="_subscription",ze={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},ec=.1,mp={database:":memory:"},Kn="2.21.8",Ep=1e4,rr={link_mode:"link_mode",relay:"relay"},Yr={inbound:"inbound",outbound:"outbound"},tc="0.3",rc="WALLETCONNECT_CLIENT_ID",rs="WALLETCONNECT_LINK_MODE_APPS",Be={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},vp=V.THIRTY_DAYS,nc="subscription",ic="0.3",_p=V.FIVE_SECONDS*1e3,sc="pairing",oc="0.3",xp=V.THIRTY_DAYS,mr={wc_pairingDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:V.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:V.ONE_DAY,prompt:!1,tag:0},res:{ttl:V.ONE_DAY,prompt:!1,tag:0}}},Er={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},We={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},ac="history",cc="0.3",uc="expirer",Ge={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},lc="0.3",Ip=V.ONE_DAY,fc="verify-api",Dp="https://verify.walletconnect.com",hc="https://verify.walletconnect.org",Zr=hc,dc=`${Zr}/v3`,gc=[Dp,hc],pc="echo",yc="https://echo.walletconnect.com",Sp="event-client",lt={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"},wt={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"},Op={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"},Ap={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"},Tp={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"},Bp={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"},bc=.1,wc="event-client",mc=86400,Ec="https://pulse.walletconnect.org/batch";function Rp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function vc(t,...e){if(!Rp(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 _c(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 Cp(t,e){vc(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const vr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ns=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Np(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function xc(t){return typeof t=="string"&&(t=Np(t)),vc(t),t}class Pp{clone(){return this._cloneInto()}}function $p(t){const e=n=>t().update(xc(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ic(t=32){if(vr&&typeof vr.getRandomValues=="function")return vr.getRandomValues(new Uint8Array(t));if(vr&&typeof vr.randomBytes=="function")return vr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Lp(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,u=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+u,a,n)}class Up extends Pp{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ns(this.buffer)}update(e){_c(this);const{view:r,buffer:n,blockLen:i}=this;e=xc(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=ns(e