@walletconnect/core
Version:
Core for WalletConnect Protocol
14 lines (12 loc) • 328 kB
JavaScript
(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 sa(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,oa=gr&&typeof gr.apply=="function"?gr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Cn;gr&&typeof gr.ownKeys=="function"?Cn=gr.ownKeys:Object.getOwnPropertySymbols?Cn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Cn=function(e){return Object.getOwnPropertyNames(e)};function hd(t){console&&console.warn&&console.warn(t)}var aa=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 ca=10;function Nn(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 ca},set:function(t){if(typeof t!="number"||t<0||aa(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ca=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||aa(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 ua(t){return t._maxListeners===void 0?ee.defaultMaxListeners:t._maxListeners}ee.prototype.getMaxListeners=function(){return ua(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")oa(c,this,r);else for(var u=c.length,l=ga(c,u),n=0;n<u;++n)oa(l[n],this,r);return!0};function la(t,e,r,n){var i,s,o;if(Nn(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=ua(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 la(this,e,r,!1)},ee.prototype.on=ee.prototype.addListener,ee.prototype.prependListener=function(e,r){return la(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 fa(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 Nn(r),this.on(e,fa(this,e,r)),this},ee.prototype.prependOnceListener=function(e,r){return Nn(r),this.prependListener(e,fa(this,e,r)),this},ee.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Nn(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 ha(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):ga(i,i.length)}ee.prototype.listeners=function(e){return ha(this,e,!0)},ee.prototype.rawListeners=function(e){return ha(this,e,!1)},ee.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):da.call(t,e)},ee.prototype.listenerCount=da;function da(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?Cn(this._events):[]};function ga(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))}pa(t,e,s,{once:!0}),e!=="error"&&bd(t,i,{once:!0})})}function bd(t,e,r){typeof t.on=="function"&&pa(t,"error",e,r)}function pa(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 Ui=function(t,e){return Ui=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])},Ui(t,e)};function wd(t,e){Ui(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Fi=function(){return Fi=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},Fi.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 Dd(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 Id(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 ji(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 ya(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(ya(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 Fr(t){return this instanceof Fr?(this.v=t,this):new Fr(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(g){return new Promise(function(d,p){s.push([h,g,d,p])>1||a(h,g)})})}function a(h,g){try{c(n[h](g))}catch(d){f(s[0][3],d)}}function c(h){h.value instanceof Fr?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,g){h(g),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:Fr(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 ji=="function"?ji(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 Fi},__rest:md,__decorate:Ed,__param:vd,__metadata:_d,__awaiter:xd,__generator:Dd,__createBinding:Id,__exportStar:Sd,__values:ji,__read:ya,__spread:Od,__spreadArrays:Ad,__await:Fr,__asyncGenerator:Td,__asyncDelegator:Bd,__asyncValues:Rd,__makeTemplateObject:Cd,__importStar:Nd,__importDefault:Pd,__classPrivateFieldGet:$d,__classPrivateFieldSet:Ld}),Pn=sa(Ud),zi={},jr={},ba;function Fd(){if(ba)return jr;ba=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return jr.delay=t,jr}var Zt={},ki={},Xt={},wa;function jd(){return wa||(wa=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 Mi={},ma;function zd(){return ma||(ma=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}(Mi)),Mi}var Ea;function va(){return Ea||(Ea=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Pn;e.__exportStar(jd(),t),e.__exportStar(zd(),t)}(ki)),ki}var _a;function kd(){if(_a)return Zt;_a=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.fromMiliseconds=Zt.toMiliseconds=void 0;const t=va();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 xa;function Md(){return xa||(xa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Pn;e.__exportStar(Fd(),t),e.__exportStar(kd(),t)}(zi)),zi}var pr={},Da;function Hd(){if(Da)return pr;Da=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 Hi={},zr={},Ia;function Vd(){if(Ia)return zr;Ia=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.IWatch=void 0;class t{}return zr.IWatch=t,zr}var Sa;function Kd(){return Sa||(Sa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Pn.__exportStar(Vd(),t)}(Hi)),Hi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Pn;e.__exportStar(Md(),t),e.__exportStar(Hd(),t),e.__exportStar(Kd(),t),e.__exportStar(va(),t)})(V);class Jt{}class qd extends Jt{constructor(e){super()}}const Oa=V.FIVE_SECONDS,Qt={pulse:"heartbeat_pulse"};class Vi extends qd{constructor(e){super(e),this.events=new qe.exports.EventEmitter,this.interval=Oa,this.interval=e?.interval||Oa}static async init(e){const r=new Vi(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 $n(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 ue(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 Ln(t){if(Qd(t))return String(t);if(eg(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Ln(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ki="base64:";function tg(t){return typeof t=="string"?t:Ki+ig(t)}function rg(t){return typeof t!="string"||!t.startsWith(Ki)?t:ng(t.slice(Ki.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 Un(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 Aa(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,g=d=>{let p=h.get(d.base);return p||(p={driver:d.driver,base:d.base,items:[]},h.set(d.base,p)),p};for(const d of u){const p=typeof d=="string",m=Ae(p?d:d.key),R=p?void 0:d.value,P=p||!d.options?l:{...l,...d.options},E=r(m);g(E).items.push({key:m,value:R,relativeKey:E.relativeKey,options:P})}return Promise.all([...h.values()].map(d=>f(d))).then(d=>d.flat())},c={hasItem(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return ue(h.hasItem,f,l)},getItem(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return ue(h.getItem,f,l).then(g=>$n(g))},getItems(u,l={}){return a(u,l,f=>f.driver.getItems?ue(f.driver.getItems,f.items.map(h=>({key:h.relativeKey,options:h.options})),l).then(h=>h.map(g=>({key:sg(f.base,g.key),value:$n(g.value)}))):Promise.all(f.items.map(h=>ue(f.driver.getItem,h.relativeKey,h.options).then(g=>({key:h.key,value:$n(g)})))))},getItemRaw(u,l={}){u=Ae(u);const{relativeKey:f,driver:h}=r(u);return h.getItemRaw?ue(h.getItemRaw,f,l):ue(h.getItem,f,l).then(g=>rg(g))},async setItem(u,l,f={}){if(l===void 0)return c.removeItem(u);u=Ae(u);const{relativeKey:h,driver:g}=r(u);g.setItem&&(await ue(g.setItem,h,Ln(l),f),g.watch||i("update",u))},async setItems(u,l){await a(u,l,async f=>{if(f.driver.setItems)return ue(f.driver.setItems,f.items.map(h=>({key:h.relativeKey,value:Ln(h.value),options:h.options})),l);f.driver.setItem&&await Promise.all(f.items.map(h=>ue(f.driver.setItem,h.relativeKey,Ln(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:g}=r(u);if(g.setItemRaw)await ue(g.setItemRaw,h,l,f);else if(g.setItem)await ue(g.setItem,h,tg(l),f);else return;g.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 ue(h.removeItem,f,l),(l.removeMeta||l.removeMata)&&await ue(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),g=Object.create(null);if(h.getMeta&&Object.assign(g,await ue(h.getMeta,f,l)),!l.nativeOnly){const d=await ue(h.getItem,f+"$",l).then(p=>$n(p));d&&typeof d=="object"&&(typeof d.atime=="string"&&(d.atime=new Date(d.atime)),typeof d.mtime=="string"&&(d.mtime=new Date(d.mtime)),Object.assign(g,d))}return g},setMeta(u,l,f={}){return this.setItem(u+"$",l,f)},removeMeta(u,l={}){return this.removeItem(u+"$",l)},async getKeys(u,l={}){u=Un(u);const f=n(u,!0);let h=[];const g=[];let d=!0;for(const m of f){m.driver.flags?.maxDepth||(d=!1);const R=await ue(m.driver.getKeys,m.relativeBase,l);for(const P of R){const E=m.mountpoint+Ae(P);h.some(_=>E.startsWith(_))||g.push(E)}h=[m.mountpoint,...h.filter(P=>!P.startsWith(m.mountpoint))]}const p=l.maxDepth!==void 0&&!d;return g.filter(m=>(!p||og(m,l.maxDepth))&&ag(m,u))},async clear(u,l={}){u=Un(u),await Promise.all(n(u,!1).map(async f=>{if(f.driver.clear)return ue(f.driver.clear,f.relativeBase,l);if(f.driver.removeItem){const h=await f.driver.getKeys(f.relativeBase||"",l);return Promise.all(h.map(g=>f.driver.removeItem(g,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>Ta(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=Un(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(Aa(l,i,u)).then(f=>{e.unwatch[u]=f}).catch(console.error),c},async unmount(u,l=!0){u=Un(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u]?.(),delete e.unwatch[u]),l&&await Ta(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 Aa(t,e,r){return t.watch?t.watch((n,i)=>e(n,r+i)):()=>{}}async function Ta(t){typeof t.dispose=="function"&&await ue(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 Ba(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 qi;function kr(){return qi||(qi=Ba("keyval-store","keyval")),qi}function Ra(t,e=kr()){return e("readonly",r=>er(r.get(t)))}function fg(t,e,r=kr()){return r("readwrite",n=>(n.put(e,t),er(n.transaction)))}function hg(t,e=kr()){return e("readwrite",r=>(r.delete(t),er(r.transaction)))}function dg(t=kr()){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=kr()){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=Ba(t.dbName,t.storeName)),{name:wg,options:t,async hasItem(i){return!(typeof await Ra(r(i),n)>"u")},async getItem(i){return await Ra(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 Wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Fn={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 Wi<"u"&&Wi.localStorage?Fn.exports=Wi.localStorage:typeof window<"u"&&window.localStorage?Fn.exports=window.localStorage:Fn.exports=new e})();function xg(t){var e;return[t[0],yr((e=t[1])!=null?e:"")]}class Dg{constructor(){this.localStorage=Fn.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 Ig="wc_storage_version",Ca=1,Sg=async(t,e,r)=>{const n=Ig,i=await e.getItem(n);if(i&&i>=Ca){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,Ca),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 Dg;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,g=0;g<h;){if(t.charCodeAt(g)===37&&g+1<h){switch(f=f>-1?f:0,t.charCodeAt(g+1)){case 100:case 102:if(l>=c||e[l]==null)break;f<g&&(u+=t.slice(f,g)),u+=Number(e[l]),f=g+2,g++;break;case 105:if(l>=c||e[l]==null)break;f<g&&(u+=t.slice(f,g)),u+=Math.floor(Number(e[l])),f=g+2,g++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;f<g&&(u+=t.slice(f,g));var d=typeof e[l];if(d==="string"){u+="'"+e[l]+"'",f=g+2,g++;break}if(d==="function"){u+=e[l].name||"<anonymous>",f=g+2,g++;break}u+=n(e[l]),f=g+2,g++;break;case 115:if(l>=c)break;f<g&&(u+=t.slice(f,g)),u+=String(e[l]),f=g+2,g++;break;case 37:f<g&&(u+=t.slice(f,g)),u+="%",f=g+2,g++,l--;break}++l}++g}return f===-1?t:(f<h&&(u+=t.slice(f)),u)}const Na=Bg;var Bt=ut;const Mr=kg().console||{},Cg={mapHttpRequest:zn,mapHttpResponse:zn,wrapRequestSerializer:Yi,wrapResponseSerializer:Yi,wrapErrorSerializer:Yi,req:zn,res:zn,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||Mr;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=Hr),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=Hr,c.serializers=n,c._serialize=i,c._stdErrSerialize=s,c.child=g,e&&(c._logEvent=Gi());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function f(){return this._level}function h(d){if(d!=="silent"&&!this.levels.values[d])throw Error("unknown level "+d);this._level=d,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 g(d,p){if(!d)throw new Error("missing bindings for child Pino");p=p||{},i&&d.serializers&&(p.serializers=d.serializers);const m=p.serializers;if(i&&m){var R=Object.assign({},n,m),P=t.browser.serialize===!0?Object.keys(R):i;delete d.serializers,jn([d],P,R,this._stdErrSerialize)}function E(_){this._childLevel=(_._childLevel|0)+1,this.error=wr(_,d,"error"),this.fatal=wr(_,d,"fatal"),this.warn=wr(_,d,"warn"),this.info=wr(_,d,"info"),this.debug=wr(_,d,"debug"),this.trace=wr(_,d,"trace"),R&&(this.serializers=R,this._serialize=P),e&&(this._logEvent=Gi([].concat(_._logEvent.bindings,d)))}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:Pa,epochTime:$a,unixTime:jg,isoTime:zg});function br(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Hr:i[r]?i[r]:Mr[r]||Mr[n]||Hr,Pg(t,e,r)}function Pg(t,e,r){!t.transmit&&e[r]===Hr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Mr?Mr:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&jn(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&&jn(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?Na(i.shift(),i):void 0}else typeof s=="string"&&(s=Na(i.shift(),i));return s!==void 0&&(o.msg=s),o}function jn(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;jn(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=Gi(c)}function Gi(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?Pa:$a}function zn(){return{}}function Yi(t){return t}function Hr(){}function Pa(){return!1}function $a(){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"},Vr="custom_context",Zi=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 La{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 Ua{constructor(e,r=Zi){this.level=e??"error",this.levelValue=Bt.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new La(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Bt.levels.values.error?console.error(e):r===Bt.levels.values.warn?console.warn(e):r===Bt.levels.values.debug?console.debug(e):r===Bt.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 La(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=Zi){this.baseChunkLogger=new Ua(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=Zi){this.baseChunkLogger=new Ua(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,Fa=Object.getOwnPropertySymbols,Yg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,ja=(t,e,r)=>e in t?qg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kn=(t,e)=>{for(var r in e||(e={}))Yg.call(e,r)&&ja(t,r,e[r]);if(Fa)for(var r of Fa(e))Zg.call(e,r)&&ja(t,r,e[r]);return t},Mn=(t,e)=>Wg(t,Gg(e));function za(t){return Mn(kn({},t),{level:t?.level||Mg.level})}function Xg(t,e=Vr){return t[e]||""}function Jg(t,e,r=Vr){return t[r]=e,t}function je(t,e=Vr){let r="";return typeof t.bindings>"u"?r=Xg(t,e):r=t.bindings().context||"",r}function Qg(t,e,r=Vr){const n=je(t,r);return n.trim()?`${n}/${e}`:e}function Te(t,e,r=Vr){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:Bt(Mn(kn({},t.opts),{level:"trace",browser:Mn(kn({},(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:Bt(Mn(kn({},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,ka=(t,e,r)=>ip(t,typeof e!="symbol"?e+"":e,r);class sp extends Jt{constructor(e){super(),this.opts=e,ka(this,"protocol","wc"),ka(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 Xi="wc",Ji=2,Kr="core",tt=`${Xi}@2:${Kr}:`,Ma={name:Kr,logger:"error"},Ha={database:":memory:"},Va="crypto",Qi="client_ed25519_seed",Ka=V.ONE_DAY,qa="keychain",Wa="0.3",Ga="messages",Ya="0.3",es=V.SIX_HOURS,Za="publisher",Xa="irn",Ja="error",ts="wss://relay.walletconnect.org",Qa="relayer",de={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"},ec="_subscription",ze={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},tc=.1,mp={database:":memory:"},Hn="2.21.3",Ep=1e4,rr={link_mode:"link_mode",relay:"relay"},qr={inbound:"inbound",outbound:"outbound"},rc="0.3",nc="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,ic="subscription",sc="0.3",_p=V.FIVE_SECONDS*1e3,oc="pairing",ac="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"},cc="history",uc="0.3",lc="expirer",Ge={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},fc="0.3",Dp=V.ONE_DAY,hc="verify-api",Ip="https://verify.walletconnect.com",dc="https://verify.walletconnect.org",Wr=dc,gc=`${Wr}/v3`,pc=[Ip,dc],yc="echo",bc="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"},bt={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"},wc=.1,mc="event-client",Ec=86400,vc="https://pulse.walletconnect.org/batch";function Rp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function _c(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 xc(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){_c(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 Dc(t){return typeof t=="string"&&(t=Np(t)),_c(t),t}class Pp{clone(){return this._cloneInto()}}function $p(t){const e=n=>t().update(Dc(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){xc(this);const{view:r,buffer:n,blockLen:i}=this;e=Dc(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