;
! function() {
    try {
        var e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof window ? window : "undefined" != typeof self ? self : {},
            n = (new e.Error).stack;
        n && ((e._debugIds || (e._debugIds = {}))[n] = "bc7ea281-0571-6388-e7b0-a3bf188c64a3")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 379666, (e, t, i) => {
    "use strict";
    var r, s = "object" == typeof Reflect ? Reflect : null,
        n = s && "function" == typeof s.apply ? s.apply : function(e, t, i) {
            return Function.prototype.apply.call(e, t, i)
        };
    r = s && "function" == typeof s.ownKeys ? s.ownKeys : Object.getOwnPropertySymbols ? function(e) {
        return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))
    } : function(e) {
        return Object.getOwnPropertyNames(e)
    };
    var o = Number.isNaN || function(e) {
        return e != e
    };

    function a() {
        a.init.call(this)
    }
    t.exports = a, t.exports.once = function(e, t) {
        return new Promise(function(i, r) {
            var s, n, o;

            function a(i) {
                e.removeListener(t, l), r(i)
            }

            function l() {
                "function" == typeof e.removeListener && e.removeListener("error", a), i([].slice.call(arguments))
            }
            m(e, t, l, {
                once: !0
            }), "error" !== t && (s = e, n = a, o = {
                once: !0
            }, "function" == typeof s.on && m(s, "error", n, o))
        })
    }, a.EventEmitter = a, a.prototype._events = void 0, a.prototype._eventsCount = 0, a.prototype._maxListeners = void 0;
    var l = 10;

    function c(e) {
        if ("function" != typeof e) throw TypeError('The "listener" argument must be of type Function. Received type ' + typeof e)
    }

    function h(e) {
        return void 0 === e._maxListeners ? a.defaultMaxListeners : e._maxListeners
    }

    function u(e, t, i, r) {
        if (c(i), void 0 === (n = e._events) ? (n = e._events = Object.create(null), e._eventsCount = 0) : (void 0 !== n.newListener && (e.emit("newListener", t, i.listener ? i.listener : i), n = e._events), o = n[t]), void 0 === o) o = n[t] = i, ++e._eventsCount;
        else if ("function" == typeof o ? o = n[t] = r ? [i, o] : [o, i] : r ? o.unshift(i) : o.push(i), (s = h(e)) > 0 && o.length > s && !o.warned) {
            o.warned = !0;
            var s, n, o, a = Error("Possible EventEmitter memory leak detected. " + o.length + " " + String(t) + " listeners added. Use emitter.setMaxListeners() to increase limit");
            a.name = "MaxListenersExceededWarning", a.emitter = e, a.type = t, a.count = o.length, console && console.warn && console.warn(a)
        }
        return e
    }

    function d() {
        if (!this.fired) return (this.target.removeListener(this.type, this.wrapFn), this.fired = !0, 0 == arguments.length) ? this.listener.call(this.target) : this.listener.apply(this.target, arguments)
    }

    function p(e, t, i) {
        var r = {
                fired: !1,
                wrapFn: void 0,
                target: e,
                type: t,
                listener: i
            },
            s = d.bind(r);
        return s.listener = i, r.wrapFn = s, s
    }

    function f(e, t, i) {
        var r = e._events;
        if (void 0 === r) return [];
        var s = r[t];
        return void 0 === s ? [] : "function" == typeof s ? i ? [s.listener || s] : [s] : i ? function(e) {
            for (var t = Array(e.length), i = 0; i < t.length; ++i) t[i] = e[i].listener || e[i];
            return t
        }(s) : y(s, s.length)
    }

    function g(e) {
        var t = this._events;
        if (void 0 !== t) {
            var i = t[e];
            if ("function" == typeof i) return 1;
            if (void 0 !== i) return i.length
        }
        return 0
    }

    function y(e, t) {
        for (var i = Array(t), r = 0; r < t; ++r) i[r] = e[r];
        return i
    }

    function m(e, t, i, r) {
        if ("function" == typeof e.on) r.once ? e.once(t, i) : e.on(t, i);
        else if ("function" == typeof e.addEventListener) e.addEventListener(t, function s(n) {
            r.once && e.removeEventListener(t, s), i(n)
        });
        else throw TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof e)
    }
    Object.defineProperty(a, "defaultMaxListeners", {
        enumerable: !0,
        get: function() {
            return l
        },
        set: function(e) {
            if ("number" != typeof e || e < 0 || o(e)) throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + e + ".");
            l = e
        }
    }), a.init = function() {
        (void 0 === this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0
    }, a.prototype.setMaxListeners = function(e) {
        if ("number" != typeof e || e < 0 || o(e)) throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
        return this._maxListeners = e, this
    }, a.prototype.getMaxListeners = function() {
        return h(this)
    }, a.prototype.emit = function(e) {
        for (var t = [], i = 1; i < arguments.length; i++) t.push(arguments[i]);
        var r = "error" === e,
            s = this._events;
        if (void 0 !== s) r = r && void 0 === s.error;
        else if (!r) return !1;
        if (r) {
            if (t.length > 0 && (o = t[0]), o instanceof Error) throw o;
            var o, a = Error("Unhandled error." + (o ? " (" + o.message + ")" : ""));
            throw a.context = o, a
        }
        var l = s[e];
        if (void 0 === l) return !1;
        if ("function" == typeof l) n(l, this, t);
        else
            for (var c = l.length, h = y(l, c), i = 0; i < c; ++i) n(h[i], this, t);
        return !0
    }, a.prototype.addListener = function(e, t) {
        return u(this, e, t, !1)
    }, a.prototype.on = a.prototype.addListener, a.prototype.prependListener = function(e, t) {
        return u(this, e, t, !0)
    }, a.prototype.once = function(e, t) {
        return c(t), this.on(e, p(this, e, t)), this
    }, a.prototype.prependOnceListener = function(e, t) {
        return c(t), this.prependListener(e, p(this, e, t)), this
    }, a.prototype.removeListener = function(e, t) {
        var i, r, s, n, o;
        if (c(t), void 0 === (r = this._events) || void 0 === (i = r[e])) return this;
        if (i === t || i.listener === t) 0 == --this._eventsCount ? this._events = Object.create(null) : (delete r[e], r.removeListener && this.emit("removeListener", e, i.listener || t));
        else if ("function" != typeof i) {
            for (s = -1, n = i.length - 1; n >= 0; n--)
                if (i[n] === t || i[n].listener === t) {
                    o = i[n].listener, s = n;
                    break
                }
            if (s < 0) return this;
            0 === s ? i.shift() : function(e, t) {
                for (; t + 1 < e.length; t++) e[t] = e[t + 1];
                e.pop()
            }(i, s), 1 === i.length && (r[e] = i[0]), void 0 !== r.removeListener && this.emit("removeListener", e, o || t)
        }
        return this
    }, a.prototype.off = a.prototype.removeListener, a.prototype.removeAllListeners = function(e) {
        var t, i, r;
        if (void 0 === (i = this._events)) return this;
        if (void 0 === i.removeListener) return 0 == arguments.length ? (this._events = Object.create(null), this._eventsCount = 0) : void 0 !== i[e] && (0 == --this._eventsCount ? this._events = Object.create(null) : delete i[e]), this;
        if (0 == arguments.length) {
            var s, n = Object.keys(i);
            for (r = 0; r < n.length; ++r) "removeListener" !== (s = n[r]) && this.removeAllListeners(s);
            return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this
        }
        if ("function" == typeof(t = i[e])) this.removeListener(e, t);
        else if (void 0 !== t)
            for (r = t.length - 1; r >= 0; r--) this.removeListener(e, t[r]);
        return this
    }, a.prototype.listeners = function(e) {
        return f(this, e, !0)
    }, a.prototype.rawListeners = function(e) {
        return f(this, e, !1)
    }, a.listenerCount = function(e, t) {
        return "function" == typeof e.listenerCount ? e.listenerCount(t) : g.call(e, t)
    }, a.prototype.listenerCount = g, a.prototype.eventNames = function() {
        return this._eventsCount > 0 ? r(this._events) : []
    }
}, 575824, e => {
    "use strict";
    var t = function(e, i) {
            return (t = Object.setPrototypeOf || ({
                __proto__: []
            }) instanceof Array && function(e, t) {
                e.__proto__ = t
            } || function(e, t) {
                for (var i in t) t.hasOwnProperty(i) && (e[i] = t[i])
            })(e, i)
        },
        i = function() {
            return (i = Object.assign || function(e) {
                for (var t, i = 1, r = arguments.length; i < r; i++)
                    for (var s in t = arguments[i]) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s]);
                return e
            }).apply(this, arguments)
        };

    function r(e) {
        var t = "function" == typeof Symbol && Symbol.iterator,
            i = t && e[t],
            r = 0;
        if (i) return i.call(e);
        if (e && "number" == typeof e.length) return {
            next: function() {
                return e && r >= e.length && (e = void 0), {
                    value: e && e[r++],
                    done: !e
                }
            }
        };
        throw TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.")
    }

    function s(e, t) {
        var i = "function" == typeof Symbol && e[Symbol.iterator];
        if (!i) return e;
        var r, s, n = i.call(e),
            o = [];
        try {
            for (;
                (void 0 === t || t-- > 0) && !(r = n.next()).done;) o.push(r.value)
        } catch (e) {
            s = {
                error: e
            }
        } finally {
            try {
                r && !r.done && (i = n.return) && i.call(n)
            } finally {
                if (s) throw s.error
            }
        }
        return o
    }

    function n(e) {
        return this instanceof n ? (this.v = e, this) : new n(e)
    }
    e.s(["__assign", () => i, "__asyncDelegator", 0, function(e) {
        var t, i;
        return t = {}, r("next"), r("throw", function(e) {
            throw e
        }), r("return"), t[Symbol.iterator] = function() {
            return this
        }, t;

        function r(r, s) {
            t[r] = e[r] ? function(t) {
                return (i = !i) ? {
                    value: n(e[r](t)),
                    done: "return" === r
                } : s ? s(t) : t
            } : s
        }
    }, "__asyncGenerator", 0, function(e, t, i) {
        if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
        var r, s = i.apply(e, t || []),
            o = [];
        return r = {}, a("next"), a("throw"), a("return"), r[Symbol.asyncIterator] = function() {
            return this
        }, r;

        function a(e) {
            s[e] && (r[e] = function(t) {
                return new Promise(function(i, r) {
                    o.push([e, t, i, r]) > 1 || l(e, t)
                })
            })
        }

        function l(e, t) {
            try {
                var i;
                (i = s[e](t)).value instanceof n ? Promise.resolve(i.value.v).then(c, h) : u(o[0][2], i)
            } catch (e) {
                u(o[0][3], e)
            }
        }

        function c(e) {
            l("next", e)
        }

        function h(e) {
            l("throw", e)
        }

        function u(e, t) {
            e(t), o.shift(), o.length && l(o[0][0], o[0][1])
        }
    }, "__asyncValues", 0, function(e) {
        if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
        var t, i = e[Symbol.asyncIterator];
        return i ? i.call(e) : (e = r(e), t = {}, s("next"), s("throw"), s("return"), t[Symbol.asyncIterator] = function() {
            return this
        }, t);

        function s(i) {
            t[i] = e[i] && function(t) {
                return new Promise(function(r, s) {
                    var n, o, a;
                    n = r, o = s, a = (t = e[i](t)).done, Promise.resolve(t.value).then(function(e) {
                        n({
                            value: e,
                            done: a
                        })
                    }, o)
                })
            }
        }
    }, "__await", 0, n, "__awaiter", 0, function(e, t, i, r) {
        return new(i || (i = Promise))(function(s, n) {
            function o(e) {
                try {
                    l(r.next(e))
                } catch (e) {
                    n(e)
                }
            }

            function a(e) {
                try {
                    l(r.throw(e))
                } catch (e) {
                    n(e)
                }
            }

            function l(e) {
                var t;
                e.done ? s(e.value) : ((t = e.value) instanceof i ? t : new i(function(e) {
                    e(t)
                })).then(o, a)
            }
            l((r = r.apply(e, t || [])).next())
        })
    }, "__classPrivateFieldGet", 0, function(e, t) {
        if (!t.has(e)) throw TypeError("attempted to get private field on non-instance");
        return t.get(e)
    }, "__classPrivateFieldSet", 0, function(e, t, i) {
        if (!t.has(e)) throw TypeError("attempted to set private field on non-instance");
        return t.set(e, i), i
    }, "__createBinding", 0, function(e, t, i, r) {
        void 0 === r && (r = i), e[r] = t[i]
    }, "__decorate", 0, function(e, t, i, r) {
        var s, n = arguments.length,
            o = n < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o = Reflect.decorate(e, t, i, r);
        else
            for (var a = e.length - 1; a >= 0; a--)(s = e[a]) && (o = (n < 3 ? s(o) : n > 3 ? s(t, i, o) : s(t, i)) || o);
        return n > 3 && o && Object.defineProperty(t, i, o), o
    }, "__exportStar", 0, function(e, t) {
        for (var i in e) "default" === i || t.hasOwnProperty(i) || (t[i] = e[i])
    }, "__extends", 0, function(e, i) {
        function r() {
            this.constructor = e
        }
        t(e, i), e.prototype = null === i ? Object.create(i) : (r.prototype = i.prototype, new r)
    }, "__generator", 0, function(e, t) {
        var i, r, s, n, o = {
            label: 0,
            sent: function() {
                if (1 & s[0]) throw s[1];
                return s[1]
            },
            trys: [],
            ops: []
        };
        return n = {
            next: a(0),
            throw: a(1),
            return: a(2)
        }, "function" == typeof Symbol && (n[Symbol.iterator] = function() {
            return this
        }), n;

        function a(n) {
            return function(a) {
                var l = [n, a];
                if (i) throw TypeError("Generator is already executing.");
                for (; o;) try {
                    if (i = 1, r && (s = 2 & l[0] ? r.return : l[0] ? r.throw || ((s = r.return) && s.call(r), 0) : r.next) && !(s = s.call(r, l[1])).done) return s;
                    switch (r = 0, s && (l = [2 & l[0], s.value]), l[0]) {
                        case 0:
                        case 1:
                            s = l;
                            break;
                        case 4:
                            return o.label++, {
                                value: l[1],
                                done: !1
                            };
                        case 5:
                            o.label++, r = l[1], l = [0];
                            continue;
                        case 7:
                            l = o.ops.pop(), o.trys.pop();
                            continue;
                        default:
                            if (!(s = (s = o.trys).length > 0 && s[s.length - 1]) && (6 === l[0] || 2 === l[0])) {
                                o = 0;
                                continue
                            }
                            if (3 === l[0] && (!s || l[1] > s[0] && l[1] < s[3])) {
                                o.label = l[1];
                                break
                            }
                            if (6 === l[0] && o.label < s[1]) {
                                o.label = s[1], s = l;
                                break
                            }
                            if (s && o.label < s[2]) {
                                o.label = s[2], o.ops.push(l);
                                break
                            }
                            s[2] && o.ops.pop(), o.trys.pop();
                            continue
                    }
                    l = t.call(e, o)
                } catch (e) {
                    l = [6, e], r = 0
                } finally {
                    i = s = 0
                }
                if (5 & l[0]) throw l[1];
                return {
                    value: l[0] ? l[1] : void 0,
                    done: !0
                }
            }
        }
    }, "__importDefault", 0, function(e) {
        return e && e.__esModule ? e : {
            default: e
        }
    }, "__importStar", 0, function(e) {
        if (e && e.__esModule) return e;
        var t = {};
        if (null != e)
            for (var i in e) Object.hasOwnProperty.call(e, i) && (t[i] = e[i]);
        return t.default = e, t
    }, "__makeTemplateObject", 0, function(e, t) {
        return Object.defineProperty ? Object.defineProperty(e, "raw", {
            value: t
        }) : e.raw = t, e
    }, "__metadata", 0, function(e, t) {
        if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(e, t)
    }, "__param", 0, function(e, t) {
        return function(i, r) {
            t(i, r, e)
        }
    }, "__read", 0, s, "__rest", 0, function(e, t) {
        var i = {};
        for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && 0 > t.indexOf(r) && (i[r] = e[r]);
        if (null != e && "function" == typeof Object.getOwnPropertySymbols)
            for (var s = 0, r = Object.getOwnPropertySymbols(e); s < r.length; s++) 0 > t.indexOf(r[s]) && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (i[r[s]] = e[r[s]]);
        return i
    }, "__spread", 0, function() {
        for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(s(arguments[t]));
        return e
    }, "__spreadArrays", 0, function() {
        for (var e = 0, t = 0, i = arguments.length; t < i; t++) e += arguments[t].length;
        for (var r = Array(e), s = 0, t = 0; t < i; t++)
            for (var n = arguments[t], o = 0, a = n.length; o < a; o++, s++) r[s] = n[o];
        return r
    }, "__values", 0, r])
}, 868029, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.delay = void 0, i.delay = function(e) {
        return new Promise(t => {
            setTimeout(() => {
                t(!0)
            }, e)
        })
    }
}, 814165, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.ONE_THOUSAND = i.ONE_HUNDRED = void 0, i.ONE_HUNDRED = 100, i.ONE_THOUSAND = 1e3
}, 334933, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.ONE_YEAR = i.FOUR_WEEKS = i.THREE_WEEKS = i.TWO_WEEKS = i.ONE_WEEK = i.THIRTY_DAYS = i.SEVEN_DAYS = i.FIVE_DAYS = i.THREE_DAYS = i.ONE_DAY = i.TWENTY_FOUR_HOURS = i.TWELVE_HOURS = i.SIX_HOURS = i.THREE_HOURS = i.ONE_HOUR = i.SIXTY_MINUTES = i.THIRTY_MINUTES = i.TEN_MINUTES = i.FIVE_MINUTES = i.ONE_MINUTE = i.SIXTY_SECONDS = i.THIRTY_SECONDS = i.TEN_SECONDS = i.FIVE_SECONDS = i.ONE_SECOND = void 0, i.ONE_SECOND = 1, i.FIVE_SECONDS = 5, i.TEN_SECONDS = 10, i.THIRTY_SECONDS = 30, i.SIXTY_SECONDS = 60, i.ONE_MINUTE = i.SIXTY_SECONDS, i.FIVE_MINUTES = 5 * i.ONE_MINUTE, i.TEN_MINUTES = 10 * i.ONE_MINUTE, i.THIRTY_MINUTES = 30 * i.ONE_MINUTE, i.SIXTY_MINUTES = 60 * i.ONE_MINUTE, i.ONE_HOUR = i.SIXTY_MINUTES, i.THREE_HOURS = 3 * i.ONE_HOUR, i.SIX_HOURS = 6 * i.ONE_HOUR, i.TWELVE_HOURS = 12 * i.ONE_HOUR, i.TWENTY_FOUR_HOURS = 24 * i.ONE_HOUR, i.ONE_DAY = i.TWENTY_FOUR_HOURS, i.THREE_DAYS = 3 * i.ONE_DAY, i.FIVE_DAYS = 5 * i.ONE_DAY, i.SEVEN_DAYS = 7 * i.ONE_DAY, i.THIRTY_DAYS = 30 * i.ONE_DAY, i.ONE_WEEK = i.SEVEN_DAYS, i.TWO_WEEKS = 2 * i.ONE_WEEK, i.THREE_WEEKS = 3 * i.ONE_WEEK, i.FOUR_WEEKS = 4 * i.ONE_WEEK, i.ONE_YEAR = 365 * i.ONE_DAY
}, 494301, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    });
    let r = e.r(575824);
    r.__exportStar(e.r(814165), i), r.__exportStar(e.r(334933), i)
}, 572739, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.fromMiliseconds = i.toMiliseconds = void 0;
    let r = e.r(494301);
    i.toMiliseconds = function(e) {
        return e * r.ONE_THOUSAND
    }, i.fromMiliseconds = function(e) {
        return Math.floor(e / r.ONE_THOUSAND)
    }
}, 273712, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    });
    let r = e.r(575824);
    r.__exportStar(e.r(868029), i), r.__exportStar(e.r(572739), i)
}, 333806, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.Watch = void 0;
    class r {
        constructor() {
            this.timestamps = new Map
        }
        start(e) {
            if (this.timestamps.has(e)) throw Error(`Watch already started for label: ${e}`);
            this.timestamps.set(e, {
                started: Date.now()
            })
        }
        stop(e) {
            let t = this.get(e);
            if (void 0 !== t.elapsed) throw Error(`Watch already stopped for label: ${e}`);
            let i = Date.now() - t.started;
            this.timestamps.set(e, {
                started: t.started,
                elapsed: i
            })
        }
        get(e) {
            let t = this.timestamps.get(e);
            if (void 0 === t) throw Error(`No timestamp found for label: ${e}`);
            return t
        }
        elapsed(e) {
            let t = this.get(e);
            return t.elapsed || Date.now() - t.started
        }
    }
    i.Watch = r, i.default = r
}, 222803, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.IWatch = void 0, i.IWatch = class {}
}, 948662, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), e.r(575824).__exportStar(e.r(222803), i)
}, 367069, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    });
    let r = e.r(575824);
    r.__exportStar(e.r(273712), i), r.__exportStar(e.r(333806), i), r.__exportStar(e.r(948662), i), r.__exportStar(e.r(494301), i)
}, 896119, (e, t, i) => {
    "use strict";

    function r(e) {
        let t;
        return "u" > typeof window && void 0 !== window[e] && (t = window[e]), t
    }

    function s(e) {
        let t = r(e);
        if (!t) throw Error(`${e} is not defined in Window`);
        return t
    }
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.getLocalStorage = i.getLocalStorageOrThrow = i.getCrypto = i.getCryptoOrThrow = i.getLocation = i.getLocationOrThrow = i.getNavigator = i.getNavigatorOrThrow = i.getDocument = i.getDocumentOrThrow = i.getFromWindowOrThrow = i.getFromWindow = void 0, i.getFromWindow = r, i.getFromWindowOrThrow = s, i.getDocumentOrThrow = function() {
        return s("document")
    }, i.getDocument = function() {
        return r("document")
    }, i.getNavigatorOrThrow = function() {
        return s("navigator")
    }, i.getNavigator = function() {
        return r("navigator")
    }, i.getLocationOrThrow = function() {
        return s("location")
    }, i.getLocation = function() {
        return r("location")
    }, i.getCryptoOrThrow = function() {
        return s("crypto")
    }, i.getCrypto = function() {
        return r("crypto")
    }, i.getLocalStorageOrThrow = function() {
        return s("localStorage")
    }, i.getLocalStorage = function() {
        return r("localStorage")
    }
}, 502237, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.getWindowMetadata = void 0;
    let r = e.r(896119);
    i.getWindowMetadata = function() {
        let e, t, i;
        try {
            e = r.getDocumentOrThrow(), t = r.getLocationOrThrow()
        } catch (e) {
            return null
        }

        function s(...t) {
            let i = e.getElementsByTagName("meta");
            for (let e = 0; e < i.length; e++) {
                let r = i[e],
                    s = ["itemprop", "property", "name"].map(e => r.getAttribute(e)).filter(e => !!e && t.includes(e));
                if (s.length && s) {
                    let e = r.getAttribute("content");
                    if (e) return e
                }
            }
            return ""
        }
        let n = ((i = s("name", "og:site_name", "og:title", "twitter:title")) || (i = e.title), i),
            o = s("description", "og:description", "twitter:description", "keywords"),
            a = t.origin;
        return {
            description: o,
            url: a,
            icons: function() {
                let i = e.getElementsByTagName("link"),
                    r = [];
                for (let e = 0; e < i.length; e++) {
                    let s = i[e],
                        n = s.getAttribute("rel");
                    if (n && n.toLowerCase().indexOf("icon") > -1) {
                        let e = s.getAttribute("href");
                        if (e)
                            if (-1 === e.toLowerCase().indexOf("https:") && -1 === e.toLowerCase().indexOf("http:") && 0 !== e.indexOf("//")) {
                                let i = t.protocol + "//" + t.host;
                                if (0 === e.indexOf("/")) i += e;
                                else {
                                    let r = t.pathname.split("/");
                                    r.pop(), i += r.join("/") + "/" + e
                                }
                                r.push(i)
                            } else if (0 === e.indexOf("//")) {
                            let i = t.protocol + e;
                            r.push(i)
                        } else r.push(e)
                    }
                }
                return r
            }(),
            name: n
        }
    }
}, 966832, 980761, 495913, 73975, 938918, 696172, 735291, e => {
    "use strict";
    var t = e.i(368089);
    class i extends Error {
        constructor(e, t = {}) {
            const r = (() => {
                    if (t.cause instanceof i) {
                        if (t.cause.details) return t.cause.details;
                        if (t.cause.shortMessage) return t.cause.shortMessage
                    }
                    return t.cause && "details" in t.cause && "string" == typeof t.cause.details ? t.cause.details : t.cause ? .message ? t.cause.message : t.details
                })(),
                s = t.cause instanceof i && t.cause.docsPath || t.docsPath,
                n = `https://oxlib.sh${s??""}`;
            super([e || "An error occurred.", ...t.metaMessages ? ["", ...t.metaMessages] : [], ...r || s ? ["", r ? `Details: ${r}` : void 0, s ? `See: ${n}` : void 0] : []].filter(e => "string" == typeof e).join("\n"), t.cause ? {
                cause: t.cause
            } : void 0), Object.defineProperty(this, "details", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "docs", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "docsPath", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "shortMessage", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "cause", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "BaseError"
            }), Object.defineProperty(this, "version", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "ox@0.1.1"
            }), this.cause = t.cause, this.details = r, this.docs = n, this.docsPath = s, this.shortMessage = e
        }
        walk(e) {
            return function e(t, i) {
                return i ? .(t) ? t : t && "object" == typeof t && "cause" in t && t.cause ? e(t.cause, i) : i ? null : t
            }(this, e)
        }
    }

    function r(e, t) {
        if (p(e) > t) throw new b({
            givenSize: p(e),
            maxSize: t
        })
    }

    function s(e, t = {}) {
        let {
            dir: i,
            size: r = 32
        } = t;
        if (0 === r) return e;
        let n = e.replace("0x", "");
        if (n.length > 2 * r) throw new v({
            size: Math.ceil(n.length / 2),
            targetSize: r,
            type: "Hex"
        });
        return `0x${n["right"===i?"padEnd":"padStart"](2*r,"0")}`
    }

    function n(e, t, i) {
        return JSON.stringify(e, (e, i) => "function" == typeof t ? t(e, i) : "bigint" == typeof i ? i.toString() + "#__bigint" : i, i)
    }
    let o = Array.from({
        length: 256
    }, (e, t) => t.toString(16).padStart(2, "0"));

    function a(...e) {
        return `0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`
    }

    function l(e) {
        return e instanceof Uint8Array ? c(e) : Array.isArray(e) ? c(new Uint8Array(e)) : e
    }

    function c(e, t = {}) {
        let i = "";
        for (let t = 0; t < e.length; t++) i += o[e[t]];
        let s = `0x${i}`;
        return "number" == typeof t.size ? (r(s, t.size), u(s, t.size)) : s
    }

    function h(e, t = {}) {
        var i;
        let r, {
                signed: n,
                size: o
            } = t,
            a = BigInt(e);
        o ? r = n ? (1 n << 8 n * BigInt(o) - 1 n) - 1 n : 2 n ** (8 n * BigInt(o)) - 1 n : "number" == typeof e && (r = BigInt(Number.MAX_SAFE_INTEGER));
        let l = "bigint" == typeof r && n ? -r - 1 n : 0;
        if (r && a > r || a < l) {
            let t = "bigint" == typeof e ? "n" : "";
            throw new g({
                max: r ? `${r}${t}` : void 0,
                min: `${l}${t}`,
                signed: n,
                size: o,
                value: `${e}${t}`
            })
        }
        let c = (n && a < 0 ? (1 n << BigInt(8 * o)) + BigInt(a) : a).toString(16),
            u = `0x${c}`;
        return o ? (i = u, s(i, {
            dir: "left",
            size: o
        })) : u
    }

    function u(e, t) {
        return s(e, {
            dir: "right",
            size: t
        })
    }

    function d(e, t, i, r = {}) {
        let {
            strict: s
        } = r;
        if ("number" == typeof t && t > 0 && t > p(e) - 1) throw new w({
            offset: t,
            position: "start",
            size: p(e)
        });
        let n = `0x${e.replace("0x","").slice((t??0)*2,(i??e.length)*2)}`;
        return s && function(e, t, i) {
            if ("number" == typeof t && "number" == typeof i && p(e) !== i - t) throw new w({
                offset: i,
                position: "end",
                size: p(e)
            })
        }(n, t, i), n
    }

    function p(e) {
        return Math.ceil((e.length - 2) / 2)
    }

    function f(e) {
        return function(e, t = {}) {
            let {
                dir: i = "left"
            } = t, r = e.replace("0x", ""), s = 0;
            for (let e = 0; e < r.length - 1; e++)
                if ("0" === r["left" === i ? e : r.length - e - 1].toString()) s++;
                else break;
            return "0" === (r = "left" === i ? r.slice(s) : r.slice(0, r.length - s)) ? "0x" : "right" === i && r.length % 2 == 1 ? `0x${r}0` : `0x${r}`
        }(e, {
            dir: "left"
        })
    }
    class g extends i {
        constructor({
            max: e,
            min: t,
            signed: i,
            size: r,
            value: s
        }) {
            super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.IntegerOutOfRangeError"
            })
        }
    }
    class y extends i {
        constructor(e) {
            super(`Value \`${"object"==typeof e?n(e):e}\` of type \`${typeof e}\` is an invalid hex type.`, {
                metaMessages: ['Hex types must be represented as `"0x${string}"`.']
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.InvalidHexTypeError"
            })
        }
    }
    class m extends i {
        constructor(e) {
            super(`Value \`${e}\` is an invalid hex value.`, {
                metaMessages: ['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.InvalidHexValueError"
            })
        }
    }
    class b extends i {
        constructor({
            givenSize: e,
            maxSize: t
        }) {
            super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.SizeOverflowError"
            })
        }
    }
    class w extends i {
        constructor({
            offset: e,
            position: t,
            size: i
        }) {
            super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${i}\`).`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.SliceOffsetOutOfBoundsError"
            })
        }
    }
    class v extends i {
        constructor({
            size: e,
            targetSize: t,
            type: i
        }) {
            super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Hex.SizeExceedsPaddingSizeError"
            })
        }
    }

    function E(e) {
        return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : void 0
    }
    let x = new TextEncoder;

    function I(e) {
        var t;
        return e instanceof Uint8Array ? e : "string" == typeof e ? S(e) : (t = e) instanceof Uint8Array ? t : new Uint8Array(t)
    }

    function S(e, t = {}) {
        let {
            size: s
        } = t, n = e;
        s && (r(e, s), n = u(e, s));
        let o = n.slice(2);
        o.length % 2 && (o = `0${o}`);
        let a = o.length / 2,
            l = new Uint8Array(a);
        for (let e = 0, t = 0; e < a; e++) {
            let r = E(o.charCodeAt(t++)),
                s = E(o.charCodeAt(t++));
            if (void 0 === r || void 0 === s) throw new i(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);
            l[e] = 16 * r + s
        }
        return l
    }
    class _ extends i {
        constructor(e) {
            super(`Value \`${"object"==typeof e?n(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`, {
                metaMessages: ["Bytes values must be of type `Bytes`."]
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Bytes.InvalidBytesTypeError"
            })
        }
    }
    class P extends i {
        constructor({
            givenSize: e,
            maxSize: t
        }) {
            super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Bytes.SizeOverflowError"
            })
        }
    }
    class T extends i {
        constructor({
            size: e,
            targetSize: t,
            type: i
        }) {
            super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Bytes.SizeExceedsPaddingSizeError"
            })
        }
    }
    let A = 2 n ** 256 n - 1 n;

    function O(e, t = {}) {
        let {
            recovered: i
        } = t;
        if (void 0 === e.r || void 0 === e.s || i && void 0 === e.yParity) throw new $({
            signature: e
        });
        if (e.r < 0 n || e.r > A) throw new q({
            value: e.r
        });
        if (e.s < 0 n || e.s > A) throw new z({
            value: e.s
        });
        if ("number" == typeof e.yParity && 0 !== e.yParity && 1 !== e.yParity) throw new V({
            value: e.yParity
        })
    }

    function R(e) {
        return N(c(e))
    }

    function N(e) {
        if (130 !== e.length && 132 !== e.length) throw new j({
            signature: e
        });
        let t = BigInt(d(e, 0, 32)),
            i = BigInt(d(e, 32, 64)),
            r = (() => {
                let t = Number(`0x${e.slice(130)}`);
                if (!Number.isNaN(t)) try {
                    return B(t)
                } catch {
                    throw new V({
                        value: t
                    })
                }
            })();
        return void 0 === r ? {
            r: t,
            s: i
        } : {
            r: t,
            s: i,
            yParity: r
        }
    }

    function U(e) {
        let t = "string" == typeof e ? N(e) : e instanceof Uint8Array ? R(e) : "string" == typeof e.r ? L(e) : e.v ? k(e) : {
            r: e.r,
            s: e.s,
            ...void 0 !== e.yParity ? {
                yParity: e.yParity
            } : {}
        };
        return O(t), t
    }

    function C(e) {
        let {
            r: i,
            s: r
        } = t.secp256k1.Signature.fromDER(l(e).slice(2));
        return {
            r: i,
            s: r
        }
    }

    function k(e) {
        return {
            r: e.r,
            s: e.s,
            yParity: B(e.v)
        }
    }

    function L(e) {
        let t = (() => {
            let t = e.v ? Number(e.v) : void 0,
                i = e.yParity ? Number(e.yParity) : void 0;
            if ("number" == typeof t && "number" != typeof i && (i = B(t)), "number" != typeof i) throw new V({
                value: e.yParity
            });
            return i
        })();
        return {
            r: BigInt(e.r),
            s: BigInt(e.s),
            yParity: t
        }
    }

    function D(e) {
        O(e);
        let t = e.r,
            i = e.s;
        return a(h(t, {
            size: 32
        }), h(i, {
            size: 32
        }), "number" == typeof e.yParity ? h(M(e.yParity), {
            size: 1
        }) : "0x")
    }

    function B(e) {
        if (0 === e || 27 === e) return 0;
        if (1 === e || 28 === e) return 1;
        if (e >= 35) return +(e % 2 == 0);
        throw new K({
            value: e
        })
    }

    function M(e) {
        if (0 === e) return 27;
        if (1 === e) return 28;
        throw new V({
            value: e
        })
    }
    class j extends i {
        constructor({
            signature: e
        }) {
            super(`Value \`${e}\` is an invalid signature size.`, {
                metaMessages: ["Expected: 64 bytes or 65 bytes.", `Received ${p(l(e))} bytes.`]
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.InvalidSerializedSizeError"
            })
        }
    }
    class $ extends i {
        constructor({
            signature: e
        }) {
            super(`Signature \`${n(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.MissingPropertiesError"
            })
        }
    }
    class q extends i {
        constructor({
            value: e
        }) {
            super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.InvalidRError"
            })
        }
    }
    class z extends i {
        constructor({
            value: e
        }) {
            super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.InvalidSError"
            })
        }
    }
    class V extends i {
        constructor({
            value: e
        }) {
            super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.InvalidYParityError"
            })
        }
    }
    class K extends i {
        constructor({
            value: e
        }) {
            super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Signature.InvalidVError"
            })
        }
    }
    e.s(["InvalidRError", 0, q, "InvalidSError", 0, z, "InvalidSerializedSizeError", 0, j, "InvalidVError", 0, K, "InvalidYParityError", 0, V, "MissingPropertiesError", 0, $, "assert", 0, O, "extract", 0, function(e) {
        if (void 0 !== e.r && void 0 !== e.s) return U(e)
    }, "from", 0, U, "fromBytes", 0, R, "fromDerBytes", 0, function(e) {
        return C(c(e))
    }, "fromDerHex", 0, C, "fromHex", 0, N, "fromLegacy", 0, k, "fromRpc", 0, L, "fromTuple", 0, function(e) {
        let [t, i, r] = e;
        return U({
            r: "0x" === i ? 0 n : BigInt(i),
            s: "0x" === r ? 0 n : BigInt(r),
            yParity: "0x" === t ? 0 : Number(t)
        })
    }, "toBytes", 0, function(e) {
        return S(D(e))
    }, "toDerBytes", 0, function(e) {
        return new t.secp256k1.Signature(e.r, e.s).toDERRawBytes()
    }, "toDerHex", 0, function(e) {
        let i = new t.secp256k1.Signature(e.r, e.s);
        return `0x${i.toDERHex()}`
    }, "toHex", 0, D, "toLegacy", 0, function(e) {
        return {
            r: e.r,
            s: e.s,
            v: M(e.yParity)
        }
    }, "toRpc", 0, function(e) {
        let {
            r: t,
            s: i,
            yParity: r
        } = e;
        return {
            r: h(t, {
                size: 32
            }),
            s: h(i, {
                size: 32
            }),
            yParity: 0 === r ? "0x0" : "0x1"
        }
    }, "toTuple", 0, function(e) {
        let {
            r: t,
            s: i,
            yParity: r
        } = e;
        return [r ? "0x01" : "0x", 0 n === t ? "0x" : f(h(t)), 0 n === i ? "0x" : f(h(i))]
    }, "vToYParity", 0, B, "validate", 0, function(e, t = {}) {
        try {
            return O(e, t), !0
        } catch {
            return !1
        }
    }, "yParityToV", 0, M], 500709);
    var F = e.i(500709);
    e.s(["Signature", 0, F], 966832);
    class H extends Map {
        constructor(e) {
            super(), Object.defineProperty(this, "maxSize", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: void 0
            }), this.maxSize = e
        }
        get(e) {
            let t = super.get(e);
            return super.has(e) && void 0 !== t && (this.delete(e), super.set(e, t)), t
        }
        set(e, t) {
            if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
                let e = this.keys().next().value;
                e && this.delete(e)
            }
            return this
        }
    }
    let W = {
        checksum: new H(8192)
    }.checksum;
    var G = e.i(918196);

    function Y(e, t = {}) {
        let {
            as: i = "string" == typeof e ? "Hex" : "Bytes"
        } = t, r = (0, G.keccak_256)(I(e));
        return "Bytes" === i ? r : c(r)
    }

    function J(e, t = {}) {
        let {
            compressed: i
        } = t, {
            prefix: r,
            x: s,
            y: n
        } = e;
        if (!1 === i || "bigint" == typeof s && "bigint" == typeof n) {
            if (4 !== r) throw new et({
                prefix: r,
                cause: new er
            });
            return
        }
        if (!0 === i || "bigint" == typeof s && void 0 === n) {
            if (3 !== r && 2 !== r) throw new et({
                prefix: r,
                cause: new ei
            });
            return
        }
        throw new ee({
            publicKey: e
        })
    }

    function Q(e) {
        let t = (() => {
            if (function(e, t = {}) {
                    let {
                        strict: i = !1
                    } = t;
                    try {
                        return ! function(e, t = {}) {
                            let {
                                strict: i = !1
                            } = t;
                            if (!e || "string" != typeof e) throw new y(e);
                            if (i && !/^0x[0-9a-fA-F]*$/.test(e) || !e.startsWith("0x")) throw new m(e)
                        }(e, {
                            strict: i
                        }), !0
                    } catch {
                        return !1
                    }
                }(e)) return Z(e);
            if (function(e) {
                    try {
                        if (!(e instanceof Uint8Array) && (!e || "object" != typeof e || !("BYTES_PER_ELEMENT" in e) || 1 !== e.BYTES_PER_ELEMENT || "Uint8Array" !== e.constructor.name)) throw new _(e);
                        return !0
                    } catch {
                        return !1
                    }
                }(e)) return Z(c(e));
            let {
                prefix: t,
                x: i,
                y: r
            } = e;
            return "bigint" == typeof i && "bigint" == typeof r ? {
                prefix: t ? ? 4,
                x: i,
                y: r
            } : {
                prefix: t,
                x: i
            }
        })();
        return J(t), t
    }

    function Z(e) {
        if (132 !== e.length && 130 !== e.length && 68 !== e.length) throw new es({
            publicKey: e
        });
        if (130 === e.length) return {
            prefix: 4,
            x: BigInt(d(e, 0, 32)),
            y: BigInt(d(e, 32, 64))
        };
        if (132 === e.length) {
            let t = Number(d(e, 0, 1));
            return {
                prefix: t,
                x: BigInt(d(e, 1, 33)),
                y: BigInt(d(e, 33, 65))
            }
        }
        return {
            prefix: Number(d(e, 0, 1)),
            x: BigInt(d(e, 1, 33))
        }
    }

    function X(e, t = {}) {
        J(e);
        let {
            prefix: i,
            x: r,
            y: s
        } = e, {
            includePrefix: n = !0
        } = t;
        return a(n ? h(i, {
            size: 1
        }) : "0x", h(r, {
            size: 32
        }), "bigint" == typeof s ? h(s, {
            size: 32
        }) : "0x")
    }
    class ee extends i {
        constructor({
            publicKey: e
        }) {
            super(`Value \`${n(e)}\` is not a valid public key.`, {
                metaMessages: ["Public key must contain:", "- an `x` and `prefix` value (compressed)", "- an `x`, `y`, and `prefix` value (uncompressed)"]
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "PublicKey.InvalidError"
            })
        }
    }
    class et extends i {
        constructor({
            prefix: e,
            cause: t
        }) {
            super(`Prefix "${e}" is invalid.`, {
                cause: t
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "PublicKey.InvalidPrefixError"
            })
        }
    }
    class ei extends i {
        constructor() {
            super("Prefix must be 2 or 3 for compressed public keys."), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "PublicKey.InvalidCompressedPrefixError"
            })
        }
    }
    class er extends i {
        constructor() {
            super("Prefix must be 4 for uncompressed public keys."), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "PublicKey.InvalidUncompressedPrefixError"
            })
        }
    }
    class es extends i {
        constructor({
            publicKey: e
        }) {
            super(`Value \`${e}\` is an invalid public key size.`, {
                metaMessages: ["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).", `Received ${p(l(e))} bytes.`]
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "PublicKey.InvalidSerializedSizeError"
            })
        }
    }
    let en = /^0x[a-fA-F0-9]{40}$/;

    function eo(e, t = {}) {
        let {
            strict: i = !0
        } = t;
        if (!en.test(e)) throw new el({
            address: e,
            cause: new ec
        });
        if (i) {
            if (e.toLowerCase() === e) return;
            if (ea(e) !== e) throw new el({
                address: e,
                cause: new eh
            })
        }
    }

    function ea(e) {
        if (W.has(e)) return W.get(e);
        eo(e, {
            strict: !1
        });
        let t = e.substring(2).toLowerCase(),
            i = Y(function(e, t = {}) {
                let {
                    size: i
                } = t, r = x.encode(e);
                if ("number" == typeof i) {
                    var s;
                    if (r.length > i) throw new P({
                        givenSize: r.length,
                        maxSize: i
                    });
                    return s = r,
                        function(e, t = {}) {
                            let {
                                dir: i,
                                size: r = 32
                            } = t;
                            if (0 === r) return e;
                            if (e.length > r) throw new T({
                                size: e.length,
                                targetSize: r,
                                type: "Bytes"
                            });
                            let s = new Uint8Array(r);
                            for (let t = 0; t < r; t++) {
                                let n = "right" === i;
                                s[n ? t : r - t - 1] = e[n ? t : e.length - t - 1]
                            }
                            return s
                        }(s, {
                            dir: "right",
                            size: i
                        })
                }
                return r
            }(t), {
                as: "Bytes"
            }),
            r = t.split("");
        for (let e = 0; e < 40; e += 2) i[e >> 1] >> 4 >= 8 && r[e] && (r[e] = r[e].toUpperCase()), (15 & i[e >> 1]) >= 8 && r[e + 1] && (r[e + 1] = r[e + 1].toUpperCase());
        let s = `0x${r.join("")}`;
        return W.set(e, s), s
    }
    class el extends i {
        constructor({
            address: e,
            cause: t
        }) {
            super(`Address "${e}" is invalid.`, {
                cause: t
            }), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Address.InvalidAddressError"
            })
        }
    }
    class ec extends i {
        constructor() {
            super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Address.InvalidInputError"
            })
        }
    }
    class eh extends i {
        constructor() {
            super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: "Address.InvalidChecksumError"
            })
        }
    }
    let eu = t.secp256k1;

    function ed(e) {
        let {
            privateKey: i
        } = e;
        return Q(t.secp256k1.ProjectivePoint.fromPrivateKey(l(i).slice(2)))
    }

    function ep(e = {}) {
        let {
            as: i = "Hex"
        } = e, r = t.secp256k1.utils.randomPrivateKey();
        return "Hex" === i ? c(r) : r
    }

    function ef(e) {
        return function(e, t = {}) {
            let i = Y(`0x${X(e).slice(4)}`).substring(26);
            return function(e, t = {}) {
                let {
                    checksum: i = !1
                } = t;
                return (eo(e), i) ? ea(e) : e
            }(`0x${i}`, t)
        }(eg(e))
    }

    function eg(e) {
        let {
            payload: i,
            signature: r
        } = e, {
            r: s,
            s: n,
            yParity: o
        } = r;
        return Q(new t.secp256k1.Signature(BigInt(s), BigInt(n)).addRecoveryBit(o).recoverPublicKey(l(i).substring(2)))
    }
    e.s(["createKeyPair", 0, function(e = {}) {
        let {
            as: t = "Hex"
        } = e, i = ep({
            as: t
        }), r = ed({
            privateKey: i
        });
        return {
            privateKey: i,
            publicKey: r
        }
    }, "getPublicKey", 0, ed, "getSharedSecret", 0, function(e) {
        let {
            as: i = "Hex",
            privateKey: r,
            publicKey: s
        } = e, n = t.secp256k1.ProjectivePoint.fromHex(X(s).slice(2)).multiply(t.secp256k1.utils.normPrivateKeyToScalar(l(r).slice(2))).toRawBytes(!0);
        return "Hex" === i ? c(n) : n
    }, "noble", 0, eu, "randomPrivateKey", 0, ep, "recoverAddress", 0, ef, "recoverPublicKey", 0, eg, "sign", 0, function(e) {
        let {
            extraEntropy: i = !1,
            hash: r,
            payload: s,
            privateKey: n
        } = e, {
            r: o,
            s: a,
            recovery: c
        } = t.secp256k1.sign(I(s), I(n), {
            extraEntropy: "boolean" == typeof i ? i : l(i).slice(2),
            lowS: !0,
            ...r ? {
                prehash: !0
            } : {}
        });
        return {
            r: o,
            s: a,
            yParity: c
        }
    }, "verify", 0, function(e) {
        let {
            address: i,
            hash: r,
            payload: s,
            publicKey: n,
            signature: o
        } = e;
        if (i) {
            var a;
            return a = ef({
                payload: s,
                signature: o
            }), eo(i, {
                strict: !1
            }), eo(a, {
                strict: !1
            }), i.toLowerCase() === a.toLowerCase()
        }
        return t.secp256k1.verify(o, I(s), function(e, t = {}) {
            return S(X(e, t))
        }(n), ...r ? [{
            prehash: !0,
            lowS: !0
        }] : [])
    }], 443758);
    var ey = e.i(443758);
    e.s(["Secp256k1", 0, ey], 980761);
    var em = e.i(354955);
    let eb = Uint8Array.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9]);
    var ew = e.i(91197),
        ev = e.i(257647),
        eE = em;
    let ex = Uint32Array.from([0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19]),
        eI = new Uint32Array(32);

    function eS(e, t, i, r, s, n) {
        let o = s[n],
            a = s[n + 1],
            l = eI[2 * e],
            c = eI[2 * e + 1],
            h = eI[2 * t],
            u = eI[2 * t + 1],
            d = eI[2 * i],
            p = eI[2 * i + 1],
            f = eI[2 * r],
            g = eI[2 * r + 1],
            y = ev.add3L(l, h, o);
        c = ev.add3H(y, c, u, a), l = 0 | y, ({
            Dh: g,
            Dl: f
        } = {
            Dh: g ^ c,
            Dl: f ^ l
        }), ({
            Dh: g,
            Dl: f
        } = {
            Dh: ev.rotr32H(g, f),
            Dl: ev.rotr32L(g, f)
        }), ({
            h: p,
            l: d
        } = ev.add(p, d, g, f)), ({
            Bh: u,
            Bl: h
        } = {
            Bh: u ^ p,
            Bl: h ^ d
        }), ({
            Bh: u,
            Bl: h
        } = {
            Bh: ev.rotrSH(u, h, 24),
            Bl: ev.rotrSL(u, h, 24)
        }), eI[2 * e] = l, eI[2 * e + 1] = c, eI[2 * t] = h, eI[2 * t + 1] = u, eI[2 * i] = d, eI[2 * i + 1] = p, eI[2 * r] = f, eI[2 * r + 1] = g
    }

    function e_(e, t, i, r, s, n) {
        let o = s[n],
            a = s[n + 1],
            l = eI[2 * e],
            c = eI[2 * e + 1],
            h = eI[2 * t],
            u = eI[2 * t + 1],
            d = eI[2 * i],
            p = eI[2 * i + 1],
            f = eI[2 * r],
            g = eI[2 * r + 1],
            y = ev.add3L(l, h, o);
        c = ev.add3H(y, c, u, a), l = 0 | y, ({
            Dh: g,
            Dl: f
        } = {
            Dh: g ^ c,
            Dl: f ^ l
        }), ({
            Dh: g,
            Dl: f
        } = {
            Dh: ev.rotrSH(g, f, 16),
            Dl: ev.rotrSL(g, f, 16)
        }), ({
            h: p,
            l: d
        } = ev.add(p, d, g, f)), ({
            Bh: u,
            Bl: h
        } = {
            Bh: u ^ p,
            Bl: h ^ d
        }), ({
            Bh: u,
            Bl: h
        } = {
            Bh: ev.rotrBH(u, h, 63),
            Bl: ev.rotrBL(u, h, 63)
        }), eI[2 * e] = l, eI[2 * e + 1] = c, eI[2 * t] = h, eI[2 * t + 1] = u, eI[2 * i] = d, eI[2 * i + 1] = p, eI[2 * r] = f, eI[2 * r + 1] = g
    }

    function eP(e, t = {}, i, r, s) {
        if ((0, eE.anumber)(i), e < 0 || e > i) throw Error("outputLen bigger than keyLen");
        let {
            key: n,
            salt: o,
            personalization: a
        } = t;
        if (void 0 !== n && (n.length < 1 || n.length > i)) throw Error("key length must be undefined or 1.." + i);
        if (void 0 !== o && o.length !== r) throw Error("salt must be undefined or " + r);
        if (void 0 !== a && a.length !== s) throw Error("personalization must be undefined or " + s)
    }
    class eT extends eE.Hash {
        constructor(e, t) {
            super(), this.finished = !1, this.destroyed = !1, this.length = 0, this.pos = 0, (0, eE.anumber)(e), (0, eE.anumber)(t), this.blockLen = e, this.outputLen = t, this.buffer = new Uint8Array(e), this.buffer32 = (0, eE.u32)(this.buffer)
        }
        update(e) {
            (0, eE.aexists)(this), e = (0, eE.toBytes)(e), (0, eE.abytes)(e);
            let {
                blockLen: t,
                buffer: i,
                buffer32: r
            } = this, s = e.length, n = e.byteOffset, o = e.buffer;
            for (let a = 0; a < s;) {
                this.pos === t && ((0, eE.swap32IfBE)(r), this.compress(r, 0, !1), (0, eE.swap32IfBE)(r), this.pos = 0);
                let l = Math.min(t - this.pos, s - a),
                    c = n + a;
                if (l === t && !(c % 4) && a + l < s) {
                    let e = new Uint32Array(o, c, Math.floor((s - a) / 4));
                    (0, eE.swap32IfBE)(e);
                    for (let i = 0; a + t < s; i += r.length, a += t) this.length += t, this.compress(e, i, !1);
                    (0, eE.swap32IfBE)(e);
                    continue
                }
                i.set(e.subarray(a, a + l), this.pos), this.pos += l, this.length += l, a += l
            }
            return this
        }
        digestInto(e) {
            (0, eE.aexists)(this), (0, eE.aoutput)(e, this);
            let {
                pos: t,
                buffer32: i
            } = this;
            this.finished = !0, (0, eE.clean)(this.buffer.subarray(t)), (0, eE.swap32IfBE)(i), this.compress(i, 0, !0), (0, eE.swap32IfBE)(i);
            let r = (0, eE.u32)(e);
            this.get().forEach((e, t) => r[t] = (0, eE.swap8IfBE)(e))
        }
        digest() {
            let {
                buffer: e,
                outputLen: t
            } = this;
            this.digestInto(e);
            let i = e.slice(0, t);
            return this.destroy(), i
        }
        _cloneInto(e) {
            let {
                buffer: t,
                length: i,
                finished: r,
                destroyed: s,
                outputLen: n,
                pos: o
            } = this;
            return e || (e = new this.constructor({
                dkLen: n
            })), e.set(...this.get()), e.buffer.set(t), e.destroyed = s, e.finished = r, e.length = i, e.pos = o, e.outputLen = n, e
        }
        clone() {
            return this._cloneInto()
        }
    }
    class eA extends eT {
        constructor(e = {}) {
            const t = void 0 === e.dkLen ? 64 : e.dkLen;
            super(128, t), this.v0l = 0 | ex[0], this.v0h = 0 | ex[1], this.v1l = 0 | ex[2], this.v1h = 0 | ex[3], this.v2l = 0 | ex[4], this.v2h = 0 | ex[5], this.v3l = 0 | ex[6], this.v3h = 0 | ex[7], this.v4l = 0 | ex[8], this.v4h = 0 | ex[9], this.v5l = 0 | ex[10], this.v5h = 0 | ex[11], this.v6l = 0 | ex[12], this.v6h = 0 | ex[13], this.v7l = 0 | ex[14], this.v7h = 0 | ex[15], eP(t, e, 64, 16, 16);
            let {
                key: i,
                personalization: r,
                salt: s
            } = e, n = 0;
            if (void 0 !== i && (n = (i = (0, eE.toBytes)(i)).length), this.v0l ^= this.outputLen | n << 8 | 0x1010000, void 0 !== s) {
                s = (0, eE.toBytes)(s);
                const e = (0, eE.u32)(s);
                this.v4l ^= (0, eE.swap8IfBE)(e[0]), this.v4h ^= (0, eE.swap8IfBE)(e[1]), this.v5l ^= (0, eE.swap8IfBE)(e[2]), this.v5h ^= (0, eE.swap8IfBE)(e[3])
            }
            if (void 0 !== r) {
                r = (0, eE.toBytes)(r);
                const e = (0, eE.u32)(r);
                this.v6l ^= (0, eE.swap8IfBE)(e[0]), this.v6h ^= (0, eE.swap8IfBE)(e[1]), this.v7l ^= (0, eE.swap8IfBE)(e[2]), this.v7h ^= (0, eE.swap8IfBE)(e[3])
            }
            if (void 0 !== i) {
                const e = new Uint8Array(this.blockLen);
                e.set(i), this.update(e)
            }
        }
        get() {
            let {
                v0l: e,
                v0h: t,
                v1l: i,
                v1h: r,
                v2l: s,
                v2h: n,
                v3l: o,
                v3h: a,
                v4l: l,
                v4h: c,
                v5l: h,
                v5h: u,
                v6l: d,
                v6h: p,
                v7l: f,
                v7h: g
            } = this;
            return [e, t, i, r, s, n, o, a, l, c, h, u, d, p, f, g]
        }
        set(e, t, i, r, s, n, o, a, l, c, h, u, d, p, f, g) {
            this.v0l = 0 | e, this.v0h = 0 | t, this.v1l = 0 | i, this.v1h = 0 | r, this.v2l = 0 | s, this.v2h = 0 | n, this.v3l = 0 | o, this.v3h = 0 | a, this.v4l = 0 | l, this.v4h = 0 | c, this.v5l = 0 | h, this.v5h = 0 | u, this.v6l = 0 | d, this.v6h = 0 | p, this.v7l = 0 | f, this.v7h = 0 | g
        }
        compress(e, t, i) {
            this.get().forEach((e, t) => eI[t] = e), eI.set(ex, 16);
            let {
                h: r,
                l: s
            } = ev.fromBig(BigInt(this.length));
            eI[24] = ex[8] ^ s, eI[25] = ex[9] ^ r, i && (eI[28] = ~eI[28], eI[29] = ~eI[29]);
            let n = 0;
            for (let i = 0; i < 12; i++) eS(0, 4, 8, 12, e, t + 2 * eb[n++]), e_(0, 4, 8, 12, e, t + 2 * eb[n++]), eS(1, 5, 9, 13, e, t + 2 * eb[n++]), e_(1, 5, 9, 13, e, t + 2 * eb[n++]), eS(2, 6, 10, 14, e, t + 2 * eb[n++]), e_(2, 6, 10, 14, e, t + 2 * eb[n++]), eS(3, 7, 11, 15, e, t + 2 * eb[n++]), e_(3, 7, 11, 15, e, t + 2 * eb[n++]), eS(0, 5, 10, 15, e, t + 2 * eb[n++]), e_(0, 5, 10, 15, e, t + 2 * eb[n++]), eS(1, 6, 11, 12, e, t + 2 * eb[n++]), e_(1, 6, 11, 12, e, t + 2 * eb[n++]), eS(2, 7, 8, 13, e, t + 2 * eb[n++]), e_(2, 7, 8, 13, e, t + 2 * eb[n++]), eS(3, 4, 9, 14, e, t + 2 * eb[n++]), e_(3, 4, 9, 14, e, t + 2 * eb[n++]);
            this.v0l ^= eI[0] ^ eI[16], this.v0h ^= eI[1] ^ eI[17], this.v1l ^= eI[2] ^ eI[18], this.v1h ^= eI[3] ^ eI[19], this.v2l ^= eI[4] ^ eI[20], this.v2h ^= eI[5] ^ eI[21], this.v3l ^= eI[6] ^ eI[22], this.v3h ^= eI[7] ^ eI[23], this.v4l ^= eI[8] ^ eI[24], this.v4h ^= eI[9] ^ eI[25], this.v5l ^= eI[10] ^ eI[26], this.v5h ^= eI[11] ^ eI[27], this.v6l ^= eI[12] ^ eI[28], this.v6h ^= eI[13] ^ eI[29], this.v7l ^= eI[14] ^ eI[30], this.v7h ^= eI[15] ^ eI[31], (0, eE.clean)(eI)
        }
        destroy() {
            this.destroyed = !0, (0, eE.clean)(this.buffer32), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        }
    }
    let eO = (0, eE.createOptHasher)(e => new eA(e)),
        eR = ew.SHA256_IV;

    function eN(e) {
        return `${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`
    }
    e.s(["blake2b", 0, eO], 495913);
    class eU {
        type;
        data;
        constructor(e, t) {
            this.type = e, this.data = t
        }
    }
    class eC extends Error {
        constructor(e) {
            super(e), Object.setPrototypeOf(this, Object.create(eC.prototype)), Object.defineProperty(this, "name", {
                configurable: !0,
                enumerable: !1,
                value: eC.name
            })
        }
    }

    function ek(e, t, i) {
        let r = Math.floor(i / 0x100000000);
        e.setUint32(t, r), e.setUint32(t + 4, i)
    }

    function eL(e, t) {
        return 0x100000000 * e.getInt32(t) + e.getUint32(t + 4)
    }
    let eD = {
        type: -1,
        encode: function(e) {
            if (!(e instanceof Date)) return null; {
                let t, i, r, s;
                return function({
                    sec: e,
                    nsec: t
                }) {
                    if (e >= 0 && t >= 0 && e <= 0x3ffffffff)
                        if (0 === t && e <= 0xffffffff) {
                            let t = new Uint8Array(4);
                            return new DataView(t.buffer).setUint32(0, e), t
                        } else {
                            let i = e / 0x100000000,
                                r = new Uint8Array(8),
                                s = new DataView(r.buffer);
                            return s.setUint32(0, t << 2 | 3 & i), s.setUint32(4, 0 | e), r
                        } {
                            let i = new Uint8Array(12),
                                r = new DataView(i.buffer);
                            return r.setUint32(0, t), ek(r, 4, e), i
                        }
                }((i = Math.floor((t = e.getTime()) / 1e3), s = Math.floor((r = (t - 1e3 * i) * 1e6) / 1e9), {
                    sec: i + s,
                    nsec: r - 1e9 * s
                }))
            }
        },
        decode: function(e) {
            let t = function(e) {
                let t = new DataView(e.buffer, e.byteOffset, e.byteLength);
                switch (e.byteLength) {
                    case 4:
                        return {
                            sec: t.getUint32(0),
                            nsec: 0
                        };
                    case 8:
                        {
                            let e = t.getUint32(0);
                            return {
                                sec: (3 & e) * 0x100000000 + t.getUint32(4),
                                nsec: e >>> 2
                            }
                        }
                    case 12:
                        return {
                            sec: eL(t, 4),
                            nsec: t.getUint32(0)
                        };
                    default:
                        throw new eC(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)
                }
            }(e);
            return new Date(1e3 * t.sec + t.nsec / 1e6)
        }
    };
    class eB {
        static defaultCodec = new eB;
        __brand;
        builtInEncoders = [];
        builtInDecoders = [];
        encoders = [];
        decoders = [];
        constructor() {
            this.register(eD)
        }
        register({
            type: e,
            encode: t,
            decode: i
        }) {
            if (e >= 0) this.encoders[e] = t, this.decoders[e] = i;
            else {
                let r = -1 - e;
                this.builtInEncoders[r] = t, this.builtInDecoders[r] = i
            }
        }
        tryToEncode(e, t) {
            for (let i = 0; i < this.builtInEncoders.length; i++) {
                let r = this.builtInEncoders[i];
                if (null != r) {
                    let s = r(e, t);
                    if (null != s) return new eU(-1 - i, s)
                }
            }
            for (let i = 0; i < this.encoders.length; i++) {
                let r = this.encoders[i];
                if (null != r) {
                    let s = r(e, t);
                    if (null != s) return new eU(i, s)
                }
            }
            return e instanceof eU ? e : null
        }
        decode(e, t, i) {
            let r = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
            return r ? r(e, t, i) : new eU(t, e)
        }
    }
    let eM = new TextEncoder;

    function ej(e, t, i) {
        let r = t,
            s = r + i,
            n = [],
            o = "";
        for (; r < s;) {
            let t = e[r++];
            if ((128 & t) == 0) n.push(t);
            else if ((224 & t) == 192) {
                let i = 63 & e[r++];
                n.push((31 & t) << 6 | i)
            } else if ((240 & t) == 224) {
                let i = 63 & e[r++],
                    s = 63 & e[r++];
                n.push((31 & t) << 12 | i << 6 | s)
            } else if ((248 & t) == 240) {
                let i = (7 & t) << 18 | (63 & e[r++]) << 12 | (63 & e[r++]) << 6 | 63 & e[r++];
                i > 65535 && (i -= 65536, n.push(i >>> 10 & 1023 | 55296), i = 56320 | 1023 & i), n.push(i)
            } else n.push(t);
            n.length >= 4096 && (o += String.fromCharCode(...n), n.length = 0)
        }
        return n.length > 0 && (o += String.fromCharCode(...n)), o
    }
    let e$ = new TextDecoder;

    function eq(e) {
        return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : e instanceof ArrayBuffer || "u" > typeof SharedArrayBuffer && e instanceof SharedArrayBuffer ? new Uint8Array(e) : Uint8Array.from(e)
    }
    let ez = "array",
        eV = "map_key",
        eK = "map_value",
        eF = e => {
            if ("string" == typeof e || "number" == typeof e) return e;
            throw new eC("The type of key must be string or number but " + typeof e)
        };
    class eH {
        stack = [];
        stackHeadPosition = -1;
        get length() {
            return this.stackHeadPosition + 1
        }
        top() {
            return this.stack[this.stackHeadPosition]
        }
        pushArrayState(e) {
            let t = this.getUninitializedStateFromPool();
            t.type = ez, t.position = 0, t.size = e, t.array = Array(e)
        }
        pushMapState(e) {
            let t = this.getUninitializedStateFromPool();
            t.type = eV, t.readCount = 0, t.size = e, t.map = {}
        }
        getUninitializedStateFromPool() {
            return this.stackHeadPosition++, this.stackHeadPosition === this.stack.length && this.stack.push({
                type: void 0,
                size: 0,
                array: void 0,
                position: 0,
                readCount: 0,
                map: void 0,
                key: null
            }), this.stack[this.stackHeadPosition]
        }
        release(e) {
            if (this.stack[this.stackHeadPosition] !== e) throw Error("Invalid stack state. Released state is not on top of the stack.");
            e.type === ez && (e.size = 0, e.array = void 0, e.position = 0, e.type = void 0), (e.type === eV || e.type === eK) && (e.size = 0, e.map = void 0, e.readCount = 0, e.type = void 0), this.stackHeadPosition--
        }
        reset() {
            this.stack.length = 0, this.stackHeadPosition = -1
        }
    }
    let eW = new DataView(new ArrayBuffer(0)),
        eG = new Uint8Array(eW.buffer);
    try {
        eW.getInt8(0)
    } catch (e) {
        if (!(e instanceof RangeError)) throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")
    }
    let eY = RangeError("Insufficient data"),
        eJ = new class {
            hit = 0;
            miss = 0;
            caches;
            maxKeyLength;
            maxLengthPerKey;
            constructor(e = 16, t = 16) {
                this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
                for (let e = 0; e < this.maxKeyLength; e++) this.caches.push([])
            }
            canBeCached(e) {
                return e > 0 && e <= this.maxKeyLength
            }
            find(e, t, i) {
                let r = this.caches[i - 1];
                e: for (let s of r) {
                    let r = s.bytes;
                    for (let s = 0; s < i; s++)
                        if (r[s] !== e[t + s]) continue e;
                    return s.str
                }
                return null
            }
            store(e, t) {
                let i = this.caches[e.length - 1],
                    r = {
                        bytes: e,
                        str: t
                    };
                i.length >= this.maxLengthPerKey ? i[Math.random() * i.length | 0] = r : i.push(r)
            }
            decode(e, t, i) {
                let r = this.find(e, t, i);
                if (null != r) return this.hit++, r;
                this.miss++;
                let s = ej(e, t, i),
                    n = Uint8Array.prototype.slice.call(e, t, t + i);
                return this.store(n, s), s
            }
        };
    class eQ {
        extensionCodec;
        context;
        useBigInt64;
        rawStrings;
        maxStrLength;
        maxBinLength;
        maxArrayLength;
        maxMapLength;
        maxExtLength;
        keyDecoder;
        mapKeyConverter;
        totalPos = 0;
        pos = 0;
        view = eW;
        bytes = eG;
        headByte = -1;
        stack = new eH;
        entered = !1;
        constructor(e) {
            this.extensionCodec = e ? .extensionCodec ? ? eB.defaultCodec, this.context = e ? .context, this.useBigInt64 = e ? .useBigInt64 ? ? !1, this.rawStrings = e ? .rawStrings ? ? !1, this.maxStrLength = e ? .maxStrLength ? ? 0xffffffff, this.maxBinLength = e ? .maxBinLength ? ? 0xffffffff, this.maxArrayLength = e ? .maxArrayLength ? ? 0xffffffff, this.maxMapLength = e ? .maxMapLength ? ? 0xffffffff, this.maxExtLength = e ? .maxExtLength ? ? 0xffffffff, this.keyDecoder = e ? .keyDecoder !== void 0 ? e.keyDecoder : eJ, this.mapKeyConverter = e ? .mapKeyConverter ? ? eF
        }
        clone() {
            return new eQ({
                extensionCodec: this.extensionCodec,
                context: this.context,
                useBigInt64: this.useBigInt64,
                rawStrings: this.rawStrings,
                maxStrLength: this.maxStrLength,
                maxBinLength: this.maxBinLength,
                maxArrayLength: this.maxArrayLength,
                maxMapLength: this.maxMapLength,
                maxExtLength: this.maxExtLength,
                keyDecoder: this.keyDecoder
            })
        }
        reinitializeState() {
            this.totalPos = 0, this.headByte = -1, this.stack.reset()
        }
        setBuffer(e) {
            let t = eq(e);
            this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0
        }
        appendBuffer(e) {
            if (-1 !== this.headByte || this.hasRemaining(1)) {
                let t = this.bytes.subarray(this.pos),
                    i = eq(e),
                    r = new Uint8Array(t.length + i.length);
                r.set(t), r.set(i, t.length), this.setBuffer(r)
            } else this.setBuffer(e)
        }
        hasRemaining(e) {
            return this.view.byteLength - this.pos >= e
        }
        createExtraByteError(e) {
            let {
                view: t,
                pos: i
            } = this;
            return RangeError(`Extra ${t.byteLength-i} of ${t.byteLength} byte(s) found at buffer[${e}]`)
        }
        decode(e) {
            if (this.entered) return this.clone().decode(e);
            try {
                this.entered = !0, this.reinitializeState(), this.setBuffer(e);
                let t = this.doDecodeSync();
                if (this.hasRemaining(1)) throw this.createExtraByteError(this.pos);
                return t
            } finally {
                this.entered = !1
            }
        }* decodeMulti(e) {
            if (this.entered) {
                let t = this.clone();
                yield* t.decodeMulti(e);
                return
            }
            try {
                for (this.entered = !0, this.reinitializeState(), this.setBuffer(e); this.hasRemaining(1);) yield this.doDecodeSync()
            } finally {
                this.entered = !1
            }
        }
        async decodeAsync(e) {
            if (this.entered) return this.clone().decodeAsync(e);
            try {
                let t;
                this.entered = !0;
                let i = !1;
                for await (let r of e) {
                    if (i) throw this.entered = !1, this.createExtraByteError(this.totalPos);
                    this.appendBuffer(r);
                    try {
                        t = this.doDecodeSync(), i = !0
                    } catch (e) {
                        if (!(e instanceof RangeError)) throw e
                    }
                    this.totalPos += this.pos
                }
                if (i) {
                    if (this.hasRemaining(1)) throw this.createExtraByteError(this.totalPos);
                    return t
                }
                let {
                    headByte: r,
                    pos: s,
                    totalPos: n
                } = this;
                throw RangeError(`Insufficient data in parsing ${eN(r)} at ${n} (${s} in the current buffer)`)
            } finally {
                this.entered = !1
            }
        }
        decodeArrayStream(e) {
            return this.decodeMultiAsync(e, !0)
        }
        decodeStream(e) {
            return this.decodeMultiAsync(e, !1)
        }
        async * decodeMultiAsync(e, t) {
            if (this.entered) {
                let i = this.clone();
                yield* i.decodeMultiAsync(e, t);
                return
            }
            try {
                this.entered = !0;
                let i = t,
                    r = -1;
                for await (let s of e) {
                    if (t && 0 === r) throw this.createExtraByteError(this.totalPos);
                    this.appendBuffer(s), i && (r = this.readArraySize(), i = !1, this.complete());
                    try {
                        for (; yield this.doDecodeSync(), 0 != --r;);
                    } catch (e) {
                        if (!(e instanceof RangeError)) throw e
                    }
                    this.totalPos += this.pos
                }
            } finally {
                this.entered = !1
            }
        }
        doDecodeSync() {
            t: for (;;) {
                let e, t = this.readHeadByte();
                if (t >= 224) e = t - 256;
                else if (t < 192)
                    if (t < 128) e = t;
                    else if (t < 144) {
                    let i = t - 128;
                    if (0 !== i) {
                        this.pushMapState(i), this.complete();
                        continue
                    }
                    e = {}
                } else if (t < 160) {
                    let i = t - 144;
                    if (0 !== i) {
                        this.pushArrayState(i), this.complete();
                        continue
                    }
                    e = []
                } else {
                    let i = t - 160;
                    e = this.decodeString(i, 0)
                } else if (192 === t) e = null;
                else if (194 === t) e = !1;
                else if (195 === t) e = !0;
                else if (202 === t) e = this.readF32();
                else if (203 === t) e = this.readF64();
                else if (204 === t) e = this.readU8();
                else if (205 === t) e = this.readU16();
                else if (206 === t) e = this.readU32();
                else if (207 === t) e = this.useBigInt64 ? this.readU64AsBigInt() : this.readU64();
                else if (208 === t) e = this.readI8();
                else if (209 === t) e = this.readI16();
                else if (210 === t) e = this.readI32();
                else if (211 === t) e = this.useBigInt64 ? this.readI64AsBigInt() : this.readI64();
                else if (217 === t) {
                    let t = this.lookU8();
                    e = this.decodeString(t, 1)
                } else if (218 === t) {
                    let t = this.lookU16();
                    e = this.decodeString(t, 2)
                } else if (219 === t) {
                    let t = this.lookU32();
                    e = this.decodeString(t, 4)
                } else if (220 === t) {
                    let t = this.readU16();
                    if (0 !== t) {
                        this.pushArrayState(t), this.complete();
                        continue
                    }
                    e = []
                } else if (221 === t) {
                    let t = this.readU32();
                    if (0 !== t) {
                        this.pushArrayState(t), this.complete();
                        continue
                    }
                    e = []
                } else if (222 === t) {
                    let t = this.readU16();
                    if (0 !== t) {
                        this.pushMapState(t), this.complete();
                        continue
                    }
                    e = {}
                } else if (223 === t) {
                    let t = this.readU32();
                    if (0 !== t) {
                        this.pushMapState(t), this.complete();
                        continue
                    }
                    e = {}
                } else if (196 === t) {
                    let t = this.lookU8();
                    e = this.decodeBinary(t, 1)
                } else if (197 === t) {
                    let t = this.lookU16();
                    e = this.decodeBinary(t, 2)
                } else if (198 === t) {
                    let t = this.lookU32();
                    e = this.decodeBinary(t, 4)
                } else if (212 === t) e = this.decodeExtension(1, 0);
                else if (213 === t) e = this.decodeExtension(2, 0);
                else if (214 === t) e = this.decodeExtension(4, 0);
                else if (215 === t) e = this.decodeExtension(8, 0);
                else if (216 === t) e = this.decodeExtension(16, 0);
                else if (199 === t) {
                    let t = this.lookU8();
                    e = this.decodeExtension(t, 1)
                } else if (200 === t) {
                    let t = this.lookU16();
                    e = this.decodeExtension(t, 2)
                } else if (201 === t) {
                    let t = this.lookU32();
                    e = this.decodeExtension(t, 4)
                } else throw new eC(`Unrecognized type byte: ${eN(t)}`);
                this.complete();
                let i = this.stack;
                for (; i.length > 0;) {
                    let t = i.top();
                    if (t.type === ez)
                        if (t.array[t.position] = e, t.position++, t.position === t.size) e = t.array, i.release(t);
                        else continue t;
                    else if (t.type === eV) {
                        if ("__proto__" === e) throw new eC("The key __proto__ is not allowed");
                        t.key = this.mapKeyConverter(e), t.type = eK;
                        continue t
                    } else if (t.map[t.key] = e, t.readCount++, t.readCount === t.size) e = t.map, i.release(t);
                    else {
                        t.key = null, t.type = eV;
                        continue t
                    }
                }
                return e
            }
        }
        readHeadByte() {
            return -1 === this.headByte && (this.headByte = this.readU8()), this.headByte
        }
        complete() {
            this.headByte = -1
        }
        readArraySize() {
            let e = this.readHeadByte();
            switch (e) {
                case 220:
                    return this.readU16();
                case 221:
                    return this.readU32();
                default:
                    if (e < 160) return e - 144;
                    throw new eC(`Unrecognized array type byte: ${eN(e)}`)
            }
        }
        pushMapState(e) {
            if (e > this.maxMapLength) throw new eC(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
            this.stack.pushMapState(e)
        }
        pushArrayState(e) {
            if (e > this.maxArrayLength) throw new eC(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
            this.stack.pushArrayState(e)
        }
        decodeString(e, t) {
            return !this.rawStrings || this.stateIsMapKey() ? this.decodeUtf8String(e, t) : this.decodeBinary(e, t)
        }
        decodeUtf8String(e, t) {
            let i;
            if (e > this.maxStrLength) throw new eC(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
            if (this.bytes.byteLength < this.pos + t + e) throw eY;
            let r = this.pos + t;
            return i = this.stateIsMapKey() && this.keyDecoder ? .canBeCached(e) ? this.keyDecoder.decode(this.bytes, r, e) : function(e, t, i) {
                let r;
                if (!(i > 200)) return ej(e, t, i);
                return r = e.subarray(t, t + i), e$.decode(r)
            }(this.bytes, r, e), this.pos += t + e, i
        }
        stateIsMapKey() {
            return this.stack.length > 0 && this.stack.top().type === eV
        }
        decodeBinary(e, t) {
            if (e > this.maxBinLength) throw new eC(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
            if (!this.hasRemaining(e + t)) throw eY;
            let i = this.pos + t,
                r = this.bytes.subarray(i, i + e);
            return this.pos += t + e, r
        }
        decodeExtension(e, t) {
            if (e > this.maxExtLength) throw new eC(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
            let i = this.view.getInt8(this.pos + t),
                r = this.decodeBinary(e, t + 1);
            return this.extensionCodec.decode(r, i, this.context)
        }
        lookU8() {
            return this.view.getUint8(this.pos)
        }
        lookU16() {
            return this.view.getUint16(this.pos)
        }
        lookU32() {
            return this.view.getUint32(this.pos)
        }
        readU8() {
            let e = this.view.getUint8(this.pos);
            return this.pos++, e
        }
        readI8() {
            let e = this.view.getInt8(this.pos);
            return this.pos++, e
        }
        readU16() {
            let e = this.view.getUint16(this.pos);
            return this.pos += 2, e
        }
        readI16() {
            let e = this.view.getInt16(this.pos);
            return this.pos += 2, e
        }
        readU32() {
            let e = this.view.getUint32(this.pos);
            return this.pos += 4, e
        }
        readI32() {
            let e = this.view.getInt32(this.pos);
            return this.pos += 4, e
        }
        readU64() {
            var e, t;
            let i = (e = this.view, t = this.pos, 0x100000000 * e.getUint32(t) + e.getUint32(t + 4));
            return this.pos += 8, i
        }
        readI64() {
            let e = eL(this.view, this.pos);
            return this.pos += 8, e
        }
        readU64AsBigInt() {
            let e = this.view.getBigUint64(this.pos);
            return this.pos += 8, e
        }
        readI64AsBigInt() {
            let e = this.view.getBigInt64(this.pos);
            return this.pos += 8, e
        }
        readF32() {
            let e = this.view.getFloat32(this.pos);
            return this.pos += 4, e
        }
        readF64() {
            let e = this.view.getFloat64(this.pos);
            return this.pos += 8, e
        }
    }
    e.s(["decode", 0, function(e, t) {
        return new eQ(t).decode(e)
    }], 73975);
    class eZ {
        extensionCodec;
        context;
        useBigInt64;
        maxDepth;
        initialBufferSize;
        sortKeys;
        forceFloat32;
        ignoreUndefined;
        forceIntegerToFloat;
        pos;
        view;
        bytes;
        entered = !1;
        constructor(e) {
            this.extensionCodec = e ? .extensionCodec ? ? eB.defaultCodec, this.context = e ? .context, this.useBigInt64 = e ? .useBigInt64 ? ? !1, this.maxDepth = e ? .maxDepth ? ? 100, this.initialBufferSize = e ? .initialBufferSize ? ? 2048, this.sortKeys = e ? .sortKeys ? ? !1, this.forceFloat32 = e ? .forceFloat32 ? ? !1, this.ignoreUndefined = e ? .ignoreUndefined ? ? !1, this.forceIntegerToFloat = e ? .forceIntegerToFloat ? ? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer)
        }
        clone() {
            return new eZ({
                extensionCodec: this.extensionCodec,
                context: this.context,
                useBigInt64: this.useBigInt64,
                maxDepth: this.maxDepth,
                initialBufferSize: this.initialBufferSize,
                sortKeys: this.sortKeys,
                forceFloat32: this.forceFloat32,
                ignoreUndefined: this.ignoreUndefined,
                forceIntegerToFloat: this.forceIntegerToFloat
            })
        }
        reinitializeState() {
            this.pos = 0
        }
        encodeSharedRef(e) {
            if (this.entered) return this.clone().encodeSharedRef(e);
            try {
                return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.subarray(0, this.pos)
            } finally {
                this.entered = !1
            }
        }
        encode(e) {
            if (this.entered) return this.clone().encode(e);
            try {
                return this.entered = !0, this.reinitializeState(), this.doEncode(e, 1), this.bytes.slice(0, this.pos)
            } finally {
                this.entered = !1
            }
        }
        doEncode(e, t) {
            if (t > this.maxDepth) throw Error(`Too deep objects in depth ${t}`);
            null == e ? this.encodeNil() : "boolean" == typeof e ? this.encodeBoolean(e) : "number" == typeof e ? this.forceIntegerToFloat ? this.encodeNumberAsFloat(e) : this.encodeNumber(e) : "string" == typeof e ? this.encodeString(e) : this.useBigInt64 && "bigint" == typeof e ? this.encodeBigInt64(e) : this.encodeObject(e, t)
        }
        ensureBufferSizeToWrite(e) {
            let t = this.pos + e;
            this.view.byteLength < t && this.resizeBuffer(2 * t)
        }
        resizeBuffer(e) {
            let t = new ArrayBuffer(e),
                i = new Uint8Array(t),
                r = new DataView(t);
            i.set(this.bytes), this.view = r, this.bytes = i
        }
        encodeNil() {
            this.writeU8(192)
        }
        encodeBoolean(e) {
            !1 === e ? this.writeU8(194) : this.writeU8(195)
        }
        encodeNumber(e) {
            !this.forceIntegerToFloat && Number.isSafeInteger(e) ? e >= 0 ? e < 128 ? this.writeU8(e) : e < 256 ? (this.writeU8(204), this.writeU8(e)) : e < 65536 ? (this.writeU8(205), this.writeU16(e)) : e < 0x100000000 ? (this.writeU8(206), this.writeU32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(207), this.writeU64(e)) : e >= -32 ? this.writeU8(224 | e + 32) : e >= -128 ? (this.writeU8(208), this.writeI8(e)) : e >= -32768 ? (this.writeU8(209), this.writeI16(e)) : e >= -0x80000000 ? (this.writeU8(210), this.writeI32(e)) : this.useBigInt64 ? this.encodeNumberAsFloat(e) : (this.writeU8(211), this.writeI64(e)) : this.encodeNumberAsFloat(e)
        }
        encodeNumberAsFloat(e) {
            this.forceFloat32 ? (this.writeU8(202), this.writeF32(e)) : (this.writeU8(203), this.writeF64(e))
        }
        encodeBigInt64(e) {
            e >= BigInt(0) ? (this.writeU8(207), this.writeBigUint64(e)) : (this.writeU8(211), this.writeBigInt64(e))
        }
        writeStringHeader(e) {
            if (e < 32) this.writeU8(160 + e);
            else if (e < 256) this.writeU8(217), this.writeU8(e);
            else if (e < 65536) this.writeU8(218), this.writeU16(e);
            else if (e < 0x100000000) this.writeU8(219), this.writeU32(e);
            else throw Error(`Too long string: ${e} bytes in UTF-8`)
        }
        encodeString(e) {
            let t = function(e) {
                let t = e.length,
                    i = 0,
                    r = 0;
                for (; r < t;) {
                    let s = e.charCodeAt(r++);
                    if ((0xffffff80 & s) == 0) {
                        i++;
                        continue
                    }
                    if ((0xfffff800 & s) == 0) i += 2;
                    else {
                        if (s >= 55296 && s <= 56319 && r < t) {
                            let t = e.charCodeAt(r);
                            (64512 & t) == 56320 && (++r, s = ((1023 & s) << 10) + (1023 & t) + 65536)
                        }(0xffff0000 & s) == 0 ? i += 3 : i += 4
                    }
                }
                return i
            }(e);
            this.ensureBufferSizeToWrite(5 + t), this.writeStringHeader(t),
                function(e, t, i) {
                    if (e.length > 50) eM.encodeInto(e, t.subarray(i));
                    else ! function(e, t, i) {
                        let r = e.length,
                            s = i,
                            n = 0;
                        for (; n < r;) {
                            let i = e.charCodeAt(n++);
                            if ((0xffffff80 & i) == 0) {
                                t[s++] = i;
                                continue
                            }
                            if ((0xfffff800 & i) == 0) t[s++] = i >> 6 & 31 | 192;
                            else {
                                if (i >= 55296 && i <= 56319 && n < r) {
                                    let t = e.charCodeAt(n);
                                    (64512 & t) == 56320 && (++n, i = ((1023 & i) << 10) + (1023 & t) + 65536)
                                }(0xffff0000 & i) == 0 ? t[s++] = i >> 12 & 15 | 224 : (t[s++] = i >> 18 & 7 | 240, t[s++] = i >> 12 & 63 | 128), t[s++] = i >> 6 & 63 | 128
                            }
                            t[s++] = 63 & i | 128
                        }
                    }(e, t, i)
                }(e, this.bytes, this.pos), this.pos += t
        }
        encodeObject(e, t) {
            let i = this.extensionCodec.tryToEncode(e, this.context);
            if (null != i) this.encodeExtension(i);
            else if (Array.isArray(e)) this.encodeArray(e, t);
            else if (ArrayBuffer.isView(e)) this.encodeBinary(e);
            else if ("object" == typeof e) this.encodeMap(e, t);
            else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)
        }
        encodeBinary(e) {
            let t = e.byteLength;
            if (t < 256) this.writeU8(196), this.writeU8(t);
            else if (t < 65536) this.writeU8(197), this.writeU16(t);
            else if (t < 0x100000000) this.writeU8(198), this.writeU32(t);
            else throw Error(`Too large binary: ${t}`);
            let i = eq(e);
            this.writeU8a(i)
        }
        encodeArray(e, t) {
            let i = e.length;
            if (i < 16) this.writeU8(144 + i);
            else if (i < 65536) this.writeU8(220), this.writeU16(i);
            else if (i < 0x100000000) this.writeU8(221), this.writeU32(i);
            else throw Error(`Too large array: ${i}`);
            for (let i of e) this.doEncode(i, t + 1)
        }
        countWithoutUndefined(e, t) {
            let i = 0;
            for (let r of t) void 0 !== e[r] && i++;
            return i
        }
        encodeMap(e, t) {
            let i = Object.keys(e);
            this.sortKeys && i.sort();
            let r = this.ignoreUndefined ? this.countWithoutUndefined(e, i) : i.length;
            if (r < 16) this.writeU8(128 + r);
            else if (r < 65536) this.writeU8(222), this.writeU16(r);
            else if (r < 0x100000000) this.writeU8(223), this.writeU32(r);
            else throw Error(`Too large map object: ${r}`);
            for (let r of i) {
                let i = e[r];
                this.ignoreUndefined && void 0 === i || (this.encodeString(r), this.doEncode(i, t + 1))
            }
        }
        encodeExtension(e) {
            if ("function" == typeof e.data) {
                let t = e.data(this.pos + 6),
                    i = t.length;
                if (i >= 0x100000000) throw Error(`Too large extension object: ${i}`);
                this.writeU8(201), this.writeU32(i), this.writeI8(e.type), this.writeU8a(t);
                return
            }
            let t = e.data.length;
            if (1 === t) this.writeU8(212);
            else if (2 === t) this.writeU8(213);
            else if (4 === t) this.writeU8(214);
            else if (8 === t) this.writeU8(215);
            else if (16 === t) this.writeU8(216);
            else if (t < 256) this.writeU8(199), this.writeU8(t);
            else if (t < 65536) this.writeU8(200), this.writeU16(t);
            else if (t < 0x100000000) this.writeU8(201), this.writeU32(t);
            else throw Error(`Too large extension object: ${t}`);
            this.writeI8(e.type), this.writeU8a(e.data)
        }
        writeU8(e) {
            this.ensureBufferSizeToWrite(1), this.view.setUint8(this.pos, e), this.pos++
        }
        writeU8a(e) {
            let t = e.length;
            this.ensureBufferSizeToWrite(t), this.bytes.set(e, this.pos), this.pos += t
        }
        writeI8(e) {
            this.ensureBufferSizeToWrite(1), this.view.setInt8(this.pos, e), this.pos++
        }
        writeU16(e) {
            this.ensureBufferSizeToWrite(2), this.view.setUint16(this.pos, e), this.pos += 2
        }
        writeI16(e) {
            this.ensureBufferSizeToWrite(2), this.view.setInt16(this.pos, e), this.pos += 2
        }
        writeU32(e) {
            this.ensureBufferSizeToWrite(4), this.view.setUint32(this.pos, e), this.pos += 4
        }
        writeI32(e) {
            this.ensureBufferSizeToWrite(4), this.view.setInt32(this.pos, e), this.pos += 4
        }
        writeF32(e) {
            this.ensureBufferSizeToWrite(4), this.view.setFloat32(this.pos, e), this.pos += 4
        }
        writeF64(e) {
            this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8
        }
        writeU64(e) {
            var t, i;
            this.ensureBufferSizeToWrite(8), t = this.view, i = this.pos, t.setUint32(i, e / 0x100000000), t.setUint32(i + 4, e), this.pos += 8
        }
        writeI64(e) {
            this.ensureBufferSizeToWrite(8), ek(this.view, this.pos, e), this.pos += 8
        }
        writeBigUint64(e) {
            this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8
        }
        writeBigInt64(e) {
            this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8
        }
    }

    function eX(e) {
        return e instanceof Uint8Array || ArrayBuffer.isView(e) && "Uint8Array" === e.constructor.name
    }

    function e0(e, t) {
        return !!Array.isArray(t) && (0 === t.length || (e ? t.every(e => "string" == typeof e) : t.every(e => Number.isSafeInteger(e))))
    }

    function e1(e) {
        if ("function" != typeof e) throw Error("function expected");
        return !0
    }

    function e2(e, t) {
        if ("string" != typeof t) throw Error(`${e}: string expected`);
        return !0
    }

    function e8(e) {
        if (!Number.isSafeInteger(e)) throw Error(`invalid integer: ${e}`)
    }

    function e3(e) {
        if (!Array.isArray(e)) throw Error("array expected")
    }

    function e6(e, t) {
        if (!e0(!0, t)) throw Error(`${e}: array of strings expected`)
    }

    function e5(e, t) {
        if (!e0(!1, t)) throw Error(`${e}: array of numbers expected`)
    }

    function e4(...e) {
        let t = e => e,
            i = (e, t) => i => e(t(i));
        return {
            encode: e.map(e => e.encode).reduceRight(i, t),
            decode: e.map(e => e.decode).reduce(i, t)
        }
    }

    function e9(e) {
        let t = "string" == typeof e ? e.split("") : e,
            i = t.length;
        e6("alphabet", t);
        let r = new Map(t.map((e, t) => [e, t]));
        return {
            encode: r => (e3(r), r.map(r => {
                if (!Number.isSafeInteger(r) || r < 0 || r >= i) throw Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);
                return t[r]
            })),
            decode: t => (e3(t), t.map(t => {
                e2("alphabet.decode", t);
                let i = r.get(t);
                if (void 0 === i) throw Error(`Unknown letter: "${t}". Allowed: ${e}`);
                return i
            }))
        }
    }

    function e7(e = "") {
        return e2("join", e), {
            encode: t => (e6("join.decode", t), t.join(e)),
            decode: t => (e2("join.decode", t), t.split(e))
        }
    }

    function te(e, t, i) {
        if (t < 2) throw Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);
        if (i < 2) throw Error(`convertRadix: invalid to=${i}, base cannot be less than 2`);
        if (e3(e), !e.length) return [];
        let r = 0,
            s = [],
            n = Array.from(e, e => {
                if (e8(e), e < 0 || e >= t) throw Error(`invalid integer: ${e}`);
                return e
            }),
            o = n.length;
        for (;;) {
            let e = 0,
                a = !0;
            for (let s = r; s < o; s++) {
                let o = n[s],
                    l = t * e,
                    c = l + o;
                if (!Number.isSafeInteger(c) || l / t !== e || c - o !== l) throw Error("convertRadix: carry overflow");
                let h = c / i;
                e = c % i;
                let u = Math.floor(h);
                if (n[s] = u, !Number.isSafeInteger(u) || u * i + e !== c) throw Error("convertRadix: carry overflow");
                a && (u ? a = !1 : r = s)
            }
            if (s.push(e), a) break
        }
        for (let t = 0; t < e.length - 1 && 0 === e[t]; t++) s.push(0);
        return s.reverse()
    }
    e.s(["encode", 0, function(e, t) {
        return new eZ(t).encodeSharedRef(e)
    }], 938918);
    let tt = (e, t) => 0 === t ? e : tt(t, e % t),
        ti = (e, t) => e + (t - tt(e, t)),
        tr = (() => {
            let e = [];
            for (let t = 0; t < 40; t++) e.push(2 ** t);
            return e
        })();

    function ts(e, t, i, r) {
        if (e3(e), t <= 0 || t > 32) throw Error(`convertRadix2: wrong from=${t}`);
        if (i <= 0 || i > 32) throw Error(`convertRadix2: wrong to=${i}`);
        if (ti(t, i) > 32) throw Error(`convertRadix2: carry overflow from=${t} to=${i} carryBits=${ti(t,i)}`);
        let s = 0,
            n = 0,
            o = tr[t],
            a = tr[i] - 1,
            l = [];
        for (let r of e) {
            if (e8(r), r >= o) throw Error(`convertRadix2: invalid data word=${r} from=${t}`);
            if (s = s << t | r, n + t > 32) throw Error(`convertRadix2: carry overflow pos=${n} from=${t}`);
            for (n += t; n >= i; n -= i) l.push((s >> n - i & a) >>> 0);
            let e = tr[n];
            if (void 0 === e) throw Error("invalid carry");
            s &= e - 1
        }
        if (s = s << i - n & a, !r && n >= t) throw Error("Excess padding");
        if (!r && s > 0) throw Error(`Non-zero padding: ${s}`);
        return r && n > 0 && l.push(s >>> 0), l
    }
    let tn = e4(function(e = !1) {
            e8(5), !1;
            if (ti(8, 5) > 32 || ti(5, 8) > 32) throw Error("radix2: carry overflow");
            return {
                encode: t => {
                    if (!eX(t)) throw Error("radix2.encode input should be Uint8Array");
                    return ts(Array.from(t), 8, 5, !e)
                },
                decode: t => (e5("radix2.decode", t), Uint8Array.from(ts(t, 5, 8, e)))
            }
        }(), e9("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), function(e = "=") {
            return e8(5), e2("padding", e), {
                encode(t) {
                    for (e6("padding.encode", t); 5 * t.length % 8;) t.push(e);
                    return t
                },
                decode(t) {
                    e6("padding.decode", t);
                    let i = t.length;
                    if (5 * i % 8) throw Error("padding: invalid, string should have whole number of bytes");
                    for (; i > 0 && t[i - 1] === e; i--)
                        if ((i - 1) * 5 % 8 == 0) throw Error("padding: invalid, string has too much padding");
                    return t.slice(0, i)
                }
            }
        }(), e7("")),
        to = "function" == typeof Uint8Array.from([]).toBase64 && "function" == typeof Uint8Array.fromBase64,
        ta = e4((e8(58), {
            encode: e => {
                if (!eX(e)) throw Error("radix.encode input should be Uint8Array");
                return te(Array.from(e), 256, 58)
            },
            decode: e => (e5("radix.decode", e), Uint8Array.from(te(e, 58, 256)))
        }), e9("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), e7("")),
        tl = e4(e9("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), e7(""));
    "function" == typeof Uint8Array.from([]).toHex && "function" == typeof Uint8Array.fromHex || e1(e => {
        if ("string" != typeof e || e.length % 2 != 0) throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
        return e.toLowerCase()
    }), e.s(["base32", 0, tn, "base58", 0, ta], 696172), e.s(["compare", 0, function(e, t) {
        for (let i = 0; i < e.byteLength; i++) {
            if (e[i] < t[i]) return -1;
            if (e[i] > t[i]) return 1
        }
        return e.byteLength > t.byteLength ? 1 : e.byteLength < t.byteLength ? -1 : 0
    }], 735291)
}, 398936, 562975, e => {
    "use strict";

    function t(e) {
        return null != globalThis.Buffer ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : e
    }
    e.s(["asUint8Array", 0, t], 562975), e.s(["allocUnsafe", 0, function(e = 0) {
        return null != globalThis.Buffer && null != globalThis.Buffer.allocUnsafe ? t(globalThis.Buffer.allocUnsafe(e)) : new Uint8Array(e)
    }], 398936)
}, 724990, 810685, e => {
    "use strict";
    var t = e.i(398936),
        i = e.i(562975);
    e.s(["concat", 0, function(e, r) {
        r || (r = e.reduce((e, t) => e + t.length, 0));
        let s = (0, t.allocUnsafe)(r),
            n = 0;
        for (let t of e) s.set(t, n), n += t.length;
        return (0, i.asUint8Array)(s)
    }], 724990), e.s(["equals", 0, function(e, t) {
        if (e === t) return !0;
        if (e.byteLength !== t.byteLength) return !1;
        for (let i = 0; i < e.byteLength; i++)
            if (e[i] !== t[i]) return !1;
        return !0
    }], 810685)
}, 824787, e => {
    "use strict";
    let t = function(e, t) {
            if (e.length >= 255) throw TypeError("Alphabet too long");
            for (var i = new Uint8Array(256), r = 0; r < i.length; r++) i[r] = 255;
            for (var s = 0; s < e.length; s++) {
                var n = e.charAt(s),
                    o = n.charCodeAt(0);
                if (255 !== i[o]) throw TypeError(n + " is ambiguous");
                i[o] = s
            }
            var a = e.length,
                l = e.charAt(0),
                c = Math.log(a) / Math.log(256),
                h = Math.log(256) / Math.log(a);

            function u(e) {
                if ("string" != typeof e) throw TypeError("Expected String");
                if (0 === e.length) return new Uint8Array;
                var t = 0;
                if (" " !== e[0]) {
                    for (var r = 0, s = 0; e[t] === l;) r++, t++;
                    for (var n = (e.length - t) * c + 1 >>> 0, o = new Uint8Array(n); e[t];) {
                        var h = i[e.charCodeAt(t)];
                        if (255 === h) return;
                        for (var u = 0, d = n - 1;
                            (0 !== h || u < s) && -1 !== d; d--, u++) h += a * o[d] >>> 0, o[d] = h % 256 >>> 0, h = h / 256 >>> 0;
                        if (0 !== h) throw Error("Non-zero carry");
                        s = u, t++
                    }
                    if (" " !== e[t]) {
                        for (var p = n - s; p !== n && 0 === o[p];) p++;
                        for (var f = new Uint8Array(r + (n - p)), g = r; p !== n;) f[g++] = o[p++];
                        return f
                    }
                }
            }
            return {
                encode: function(t) {
                    if (t instanceof Uint8Array || (ArrayBuffer.isView(t) ? t = new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : Array.isArray(t) && (t = Uint8Array.from(t))), !(t instanceof Uint8Array)) throw TypeError("Expected Uint8Array");
                    if (0 === t.length) return "";
                    for (var i = 0, r = 0, s = 0, n = t.length; s !== n && 0 === t[s];) s++, i++;
                    for (var o = (n - s) * h + 1 >>> 0, c = new Uint8Array(o); s !== n;) {
                        for (var u = t[s], d = 0, p = o - 1;
                            (0 !== u || d < r) && -1 !== p; p--, d++) u += 256 * c[p] >>> 0, c[p] = u % a >>> 0, u = u / a >>> 0;
                        if (0 !== u) throw Error("Non-zero carry");
                        r = d, s++
                    }
                    for (var f = o - r; f !== o && 0 === c[f];) f++;
                    for (var g = l.repeat(i); f < o; ++f) g += e.charAt(c[f]);
                    return g
                },
                decodeUnsafe: u,
                decode: function(e) {
                    var i = u(e);
                    if (i) return i;
                    throw Error(`Non-${t} character`)
                }
            }
        },
        i = new Uint8Array(0),
        r = (e, t) => {
            if (e === t) return !0;
            if (e.byteLength !== t.byteLength) return !1;
            for (let i = 0; i < e.byteLength; i++)
                if (e[i] !== t[i]) return !1;
            return !0
        },
        s = e => {
            if (e instanceof Uint8Array && "Uint8Array" === e.constructor.name) return e;
            if (e instanceof ArrayBuffer) return new Uint8Array(e);
            if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
            throw Error("Unknown type, must be binary type")
        },
        n = e => new TextEncoder().encode(e),
        o = e => new TextDecoder().decode(e);
    e.s(["coerce", 0, s, "empty", 0, i, "equals", 0, r, "fromHex", 0, e => {
        let t = e.match(/../g);
        return t ? new Uint8Array(t.map(e => parseInt(e, 16))) : i
    }, "fromString", 0, n, "isBinary", 0, e => e instanceof ArrayBuffer || ArrayBuffer.isView(e), "toHex", 0, e => e.reduce((e, t) => e + t.toString(16).padStart(2, "0"), ""), "toString", 0, o], 934782);
    class a {
        constructor(e, t, i) {
            this.name = e, this.prefix = t, this.baseEncode = i
        }
        encode(e) {
            if (e instanceof Uint8Array) return `${this.prefix}${this.baseEncode(e)}`;
            throw Error("Unknown type, must be binary type")
        }
    }
    class l {
        constructor(e, t, i) {
            if (this.name = e, this.prefix = t, void 0 === t.codePointAt(0)) throw Error("Invalid prefix character");
            this.prefixCodePoint = t.codePointAt(0), this.baseDecode = i
        }
        decode(e) {
            if ("string" == typeof e) {
                if (e.codePointAt(0) !== this.prefixCodePoint) throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
                return this.baseDecode(e.slice(this.prefix.length))
            }
            throw Error("Can only multibase decode strings")
        }
        or(e) {
            return h(this, e)
        }
    }
    class c {
        constructor(e) {
            this.decoders = e
        }
        or(e) {
            return h(this, e)
        }
        decode(e) {
            let t = e[0],
                i = this.decoders[t];
            if (i) return i.decode(e);
            throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)
        }
    }
    let h = (e, t) => new c({ ...e.decoders || {
            [e.prefix]: e
        },
        ...t.decoders || {
            [t.prefix]: t
        }
    });
    class u {
        constructor(e, t, i, r) {
            this.name = e, this.prefix = t, this.baseEncode = i, this.baseDecode = r, this.encoder = new a(e, t, i), this.decoder = new l(e, t, r)
        }
        encode(e) {
            return this.encoder.encode(e)
        }
        decode(e) {
            return this.decoder.decode(e)
        }
    }
    let d = ({
            name: e,
            prefix: t,
            encode: i,
            decode: r
        }) => new u(e, t, i, r),
        p = ({
            prefix: e,
            name: i,
            alphabet: r
        }) => {
            let {
                encode: n,
                decode: o
            } = t(r, i);
            return d({
                prefix: e,
                name: i,
                encode: n,
                decode: e => s(o(e))
            })
        },
        f = ({
            name: e,
            prefix: t,
            bitsPerChar: i,
            alphabet: r
        }) => d({
            prefix: t,
            name: e,
            encode: e => ((e, t, i) => {
                let r = "=" === t[t.length - 1],
                    s = (1 << i) - 1,
                    n = "",
                    o = 0,
                    a = 0;
                for (let r = 0; r < e.length; ++r)
                    for (a = a << 8 | e[r], o += 8; o > i;) o -= i, n += t[s & a >> o];
                if (o && (n += t[s & a << i - o]), r)
                    for (; n.length * i & 7;) n += "=";
                return n
            })(e, r, i),
            decode: t => ((e, t, i, r) => {
                let s = {};
                for (let e = 0; e < t.length; ++e) s[t[e]] = e;
                let n = e.length;
                for (;
                    "=" === e[n - 1];) --n;
                let o = new Uint8Array(n * i / 8 | 0),
                    a = 0,
                    l = 0,
                    c = 0;
                for (let t = 0; t < n; ++t) {
                    let n = s[e[t]];
                    if (void 0 === n) throw SyntaxError(`Non-${r} character`);
                    l = l << i | n, (a += i) >= 8 && (a -= 8, o[c++] = 255 & l >> a)
                }
                if (a >= i || 255 & l << 8 - a) throw SyntaxError("Unexpected end of data");
                return o
            })(t, r, i, e)
        }),
        g = d({
            prefix: "\0",
            name: "identity",
            encode: e => o(e),
            decode: e => n(e)
        });
    e.s(["identity", 0, g], 522771);
    var y = e.i(522771);
    let m = f({
        prefix: "0",
        name: "base2",
        alphabet: "01",
        bitsPerChar: 1
    });
    e.s(["base2", 0, m], 716499);
    var b = e.i(716499);
    let w = f({
        prefix: "7",
        name: "base8",
        alphabet: "01234567",
        bitsPerChar: 3
    });
    e.s(["base8", 0, w], 190857);
    var v = e.i(190857);
    let E = p({
        prefix: "9",
        name: "base10",
        alphabet: "0123456789"
    });
    e.s(["base10", 0, E], 535636);
    var x = e.i(535636);
    let I = f({
            prefix: "f",
            name: "base16",
            alphabet: "0123456789abcdef",
            bitsPerChar: 4
        }),
        S = f({
            prefix: "F",
            name: "base16upper",
            alphabet: "0123456789ABCDEF",
            bitsPerChar: 4
        });
    e.s(["base16", 0, I, "base16upper", 0, S], 537850);
    var _ = e.i(537850);
    let P = f({
            prefix: "b",
            name: "base32",
            alphabet: "abcdefghijklmnopqrstuvwxyz234567",
            bitsPerChar: 5
        }),
        T = f({
            prefix: "B",
            name: "base32upper",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
            bitsPerChar: 5
        }),
        A = f({
            prefix: "c",
            name: "base32pad",
            alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
            bitsPerChar: 5
        }),
        O = f({
            prefix: "C",
            name: "base32padupper",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
            bitsPerChar: 5
        }),
        R = f({
            prefix: "v",
            name: "base32hex",
            alphabet: "0123456789abcdefghijklmnopqrstuv",
            bitsPerChar: 5
        }),
        N = f({
            prefix: "V",
            name: "base32hexupper",
            alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
            bitsPerChar: 5
        }),
        U = f({
            prefix: "t",
            name: "base32hexpad",
            alphabet: "0123456789abcdefghijklmnopqrstuv=",
            bitsPerChar: 5
        }),
        C = f({
            prefix: "T",
            name: "base32hexpadupper",
            alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
            bitsPerChar: 5
        }),
        k = f({
            prefix: "h",
            name: "base32z",
            alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
            bitsPerChar: 5
        });
    e.s(["base32", 0, P, "base32hex", 0, R, "base32hexpad", 0, U, "base32hexpadupper", 0, C, "base32hexupper", 0, N, "base32pad", 0, A, "base32padupper", 0, O, "base32upper", 0, T, "base32z", 0, k], 459905);
    var L = e.i(459905);
    let D = p({
            prefix: "k",
            name: "base36",
            alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
        }),
        B = p({
            prefix: "K",
            name: "base36upper",
            alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        });
    e.s(["base36", 0, D, "base36upper", 0, B], 892724);
    var M = e.i(892724);
    let j = p({
            name: "base58btc",
            prefix: "z",
            alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
        }),
        $ = p({
            name: "base58flickr",
            prefix: "Z",
            alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
        });
    e.s(["base58btc", 0, j, "base58flickr", 0, $], 495559);
    var q = e.i(495559);
    let z = f({
            prefix: "m",
            name: "base64",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
            bitsPerChar: 6
        }),
        V = f({
            prefix: "M",
            name: "base64pad",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
            bitsPerChar: 6
        }),
        K = f({
            prefix: "u",
            name: "base64url",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
            bitsPerChar: 6
        }),
        F = f({
            prefix: "U",
            name: "base64urlpad",
            alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
            bitsPerChar: 6
        });
    e.s(["base64", 0, z, "base64pad", 0, V, "base64url", 0, K, "base64urlpad", 0, F], 559513);
    var H = e.i(559513);
    let W = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),
        G = W.reduce((e, t, i) => (e[i] = t, e), []),
        Y = W.reduce((e, t, i) => (e[t.codePointAt(0)] = i, e), []),
        J = d({
            prefix: "🚀",
            name: "base256emoji",
            encode: function(e) {
                return e.reduce((e, t) => e += G[t], "")
            },
            decode: function(e) {
                let t = [];
                for (let i of e) {
                    let e = Y[i.codePointAt(0)];
                    if (void 0 === e) throw Error(`Non-base256emoji character: ${i}`);
                    t.push(e)
                }
                return new Uint8Array(t)
            }
        });
    e.s(["base256emoji", 0, J], 915157);
    var Q = e.i(915157);

    function Z(e, t, i) {
        t = t || [];
        for (var r = i = i || 0; e >= 0x80000000;) t[i++] = 255 & e | 128, e /= 128;
        for (; - 128 & e;) t[i++] = 255 & e | 128, e >>>= 7;
        return t[i] = 0 | e, Z.bytes = i - r + 1, t
    }

    function X(e, t) {
        var i, r = 0,
            t = t || 0,
            s = 0,
            n = t,
            o = e.length;
        do {
            if (n >= o) throw X.bytes = 0, RangeError("Could not decode varint");
            i = e[n++], r += s < 28 ? (127 & i) << s : (127 & i) * Math.pow(2, s), s += 7
        } while (i >= 128) return X.bytes = n - t, r
    }
    let ee = (e, t = 0) => [X(e, t), X.bytes],
        et = (e, t, i = 0) => (Z(e, t, i), t),
        ei = e => {
            var t;
            return (t = e) < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 0x10000000 ? 4 : t < 0x800000000 ? 5 : t < 0x40000000000 ? 6 : t < 0x2000000000000 ? 7 : t < 0x100000000000000 ? 8 : t < 0x8000000000000000 ? 9 : 10
        };
    e.s(["decode", 0, ee, "encodeTo", 0, et, "encodingLength", 0, ei], 489430);
    let er = (e, t) => {
            let i = t.byteLength,
                r = ei(e),
                s = r + ei(i),
                n = new Uint8Array(s + i);
            return et(e, n, 0), et(i, n, r), n.set(t, s), new eo(e, i, t, n)
        },
        es = e => {
            let t = s(e),
                [i, r] = ee(t),
                [n, o] = ee(t.subarray(r)),
                a = t.subarray(r + o);
            if (a.byteLength !== n) throw Error("Incorrect length");
            return new eo(i, n, a, t)
        },
        en = (e, t) => e === t || e.code === t.code && e.size === t.size && r(e.bytes, t.bytes);
    class eo {
        constructor(e, t, i, r) {
            this.code = e, this.size = t, this.digest = i, this.bytes = r
        }
    }
    e.s(["Digest", 0, eo, "create", 0, er, "decode", 0, es, "equals", 0, en], 794804);
    let ea = ({
        name: e,
        code: t,
        encode: i
    }) => new el(e, t, i);
    class el {
        constructor(e, t, i) {
            this.name = e, this.code = t, this.encode = i
        }
        digest(e) {
            if (e instanceof Uint8Array) {
                let t = this.encode(e);
                return t instanceof Uint8Array ? er(this.code, t) : t.then(e => er(this.code, e))
            }
            throw Error("Unknown type, must be binary type")
        }
    }
    e.s(["Hasher", 0, el, "from", 0, ea], 499880);
    let ec = e => async t => new Uint8Array(await crypto.subtle.digest(e, t)),
        eh = ea({
            name: "sha2-256",
            code: 18,
            encode: ec("SHA-256")
        }),
        eu = ea({
            name: "sha2-512",
            code: 19,
            encode: ec("SHA-512")
        });
    e.s(["sha256", 0, eh, "sha512", 0, eu], 696715);
    e.i(696715);
    e.s(["identity", 0, {
        code: 0,
        name: "identity",
        encode: s,
        digest: e => er(0, s(e))
    }], 516096);
    e.i(516096);
    e.s(["code", 0, 85, "decode", 0, e => s(e), "encode", 0, e => s(e), "name", 0, "raw"], 586632), e.i(586632);
    let ed = new TextEncoder,
        ep = new TextDecoder;
    e.s(["code", 0, 512, "decode", 0, e => JSON.parse(ep.decode(e)), "encode", 0, e => ed.encode(JSON.stringify(e)), "name", 0, "json"], 61009), e.i(61009);
    class ef {
        constructor(e, t, i, r) {
            this.code = t, this.version = e, this.multihash = i, this.bytes = r, this.byteOffset = r.byteOffset, this.byteLength = r.byteLength, this.asCID = this, this._baseCache = new Map, Object.defineProperties(this, {
                byteOffset: eI,
                byteLength: eI,
                code: ex,
                version: ex,
                multihash: ex,
                bytes: ex,
                _baseCache: eI,
                asCID: eI
            })
        }
        toV0() {
            if (0 === this.version) return this; {
                let {
                    code: e,
                    multihash: t
                } = this;
                if (e !== eb) throw Error("Cannot convert a non dag-pb CID to CIDv0");
                if (t.code !== ew) throw Error("Cannot convert non sha2-256 multihash CID to CIDv0");
                return ef.createV0(t)
            }
        }
        toV1() {
            switch (this.version) {
                case 0:
                    {
                        let {
                            code: e,
                            digest: t
                        } = this.multihash,
                        i = er(e, t);
                        return ef.createV1(this.code, i)
                    }
                case 1:
                    return this;
                default:
                    throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)
            }
        }
        equals(e) {
            return e && this.code === e.code && this.version === e.version && en(this.multihash, e.multihash)
        }
        toString(e) {
            let {
                bytes: t,
                version: i,
                _baseCache: r
            } = this;
            return 0 === i ? ey(t, r, e || j.encoder) : em(t, r, e || P.encoder)
        }
        toJSON() {
            return {
                code: this.code,
                version: this.version,
                hash: this.multihash.bytes
            }
        }
        get[Symbol.toStringTag]() {
            return "CID"
        }[Symbol.for("nodejs.util.inspect.custom")]() {
            return "CID(" + this.toString() + ")"
        }
        static isCID(e) {
            return eS(/^0\.0/, e_), !!(e && (e[eE] || e.asCID === e))
        }
        get toBaseEncodedString() {
            throw Error("Deprecated, use .toString()")
        }
        get codec() {
            throw Error('"codec" property is deprecated, use integer "code" property instead')
        }
        get buffer() {
            throw Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")
        }
        get multibaseName() {
            throw Error('"multibaseName" property is deprecated')
        }
        get prefix() {
            throw Error('"prefix" property is deprecated')
        }
        static asCID(e) {
            if (e instanceof ef) return e;
            if (null != e && e.asCID === e) {
                let {
                    version: t,
                    code: i,
                    multihash: r,
                    bytes: s
                } = e;
                return new ef(t, i, r, s || ev(t, i, r.bytes))
            }
            if (null == e || !0 !== e[eE]) return null; {
                let {
                    version: t,
                    multihash: i,
                    code: r
                } = e, s = es(i);
                return ef.create(t, r, s)
            }
        }
        static create(e, t, i) {
            if ("number" != typeof t) throw Error("String codecs are no longer supported");
            switch (e) {
                case 0:
                    if (t === eb) return new ef(e, t, i, i.bytes);
                    throw Error(`Version 0 CID must use dag-pb (code: ${eb}) block encoding`);
                case 1:
                    {
                        let r = ev(e, t, i.bytes);
                        return new ef(e, t, i, r)
                    }
                default:
                    throw Error("Invalid version")
            }
        }
        static createV0(e) {
            return ef.create(0, eb, e)
        }
        static createV1(e, t) {
            return ef.create(1, e, t)
        }
        static decode(e) {
            let [t, i] = ef.decodeFirst(e);
            if (i.length) throw Error("Incorrect length");
            return t
        }
        static decodeFirst(e) {
            let t = ef.inspectBytes(e),
                i = t.size - t.multihashSize,
                r = s(e.subarray(i, i + t.multihashSize));
            if (r.byteLength !== t.multihashSize) throw Error("Incorrect length");
            let n = r.subarray(t.multihashSize - t.digestSize),
                o = new eo(t.multihashCode, t.digestSize, n, r);
            return [0 === t.version ? ef.createV0(o) : ef.createV1(t.codec, o), e.subarray(t.size)]
        }
        static inspectBytes(e) {
            let t = 0,
                i = () => {
                    let [i, r] = ee(e.subarray(t));
                    return t += r, i
                },
                r = i(),
                s = eb;
            if (18 === r ? (r = 0, t = 0) : 1 === r && (s = i()), 0 !== r && 1 !== r) throw RangeError(`Invalid CID version ${r}`);
            let n = t,
                o = i(),
                a = i(),
                l = t + a;
            return {
                version: r,
                codec: s,
                multihashCode: o,
                digestSize: a,
                multihashSize: l - n,
                size: l
            }
        }
        static parse(e, t) {
            let [i, r] = eg(e, t), s = ef.decode(r);
            return s._baseCache.set(i, e), s
        }
    }
    let eg = (e, t) => {
            switch (e[0]) {
                case "Q":
                    {
                        let i = t || j;
                        return [j.prefix, i.decode(`${j.prefix}${e}`)]
                    }
                case j.prefix:
                    {
                        let i = t || j;
                        return [j.prefix, i.decode(e)]
                    }
                case P.prefix:
                    {
                        let i = t || P;
                        return [P.prefix, i.decode(e)]
                    }
                default:
                    if (null == t) throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
                    return [e[0], t.decode(e)]
            }
        },
        ey = (e, t, i) => {
            let {
                prefix: r
            } = i;
            if (r !== j.prefix) throw Error(`Cannot string encode V0 in ${i.name} encoding`);
            let s = t.get(r);
            if (null != s) return s; {
                let s = i.encode(e).slice(1);
                return t.set(r, s), s
            }
        },
        em = (e, t, i) => {
            let {
                prefix: r
            } = i, s = t.get(r);
            if (null != s) return s; {
                let s = i.encode(e);
                return t.set(r, s), s
            }
        },
        eb = 112,
        ew = 18,
        ev = (e, t, i) => {
            let r = ei(e),
                s = r + ei(t),
                n = new Uint8Array(s + i.byteLength);
            return et(e, n, 0), et(t, n, r), n.set(i, s), n
        },
        eE = Symbol.for("@ipld/js-cid/CID"),
        ex = {
            writable: !1,
            configurable: !1,
            enumerable: !0
        },
        eI = {
            writable: !1,
            enumerable: !1,
            configurable: !1
        },
        eS = (e, t) => {
            if (e.test("0.0.0-dev")) console.warn(t);
            else throw Error(t)
        },
        e_ = `CID.isCID(v) is deprecated and will be removed in the next major release.
Following code pattern:

if (CID.isCID(value)) {
  doSomethingWithCID(value)
}

Is replaced with:

const cid = CID.asCID(value)
if (cid) {
  // Make sure to use cid instead of value
  doSomethingWithCID(cid)
}
`;
    e.i(489430), e.i(934782), e.i(499880), e.i(794804);
    let eP = { ...y,
        ...b,
        ...v,
        ...x,
        ..._,
        ...L,
        ...M,
        ...q,
        ...H,
        ...Q
    };
    e.s(["bases", 0, eP], 824787)
}, 634417, 40624, e => {
    "use strict";
    var t = e.i(824787),
        i = e.i(398936);

    function r(e, t, i, r) {
        return {
            name: e,
            prefix: t,
            encoder: {
                name: e,
                prefix: t,
                encode: i
            },
            decoder: {
                decode: r
            }
        }
    }
    let s = r("utf8", "u", e => "u" + new TextDecoder("utf8").decode(e), e => new TextEncoder().encode(e.substring(1))),
        n = r("ascii", "a", e => {
            let t = "a";
            for (let i = 0; i < e.length; i++) t += String.fromCharCode(e[i]);
            return t
        }, e => {
            e = e.substring(1);
            let t = (0, i.allocUnsafe)(e.length);
            for (let i = 0; i < e.length; i++) t[i] = e.charCodeAt(i);
            return t
        }),
        o = {
            utf8: s,
            "utf-8": s,
            hex: t.bases.base16,
            latin1: n,
            ascii: n,
            binary: n,
            ...t.bases
        };
    e.s(["default", 0, o], 40624);
    var a = e.i(562975);
    e.s(["fromString", 0, function(e, t = "utf8") {
        let i = o[t];
        if (!i) throw Error(`Unsupported encoding "${t}"`);
        return ("utf8" === t || "utf-8" === t) && null != globalThis.Buffer && null != globalThis.Buffer.from ? (0, a.asUint8Array)(globalThis.Buffer.from(e, "utf-8")) : i.decoder.decode(`${i.prefix}${e}`)
    }], 634417)
}, 843010, 72716, 736820, 724197, 269956, e => {
    "use strict";
    let t, i, r;
    e.i(735291), e.i(724990), e.i(810685), e.i(634417);
    var s, n, o, a = e.i(40624);

    function l(e) {
        return e instanceof Uint8Array || ArrayBuffer.isView(e) && "Uint8Array" === e.constructor.name
    }

    function c(e) {
        if ("boolean" != typeof e) throw Error(`boolean expected, not ${e}`)
    }

    function h(e) {
        if (!Number.isSafeInteger(e) || e < 0) throw Error("positive integer expected, got " + e)
    }

    function u(e, ...t) {
        if (!l(e)) throw Error("Uint8Array expected");
        if (t.length > 0 && !t.includes(e.length)) throw Error("Uint8Array expected of length " + t + ", got length=" + e.length)
    }

    function d(e, t = !0) {
        if (e.destroyed) throw Error("Hash instance has been destroyed");
        if (t && e.finished) throw Error("Hash#digest() has already been called")
    }

    function p(e) {
        return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4))
    }

    function f(...e) {
        for (let t = 0; t < e.length; t++) e[t].fill(0)
    }
    e.s(["toString", 0, function(e, t = "utf8") {
        let i = a.default[t];
        if (!i) throw Error(`Unsupported encoding "${t}"`);
        return ("utf8" === t || "utf-8" === t) && null != globalThis.Buffer && null != globalThis.Buffer.from ? globalThis.Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("utf8") : i.encoder.encode(e).substring(1)
    }], 72716), e.i(398936), e.i(562975), e.s([], 843010);
    let g = 68 === new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];

    function y(e) {
        if ("string" == typeof e) e = function(e) {
            if ("string" != typeof e) throw Error("string expected");
            return new Uint8Array(new TextEncoder().encode(e))
        }(e);
        else if (l(e)) e = w(e);
        else throw Error("Uint8Array expected, got " + typeof e);
        return e
    }

    function m(e, t, i = !0) {
        if (void 0 === t) return new Uint8Array(e);
        if (t.length !== e) throw Error("invalid output length, expected " + e + ", got: " + t.length);
        if (i && t.byteOffset % 4 != 0) throw Error("invalid output, must be aligned");
        return t
    }

    function b(e, t, i, r) {
        if ("function" == typeof e.setBigUint64) return e.setBigUint64(t, i, r);
        let s = BigInt(32),
            n = BigInt(0xffffffff),
            o = Number(i >> s & n),
            a = Number(i & n),
            l = 4 * !!r,
            c = 4 * !r;
        e.setUint32(t + l, o, r), e.setUint32(t + c, a, r)
    }

    function w(e) {
        return Uint8Array.from(e)
    }
    let v = e => Uint8Array.from(e.split("").map(e => e.charCodeAt(0))),
        E = v("expand 16-byte k"),
        x = v("expand 32-byte k"),
        I = p(E),
        S = p(x);

    function _(e, t) {
        return e << t | e >>> 32 - t
    }

    function P(e) {
        return e.byteOffset % 4 == 0
    }
    let T = 0x100000000 - 1,
        A = new Uint32Array;

    function O(e, t) {
        let {
            allowShortKeys: i,
            extendNonceFn: r,
            counterLength: s,
            counterRight: n,
            rounds: o
        } = function(e, t) {
            if (null == t || "object" != typeof t) throw Error("options must be defined");
            return Object.assign(e, t)
        }({
            allowShortKeys: !1,
            counterLength: 8,
            counterRight: !1,
            rounds: 20
        }, t);
        if ("function" != typeof e) throw Error("core must be a function");
        return h(s), h(o), c(n), c(i), (t, a, l, c, d = 0) => {
            let g, y;
            u(t), u(a), u(l);
            let m = l.length;
            if (void 0 === c && (c = new Uint8Array(m)), u(c), h(d), d < 0 || d >= T) throw Error("arx: counter overflow");
            if (c.length < m) throw Error(`arx: output (${c.length}) is shorter than data (${m})`);
            let b = [],
                v = t.length;
            if (32 === v) b.push(g = w(t)), y = S;
            else if (16 === v && i)(g = new Uint8Array(32)).set(t), g.set(t, 16), y = I, b.push(g);
            else throw Error(`arx: invalid 32-byte key, got length=${v}`);
            P(a) || b.push(a = w(a));
            let E = p(g);
            if (r) {
                if (24 !== a.length) throw Error("arx: extended nonce must be 24 bytes");
                r(y, E, p(a.subarray(0, 16)), E), a = a.subarray(16)
            }
            let x = 16 - s;
            if (x !== a.length) throw Error(`arx: nonce must be ${x} or 16 bytes`);
            if (12 !== x) {
                let e = new Uint8Array(12);
                e.set(a, n ? 0 : 12 - a.length), a = e, b.push(a)
            }
            return ! function(e, t, i, r, s, n, o, a) {
                let l = s.length,
                    c = new Uint8Array(64),
                    h = p(c),
                    u = P(s) && P(n),
                    d = u ? p(s) : A,
                    f = u ? p(n) : A;
                for (let p = 0; p < l; o++) {
                    if (e(t, i, r, h, o, a), o >= T) throw Error("arx: counter overflow");
                    let g = Math.min(64, l - p);
                    if (u && 64 === g) {
                        let e = p / 4;
                        if (p % 4 != 0) throw Error("arx: invalid block position");
                        for (let t = 0, i; t < 16; t++) f[i = e + t] = d[i] ^ h[t];
                        p += 64;
                        continue
                    }
                    for (let e = 0, t; e < g; e++) n[t = p + e] = s[t] ^ c[e];
                    p += g
                }
            }(e, y, E, p(a), l, c, d, o), f(...b), c
        }
    }
    let R = (e, t) => 255 & e[t++] | (255 & e[t++]) << 8;
    class N {
        constructor(e) {
            this.blockLen = 16, this.outputLen = 16, this.buffer = new Uint8Array(16), this.r = new Uint16Array(10), this.h = new Uint16Array(10), this.pad = new Uint16Array(8), this.pos = 0, this.finished = !1, u(e = y(e), 32);
            const t = R(e, 0),
                i = R(e, 2),
                r = R(e, 4),
                s = R(e, 6),
                n = R(e, 8),
                o = R(e, 10),
                a = R(e, 12),
                l = R(e, 14);
            this.r[0] = 8191 & t, this.r[1] = (t >>> 13 | i << 3) & 8191, this.r[2] = (i >>> 10 | r << 6) & 7939, this.r[3] = (r >>> 7 | s << 9) & 8191, this.r[4] = (s >>> 4 | n << 12) & 255, this.r[5] = n >>> 1 & 8190, this.r[6] = (n >>> 14 | o << 2) & 8191, this.r[7] = (o >>> 11 | a << 5) & 8065, this.r[8] = (a >>> 8 | l << 8) & 8191, this.r[9] = l >>> 5 & 127;
            for (let t = 0; t < 8; t++) this.pad[t] = R(e, 16 + 2 * t)
        }
        process(e, t, i = !1) {
            let {
                h: r,
                r: s
            } = this, n = s[0], o = s[1], a = s[2], l = s[3], c = s[4], h = s[5], u = s[6], d = s[7], p = s[8], f = s[9], g = R(e, t + 0), y = R(e, t + 2), m = R(e, t + 4), b = R(e, t + 6), w = R(e, t + 8), v = R(e, t + 10), E = R(e, t + 12), x = R(e, t + 14), I = r[0] + (8191 & g), S = r[1] + ((g >>> 13 | y << 3) & 8191), _ = r[2] + ((y >>> 10 | m << 6) & 8191), P = r[3] + ((m >>> 7 | b << 9) & 8191), T = r[4] + ((b >>> 4 | w << 12) & 8191), A = r[5] + (w >>> 1 & 8191), O = r[6] + ((w >>> 14 | v << 2) & 8191), N = r[7] + ((v >>> 11 | E << 5) & 8191), U = r[8] + ((E >>> 8 | x << 8) & 8191), C = r[9] + (x >>> 5 | 2048 * !i), k = 0, L = 0 + I * n + 5 * f * S + 5 * p * _ + 5 * d * P + 5 * u * T;
            k = L >>> 13, L &= 8191, L += 5 * h * A + 5 * c * O + 5 * l * N + 5 * a * U + 5 * o * C, k += L >>> 13, L &= 8191;
            let D = k + I * o + S * n + 5 * f * _ + 5 * p * P + 5 * d * T;
            k = D >>> 13, D &= 8191, D += 5 * u * A + 5 * h * O + 5 * c * N + 5 * l * U + 5 * a * C, k += D >>> 13, D &= 8191;
            let B = k + I * a + S * o + _ * n + 5 * f * P + 5 * p * T;
            k = B >>> 13, B &= 8191, B += 5 * d * A + 5 * u * O + 5 * h * N + 5 * c * U + 5 * l * C, k += B >>> 13, B &= 8191;
            let M = k + I * l + S * a + _ * o + P * n + 5 * f * T;
            k = M >>> 13, M &= 8191, M += 5 * p * A + 5 * d * O + 5 * u * N + 5 * h * U + 5 * c * C, k += M >>> 13, M &= 8191;
            let j = k + I * c + S * l + _ * a + P * o + T * n;
            k = j >>> 13, j &= 8191, j += 5 * f * A + 5 * p * O + 5 * d * N + 5 * u * U + 5 * h * C, k += j >>> 13, j &= 8191;
            let $ = k + I * h + S * c + _ * l + P * a + T * o;
            k = $ >>> 13, $ &= 8191, $ += A * n + 5 * f * O + 5 * p * N + 5 * d * U + 5 * u * C, k += $ >>> 13, $ &= 8191;
            let q = k + I * u + S * h + _ * c + P * l + T * a;
            k = q >>> 13, q &= 8191, q += A * o + O * n + 5 * f * N + 5 * p * U + 5 * d * C, k += q >>> 13, q &= 8191;
            let z = k + I * d + S * u + _ * h + P * c + T * l;
            k = z >>> 13, z &= 8191, z += A * a + O * o + N * n + 5 * f * U + 5 * p * C, k += z >>> 13, z &= 8191;
            let V = k + I * p + S * d + _ * u + P * h + T * c;
            k = V >>> 13, V &= 8191, V += A * l + O * a + N * o + U * n + 5 * f * C, k += V >>> 13, V &= 8191;
            let K = k + I * f + S * p + _ * d + P * u + T * h;
            k = K >>> 13, K &= 8191, K += A * c + O * l + N * a + U * o + C * n, k += K >>> 13, K &= 8191, L = 8191 & (k = (k = (k << 2) + k | 0) + L | 0), k >>>= 13, D += k, r[0] = L, r[1] = D, r[2] = B, r[3] = M, r[4] = j, r[5] = $, r[6] = q, r[7] = z, r[8] = V, r[9] = K
        }
        finalize() {
            let {
                h: e,
                pad: t
            } = this, i = new Uint16Array(10), r = e[1] >>> 13;
            e[1] &= 8191;
            for (let t = 2; t < 10; t++) e[t] += r, r = e[t] >>> 13, e[t] &= 8191;
            e[0] += 5 * r, r = e[0] >>> 13, e[0] &= 8191, e[1] += r, r = e[1] >>> 13, e[1] &= 8191, e[2] += r, i[0] = e[0] + 5, r = i[0] >>> 13, i[0] &= 8191;
            for (let t = 1; t < 10; t++) i[t] = e[t] + r, r = i[t] >>> 13, i[t] &= 8191;
            i[9] -= 8192;
            let s = (1 ^ r) - 1;
            for (let e = 0; e < 10; e++) i[e] &= s;
            s = ~s;
            for (let t = 0; t < 10; t++) e[t] = e[t] & s | i[t];
            e[0] = (e[0] | e[1] << 13) & 65535, e[1] = (e[1] >>> 3 | e[2] << 10) & 65535, e[2] = (e[2] >>> 6 | e[3] << 7) & 65535, e[3] = (e[3] >>> 9 | e[4] << 4) & 65535, e[4] = (e[4] >>> 12 | e[5] << 1 | e[6] << 14) & 65535, e[5] = (e[6] >>> 2 | e[7] << 11) & 65535, e[6] = (e[7] >>> 5 | e[8] << 8) & 65535, e[7] = (e[8] >>> 8 | e[9] << 5) & 65535;
            let n = e[0] + t[0];
            e[0] = 65535 & n;
            for (let i = 1; i < 8; i++) n = (e[i] + t[i] | 0) + (n >>> 16) | 0, e[i] = 65535 & n;
            f(i)
        }
        update(e) {
            d(this), u(e = y(e));
            let {
                buffer: t,
                blockLen: i
            } = this, r = e.length;
            for (let s = 0; s < r;) {
                let n = Math.min(i - this.pos, r - s);
                if (n === i) {
                    for (; i <= r - s; s += i) this.process(e, s);
                    continue
                }
                t.set(e.subarray(s, s + n), this.pos), this.pos += n, s += n, this.pos === i && (this.process(t, 0, !1), this.pos = 0)
            }
            return this
        }
        destroy() {
            f(this.h, this.r, this.buffer, this.pad)
        }
        digestInto(e) {
            d(this);
            u(e);
            let t = this.outputLen;
            if (e.length < t) throw Error("digestInto() expects output buffer of length at least " + t);
            this.finished = !0;
            let {
                buffer: i,
                h: r
            } = this, {
                pos: s
            } = this;
            if (s) {
                for (i[s++] = 1; s < 16; s++) i[s] = 0;
                this.process(i, 0, !0)
            }
            this.finalize();
            let n = 0;
            for (let t = 0; t < 8; t++) e[n++] = r[t] >>> 0, e[n++] = r[t] >>> 8;
            return e
        }
        digest() {
            let {
                buffer: e,
                outputLen: t
            } = this;
            this.digestInto(e);
            let i = e.slice(0, t);
            return this.destroy(), i
        }
    }
    let U = (s = e => new N(e), (t = (e, t) => s(t).update(y(e)).digest()).outputLen = (i = s(new Uint8Array(32))).outputLen, t.blockLen = i.blockLen, t.create = e => s(e), t);

    function C(e, t, i, r, s, n = 20) {
        let o = e[0],
            a = e[1],
            l = e[2],
            c = e[3],
            h = t[0],
            u = t[1],
            d = t[2],
            p = t[3],
            f = t[4],
            g = t[5],
            y = t[6],
            m = t[7],
            b = i[0],
            w = i[1],
            v = i[2],
            E = o,
            x = a,
            I = l,
            S = c,
            P = h,
            T = u,
            A = d,
            O = p,
            R = f,
            N = g,
            U = y,
            k = m,
            L = s,
            D = b,
            B = w,
            M = v;
        for (let e = 0; e < n; e += 2) R = R + (L = _(L ^ (E = E + P | 0), 16)) | 0, E = E + (P = _(P ^ R, 12)) | 0, R = R + (L = _(L ^ E, 8)) | 0, P = _(P ^ R, 7), N = N + (D = _(D ^ (x = x + T | 0), 16)) | 0, x = x + (T = _(T ^ N, 12)) | 0, N = N + (D = _(D ^ x, 8)) | 0, T = _(T ^ N, 7), U = U + (B = _(B ^ (I = I + A | 0), 16)) | 0, I = I + (A = _(A ^ U, 12)) | 0, U = U + (B = _(B ^ I, 8)) | 0, A = _(A ^ U, 7), k = k + (M = _(M ^ (S = S + O | 0), 16)) | 0, S = S + (O = _(O ^ k, 12)) | 0, k = k + (M = _(M ^ S, 8)) | 0, O = _(O ^ k, 7), U = U + (M = _(M ^ (E = E + T | 0), 16)) | 0, E = E + (T = _(T ^ U, 12)) | 0, U = U + (M = _(M ^ E, 8)) | 0, T = _(T ^ U, 7), k = k + (L = _(L ^ (x = x + A | 0), 16)) | 0, x = x + (A = _(A ^ k, 12)) | 0, k = k + (L = _(L ^ x, 8)) | 0, A = _(A ^ k, 7), R = R + (D = _(D ^ (I = I + O | 0), 16)) | 0, I = I + (O = _(O ^ R, 12)) | 0, R = R + (D = _(D ^ I, 8)) | 0, O = _(O ^ R, 7), N = N + (B = _(B ^ (S = S + P | 0), 16)) | 0, S = S + (P = _(P ^ N, 12)) | 0, N = N + (B = _(B ^ S, 8)) | 0, P = _(P ^ N, 7);
        let j = 0;
        r[j++] = o + E | 0, r[j++] = a + x | 0, r[j++] = l + I | 0, r[j++] = c + S | 0, r[j++] = h + P | 0, r[j++] = u + T | 0, r[j++] = d + A | 0, r[j++] = p + O | 0, r[j++] = f + R | 0, r[j++] = g + N | 0, r[j++] = y + U | 0, r[j++] = m + k | 0, r[j++] = s + L | 0, r[j++] = b + D | 0, r[j++] = w + B | 0, r[j++] = v + M | 0
    }
    let k = O(C, {
            counterRight: !1,
            counterLength: 4,
            allowShortKeys: !1
        }),
        L = O(C, {
            counterRight: !1,
            counterLength: 8,
            extendNonceFn: function(e, t, i, r) {
                let s = e[0],
                    n = e[1],
                    o = e[2],
                    a = e[3],
                    l = t[0],
                    c = t[1],
                    h = t[2],
                    u = t[3],
                    d = t[4],
                    p = t[5],
                    f = t[6],
                    g = t[7],
                    y = i[0],
                    m = i[1],
                    b = i[2],
                    w = i[3];
                for (let e = 0; e < 20; e += 2) d = d + (y = _(y ^ (s = s + l | 0), 16)) | 0, s = s + (l = _(l ^ d, 12)) | 0, d = d + (y = _(y ^ s, 8)) | 0, l = _(l ^ d, 7), p = p + (m = _(m ^ (n = n + c | 0), 16)) | 0, n = n + (c = _(c ^ p, 12)) | 0, p = p + (m = _(m ^ n, 8)) | 0, c = _(c ^ p, 7), f = f + (b = _(b ^ (o = o + h | 0), 16)) | 0, o = o + (h = _(h ^ f, 12)) | 0, f = f + (b = _(b ^ o, 8)) | 0, h = _(h ^ f, 7), g = g + (w = _(w ^ (a = a + u | 0), 16)) | 0, a = a + (u = _(u ^ g, 12)) | 0, g = g + (w = _(w ^ a, 8)) | 0, u = _(u ^ g, 7), f = f + (w = _(w ^ (s = s + c | 0), 16)) | 0, s = s + (c = _(c ^ f, 12)) | 0, f = f + (w = _(w ^ s, 8)) | 0, c = _(c ^ f, 7), g = g + (y = _(y ^ (n = n + h | 0), 16)) | 0, n = n + (h = _(h ^ g, 12)) | 0, g = g + (y = _(y ^ n, 8)) | 0, h = _(h ^ g, 7), d = d + (m = _(m ^ (o = o + u | 0), 16)) | 0, o = o + (u = _(u ^ d, 12)) | 0, d = d + (m = _(m ^ o, 8)) | 0, u = _(u ^ d, 7), p = p + (b = _(b ^ (a = a + l | 0), 16)) | 0, a = a + (l = _(l ^ p, 12)) | 0, p = p + (b = _(b ^ a, 8)) | 0, l = _(l ^ p, 7);
                let v = 0;
                r[v++] = s, r[v++] = n, r[v++] = o, r[v++] = a, r[v++] = y, r[v++] = m, r[v++] = b, r[v++] = w
            },
            allowShortKeys: !1
        }),
        D = new Uint8Array(16),
        B = (e, t) => {
            e.update(t);
            let i = t.length % 16;
            i && e.update(D.subarray(i))
        },
        M = new Uint8Array(32);

    function j(e, t, i, r, s) {
        var n, o;
        let a, l, h = e(t, i, M),
            u = U.create(h);
        s && B(u, s), B(u, r);
        let d = (n = r.length, o = s ? s.length : 0, c(!0), b(l = new DataView((a = new Uint8Array(16)).buffer, a.byteOffset, a.byteLength), 0, BigInt(o), !0), b(l, 8, BigInt(n), !0), a);
        u.update(d);
        let p = u.digest();
        return f(h, d), p
    }
    let $ = e => (t, i, r) => ({
            encrypt(s, n) {
                let o = s.length;
                (n = m(o + 16, n, !1)).set(s);
                let a = n.subarray(0, -16);
                e(t, i, a, a, 1);
                let l = j(e, t, i, a, r);
                return n.set(l, o), f(l), n
            },
            decrypt(s, n) {
                n = m(s.length - 16, n, !1);
                let o = s.subarray(0, -16),
                    a = s.subarray(-16),
                    l = j(e, t, i, o, r);
                if (! function(e, t) {
                        if (e.length !== t.length) return !1;
                        let i = 0;
                        for (let r = 0; r < e.length; r++) i |= e[r] ^ t[r];
                        return 0 === i
                    }(a, l)) throw Error("invalid tag");
                return n.set(s.subarray(0, -16)), e(t, i, n, n, 1), f(l), n
            }
        }),
        q = ((e, t) => {
            function i(r, ...s) {
                if (u(r), !g) throw Error("Non little-endian hardware is not yet supported");
                if (void 0 !== e.nonceLength) {
                    let t = s[0];
                    if (!t) throw Error("nonce / iv required");
                    e.varSizeNonce ? u(t) : u(t, e.nonceLength)
                }
                let n = e.tagLength;
                n && void 0 !== s[1] && u(s[1]);
                let o = t(r, ...s),
                    a = (e, t) => {
                        if (void 0 !== t) {
                            if (2 !== e) throw Error("cipher output not supported");
                            u(t)
                        }
                    },
                    l = !1;
                return {
                    encrypt(e, t) {
                        if (l) throw Error("cannot encrypt() twice with same key + nonce");
                        return l = !0, u(e), a(o.encrypt.length, t), o.encrypt(e, t)
                    },
                    decrypt(e, t) {
                        if (u(e), n && e.length < n) throw Error("invalid ciphertext length: smaller than tagLength=" + n);
                        return a(o.decrypt.length, t), o.decrypt(e, t)
                    }
                }
            }
            return Object.assign(i, e), i
        })({
            blockSize: 64,
            nonceLength: 12,
            tagLength: 16
        }, $(k));
    $(L), e.s(["chacha20poly1305", 0, q], 736820);
    var z = e.i(388326),
        V = e.i(354955);
    let K = Uint8Array.from([0]),
        F = Uint8Array.of();
    e.s(["hkdf", 0, (e, t, i, r, s) => {
        var n;
        return function(e, t, i, r = 32) {
            (0, V.ahash)(e), (0, V.anumber)(r);
            let s = e.outputLen;
            if (r > 255 * s) throw Error("Length should be <= 255*HashLen");
            let n = Math.ceil(r / s);
            void 0 === i && (i = F);
            let o = new Uint8Array(n * s),
                a = z.hmac.create(e, t),
                l = a._cloneInto(),
                c = new Uint8Array(a.outputLen);
            for (let e = 0; e < n; e++) K[0] = e + 1, l.update(0 === e ? F : c).update(i).update(K).digestInto(c), o.set(c, s * e), a._cloneInto(l);
            return a.destroy(), l.destroy(), (0, V.clean)(c, K), o.slice(0, r)
        }(e, (n = i, (0, V.ahash)(e), void 0 === n && (n = new Uint8Array(e.outputLen)), (0, z.hmac)(e, (0, V.toBytes)(n), (0, V.toBytes)(t))), r, s)
    }], 724197);
    var H = e.i(727830),
        W = e.i(675401),
        G = e.i(553037),
        Y = e.i(65140),
        J = e.i(166125);
    let Q = {
            p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
            n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
            h: BigInt(1),
            a: BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
            b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
            Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
            Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
        },
        Z = {
            p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),
            n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
            h: BigInt(1),
            a: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),
            b: BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),
            Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
            Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")
        },
        X = {
            p: BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
            n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
            h: BigInt(1),
            a: BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),
            b: BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),
            Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
            Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")
        },
        ee = (0, Y.Field)(Q.p),
        et = (0, Y.Field)(Z.p),
        ei = (0, Y.Field)(X.p),
        er = (0, W.createCurve)({ ...Q,
            Fp: ee,
            lowS: !1
        }, H.sha256);
    (0, G.createHasher)(er.Point, (n = er.Point, o = {
        A: Q.a,
        B: Q.b,
        Z: er.Point.Fp.create(BigInt("-10"))
    }, r = (0, J.mapToCurveSimpleSWU)(n.Fp, o), e => r(e[0])), {
        DST: "P256_XMD:SHA-256_SSWU_RO_",
        encodeDST: "P256_XMD:SHA-256_SSWU_NU_",
        p: Q.p,
        m: 1,
        k: 128,
        expand: "xmd",
        hash: H.sha256
    }), (0, W.createCurve)({ ...Z,
        Fp: et,
        lowS: !1
    }, H.sha384), (0, W.createCurve)({ ...X,
        Fp: ei,
        lowS: !1,
        allowedPrivateKeyLengths: [130, 131, 132]
    }, H.sha512), e.s(["p256", 0, er], 269956)
}, 786863, e => {
    "use strict";
    e.s(["safeJsonParse", 0, function(e) {
        if ("string" != typeof e) throw Error(`Cannot safe json parse value of type ${typeof e}`);
        try {
            return JSON.parse(e.replace(/([\[:])?(\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, '$1"$2n"$3'), (e, t) => "string" == typeof t && t.match(/^\d+n$/) ? BigInt(t.substring(0, t.length - 1)) : t)
        } catch (t) {
            return e
        }
    }, "safeJsonStringify", 0, function(e) {
        return "string" == typeof e ? e : JSON.stringify(e, (e, t) => "bigint" == typeof t ? t.toString() + "n" : t) || ""
    }])
}, 355055, e => {
    "use strict";
    let t, i;
    var r, s = e.i(367069),
        n = e.i(786863);

    function o(e, ...t) {
        if (!(e instanceof Uint8Array || ArrayBuffer.isView(e) && "Uint8Array" === e.constructor.name)) throw Error("Uint8Array expected");
        if (t.length > 0 && !t.includes(e.length)) throw Error("Uint8Array expected of length " + t + ", got length=" + e.length)
    }

    function a(e, t = !0) {
        if (e.destroyed) throw Error("Hash instance has been destroyed");
        if (t && e.finished) throw Error("Hash#digest() has already been called")
    }
    let l = "object" == typeof globalThis && "crypto" in globalThis ? globalThis.crypto : void 0,
        c = e => new DataView(e.buffer, e.byteOffset, e.byteLength);

    function h(e) {
        return "string" == typeof e && (e = function(e) {
            if ("string" != typeof e) throw Error("utf8ToBytes expected string, got " + typeof e);
            return new Uint8Array(new TextEncoder().encode(e))
        }(e)), o(e), e
    }
    class u {
        clone() {
            return this._cloneInto()
        }
    }

    function d(e = 32) {
        if (l && "function" == typeof l.getRandomValues) return l.getRandomValues(new Uint8Array(e));
        if (l && "function" == typeof l.randomBytes) return l.randomBytes(e);
        throw Error("crypto.getRandomValues must be defined")
    }
    class p extends u {
        constructor(e, t, i, r) {
            super(), this.blockLen = e, this.outputLen = t, this.padOffset = i, this.isLE = r, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = c(this.buffer)
        }
        update(e) {
            a(this);
            let {
                view: t,
                buffer: i,
                blockLen: r
            } = this, s = (e = h(e)).length;
            for (let n = 0; n < s;) {
                let o = Math.min(r - this.pos, s - n);
                if (o === r) {
                    let t = c(e);
                    for (; r <= s - n; n += r) this.process(t, n);
                    continue
                }
                i.set(e.subarray(n, n + o), this.pos), this.pos += o, n += o, this.pos === r && (this.process(t, 0), this.pos = 0)
            }
            return this.length += e.length, this.roundClean(), this
        }
        digestInto(e) {
            a(this),
                function(e, t) {
                    o(e);
                    let i = t.outputLen;
                    if (e.length < i) throw Error("digestInto() expects output buffer of length at least " + i)
                }(e, this), this.finished = !0;
            let {
                buffer: t,
                view: i,
                blockLen: r,
                isLE: s
            } = this, {
                pos: n
            } = this;
            t[n++] = 128, this.buffer.subarray(n).fill(0), this.padOffset > r - n && (this.process(i, 0), n = 0);
            for (let e = n; e < r; e++) t[e] = 0;
            (function(e, t, i, r) {
                if ("function" == typeof e.setBigUint64) return e.setBigUint64(t, i, r);
                let s = BigInt(32),
                    n = BigInt(0xffffffff),
                    o = Number(i >> s & n),
                    a = Number(i & n),
                    l = 4 * !!r,
                    c = 4 * !r;
                e.setUint32(t + l, o, r), e.setUint32(t + c, a, r)
            })(i, r - 8, BigInt(8 * this.length), s), this.process(i, 0);
            let l = c(e),
                h = this.outputLen;
            if (h % 4) throw Error("_sha2: outputLen should be aligned to 32bit");
            let u = h / 4,
                d = this.get();
            if (u > d.length) throw Error("_sha2: outputLen bigger than state");
            for (let e = 0; e < u; e++) l.setUint32(4 * e, d[e], s)
        }
        digest() {
            let {
                buffer: e,
                outputLen: t
            } = this;
            this.digestInto(e);
            let i = e.slice(0, t);
            return this.destroy(), i
        }
        _cloneInto(e) {
            e || (e = new this.constructor), e.set(...this.get());
            let {
                blockLen: t,
                buffer: i,
                length: r,
                finished: s,
                destroyed: n,
                pos: o
            } = this;
            return e.length = r, e.pos = o, e.finished = s, e.destroyed = n, r % t && e.buffer.set(i), e
        }
    }
    let f = BigInt(0x100000000 - 1),
        g = BigInt(32),
        y = (e, t, i) => e >>> i,
        m = (e, t, i) => e << 32 - i | t >>> i,
        b = (e, t, i) => e >>> i | t << 32 - i,
        w = (e, t, i) => e << 32 - i | t >>> i,
        v = (e, t, i) => e << 64 - i | t >>> i - 32,
        E = (e, t, i) => e >>> i - 32 | t << 64 - i,
        x = function(e, t, i, r) {
            let s = (t >>> 0) + (r >>> 0);
            return {
                h: e + i + (s / 0x100000000 | 0) | 0,
                l: 0 | s
            }
        },
        I = (e, t, i) => (e >>> 0) + (t >>> 0) + (i >>> 0),
        S = (e, t, i, r) => t + i + r + (e / 0x100000000 | 0) | 0,
        _ = (e, t, i, r) => (e >>> 0) + (t >>> 0) + (i >>> 0) + (r >>> 0),
        P = (e, t, i, r, s) => t + i + r + s + (e / 0x100000000 | 0) | 0,
        T = (e, t, i, r, s, n) => t + i + r + s + n + (e / 0x100000000 | 0) | 0,
        A = (e, t, i, r, s) => (e >>> 0) + (t >>> 0) + (i >>> 0) + (r >>> 0) + (s >>> 0),
        [O, R] = function(e, t = !1) {
            let i = new Uint32Array(e.length),
                r = new Uint32Array(e.length);
            for (let s = 0; s < e.length; s++) {
                let {
                    h: n,
                    l: o
                } = function(e, t = !1) {
                    return t ? {
                        h: Number(e & f),
                        l: Number(e >> g & f)
                    } : {
                        h: 0 | Number(e >> g & f),
                        l: 0 | Number(e & f)
                    }
                }(e[s], t);
                [i[s], r[s]] = [n, o]
            }
            return [i, r]
        }(["0x428a2f98d728ae22", "0x7137449123ef65cd", "0xb5c0fbcfec4d3b2f", "0xe9b5dba58189dbbc", "0x3956c25bf348b538", "0x59f111f1b605d019", "0x923f82a4af194f9b", "0xab1c5ed5da6d8118", "0xd807aa98a3030242", "0x12835b0145706fbe", "0x243185be4ee4b28c", "0x550c7dc3d5ffb4e2", "0x72be5d74f27b896f", "0x80deb1fe3b1696b1", "0x9bdc06a725c71235", "0xc19bf174cf692694", "0xe49b69c19ef14ad2", "0xefbe4786384f25e3", "0x0fc19dc68b8cd5b5", "0x240ca1cc77ac9c65", "0x2de92c6f592b0275", "0x4a7484aa6ea6e483", "0x5cb0a9dcbd41fbd4", "0x76f988da831153b5", "0x983e5152ee66dfab", "0xa831c66d2db43210", "0xb00327c898fb213f", "0xbf597fc7beef0ee4", "0xc6e00bf33da88fc2", "0xd5a79147930aa725", "0x06ca6351e003826f", "0x142929670a0e6e70", "0x27b70a8546d22ffc", "0x2e1b21385c26c926", "0x4d2c6dfc5ac42aed", "0x53380d139d95b3df", "0x650a73548baf63de", "0x766a0abb3c77b2a8", "0x81c2c92e47edaee6", "0x92722c851482353b", "0xa2bfe8a14cf10364", "0xa81a664bbc423001", "0xc24b8b70d0f89791", "0xc76c51a30654be30", "0xd192e819d6ef5218", "0xd69906245565a910", "0xf40e35855771202a", "0x106aa07032bbd1b8", "0x19a4c116b8d2d0c8", "0x1e376c085141ab53", "0x2748774cdf8eeb99", "0x34b0bcb5e19b48a8", "0x391c0cb3c5c95a63", "0x4ed8aa4ae3418acb", "0x5b9cca4f7763e373", "0x682e6ff3d6b2b8a3", "0x748f82ee5defb2fc", "0x78a5636f43172f60", "0x84c87814a1f0ab72", "0x8cc702081a6439ec", "0x90befffa23631e28", "0xa4506cebde82bde9", "0xbef9a3f7b2c67915", "0xc67178f2e372532b", "0xca273eceea26619c", "0xd186b8c721c0c207", "0xeada7dd6cde0eb1e", "0xf57d4f7fee6ed178", "0x06f067aa72176fba", "0x0a637dc5a2c898a6", "0x113f9804bef90dae", "0x1b710b35131c471b", "0x28db77f523047d84", "0x32caab7b40c72493", "0x3c9ebe0a15c9bebc", "0x431d67c49c100d4c", "0x4cc5d4becb3e42b6", "0x597f299cfc657e2a", "0x5fcb6fab3ad6faec", "0x6c44198c4a475817"].map(e => BigInt(e))),
        N = new Uint32Array(80),
        U = new Uint32Array(80);
    class C extends p {
        constructor() {
            super(128, 64, 16, !1), this.Ah = 0x6a09e667, this.Al = -0xc4336f8, this.Bh = -0x4498517b, this.Bl = -0x7b3558c5, this.Ch = 0x3c6ef372, this.Cl = -0x16b07d5, this.Dh = -0x5ab00ac6, this.Dl = 0x5f1d36f1, this.Eh = 0x510e527f, this.El = -0x52197d2f, this.Fh = -0x64fa9774, this.Fl = 0x2b3e6c1f, this.Gh = 0x1f83d9ab, this.Gl = -0x4be4295, this.Hh = 0x5be0cd19, this.Hl = 0x137e2179
        }
        get() {
            let {
                Ah: e,
                Al: t,
                Bh: i,
                Bl: r,
                Ch: s,
                Cl: n,
                Dh: o,
                Dl: a,
                Eh: l,
                El: c,
                Fh: h,
                Fl: u,
                Gh: d,
                Gl: p,
                Hh: f,
                Hl: g
            } = this;
            return [e, t, i, r, s, n, o, a, l, c, h, u, d, p, f, g]
        }
        set(e, t, i, r, s, n, o, a, l, c, h, u, d, p, f, g) {
            this.Ah = 0 | e, this.Al = 0 | t, this.Bh = 0 | i, this.Bl = 0 | r, this.Ch = 0 | s, this.Cl = 0 | n, this.Dh = 0 | o, this.Dl = 0 | a, this.Eh = 0 | l, this.El = 0 | c, this.Fh = 0 | h, this.Fl = 0 | u, this.Gh = 0 | d, this.Gl = 0 | p, this.Hh = 0 | f, this.Hl = 0 | g
        }
        process(e, t) {
            for (let i = 0; i < 16; i++, t += 4) N[i] = e.getUint32(t), U[i] = e.getUint32(t += 4);
            for (let e = 16; e < 80; e++) {
                let t = 0 | N[e - 15],
                    i = 0 | U[e - 15],
                    r = b(t, i, 1) ^ b(t, i, 8) ^ y(t, i, 7),
                    s = w(t, i, 1) ^ w(t, i, 8) ^ m(t, i, 7),
                    n = 0 | N[e - 2],
                    o = 0 | U[e - 2],
                    a = b(n, o, 19) ^ v(n, o, 61) ^ y(n, o, 6),
                    l = _(s, w(n, o, 19) ^ E(n, o, 61) ^ m(n, o, 6), U[e - 7], U[e - 16]),
                    c = P(l, r, a, N[e - 7], N[e - 16]);
                N[e] = 0 | c, U[e] = 0 | l
            }
            let {
                Ah: i,
                Al: r,
                Bh: s,
                Bl: n,
                Ch: o,
                Cl: a,
                Dh: l,
                Dl: c,
                Eh: h,
                El: u,
                Fh: d,
                Fl: p,
                Gh: f,
                Gl: g,
                Hh: C,
                Hl: k
            } = this;
            for (let e = 0; e < 80; e++) {
                let t = b(h, u, 14) ^ b(h, u, 18) ^ v(h, u, 41),
                    y = w(h, u, 14) ^ w(h, u, 18) ^ E(h, u, 41),
                    m = h & d ^ ~h & f,
                    _ = A(k, y, u & p ^ ~u & g, R[e], U[e]),
                    P = T(_, C, t, m, O[e], N[e]),
                    L = 0 | _,
                    D = b(i, r, 28) ^ v(i, r, 34) ^ v(i, r, 39),
                    B = w(i, r, 28) ^ E(i, r, 34) ^ E(i, r, 39),
                    M = i & s ^ i & o ^ s & o,
                    j = r & n ^ r & a ^ n & a;
                C = 0 | f, k = 0 | g, f = 0 | d, g = 0 | p, d = 0 | h, p = 0 | u, ({
                    h: h,
                    l: u
                } = x(0 | l, 0 | c, 0 | P, 0 | L)), l = 0 | o, c = 0 | a, o = 0 | s, a = 0 | n, s = 0 | i, n = 0 | r;
                let $ = I(L, B, j);
                i = S($, P, D, M), r = 0 | $
            }({
                h: i,
                l: r
            } = x(0 | this.Ah, 0 | this.Al, 0 | i, 0 | r)), ({
                h: s,
                l: n
            } = x(0 | this.Bh, 0 | this.Bl, 0 | s, 0 | n)), ({
                h: o,
                l: a
            } = x(0 | this.Ch, 0 | this.Cl, 0 | o, 0 | a)), ({
                h: l,
                l: c
            } = x(0 | this.Dh, 0 | this.Dl, 0 | l, 0 | c)), ({
                h: h,
                l: u
            } = x(0 | this.Eh, 0 | this.El, 0 | h, 0 | u)), ({
                h: d,
                l: p
            } = x(0 | this.Fh, 0 | this.Fl, 0 | d, 0 | p)), ({
                h: f,
                l: g
            } = x(0 | this.Gh, 0 | this.Gl, 0 | f, 0 | g)), ({
                h: C,
                l: k
            } = x(0 | this.Hh, 0 | this.Hl, 0 | C, 0 | k)), this.set(i, r, s, n, o, a, l, c, h, u, d, p, f, g, C, k)
        }
        roundClean() {
            N.fill(0), U.fill(0)
        }
        destroy() {
            this.buffer.fill(0), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        }
    }
    let k = (r = () => new C, (t = e => r().update(h(e)).digest()).outputLen = (i = r()).outputLen, t.blockLen = i.blockLen, t.create = () => r(), t),
        L = BigInt(0),
        D = BigInt(1),
        B = BigInt(2);

    function M(e) {
        return e instanceof Uint8Array || ArrayBuffer.isView(e) && "Uint8Array" === e.constructor.name
    }

    function j(e) {
        if (!M(e)) throw Error("Uint8Array expected")
    }

    function $(e, t) {
        if ("boolean" != typeof t) throw Error(e + " boolean expected, got " + t)
    }
    let q = Array.from({
        length: 256
    }, (e, t) => t.toString(16).padStart(2, "0"));

    function z(e) {
        j(e);
        let t = "";
        for (let i = 0; i < e.length; i++) t += q[e[i]];
        return t
    }

    function V(e) {
        if ("string" != typeof e) throw Error("hex string expected, got " + typeof e);
        return "" === e ? L : BigInt("0x" + e)
    }

    function K(e) {
        return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : void 0
    }

    function F(e) {
        if ("string" != typeof e) throw Error("hex string expected, got " + typeof e);
        let t = e.length,
            i = t / 2;
        if (t % 2) throw Error("hex string expected, got unpadded hex of length " + t);
        let r = new Uint8Array(i);
        for (let t = 0, s = 0; t < i; t++, s += 2) {
            let i = K(e.charCodeAt(s)),
                n = K(e.charCodeAt(s + 1));
            if (void 0 === i || void 0 === n) throw Error('hex string expected, got non-hex character "' + (e[s] + e[s + 1]) + '" at index ' + s);
            r[t] = 16 * i + n
        }
        return r
    }

    function H(e) {
        return j(e), V(z(Uint8Array.from(e).reverse()))
    }

    function W(e, t) {
        return F(e.toString(16).padStart(2 * t, "0"))
    }

    function G(e, t) {
        return W(e, t).reverse()
    }

    function Y(e, t, i) {
        let r;
        if ("string" == typeof t) try {
                r = F(t)
            } catch (t) {
                throw Error(e + " must be hex string or Uint8Array, cause: " + t)
            } else if (M(t)) r = Uint8Array.from(t);
            else throw Error(e + " must be hex string or Uint8Array");
        let s = r.length;
        if ("number" == typeof i && s !== i) throw Error(e + " of length " + i + " expected, got " + s);
        return r
    }

    function J(...e) {
        let t = 0;
        for (let i = 0; i < e.length; i++) {
            let r = e[i];
            j(r), t += r.length
        }
        let i = new Uint8Array(t);
        for (let t = 0, r = 0; t < e.length; t++) {
            let s = e[t];
            i.set(s, r), r += s.length
        }
        return i
    }
    let Q = e => "bigint" == typeof e && L <= e;

    function Z(e, t, i, r) {
        if (!(Q(t) && Q(i) && Q(r)) || !(i <= t) || !(t < r)) throw Error("expected valid " + e + ": " + i + " <= n < " + r + ", got " + t)
    }
    let X = {
        bigint: e => "bigint" == typeof e,
        function: e => "function" == typeof e,
        boolean: e => "boolean" == typeof e,
        string: e => "string" == typeof e,
        stringOrUint8Array: e => "string" == typeof e || M(e),
        isSafeInteger: e => Number.isSafeInteger(e),
        array: e => Array.isArray(e),
        field: (e, t) => t.Fp.isValid(e),
        hash: e => "function" == typeof e && Number.isSafeInteger(e.outputLen)
    };

    function ee(e, t, i = {}) {
        let r = (t, i, r) => {
            let s = X[i];
            if ("function" != typeof s) throw Error("invalid validator function");
            let n = e[t];
            if (!(r && void 0 === n) && !s(n, e)) throw Error("param " + String(t) + " is invalid. Expected " + i + ", got " + n)
        };
        for (let [e, i] of Object.entries(t)) r(e, i, !1);
        for (let [e, t] of Object.entries(i)) r(e, t, !0);
        return e
    }

    function et(e) {
        let t = new WeakMap;
        return (i, ...r) => {
            let s = t.get(i);
            if (void 0 !== s) return s;
            let n = e(i, ...r);
            return t.set(i, n), n
        }
    }
    let ei = BigInt(0),
        er = BigInt(1),
        es = BigInt(2),
        en = BigInt(3),
        eo = BigInt(4),
        ea = BigInt(5),
        el = BigInt(8);

    function ec(e, t) {
        let i = e % t;
        return i >= ei ? i : t + i
    }

    function eh(e, t, i) {
        let r = e;
        for (; t-- > ei;) r *= r, r %= i;
        return r
    }

    function eu(e, t) {
        if (e === ei) throw Error("invert: expected non-zero number");
        if (t <= ei) throw Error("invert: expected positive modulus, got " + t);
        let i = ec(e, t),
            r = t,
            s = ei,
            n = er;
        for (; i !== ei;) {
            let e = r / i,
                t = r % i,
                o = s - n * e;
            r = i, i = t, s = n, n = o
        }
        if (r !== er) throw Error("invert: does not exist");
        return ec(s, t)
    }
    let ed = ["create", "isValid", "is0", "neg", "inv", "sqrt", "sqr", "eql", "add", "sub", "mul", "pow", "div", "addN", "subN", "mulN", "sqrN"];

    function ep(e, t) {
        let i = void 0 !== t ? t : e.toString(2).length,
            r = Math.ceil(i / 8);
        return {
            nBitLength: i,
            nByteLength: r
        }
    }

    function ef(e, t, i = !1, r = {}) {
        let s;
        if (e <= ei) throw Error("invalid field: expected ORDER > 0, got " + e);
        let {
            nBitLength: n,
            nByteLength: o
        } = ep(e, t);
        if (o > 2048) throw Error("invalid field: expected ORDER of <= 2048 bytes");
        let a = Object.freeze({
            ORDER: e,
            isLE: i,
            BITS: n,
            BYTES: o,
            MASK: (B << BigInt(n - 1)) - D,
            ZERO: ei,
            ONE: er,
            create: t => ec(t, e),
            isValid: t => {
                if ("bigint" != typeof t) throw Error("invalid field element: expected bigint, got " + typeof t);
                return ei <= t && t < e
            },
            is0: e => e === ei,
            isOdd: e => (e & er) === er,
            neg: t => ec(-t, e),
            eql: (e, t) => e === t,
            sqr: t => ec(t * t, e),
            add: (t, i) => ec(t + i, e),
            sub: (t, i) => ec(t - i, e),
            mul: (t, i) => ec(t * i, e),
            pow: (e, t) => (function(e, t, i) {
                if (i < ei) throw Error("invalid exponent, negatives unsupported");
                if (i === ei) return e.ONE;
                if (i === er) return t;
                let r = e.ONE,
                    s = t;
                for (; i > ei;) i & er && (r = e.mul(r, s)), s = e.sqr(s), i >>= er;
                return r
            })(a, e, t),
            div: (t, i) => ec(t * eu(i, e), e),
            sqrN: e => e * e,
            addN: (e, t) => e + t,
            subN: (e, t) => e - t,
            mulN: (e, t) => e * t,
            inv: t => eu(t, e),
            sqrt: r.sqrt || (t => (s || (s = function(e) {
                if (e % eo === en) {
                    let t = (e + er) / eo;
                    return function(e, i) {
                        let r = e.pow(i, t);
                        if (!e.eql(e.sqr(r), i)) throw Error("Cannot find square root");
                        return r
                    }
                }
                if (e % el === ea) {
                    let t = (e - ea) / el;
                    return function(e, i) {
                        let r = e.mul(i, es),
                            s = e.pow(r, t),
                            n = e.mul(i, s),
                            o = e.mul(e.mul(n, es), s),
                            a = e.mul(n, e.sub(o, e.ONE));
                        if (!e.eql(e.sqr(a), i)) throw Error("Cannot find square root");
                        return a
                    }
                }
                return function(e) {
                    let t, i, r, s = (e - er) / es;
                    for (t = e - er, i = 0; t % es === ei; t /= es, i++);
                    for (r = es; r < e && function(e, t, i) {
                            if (t < ei) throw Error("invalid exponent, negatives unsupported");
                            if (i <= ei) throw Error("invalid modulus");
                            if (i === er) return ei;
                            let r = er;
                            for (; t > ei;) t & er && (r = r * e % i), e = e * e % i, t >>= er;
                            return r
                        }(r, s, e) !== e - er; r++)
                        if (r > 1e3) throw Error("Cannot find square root: likely non-prime P");
                    if (1 === i) {
                        let t = (e + er) / eo;
                        return function(e, i) {
                            let r = e.pow(i, t);
                            if (!e.eql(e.sqr(r), i)) throw Error("Cannot find square root");
                            return r
                        }
                    }
                    let n = (t + er) / es;
                    return function(e, o) {
                        if (e.pow(o, s) === e.neg(e.ONE)) throw Error("Cannot find square root");
                        let a = i,
                            l = e.pow(e.mul(e.ONE, r), t),
                            c = e.pow(o, n),
                            h = e.pow(o, t);
                        for (; !e.eql(h, e.ONE);) {
                            if (e.eql(h, e.ZERO)) return e.ZERO;
                            let t = 1;
                            for (let i = e.sqr(h); t < a && !e.eql(i, e.ONE); t++) i = e.sqr(i);
                            let i = e.pow(l, er << BigInt(a - t - 1));
                            l = e.sqr(i), c = e.mul(c, i), h = e.mul(h, l), a = t
                        }
                        return c
                    }
                }(e)
            }(e)), s(a, t))),
            invertBatch: e => {
                let t, i, r;
                return t = Array(e.length), i = e.reduce((e, i, r) => a.is0(i) ? e : (t[r] = e, a.mul(e, i)), a.ONE), r = a.inv(i), e.reduceRight((e, i, r) => a.is0(i) ? e : (t[r] = a.mul(e, t[r]), a.mul(e, i)), r), t
            },
            cmov: (e, t, i) => i ? t : e,
            toBytes: e => i ? G(e, o) : W(e, o),
            fromBytes: e => {
                if (e.length !== o) throw Error("Field.fromBytes: expected " + o + " bytes, got " + e.length);
                return i ? H(e) : V(z(e))
            }
        });
        return Object.freeze(a)
    }
    let eg = BigInt(0),
        ey = BigInt(1);

    function em(e, t) {
        let i = t.negate();
        return e ? i : t
    }

    function eb(e, t) {
        if (!Number.isSafeInteger(e) || e <= 0 || e > t) throw Error("invalid window size, expected [1.." + t + "], got W=" + e)
    }

    function ew(e, t) {
        return eb(e, t), {
            windows: Math.ceil(t / e) + 1,
            windowSize: 2 ** (e - 1)
        }
    }
    let ev = new WeakMap,
        eE = new WeakMap;

    function ex(e) {
        return eE.get(e) || 1
    }
    let eI = BigInt(0),
        eS = BigInt(1),
        e_ = BigInt(2),
        eP = BigInt(8),
        eT = {
            zip215: !0
        };
    BigInt(0), BigInt(1);
    let eA = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),
        eO = BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
    BigInt(0);
    let eR = BigInt(1),
        eN = BigInt(2);
    BigInt(3);
    let eU = BigInt(5),
        eC = BigInt(8),
        ek = ef(eA, void 0, !0),
        eL = function(e) {
            var t;
            let i, r = (ee(e.Fp, ed.reduce((e, t) => (e[t] = "function", e), {
                    ORDER: "bigint",
                    MASK: "bigint",
                    BYTES: "isSafeInteger",
                    BITS: "isSafeInteger"
                })), ee(e, {
                    n: "bigint",
                    h: "bigint",
                    Gx: "field",
                    Gy: "field"
                }, {
                    nBitLength: "isSafeInteger",
                    nByteLength: "isSafeInteger"
                }), i = Object.freeze({ ...ep(e.n, e.nBitLength),
                    ...e,
                    p: e.Fp.ORDER
                }), ee(e, {
                    hash: "function",
                    a: "bigint",
                    d: "bigint",
                    randomBytes: "function"
                }, {
                    adjustScalarBytes: "function",
                    domain: "function",
                    uvRatio: "function",
                    mapToCurve: "function"
                }), Object.freeze({ ...i
                })),
                {
                    Fp: s,
                    n: n,
                    prehash: o,
                    hash: a,
                    randomBytes: l,
                    nByteLength: c,
                    h: h
                } = r,
                u = e_ << BigInt(8 * c) - eS,
                d = s.create,
                p = ef(r.n, r.nBitLength),
                f = r.uvRatio || ((e, t) => {
                    try {
                        return {
                            isValid: !0,
                            value: s.sqrt(e * s.inv(t))
                        }
                    } catch {
                        return {
                            isValid: !1,
                            value: eI
                        }
                    }
                }),
                g = r.adjustScalarBytes || (e => e),
                y = r.domain || ((e, t, i) => {
                    if ($("phflag", i), t.length || i) throw Error("Contexts/pre-hash are not supported");
                    return e
                });

            function m(e, t) {
                Z("coordinate " + e, t, eI, u)
            }

            function b(e) {
                if (!(e instanceof E)) throw Error("ExtendedPoint expected")
            }
            let w = et((e, t) => {
                    let {
                        ex: i,
                        ey: r,
                        ez: n
                    } = e, o = e.is0();
                    null == t && (t = o ? eP : s.inv(n));
                    let a = d(i * t),
                        l = d(r * t),
                        c = d(n * t);
                    if (o) return {
                        x: eI,
                        y: eS
                    };
                    if (c !== eS) throw Error("invZ was invalid");
                    return {
                        x: a,
                        y: l
                    }
                }),
                v = et(e => {
                    let {
                        a: t,
                        d: i
                    } = r;
                    if (e.is0()) throw Error("bad point: ZERO");
                    let {
                        ex: s,
                        ey: n,
                        ez: o,
                        et: a
                    } = e, l = d(s * s), c = d(n * n), h = d(o * o), u = d(h * h), p = d(l * t);
                    if (d(h * d(p + c)) !== d(u + d(i * d(l * c)))) throw Error("bad point: equation left != right (1)");
                    if (d(s * n) !== d(o * a)) throw Error("bad point: equation left != right (2)");
                    return !0
                });
            class E {
                constructor(e, t, i, r) {
                    this.ex = e, this.ey = t, this.ez = i, this.et = r, m("x", e), m("y", t), m("z", i), m("t", r), Object.freeze(this)
                }
                get x() {
                    return this.toAffine().x
                }
                get y() {
                    return this.toAffine().y
                }
                static fromAffine(e) {
                    if (e instanceof E) throw Error("extended point not allowed");
                    let {
                        x: t,
                        y: i
                    } = e || {};
                    return m("x", t), m("y", i), new E(t, i, eS, d(t * i))
                }
                static normalizeZ(e) {
                    let t = s.invertBatch(e.map(e => e.ez));
                    return e.map((e, i) => e.toAffine(t[i])).map(E.fromAffine)
                }
                static msm(e, t) {
                    return function(e, t, i, r) {
                        if (function(e, t) {
                                if (!Array.isArray(e)) throw Error("array expected");
                                e.forEach((e, i) => {
                                    if (!(e instanceof t)) throw Error("invalid point at index " + i)
                                })
                            }(i, e), function(e, t) {
                                if (!Array.isArray(e)) throw Error("array of scalars expected");
                                e.forEach((e, i) => {
                                    if (!t.isValid(e)) throw Error("invalid scalar at index " + i)
                                })
                            }(r, t), i.length !== r.length) throw Error("arrays of points and scalars must have equal length");
                        let s = e.ZERO,
                            n = function(e) {
                                let t;
                                for (t = 0; e > L; e >>= D, t += 1);
                                return t
                            }(BigInt(i.length)),
                            o = n > 12 ? n - 3 : n > 4 ? n - 2 : n ? 2 : 1,
                            a = (1 << o) - 1,
                            l = Array(a + 1).fill(s),
                            c = Math.floor((t.BITS - 1) / o) * o,
                            h = s;
                        for (let e = c; e >= 0; e -= o) {
                            l.fill(s);
                            for (let t = 0; t < r.length; t++) {
                                let s = Number(r[t] >> BigInt(e) & BigInt(a));
                                l[s] = l[s].add(i[t])
                            }
                            let t = s;
                            for (let e = l.length - 1, i = s; e > 0; e--) i = i.add(l[e]), t = t.add(i);
                            if (h = h.add(t), 0 !== e)
                                for (let e = 0; e < o; e++) h = h.double()
                        }
                        return h
                    }(E, p, e, t)
                }
                _setWindowSize(e) {
                    S.setWindowSize(this, e)
                }
                assertValidity() {
                    v(this)
                }
                equals(e) {
                    b(e);
                    let {
                        ex: t,
                        ey: i,
                        ez: r
                    } = this, {
                        ex: s,
                        ey: n,
                        ez: o
                    } = e, a = d(t * o), l = d(s * r), c = d(i * o), h = d(n * r);
                    return a === l && c === h
                }
                is0() {
                    return this.equals(E.ZERO)
                }
                negate() {
                    return new E(d(-this.ex), this.ey, this.ez, d(-this.et))
                }
                double() {
                    let {
                        a: e
                    } = r, {
                        ex: t,
                        ey: i,
                        ez: s
                    } = this, n = d(t * t), o = d(i * i), a = d(e_ * d(s * s)), l = d(e * n), c = t + i, h = d(d(c * c) - n - o), u = l + o, p = u - a, f = l - o, g = d(h * p), y = d(u * f), m = d(h * f);
                    return new E(g, y, d(p * u), m)
                }
                add(e) {
                    b(e);
                    let {
                        a: t,
                        d: i
                    } = r, {
                        ex: s,
                        ey: n,
                        ez: o,
                        et: a
                    } = this, {
                        ex: l,
                        ey: c,
                        ez: h,
                        et: u
                    } = e;
                    if (t === BigInt(-1)) {
                        let e = d((n - s) * (c + l)),
                            t = d((n + s) * (c - l)),
                            i = d(t - e);
                        if (i === eI) return this.double();
                        let r = d(o * e_ * u),
                            p = d(a * e_ * h),
                            f = p + r,
                            g = t + e,
                            y = p - r,
                            m = d(f * i),
                            b = d(g * y),
                            w = d(f * y);
                        return new E(m, b, d(i * g), w)
                    }
                    let p = d(s * l),
                        f = d(n * c),
                        g = d(a * i * u),
                        y = d(o * h),
                        m = d((s + n) * (l + c) - p - f),
                        w = y - g,
                        v = y + g,
                        x = d(f - t * p),
                        I = d(m * w),
                        S = d(v * x),
                        _ = d(m * x);
                    return new E(I, S, d(w * v), _)
                }
                subtract(e) {
                    return this.add(e.negate())
                }
                wNAF(e) {
                    return S.wNAFCached(this, e, E.normalizeZ)
                }
                multiply(e) {
                    Z("scalar", e, eS, n);
                    let {
                        p: t,
                        f: i
                    } = this.wNAF(e);
                    return E.normalizeZ([t, i])[0]
                }
                multiplyUnsafe(e, t = E.ZERO) {
                    return Z("scalar", e, eI, n), e === eI ? I : this.is0() || e === eS ? this : S.wNAFCachedUnsafe(this, e, E.normalizeZ, t)
                }
                isSmallOrder() {
                    return this.multiplyUnsafe(h).is0()
                }
                isTorsionFree() {
                    return S.unsafeLadder(this, n).is0()
                }
                toAffine(e) {
                    return w(this, e)
                }
                clearCofactor() {
                    let {
                        h: e
                    } = r;
                    return e === eS ? this : this.multiplyUnsafe(e)
                }
                static fromHex(e, t = !1) {
                    let {
                        d: i,
                        a: n
                    } = r, o = s.BYTES;
                    e = Y("pointHex", e, o), $("zip215", t);
                    let a = e.slice(),
                        l = e[o - 1];
                    a[o - 1] = -129 & l;
                    let c = H(a);
                    Z("pointHex.y", c, eI, t ? u : s.ORDER);
                    let h = d(c * c),
                        {
                            isValid: p,
                            value: g
                        } = f(d(h - eS), d(i * h - n));
                    if (!p) throw Error("Point.fromHex: invalid y coordinate");
                    let y = (g & eS) === eS,
                        m = (128 & l) != 0;
                    if (!t && g === eI && m) throw Error("Point.fromHex: x=0 and x_0=1");
                    return m !== y && (g = d(-g)), E.fromAffine({
                        x: g,
                        y: c
                    })
                }
                static fromPrivateKey(e) {
                    return _(e).point
                }
                toRawBytes() {
                    let {
                        x: e,
                        y: t
                    } = this.toAffine(), i = G(t, s.BYTES);
                    return i[i.length - 1] |= e & eS ? 128 : 0, i
                }
                toHex() {
                    return z(this.toRawBytes())
                }
            }
            E.BASE = new E(r.Gx, r.Gy, eS, d(r.Gx * r.Gy)), E.ZERO = new E(eI, eS, eS, eI);
            let {
                BASE: x,
                ZERO: I
            } = E, S = (t = 8 * c, {
                constTimeNegate: em,
                hasPrecomputes: e => 1 !== ex(e),
                unsafeLadder(e, t, i = E.ZERO) {
                    let r = e;
                    for (; t > eg;) t & ey && (i = i.add(r)), r = r.double(), t >>= ey;
                    return i
                },
                precomputeWindow(e, i) {
                    let {
                        windows: r,
                        windowSize: s
                    } = ew(i, t), n = [], o = e, a = o;
                    for (let e = 0; e < r; e++) {
                        a = o, n.push(a);
                        for (let e = 1; e < s; e++) a = a.add(o), n.push(a);
                        o = a.double()
                    }
                    return n
                },
                wNAF(e, i, r) {
                    let {
                        windows: s,
                        windowSize: n
                    } = ew(e, t), o = E.ZERO, a = E.BASE, l = BigInt(2 ** e - 1), c = 2 ** e, h = BigInt(e);
                    for (let e = 0; e < s; e++) {
                        let t = e * n,
                            s = Number(r & l);
                        r >>= h, s > n && (s -= c, r += ey);
                        let u = t + Math.abs(s) - 1,
                            d = e % 2 != 0,
                            p = s < 0;
                        0 === s ? a = a.add(em(d, i[t])) : o = o.add(em(p, i[u]))
                    }
                    return {
                        p: o,
                        f: a
                    }
                },
                wNAFUnsafe(e, i, r, s = E.ZERO) {
                    let {
                        windows: n,
                        windowSize: o
                    } = ew(e, t), a = BigInt(2 ** e - 1), l = 2 ** e, c = BigInt(e);
                    for (let e = 0; e < n; e++) {
                        let t = e * o;
                        if (r === eg) break;
                        let n = Number(r & a);
                        if (r >>= c, n > o && (n -= l, r += ey), 0 === n) continue;
                        let h = i[t + Math.abs(n) - 1];
                        n < 0 && (h = h.negate()), s = s.add(h)
                    }
                    return s
                },
                getPrecomputes(e, t, i) {
                    let r = ev.get(t);
                    return r || (r = this.precomputeWindow(t, e), 1 !== e && ev.set(t, i(r))), r
                },
                wNAFCached(e, t, i) {
                    let r = ex(e);
                    return this.wNAF(r, this.getPrecomputes(r, e, i), t)
                },
                wNAFCachedUnsafe(e, t, i, r) {
                    let s = ex(e);
                    return 1 === s ? this.unsafeLadder(e, t, r) : this.wNAFUnsafe(s, this.getPrecomputes(s, e, i), t, r)
                },
                setWindowSize(e, i) {
                    eb(i, t), eE.set(e, i), ev.delete(e)
                }
            });

            function _(e) {
                let t = s.BYTES;
                e = Y("private key", e, t);
                let i = Y("hashed private key", a(e), 2 * t),
                    r = g(i.slice(0, t)),
                    o = i.slice(t, 2 * t),
                    l = ec(H(r), n),
                    c = x.multiply(l),
                    h = c.toRawBytes();
                return {
                    head: r,
                    prefix: o,
                    scalar: l,
                    point: c,
                    pointBytes: h
                }
            }

            function P(e = new Uint8Array, ...t) {
                return ec(H(a(y(J(...t), Y("context", e), !!o))), n)
            }
            return x._setWindowSize(8), {
                CURVE: r,
                getPublicKey: function(e) {
                    return _(e).pointBytes
                },
                sign: function(e, t, i = {}) {
                    e = Y("message", e), o && (e = o(e));
                    let {
                        prefix: r,
                        scalar: a,
                        pointBytes: l
                    } = _(t), c = P(i.context, r, e), h = x.multiply(c).toRawBytes(), u = ec(c + P(i.context, h, l, e) * a, n);
                    return Z("signature.s", u, eI, n), Y("result", J(h, G(u, s.BYTES)), 2 * s.BYTES)
                },
                verify: function(e, t, i, r = eT) {
                    let n, a, l, {
                            context: c,
                            zip215: h
                        } = r,
                        u = s.BYTES;
                    e = Y("signature", e, 2 * u), t = Y("message", t), i = Y("publicKey", i, u), void 0 !== h && $("zip215", h), o && (t = o(t));
                    let d = H(e.slice(u, 2 * u));
                    try {
                        n = E.fromHex(i, h), a = E.fromHex(e.slice(0, u), h), l = x.multiplyUnsafe(d)
                    } catch {
                        return !1
                    }
                    if (!h && n.isSmallOrder()) return !1;
                    let p = P(c, a.toRawBytes(), n.toRawBytes(), t);
                    return a.add(n.multiplyUnsafe(p)).subtract(l).clearCofactor().equals(E.ZERO)
                },
                ExtendedPoint: E,
                utils: {
                    getExtendedPublicKey: _,
                    randomPrivateKey: () => l(s.BYTES),
                    precompute: (e = 8, t = E.BASE) => (t._setWindowSize(e), t.multiply(BigInt(3)), t)
                }
            }
        }({
            a: BigInt(-1),
            d: BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),
            Fp: ek,
            n: BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),
            h: eC,
            Gx: BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),
            Gy: BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),
            hash: k,
            randomBytes: d,
            adjustScalarBytes: function(e) {
                return e[0] &= 248, e[31] &= 127, e[31] |= 64, e
            },
            uvRatio: function(e, t) {
                var i;
                let r, s, n, o, a, l, c, h, u, d, p, f, g, y, m = ec(t * t * t, eA),
                    b = (i = e * ec(m * m * t, eA), r = BigInt(10), s = BigInt(20), n = BigInt(40), o = BigInt(80), l = eh(a = i * i % eA * i % eA, eN, eA) * a % eA, c = eh(l, eR, eA) * i % eA, h = eh(c, eU, eA) * c % eA, u = eh(h, r, eA) * h % eA, d = eh(u, s, eA) * u % eA, p = eh(d, n, eA) * d % eA, f = eh(p, o, eA) * p % eA, g = eh(f, o, eA) * p % eA, y = eh(g, r, eA) * h % eA, {
                        pow_p_5_8: eh(y, eN, eA) * i % eA,
                        b2: a
                    }).pow_p_5_8,
                    w = ec(e * m * b, eA),
                    v = ec(t * w * w, eA),
                    E = w,
                    x = ec(w * eO, eA),
                    I = v === e,
                    S = v === ec(-e, eA),
                    _ = v === ec(-e * eO, eA);
                return I && (w = E), (S || _) && (w = x), (ec(w, eA) & er) === er && (w = ec(-w, eA)), {
                    isValid: I || S,
                    value: w
                }
            }
        }),
        eD = "base64url",
        eB = "utf8",
        eM = "utf8",
        ej = "base58btc";

    function e$(e) {
        return null != globalThis.Buffer ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : e
    }

    function eq(e = 0) {
        return null != globalThis.Buffer && null != globalThis.Buffer.allocUnsafe ? e$(globalThis.Buffer.allocUnsafe(e)) : new Uint8Array(e)
    }

    function ez(e, t) {
        t || (t = e.reduce((e, t) => e + t.length, 0));
        let i = eq(t),
            r = 0;
        for (let t of e) i.set(t, r), r += t.length;
        return e$(i)
    }
    var eV = function(e, t) {
        if (e.length >= 255) throw TypeError("Alphabet too long");
        for (var i = new Uint8Array(256), r = 0; r < i.length; r++) i[r] = 255;
        for (var s = 0; s < e.length; s++) {
            var n = e.charAt(s),
                o = n.charCodeAt(0);
            if (255 !== i[o]) throw TypeError(n + " is ambiguous");
            i[o] = s
        }
        var a = e.length,
            l = e.charAt(0),
            c = Math.log(a) / Math.log(256),
            h = Math.log(256) / Math.log(a);

        function u(e) {
            if ("string" != typeof e) throw TypeError("Expected String");
            if (0 === e.length) return new Uint8Array;
            var t = 0;
            if (" " !== e[0]) {
                for (var r = 0, s = 0; e[t] === l;) r++, t++;
                for (var n = (e.length - t) * c + 1 >>> 0, o = new Uint8Array(n); e[t];) {
                    var h = i[e.charCodeAt(t)];
                    if (255 === h) return;
                    for (var u = 0, d = n - 1;
                        (0 !== h || u < s) && -1 !== d; d--, u++) h += a * o[d] >>> 0, o[d] = h % 256 >>> 0, h = h / 256 >>> 0;
                    if (0 !== h) throw Error("Non-zero carry");
                    s = u, t++
                }
                if (" " !== e[t]) {
                    for (var p = n - s; p !== n && 0 === o[p];) p++;
                    for (var f = new Uint8Array(r + (n - p)), g = r; p !== n;) f[g++] = o[p++];
                    return f
                }
            }
        }
        return {
            encode: function(t) {
                if (t instanceof Uint8Array || (ArrayBuffer.isView(t) ? t = new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : Array.isArray(t) && (t = Uint8Array.from(t))), !(t instanceof Uint8Array)) throw TypeError("Expected Uint8Array");
                if (0 === t.length) return "";
                for (var i = 0, r = 0, s = 0, n = t.length; s !== n && 0 === t[s];) s++, i++;
                for (var o = (n - s) * h + 1 >>> 0, c = new Uint8Array(o); s !== n;) {
                    for (var u = t[s], d = 0, p = o - 1;
                        (0 !== u || d < r) && -1 !== p; p--, d++) u += 256 * c[p] >>> 0, c[p] = u % a >>> 0, u = u / a >>> 0;
                    if (0 !== u) throw Error("Non-zero carry");
                    r = d, s++
                }
                for (var f = o - r; f !== o && 0 === c[f];) f++;
                for (var g = l.repeat(i); f < o; ++f) g += e.charAt(c[f]);
                return g
            },
            decodeUnsafe: u,
            decode: function(e) {
                var i = u(e);
                if (i) return i;
                throw Error(`Non-${t} character`)
            }
        }
    };
    let eK = e => {
        if (e instanceof Uint8Array && "Uint8Array" === e.constructor.name) return e;
        if (e instanceof ArrayBuffer) return new Uint8Array(e);
        if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
        throw Error("Unknown type, must be binary type")
    };
    class eF {
        constructor(e, t, i) {
            this.name = e, this.prefix = t, this.baseEncode = i
        }
        encode(e) {
            if (e instanceof Uint8Array) return `${this.prefix}${this.baseEncode(e)}`;
            throw Error("Unknown type, must be binary type")
        }
    }
    class eH {
        constructor(e, t, i) {
            if (this.name = e, this.prefix = t, void 0 === t.codePointAt(0)) throw Error("Invalid prefix character");
            this.prefixCodePoint = t.codePointAt(0), this.baseDecode = i
        }
        decode(e) {
            if ("string" == typeof e) {
                if (e.codePointAt(0) !== this.prefixCodePoint) throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
                return this.baseDecode(e.slice(this.prefix.length))
            }
            throw Error("Can only multibase decode strings")
        }
        or(e) {
            return eG(this, e)
        }
    }
    class eW {
        constructor(e) {
            this.decoders = e
        }
        or(e) {
            return eG(this, e)
        }
        decode(e) {
            let t = e[0],
                i = this.decoders[t];
            if (i) return i.decode(e);
            throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)
        }
    }
    let eG = (e, t) => new eW({ ...e.decoders || {
            [e.prefix]: e
        },
        ...t.decoders || {
            [t.prefix]: t
        }
    });
    class eY {
        constructor(e, t, i, r) {
            this.name = e, this.prefix = t, this.baseEncode = i, this.baseDecode = r, this.encoder = new eF(e, t, i), this.decoder = new eH(e, t, r)
        }
        encode(e) {
            return this.encoder.encode(e)
        }
        decode(e) {
            return this.decoder.decode(e)
        }
    }
    let eJ = ({
            name: e,
            prefix: t,
            encode: i,
            decode: r
        }) => new eY(e, t, i, r),
        eQ = ({
            prefix: e,
            name: t,
            alphabet: i
        }) => {
            let {
                encode: r,
                decode: s
            } = eV(i, t);
            return eJ({
                prefix: e,
                name: t,
                encode: r,
                decode: e => eK(s(e))
            })
        },
        eZ = ({
            name: e,
            prefix: t,
            bitsPerChar: i,
            alphabet: r
        }) => eJ({
            prefix: t,
            name: e,
            encode: e => ((e, t, i) => {
                let r = "=" === t[t.length - 1],
                    s = (1 << i) - 1,
                    n = "",
                    o = 0,
                    a = 0;
                for (let r = 0; r < e.length; ++r)
                    for (a = a << 8 | e[r], o += 8; o > i;) o -= i, n += t[s & a >> o];
                if (o && (n += t[s & a << i - o]), r)
                    for (; n.length * i & 7;) n += "=";
                return n
            })(e, r, i),
            decode: t => ((e, t, i, r) => {
                let s = {};
                for (let e = 0; e < t.length; ++e) s[t[e]] = e;
                let n = e.length;
                for (;
                    "=" === e[n - 1];) --n;
                let o = new Uint8Array(n * i / 8 | 0),
                    a = 0,
                    l = 0,
                    c = 0;
                for (let t = 0; t < n; ++t) {
                    let n = s[e[t]];
                    if (void 0 === n) throw SyntaxError(`Non-${r} character`);
                    l = l << i | n, (a += i) >= 8 && (a -= 8, o[c++] = 255 & l >> a)
                }
                if (a >= i || 255 & l << 8 - a) throw SyntaxError("Unexpected end of data");
                return o
            })(t, r, i, e)
        });
    var eX = Object.freeze({
            __proto__: null,
            identity: eJ({
                prefix: "\0",
                name: "identity",
                encode: e => new TextDecoder().decode(e),
                decode: e => new TextEncoder().encode(e)
            })
        }),
        e0 = Object.freeze({
            __proto__: null,
            base2: eZ({
                prefix: "0",
                name: "base2",
                alphabet: "01",
                bitsPerChar: 1
            })
        }),
        e1 = Object.freeze({
            __proto__: null,
            base8: eZ({
                prefix: "7",
                name: "base8",
                alphabet: "01234567",
                bitsPerChar: 3
            })
        }),
        e2 = Object.freeze({
            __proto__: null,
            base10: eQ({
                prefix: "9",
                name: "base10",
                alphabet: "0123456789"
            })
        }),
        e8 = Object.freeze({
            __proto__: null,
            base16: eZ({
                prefix: "f",
                name: "base16",
                alphabet: "0123456789abcdef",
                bitsPerChar: 4
            }),
            base16upper: eZ({
                prefix: "F",
                name: "base16upper",
                alphabet: "0123456789ABCDEF",
                bitsPerChar: 4
            })
        }),
        e3 = Object.freeze({
            __proto__: null,
            base32: eZ({
                prefix: "b",
                name: "base32",
                alphabet: "abcdefghijklmnopqrstuvwxyz234567",
                bitsPerChar: 5
            }),
            base32upper: eZ({
                prefix: "B",
                name: "base32upper",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
                bitsPerChar: 5
            }),
            base32pad: eZ({
                prefix: "c",
                name: "base32pad",
                alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
                bitsPerChar: 5
            }),
            base32padupper: eZ({
                prefix: "C",
                name: "base32padupper",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
                bitsPerChar: 5
            }),
            base32hex: eZ({
                prefix: "v",
                name: "base32hex",
                alphabet: "0123456789abcdefghijklmnopqrstuv",
                bitsPerChar: 5
            }),
            base32hexupper: eZ({
                prefix: "V",
                name: "base32hexupper",
                alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
                bitsPerChar: 5
            }),
            base32hexpad: eZ({
                prefix: "t",
                name: "base32hexpad",
                alphabet: "0123456789abcdefghijklmnopqrstuv=",
                bitsPerChar: 5
            }),
            base32hexpadupper: eZ({
                prefix: "T",
                name: "base32hexpadupper",
                alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
                bitsPerChar: 5
            }),
            base32z: eZ({
                prefix: "h",
                name: "base32z",
                alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
                bitsPerChar: 5
            })
        }),
        e6 = Object.freeze({
            __proto__: null,
            base36: eQ({
                prefix: "k",
                name: "base36",
                alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
            }),
            base36upper: eQ({
                prefix: "K",
                name: "base36upper",
                alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
            })
        }),
        e5 = Object.freeze({
            __proto__: null,
            base58btc: eQ({
                name: "base58btc",
                prefix: "z",
                alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
            }),
            base58flickr: eQ({
                name: "base58flickr",
                prefix: "Z",
                alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
            })
        }),
        e4 = Object.freeze({
            __proto__: null,
            base64: eZ({
                prefix: "m",
                name: "base64",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
                bitsPerChar: 6
            }),
            base64pad: eZ({
                prefix: "M",
                name: "base64pad",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
                bitsPerChar: 6
            }),
            base64url: eZ({
                prefix: "u",
                name: "base64url",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
                bitsPerChar: 6
            }),
            base64urlpad: eZ({
                prefix: "U",
                name: "base64urlpad",
                alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
                bitsPerChar: 6
            })
        });
    let e9 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),
        e7 = e9.reduce((e, t, i) => (e[i] = t, e), []),
        te = e9.reduce((e, t, i) => (e[t.codePointAt(0)] = i, e), []);
    var tt = Object.freeze({
        __proto__: null,
        base256emoji: eJ({
            prefix: "🚀",
            name: "base256emoji",
            encode: function(e) {
                return e.reduce((e, t) => e += e7[t], "")
            },
            decode: function(e) {
                let t = [];
                for (let i of e) {
                    let e = te[i.codePointAt(0)];
                    if (void 0 === e) throw Error(`Non-base256emoji character: ${i}`);
                    t.push(e)
                }
                return new Uint8Array(t)
            }
        })
    });

    function ti(e, t, i) {
        t = t || [], i = i || 0;
        for (var r = i; e >= 0x80000000;) t[i++] = 255 & e | 128, e /= 128;
        for (; - 128 & e;) t[i++] = 255 & e | 128, e >>>= 7;
        return t[i] = 0 | e, ti.bytes = i - r + 1, t
    }
    var tr = function(e) {
        return e < 128 ? 1 : e < 16384 ? 2 : e < 2097152 ? 3 : e < 0x10000000 ? 4 : e < 0x800000000 ? 5 : e < 0x40000000000 ? 6 : e < 0x2000000000000 ? 7 : e < 0x100000000000000 ? 8 : e < 0x8000000000000000 ? 9 : 10
    };
    let ts = (e, t, i = 0) => (ti(e, t, i), t),
        tn = (e, t) => {
            let i = t.byteLength,
                r = tr(e),
                s = r + tr(i),
                n = new Uint8Array(s + i);
            return ts(e, n, 0), ts(i, n, r), n.set(t, s), new to(e, i, t, n)
        };
    class to {
        constructor(e, t, i, r) {
            this.code = e, this.size = t, this.digest = i, this.bytes = r
        }
    }
    let ta = ({
        name: e,
        code: t,
        encode: i
    }) => new tl(e, t, i);
    class tl {
        constructor(e, t, i) {
            this.name = e, this.code = t, this.encode = i
        }
        digest(e) {
            if (e instanceof Uint8Array) {
                let t = this.encode(e);
                return t instanceof Uint8Array ? tn(this.code, t) : t.then(e => tn(this.code, e))
            }
            throw Error("Unknown type, must be binary type")
        }
    }
    let tc = e => async t => new Uint8Array(await crypto.subtle.digest(e, t));
    var th = Object.freeze({
            __proto__: null,
            sha256: ta({
                name: "sha2-256",
                code: 18,
                encode: tc("SHA-256")
            }),
            sha512: ta({
                name: "sha2-512",
                code: 19,
                encode: tc("SHA-512")
            })
        }),
        tu = Object.freeze({
            __proto__: null,
            identity: {
                code: 0,
                name: "identity",
                encode: eK,
                digest: e => tn(0, eK(e))
            }
        });
    new TextEncoder, new TextDecoder;
    let td = { ...eX,
        ...e0,
        ...e1,
        ...e2,
        ...e8,
        ...e3,
        ...e6,
        ...e5,
        ...e4,
        ...tt
    };

    function tp(e, t, i, r) {
        return {
            name: e,
            prefix: t,
            encoder: {
                name: e,
                prefix: t,
                encode: i
            },
            decoder: {
                decode: r
            }
        }
    }({ ...th,
        ...tu
    });
    let tf = tp("utf8", "u", e => "u" + new TextDecoder("utf8").decode(e), e => new TextEncoder().encode(e.substring(1))),
        tg = tp("ascii", "a", e => {
            let t = "a";
            for (let i = 0; i < e.length; i++) t += String.fromCharCode(e[i]);
            return t
        }, e => {
            let t = eq((e = e.substring(1)).length);
            for (let i = 0; i < e.length; i++) t[i] = e.charCodeAt(i);
            return t
        }),
        ty = {
            utf8: tf,
            "utf-8": tf,
            hex: td.base16,
            latin1: tg,
            ascii: tg,
            binary: tg,
            ...td
        };

    function tm(e, t = "utf8") {
        let i = ty[t];
        if (!i) throw Error(`Unsupported encoding "${t}"`);
        return ("utf8" === t || "utf-8" === t) && null != globalThis.Buffer && null != globalThis.Buffer.from ? globalThis.Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("utf8") : i.encoder.encode(e).substring(1)
    }

    function tb(e, t = "utf8") {
        let i = ty[t];
        if (!i) throw Error(`Unsupported encoding "${t}"`);
        return ("utf8" === t || "utf-8" === t) && null != globalThis.Buffer && null != globalThis.Buffer.from ? e$(globalThis.Buffer.from(e, "utf-8")) : i.decoder.decode(`${i.prefix}${e}`)
    }

    function tw(e) {
        return (0, n.safeJsonParse)(tm(tb(e, eD), eB))
    }

    function tv(e) {
        return tm(tb((0, n.safeJsonStringify)(e), eB), eD)
    }

    function tE(e) {
        return ["did:key", "z" + tm(ez([tb("K36", ej), e]), ej)].join(":")
    }
    async function tx(e, t, i, r, n = (0, s.fromMiliseconds)(Date.now())) {
        let o = {
                alg: "EdDSA",
                typ: "JWT"
            },
            a = {
                iss: tE(r.publicKey),
                sub: e,
                aud: t,
                iat: n,
                exp: n + i
            },
            l = tb([tv((c = {
                header: o,
                payload: a
            }).header), tv(c.payload)].join("."), eM);
        var c, h = {
            header: o,
            payload: a,
            signature: eL.sign(l, r.secretKey.slice(0, 32))
        };
        return [tv(h.header), tv(h.payload), tm(h.signature, eD)].join(".")
    }
    e.s(["decodeJWT", 0, function(e) {
        let t = e.split(".");
        return {
            header: tw(t[0]),
            payload: tw(t[1]),
            signature: tb(t[2], eD),
            data: tb(t.slice(0, 2).join("."), eM)
        }
    }, "encodeIss", 0, tE, "generateKeyPair", 0, function(e = d(32)) {
        let t = eL.getPublicKey(e);
        return {
            secretKey: ez([e, t]),
            publicKey: t
        }
    }, "signJWT", 0, tx])
}, 272820, e => {
    "use strict";
    e.s(["RELAY_JSONRPC", 0, {
        waku: {
            publish: "waku_publish",
            batchPublish: "waku_batchPublish",
            subscribe: "waku_subscribe",
            batchSubscribe: "waku_batchSubscribe",
            subscription: "waku_subscription",
            unsubscribe: "waku_unsubscribe",
            batchUnsubscribe: "waku_batchUnsubscribe",
            batchFetchMessages: "waku_batchFetchMessages"
        },
        irn: {
            publish: "irn_publish",
            batchPublish: "irn_batchPublish",
            subscribe: "irn_subscribe",
            batchSubscribe: "irn_batchSubscribe",
            subscription: "irn_subscription",
            unsubscribe: "irn_unsubscribe",
            batchUnsubscribe: "irn_batchUnsubscribe",
            batchFetchMessages: "irn_batchFetchMessages"
        },
        iridium: {
            publish: "iridium_publish",
            batchPublish: "iridium_batchPublish",
            subscribe: "iridium_subscribe",
            batchSubscribe: "iridium_batchSubscribe",
            subscription: "iridium_subscription",
            unsubscribe: "iridium_unsubscribe",
            batchUnsubscribe: "iridium_batchUnsubscribe",
            batchFetchMessages: "iridium_batchFetchMessages"
        }
    }])
}, 958816, (e, t, i) => {
    function r(e) {
        return (0x100000000 + e).toString(16).substring(1)
    }
    t.exports = {
        normalizeInput: function(e) {
            let t;
            if (e instanceof Uint8Array) t = e;
            else if ("string" == typeof e) t = new TextEncoder().encode(e);
            else throw Error("Input must be an string, Buffer or Uint8Array");
            return t
        },
        toHex: function(e) {
            return Array.prototype.map.call(e, function(e) {
                return (e < 16 ? "0" : "") + e.toString(16)
            }).join("")
        },
        debugPrint: function(e, t, i) {
            let s = "\n" + e + " = ";
            for (let n = 0; n < t.length; n += 2) {
                if (32 === i) s += r(t[n]).toUpperCase(), s += " ", s += r(t[n + 1]).toUpperCase();
                else if (64 === i) s += r(t[n + 1]).toUpperCase(), s += r(t[n]).toUpperCase();
                else throw Error("Invalid size " + i);
                n % 6 == 4 ? s += "\n" + Array(e.length + 4).join(" ") : n < t.length - 2 && (s += " ")
            }
            console.log(s)
        },
        testSpeed: function(e, t, i) {
            let r = new Date().getTime(),
                s = new Uint8Array(t);
            for (let e = 0; e < t; e++) s[e] = e % 256;
            let n = new Date().getTime();
            console.log("Generated random input in " + (n - r) + "ms"), r = n;
            for (let n = 0; n < i; n++) {
                let i = e(s),
                    n = new Date().getTime(),
                    o = n - r;
                r = n, console.log("Hashed in " + o + "ms: " + i.substring(0, 20) + "..."), console.log(Math.round(t / 1048576 / (o / 1e3) * 100) / 100 + " MB PER SECOND")
            }
        }
    }
}, 513024, (e, t, i) => {
    let r = e.r(958816);

    function s(e, t, i) {
        let r = e[t] + e[i],
            s = e[t + 1] + e[i + 1];
        r >= 0x100000000 && s++, e[t] = r, e[t + 1] = s
    }

    function n(e, t, i, r) {
        let s = e[t] + i;
        i < 0 && (s += 0x100000000);
        let n = e[t + 1] + r;
        s >= 0x100000000 && n++, e[t] = s, e[t + 1] = n
    }

    function o(e, t) {
        return e[t] ^ e[t + 1] << 8 ^ e[t + 2] << 16 ^ e[t + 3] << 24
    }

    function a(e, t, i, r, o, a) {
        let l = u[o],
            c = u[o + 1],
            d = u[a],
            p = u[a + 1];
        s(h, e, t), n(h, e, l, c);
        let f = h[r] ^ h[e],
            g = h[r + 1] ^ h[e + 1];
        h[r] = g, h[r + 1] = f, s(h, i, r), f = h[t] ^ h[i], g = h[t + 1] ^ h[i + 1], h[t] = f >>> 24 ^ g << 8, h[t + 1] = g >>> 24 ^ f << 8, s(h, e, t), n(h, e, d, p), f = h[r] ^ h[e], g = h[r + 1] ^ h[e + 1], h[r] = f >>> 16 ^ g << 16, h[r + 1] = g >>> 16 ^ f << 16, s(h, i, r), f = h[t] ^ h[i], g = h[t + 1] ^ h[i + 1], h[t] = g >>> 31 ^ f << 1, h[t + 1] = f >>> 31 ^ g << 1
    }
    let l = new Uint32Array([0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, 0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19]),
        c = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3].map(function(e) {
            return 2 * e
        })),
        h = new Uint32Array(32),
        u = new Uint32Array(32);

    function d(e, t) {
        let i = 0;
        for (i = 0; i < 16; i++) h[i] = e.h[i], h[i + 16] = l[i];
        for (h[24] = h[24] ^ e.t, h[25] = h[25] ^ e.t / 0x100000000, t && (h[28] = ~h[28], h[29] = ~h[29]), i = 0; i < 32; i++) u[i] = o(e.b, 4 * i);
        for (i = 0; i < 12; i++) a(0, 8, 16, 24, c[16 * i + 0], c[16 * i + 1]), a(2, 10, 18, 26, c[16 * i + 2], c[16 * i + 3]), a(4, 12, 20, 28, c[16 * i + 4], c[16 * i + 5]), a(6, 14, 22, 30, c[16 * i + 6], c[16 * i + 7]), a(0, 10, 20, 30, c[16 * i + 8], c[16 * i + 9]), a(2, 12, 22, 24, c[16 * i + 10], c[16 * i + 11]), a(4, 14, 16, 26, c[16 * i + 12], c[16 * i + 13]), a(6, 8, 18, 28, c[16 * i + 14], c[16 * i + 15]);
        for (i = 0; i < 16; i++) e.h[i] = e.h[i] ^ h[i] ^ h[i + 16]
    }
    let p = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);

    function f(e, t, i, r) {
        if (0 === e || e > 64) throw Error("Illegal output length, expected 0 < length <= 64");
        if (t && t.length > 64) throw Error("Illegal key, expected Uint8Array with 0 < length <= 64");
        if (i && 16 !== i.length) throw Error("Illegal salt, expected Uint8Array with length is 16");
        if (r && 16 !== r.length) throw Error("Illegal personal, expected Uint8Array with length is 16");
        let s = {
            b: new Uint8Array(128),
            h: new Uint32Array(16),
            t: 0,
            c: 0,
            outlen: e
        };
        p.fill(0), p[0] = e, t && (p[1] = t.length), p[2] = 1, p[3] = 1, i && p.set(i, 32), r && p.set(r, 48);
        for (let e = 0; e < 16; e++) s.h[e] = l[e] ^ o(p, 4 * e);
        return t && (g(s, t), s.c = 128), s
    }

    function g(e, t) {
        for (let i = 0; i < t.length; i++) 128 === e.c && (e.t += e.c, d(e, !1), e.c = 0), e.b[e.c++] = t[i]
    }

    function y(e) {
        for (e.t += e.c; e.c < 128;) e.b[e.c++] = 0;
        d(e, !0);
        let t = new Uint8Array(e.outlen);
        for (let i = 0; i < e.outlen; i++) t[i] = e.h[i >> 2] >> 8 * (3 & i);
        return t
    }

    function m(e, t, i, s, n) {
        i = i || 64, e = r.normalizeInput(e), s && (s = r.normalizeInput(s)), n && (n = r.normalizeInput(n));
        let o = f(i, t, s, n);
        return g(o, e), y(o)
    }
    t.exports = {
        blake2b: m,
        blake2bHex: function(e, t, i, s, n) {
            let o = m(e, t, i, s, n);
            return r.toHex(o)
        },
        blake2bInit: f,
        blake2bUpdate: g,
        blake2bFinal: y
    }
}, 24350, (e, t, i) => {
    let r = e.r(958816);

    function s(e, t, i, r, s, o) {
        l[e] = l[e] + l[t] + s, l[r] = n(l[r] ^ l[e], 16), l[i] = l[i] + l[r], l[t] = n(l[t] ^ l[i], 12), l[e] = l[e] + l[t] + o, l[r] = n(l[r] ^ l[e], 8), l[i] = l[i] + l[r], l[t] = n(l[t] ^ l[i], 7)
    }

    function n(e, t) {
        return e >>> t ^ e << 32 - t
    }
    let o = new Uint32Array([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]),
        a = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]),
        l = new Uint32Array(16),
        c = new Uint32Array(16);

    function h(e, t) {
        let i = 0;
        for (i = 0; i < 8; i++) l[i] = e.h[i], l[i + 8] = o[i];
        for (l[12] ^= e.t, l[13] ^= e.t / 0x100000000, t && (l[14] = ~l[14]), i = 0; i < 16; i++) {
            var r, n;
            c[i] = (r = e.b)[n = 4 * i] ^ r[n + 1] << 8 ^ r[n + 2] << 16 ^ r[n + 3] << 24
        }
        for (i = 0; i < 10; i++) s(0, 4, 8, 12, c[a[16 * i + 0]], c[a[16 * i + 1]]), s(1, 5, 9, 13, c[a[16 * i + 2]], c[a[16 * i + 3]]), s(2, 6, 10, 14, c[a[16 * i + 4]], c[a[16 * i + 5]]), s(3, 7, 11, 15, c[a[16 * i + 6]], c[a[16 * i + 7]]), s(0, 5, 10, 15, c[a[16 * i + 8]], c[a[16 * i + 9]]), s(1, 6, 11, 12, c[a[16 * i + 10]], c[a[16 * i + 11]]), s(2, 7, 8, 13, c[a[16 * i + 12]], c[a[16 * i + 13]]), s(3, 4, 9, 14, c[a[16 * i + 14]], c[a[16 * i + 15]]);
        for (i = 0; i < 8; i++) e.h[i] ^= l[i] ^ l[i + 8]
    }

    function u(e, t) {
        if (!(e > 0 && e <= 32)) throw Error("Incorrect output length, should be in [1, 32]");
        let i = t ? t.length : 0;
        if (t && !(i > 0 && i <= 32)) throw Error("Incorrect key length, should be in [1, 32]");
        let r = {
            h: new Uint32Array(o),
            b: new Uint8Array(64),
            c: 0,
            t: 0,
            outlen: e
        };
        return r.h[0] ^= 0x1010000 ^ i << 8 ^ e, i > 0 && (d(r, t), r.c = 64), r
    }

    function d(e, t) {
        for (let i = 0; i < t.length; i++) 64 === e.c && (e.t += e.c, h(e, !1), e.c = 0), e.b[e.c++] = t[i]
    }

    function p(e) {
        for (e.t += e.c; e.c < 64;) e.b[e.c++] = 0;
        h(e, !0);
        let t = new Uint8Array(e.outlen);
        for (let i = 0; i < e.outlen; i++) t[i] = e.h[i >> 2] >> 8 * (3 & i) & 255;
        return t
    }

    function f(e, t, i) {
        i = i || 32, e = r.normalizeInput(e);
        let s = u(i, t);
        return d(s, e), p(s)
    }
    t.exports = {
        blake2s: f,
        blake2sHex: function(e, t, i) {
            let s = f(e, t, i);
            return r.toHex(s)
        },
        blake2sInit: u,
        blake2sUpdate: d,
        blake2sFinal: p
    }
}, 812837, (e, t, i) => {
    let r = e.r(513024),
        s = e.r(24350);
    t.exports = {
        blake2b: r.blake2b,
        blake2bHex: r.blake2bHex,
        blake2bInit: r.blake2bInit,
        blake2bUpdate: r.blake2bUpdate,
        blake2bFinal: r.blake2bFinal,
        blake2s: s.blake2s,
        blake2sHex: s.blake2sHex,
        blake2sInit: s.blake2sInit,
        blake2sUpdate: s.blake2sUpdate,
        blake2sFinal: s.blake2sFinal
    }
}, 128130, e => {
    "use strict";
    var t = {
        exports: {}
    };

    function i(e) {
        try {
            return JSON.stringify(e)
        } catch {
            return '"[Circular]"'
        }
    }
    let r = function(e, t, r) {
        var s = r && r.stringify || i;
        if ("object" == typeof e && null !== e) {
            var n = t.length + 1;
            if (1 === n) return e;
            var o = Array(n);
            o[0] = s(e);
            for (var a = 1; a < n; a++) o[a] = s(t[a]);
            return o.join(" ")
        }
        if ("string" != typeof e) return e;
        var l = t.length;
        if (0 === l) return e;
        for (var c = "", h = 0, u = -1, d = e && e.length || 0, p = 0; p < d;) {
            if (37 === e.charCodeAt(p) && p + 1 < d) {
                switch (u = u > -1 ? u : 0, e.charCodeAt(p + 1)) {
                    case 100:
                    case 102:
                        if (h >= l || null == t[h]) break;
                        u < p && (c += e.slice(u, p)), c += Number(t[h]), u = p + 2, p++;
                        break;
                    case 105:
                        if (h >= l || null == t[h]) break;
                        u < p && (c += e.slice(u, p)), c += Math.floor(Number(t[h])), u = p + 2, p++;
                        break;
                    case 79:
                    case 111:
                    case 106:
                        if (h >= l || void 0 === t[h]) break;
                        u < p && (c += e.slice(u, p));
                        var f = typeof t[h];
                        if ("string" === f) {
                            c += "'" + t[h] + "'", u = p + 2, p++;
                            break
                        }
                        if ("function" === f) {
                            c += t[h].name || "<anonymous>", u = p + 2, p++;
                            break
                        }
                        c += s(t[h]), u = p + 2, p++;
                        break;
                    case 115:
                        if (h >= l) break;
                        u < p && (c += e.slice(u, p)), c += String(t[h]), u = p + 2, p++;
                        break;
                    case 37:
                        u < p && (c += e.slice(u, p)), c += "%", u = p + 2, p++, h--
                }++h
            }++p
        }
        return -1 === u ? e : (u < d && (c += e.slice(u)), c)
    };
    t.exports = h;
    let s = function() {
        function e(e) {
            return "u" > typeof e && e
        }
        try {
            return "u" > typeof globalThis || Object.defineProperty(Object.prototype, "globalThis", {
                get: function() {
                    return delete Object.prototype.globalThis, this.globalThis = this
                },
                configurable: !0
            }), globalThis
        } catch {
            return e(self) || e(window) || e(this) || {}
        }
    }().console || {};

    function n(e, t) {
        return "silent" === e ? 1 / 0 : t.levels.values[e]
    }
    let o = Symbol("pino.logFuncs"),
        a = Symbol("pino.hierarchy"),
        l = {
            error: "log",
            fatal: "error",
            warn: "error",
            info: "log",
            debug: "log",
            trace: "log"
        };

    function c(e, t) {
        let i = {
            logger: t,
            parent: e[a]
        };
        t[a] = i
    }

    function h(e) {
        var t, i, r;
        let a, f, g;
        (e = e || {}).browser = e.browser || {};
        let y = e.browser.transmit;
        if (y && "function" != typeof y.send) throw Error("pino: transmit option must have a send function");
        let v = e.browser.write || s;
        e.browser.write && (e.browser.asObject = !0);
        let E = e.serializers || {},
            x = (t = e.browser.serialize, Array.isArray(t) ? t.filter(function(e) {
                return "!stdSerializers.err" !== e
            }) : !0 === t && Object.keys(E)),
            I = e.browser.serialize;
        Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (I = !1);
        let S = Object.keys(e.customLevels || {}),
            _ = ["error", "fatal", "warn", "info", "debug", "trace"].concat(S);
        "function" == typeof v && _.forEach(function(e) {
            v[e] = v
        }), (!1 === e.enabled || e.browser.disabled) && (e.level = "silent");
        let P = e.level || "info",
            T = Object.create(v);
        T.log || (T.log = m), a = {}, _.forEach(e => {
            a[e] = v[e] ? v[e] : s[e] || s[l[e] || "log"] || m
        }), T[o] = a, c({}, T), Object.defineProperty(T, "levelVal", {
            get: function() {
                return n(this.level, this)
            }
        }), Object.defineProperty(T, "level", {
            get: function() {
                return this._level
            },
            set: function(e) {
                if ("silent" !== e && !this.levels.values[e]) throw Error("unknown level " + e);
                this._level = e, u(this, A, T, "error"), u(this, A, T, "fatal"), u(this, A, T, "warn"), u(this, A, T, "info"), u(this, A, T, "debug"), u(this, A, T, "trace"), S.forEach(e => {
                    u(this, A, T, e)
                })
            }
        });
        let A = {
            transmit: y,
            serialize: x,
            asObject: e.browser.asObject,
            asObjectBindingsOnly: e.browser.asObjectBindingsOnly,
            formatters: e.browser.formatters,
            levels: _,
            timestamp: "function" == typeof(i = e).timestamp ? i.timestamp : !1 === i.timestamp ? b : w,
            messageKey: e.messageKey || "msg",
            onChild: e.onChild || m
        };

        function O(t, i, r) {
            if (!i) throw Error("missing bindings for child Pino");
            r = r || {}, x && i.serializers && (r.serializers = i.serializers);
            let s = r.serializers;
            if (x && s) {
                var n = Object.assign({}, E, s),
                    o = !0 === e.browser.serialize ? Object.keys(n) : x;
                delete i.serializers, d([i], o, n, this._stdErrSerialize)
            }

            function a(e) {
                this._childLevel = (0 | e._childLevel) + 1, this.bindings = i, n && (this.serializers = n, this._serialize = o), y && (this._logEvent = p([].concat(e._logEvent.bindings, i)))
            }
            a.prototype = this;
            let l = new a(this);
            return c(this, l), l.child = function(...e) {
                return O.call(this, t, ...e)
            }, l.level = r.level || this.level, t.onChild(l), l
        }
        return f = e.customLevels || {}, T.levels = {
            values: Object.assign({}, h.levels.values, f),
            labels: Object.assign({}, h.levels.labels, (g = {}, Object.keys(r = f).forEach(function(e) {
                g[r[e]] = e
            }), g))
        }, T.level = P, T.isLevelEnabled = function(e) {
            return !!this.levels.values[e] && this.levels.values[e] >= this.levels.values[this.level]
        }, T.setMaxListeners = T.getMaxListeners = T.emit = T.addListener = T.on = T.prependListener = T.once = T.prependOnceListener = T.removeListener = T.removeAllListeners = T.listeners = T.listenerCount = T.eventNames = T.write = T.flush = m, T.serializers = E, T._serialize = x, T._stdErrSerialize = I, T.child = function(...e) {
            return O.call(this, A, ...e)
        }, y && (T._logEvent = p()), T
    }

    function u(e, t, i, l) {
        var c, h, u, f, g, y, b;
        if (Object.defineProperty(e, l, {
                value: n(e.level, i) > n(l, i) ? m : i[o][l],
                writable: !0,
                enumerable: !0,
                configurable: !0
            }), e[l] === m) {
            if (!t.transmit) return;
            let r = n(t.transmit.level || e.level, i);
            if (n(l, i) < r) return
        }
        e[l] = (c = e, h = t, u = i, f = l, g = c[o][f], function() {
            let e = h.timestamp(),
                t = Array(arguments.length),
                i = Object.getPrototypeOf && Object.getPrototypeOf(this) === s ? s : this;
            for (var o = 0; o < t.length; o++) t[o] = arguments[o];
            var a = !1;
            if (h.serialize && (d(t, this._serialize, this.serializers, this._stdErrSerialize), a = !0), h.asObject || h.formatters ? g.call(i, ... function(e, t, i, s, n) {
                    let {
                        level: o,
                        log: a = e => e
                    } = n.formatters || {}, l = i.slice(), c = l[0], h = {}, u = (0 | e._childLevel) + 1;
                    if ((u < 1 && (u = 1), s && (h.time = s), o) ? Object.assign(h, o(t, e.levels.values[t])) : h.level = e.levels.values[t], n.asObjectBindingsOnly) {
                        if (null !== c && "object" == typeof c)
                            for (; u-- && "object" == typeof l[0];) Object.assign(h, l.shift());
                        return [a(h), ...l]
                    }
                    if (null !== c && "object" == typeof c) {
                        for (; u-- && "object" == typeof l[0];) Object.assign(h, l.shift());
                        c = l.length ? r(l.shift(), l) : void 0
                    } else "string" == typeof c && (c = r(l.shift(), l));
                    return void 0 !== c && (h[n.messageKey] = c), [a(h)]
                }(this, f, t, e, h)) : g.apply(i, t), h.transmit) {
                let i = h.transmit.level || c._level,
                    r = n(i, u),
                    s = n(f, u);
                if (s < r) return;
                ! function(e, t, i, r = !1) {
                    let s = t.send,
                        n = t.ts,
                        o = t.methodLevel,
                        a = t.methodValue,
                        l = t.val,
                        c = e._logEvent.bindings;
                    r || d(i, e._serialize || Object.keys(e.serializers), e.serializers, void 0 === e._stdErrSerialize || e._stdErrSerialize), e._logEvent.ts = n, e._logEvent.messages = i.filter(function(e) {
                        return -1 === c.indexOf(e)
                    }), e._logEvent.level.label = o, e._logEvent.level.value = a, s(o, e._logEvent, l), e._logEvent = p(c)
                }(this, {
                    ts: e,
                    methodLevel: f,
                    methodValue: s,
                    transmitLevel: i,
                    transmitValue: u.levels.values[h.transmit.level || c._level],
                    send: h.transmit.send,
                    val: n(c._level, u)
                }, t, a)
            }
        });
        let w = function(e) {
            let t = [];
            e.bindings && t.push(e.bindings);
            let i = e[a];
            for (; i.parent;)(i = i.parent).logger.bindings && t.push(i.logger.bindings);
            return t.reverse()
        }(e);
        0 !== w.length && (e[l] = (y = w, b = e[l], function() {
            return b.apply(this, [...y, ...arguments])
        }))
    }

    function d(e, t, i, r) {
        for (let s in e)
            if (r && e[s] instanceof Error) e[s] = h.stdSerializers.err(e[s]);
            else if ("object" == typeof e[s] && !Array.isArray(e[s]) && t)
            for (let r in e[s]) t.indexOf(r) > -1 && r in i && (e[s][r] = i[r](e[s][r]))
    }

    function p(e) {
        return {
            ts: 0,
            messages: [],
            bindings: e || [],
            level: {
                label: "",
                value: 0
            }
        }
    }

    function f(e) {
        let t = {
            type: e.constructor.name,
            msg: e.message,
            stack: e.stack
        };
        for (let i in e) void 0 === t[i] && (t[i] = e[i]);
        return t
    }

    function g() {
        return {}
    }

    function y(e) {
        return e
    }

    function m() {}

    function b() {
        return !1
    }

    function w() {
        return Date.now()
    }
    h.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"
        }
    }, h.stdSerializers = {
        mapHttpRequest: g,
        mapHttpResponse: g,
        wrapRequestSerializer: y,
        wrapResponseSerializer: y,
        wrapErrorSerializer: y,
        req: g,
        res: g,
        err: f,
        errWithCause: f
    }, h.stdTimeFunctions = Object.assign({}, {
        nullTime: b,
        epochTime: w,
        unixTime: function() {
            return Math.round(Date.now() / 1e3)
        },
        isoTime: function() {
            return new Date(Date.now()).toISOString()
        }
    }), t.exports.default = h, t.exports.pino = h;
    let v = "custom_context";
    var E = Object.defineProperty,
        x = (e, t, i) => {
            let r;
            return (r = "symbol" != typeof t ? t + "" : t) in e ? E(e, r, {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: i
            }) : e[r] = i
        };
    class I {
        constructor(e) {
            x(this, "nodeValue"), x(this, "sizeInBytes"), x(this, "next"), 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 S {
        constructor(e) {
            x(this, "lengthInNodes"), x(this, "sizeInBytes"), x(this, "head"), x(this, "tail"), x(this, "maxSizeInBytes"), this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e, this.sizeInBytes = 0
        }
        append(e) {
            let t = new I(e);
            if (t.size > this.maxSizeInBytes) throw Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);
            for (; this.size + t.size > this.maxSizeInBytes;) this.shift();
            this.head ? this.tail && (this.tail.next = t) : this.head = t, this.tail = t, this.lengthInNodes++, this.sizeInBytes += t.size
        }
        shift() {
            if (!this.head) return;
            let e = this.head;
            this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e.size
        }
        toArray() {
            let e = [],
                t = this.head;
            for (; null !== t;) e.push(t.value), t = t.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
                    };
                    let t = e.value;
                    return e = e.next, {
                        done: !1,
                        value: t
                    }
                }
            }
        }
    }

    function _(e) {
        return "string" == typeof e ? e : JSON.stringify(e, (e, t) => "bigint" == typeof t ? t.toString() + "n" : t) || ""
    }
    var P = Object.defineProperty,
        T = (e, t, i) => {
            let r;
            return (r = "symbol" != typeof t ? t + "" : t) in e ? P(e, r, {
                enumerable: !0,
                configurable: !0,
                writable: !0,
                value: i
            }) : e[r] = i
        };
    class A {
        constructor(e, i = 1024e3) {
            T(this, "logs"), T(this, "level"), T(this, "levelValue"), T(this, "MAX_LOG_SIZE_IN_BYTES"), this.level = e ? ? "error", this.levelValue = t.exports.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = i, this.logs = new S(this.MAX_LOG_SIZE_IN_BYTES)
        }
        forwardToConsole(e, i) {
            i === t.exports.levels.values.error ? console.error(e) : i === t.exports.levels.values.warn ? console.warn(e) : i === t.exports.levels.values.debug ? console.debug(e) : i === t.exports.levels.values.trace ? console.trace(e) : console.log(e)
        }
        appendToLogs(e) {
            this.logs.append(_({
                timestamp: new Date().toISOString(),
                log: e
            }));
            let t = "string" == typeof e ? JSON.parse(e).level : e.level;
            t >= this.levelValue && this.forwardToConsole(e, t)
        }
        getLogs() {
            return this.logs
        }
        clearLogs() {
            this.logs = new S(this.MAX_LOG_SIZE_IN_BYTES)
        }
        getLogArray() {
            return Array.from(this.logs)
        }
        logsToBlob(e) {
            let t = this.getLogArray();
            return t.push(_({
                extraMetadata: e
            })), new Blob(t, {
                type: "application/json"
            })
        }
    }
    var O = Object.defineProperty;
    class R {
        constructor(e, t = 1024e3) {
            ((e, t, i) => {
                let r;
                return (r = "symbol" != typeof t ? t + "" : t) in e ? O(e, r, {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: i
                }) : e[r] = i
            })(this, "baseChunkLogger"), this.baseChunkLogger = new A(e, t)
        }
        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) {
            let t = URL.createObjectURL(this.logsToBlob(e)),
                i = document.createElement("a");
            i.href = t, i.download = `walletconnect-logs-${new Date().toISOString()}.txt`, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(t)
        }
    }
    var N = Object.defineProperty;
    class U {
        constructor(e, t = 1024e3) {
            ((e, t, i) => {
                let r;
                return (r = "symbol" != typeof t ? t + "" : t) in e ? N(e, r, {
                    enumerable: !0,
                    configurable: !0,
                    writable: !0,
                    value: i
                }) : e[r] = i
            })(this, "baseChunkLogger"), this.baseChunkLogger = new A(e, t)
        }
        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 C = Object.defineProperty,
        k = Object.defineProperties,
        L = Object.getOwnPropertyDescriptors,
        D = Object.getOwnPropertySymbols,
        B = Object.prototype.hasOwnProperty,
        M = Object.prototype.propertyIsEnumerable,
        j = (e, t, i) => t in e ? C(e, t, {
            enumerable: !0,
            configurable: !0,
            writable: !0,
            value: i
        }) : e[t] = i,
        $ = (e, t) => {
            for (var i in t || (t = {})) B.call(t, i) && j(e, i, t[i]);
            if (D)
                for (var i of D(t)) M.call(t, i) && j(e, i, t[i]);
            return e
        };

    function q(e, t = v) {
        return e[t] || ""
    }
    e.s(["generateChildLogger", 0, function(e, t, i = v) {
        let r = function(e, t, i = v) {
            let r = q(e, i);
            return r.trim() ? `${r}/${t}` : t
        }(e, t, i);
        return function(e, t, i = v) {
            return e[i] = t, e
        }(e.child({
            context: r
        }), r, i)
    }, "generatePlatformLogger", 0, function(e) {
        var i, r, s, n, o, a, l;
        let c, h, u, d, p, f;
        if ("u" > typeof e.loggerOverride && "string" != typeof e.loggerOverride) return {
            logger: e.loggerOverride,
            chunkLoggerController: null
        };
        let g = k($({}, e.opts), L({
            level: "string" == typeof e.loggerOverride ? e.loggerOverride : null == (i = e.opts) ? void 0 : i.level
        }));
        return "u" > typeof window ? (u = new R(null == (s = (r = k($({}, e), L({
            opts: g
        }))).opts) ? void 0 : s.level, r.maxSizeInBytes), {
            logger: t.exports((c = $({}, r.opts), h = {
                level: "trace",
                browser: k($({}, null == (n = r.opts) ? void 0 : n.browser), L({
                    write: e => u.write(e)
                }))
            }, k(c, L(h)))),
            chunkLoggerController: u
        }) : (f = new U(null == (a = (o = k($({}, e), L({
            opts: g
        }))).opts) ? void 0 : a.level, o.maxSizeInBytes), {
            logger: t.exports((d = $({}, o.opts), p = {
                level: "trace",
                browser: k($({}, null == (l = o.opts) ? void 0 : l.browser), L({
                    write: e => f.write(e)
                }))
            }, k(d, L(p))), f),
            chunkLoggerController: f
        })
    }, "getDefaultLoggerOptions", 0, function(e) {
        return k($({}, e), L({
            level: e ? .level || "info"
        }))
    }, "getLoggerContext", 0, q])
}, 613532, e => {
    "use strict";
    var t = e.i(284553),
        i = e.i(690151),
        r = e.i(367069),
        s = e.i(896119),
        n = e.i(502237),
        o = e.i(918196),
        a = e.i(966832),
        l = e.i(980761),
        c = e.i(727830),
        h = e.i(495913),
        u = e.i(73975),
        d = e.i(938918),
        p = e.i(696172);
    e.i(843010);
    var f = e.i(724990),
        g = e.i(72716),
        y = e.i(634417),
        m = e.i(736820),
        b = e.i(724197),
        w = e.i(354955),
        v = e.i(281851),
        E = e.i(241961),
        x = e.i(269956),
        I = e.i(355055),
        S = e.i(272820),
        _ = e.i(812837),
        P = e.i(128130);

    function T(e) {
        let [t, i] = e.split(":");
        return {
            namespace: t,
            reference: i
        }
    }

    function A(e, t) {
        return e.includes(":") ? [e] : t.chains || []
    }
    let O = {
            INVALID_METHOD: {
                message: "Invalid method.",
                code: 1001
            },
            INVALID_EVENT: {
                message: "Invalid event.",
                code: 1002
            },
            INVALID_UPDATE_REQUEST: {
                message: "Invalid update request.",
                code: 1003
            },
            INVALID_EXTEND_REQUEST: {
                message: "Invalid extend request.",
                code: 1004
            },
            INVALID_SESSION_SETTLE_REQUEST: {
                message: "Invalid session settle request.",
                code: 1005
            },
            UNAUTHORIZED_METHOD: {
                message: "Unauthorized method.",
                code: 3001
            },
            UNAUTHORIZED_EVENT: {
                message: "Unauthorized event.",
                code: 3002
            },
            UNAUTHORIZED_UPDATE_REQUEST: {
                message: "Unauthorized update request.",
                code: 3003
            },
            UNAUTHORIZED_EXTEND_REQUEST: {
                message: "Unauthorized extend request.",
                code: 3004
            },
            USER_REJECTED: {
                message: "User rejected.",
                code: 5e3
            },
            USER_REJECTED_CHAINS: {
                message: "User rejected chains.",
                code: 5001
            },
            USER_REJECTED_METHODS: {
                message: "User rejected methods.",
                code: 5002
            },
            USER_REJECTED_EVENTS: {
                message: "User rejected events.",
                code: 5003
            },
            UNSUPPORTED_CHAINS: {
                message: "Unsupported chains.",
                code: 5100
            },
            UNSUPPORTED_METHODS: {
                message: "Unsupported methods.",
                code: 5101
            },
            UNSUPPORTED_EVENTS: {
                message: "Unsupported events.",
                code: 5102
            },
            UNSUPPORTED_ACCOUNTS: {
                message: "Unsupported accounts.",
                code: 5103
            },
            UNSUPPORTED_NAMESPACE_KEY: {
                message: "Unsupported namespace key.",
                code: 5104
            },
            USER_DISCONNECTED: {
                message: "User disconnected.",
                code: 6e3
            },
            SESSION_SETTLEMENT_FAILED: {
                message: "Session settlement failed.",
                code: 7e3
            },
            WC_METHOD_UNSUPPORTED: {
                message: "Unsupported wc_ method.",
                code: 10001
            }
        },
        R = {
            NOT_INITIALIZED: {
                message: "Not initialized.",
                code: 1
            },
            NO_MATCHING_KEY: {
                message: "No matching key.",
                code: 2
            },
            RESTORE_WILL_OVERRIDE: {
                message: "Restore will override.",
                code: 3
            },
            RESUBSCRIBED: {
                message: "Resubscribed.",
                code: 4
            },
            MISSING_OR_INVALID: {
                message: "Missing or invalid.",
                code: 5
            },
            EXPIRED: {
                message: "Expired.",
                code: 6
            },
            UNKNOWN_TYPE: {
                message: "Unknown type.",
                code: 7
            },
            MISMATCHED_TOPIC: {
                message: "Mismatched topic.",
                code: 8
            },
            NON_CONFORMING_NAMESPACES: {
                message: "Non conforming namespaces.",
                code: 9
            }
        };

    function N(e, t) {
        let {
            message: i,
            code: r
        } = R[e];
        return {
            message: t ? `${i} ${t}` : i,
            code: r
        }
    }

    function U(e, t) {
        let {
            message: i,
            code: r
        } = O[e];
        return {
            message: t ? `${i} ${t}` : i,
            code: r
        }
    }
    let C = "react-native",
        k = "node",
        L = "browser";

    function D() {
        return "u" > typeof t.default && "u" > typeof t.default.versions && "u" > typeof t.default.versions.node
    }

    function B() {
        return !(0, s.getDocument)() && !!(0, s.getNavigator)() && "ReactNative" === navigator.product
    }

    function M() {
        return !D() && !!(0, s.getNavigator)() && !!(0, s.getDocument)()
    }

    function j() {
        return B() ? C : D() ? k : M() ? L : "unknown"
    }

    function $() {
        return (0, n.getWindowMetadata)() || {
            name: "",
            description: "",
            url: "",
            icons: [""]
        }
    }

    function q(t, r, n) {
        let o, a = function() {
                if (j() === C && "u" > typeof e.g ? .Platform) {
                    let {
                        OS: t,
                        Version: i
                    } = e.g.Platform;
                    return [t, i].join("-")
                }
                let t = (0, i.detect)();
                if (null === t) return "unknown";
                let r = t.os ? t.os.replace(" ", "").toLowerCase() : "unknown";
                return "browser" === t.type ? [r, t.name, t.version].join("-") : [r, t.version].join("-")
            }(),
            l = (o = j()) === L ? [o, (0, s.getLocation)() ? .host || "unknown"].join(":") : o;
        return [
            [t, r].join("-"), ["js", n].join("-"), a, l
        ].join("/")
    }

    function z(e, t) {
        return e.filter(e => t.includes(e)).length === e.length
    }

    function V(e, t) {
        if ("string" == typeof t && t.startsWith(`${e}:`)) return t;
        if ("topic" === e.toLowerCase()) {
            if ("string" != typeof t) throw Error('Value must be "string" for expirer target type: topic');
            return `topic:${t}`
        }
        if ("id" === e.toLowerCase()) {
            if ("number" != typeof t) throw Error('Value must be "number" for expirer target type: id');
            return `id:${t}`
        }
        throw Error(`Unknown expirer target type: ${e}`)
    }

    function K(e = [], t = []) {
        return [...new Set([...e, ...t])]
    }
    async function F({
        id: t,
        topic: i,
        wcDeepLink: r
    }) {
        try {
            if (!r) return;
            let o = ("string" == typeof r ? JSON.parse(r) : r) ? .href;
            if ("string" != typeof o) return;
            let a = function(e, t, i) {
                    let r = `requestId=${t}&sessionTopic=${i}`;
                    e.endsWith("/") && (e = e.slice(0, -1));
                    let s = `${e}`;
                    if (e.startsWith("https://t.me")) {
                        let t = e.includes("?") ? "&startapp=" : "?startapp=";
                        s = `${s}${t}${function(e,t=!1){let i=new TextEncoder().encode(e),r=Array(i.length);for(let e=0;e<i.length;e++)r[e]=String.fromCharCode(i[e]);let s=btoa(r.join(""));return t?s.replace(/[=]/g,""):s}(r,!0)}`
                    } else s = `${s}/wc?${r}`;
                    return s
                }(o, t, i),
                l = j();
            if (l === L) {
                var n;
                let e;
                if (!(0, s.getDocument)() ? .hasFocus()) return void console.warn("Document does not have focus, skipping deeplink.");
                n = a, e = "_self", ! function() {
                    try {
                        return window.self !== window.top
                    } catch {
                        return !1
                    }
                }() ? ("u" > typeof window && (window.TelegramWebviewProxy || window.Telegram || window.TelegramWebviewProxyProto) || n.startsWith("https://") || n.startsWith("http://")) && (e = "_blank") : e = "_top", window.open(n, e, "noreferrer noopener")
            } else l === C && "u" > typeof e.g ? .Linking && await e.g.Linking.openURL(a)
        } catch (e) {
            console.error(e)
        }
    }
    async function H(e, t) {
        let i = "";
        try {
            if (M() && (i = localStorage.getItem(t))) return i;
            i = await e.getItem(t)
        } catch (e) {
            console.error(e)
        }
        return i
    }

    function W(e) {
        let t = atob(e + "=".repeat((4 - e.length % 4) % 4)),
            i = new Uint8Array(t.length);
        for (let e = 0; e < t.length; e++) i[e] = t.charCodeAt(e);
        return new TextDecoder().decode(i)
    }

    function G(e) {
        let t = atob(e + "=".repeat((4 - e.length % 4) % 4)),
            i = new Uint8Array(t.length);
        for (let e = 0; e < t.length; e++) i[e] = t.charCodeAt(e);
        return i
    }

    function Y(e) {
        let t = `Ethereum Signed Message:
${e.length}`,
            i = new TextEncoder().encode(t + e);
        return "0x" + (0, g.toString)((0, o.keccak_256)(i), "base16")
    }
    async function J(e, t, i, r, s, n) {
        switch (i.t) {
            case "eip191":
                var o, c, h;
                let u;
                return await (o = e, c = t, h = i.s, u = a.Signature.fromHex(h), l.Secp256k1.recoverAddress({
                    payload: Y(c),
                    signature: u
                }).toLowerCase() === o.toLowerCase());
            case "eip1271":
                return await Q(e, t, i.s, r, s, n);
            default:
                throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${i.t}`)
        }
    }
    async function Q(e, t, i, r, s, n) {
        let o = T(r);
        if (!o.namespace || !o.reference) throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);
        try {
            let o = "0x1626ba7e",
                a = i.substring(2),
                l = (a.length / 2).toString(16).padStart(64, "0"),
                c = (t.startsWith("0x") ? t : Y(t)).substring(2),
                h = o + c + "0000000000000000000000000000000000000000000000000000000000000040" + l + a,
                u = await fetch(`${n||"https://rpc.walletconnect.org/v1"}/?chainId=${r}&projectId=${s}`, {
                    headers: {
                        "Content-Type": "application/json"
                    },
                    method: "POST",
                    body: JSON.stringify({
                        id: Date.now() + Math.floor(1e3 * Math.random()),
                        jsonrpc: "2.0",
                        method: "eth_call",
                        params: [{
                            to: e,
                            data: h
                        }, "latest"]
                    })
                }),
                {
                    result: d
                } = await u.json();
            return !!d && d.slice(0, o.length).toLowerCase() === o.toLowerCase()
        } catch (e) {
            return console.error("isValidEip1271Signature: ", e), !1
        }
    }

    function Z(e) {
        let t = [],
            i = BigInt(e);
        for (; i >= 128 n;) t.push(Number(127 n & i | 128 n)), i >>= 7 n;
        return t.push(Number(i)), new Uint8Array(t)
    }
    let X = "did:pkh:",
        ee = {
            eip155: "Ethereum",
            solana: "Solana",
            bip122: "Bitcoin"
        },
        et = e => e ? .split(":"),
        ei = e => {
            let t = e && et(e);
            if (t) return t[2] + ":" + t[3]
        },
        er = e => {
            let t = e && et(e);
            if (t) return t.pop()
        };
    async function es(e) {
        let {
            cacao: t,
            projectId: i
        } = e, {
            s: r,
            p: s
        } = t, n = en(s, s.iss), o = er(s.iss);
        return await J(o, n, r, ei(s.iss), i)
    }
    let en = (e, t) => {
        let i = (e => {
            let t = e && et(e);
            if (t) return e.includes(X) ? t[2] : t[0]
        })(t);
        if (!i) throw Error("Invalid issuer: " + t);
        let r = `${e.domain} wants you to sign in with your ${i?ee[i]||i:""} account:`,
            s = er(t);
        if (!e.aud && !e.uri) throw Error("Either `aud` or `uri` is required to construct the message");
        let n = e.statement || void 0,
            o = `URI: ${e.aud||e.uri}`,
            a = `Version: ${e.version}`,
            l = `Chain ID: ${(e=>{let t=e&&et(e);if(t)return e.includes(X)?t[3]:t[1]})(t)}`,
            c = `Nonce: ${e.nonce}`,
            h = `Issued At: ${e.iat}`,
            u = e.exp ? `Expiration Time: ${e.exp}` : void 0,
            d = e.nbf ? `Not Before: ${e.nbf}` : void 0,
            p = e.requestId ? `Request ID: ${e.requestId}` : void 0,
            f = e.resources ? `Resources:${e.resources.map(e=>`
- ${e}`).join("")}` : void 0,
            g = ec(e.resources);
        return g && (n = function(e = "", t) {
            eo(t);
            let i = "I further authorize the stated URI to perform the following actions on my behalf: ";
            if (e.includes(i)) return e;
            let r = [],
                s = 0;
            Object.keys(t.att).forEach(e => {
                let i = Object.keys(t.att[e]).map(e => ({
                    ability: e.split("/")[0],
                    action: e.split("/")[1]
                }));
                i.sort((e, t) => e.action.localeCompare(t.action));
                let n = {};
                i.forEach(e => {
                    n[e.ability] || (n[e.ability] = []), n[e.ability].push(e.action)
                });
                let o = Object.keys(n).map(t => (s++, `(${s}) '${t}': '${n[t].join("', '")}' for '${e}'.`));
                r.push(o.join(", ").replace(".,", "."))
            });
            let n = r.join(" "),
                o = `${i}${n}`;
            return `${e?e+" ":""}${o}`
        }(n, el(g))), [r, s, "", n, "", o, a, l, c, h, u, d, p, f].filter(e => null != e).join(`
`)
    };

    function eo(e) {
        if (!e) throw Error("No recap provided, value is undefined");
        if (!e.att) throw Error("No `att` property found");
        let t = Object.keys(e.att);
        if (!t ? .length) throw Error("No resources found in `att` property");
        t.forEach(t => {
            let i = e.att[t];
            if (Array.isArray(i) || "object" != typeof i) throw Error(`Resource must be an object: ${t}`);
            if (!Object.keys(i).length) throw Error(`Resource object is empty: ${t}`);
            Object.keys(i).forEach(e => {
                let t = i[e];
                if (!Array.isArray(t)) throw Error(`Ability limits ${e} must be an array of objects, found: ${t}`);
                if (!t.length) throw Error(`Value of ${e} is empty array, must be an array with objects`);
                t.forEach(t => {
                    if ("object" != typeof t) throw Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)
                })
            })
        })
    }

    function ea(e) {
        return eo(e), `urn:recap:${(function(e){let t=JSON.stringify(e),i=new TextEncoder().encode(t),r=Array(i.length);for(let e=0;e<i.length;e++)r[e]=String.fromCharCode(i[e]);return btoa(r.join(""))})(e).replace(/=/g,"")}`
    }

    function el(e) {
        let t = function(e) {
            let t = atob(e + "=".repeat((4 - e.length % 4) % 4)),
                i = new Uint8Array(t.length);
            for (let e = 0; e < t.length; e++) i[e] = t.charCodeAt(e);
            return JSON.parse(new TextDecoder().decode(i))
        }(e.replace("urn:recap:", ""));
        return eo(t), t
    }

    function ec(e) {
        if (!e) return;
        let t = e ? .[e.length - 1];
        return t && t.includes("urn:recap:") ? t : void 0
    }
    let eh = "base10",
        eu = "base16",
        ed = "base64pad",
        ep = "base64url",
        ef = "utf8";

    function eg(e) {
        return (0, y.fromString)(`${e}`, eh)
    }

    function ey(e) {
        return Number((0, g.toString)(e, eh))
    }

    function em(e) {
        return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")
    }

    function eb(e) {
        let t = e.replace(/-/g, "+").replace(/_/g, "/"),
            i = (4 - t.length % 4) % 4;
        return t + "=".repeat(i)
    }

    function ew(e) {
        if (2 === ey(e.type)) return (0, g.toString)((0, f.concat)([e.type, e.sealed]), ed);
        if (1 === ey(e.type)) {
            if (typeof e.senderPublicKey > "u") throw Error("Missing sender public key for type 1 envelope");
            return (0, g.toString)((0, f.concat)([e.type, e.senderPublicKey, e.iv, e.sealed]), ed)
        }
        return (0, g.toString)((0, f.concat)([e.type, e.iv, e.sealed]), ed)
    }

    function ev(e) {
        let t = (e.encoding || ed) === ep ? eb(e.encoded) : e.encoded,
            i = (0, y.fromString)(t, ed),
            r = i.slice(0, 1);
        if (1 === ey(r)) {
            let e = i.slice(1, 33),
                t = i.slice(33, 45);
            return {
                type: r,
                sealed: i.slice(45),
                iv: t,
                senderPublicKey: e
            }
        }
        if (2 === ey(r)) return {
            type: r,
            sealed: i.slice(1),
            iv: (0, w.randomBytes)(12)
        };
        let s = i.slice(1, 13);
        return {
            type: r,
            sealed: i.slice(13),
            iv: s
        }
    }

    function eE(e) {
        let t = e ? .type || 0;
        if (1 === t) {
            if (typeof e ? .senderPublicKey > "u") throw Error("missing sender public key");
            if (typeof e ? .receiverPublicKey > "u") throw Error("missing receiver public key")
        }
        return {
            type: t,
            senderPublicKey: e ? .senderPublicKey,
            receiverPublicKey: e ? .receiverPublicKey
        }
    }

    function ex(e) {
        let t = [];
        return e.forEach(e => {
            let [i, r] = e.split(":");
            t.push(`${i}:${r}`)
        }), t
    }

    function eI(e) {
        let t = [];
        return Object.values(e).forEach(e => {
            t.push(...ex(e.accounts))
        }), [...new Set(t)]
    }

    function eS(e) {
        return e.includes(":")
    }

    function e_(e) {
        return eS(e) ? e.split(":")[0] : e
    }

    function eP(e) {
        let t = {};
        if (!eA(e)) return t;
        for (let [i, r] of Object.entries(e)) {
            let e = eS(i) ? [i] : r.chains,
                s = r.methods || [],
                n = r.events || [],
                o = e_(i);
            t[o] = { ...t[o],
                chains: K(e, t[o] ? .chains),
                methods: K(s, t[o] ? .methods),
                events: K(n, t[o] ? .events)
            }
        }
        return t
    }

    function eT(e, t) {
        return !!Array.isArray(e) && (!("u" > typeof t) || !e.length || e.every(t))
    }

    function eA(e) {
        return Object.getPrototypeOf(e) === Object.prototype && Object.keys(e).length
    }

    function eO(e) {
        return typeof e > "u"
    }

    function eR(e, t) {
        return !!(t && eO(e)) || "string" == typeof e && !!e.trim().length
    }

    function eN(e, t) {
        return !!(t && eO(e)) || "number" == typeof e && !isNaN(e)
    }

    function eU(e) {
        return !!(eR(e, !1) && e.includes(":")) && 2 === e.split(":").length
    }

    function eC(e) {
        let t = !0;
        return eT(e) ? e.length && (t = e.every(e => eR(e, !1))) : t = !1, t
    }

    function ek(e, t) {
        let i = null;
        return Object.values(e).forEach(e => {
            var r;
            let s;
            if (i) return;
            let n = (r = `${t}, namespace`, s = null, eC(e ? .methods) ? eC(e ? .events) || (s = U("UNSUPPORTED_EVENTS", `${r}, events should be an array of strings or empty array for no events`)) : s = U("UNSUPPORTED_METHODS", `${r}, methods should be an array of strings or empty array for no methods`), s);
            n && (i = n)
        }), i
    }

    function eL(e) {
        return eR(e.protocol, !0)
    }

    function eD(e) {
        return [...new Set(e.map(e => e.includes(":") ? e.split(":")[0] : e))]
    }
    async function eB() {
        return !(B() && e.g ? .NetInfo) || (await e.g ? .NetInfo.fetch()) ? .isConnected
    }
    let eM = {};

    function ej(e) {
        return new Uint8Array(e.replace(/^0x/, "").match(/.{1,2}/g).map(e => parseInt(e, 16)))
    }
    e.s(["BASE16", 0, eu, "BASE64", 0, ed, "BASE64URL", 0, ep, "LimitedSet", 0, class {
        constructor({
            limit: e
        }) {
            this.limit = e, this.set = new Set
        }
        add(e) {
            if (!this.set.has(e)) {
                if (this.set.size >= this.limit) {
                    let e = this.set.values().next().value;
                    e && this.set.delete(e)
                }
                this.set.add(e)
            }
        }
        has(e) {
            return this.set.has(e)
        }
    }, "MemoryStore", 0, class {
        static get(e) {
            return eM[e]
        }
        static set(e, t) {
            eM[e] = t
        }
        static delete(e) {
            delete eM[e]
        }
    }, "TYPE_1", 0, 1, "TYPE_2", 0, 2, "buildNamespacesFromAuth", 0, function(e, t) {
        var i;
        let r, s = (i = t = t.map(e => e.replace("did:pkh:", "")), r = {}, i ? .forEach(e => {
            let [t, i] = e.split(":");
            r[t] || (r[t] = {
                accounts: [],
                chains: [],
                events: [],
                methods: []
            }), r[t].accounts.push(e), r[t].chains ? .push(`${t}:${i}`)
        }), r);
        for (let [t, i] of Object.entries(s)) i.methods ? i.methods = K(i.methods, e) : i.methods = e, i.events = ["chainChanged", "accountsChanged"];
        return s
    }, "buildSignedExtrinsicHash", 0, function(e) {
        let t, i, r = ej(e.signature),
            s = function({
                publicKey: e,
                signature: t,
                payload: i
            }) {
                var r, s;
                let n, o = ej(i.method),
                    a = 128 | parseInt(i.version ? .toString() || "4"),
                    l = (r = i.address, 42 === (n = p.base58.decode(r)[0]) ? 0 : 60 === n ? 2 : 1),
                    c = "00" === i.era ? new Uint8Array([0]) : ej(i.era);
                if (1 !== c.length && 2 !== c.length) throw Error("Invalid era length");
                let h = parseInt(i.nonce, 16),
                    u = new Uint8Array([255 & h, h >> 8 & 255]),
                    d = new Uint8Array([0, ...e, l, ...t, ...c, ...u, ... function(e) {
                        if (e < 1 n << 6 n) return new Uint8Array([Number(e << 2 n)]);
                        if (e < 1 n << 14 n) {
                            let t = e << 2 n | 1 n;
                            return new Uint8Array([Number(255 n & t), Number(t >> 8 n & 255 n)])
                        }
                        if (e < 1 n << 30 n) {
                            let t = e << 2 n | 2 n;
                            return new Uint8Array([Number(255 n & t), Number(t >> 8 n & 255 n), Number(t >> 16 n & 255 n), Number(t >> 24 n & 255 n)])
                        }
                        throw Error("BigInt compact encoding not supported > 2^30")
                    }(BigInt(`0x${(s=i.tip).startsWith("0x")?s.slice(2):s}`)), ...o]);
                return new Uint8Array([... function(e) {
                    if (e < 64) return new Uint8Array([e << 2]);
                    if (e < 16384) {
                        let t = e << 2 | 1;
                        return new Uint8Array([255 & t, t >> 8 & 255])
                    }
                    if (e < 0x40000000) {
                        let t = e << 2 | 2;
                        return new Uint8Array([255 & t, t >> 8 & 255, t >> 16 & 255, t >> 24 & 255])
                    }
                    throw Error("Compact encoding > 2^30 not supported")
                }(d.length + 1), a, ...d])
            }({
                publicKey: function(e) {
                    let t = p.base58.decode(e);
                    if (t.length < 33) throw Error("Too short to contain a public key");
                    return t.slice(1, 33)
                }(e.transaction.address),
                signature: r,
                payload: e.transaction
            });
        return t = ej((0, g.toString)(s, "base16")), i = (0, _.blake2b)(t, void 0, 32), "0x" + (0, g.toString)(i, "base16")
    }, "calcExpiry", 0, function(e, t) {
        return (0, r.fromMiliseconds)((t || Date.now()) + (0, r.toMiliseconds)(e))
    }, "createDelayedPromise", 0, function(e = r.FIVE_MINUTES, t) {
        let i, s, n, o, a = (0, r.toMiliseconds)(e || r.FIVE_MINUTES);
        return {
            resolve: e => {
                n && i && (clearTimeout(n), i(e), o = Promise.resolve(e))
            },
            reject: e => {
                n && s && (clearTimeout(n), s(e))
            },
            done: () => new Promise((e, r) => {
                if (o) return e(o);
                n = setTimeout(() => {
                    let e = N("EXPIRED"),
                        i = Error(t || e.message);
                    i.code = e.code, r(i)
                }, a), i = e, s = r
            })
        }
    }, "createEncodedRecap", 0, function(e, t, i) {
        return ea(function(e, t, i, r = {}) {
            return i ? .sort((e, t) => e.localeCompare(t)), {
                att: {
                    [e]: function(e, t, i = {}) {
                        return Object.assign({}, ...(t = t ? .sort((e, t) => e.localeCompare(t))).map(t => ({
                            [`${e}/${t}`]: [i]
                        })))
                    }(t, i, r)
                }
            }
        }(e, t, i))
    }, "createExpiringPromise", 0, function(e, t, i) {
        return new Promise(async (r, s) => {
            let n = setTimeout(() => s(Error(i)), t);
            try {
                let t = await e;
                r(t)
            } catch (e) {
                s(e)
            }
            clearTimeout(n)
        })
    }, "createLogger", 0, function({
        logger: e,
        name: t
    }) {
        let i = "string" == typeof e ? (0, P.generatePlatformLogger)({
            opts: {
                level: e,
                name: t
            }
        }).logger : e;
        return i.level = "string" == typeof e ? e : e.level, i
    }, "decodeTypeByte", 0, ey, "decodeTypeTwoEnvelope", 0, function(e, t) {
        let {
            sealed: i
        } = ev({
            encoded: e,
            encoding: t
        });
        return (0, g.toString)(i, ef)
    }, "decrypt", 0, function(e) {
        let t = (0, y.fromString)(e.symKey, eu),
            {
                sealed: i,
                iv: r
            } = ev({
                encoded: e.encoded,
                encoding: e.encoding
            }),
            s = (0, m.chacha20poly1305)(t, r).decrypt(i);
        if (null === s) throw Error("Failed to decrypt");
        return (0, g.toString)(s, ef)
    }, "deriveSymKey", 0, function(e, t) {
        let i = E.x25519.getSharedSecret((0, y.fromString)(e, eu), (0, y.fromString)(t, eu)),
            r = (0, b.hkdf)(v.sha256, i, void 0, void 0, 32);
        return (0, g.toString)(r, eu)
    }, "deserialize", 0, ev, "encodeTypeTwoEnvelope", 0, function(e, t) {
        let i = eg(2),
            r = (0, w.randomBytes)(12),
            s = ew({
                type: i,
                sealed: (0, y.fromString)(e, ef),
                iv: r
            });
        return t === ep ? em(s) : s
    }, "encrypt", 0, function(e) {
        let t = eg("u" > typeof e.type ? e.type : 0);
        if (1 === ey(t) && typeof e.senderPublicKey > "u") throw Error("Missing sender public key for type 1 envelope");
        let i = "u" > typeof e.senderPublicKey ? (0, y.fromString)(e.senderPublicKey, eu) : void 0,
            r = "u" > typeof e.iv ? (0, y.fromString)(e.iv, eu) : (0, w.randomBytes)(12),
            s = (0, y.fromString)(e.symKey, eu),
            n = ew({
                type: t,
                sealed: (0, m.chacha20poly1305)(s, r).encrypt((0, y.fromString)(e.message, ef)),
                iv: r,
                senderPublicKey: i
            });
        return e.encoding === ep ? em(n) : n
    }, "engineEvent", 0, function(e, t) {
        return `${e}${t?`:${t}`:""}`
    }, "extractSolanaTransactionId", 0, function(e) {
        let t = G(e),
            i = t[0];
        if (0 === i) throw Error("No signatures found");
        if (t.length < 1 + 64 * i) throw Error("Transaction data too short for claimed signature count");
        if (t.length < 100) throw Error("Transaction too short");
        let r = t.slice(1, 65);
        return p.base58.encode(r)
    }, "formatIdTarget", 0, function(e) {
        return V("id", e)
    }, "formatMessage", 0, en, "formatRelayRpcUrl", 0, function({
        protocol: e,
        version: t,
        relayUrl: i,
        sdkVersion: r,
        auth: s,
        projectId: n,
        useOnCloseEvent: o,
        bundleId: a,
        packageName: l
    }) {
        var c, h;
        let u, d = i.split("?"),
            p = q(e, t, r),
            f = (c = d[1] || "", h = {
                auth: s,
                ua: p,
                projectId: n,
                useOnCloseEvent: o || void 0,
                packageName: l || void 0,
                bundleId: a || void 0
            }, u = new URLSearchParams(c), Object.entries(h).sort(([e], [t]) => e.localeCompare(t)).forEach(([e, t]) => {
                null != t && u.set(e, String(t))
            }), u.toString());
        return d[0] + "?" + f
    }, "formatTopicTarget", 0, function(e) {
        return V("topic", e)
    }, "formatUA", 0, q, "formatUri", 0, function(e) {
        let t = new URLSearchParams;
        return Object.entries({ ... function(e, t = "-") {
                let i = {};
                return Object.keys(e).forEach(r => {
                    e[r] && (i["relay" + t + r] = e[r])
                }), i
            }(e.relay),
            symKey: e.symKey,
            ...e.expiryTimestamp && {
                expiryTimestamp: e.expiryTimestamp.toString()
            },
            ...e.methods && {
                methods: e.methods.join(",")
            }
        }).sort(([e], [t]) => e.localeCompare(t)).forEach(([e, i]) => {
            void 0 !== i && t.append(e, String(i))
        }), `${e.protocol}:${e.topic}@${e.version}?${t}`
    }, "generateKeyPair", 0, function() {
        let e = E.x25519.utils.randomPrivateKey(),
            t = E.x25519.getPublicKey(e);
        return {
            privateKey: (0, g.toString)(e, eu),
            publicKey: (0, g.toString)(t, eu)
        }
    }, "generateRandomBytes32", 0, function() {
        let e = (0, w.randomBytes)(32);
        return (0, g.toString)(e, eu)
    }, "getAccountsFromNamespaces", 0, function(e, t = []) {
        let i = [];
        return Object.keys(e).forEach(r => {
            if (t.length && !t.includes(r)) return;
            let s = e[r];
            i.push(...s.accounts)
        }), i
    }, "getAlgorandTransactionId", 0, function(e) {
        let t = G(e),
            i = (0, u.decode)(t).txn;
        if (!i) throw Error("Invalid signed transaction: missing 'txn' field");
        let r = (0, d.encode)(i),
            s = new TextEncoder().encode("TX"),
            n = (0, f.concat)([s, new Uint8Array(r)]),
            o = (0, c.sha512_256)(n);
        return p.base32.encode(o).replace(/=+$/, "")
    }, "getAppId", 0, function() {
        try {
            return B() && "u" > typeof e.g ? .Application ? e.g.Application ? .applicationId : void 0
        } catch {
            return
        }
    }, "getAppMetadata", 0, $, "getChainsFromRecap", 0, function(e) {
        let t = el(e);
        eo(t);
        let i = [];
        return Object.values(t.att).forEach(e => {
            Object.values(e).forEach(e => {
                e ? .[0] ? .chains && i.push(e[0].chains)
            })
        }), [...new Set(i.flat())]
    }, "getDeepLink", 0, H, "getDidAddress", 0, er, "getInternalError", 0, N, "getLinkModeURL", 0, function(e, t, i) {
        return `${e}?wc_ev=${i}&topic=${t}`
    }, "getMethodsFromRecap", 0, function(e) {
        let t = el(e);
        eo(t);
        let i = t.att ? .eip155;
        return i ? Object.keys(i).map(e => e.split("/")[1]) : []
    }, "getNamespacedDidChainId", 0, ei, "getNamespacesChains", 0, eI, "getNamespacesEvents", 0, function(e) {
        let t = [];
        return Object.values(e).forEach(e => {
            t.push(...e.events)
        }), [...new Set(t)]
    }, "getNamespacesMethods", 0, function(e) {
        let t = [];
        return Object.values(e).forEach(e => {
            t.push(...e.methods)
        }), [...new Set(t)]
    }, "getNearTransactionIdFromSignedTransaction", 0, function(e) {
        let t = new Uint8Array((0, c.sha256)(function(e) {
            if (e instanceof Uint8Array) return e;
            if (Array.isArray(e)) return new Uint8Array(e);
            if ("object" == typeof e && e ? .data) return new Uint8Array(Object.values(e.data));
            if ("object" == typeof e && e) return new Uint8Array(Object.values(e));
            throw Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")
        }(e)));
        return p.base58.encode(t)
    }, "getRecapFromResources", 0, ec, "getRelayProtocolApi", 0, function(e) {
        let t = S.RELAY_JSONRPC[e];
        if (typeof t > "u") throw Error(`Relay Protocol not supported: ${e}`);
        return t
    }, "getRelayProtocolName", 0, function(e) {
        return e ? .relay || {
            protocol: "irn"
        }
    }, "getSdkError", 0, U, "getSearchParamFromURL", 0, function(e, t) {
        if (!e.includes(t)) return null;
        let i = e.split(/([&,?,=])/),
            r = i.indexOf(t);
        return i[r + 2]
    }, "getSignDirectHash", 0, function(e) {
        let t = G(e.signed.bodyBytes),
            i = G(e.signed.authInfoBytes),
            r = G(e.signature.signature),
            s = [];
        s.push(new Uint8Array([10])), s.push(Z(t.length)), s.push(t), s.push(new Uint8Array([18])), s.push(Z(i.length)), s.push(i), s.push(new Uint8Array([26])), s.push(Z(r.length)), s.push(r);
        let n = (0, f.concat)(s),
            o = (0, c.sha256)(n);
        return (0, g.toString)(o, "base16").toUpperCase()
    }, "getSuiDigest", 0, function(e) {
        let t = G(e),
            i = new TextEncoder().encode("TransactionData::"),
            r = new Uint8Array(i.length + t.length);
        r.set(i), r.set(t, i.length);
        let s = (0, h.blake2b)(r, {
            dkLen: 32
        });
        return p.base58.encode(s)
    }, "getWalletSendCallsHashes", 0, function(e) {
        let t = [];
        try {
            if ("string" == typeof e) return t.push(e), t;
            if ("object" != typeof e) return t;
            e ? .id && t.push(e.id);
            let i = e ? .capabilities ? .caip345 ? .transactionHashes;
            i && t.push(...i)
        } catch (e) {
            console.warn("getWalletSendCallsHashes failed: ", e)
        }
        return t
    }, "handleDeeplinkRedirect", 0, F, "hashKey", 0, function(e) {
        let t = (0, v.sha256)((0, y.fromString)(e, eu));
        return (0, g.toString)(t, eu)
    }, "hashMessage", 0, function(e) {
        let t = (0, v.sha256)((0, y.fromString)(e, ef));
        return (0, g.toString)(t, eu)
    }, "isAndroid", 0, function() {
        return B() && "u" > typeof e.g ? .Platform && e.g ? .Platform.OS === "android"
    }, "isAppVisible", 0, function() {
        return !(M() && (0, s.getDocument)()) || (0, s.getDocument)() ? .visibilityState === "visible"
    }, "isBrowser", 0, M, "isCaipNamespace", 0, eS, "isConformingNamespaces", 0, function(e, t, i) {
        var r, s;
        let n, o, a = null,
            l = (n = {}, Object.keys(r = e).forEach(e => {
                e.includes(":") ? n[e] = r[e] : r[e].chains ? .forEach(t => {
                    n[t] = {
                        methods: r[e].methods,
                        events: r[e].events
                    }
                })
            }), n),
            c = (o = {}, Object.keys(s = t).forEach(e => {
                e.includes(":") ? o[e] = s[e] : ex(s[e].accounts) ? .forEach(t => {
                    o[t] = {
                        accounts: s[e].accounts.filter(e => e.includes(`${t}:`)),
                        methods: s[e].methods,
                        events: s[e].events
                    }
                })
            }), o),
            h = Object.keys(l),
            u = Object.keys(c),
            d = eD(Object.keys(e)),
            p = eD(Object.keys(t)),
            f = d.filter(e => !p.includes(e));
        return f.length && (a = N("NON_CONFORMING_NAMESPACES", `${i} namespaces keys don't satisfy requiredNamespaces.
      Required: ${f.toString()}
      Received: ${Object.keys(t).toString()}`)), z(h, u) || (a = N("NON_CONFORMING_NAMESPACES", `${i} namespaces chains don't satisfy required namespaces.
      Required: ${h.toString()}
      Approved: ${u.toString()}`)), Object.keys(t).forEach(e => {
            if (!e.includes(":") || a) return;
            let r = ex(t[e].accounts);
            r.includes(e) || (a = N("NON_CONFORMING_NAMESPACES", `${i} namespaces accounts don't satisfy namespace accounts for ${e}
        Required: ${e}
        Approved: ${r.toString()}`))
        }), h.forEach(e => {
            a || (z(l[e].methods, c[e].methods) ? z(l[e].events, c[e].events) || (a = N("NON_CONFORMING_NAMESPACES", `${i} namespaces events don't satisfy namespace events for ${e}`)) : a = N("NON_CONFORMING_NAMESPACES", `${i} namespaces methods don't satisfy namespace methods for ${e}`))
        }), a
    }, "isExpired", 0, function(e) {
        return Date.now() >= (0, r.toMiliseconds)(e)
    }, "isIos", 0, function() {
        return B() && "u" > typeof e.g ? .Platform && e.g ? .Platform.OS === "ios"
    }, "isNode", 0, D, "isOnline", 0, function() {
        let e = j();
        return new Promise(t => {
            switch (e) {
                case L:
                    t(M() && navigator ? .onLine);
                    break;
                case C:
                    t(eB());
                    break;
                default:
                    t(!0)
            }
        })
    }, "isProposalStruct", 0, function(e) {
        return e ? .proposer ? .publicKey
    }, "isReactNative", 0, B, "isSessionCompatible", 0, function(e, t) {
        let {
            requiredNamespaces: i
        } = t, r = Object.keys(e.namespaces), s = Object.keys(i), n = !0;
        return !!z(s, r) && (r.forEach(t => {
            let {
                accounts: r,
                methods: s,
                events: o
            } = e.namespaces[t], a = ex(r), l = i[t];
            z(A(t, l), a) && z(l.methods, s) && z(l.events, o) || (n = !1)
        }), n)
    }, "isSessionStruct", 0, function(e) {
        return e ? .topic
    }, "isTestRun", 0, function() {
        return "u" > typeof t.default && "true" === t.default.env.IS_VITEST
    }, "isTypeOneEnvelope", 0, function(e) {
        return 1 === e.type && "string" == typeof e.senderPublicKey && "string" == typeof e.receiverPublicKey
    }, "isTypeTwoEnvelope", 0, function(e) {
        return 2 === e.type
    }, "isUndefined", 0, eO, "isValidArray", 0, eT, "isValidController", 0, function(e, t) {
        let i = null;
        return eR(e ? .publicKey, !1) || (i = N("MISSING_OR_INVALID", `${t} controller public key should be a string`)), i
    }, "isValidErrorReason", 0, function(e) {
        return !(!e || "object" != typeof e || !e.code || !eN(e.code, !1) || !e.message || !eR(e.message, !1))
    }, "isValidEvent", 0, function(e) {
        return !(eO(e) || !eR(e.name, !1))
    }, "isValidId", 0, function(e) {
        return "number" == typeof e
    }, "isValidNamespaces", 0, function(e, t) {
        let i = null;
        if (e && eA(e)) {
            let r, s = ek(e, t);
            s && (i = s);
            let n = (r = null, Object.values(e).forEach(e => {
                var i, s;
                let n;
                if (r) return;
                let o = (i = e ? .accounts, s = `${t} namespace`, n = null, eT(i) ? i.forEach(e => {
                    n || function(e) {
                        if (eR(e, !1) && e.includes(":")) {
                            let t = e.split(":");
                            if (3 === t.length) {
                                let e = t[0] + ":" + t[1];
                                return !!t[2] && eU(e)
                            }
                        }
                        return !1
                    }(e) || (n = U("UNSUPPORTED_ACCOUNTS", `${s}, account ${e} should be a string and conform to "namespace:chainId:address" format`))
                }) : n = U("UNSUPPORTED_ACCOUNTS", `${s}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), n);
                o && (r = o)
            }), r);
            n && (i = n)
        } else i = N("MISSING_OR_INVALID", `${t}, namespaces should be an object with data`);
        return i
    }, "isValidNamespacesChainId", 0, function(e, t) {
        return !(!eU(t) || !eI(e).includes(t))
    }, "isValidNamespacesEvent", 0, function(e, t, i) {
        let r;
        return !!eR(i, !1) && (r = [], Object.values(e).forEach(e => {
            ex(e.accounts).includes(t) && r.push(...e.events)
        }), r).includes(i)
    }, "isValidNamespacesRequest", 0, function(e, t, i) {
        let r;
        return !!eR(i, !1) && (r = [], Object.values(e).forEach(e => {
            ex(e.accounts).includes(t) && r.push(...e.methods)
        }), r).includes(i)
    }, "isValidObject", 0, eA, "isValidParams", 0, function(e) {
        return "u" > typeof e
    }, "isValidRelay", 0, eL, "isValidRelays", 0, function(e, t) {
        let i = !1;
        return t && !e ? i = !0 : e && eT(e) && e.length && e.forEach(e => {
            i = eL(e)
        }), i
    }, "isValidRequest", 0, function(e) {
        return !(eO(e) || !eR(e.method, !1))
    }, "isValidRequestExpiry", 0, function(e, t) {
        return eN(e, !1) && e <= t.max && e >= t.min
    }, "isValidRequiredNamespaces", 0, function(e, t, i) {
        let r = null;
        if (e && eA(e)) {
            let s, n = ek(e, t);
            n && (r = n);
            let o = (s = null, Object.entries(e).forEach(([e, r]) => {
                var n, o;
                let a;
                if (s) return;
                let l = (n = A(e, r), o = `${t} ${i}`, a = null, eT(n) && n.length ? n.forEach(e => {
                    a || eU(e) || (a = U("UNSUPPORTED_CHAINS", `${o}, chain ${e} should be a string and conform to "namespace:chainId" format`))
                }) : eU(e) || (a = U("UNSUPPORTED_CHAINS", `${o}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)), a);
                l && (s = l)
            }), s);
            o && (r = o)
        } else r = N("MISSING_OR_INVALID", `${t}, ${i} should be an object with data`);
        return r
    }, "isValidResponse", 0, function(e) {
        return !(eO(e) || eO(e.result) && eO(e.error) || !eN(e.id, !1) || !eR(e.jsonrpc, !1))
    }, "isValidString", 0, eR, "isValidUrl", 0, function(e) {
        function t(e) {
            try {
                return "u" > typeof new URL(e)
            } catch {
                return !1
            }
        }
        try {
            if (eR(e, !1)) {
                if (t(e)) return !0;
                let i = W(e);
                return t(i)
            }
        } catch {}
        return !1
    }, "mapToObj", 0, function(e) {
        return Object.fromEntries(e.entries())
    }, "mergeArrays", 0, K, "mergeEncodedRecaps", 0, function(e, t) {
        var i, r;
        let s, n;
        return ea((i = el(e), r = el(t), eo(i), eo(r), s = Object.keys(i.att).concat(Object.keys(r.att)).sort((e, t) => e.localeCompare(t)), n = {
            att: {}
        }, s.forEach(e => {
            Object.keys(i.att ? .[e] || {}).concat(Object.keys(r.att ? .[e] || {})).sort((e, t) => e.localeCompare(t)).forEach(t => {
                n.att[e] = { ...n.att[e],
                    [t]: i.att[e] ? .[t] || r.att[e] ? .[t]
                }
            })
        }), n))
    }, "mergeRequiredAndOptionalNamespaces", 0, function(e, t) {
        let i = eP(e),
            r = eP(t),
            s = {};
        for (let e of Object.keys(i).concat(Object.keys(r))) s[e] = {
            chains: K(i[e] ? .chains, r[e] ? .chains),
            methods: K(i[e] ? .methods, r[e] ? .methods),
            events: K(i[e] ? .events, r[e] ? .events)
        };
        return s
    }, "objToMap", 0, function(e) {
        return new Map(Object.entries(e))
    }, "parseChainId", 0, T, "parseExpirerTarget", 0, function(e) {
        let [t, i] = e.split(":"), r = {
            id: void 0,
            topic: void 0
        };
        if ("topic" === t && "string" == typeof i) r.topic = i;
        else if ("id" === t && Number.isInteger(Number(i))) r.id = Number(i);
        else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);
        return r
    }, "parseNamespaceKey", 0, e_, "parseUri", 0, function(e) {
        var t;
        if (!e.includes("wc:")) {
            let t = W(e);
            t ? .includes("wc:") && (e = t)
        }
        let i = (e = (e = e.includes("wc://") ? e.replace("wc://", "") : e).includes("wc:") ? e.replace("wc:", "") : e).indexOf(":"),
            r = -1 !== e.indexOf("?") ? e.indexOf("?") : void 0,
            s = e.substring(0, i),
            n = e.substring(i + 1, r).split("@"),
            o = Object.fromEntries(new URLSearchParams("u" > typeof r ? e.substring(r) : "").entries()),
            a = "string" == typeof o.methods ? o.methods.split(",") : void 0;
        return {
            protocol: s,
            topic: (t = n[0]).startsWith("//") ? t.substring(2) : t,
            version: parseInt(n[1], 10),
            symKey: o.symKey,
            relay: function(e, t = "-") {
                let i = {},
                    r = "relay" + t;
                return Object.keys(e).forEach(t => {
                    if (t.startsWith(r)) {
                        let s = t.replace(r, ""),
                            n = e[t];
                        i[s] = n
                    }
                }), i
            }(o),
            methods: a,
            expiryTimestamp: o.expiryTimestamp ? parseInt(o.expiryTimestamp, 10) : void 0
        }
    }, "populateAppMetadata", 0, function(e) {
        let t = $();
        try {
            return e ? .url && t.url && new URL(e.url).host !== new URL(t.url).host && (console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${t.url}. This is probably unintended and can lead to issues.`), e.url = t.url), e ? .icons ? .length && e.icons.length > 0 && (e.icons = e.icons.filter(e => "" !== e)), { ...t,
                ...e,
                url: e ? .url || t.url,
                name: e ? .name || t.name,
                description: e ? .description || t.description,
                icons: e ? .icons ? .length && e.icons.length > 0 ? e.icons : t.icons
            }
        } catch (i) {
            return console.warn("Error populating app metadata", i), e || t
        }
    }, "sleep", 0, function(e) {
        return new Promise(t => setTimeout(t, e))
    }, "subscribeToNetworkChange", 0, function(t) {
        var i, r;
        switch (j()) {
            case L:
                i = t, !B() && M() && (window.addEventListener("online", () => i(!0)), window.addEventListener("offline", () => i(!1)));
                break;
            case C:
                r = t, B() && e.g ? .NetInfo && e.g ? .NetInfo.addEventListener(e => r(e ? .isConnected))
        }
    }, "uuidv4", 0, function() {
        return "u" > typeof crypto && crypto ? .randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu, e => {
            let t = 16 * Math.random() | 0;
            return ("x" === e ? t : 3 & t | 8).toString(16)
        })
    }, "validateDecoding", 0, function(e, t) {
        let i = ev({
            encoded: e,
            encoding: t ? .encoding
        });
        return eE({
            type: ey(i.type),
            senderPublicKey: "u" > typeof i.senderPublicKey ? (0, g.toString)(i.senderPublicKey, eu) : void 0,
            receiverPublicKey: t ? .receiverPublicKey
        })
    }, "validateEncoding", 0, eE, "validateSignedCacao", 0, es, "verifyP256Jwt", 0, function(e, t) {
        let i, r, [s, n, o] = e.split("."),
            a = (0, y.fromString)(eb(o), ed);
        if (64 !== a.length) throw Error("Invalid signature length");
        let l = a.slice(0, 32),
            c = a.slice(32, 64),
            h = `${s}.${n}`,
            u = (0, v.sha256)(h),
            d = (i = (0, y.fromString)(eb(t.x), ed), r = (0, y.fromString)(eb(t.y), ed), (0, f.concat)([new Uint8Array([4]), i, r]));
        if (!x.p256.verify((0, f.concat)([l, c]), u, d)) throw Error("Invalid signature");
        return (0, I.decodeJWT)(e).payload
    }])
}, 383972, 920020, 294819, 22304, e => {
    "use strict";
    let t;
    var i = e.i(379666),
        r = e.i(367069);
    class s {}
    e.s(["IEvents", 0, s], 920020);
    class n extends s {
        constructor(e) {
            super()
        }
    }
    let o = r.FIVE_SECONDS,
        a = {
            pulse: "heartbeat_pulse"
        };
    class l extends n {
        constructor(e) {
            super(e), this.events = new i.EventEmitter, this.interval = o, this.interval = e ? .interval || o
        }
        static async init(e) {
            let t = new l(e);
            return await t.init(), t
        }
        async init() {
            await this.initialize()
        }
        stop() {
            clearInterval(this.intervalRef)
        }
        on(e, t) {
            this.events.on(e, t)
        }
        once(e, t) {
            this.events.once(e, t)
        }
        off(e, t) {
            this.events.off(e, t)
        }
        removeListener(e, t) {
            this.events.removeListener(e, t)
        }
        async initialize() {
            this.intervalRef = setInterval(() => this.pulse(), (0, r.toMiliseconds)(this.interval))
        }
        pulse() {
            this.events.emit(a.pulse)
        }
    }
    e.s(["HEARTBEAT_EVENTS", 0, a, "HeartBeat", 0, l], 383972);
    let c = /"(?:_|\\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*:/,
        h = /"(?: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*:/,
        u = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;

    function d(e, t) {
        var i;
        return "__proto__" === e || "constructor" === e && t && "object" == typeof t && "prototype" in t ? void(i = e, console.warn(`[destr] Dropping "${i}" key to prevent prototype pollution.`)) : t
    }

    function p(e, t = {}) {
        if ("string" != typeof e) return e;
        if ('"' === e[0] && '"' === e[e.length - 1] && -1 === e.indexOf("\\")) return e.slice(1, -1);
        let i = e.trim();
        if (i.length <= 9) switch (i.toLowerCase()) {
            case "true":
                return !0;
            case "false":
                return !1;
            case "undefined":
                return;
            case "null":
                return null;
            case "nan":
                return NaN;
            case "infinity":
                return 1 / 0;
            case "-infinity":
                return -1 / 0
        }
        if (!u.test(e)) {
            if (t.strict) throw SyntaxError("[destr] Invalid JSON");
            return e
        }
        try {
            if (c.test(e) || h.test(e)) {
                if (t.strict) throw Error("[destr] Possible prototype pollution");
                return JSON.parse(e, d)
            }
            return JSON.parse(e)
        } catch (i) {
            if (t.strict) throw i;
            return e
        }
    }
    var f = e.i(93257);

    function g(e, ...t) {
        try {
            var i;
            return (i = e(...t)) && "function" == typeof i.then ? i : Promise.resolve(i)
        } catch (e) {
            return Promise.reject(e)
        }
    }

    function y(e) {
        let t, i;
        if (t = typeof e, null === e || "object" !== t && "function" !== t) return String(e);
        if (!(i = Object.getPrototypeOf(e)) || i.isPrototypeOf(Object) || Array.isArray(e)) return JSON.stringify(e);
        if ("function" == typeof e.toJSON) return y(e.toJSON());
        throw Error("[unstorage] Cannot stringify value!")
    }
    let m = "base64:";

    function b(e) {
        return e && e.split("?")[0] ? .replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || ""
    }

    function w(e) {
        return (e = b(e)) ? e + ":" : ""
    }

    function v(e, t, i) {
        return e.watch ? e.watch((e, r) => t(e, i + r)) : () => {}
    }
    async function E(e) {
        "function" == typeof e.dispose && await g(e.dispose)
    }

    function x(e) {
        return new Promise((t, i) => {
            e.oncomplete = e.onsuccess = () => t(e.result), e.onabort = e.onerror = () => i(e.error)
        })
    }

    function I(e, t) {
        let i;
        return (r, s) => (() => {
            if (i) return i;
            let r = indexedDB.open(e);
            return r.onupgradeneeded = () => r.result.createObjectStore(t), (i = x(r)).then(e => {
                e.onclose = () => i = void 0
            }, () => {}), i
        })().then(e => s(e.transaction(t, r).objectStore(t)))
    }

    function S() {
        return t || (t = I("keyval-store", "keyval")), t
    }
    e.s(["createStorage", 0, function(e = {}) {
        let t, i = {
                mounts: {
                    "": e.driver || (t = new Map, {
                        name: "memory",
                        getInstance: () => t,
                        hasItem: e => t.has(e),
                        getItem: e => t.get(e) ? ? null,
                        getItemRaw: e => t.get(e) ? ? null,
                        setItem(e, i) {
                            t.set(e, i)
                        },
                        setItemRaw(e, i) {
                            t.set(e, i)
                        },
                        removeItem(e) {
                            t.delete(e)
                        },
                        getKeys: () => [...t.keys()],
                        clear() {
                            t.clear()
                        },
                        dispose() {
                            t.clear()
                        }
                    })
                },
                mountpoints: [""],
                watching: !1,
                watchListeners: [],
                unwatch: {}
            },
            r = e => {
                for (let t of i.mountpoints)
                    if (e.startsWith(t)) return {
                        base: t,
                        relativeKey: e.slice(t.length),
                        driver: i.mounts[t]
                    };
                return {
                    base: "",
                    relativeKey: e,
                    driver: i.mounts[""]
                }
            },
            s = (e, t) => i.mountpoints.filter(i => i.startsWith(e) || t && e.startsWith(i)).map(t => ({
                relativeBase: e.length > t.length ? e.slice(t.length) : void 0,
                mountpoint: t,
                driver: i.mounts[t]
            })),
            n = (e, t) => {
                if (i.watching)
                    for (let r of (t = b(t), i.watchListeners)) r(e, t)
            },
            o = async () => {
                if (!i.watching)
                    for (let e in i.watching = !0, i.mounts) i.unwatch[e] = await v(i.mounts[e], n, e)
            },
            a = async () => {
                if (i.watching) {
                    for (let e in i.unwatch) await i.unwatch[e]();
                    i.unwatch = {}, i.watching = !1
                }
            },
            l = (e, t, i) => {
                let s = new Map,
                    n = e => {
                        let t = s.get(e.base);
                        return t || (t = {
                            driver: e.driver,
                            base: e.base,
                            items: []
                        }, s.set(e.base, t)), t
                    };
                for (let i of e) {
                    let e = "string" == typeof i,
                        s = b(e ? i : i.key),
                        o = e ? void 0 : i.value,
                        a = e || !i.options ? t : { ...t,
                            ...i.options
                        },
                        l = r(s);
                    n(l).items.push({
                        key: s,
                        value: o,
                        relativeKey: l.relativeKey,
                        options: a
                    })
                }
                return Promise.all([...s.values()].map(e => i(e))).then(e => e.flat())
            },
            c = {
                hasItem(e, t = {}) {
                    let {
                        relativeKey: i,
                        driver: s
                    } = r(e = b(e));
                    return g(s.hasItem, i, t)
                },
                getItem(e, t = {}) {
                    let {
                        relativeKey: i,
                        driver: s
                    } = r(e = b(e));
                    return g(s.getItem, i, t).then(e => p(e))
                },
                getItems: (e, t = {}) => l(e, t, e => e.driver.getItems ? g(e.driver.getItems, e.items.map(e => ({
                    key: e.relativeKey,
                    options: e.options
                })), t).then(t => t.map(t => ({
                    key: function(...e) {
                        return b(e.join(":"))
                    }(e.base, t.key),
                    value: p(t.value)
                }))) : Promise.all(e.items.map(t => g(e.driver.getItem, t.relativeKey, t.options).then(e => ({
                    key: t.key,
                    value: p(e)
                }))))),
                getItemRaw(e, t = {}) {
                    let {
                        relativeKey: i,
                        driver: s
                    } = r(e = b(e));
                    return s.getItemRaw ? g(s.getItemRaw, i, t) : g(s.getItem, i, t).then(e => {
                        var t;
                        return "string" == typeof e && e.startsWith(m) ? (t = e.slice(m.length), globalThis.Buffer ? f.Buffer.from(t, "base64") : Uint8Array.from(globalThis.atob(t), e => e.codePointAt(0))) : e
                    })
                },
                async setItem(e, t, i = {}) {
                    if (void 0 === t) return c.removeItem(e);
                    let {
                        relativeKey: s,
                        driver: o
                    } = r(e = b(e));
                    o.setItem && (await g(o.setItem, s, y(t), i), o.watch || n("update", e))
                },
                async setItems(e, t) {
                    await l(e, t, async e => {
                        if (e.driver.setItems) return g(e.driver.setItems, e.items.map(e => ({
                            key: e.relativeKey,
                            value: y(e.value),
                            options: e.options
                        })), t);
                        e.driver.setItem && await Promise.all(e.items.map(t => g(e.driver.setItem, t.relativeKey, y(t.value), t.options)))
                    })
                },
                async setItemRaw(e, t, i = {}) {
                    if (void 0 === t) return c.removeItem(e, i);
                    let {
                        relativeKey: s,
                        driver: o
                    } = r(e = b(e));
                    if (o.setItemRaw) await g(o.setItemRaw, s, t, i);
                    else {
                        var a;
                        if (!o.setItem) return;
                        await g(o.setItem, s, "string" == typeof t ? t : m + (a = t, globalThis.Buffer ? f.Buffer.from(a).toString("base64") : globalThis.btoa(String.fromCodePoint(...a))), i)
                    }
                    o.watch || n("update", e)
                },
                async removeItem(e, t = {}) {
                    "boolean" == typeof t && (t = {
                        removeMeta: t
                    });
                    let {
                        relativeKey: i,
                        driver: s
                    } = r(e = b(e));
                    s.removeItem && (await g(s.removeItem, i, t), (t.removeMeta || t.removeMata) && await g(s.removeItem, i + "$", t), s.watch || n("remove", e))
                },
                async getMeta(e, t = {}) {
                    "boolean" == typeof t && (t = {
                        nativeOnly: t
                    });
                    let {
                        relativeKey: i,
                        driver: s
                    } = r(e = b(e)), n = Object.create(null);
                    if (s.getMeta && Object.assign(n, await g(s.getMeta, i, t)), !t.nativeOnly) {
                        let e = await g(s.getItem, i + "$", t).then(e => p(e));
                        e && "object" == typeof e && ("string" == typeof e.atime && (e.atime = new Date(e.atime)), "string" == typeof e.mtime && (e.mtime = new Date(e.mtime)), Object.assign(n, e))
                    }
                    return n
                },
                setMeta(e, t, i = {}) {
                    return this.setItem(e + "$", t, i)
                },
                removeMeta(e, t = {}) {
                    return this.removeItem(e + "$", t)
                },
                async getKeys(e, t = {}) {
                    let i = s(e = w(e), !0),
                        r = [],
                        n = [],
                        o = !0;
                    for (let e of i) {
                        for (let i of (e.driver.flags ? .maxDepth || (o = !1), await g(e.driver.getKeys, e.relativeBase, t))) {
                            let t = e.mountpoint + b(i);
                            r.some(e => t.startsWith(e)) || n.push(t)
                        }
                        r = [e.mountpoint, ...r.filter(t => !t.startsWith(e.mountpoint))]
                    }
                    let a = void 0 !== t.maxDepth && !o;
                    return n.filter(i => {
                        var r;
                        return (!a || function(e, t) {
                            if (void 0 === t) return !0;
                            let i = 0,
                                r = e.indexOf(":");
                            for (; r > -1;) i++, r = e.indexOf(":", r + 1);
                            return i <= t
                        }(i, t.maxDepth)) && ((r = e) ? i.startsWith(r) && "$" !== i[i.length - 1] : "$" !== i[i.length - 1])
                    })
                },
                async clear(e, t = {}) {
                    e = w(e), await Promise.all(s(e, !1).map(async e => e.driver.clear ? g(e.driver.clear, e.relativeBase, t) : e.driver.removeItem ? Promise.all((await e.driver.getKeys(e.relativeBase || "", t)).map(i => e.driver.removeItem(i, t))) : void 0))
                },
                async dispose() {
                    await Promise.all(Object.values(i.mounts).map(e => E(e)))
                },
                watch: async e => (await o(), i.watchListeners.push(e), async () => {
                    i.watchListeners = i.watchListeners.filter(t => t !== e), 0 === i.watchListeners.length && await a()
                }),
                async unwatch() {
                    i.watchListeners = [], await a()
                },
                mount(e, t) {
                    if ((e = w(e)) && i.mounts[e]) throw Error(`already mounted at ${e}`);
                    return e && (i.mountpoints.push(e), i.mountpoints.sort((e, t) => t.length - e.length)), i.mounts[e] = t, i.watching && Promise.resolve(v(t, n, e)).then(t => {
                        i.unwatch[e] = t
                    }).catch(console.error), c
                },
                async unmount(e, t = !0) {
                    (e = w(e)) && i.mounts[e] && (i.watching && e in i.unwatch && (i.unwatch[e] ? .(), delete i.unwatch[e]), t && await E(i.mounts[e]), i.mountpoints = i.mountpoints.filter(t => t !== e), delete i.mounts[e])
                },
                getMount(e = "") {
                    let t = r(e = b(e) + ":");
                    return {
                        driver: t.driver,
                        base: t.base
                    }
                },
                getMounts: (e = "", t = {}) => s(e = b(e), t.parents).map(e => ({
                    driver: e.driver,
                    base: e.mountpoint
                })),
                keys: (e, t = {}) => c.getKeys(e, t),
                get: (e, t = {}) => c.getItem(e, t),
                set: (e, t, i = {}) => c.setItem(e, t, i),
                has: (e, t = {}) => c.hasItem(e, t),
                del: (e, t = {}) => c.removeItem(e, t),
                remove: (e, t = {}) => c.removeItem(e, t)
            };
        return c
    }], 294819), e.s(["clear", 0, function(e = S()) {
        return e("readwrite", e => (e.clear(), x(e.transaction)))
    }, "createStore", 0, I, "del", 0, function(e, t = S()) {
        return t("readwrite", t => (t.delete(e), x(t.transaction)))
    }, "get", 0, function(e, t = S()) {
        return t("readonly", t => x(t.get(e)))
    }, "keys", 0, function(e = S()) {
        return e("readonly", e => {
            var t;
            if (e.getAllKeys) return x(e.getAllKeys());
            let i = [];
            return (t = e => i.push(e.key), e.openCursor().onsuccess = function() {
                this.result && (t(this.result), this.result.continue())
            }, x(e.transaction)).then(() => i)
        })
    }, "set", 0, function(e, t, i = S()) {
        return i("readwrite", i => (i.put(t, e), x(i.transaction)))
    }], 22304)
}, 729864, e => {
    "use strict";
    var t = e.i(294819),
        i = e.i(22304),
        r = e.i(786863);
    class s {
        constructor() {
            this.indexedDb = (0, t.createStorage)({
                driver: ((e = {}) => {
                    let t, r = e.base && e.base.length > 0 ? `${e.base}:` : "";
                    return e.dbName && e.storeName && (t = (0, i.createStore)(e.dbName, e.storeName)), {
                        name: "idb-keyval",
                        options: e,
                        hasItem: async e => !(typeof await (0, i.get)(r + e, t) > "u"),
                        getItem: async e => await (0, i.get)(r + e, t) ? ? null,
                        setItem: (e, s) => (0, i.set)(r + e, s, t),
                        removeItem: e => (0, i.del)(r + e, t),
                        getKeys: () => (0, i.keys)(t),
                        clear: () => (0, i.clear)(t)
                    }
                })({
                    dbName: "WALLET_CONNECT_V2_INDEXED_DB",
                    storeName: "keyvaluestorage"
                })
            })
        }
        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) {
            let t = await this.indexedDb.getItem(e);
            if (null !== t) return t
        }
        async setItem(e, t) {
            await this.indexedDb.setItem(e, (0, r.safeJsonStringify)(t))
        }
        async removeItem(e) {
            await this.indexedDb.removeItem(e)
        }
    }
    var n = "u" > typeof globalThis ? globalThis : "u" > typeof window ? window : e.g,
        o = {
            exports: {}
        };

    function a(e) {
        var t;
        return [e[0], (0, r.safeJsonParse)(null != (t = e[1]) ? t : "")]
    }

    function l() {}
    l.prototype.getItem = function(e) {
        return this.hasOwnProperty(e) ? String(this[e]) : null
    }, l.prototype.setItem = function(e, t) {
        this[e] = String(t)
    }, l.prototype.removeItem = function(e) {
        delete this[e]
    }, l.prototype.clear = function() {
        let e = this;
        Object.keys(e).forEach(function(t) {
            e[t] = void 0, delete e[t]
        })
    }, l.prototype.key = function(e) {
        return e = e || 0, Object.keys(this)[e]
    }, l.prototype.__defineGetter__("length", function() {
        return Object.keys(this).length
    }), "u" > typeof n && n.localStorage ? o.exports = n.localStorage : "u" > typeof window && window.localStorage ? o.exports = window.localStorage : o.exports = new l;
    class c {
        constructor() {
            this.localStorage = o.exports
        }
        async getKeys() {
            return Object.keys(this.localStorage)
        }
        async getEntries() {
            return Object.entries(this.localStorage).map(a)
        }
        async getItem(e) {
            let t = this.localStorage.getItem(e);
            if (null !== t) return (0, r.safeJsonParse)(t)
        }
        async setItem(e, t) {
            this.localStorage.setItem(e, (0, r.safeJsonStringify)(t))
        }
        async removeItem(e) {
            this.localStorage.removeItem(e)
        }
    }
    let h = async (e, t, i) => {
            let r = "wc_storage_version",
                s = await t.getItem(r);
            if (s && s >= 1) return void i(t);
            let n = await e.getKeys();
            if (!n.length) return void i(t);
            let o = [];
            for (; n.length;) {
                let i = n.shift();
                if (!i) continue;
                let r = i.toLowerCase();
                if (r.includes("wc@") || r.includes("walletconnect") || r.includes("wc_") || r.includes("wallet_connect")) {
                    let r = await e.getItem(i);
                    await t.setItem(i, r), o.push(i)
                }
            }
            await t.setItem(r, 1), i(t), u(e, o)
        },
        u = async (e, t) => {
            t.length && t.forEach(async t => {
                await e.removeItem(t)
            })
        };
    e.s(["default", 0, class {
        constructor() {
            this.initialized = !1, this.setInitialized = e => {
                this.storage = e, this.initialized = !0
            };
            const e = new c;
            this.storage = e;
            try {
                const t = new s;
                h(e, t, 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, t) {
            return await this.initialize(), this.storage.setItem(e, t)
        }
        async removeItem(e) {
            return await this.initialize(), this.storage.removeItem(e)
        }
        async initialize() {
            this.initialized || await new Promise(e => {
                let t = setInterval(() => {
                    this.initialized && (clearInterval(t), e())
                }, 20)
            })
        }
    }])
}, 941712, e => {
    "use strict";
    var t = e.i(920020),
        i = e.i(379666);
    class r extends t.IEvents {
        constructor(e) {
            super(), this.opts = e, this.protocol = "wc", this.version = 2
        }
    }
    class s extends t.IEvents {
        constructor(e, t) {
            super(), this.core = e, this.logger = t, this.records = new Map
        }
    }
    class n extends t.IEvents {
        constructor(e, t) {
            super(), this.relayer = e, this.logger = t
        }
    }
    class o extends t.IEvents {
        constructor(e) {
            super()
        }
    }
    class a extends t.IEvents {
        constructor(e, t) {
            super(), this.relayer = e, this.logger = t
        }
    }
    class l extends t.IEvents {
        constructor(e, t) {
            super(), this.core = e, this.logger = t
        }
    }
    i.default, i.EventEmitter, e.s(["ICore", 0, r, "IEchoClient", 0, class {
        constructor(e, t) {
            this.projectId = e, this.logger = t
        }
    }, "IEngine", 0, class {
        constructor(e) {
            this.client = e
        }
    }, "IEventClient", 0, class {
        constructor(e, t, i) {
            this.core = e, this.logger = t, this.telemetryEnabled = i
        }
    }, "IExpirer", 0, l, "IJsonRpcHistory", 0, s, "IMessageTracker", 0, class {
        constructor(e, t) {
            this.logger = e, this.core = t
        }
    }, "IPublisher", 0, n, "IRelayer", 0, o, "ISignClient", 0, class {
        constructor(e) {
            this.opts = e, this.protocol = "wc", this.version = 2
        }
    }, "IStore", 0, class {
        constructor(e, t, i, r) {
            this.core = e, this.logger = t, this.name = i
        }
    }, "ISubscriber", 0, a, "IVerify", 0, class {
        constructor(e, t, i) {
            this.core = e, this.logger = t, this.store = i
        }
    }])
}, 882807, (e, t, i) => {
    "use strict";

    function r() {
        return (null === e.g || void 0 === e.g ? void 0 : e.g.crypto) || (null === e.g || void 0 === e.g ? void 0 : e.g.msCrypto) || {}
    }

    function s() {
        let e = r();
        return e.subtle || e.webkitSubtle
    }
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.isBrowserCryptoAvailable = i.getSubtleCrypto = i.getBrowerCrypto = void 0, i.getBrowerCrypto = r, i.getSubtleCrypto = s, i.isBrowserCryptoAvailable = function() {
        return !!r() && !!s()
    }
}, 375681, (e, t, i) => {
    "use strict";
    var r = e.i(284553);

    function s() {
        return "u" < typeof document && "u" > typeof navigator && "ReactNative" === navigator.product
    }

    function n() {
        return void 0 !== r.default && void 0 !== r.default.versions && void 0 !== r.default.versions.node
    }
    Object.defineProperty(i, "__esModule", {
        value: !0
    }), i.isBrowser = i.isNode = i.isReactNative = void 0, i.isReactNative = s, i.isNode = n, i.isBrowser = function() {
        return !s() && !n()
    }
}, 501900, (e, t, i) => {
    "use strict";
    Object.defineProperty(i, "__esModule", {
        value: !0
    });
    let r = e.r(575824);
    r.__exportStar(e.r(882807), i), r.__exportStar(e.r(375681), i)
}, 395998, (e, t, i) => {
    "use strict";
    t.exports = function() {
        throw Error("ws does not work in the browser. Browser clients must use the native WebSocket object")
    }
}, 540022, (e, t, i) => {
    var r = "u" > typeof globalThis && globalThis || "u" > typeof self && self || e.g,
        s = function() {
            function e() {
                this.fetch = !1, this.DOMException = r.DOMException
            }
            return e.prototype = r, new e
        }();
    (function(t) {
        var i = void 0 !== s && s || "u" > typeof self && self || e.g || {},
            r = {
                searchParams: "URLSearchParams" in i,
                iterable: "Symbol" in i && "iterator" in Symbol,
                blob: "FileReader" in i && "Blob" in i && function() {
                    try {
                        return new Blob, !0
                    } catch (e) {
                        return !1
                    }
                }(),
                formData: "FormData" in i,
                arrayBuffer: "ArrayBuffer" in i
            };
        if (r.arrayBuffer) var n = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"],
            o = ArrayBuffer.isView || function(e) {
                return e && n.indexOf(Object.prototype.toString.call(e)) > -1
            };

        function a(e) {
            if ("string" != typeof e && (e = String(e)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e) || "" === e) throw TypeError('Invalid character in header field name: "' + e + '"');
            return e.toLowerCase()
        }

        function l(e) {
            return "string" != typeof e && (e = String(e)), e
        }

        function c(e) {
            var t = {
                next: function() {
                    var t = e.shift();
                    return {
                        done: void 0 === t,
                        value: t
                    }
                }
            };
            return r.iterable && (t[Symbol.iterator] = function() {
                return t
            }), t
        }

        function h(e) {
            this.map = {}, e instanceof h ? e.forEach(function(e, t) {
                this.append(t, e)
            }, this) : Array.isArray(e) ? e.forEach(function(e) {
                if (2 != e.length) throw TypeError("Headers constructor: expected name/value pair to be length 2, found" + e.length);
                this.append(e[0], e[1])
            }, this) : e && Object.getOwnPropertyNames(e).forEach(function(t) {
                this.append(t, e[t])
            }, this)
        }

        function u(e) {
            if (!e._noBody) {
                if (e.bodyUsed) return Promise.reject(TypeError("Already read"));
                e.bodyUsed = !0
            }
        }

        function d(e) {
            return new Promise(function(t, i) {
                e.onload = function() {
                    t(e.result)
                }, e.onerror = function() {
                    i(e.error)
                }
            })
        }

        function p(e) {
            var t = new FileReader,
                i = d(t);
            return t.readAsArrayBuffer(e), i
        }

        function f(e) {
            if (e.slice) return e.slice(0);
            var t = new Uint8Array(e.byteLength);
            return t.set(new Uint8Array(e)), t.buffer
        }

        function g() {
            return this.bodyUsed = !1, this._initBody = function(e) {
                if (this.bodyUsed = this.bodyUsed, this._bodyInit = e, e)
                    if ("string" == typeof e) this._bodyText = e;
                    else if (r.blob && Blob.prototype.isPrototypeOf(e)) this._bodyBlob = e;
                else if (r.formData && FormData.prototype.isPrototypeOf(e)) this._bodyFormData = e;
                else if (r.searchParams && URLSearchParams.prototype.isPrototypeOf(e)) this._bodyText = e.toString();
                else {
                    var t;
                    r.arrayBuffer && r.blob && (t = e) && DataView.prototype.isPrototypeOf(t) ? (this._bodyArrayBuffer = f(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : r.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || o(e)) ? this._bodyArrayBuffer = f(e) : this._bodyText = e = Object.prototype.toString.call(e)
                } else this._noBody = !0, this._bodyText = "";
                !this.headers.get("content-type") && ("string" == typeof e ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : r.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"))
            }, r.blob && (this.blob = function() {
                var e = u(this);
                if (e) return e;
                if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
                if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
                if (!this._bodyFormData) return Promise.resolve(new Blob([this._bodyText]));
                throw Error("could not read FormData body as blob")
            }), this.arrayBuffer = function() {
                if (this._bodyArrayBuffer) {
                    var e = u(this);
                    return e || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset, this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength)) : Promise.resolve(this._bodyArrayBuffer))
                }
                if (r.blob) return this.blob().then(p);
                throw Error("could not read as ArrayBuffer")
            }, this.text = function() {
                var e, t, i, r, s, n = u(this);
                if (n) return n;
                if (this._bodyBlob) return e = this._bodyBlob, i = d(t = new FileReader), s = (r = /charset=([A-Za-z0-9_-]+)/.exec(e.type)) ? r[1] : "utf-8", t.readAsText(e, s), i;
                if (this._bodyArrayBuffer) return Promise.resolve(function(e) {
                    for (var t = new Uint8Array(e), i = Array(t.length), r = 0; r < t.length; r++) i[r] = String.fromCharCode(t[r]);
                    return i.join("")
                }(this._bodyArrayBuffer));
                if (!this._bodyFormData) return Promise.resolve(this._bodyText);
                throw Error("could not read FormData body as text")
            }, r.formData && (this.formData = function() {
                return this.text().then(b)
            }), this.json = function() {
                return this.text().then(JSON.parse)
            }, this
        }
        h.prototype.append = function(e, t) {
            e = a(e), t = l(t);
            var i = this.map[e];
            this.map[e] = i ? i + ", " + t : t
        }, h.prototype.delete = function(e) {
            delete this.map[a(e)]
        }, h.prototype.get = function(e) {
            return e = a(e), this.has(e) ? this.map[e] : null
        }, h.prototype.has = function(e) {
            return this.map.hasOwnProperty(a(e))
        }, h.prototype.set = function(e, t) {
            this.map[a(e)] = l(t)
        }, h.prototype.forEach = function(e, t) {
            for (var i in this.map) this.map.hasOwnProperty(i) && e.call(t, this.map[i], i, this)
        }, h.prototype.keys = function() {
            var e = [];
            return this.forEach(function(t, i) {
                e.push(i)
            }), c(e)
        }, h.prototype.values = function() {
            var e = [];
            return this.forEach(function(t) {
                e.push(t)
            }), c(e)
        }, h.prototype.entries = function() {
            var e = [];
            return this.forEach(function(t, i) {
                e.push([i, t])
            }), c(e)
        }, r.iterable && (h.prototype[Symbol.iterator] = h.prototype.entries);
        var y = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];

        function m(e, t) {
            if (!(this instanceof m)) throw TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
            var r, s, n = (t = t || {}).body;
            if (e instanceof m) {
                if (e.bodyUsed) throw TypeError("Already read");
                this.url = e.url, this.credentials = e.credentials, t.headers || (this.headers = new h(e.headers)), this.method = e.method, this.mode = e.mode, this.signal = e.signal, n || null == e._bodyInit || (n = e._bodyInit, e.bodyUsed = !0)
            } else this.url = String(e);
            if (this.credentials = t.credentials || this.credentials || "same-origin", (t.headers || !this.headers) && (this.headers = new h(t.headers)), this.method = (s = (r = t.method || this.method || "GET").toUpperCase(), y.indexOf(s) > -1 ? s : r), this.mode = t.mode || this.mode || null, this.signal = t.signal || this.signal || function() {
                    if ("AbortController" in i) return new AbortController().signal
                }(), this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && n) throw TypeError("Body not allowed for GET or HEAD requests");
            if (this._initBody(n), ("GET" === this.method || "HEAD" === this.method) && ("no-store" === t.cache || "no-cache" === t.cache)) {
                var o = /([?&])_=[^&]*/;
                o.test(this.url) ? this.url = this.url.replace(o, "$1_=" + new Date().getTime()) : this.url += (/\?/.test(this.url) ? "&" : "?") + "_=" + new Date().getTime()
            }
        }

        function b(e) {
            var t = new FormData;
            return e.trim().split("&").forEach(function(e) {
                if (e) {
                    var i = e.split("="),
                        r = i.shift().replace(/\+/g, " "),
                        s = i.join("=").replace(/\+/g, " ");
                    t.append(decodeURIComponent(r), decodeURIComponent(s))
                }
            }), t
        }

        function w(e, t) {
            if (!(this instanceof w)) throw TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
            if (t || (t = {}), this.type = "default", this.status = void 0 === t.status ? 200 : t.status, this.status < 200 || this.status > 599) throw RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
            this.ok = this.status >= 200 && this.status < 300, this.statusText = void 0 === t.statusText ? "" : "" + t.statusText, this.headers = new h(t.headers), this.url = t.url || "", this._initBody(e)
        }
        m.prototype.clone = function() {
            return new m(this, {
                body: this._bodyInit
            })
        }, g.call(m.prototype), g.call(w.prototype), w.prototype.clone = function() {
            return new w(this._bodyInit, {
                status: this.status,
                statusText: this.statusText,
                headers: new h(this.headers),
                url: this.url
            })
        }, w.error = function() {
            var e = new w(null, {
                status: 200,
                statusText: ""
            });
            return e.ok = !1, e.status = 0, e.type = "error", e
        };
        var v = [301, 302, 303, 307, 308];
        w.redirect = function(e, t) {
            if (-1 === v.indexOf(t)) throw RangeError("Invalid status code");
            return new w(null, {
                status: t,
                headers: {
                    location: e
                }
            })
        }, t.DOMException = i.DOMException;
        try {
            new t.DOMException
        } catch (e) {
            t.DOMException = function(e, t) {
                this.message = e, this.name = t;
                var i = Error(e);
                this.stack = i.stack
            }, t.DOMException.prototype = Object.create(Error.prototype), t.DOMException.prototype.constructor = t.DOMException
        }

        function E(e, s) {
            return new Promise(function(n, o) {
                var c = new m(e, s);
                if (c.signal && c.signal.aborted) return o(new t.DOMException("Aborted", "AbortError"));
                var u = new XMLHttpRequest;

                function d() {
                    u.abort()
                }
                if (u.onload = function() {
                        var e, t, i = {
                            statusText: u.statusText,
                            headers: (e = u.getAllResponseHeaders() || "", t = new h, e.replace(/\r?\n[\t ]+/g, " ").split("\r").map(function(e) {
                                return 0 === e.indexOf("\n") ? e.substr(1, e.length) : e
                            }).forEach(function(e) {
                                var i = e.split(":"),
                                    r = i.shift().trim();
                                if (r) {
                                    var s = i.join(":").trim();
                                    try {
                                        t.append(r, s)
                                    } catch (e) {
                                        console.warn("Response " + e.message)
                                    }
                                }
                            }), t)
                        };
                        0 === c.url.indexOf("file://") && (u.status < 200 || u.status > 599) ? i.status = 200 : i.status = u.status, i.url = "responseURL" in u ? u.responseURL : i.headers.get("X-Request-URL");
                        var r = "response" in u ? u.response : u.responseText;
                        setTimeout(function() {
                            n(new w(r, i))
                        }, 0)
                    }, u.onerror = function() {
                        setTimeout(function() {
                            o(TypeError("Network request failed"))
                        }, 0)
                    }, u.ontimeout = function() {
                        setTimeout(function() {
                            o(TypeError("Network request timed out"))
                        }, 0)
                    }, u.onabort = function() {
                        setTimeout(function() {
                            o(new t.DOMException("Aborted", "AbortError"))
                        }, 0)
                    }, u.open(c.method, function(e) {
                        try {
                            return "" === e && i.location.href ? i.location.href : e
                        } catch (t) {
                            return e
                        }
                    }(c.url), !0), "include" === c.credentials ? u.withCredentials = !0 : "omit" === c.credentials && (u.withCredentials = !1), "responseType" in u && (r.blob ? u.responseType = "blob" : r.arrayBuffer && (u.responseType = "arraybuffer")), s && "object" == typeof s.headers && !(s.headers instanceof h || i.Headers && s.headers instanceof i.Headers)) {
                    var p = [];
                    Object.getOwnPropertyNames(s.headers).forEach(function(e) {
                        p.push(a(e)), u.setRequestHeader(e, l(s.headers[e]))
                    }), c.headers.forEach(function(e, t) {
                        -1 === p.indexOf(t) && u.setRequestHeader(t, e)
                    })
                } else c.headers.forEach(function(e, t) {
                    u.setRequestHeader(t, e)
                });
                c.signal && (c.signal.addEventListener("abort", d), u.onreadystatechange = function() {
                    4 === u.readyState && c.signal.removeEventListener("abort", d)
                }), u.send(void 0 === c._bodyInit ? null : c._bodyInit)
            })
        }
        E.polyfill = !0, i.fetch || (i.fetch = E, i.Headers = h, i.Request = m, i.Response = w), t.Headers = h, t.Request = m, t.Response = w, t.fetch = E, Object.defineProperty(t, "__esModule", {
            value: !0
        })
    })({}), s.fetch.ponyfill = !0, delete s.fetch.polyfill;
    var n = r.fetch ? r : s;
    (i = n.fetch).default = n.fetch, i.fetch = n.fetch, i.Headers = n.Headers, i.Request = n.Request, i.Response = n.Response, t.exports = i
}, 492005, 578244, 309758, 234939, 764806, 189608, 360028, 168977, 984956, e => {
    "use strict";
    var t = e.i(379666),
        i = e.i(284553),
        r = e.i(383972),
        s = e.i(729864),
        n = e.i(128130),
        o = e.i(941712),
        a = e.i(367069),
        l = e.i(786863),
        c = e.i(355055),
        h = e.i(634417),
        u = e.i(613532);
    e.i(843010);
    var d = e.i(72716),
        p = e.i(501900);
    p.isNode, e.s([], 578244);
    class f {}
    class g extends f {
        constructor() {
            super()
        }
    }
    class y extends g {
        constructor(e) {
            super()
        }
    }
    let m = "INTERNAL_ERROR",
        b = "SERVER_ERROR",
        w = [-32700, -32600, -32601, -32602, -32603],
        v = {
            PARSE_ERROR: {
                code: -32700,
                message: "Parse error"
            },
            INVALID_REQUEST: {
                code: -32600,
                message: "Invalid Request"
            },
            METHOD_NOT_FOUND: {
                code: -32601,
                message: "Method not found"
            },
            INVALID_PARAMS: {
                code: -32602,
                message: "Invalid params"
            },
            [m]: {
                code: -32603,
                message: "Internal error"
            },
            [b]: {
                code: -32e3,
                message: "Server error"
            }
        };

    function E(e) {
        return Object.keys(v).includes(e) ? v[e] : v[b]
    }

    function x(e, t, i) {
        return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? Error(`Unavailable ${i} RPC url at ${t}`) : e
    }

    function I(e = 3) {
        return Date.now() * Math.pow(10, e) + Math.floor(Math.random() * Math.pow(10, e))
    }

    function S(e = 6) {
        return BigInt(I(e))
    }

    function _(e, t, i) {
        return {
            id: i || I(),
            jsonrpc: "2.0",
            method: e,
            params: t
        }
    }

    function P(e, t) {
        return {
            id: e,
            jsonrpc: "2.0",
            result: t
        }
    }

    function T(e, t, i) {
        var r, s, n, o;
        let a;
        return {
            id: e,
            jsonrpc: "2.0",
            error: (r = t, s = i, void 0 === r ? E(m) : ("string" == typeof r && (r = Object.assign(Object.assign({}, E(b)), {
                message: r
            })), void 0 !== s && (r.data = s), n = r.code, w.includes(n) && (o = r.code, r = (a = Object.values(v).find(e => e.code === o)) || v[b]), r))
        }
    }

    function A(e) {
        return "object" == typeof e && "id" in e && "jsonrpc" in e && "2.0" === e.jsonrpc
    }

    function O(e) {
        return A(e) && "method" in e
    }

    function R(e) {
        return A(e) && (N(e) || U(e))
    }

    function N(e) {
        return "result" in e
    }

    function U(e) {
        return "error" in e
    }
    e.s(["formatJsonRpcError", 0, T, "formatJsonRpcRequest", 0, _, "formatJsonRpcResult", 0, P, "getBigIntRpcId", 0, S, "payloadId", 0, I], 309758);
    class C extends y {
        constructor(e) {
            super(e), this.events = new t.EventEmitter, this.hasRegisteredEventListeners = !1, this.connection = this.setConnection(e), this.connection.connected && this.registerEventListeners()
        }
        async connect(e = this.connection) {
            await this.open(e)
        }
        async disconnect() {
            await this.close()
        }
        on(e, t) {
            this.events.on(e, t)
        }
        once(e, t) {
            this.events.once(e, t)
        }
        off(e, t) {
            this.events.off(e, t)
        }
        removeListener(e, t) {
            this.events.removeListener(e, t)
        }
        async request(e, t) {
            return this.requestStrict(_(e.method, e.params || [], e.id || S().toString()), t)
        }
        async requestStrict(e, t) {
            return new Promise(async (i, r) => {
                if (!this.connection.connected) try {
                    await this.open()
                } catch (e) {
                    r(e)
                }
                this.events.on(`${e.id}`, e => {
                    U(e) ? r(e.error) : i(e.result)
                });
                try {
                    await this.connection.send(e, t)
                } catch (e) {
                    r(e)
                }
            })
        }
        setConnection(e = this.connection) {
            return e
        }
        onPayload(e) {
            this.events.emit("payload", e), R(e) ? this.events.emit(`${e.id}`, e) : this.events.emit("message", {
                type: e.method,
                data: e.params
            })
        }
        onClose(e) {
            e && 3e3 === e.code && this.events.emit("error", Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)), this.events.emit("disconnect")
        }
        async open(e = this.connection) {
            this.connection === e && this.connection.connected || (this.connection.connected && this.close(), "string" == typeof e && (await this.connection.open(e), e = this.connection), this.connection = this.setConnection(e), await this.connection.open(), this.registerEventListeners(), this.events.emit("connect"))
        }
        async close() {
            await this.connection.close()
        }
        registerEventListeners() {
            this.hasRegisteredEventListeners || (this.connection.on("payload", e => this.onPayload(e)), this.connection.on("close", e => this.onClose(e)), this.connection.on("error", e => this.events.emit("error", e)), this.connection.on("register_error", e => this.onClose()), this.hasRegisteredEventListeners = !0)
        }
    }

    function k(e, t) {
        let i = function(e) {
            let t = e.match(RegExp(/^\w+:/, "gi"));
            if (t && t.length) return t[0]
        }(e);
        return void 0 !== i && new RegExp(t).test(i)
    }

    function L(e) {
        return k(e, "^https?:")
    }

    function D(e) {
        return k(e, "^wss?:")
    }
    e.s(["JsonRpcProvider", 0, C], 234939);
    let B = e => e.split("?")[0],
        M = "u" > typeof WebSocket ? WebSocket : "u" > typeof e.g.WebSocket ? e.g.WebSocket : "u" > typeof window && "u" > typeof window.WebSocket ? window.WebSocket : "u" > typeof self && "u" > typeof self.WebSocket ? self.WebSocket : e.r(395998);
    class j {
        constructor(e) {
            if (this.url = e, this.events = new t.EventEmitter, this.registering = !1, !D(e)) throw Error(`Provided URL is not compatible with WebSocket connection: ${e}`);
            this.url = e
        }
        get connected() {
            return "u" > typeof this.socket
        }
        get connecting() {
            return this.registering
        }
        on(e, t) {
            this.events.on(e, t)
        }
        once(e, t) {
            this.events.once(e, t)
        }
        off(e, t) {
            this.events.off(e, t)
        }
        removeListener(e, t) {
            this.events.removeListener(e, t)
        }
        async open(e = this.url) {
            await this.register(e)
        }
        async close() {
            return new Promise((e, t) => {
                typeof this.socket > "u" ? t(Error("Connection already closed")) : (this.socket.onclose = t => {
                    this.onClose(t), e()
                }, this.socket.close())
            })
        }
        async send(e) {
            typeof this.socket > "u" && (this.socket = await this.register());
            try {
                this.socket.send((0, l.safeJsonStringify)(e))
            } catch (t) {
                this.onError(e.id, t)
            }
        }
        register(t = this.url) {
            if (!D(t)) throw Error(`Provided URL is not compatible with WebSocket connection: ${t}`);
            if (this.registering) {
                let e = this.events.getMaxListeners();
                return (this.events.listenerCount("register_error") >= e || this.events.listenerCount("open") >= e) && this.events.setMaxListeners(e + 1), new Promise((e, t) => {
                    this.events.once("register_error", e => {
                        this.resetMaxListeners(), t(e)
                    }), this.events.once("open", () => {
                        if (this.resetMaxListeners(), typeof this.socket > "u") return t(Error("WebSocket connection is missing or invalid"));
                        e(this.socket)
                    })
                })
            }
            return this.url = t, this.registering = !0, new Promise((i, r) => {
                let s = (0, p.isReactNative)() ? void 0 : {
                        rejectUnauthorized: !RegExp("wss?://localhost(:d{2,5})?").test(t)
                    },
                    n = new M(t, [], s);
                "u" > typeof WebSocket || "u" > typeof e.g.WebSocket || "u" > typeof window && "u" > typeof window.WebSocket || "u" > typeof self && "u" > typeof self.WebSocket ? n.onerror = e => {
                    r(this.emitError(e.error))
                } : n.on("error", e => {
                    r(this.emitError(e))
                }), n.onopen = () => {
                    this.onOpen(n), i(n)
                }
            })
        }
        onOpen(e) {
            e.onmessage = e => this.onPayload(e), e.onclose = e => this.onClose(e), this.socket = e, this.registering = !1, this.events.emit("open")
        }
        onClose(e) {
            this.socket = void 0, this.registering = !1, this.events.emit("close", e)
        }
        onPayload(e) {
            if (typeof e.data > "u") return;
            let t = "string" == typeof e.data ? (0, l.safeJsonParse)(e.data) : e.data;
            this.events.emit("payload", t)
        }
        onError(e, t) {
            let i = this.parseError(t),
                r = T(e, i.message || i.toString());
            this.events.emit("payload", r)
        }
        parseError(e, t = this.url) {
            return x(e, B(t), "WS")
        }
        resetMaxListeners() {
            this.events.getMaxListeners() > 10 && this.events.setMaxListeners(10)
        }
        emitError(e) {
            let t = this.parseError(Error(e ? .message || `WebSocket connection failed for host: ${B(this.url)}`));
            return this.events.emit("register_error", t), t
        }
    }
    var $ = e.i(93257);

    function q(e) {
        if (!e || "object" != typeof e) return !1;
        let t = Object.getPrototypeOf(e);
        return (null === t || t === Object.prototype || null === Object.getPrototypeOf(t)) && "[object Object]" === Object.prototype.toString.call(e)
    }

    function z(e) {
        return Object.getOwnPropertySymbols(e).filter(t => Object.prototype.propertyIsEnumerable.call(e, t))
    }

    function V(e) {
        return null == e ? void 0 === e ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e)
    }
    e.s(["getSymbols", 0, z], 764806), e.s(["getTag", 0, V], 189608);
    let K = "[object RegExp]",
        F = "[object String]",
        H = "[object Number]",
        W = "[object Boolean]",
        G = "[object Arguments]",
        Y = "[object Symbol]",
        J = "[object Date]",
        Q = "[object Map]",
        Z = "[object Set]",
        X = "[object Array]",
        ee = "[object Function]",
        et = "[object ArrayBuffer]",
        ei = "[object Object]",
        er = "[object Error]",
        es = "[object DataView]",
        en = "[object Uint8Array]",
        eo = "[object Uint8ClampedArray]",
        ea = "[object Uint16Array]",
        el = "[object Uint32Array]",
        ec = "[object BigUint64Array]",
        eh = "[object Int8Array]",
        eu = "[object Int16Array]",
        ed = "[object Int32Array]",
        ep = "[object BigInt64Array]",
        ef = "[object Float32Array]",
        eg = "[object Float64Array]";
    e.s(["argumentsTag", 0, G, "arrayBufferTag", 0, et, "arrayTag", 0, X, "bigInt64ArrayTag", 0, ep, "bigUint64ArrayTag", 0, ec, "booleanTag", 0, W, "dataViewTag", 0, es, "dateTag", 0, J, "errorTag", 0, er, "float32ArrayTag", 0, ef, "float64ArrayTag", 0, eg, "functionTag", 0, ee, "int16ArrayTag", 0, eu, "int32ArrayTag", 0, ed, "int8ArrayTag", 0, eh, "mapTag", 0, Q, "numberTag", 0, H, "objectTag", 0, ei, "regexpTag", 0, K, "setTag", 0, Z, "stringTag", 0, F, "symbolTag", 0, Y, "uint16ArrayTag", 0, ea, "uint32ArrayTag", 0, el, "uint8ArrayTag", 0, en, "uint8ClampedArrayTag", 0, eo], 360028);

    function ey() {}
    e.s(["noop", 0, ey], 168977);
    var em = e.i(896119);
    let eb = "core",
        ew = `wc@2:${eb}:`,
        ev = {
            database: ":memory:"
        },
        eE = "client_ed25519_seed",
        ex = a.ONE_DAY,
        eI = a.SIX_HOURS,
        eS = "wss://relay.walletconnect.org",
        e_ = "relayer_message",
        eP = "relayer_message_ack",
        eT = "relayer_connection_stalled",
        eA = "relayer_publish",
        eO = "payload",
        eR = "connect",
        eN = "disconnect",
        eU = "error",
        eC = "2.23.9",
        ek = "link_mode",
        eL = "relay",
        eD = "inbound",
        eB = "WALLETCONNECT_LINK_MODE_APPS",
        eM = "subscription_created",
        ej = "subscription_deleted",
        e$ = (a.THIRTY_DAYS, a.FIVE_SECONDS, a.THIRTY_DAYS, {
            wc_pairingDelete: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1e3
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1001
                }
            },
            wc_pairingPing: {
                req: {
                    ttl: a.THIRTY_SECONDS,
                    prompt: !1,
                    tag: 1002
                },
                res: {
                    ttl: a.THIRTY_SECONDS,
                    prompt: !1,
                    tag: 1003
                }
            },
            unregistered_method: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 0
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 0
                }
            }
        }),
        eq = "pairing_create",
        ez = "pairing_delete",
        eV = "history_created",
        eK = "history_updated",
        eF = "history_deleted",
        eH = "expirer_created",
        eW = "expirer_deleted",
        eG = "expirer_expired",
        eY = (a.ONE_DAY, "https://verify.walletconnect.org"),
        eJ = `${eY}/v3`,
        eQ = ["https://verify.walletconnect.com", eY],
        eZ = "malformed_pairing_uri",
        eX = "session_approve_started";
    class e0 {
        constructor(e, t) {
            this.core = e, this.logger = t, this.keychain = new Map, this.name = "keychain", this.version = "0.3", this.initialized = !1, this.storagePrefix = ew, this.init = async () => {
                if (!this.initialized) {
                    let e = await this.getKeyChain();
                    "u" > typeof e && (this.keychain = e), this.initialized = !0
                }
            }, this.has = e => (this.isInitialized(), this.keychain.has(e)), this.set = async (e, t) => {
                this.isInitialized(), this.keychain.set(e, t), await this.persist()
            }, this.get = e => {
                this.isInitialized();
                let t = this.keychain.get(e);
                if (typeof t > "u") {
                    let {
                        message: t
                    } = (0, u.getInternalError)("NO_MATCHING_KEY", `${this.name}: ${e}`);
                    throw Error(t)
                }
                return t
            }, this.del = async e => {
                this.isInitialized(), this.keychain.delete(e), await this.persist()
            }, this.core = e, this.logger = (0, n.generateChildLogger)(t, this.name)
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name
        }
        async setKeyChain(e) {
            await this.core.storage.setItem(this.storageKey, (0, u.mapToObj)(e))
        }
        async getKeyChain() {
            let e = await this.core.storage.getItem(this.storageKey);
            return "u" > typeof e ? (0, u.objToMap)(e) : void 0
        }
        async persist() {
            await this.setKeyChain(this.keychain)
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class e1 {
        constructor(e, t, i) {
            this.core = e, this.logger = t, this.name = "crypto", this.randomSessionIdentifier = (0, u.generateRandomBytes32)(), this.initialized = !1, this.init = async () => {
                this.initialized || (await this.keychain.init(), this.initialized = !0)
            }, this.hasKeys = e => (this.isInitialized(), this.keychain.has(e)), this.getClientId = async () => {
                if (this.isInitialized(), this.clientId) return this.clientId;
                let e = await this.getClientSeed(),
                    t = c.generateKeyPair(e),
                    i = c.encodeIss(t.publicKey);
                return this.clientId = i, i
            }, this.generateKeyPair = () => {
                this.isInitialized();
                let e = (0, u.generateKeyPair)();
                return this.setPrivateKey(e.publicKey, e.privateKey)
            }, this.signJWT = async e => {
                this.isInitialized();
                let t = await this.getClientSeed(),
                    i = c.generateKeyPair(t),
                    r = this.randomSessionIdentifier;
                return await c.signJWT(r, e, ex, i)
            }, this.generateSharedKey = (e, t, i) => {
                this.isInitialized();
                let r = this.getPrivateKey(e),
                    s = (0, u.deriveSymKey)(r, t);
                return this.setSymKey(s, i)
            }, this.setSymKey = async (e, t) => {
                this.isInitialized();
                let i = t || (0, u.hashKey)(e);
                return await this.keychain.set(i, e), i
            }, this.deleteKeyPair = async e => {
                this.isInitialized(), await this.keychain.del(e)
            }, this.deleteSymKey = async e => {
                this.isInitialized(), await this.keychain.del(e)
            }, this.encode = async (e, t, i) => {
                this.isInitialized();
                let r = (0, u.validateEncoding)(i),
                    s = (0, l.safeJsonStringify)(t);
                if ((0, u.isTypeTwoEnvelope)(r)) return (0, u.encodeTypeTwoEnvelope)(s, i ? .encoding);
                if ((0, u.isTypeOneEnvelope)(r)) {
                    let t = r.senderPublicKey,
                        i = r.receiverPublicKey;
                    e = await this.generateSharedKey(t, i)
                }
                let n = this.getSymKey(e),
                    {
                        type: o,
                        senderPublicKey: a
                    } = r;
                return (0, u.encrypt)({
                    type: o,
                    symKey: n,
                    message: s,
                    senderPublicKey: a,
                    encoding: i ? .encoding
                })
            }, this.decode = async (e, t, i) => {
                this.isInitialized();
                let r = (0, u.validateDecoding)(t, i);
                if ((0, u.isTypeTwoEnvelope)(r)) {
                    let e = (0, u.decodeTypeTwoEnvelope)(t, i ? .encoding);
                    return (0, l.safeJsonParse)(e)
                }
                if ((0, u.isTypeOneEnvelope)(r)) {
                    let t = r.receiverPublicKey,
                        i = r.senderPublicKey;
                    e = await this.generateSharedKey(t, i)
                }
                try {
                    let r = this.getSymKey(e),
                        s = (0, u.decrypt)({
                            symKey: r,
                            encoded: t,
                            encoding: i ? .encoding
                        });
                    return (0, l.safeJsonParse)(s)
                } catch (t) {
                    this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`), this.logger.error(t)
                }
            }, this.getPayloadType = (e, t = u.BASE64) => {
                let i = (0, u.deserialize)({
                    encoded: e,
                    encoding: t
                });
                return (0, u.decodeTypeByte)(i.type)
            }, this.getPayloadSenderPublicKey = (e, t = u.BASE64) => {
                let i = (0, u.deserialize)({
                    encoded: e,
                    encoding: t
                });
                return i.senderPublicKey ? (0, d.toString)(i.senderPublicKey, u.BASE16) : void 0
            }, this.core = e, this.logger = (0, n.generateChildLogger)(t, this.name), this.keychain = i || new e0(this.core, this.logger)
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        async setPrivateKey(e, t) {
            return await this.keychain.set(e, t), e
        }
        getPrivateKey(e) {
            return this.keychain.get(e)
        }
        async getClientSeed() {
            let e = "";
            try {
                e = this.keychain.get(eE)
            } catch {
                e = (0, u.generateRandomBytes32)(), await this.keychain.set(eE, e)
            }
            return (0, h.fromString)(e, "base16")
        }
        getSymKey(e) {
            return this.keychain.get(e)
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class e2 extends o.IMessageTracker {
        constructor(e, t) {
            super(e, t), this.logger = e, this.core = t, this.messages = new Map, this.messagesWithoutClientAck = new Map, this.name = "messages", this.version = "0.3", this.initialized = !1, this.storagePrefix = ew, this.init = async () => {
                if (!this.initialized) {
                    this.logger.trace("Initialized");
                    try {
                        let e = await this.getRelayerMessages();
                        "u" > typeof e && (this.messages = e);
                        let t = await this.getRelayerMessagesWithoutClientAck();
                        "u" > typeof t && (this.messagesWithoutClientAck = t), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({
                            type: "method",
                            method: "restore",
                            size: this.messages.size
                        })
                    } catch (e) {
                        this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e)
                    } finally {
                        this.initialized = !0
                    }
                }
            }, this.set = async (e, t, i) => {
                this.isInitialized();
                let r = (0, u.hashMessage)(t),
                    s = this.messages.get(e);
                if (typeof s > "u" && (s = {}), "u" > typeof s[r]) return r;
                if (s[r] = t, this.messages.set(e, s), i === eD) {
                    let i = this.messagesWithoutClientAck.get(e) || {};
                    this.messagesWithoutClientAck.set(e, { ...i,
                        [r]: t
                    })
                }
                return await this.persist(), r
            }, this.get = e => {
                this.isInitialized();
                let t = this.messages.get(e);
                return typeof t > "u" && (t = {}), t
            }, this.getWithoutAck = e => {
                this.isInitialized();
                let t = {};
                for (let i of e) {
                    let e = this.messagesWithoutClientAck.get(i) || {};
                    t[i] = Object.values(e)
                }
                return t
            }, this.has = (e, t) => (this.isInitialized(), "u" > typeof this.get(e)[(0, u.hashMessage)(t)]), this.ack = async (e, t) => {
                this.isInitialized();
                let i = this.messagesWithoutClientAck.get(e);
                if (typeof i > "u") return;
                let r = (0, u.hashMessage)(t);
                delete i[r], 0 === Object.keys(i).length ? this.messagesWithoutClientAck.delete(e) : this.messagesWithoutClientAck.set(e, i), await this.persist()
            }, this.del = async e => {
                this.isInitialized(), this.messages.delete(e), this.messagesWithoutClientAck.delete(e), await this.persist()
            }, this.logger = (0, n.generateChildLogger)(e, this.name), this.core = t
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name
        }
        get storageKeyWithoutClientAck() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name + "_withoutClientAck"
        }
        async setRelayerMessages(e) {
            await this.core.storage.setItem(this.storageKey, (0, u.mapToObj)(e))
        }
        async setRelayerMessagesWithoutClientAck(e) {
            await this.core.storage.setItem(this.storageKeyWithoutClientAck, (0, u.mapToObj)(e))
        }
        async getRelayerMessages() {
            let e = await this.core.storage.getItem(this.storageKey);
            return "u" > typeof e ? (0, u.objToMap)(e) : void 0
        }
        async getRelayerMessagesWithoutClientAck() {
            let e = await this.core.storage.getItem(this.storageKeyWithoutClientAck);
            return "u" > typeof e ? (0, u.objToMap)(e) : void 0
        }
        async persist() {
            await this.setRelayerMessages(this.messages), await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class e8 extends o.IPublisher {
        constructor(e, i) {
            super(e, i), this.relayer = e, this.logger = i, this.events = new t.EventEmitter, this.name = "publisher", this.queue = new Map, this.publishTimeout = (0, a.toMiliseconds)(a.ONE_MINUTE), this.initialPublishTimeout = (0, a.toMiliseconds)(15 * a.ONE_SECOND), this.needsTransportRestart = !1, this.publish = async (e, t, i) => {
                this.logger.debug("Publishing Payload"), this.logger.trace({
                    type: "method",
                    method: "publish",
                    params: {
                        topic: e,
                        message: t,
                        opts: i
                    }
                });
                let r = i ? .ttl || eI,
                    s = i ? .prompt || !1,
                    n = i ? .tag || 0,
                    o = i ? .id || S().toString(),
                    a = (0, u.getRelayProtocolApi)((0, u.getRelayProtocolName)().protocol),
                    l = {
                        id: o,
                        method: i ? .publishMethod || a.publish,
                        params: {
                            topic: e,
                            message: t,
                            ttl: r,
                            prompt: s,
                            tag: n,
                            attestation: i ? .attestation,
                            ...i ? .tvf
                        }
                    },
                    c = `Failed to publish payload, please try again. id:${o} tag:${n}`;
                try {
                    (0, u.isUndefined)(l.params ? .prompt) && delete l.params ? .prompt, (0, u.isUndefined)(l.params ? .tag) && delete l.params ? .tag;
                    let r = new Promise(async e => {
                        let t = ({
                            id: i
                        }) => {
                            l.id ? .toString() === i.toString() && (this.removeRequestFromQueue(i), this.relayer.events.removeListener(eA, t), e())
                        };
                        this.relayer.events.on(eA, t);
                        let r = (0, u.createExpiringPromise)(new Promise((e, t) => {
                            this.rpcPublish(l, i).then(e).catch(e => {
                                this.logger.warn(e, e ? .message), t(e)
                            })
                        }), this.initialPublishTimeout, `Failed initial publish, retrying.... id:${o} tag:${n}`);
                        try {
                            await r, this.events.removeListener(eA, t)
                        } catch (e) {
                            this.queue.set(o, {
                                request: l,
                                opts: i,
                                attempt: 1
                            }), this.logger.warn(e, e ? .message)
                        }
                    });
                    this.logger.trace({
                        type: "method",
                        method: "publish",
                        params: {
                            id: o,
                            topic: e,
                            message: t,
                            opts: i
                        }
                    }), await (0, u.createExpiringPromise)(r, this.publishTimeout, c)
                } catch (e) {
                    if (this.logger.debug("Failed to Publish Payload"), this.logger.error(e), i ? .internal ? .throwOnFailedPublish) throw e
                } finally {
                    this.queue.delete(o)
                }
            }, this.publishCustom = async e => {
                this.logger.debug("Publishing custom payload"), this.logger.trace({
                    type: "method",
                    method: "publishCustom",
                    params: e
                });
                let {
                    payload: t,
                    opts: i = {}
                } = e, {
                    attestation: r,
                    tvf: s,
                    publishMethod: n,
                    prompt: o,
                    tag: l,
                    ttl: c = a.FIVE_MINUTES
                } = i, h = i.id || S().toString(), d = (0, u.getRelayProtocolApi)((0, u.getRelayProtocolName)().protocol), p = n || d.publish, f = {
                    id: h,
                    method: p,
                    params: { ...t,
                        ttl: c,
                        prompt: o,
                        tag: l,
                        attestation: r,
                        ...s
                    }
                }, g = `Failed to publish custom payload, please try again. id:${h} tag:${l}`;
                try {
                    (0, u.isUndefined)(f.params ? .prompt) && delete f.params ? .prompt, (0, u.isUndefined)(f.params ? .tag) && delete f.params ? .tag;
                    let e = new Promise(async e => {
                        let t = ({
                            id: i
                        }) => {
                            f.id ? .toString() === i.toString() && (this.removeRequestFromQueue(i), this.relayer.events.removeListener(eA, t), e())
                        };
                        this.relayer.events.on(eA, t);
                        let r = (0, u.createExpiringPromise)(new Promise((e, t) => {
                            this.rpcPublish(f, i).then(e).catch(e => {
                                this.logger.warn(e, e ? .message), t(e)
                            })
                        }), this.initialPublishTimeout, `Failed initial custom payload publish, retrying.... method:${p} id:${h} tag:${l}`);
                        try {
                            await r, this.events.removeListener(eA, t)
                        } catch (e) {
                            this.queue.set(h, {
                                request: f,
                                opts: i,
                                attempt: 1
                            }), this.logger.warn(e, e ? .message)
                        }
                    });
                    this.logger.trace({
                        type: "method",
                        method: "publish",
                        params: {
                            id: h,
                            payload: t,
                            opts: i
                        }
                    }), await (0, u.createExpiringPromise)(e, this.publishTimeout, g)
                } catch (e) {
                    if (this.logger.debug("Failed to Publish Payload"), this.logger.error(e), i ? .internal ? .throwOnFailedPublish) throw e
                } finally {
                    this.queue.delete(h)
                }
            }, this.on = (e, t) => {
                this.events.on(e, t)
            }, this.once = (e, t) => {
                this.events.once(e, t)
            }, this.off = (e, t) => {
                this.events.off(e, t)
            }, this.removeListener = (e, t) => {
                this.events.removeListener(e, t)
            }, this.relayer = e, this.logger = (0, n.generateChildLogger)(i, this.name), this.registerEventListeners()
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        async rpcPublish(e, t) {
            this.logger.debug("Outgoing Relay Payload"), this.logger.trace({
                type: "message",
                direction: "outgoing",
                request: e
            });
            let i = await this.relayer.request(e);
            return this.relayer.events.emit(eA, { ...e,
                ...t
            }), this.logger.debug("Successfully Published Payload"), i
        }
        removeRequestFromQueue(e) {
            this.queue.delete(e)
        }
        checkQueue() {
            this.queue.forEach(async (e, t) => {
                let i = e.attempt + 1;
                this.queue.set(t, { ...e,
                    attempt: i
                }), this.logger.warn({}, `Publisher: queue->publishing: ${e.request.id}, tag: ${e.request.params?.tag}, attempt: ${i}`), await this.rpcPublish(e.request, e.opts), this.logger.warn({}, `Publisher: queue->published: ${e.request.id}`)
            })
        }
        registerEventListeners() {
            this.relayer.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, () => {
                if (this.needsTransportRestart) {
                    this.needsTransportRestart = !1, this.relayer.events.emit(eT);
                    return
                }
                this.checkQueue()
            }), this.relayer.on(eP, e => {
                this.removeRequestFromQueue(e.id.toString())
            })
        }
    }
    class e3 {
        constructor() {
            this.map = new Map, this.set = (e, t) => {
                let i = this.get(e);
                this.exists(e, t) || this.map.set(e, [...i, t])
            }, this.get = e => this.map.get(e) || [], this.exists = (e, t) => this.get(e).includes(t), this.delete = (e, t) => {
                if (typeof t > "u") return void this.map.delete(e);
                if (!this.map.has(e)) return;
                let i = this.get(e);
                if (!this.exists(e, t)) return;
                let r = i.filter(e => e !== t);
                r.length ? this.map.set(e, r) : this.map.delete(e)
            }, this.clear = () => {
                this.map.clear()
            }
        }
        get topics() {
            return Array.from(this.map.keys())
        }
    }
    class e6 extends o.ISubscriber {
        constructor(e, i) {
            super(e, i), this.relayer = e, this.logger = i, this.subscriptions = new Map, this.topicMap = new e3, this.events = new t.EventEmitter, this.name = "subscription", this.version = "0.3", this.pending = new Map, this.cached = [], this.initialized = !1, this.storagePrefix = ew, this.subscribeTimeout = (0, a.toMiliseconds)(a.ONE_MINUTE), this.initialSubscribeTimeout = (0, a.toMiliseconds)(15 * a.ONE_SECOND), this.batchSubscribeTopicsLimit = 500, this.init = async () => {
                this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), await this.restore()), this.initialized = !0
            }, this.subscribe = async (e, t) => {
                this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({
                    type: "method",
                    method: "subscribe",
                    params: {
                        topic: e,
                        opts: t
                    }
                });
                try {
                    let i = (0, u.getRelayProtocolName)(t),
                        r = {
                            topic: e,
                            relay: i,
                            transportType: t ? .transportType
                        };
                    t ? .internal ? .skipSubscribe || this.pending.set(e, r);
                    let s = await this.rpcSubscribe(e, i, t);
                    return "string" == typeof s && (this.onSubscribe(s, r), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({
                        type: "method",
                        method: "subscribe",
                        params: {
                            topic: e,
                            opts: t
                        }
                    })), s
                } catch (e) {
                    throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(e), e
                }
            }, this.unsubscribe = async (e, t) => {
                this.isInitialized(), "u" > typeof t ? .id ? await this.unsubscribeById(e, t.id, t) : await this.unsubscribeByTopic(e, t)
            }, this.isSubscribed = e => new Promise(t => {
                t(this.topicMap.topics.includes(e))
            }), this.isKnownTopic = e => new Promise(t => {
                t(this.topicMap.topics.includes(e) || this.pending.has(e) || this.cached.some(t => t.topic === e))
            }), this.on = (e, t) => {
                this.events.on(e, t)
            }, this.once = (e, t) => {
                this.events.once(e, t)
            }, this.off = (e, t) => {
                this.events.off(e, t)
            }, this.removeListener = (e, t) => {
                this.events.removeListener(e, t)
            }, this.start = async () => {
                await this.onConnect()
            }, this.stop = async () => {
                await this.onDisconnect()
            }, this.restart = async () => {
                await this.restore(), await this.onRestart()
            }, this.checkPending = async () => {
                if (0 === this.pending.size && (!this.initialized || !this.relayer.connected)) return;
                let e = [];
                this.pending.forEach(t => {
                    e.push(t)
                }), await this.batchSubscribe(e)
            }, this.registerEventListeners = () => {
                this.relayer.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, async () => {
                    await this.checkPending()
                }), this.events.on(eM, async e => {
                    this.logger.info(`Emitting ${eM}`), this.logger.debug({
                        type: "event",
                        event: eM,
                        data: e
                    }), await this.persist()
                }), this.events.on(ej, async e => {
                    this.logger.info(`Emitting ${ej}`), this.logger.debug({
                        type: "event",
                        event: ej,
                        data: e
                    }), await this.persist()
                })
            }, this.relayer = e, this.logger = (0, n.generateChildLogger)(i, this.name), this.clientId = ""
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.relayer.core.customStoragePrefix + "//" + this.name
        }
        get length() {
            return this.subscriptions.size
        }
        get ids() {
            return Array.from(this.subscriptions.keys())
        }
        get values() {
            return Array.from(this.subscriptions.values())
        }
        get topics() {
            return this.topicMap.topics
        }
        get hasAnyTopics() {
            return this.topicMap.topics.length > 0 || this.pending.size > 0 || this.cached.length > 0 || this.subscriptions.size > 0
        }
        hasSubscription(e, t) {
            let i = !1;
            try {
                i = this.getSubscription(e).topic === t
            } catch {}
            return i
        }
        reset() {
            this.cached = [], this.initialized = !0
        }
        onDisable() {
            this.values.length > 0 && (this.cached = this.values), this.subscriptions.clear(), this.topicMap.clear()
        }
        async unsubscribeByTopic(e, t) {
            let i = this.topicMap.get(e);
            await Promise.all(i.map(async i => await this.unsubscribeById(e, i, t)))
        }
        async unsubscribeById(e, t, i) {
            this.logger.debug("Unsubscribing Topic"), this.logger.trace({
                type: "method",
                method: "unsubscribe",
                params: {
                    topic: e,
                    id: t,
                    opts: i
                }
            });
            try {
                let r = (0, u.getSdkError)("USER_DISCONNECTED", `${this.name}, ${e}`);
                await this.onUnsubscribe(e, t, r);
                let s = (0, u.getRelayProtocolName)(i);
                await this.restartToComplete({
                    topic: e,
                    id: t,
                    relay: s
                }), await this.rpcUnsubscribe(e, t, s), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({
                    type: "method",
                    method: "unsubscribe",
                    params: {
                        topic: e,
                        id: t,
                        opts: i
                    }
                })
            } catch (e) {
                throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(e), e
            }
        }
        async rpcSubscribe(e, t, i) {
            let r = await this.getSubscriptionId(e);
            if (i ? .internal ? .skipSubscribe) return r;
            i && i ? .transportType !== eL || await this.restartToComplete({
                topic: e,
                id: e,
                relay: t
            });
            let s = {
                method: (0, u.getRelayProtocolApi)(t.protocol).subscribe,
                params: {
                    topic: e
                }
            };
            this.logger.debug("Outgoing Relay Payload"), this.logger.trace({
                type: "payload",
                direction: "outgoing",
                request: s
            });
            let n = i ? .internal ? .throwOnFailedPublish;
            try {
                if (i ? .transportType === ek) return setTimeout(() => {
                    (this.relayer.connected || this.relayer.connecting) && this.relayer.request(s).catch(e => this.logger.warn(e))
                }, (0, a.toMiliseconds)(a.ONE_SECOND)), r;
                let t = new Promise(async t => {
                        let i = r => {
                            r.topic === e && (this.events.removeListener(eM, i), t(r.id))
                        };
                        this.events.on(eM, i);
                        try {
                            let r = await (0, u.createExpiringPromise)(new Promise((e, t) => {
                                this.relayer.request(s).catch(e => {
                                    this.logger.warn(e, e ? .message), t(e)
                                }).then(e)
                            }), this.initialSubscribeTimeout, `Subscribing to ${e} failed, please try again`);
                            this.events.removeListener(eM, i), t(r)
                        } catch {}
                    }),
                    o = await (0, u.createExpiringPromise)(t, this.subscribeTimeout, `Subscribing to ${e} failed, please try again`);
                if (!o && n) throw Error(`Subscribing to ${e} failed, please try again`);
                return o ? r : null
            } catch (e) {
                if (this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(eT), n) throw e
            }
            return null
        }
        async rpcBatchSubscribe(e) {
            if (!e.length) return !0;
            let t = e[0].relay,
                i = {
                    method: (0, u.getRelayProtocolApi)(t.protocol).batchSubscribe,
                    params: {
                        topics: e.map(e => e.topic)
                    }
                };
            this.logger.debug("Outgoing Relay Payload"), this.logger.trace({
                type: "payload",
                direction: "outgoing",
                request: i
            });
            try {
                return await (0, u.createExpiringPromise)(new Promise((e, t) => {
                    this.relayer.request(i).then(e).catch(e => {
                        this.logger.warn(e), t(e)
                    })
                }), this.subscribeTimeout, "rpcBatchSubscribe failed, please try again"), !0
            } catch {
                return this.relayer.events.emit(eT), !1
            }
        }
        async rpcBatchFetchMessages(e) {
            let t;
            if (!e.length) return;
            let i = e[0].relay,
                r = {
                    method: (0, u.getRelayProtocolApi)(i.protocol).batchFetchMessages,
                    params: {
                        topics: e.map(e => e.topic)
                    }
                };
            this.logger.debug("Outgoing Relay Payload"), this.logger.trace({
                type: "payload",
                direction: "outgoing",
                request: r
            });
            try {
                t = await await (0, u.createExpiringPromise)(new Promise((e, t) => {
                    this.relayer.request(r).catch(e => {
                        this.logger.warn(e), t(e)
                    }).then(e)
                }), this.subscribeTimeout, "rpcBatchFetchMessages failed, please try again")
            } catch {
                this.relayer.events.emit(eT)
            }
            return t
        }
        rpcUnsubscribe(e, t, i) {
            let r = {
                method: (0, u.getRelayProtocolApi)(i.protocol).unsubscribe,
                params: {
                    topic: e,
                    id: t
                }
            };
            return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({
                type: "payload",
                direction: "outgoing",
                request: r
            }), this.relayer.request(r)
        }
        onSubscribe(e, t) {
            this.setSubscription(e, { ...t,
                id: e
            }), this.pending.delete(t.topic)
        }
        onBatchSubscribe(e) {
            e.length && e.forEach(e => {
                this.setSubscription(e.id, { ...e
                }), this.pending.delete(e.topic)
            })
        }
        async onUnsubscribe(e, t, i) {
            this.events.removeAllListeners(t), this.hasSubscription(t, e) && this.deleteSubscription(t, i), await this.relayer.messages.del(e)
        }
        async setRelayerSubscriptions(e) {
            await this.relayer.core.storage.setItem(this.storageKey, e)
        }
        async getRelayerSubscriptions() {
            return await this.relayer.core.storage.getItem(this.storageKey)
        }
        setSubscription(e, t) {
            this.logger.debug("Setting subscription"), this.logger.trace({
                type: "method",
                method: "setSubscription",
                id: e,
                subscription: t
            }), this.addSubscription(e, t)
        }
        addSubscription(e, t) {
            this.subscriptions.set(e, { ...t
            }), this.topicMap.set(t.topic, e), this.events.emit(eM, t)
        }
        getSubscription(e) {
            this.logger.debug("Getting subscription"), this.logger.trace({
                type: "method",
                method: "getSubscription",
                id: e
            });
            let t = this.subscriptions.get(e);
            if (!t) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `${this.name}: ${e}`);
                throw Error(t)
            }
            return t
        }
        deleteSubscription(e, t) {
            this.logger.debug("Deleting subscription"), this.logger.trace({
                type: "method",
                method: "deleteSubscription",
                id: e,
                reason: t
            });
            let i = this.getSubscription(e);
            this.subscriptions.delete(e), this.topicMap.delete(i.topic, e), this.events.emit(ej, { ...i,
                reason: t
            })
        }
        async persist() {
            await this.setRelayerSubscriptions(this.values), this.events.emit("subscription_sync")
        }
        async onRestart() {
            if (this.cached.length) {
                let e = [...this.cached],
                    t = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit);
                for (let i = 0; i < t; i++) {
                    let t = e.splice(0, this.batchSubscribeTopicsLimit);
                    await this.batchSubscribe(t)
                }
            }
            this.events.emit("subscription_resubscribed")
        }
        async restore() {
            try {
                let e = await this.getRelayerSubscriptions();
                if (typeof e > "u" || !e.length) return;
                if (this.subscriptions.size && !e.every(e => e.topic === this.subscriptions.get(e.id) ? .topic)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("RESTORE_WILL_OVERRIDE", this.name);
                    throw this.logger.error(e), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), Error(e)
                }
                this.cached = e, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({
                    type: "method",
                    method: "restore",
                    subscriptions: this.values
                })
            } catch (e) {
                this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e)
            }
        }
        async batchSubscribe(e) {
            if (e.length) {
                if (!await this.rpcBatchSubscribe(e)) {
                    this.logger.warn(`Batch subscribe failed for ${e.length} topics, adding to pending for retry`), e.forEach(e => {
                        this.pending.set(e.topic, e)
                    });
                    return
                }
                this.onBatchSubscribe(await Promise.all(e.map(async e => ({ ...e,
                    id: await this.getSubscriptionId(e.topic)
                }))))
            }
        }
        async batchFetchMessages(e) {
            if (!e.length) return;
            this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);
            let t = await this.rpcBatchFetchMessages(e);
            t && t.messages && (await (0, u.sleep)((0, a.toMiliseconds)(a.ONE_SECOND)), await this.relayer.handleBatchMessageEvents(t.messages))
        }
        async onConnect() {
            await this.restart(), this.reset()
        }
        onDisconnect() {
            this.onDisable()
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
        async restartToComplete(e) {
            this.relayer.connected || this.relayer.connecting || (this.cached.push(e), await this.relayer.transportOpen())
        }
        async getClientId() {
            return this.clientId || (this.clientId = await this.relayer.core.crypto.getClientId()), this.clientId
        }
        async getSubscriptionId(e) {
            return (0, u.hashMessage)(e + await this.getClientId())
        }
    }
    class e5 extends o.IRelayer {
        constructor(e) {
            super(e), this.protocol = "wc", this.version = 2, this.events = new t.EventEmitter, this.name = "relayer", this.transportExplicitlyClosed = !1, this.initialized = !1, this.connectionAttemptInProgress = !1, this.hasExperiencedNetworkDisruption = !1, this.heartBeatTimeout = (0, a.toMiliseconds)(a.THIRTY_SECONDS + a.FIVE_SECONDS), this.reconnectInProgress = !1, this.requestsInFlight = [], this.connectTimeout = (0, a.toMiliseconds)(15 * a.ONE_SECOND), this.stalledRestartInProgress = !1, this.stalledRestartBackoff = 0, this.stalledRestartBaseInterval = (0, a.toMiliseconds)(2 * a.ONE_SECOND), this.stalledRestartMaxInterval = (0, a.toMiliseconds)(a.THIRTY_SECONDS), this.request = async e => {
                this.logger.debug("Publishing Request Payload");
                let t = e.id || S().toString();
                await this.toEstablishConnection();
                try {
                    this.logger.trace({
                        id: t,
                        method: e.method,
                        topic: e.params ? .topic
                    }, "relayer.request - publishing...");
                    let i = `${t}:${e.params?.tag||""}`;
                    this.requestsInFlight.push(i);
                    let r = await this.provider.request(e);
                    return this.requestsInFlight = this.requestsInFlight.filter(e => e !== i), r
                } catch (e) {
                    throw this.logger.debug(`Failed to Publish Request: ${t}`), e
                }
            }, this.resetPingTimeout = () => {
                (0, u.isNode)() && (clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => {
                    try {
                        this.logger.debug({}, "pingTimeout: Connection stalled, terminating..."), this.provider ? .connection ? .socket ? .terminate ? .()
                    } catch (e) {
                        this.logger.warn(e, e ? .message)
                    }
                }, this.heartBeatTimeout))
            }, this.onPayloadHandler = e => {
                this.onProviderPayload(e), this.resetPingTimeout()
            }, this.onConnectHandler = () => {
                this.logger.warn({}, "Relayer connected 🛜"), this.startPingTimeout(), this.stalledRestartBackoff = 0, this.events.emit("relayer_connect")
            }, this.onDisconnectHandler = () => {
                this.logger.warn({}, "Relayer disconnected 🛑"), this.requestsInFlight = [], this.onProviderDisconnect()
            }, this.onProviderErrorHandler = e => {
                this.logger.fatal(`Fatal socket error: ${e.message}`), this.events.emit("relayer_error", e), this.logger.fatal("Fatal socket error received, closing transport"), this.transportExplicitlyClosed = !0, clearTimeout(this.reconnectTimeout), this.reconnectTimeout = void 0, this.reconnectInProgress = !1, this.transportClose().catch(e => this.logger.warn(e))
            }, this.registerProviderListeners = () => {
                this.provider.on(eO, this.onPayloadHandler), this.provider.on(eR, this.onConnectHandler), this.provider.on(eN, this.onDisconnectHandler), this.provider.on(eU, this.onProviderErrorHandler)
            }, this.core = e.core, this.logger = (0, u.createLogger)({
                logger: e.logger ? ? "error",
                name: this.name
            }), this.messages = new e2(this.logger, e.core), this.subscriber = new e6(this, this.logger), this.publisher = new e8(this, this.logger), this.projectId = e.projectId, this.relayUrl = e.relayUrl || eS, (0, u.isAndroid)() ? this.packageName = (0, u.getAppId)() : (0, u.isIos)() && (this.bundleId = (0, u.getAppId)()), this.provider = {}
        }
        async init() {
            this.logger.trace("Initialized"), this.registerEventListeners(), await Promise.all([this.messages.init(), this.subscriber.init()]), this.initialized = !0, this.transportOpen().catch(e => this.logger.warn(e, e ? .message))
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get connected() {
            return this.provider ? .connection ? .socket ? .readyState === 1
        }
        get connecting() {
            return this.provider ? .connection ? .socket ? .readyState === 0 || void 0 !== this.connectPromise
        }
        async publish(e, t, i) {
            this.isInitialized(), await this.publisher.publish(e, t, i), await this.recordMessageEvent({
                topic: e,
                message: t,
                publishedAt: Date.now(),
                transportType: eL
            }, "outbound")
        }
        async publishCustom(e) {
            this.isInitialized(), await this.publisher.publishCustom(e)
        }
        async subscribe(e, t) {
            this.isInitialized(), t ? .transportType && t ? .transportType !== "relay" || await this.toEstablishConnection();
            let i = t ? .internal ? .throwOnFailedPublish ? ? !0,
                r = this.subscriber.topicMap.get(e) ? .[0] || "",
                s, n = t => {
                    t.topic === e && (this.subscriber.off(eM, n), s())
                };
            return await Promise.all([new Promise(e => {
                s = e, this.subscriber.on(eM, n)
            }), new Promise((s, n) => {
                this.subscriber.subscribe(e, {
                    internal: {
                        throwOnFailedPublish: i
                    },
                    ...t
                }).then(e => {
                    r = e || r, s()
                }).catch(e => {
                    i ? n(e) : s()
                })
            })]), r
        }
        async unsubscribe(e, t) {
            this.isInitialized(), await this.subscriber.unsubscribe(e, t)
        }
        on(e, t) {
            this.events.on(e, t)
        }
        once(e, t) {
            this.events.once(e, t)
        }
        off(e, t) {
            this.events.off(e, t)
        }
        removeListener(e, t) {
            this.events.removeListener(e, t)
        }
        async transportDisconnect() {
            this.provider.disconnect && (this.hasExperiencedNetworkDisruption || this.connected) ? await (0, u.createExpiringPromise)(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect()
        }
        async transportClose() {
            this.transportExplicitlyClosed = !0, clearTimeout(this.stalledRestartTimeout), this.stalledRestartInProgress = !1, this.stalledRestartBackoff = 0, await this.resetTransport()
        }
        async transportOpen(e) {
            if (!this.subscriber.hasAnyTopics) return void this.logger.info("Starting WS connection skipped because the client has no topics to work with.");
            if (this.connectPromise ? (this.logger.debug({}, "Waiting for existing connection attempt to resolve..."), await this.connectPromise, this.logger.debug({}, "Existing connection attempt resolved")) : (this.connectPromise = this.connect(e).finally(() => {
                    this.connectPromise = void 0
                }), await this.connectPromise), !this.connected) throw Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)
        }
        async restartTransport(e) {
            this.logger.debug({}, "Restarting transport..."), this.connectionAttemptInProgress || (this.relayUrl = e || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.resetTransport(), await this.transportOpen())
        }
        async resetTransport() {
            this.reconnectInProgress = !0, clearTimeout(this.reconnectTimeout), this.reconnectTimeout = void 0, await this.transportDisconnect(), await this.subscriber.stop(), this.reconnectInProgress = !1
        }
        async confirmOnlineStateOrThrow() {
            if (!await (0, u.isOnline)()) throw Error("No internet connection detected. Please restart your network and try again.")
        }
        async handleBatchMessageEvents(e) {
            if (e ? .length === 0) return void this.logger.trace("Batch message events is empty. Ignoring...");
            let t = e.sort((e, t) => e.publishedAt - t.publishedAt);
            for (let e of (this.logger.debug(`Batch of ${t.length} message events sorted`), t)) try {
                await this.onMessageEvent(e)
            } catch (e) {
                this.logger.warn(e, "Error while processing batch message event: " + e ? .message)
            }
            this.logger.trace(`Batch of ${t.length} message events processed`)
        }
        async onLinkMessageEvent(e, t) {
            let {
                topic: i
            } = e;
            if (!t.sessionExists) {
                let e = (0, u.calcExpiry)(a.FIVE_MINUTES);
                await this.core.pairing.pairings.set(i, {
                    topic: i,
                    expiry: e,
                    relay: {
                        protocol: "irn"
                    },
                    active: !1
                })
            }
            this.events.emit(e_, e), await this.recordMessageEvent(e, eD)
        }
        async connect(e) {
            await this.confirmOnlineStateOrThrow(), e && e !== this.relayUrl && (this.relayUrl = e, await this.transportDisconnect()), this.transportExplicitlyClosed = !1;
            let t = 1;
            try {
                for (; t < 6;) {
                    this.connectionAttemptInProgress = !0;
                    try {
                        if (this.transportExplicitlyClosed) break;
                        this.logger.debug({}, `Connecting to ${this.relayUrl}, attempt: ${t}...`), await this.createProvider(), await new Promise((e, t) => {
                            let i = () => {
                                t(Error("Connection interrupted while trying to connect"))
                            };
                            this.provider.once(eN, i), (0, u.createExpiringPromise)(this.provider.connect(), this.connectTimeout, `Socket stalled when trying to connect to ${this.relayUrl}`).then(() => e()).catch(t).finally(() => {
                                this.provider.off(eN, i), clearTimeout(this.reconnectTimeout)
                            })
                        }), await new Promise((e, t) => {
                            let i = () => {
                                t(Error("Connection interrupted while trying to subscribe"))
                            };
                            this.provider.once(eN, i), this.subscriber.start().then(e).catch(t).finally(() => {
                                this.provider.off(eN, i)
                            })
                        }), this.hasExperiencedNetworkDisruption = !1
                    } catch (e) {
                        await this.subscriber.stop(), this.logger.warn({}, e.message), this.hasExperiencedNetworkDisruption = !0
                    }
                    if (this.connected) {
                        this.logger.debug({}, `Connected to ${this.relayUrl} successfully on attempt: ${t}`);
                        break
                    }
                    await new Promise(e => setTimeout(e, (0, a.toMiliseconds)(+t))), t++
                }
            } finally {
                this.connectionAttemptInProgress = !1, clearTimeout(this.reconnectTimeout), this.reconnectTimeout = void 0, this.reconnectInProgress = !1
            }
        }
        startPingTimeout() {
            if ((0, u.isNode)()) try {
                this.provider ? .connection ? .socket ? .on("ping", () => {
                    this.resetPingTimeout()
                }), this.resetPingTimeout()
            } catch (e) {
                this.logger.warn(e, e ? .message)
            }
        }
        async createProvider() {
            if (this.provider.connection && (this.unregisterProviderListeners(), this.connected)) try {
                await (0, u.createExpiringPromise)(this.provider.disconnect(), 1e3, "Closing previous provider")
            } catch {}
            let e = await this.core.crypto.signJWT(this.relayUrl);
            this.provider = new C(new j((0, u.formatRelayRpcUrl)({
                sdkVersion: eC,
                protocol: this.protocol,
                version: this.version,
                relayUrl: this.relayUrl,
                projectId: this.projectId,
                auth: e,
                useOnCloseEvent: !0,
                bundleId: this.bundleId,
                packageName: this.packageName
            }))), this.registerProviderListeners()
        }
        async recordMessageEvent(e, t) {
            let {
                topic: i,
                message: r
            } = e;
            await this.messages.set(i, r, t)
        }
        async shouldIgnoreMessageEvent(e) {
            let {
                topic: t,
                message: i
            } = e;
            if (!i || 0 === i.length) return this.logger.warn(`Ignoring invalid/empty message: ${i}`), !0;
            if (!await this.subscriber.isKnownTopic(t)) return this.logger.warn(`Ignoring message for unknown topic ${t}`), !0;
            let r = this.messages.has(t, i);
            return r && this.logger.warn(`Ignoring duplicate message: ${i}`), r
        }
        async onProviderPayload(e) {
            if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({
                    type: "payload",
                    direction: "incoming",
                    payload: e
                }), O(e)) {
                if (!e.method.endsWith("_subscription")) return;
                let t = e.params,
                    {
                        topic: i,
                        message: r,
                        publishedAt: s,
                        attestation: n
                    } = t.data,
                    o = {
                        topic: i,
                        message: r,
                        publishedAt: s,
                        transportType: eL,
                        attestation: n
                    };
                this.logger.debug("Emitting Relayer Payload"), this.logger.trace({
                    type: "event",
                    event: t.id,
                    ...o
                }), this.events.emit(t.id, o), await this.acknowledgePayload(e), await this.onMessageEvent(o)
            } else R(e) && this.events.emit(eP, e)
        }
        async onMessageEvent(e) {
            await this.shouldIgnoreMessageEvent(e) || (await this.recordMessageEvent(e, eD), this.events.emit(e_, e))
        }
        async acknowledgePayload(e) {
            let t = P(e.id, !0);
            await this.provider.connection.send(t)
        }
        unregisterProviderListeners() {
            this.provider.off(eO, this.onPayloadHandler), this.provider.off(eR, this.onConnectHandler), this.provider.off(eN, this.onDisconnectHandler), this.provider.off(eU, this.onProviderErrorHandler), clearTimeout(this.pingTimeout)
        }
        async registerEventListeners() {
            let e = await (0, u.isOnline)();
            (0, u.subscribeToNetworkChange)(async t => {
                e !== t && (e = t, t ? await this.transportOpen().catch(e => this.logger.error(e, e ? .message)) : (this.hasExperiencedNetworkDisruption = !0, await this.transportDisconnect(), this.transportExplicitlyClosed = !1))
            }), this.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, async () => {
                if (!this.transportExplicitlyClosed && !this.connected && (0, u.isAppVisible)()) try {
                    await this.confirmOnlineStateOrThrow(), await this.transportOpen()
                } catch (e) {
                    this.logger.warn(e, e ? .message)
                }
            }), this.events.on(eT, () => {
                if (this.transportExplicitlyClosed || this.stalledRestartInProgress) return;
                this.stalledRestartInProgress = !0;
                let e = 0 === this.stalledRestartBackoff ? 0 : Math.min(Math.pow(2, this.stalledRestartBackoff - 1) * this.stalledRestartBaseInterval, this.stalledRestartMaxInterval);
                this.stalledRestartBackoff++, this.logger.warn(`Connection stalled, restarting transport${e?` in ${e}ms`:""}...`), this.stalledRestartTimeout = setTimeout(async () => {
                    try {
                        if (this.transportExplicitlyClosed) return;
                        await this.restartTransport()
                    } catch (e) {
                        this.logger.error(e, e ? .message)
                    } finally {
                        this.stalledRestartInProgress = !1
                    }
                }, e)
            })
        }
        async onProviderDisconnect() {
            if (clearTimeout(this.pingTimeout), this.events.emit("relayer_disconnect"), !this.reconnectInProgress) {
                this.reconnectInProgress = !0;
                try {
                    await this.subscriber.stop()
                } catch (e) {
                    this.logger.warn(e, "subscriber.stop() failed during disconnect")
                }
                if (!this.subscriber.hasAnyTopics || this.transportExplicitlyClosed) {
                    this.reconnectInProgress = !1;
                    return
                }
                this.reconnectTimeout = setTimeout(async () => {
                    await this.transportOpen().catch(e => this.logger.error(e, e ? .message)), this.reconnectTimeout = void 0, this.reconnectInProgress = !1
                }, (0, a.toMiliseconds)(.1))
            }
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
        async toEstablishConnection() {
            if (await this.confirmOnlineStateOrThrow(), !this.connected) {
                if (this.connectPromise) return void await this.connectPromise;
                this.connectPromise = this.connect().finally(() => {
                    this.connectPromise = void 0
                }), await this.connectPromise
            }
        }
    }
    class e4 extends o.IStore {
        constructor(e, t, i, r = ew, s) {
            super(e, t, i, r), this.core = e, this.logger = t, this.name = i, this.map = new Map, this.version = "0.3", this.cached = [], this.initialized = !1, this.storagePrefix = ew, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => {
                this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach(e => {
                    this.getKey && null !== e && !(0, u.isUndefined)(e) ? this.map.set(this.getKey(e), e) : (0, u.isProposalStruct)(e) ? this.map.set(e.id, e) : (0, u.isSessionStruct)(e) && this.map.set(e.topic, e)
                }), this.cached = [], this.initialized = !0)
            }, this.set = async (e, t) => {
                this.isInitialized(), this.map.has(e) ? await this.update(e, t) : (this.logger.debug("Setting value"), this.logger.trace({
                    type: "method",
                    method: "set",
                    key: e,
                    value: t
                }), this.map.set(e, t), await this.persist())
            }, this.get = e => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({
                type: "method",
                method: "get",
                key: e
            }), this.getData(e)), this.getAll = e => (this.isInitialized(), e ? this.values.filter(t => Object.keys(e).every(i => {
                var r;
                return r = t[i],
                    function e(t, i, r, s, n, o, a) {
                        let l = a(t, i, r, s, n, o);
                        if (void 0 !== l) return l;
                        if (typeof t == typeof i) switch (typeof t) {
                            case "bigint":
                            case "string":
                            case "boolean":
                            case "symbol":
                            case "undefined":
                            case "function":
                                return t === i;
                            case "number":
                                return t === i || Object.is(t, i)
                        }
                        return function t(i, r, s, n) {
                            if (Object.is(i, r)) return !0;
                            let o = V(i),
                                a = V(r);
                            if (o === G && (o = ei), a === G && (a = ei), o !== a) return !1;
                            switch (o) {
                                case F:
                                    return i.toString() === r.toString();
                                case H:
                                    {
                                        let e = i.valueOf(),
                                            t = r.valueOf();
                                        return e === t || Number.isNaN(e) && Number.isNaN(t)
                                    }
                                case W:
                                case J:
                                case Y:
                                    return Object.is(i.valueOf(), r.valueOf());
                                case K:
                                    return i.source === r.source && i.flags === r.flags;
                                case ee:
                                    return i === r
                            }
                            let l = (s = s ? ? new Map).get(i),
                                c = s.get(r);
                            if (null != l && null != c) return l === r;
                            s.set(i, r), s.set(r, i);
                            try {
                                switch (o) {
                                    case Q:
                                        if (i.size !== r.size) return !1;
                                        for (let [t, o] of i.entries())
                                            if (!r.has(t) || !e(o, r.get(t), t, i, r, s, n)) return !1;
                                        return !0;
                                    case Z:
                                        {
                                            if (i.size !== r.size) return !1;
                                            let t = Array.from(i.values()),
                                                o = Array.from(r.values());
                                            for (let a = 0; a < t.length; a++) {
                                                let l = t[a],
                                                    c = o.findIndex(t => e(l, t, void 0, i, r, s, n));
                                                if (-1 === c) return !1;
                                                o.splice(c, 1)
                                            }
                                            return !0
                                        }
                                    case X:
                                    case en:
                                    case eo:
                                    case ea:
                                    case el:
                                    case ec:
                                    case eh:
                                    case eu:
                                    case ed:
                                    case ep:
                                    case ef:
                                    case eg:
                                        if (void 0 !== $.Buffer && $.Buffer.isBuffer(i) !== $.Buffer.isBuffer(r) || i.length !== r.length) return !1;
                                        for (let t = 0; t < i.length; t++)
                                            if (!e(i[t], r[t], t, i, r, s, n)) return !1;
                                        return !0;
                                    case et:
                                        if (i.byteLength !== r.byteLength) return !1;
                                        return t(new Uint8Array(i), new Uint8Array(r), s, n);
                                    case es:
                                        if (i.byteLength !== r.byteLength || i.byteOffset !== r.byteOffset) return !1;
                                        return t(new Uint8Array(i), new Uint8Array(r), s, n);
                                    case er:
                                        return i.name === r.name && i.message === r.message;
                                    case ei:
                                        {
                                            if (!(t(i.constructor, r.constructor, s, n) || q(i) && q(r))) return !1;
                                            let o = [...Object.keys(i), ...z(i)],
                                                a = [...Object.keys(r), ...z(r)];
                                            if (o.length !== a.length) return !1;
                                            for (let t = 0; t < o.length; t++) {
                                                let a = o[t],
                                                    l = i[a];
                                                if (!Object.hasOwn(r, a)) return !1;
                                                let c = r[a];
                                                if (!e(l, c, a, i, r, s, n)) return !1
                                            }
                                            return !0
                                        }
                                    default:
                                        return !1
                                }
                            } finally {
                                s.delete(i), s.delete(r)
                            }
                        }(t, i, o, a)
                    }(r, e[i], void 0, void 0, void 0, void 0, ey)
            })) : this.values), this.update = async (e, t) => {
                this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({
                    type: "method",
                    method: "update",
                    key: e,
                    update: t
                });
                let i = { ...this.getData(e),
                    ...t
                };
                this.map.set(e, i), await this.persist()
            }, this.delete = async (e, t) => {
                this.isInitialized(), this.map.has(e) && (this.logger.debug("Deleting value"), this.logger.trace({
                    type: "method",
                    method: "delete",
                    key: e,
                    reason: t
                }), this.map.delete(e), this.addToRecentlyDeleted(e), await this.persist())
            }, this.logger = (0, n.generateChildLogger)(t, this.name), this.storagePrefix = r, this.getKey = s
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name
        }
        get length() {
            return this.map.size
        }
        get keys() {
            return Array.from(this.map.keys())
        }
        get values() {
            return Array.from(this.map.values())
        }
        addToRecentlyDeleted(e) {
            this.recentlyDeleted.push(e), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2)
        }
        async setDataStore(e) {
            await this.core.storage.setItem(this.storageKey, e)
        }
        async getDataStore() {
            return await this.core.storage.getItem(this.storageKey)
        }
        getData(e) {
            let t = this.map.get(e);
            if (!t) {
                if (this.recentlyDeleted.includes(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e}`);
                    throw this.logger.error(t), Error(t)
                }
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `${this.name}: ${e}`);
                throw this.logger.error(t), Error(t)
            }
            return t
        }
        async persist() {
            await this.setDataStore(this.values)
        }
        async restore() {
            try {
                let e = await this.getDataStore();
                if (typeof e > "u" || !e.length) return;
                if (this.map.size) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("RESTORE_WILL_OVERRIDE", this.name);
                    throw this.logger.error(e), Error(e)
                }
                this.cached = e, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({
                    type: "method",
                    method: "restore",
                    value: this.values
                })
            } catch (e) {
                this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e)
            }
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class e9 {
        constructor(e, i) {
            this.core = e, this.logger = i, this.name = "pairing", this.version = "0.3", this.events = new t.default, this.initialized = !1, this.storagePrefix = ew, this.ignoredPayloadTypes = [u.TYPE_1], this.registeredMethods = [], this.init = async () => {
                this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = !0, this.logger.trace("Initialized"))
            }, this.register = ({
                methods: e
            }) => {
                this.isInitialized(), this.registeredMethods = [...new Set([...this.registeredMethods, ...e])]
            }, this.create = async e => {
                this.isInitialized();
                let t = (0, u.generateRandomBytes32)(),
                    i = await this.core.crypto.setSymKey(t),
                    r = (0, u.calcExpiry)(a.FIVE_MINUTES),
                    s = {
                        protocol: "irn"
                    },
                    n = {
                        topic: i,
                        expiry: r,
                        relay: s,
                        active: !1,
                        methods: e ? .methods
                    },
                    o = (0, u.formatUri)({
                        protocol: this.core.protocol,
                        version: this.core.version,
                        topic: i,
                        symKey: t,
                        relay: s,
                        expiryTimestamp: r,
                        methods: e ? .methods
                    });
                return this.events.emit(eq, n), this.core.expirer.set(i, r), await this.pairings.set(i, n), await this.core.relayer.subscribe(i, {
                    transportType: e ? .transportType,
                    internal: e ? .internal
                }), {
                    topic: i,
                    uri: o
                }
            }, this.pair = async e => {
                let t;
                this.isInitialized();
                let i = this.core.eventClient.createEvent({
                    properties: {
                        topic: e ? .uri,
                        trace: ["pairing_started"]
                    }
                });
                this.isValidPair(e, i);
                let {
                    topic: r,
                    symKey: s,
                    relay: n,
                    expiryTimestamp: o,
                    methods: l
                } = (0, u.parseUri)(e.uri);
                if (i.props.properties.topic = r, i.addTrace("pairing_uri_validation_success"), i.addTrace("pairing_uri_not_expired"), this.pairings.keys.includes(r)) {
                    if (t = this.pairings.get(r), i.addTrace("existing_pairing"), t.active) throw i.setError("active_pairing_already_exists"), Error(`Pairing already exists: ${r}. Please try again with a new connection URI.`);
                    i.addTrace("pairing_not_expired")
                }
                let c = o || (0, u.calcExpiry)(a.FIVE_MINUTES),
                    h = {
                        topic: r,
                        relay: n,
                        expiry: c,
                        active: !1,
                        methods: l
                    };
                this.core.expirer.set(r, c), await this.pairings.set(r, h), i.addTrace("store_new_pairing"), e.activatePairing && await this.activate({
                    topic: r
                }), this.events.emit(eq, h), i.addTrace("emit_inactive_pairing"), this.core.crypto.keychain.has(r) || await this.core.crypto.setSymKey(s, r), i.addTrace("subscribing_pairing_topic");
                try {
                    await this.core.relayer.confirmOnlineStateOrThrow()
                } catch {
                    i.setError("no_internet_connection")
                }
                try {
                    await this.core.relayer.subscribe(r, {
                        relay: n
                    })
                } catch (e) {
                    throw i.setError("subscribe_pairing_topic_failure"), e
                }
                return i.addTrace("subscribe_pairing_topic_success"), h
            }, this.activate = async ({
                topic: e
            }) => {
                this.isInitialized();
                let t = (0, u.calcExpiry)(a.FIVE_MINUTES);
                this.core.expirer.set(e, t), await this.pairings.update(e, {
                    active: !0,
                    expiry: t
                })
            }, this.ping = async e => {
                this.isInitialized(), await this.isValidPing(e), this.logger.warn("ping() is deprecated and will be removed in the next major release.");
                let {
                    topic: t
                } = e;
                if (this.pairings.keys.includes(t)) {
                    let e = await this.sendRequest(t, "wc_pairingPing", {}),
                        {
                            done: i,
                            resolve: r,
                            reject: s
                        } = (0, u.createDelayedPromise)();
                    this.events.once((0, u.engineEvent)("pairing_ping", e), ({
                        error: e
                    }) => {
                        e ? s(e) : r()
                    }), await i()
                }
            }, this.updateExpiry = async ({
                topic: e,
                expiry: t
            }) => {
                this.isInitialized(), await this.pairings.update(e, {
                    expiry: t
                })
            }, this.updateMetadata = async ({
                topic: e,
                metadata: t
            }) => {
                this.isInitialized(), await this.pairings.update(e, {
                    peerMetadata: t
                })
            }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async e => {
                this.isInitialized(), await this.isValidDisconnect(e);
                let {
                    topic: t
                } = e;
                this.pairings.keys.includes(t) && (await this.sendRequest(t, "wc_pairingDelete", (0, u.getSdkError)("USER_DISCONNECTED")), await this.deletePairing(t))
            }, this.formatUriFromPairing = e => {
                this.isInitialized();
                let {
                    topic: t,
                    relay: i,
                    expiry: r,
                    methods: s
                } = e, n = this.core.crypto.keychain.get(t);
                return (0, u.formatUri)({
                    protocol: this.core.protocol,
                    version: this.core.version,
                    topic: t,
                    symKey: n,
                    relay: i,
                    expiryTimestamp: r,
                    methods: s
                })
            }, this.sendRequest = async (e, t, i) => {
                let r = _(t, i),
                    s = await this.core.crypto.encode(e, r),
                    n = e$[t].req;
                return this.core.history.set(e, r), this.core.relayer.publish(e, s, n), r.id
            }, this.sendResult = async (e, t, i) => {
                let r = P(e, i),
                    s = await this.core.crypto.encode(t, r),
                    n = e$[(await this.core.history.get(t, e)).request.method].res;
                await this.core.relayer.publish(t, s, n), await this.core.history.resolve(r)
            }, this.sendError = async (e, t, i) => {
                let r = T(e, i),
                    s = await this.core.crypto.encode(t, r),
                    n = (await this.core.history.get(t, e)).request.method,
                    o = e$[n] ? e$[n].res : e$.unregistered_method.res;
                await this.core.relayer.publish(t, s, o), await this.core.history.resolve(r)
            }, this.deletePairing = async (e, t) => {
                await this.core.relayer.unsubscribe(e), await Promise.all([this.pairings.delete(e, (0, u.getSdkError)("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(e), t ? Promise.resolve() : this.core.expirer.del(e)])
            }, this.cleanup = async () => {
                let e = this.pairings.getAll().filter(e => (0, u.isExpired)(e.expiry));
                await Promise.all(e.map(e => this.deletePairing(e.topic)))
            }, this.onRelayEventRequest = async e => {
                let {
                    topic: t,
                    payload: i
                } = e;
                switch (i.method) {
                    case "wc_pairingPing":
                        return await this.onPairingPingRequest(t, i);
                    case "wc_pairingDelete":
                        return await this.onPairingDeleteRequest(t, i);
                    default:
                        return await this.onUnknownRpcMethodRequest(t, i)
                }
            }, this.onRelayEventResponse = async e => {
                let {
                    topic: t,
                    payload: i
                } = e, r = (await this.core.history.get(t, i.id)).request.method;
                return "wc_pairingPing" === r ? this.onPairingPingResponse(t, i) : this.onUnknownRpcMethodResponse(r)
            }, this.onPairingPingRequest = async (e, t) => {
                let {
                    id: i
                } = t;
                try {
                    this.isValidPing({
                        topic: e
                    }), await this.sendResult(i, e, !0), this.events.emit("pairing_ping", {
                        id: i,
                        topic: e
                    })
                } catch (t) {
                    await this.sendError(i, e, t), this.logger.error(t)
                }
            }, this.onPairingPingResponse = (e, t) => {
                let {
                    id: i
                } = t;
                setTimeout(() => {
                    N(t) ? this.events.emit((0, u.engineEvent)("pairing_ping", i), {}) : U(t) && this.events.emit((0, u.engineEvent)("pairing_ping", i), {
                        error: t.error
                    })
                }, 500)
            }, this.onPairingDeleteRequest = async (e, t) => {
                let {
                    id: i
                } = t;
                try {
                    this.isValidDisconnect({
                        topic: e
                    }), await this.deletePairing(e), this.events.emit(ez, {
                        id: i,
                        topic: e
                    })
                } catch (t) {
                    await this.sendError(i, e, t), this.logger.error(t)
                }
            }, this.onUnknownRpcMethodRequest = async (e, t) => {
                let {
                    id: i,
                    method: r
                } = t;
                try {
                    if (this.registeredMethods.includes(r)) return;
                    let t = (0, u.getSdkError)("WC_METHOD_UNSUPPORTED", r);
                    await this.sendError(i, e, t), this.logger.error(t)
                } catch (t) {
                    await this.sendError(i, e, t), this.logger.error(t)
                }
            }, this.onUnknownRpcMethodResponse = e => {
                this.registeredMethods.includes(e) || this.logger.error((0, u.getSdkError)("WC_METHOD_UNSUPPORTED", e))
            }, this.isValidPair = (e, t) => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: i
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `pair() params: ${e}`);
                    throw t.setError(eZ), Error(i)
                }
                if (!(0, u.isValidUrl)(e.uri)) {
                    let {
                        message: i
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `pair() uri: ${e.uri}`);
                    throw t.setError(eZ), Error(i)
                }
                let i = (0, u.parseUri)(e ? .uri);
                if (!i ? .relay ? .protocol) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", "pair() uri#relay-protocol");
                    throw t.setError(eZ), Error(e)
                }
                if (!i ? .symKey) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", "pair() uri#symKey");
                    throw t.setError(eZ), Error(e)
                }
                if (i ? .expiryTimestamp && (0, a.toMiliseconds)(i ? .expiryTimestamp) < Date.now()) {
                    t.setError("pairing_expired");
                    let {
                        message: e
                    } = (0, u.getInternalError)("EXPIRED", "pair() URI has expired. Please try again with a new connection URI.");
                    throw Error(e)
                }
            }, this.isValidPing = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `ping() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t
                } = e;
                await this.isValidPairingTopic(t)
            }, this.isValidDisconnect = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `disconnect() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t
                } = e;
                await this.isValidPairingTopic(t)
            }, this.isValidPairingTopic = async e => {
                if (!(0, u.isValidString)(e, !1)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `pairing topic should be a string: ${e}`);
                    throw Error(t)
                }
                if (!this.pairings.keys.includes(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("NO_MATCHING_KEY", `pairing topic doesn't exist: ${e}`);
                    throw Error(t)
                }
                if ((0, u.isExpired)(this.pairings.get(e).expiry)) {
                    await this.deletePairing(e);
                    let {
                        message: t
                    } = (0, u.getInternalError)("EXPIRED", `pairing topic: ${e}`);
                    throw Error(t)
                }
            }, this.core = e, this.logger = (0, n.generateChildLogger)(i, this.name), this.pairings = new e4(this.core, this.logger, this.name, this.storagePrefix)
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
        registerRelayerEvents() {
            this.core.relayer.on(e_, async e => {
                let {
                    topic: t,
                    message: i,
                    transportType: r
                } = e;
                if (this.pairings.keys.includes(t) && r !== ek && !this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i))) try {
                    let e = await this.core.crypto.decode(t, i);
                    O(e) ? (this.core.history.set(t, e), await this.onRelayEventRequest({
                        topic: t,
                        payload: e
                    })) : R(e) && (await this.core.history.resolve(e), await this.onRelayEventResponse({
                        topic: t,
                        payload: e
                    }), this.core.history.delete(t, e.id)), await this.core.relayer.messages.ack(t, i)
                } catch (e) {
                    this.logger.error(e)
                }
            })
        }
        registerExpirerEvents() {
            this.core.expirer.on(eG, async e => {
                let {
                    topic: t
                } = (0, u.parseExpirerTarget)(e.target);
                t && this.pairings.keys.includes(t) && (await this.deletePairing(t, !0), this.events.emit("pairing_expire", {
                    topic: t
                }))
            })
        }
    }
    class e7 extends o.IJsonRpcHistory {
        constructor(e, i) {
            super(e, i), this.core = e, this.logger = i, this.records = new Map, this.events = new t.EventEmitter, this.name = "history", this.version = "0.3", this.cached = [], this.initialized = !1, this.storagePrefix = ew, this.init = async () => {
                this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach(e => this.records.set(e.id, e)), this.cached = [], this.registerEventListeners(), this.initialized = !0)
            }, this.set = (e, t, i) => {
                if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({
                        type: "method",
                        method: "set",
                        topic: e,
                        request: t,
                        chainId: i
                    }), this.records.has(t.id)) return;
                let r = {
                    id: t.id,
                    topic: e,
                    request: {
                        method: t.method,
                        params: t.params || null
                    },
                    chainId: i,
                    expiry: (0, u.calcExpiry)(a.THIRTY_DAYS)
                };
                this.records.set(r.id, r), this.persist(), this.events.emit(eV, r)
            }, this.resolve = async e => {
                if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({
                        type: "method",
                        method: "update",
                        response: e
                    }), !this.records.has(e.id)) return;
                let t = await this.getRecord(e.id);
                "u" > typeof t.response || (t.response = U(e) ? {
                    error: e.error
                } : {
                    result: e.result
                }, this.records.set(t.id, t), this.persist(), this.events.emit(eK, t))
            }, this.get = async (e, t) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({
                type: "method",
                method: "get",
                topic: e,
                id: t
            }), await this.getRecord(t)), this.delete = (e, t) => {
                this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({
                    type: "method",
                    method: "delete",
                    id: t
                }), this.values.forEach(i => {
                    i.topic === e && ("u" > typeof t && i.id !== t || (this.records.delete(i.id), this.events.emit(eF, i)))
                }), this.persist()
            }, this.exists = async (e, t) => (this.isInitialized(), !!this.records.has(t) && (await this.getRecord(t)).topic === e), this.on = (e, t) => {
                this.events.on(e, t)
            }, this.once = (e, t) => {
                this.events.once(e, t)
            }, this.off = (e, t) => {
                this.events.off(e, t)
            }, this.removeListener = (e, t) => {
                this.events.removeListener(e, t)
            }, this.logger = (0, n.generateChildLogger)(i, this.name)
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name
        }
        get size() {
            return this.records.size
        }
        get keys() {
            return Array.from(this.records.keys())
        }
        get values() {
            return Array.from(this.records.values())
        }
        get pending() {
            let e = [];
            return this.values.forEach(t => {
                if ("u" > typeof t.response) return;
                let i = {
                    topic: t.topic,
                    request: _(t.request.method, t.request.params, t.id),
                    chainId: t.chainId
                };
                return e.push(i)
            }), e
        }
        async setJsonRpcRecords(e) {
            await this.core.storage.setItem(this.storageKey, e)
        }
        async getJsonRpcRecords() {
            return await this.core.storage.getItem(this.storageKey)
        }
        getRecord(e) {
            this.isInitialized();
            let t = this.records.get(e);
            if (!t) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `${this.name}: ${e}`);
                throw Error(t)
            }
            return t
        }
        async persist() {
            await this.setJsonRpcRecords(this.values), this.events.emit("history_sync")
        }
        async restore() {
            try {
                let e = await this.getJsonRpcRecords();
                if (typeof e > "u" || !e.length) return;
                if (this.records.size) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("RESTORE_WILL_OVERRIDE", this.name);
                    throw this.logger.error(e), Error(e)
                }
                this.cached = e, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({
                    type: "method",
                    method: "restore",
                    records: this.values
                })
            } catch (e) {
                this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e)
            }
        }
        registerEventListeners() {
            this.events.on(eV, e => {
                this.logger.info(`Emitting ${eV}`), this.logger.debug({
                    type: "event",
                    event: eV,
                    record: e
                })
            }), this.events.on(eK, e => {
                this.logger.info(`Emitting ${eK}`), this.logger.debug({
                    type: "event",
                    event: eK,
                    record: e
                })
            }), this.events.on(eF, e => {
                this.logger.info(`Emitting ${eF}`), this.logger.debug({
                    type: "event",
                    event: eF,
                    record: e
                })
            }), this.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, () => {
                this.cleanup()
            })
        }
        cleanup() {
            try {
                this.isInitialized();
                let e = !1;
                this.records.forEach(t => {
                    (0, a.toMiliseconds)(t.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t.id}`), this.records.delete(t.id), this.events.emit(eF, t, !1), e = !0)
                }), e && this.persist()
            } catch (e) {
                this.logger.warn(e)
            }
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class te extends o.IExpirer {
        constructor(e, i) {
            super(e, i), this.core = e, this.logger = i, this.expirations = new Map, this.events = new t.EventEmitter, this.name = "expirer", this.version = "0.3", this.cached = [], this.initialized = !1, this.storagePrefix = ew, this.init = async () => {
                this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach(e => this.expirations.set(e.target, e)), this.cached = [], this.registerEventListeners(), this.initialized = !0)
            }, this.has = e => {
                try {
                    let t = this.formatTarget(e);
                    return "u" > typeof this.getExpiration(t)
                } catch {
                    return !1
                }
            }, this.set = (e, t) => {
                this.isInitialized();
                let i = this.formatTarget(e),
                    r = {
                        target: i,
                        expiry: t
                    };
                this.expirations.set(i, r), this.checkExpiry(i, r), this.events.emit(eH, {
                    target: i,
                    expiration: r
                })
            }, this.get = e => {
                this.isInitialized();
                let t = this.formatTarget(e);
                return this.getExpiration(t)
            }, this.del = e => {
                if (this.isInitialized(), this.has(e)) {
                    let t = this.formatTarget(e),
                        i = this.getExpiration(t);
                    this.expirations.delete(t), this.events.emit(eW, {
                        target: t,
                        expiration: i
                    })
                }
            }, this.on = (e, t) => {
                this.events.on(e, t)
            }, this.once = (e, t) => {
                this.events.once(e, t)
            }, this.off = (e, t) => {
                this.events.off(e, t)
            }, this.removeListener = (e, t) => {
                this.events.removeListener(e, t)
            }, this.logger = (0, n.generateChildLogger)(i, this.name)
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get storageKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name
        }
        get length() {
            return this.expirations.size
        }
        get keys() {
            return Array.from(this.expirations.keys())
        }
        get values() {
            return Array.from(this.expirations.values())
        }
        formatTarget(e) {
            if ("string" == typeof e) return (0, u.formatTopicTarget)(e);
            if ("number" == typeof e) return (0, u.formatIdTarget)(e);
            let {
                message: t
            } = (0, u.getInternalError)("UNKNOWN_TYPE", `Target type: ${typeof e}`);
            throw Error(t)
        }
        async setExpirations(e) {
            await this.core.storage.setItem(this.storageKey, e)
        }
        async getExpirations() {
            return await this.core.storage.getItem(this.storageKey)
        }
        async persist() {
            await this.setExpirations(this.values), this.events.emit("expirer_sync")
        }
        async restore() {
            try {
                let e = await this.getExpirations();
                if (typeof e > "u" || !e.length) return;
                if (this.expirations.size) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("RESTORE_WILL_OVERRIDE", this.name);
                    throw this.logger.error(e), Error(e)
                }
                this.cached = e, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({
                    type: "method",
                    method: "restore",
                    expirations: this.values
                })
            } catch (e) {
                this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e)
            }
        }
        getExpiration(e) {
            let t = this.expirations.get(e);
            if (!t) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `${this.name}: ${e}`);
                throw this.logger.warn(t), Error(t)
            }
            return t
        }
        checkExpiry(e, t) {
            let {
                expiry: i
            } = t;
            (0, a.toMiliseconds)(i) - Date.now() <= 0 && this.expire(e, t)
        }
        expire(e, t) {
            this.expirations.delete(e), this.events.emit(eG, {
                target: e,
                expiration: t
            })
        }
        checkExpirations() {
            this.core.relayer.connected && this.expirations.forEach((e, t) => this.checkExpiry(t, e))
        }
        registerEventListeners() {
            this.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(eH, e => {
                this.logger.info(`Emitting ${eH}`), this.logger.debug({
                    type: "event",
                    event: eH,
                    data: e
                }), this.persist()
            }), this.events.on(eG, e => {
                this.logger.info(`Emitting ${eG}`), this.logger.debug({
                    type: "event",
                    event: eG,
                    data: e
                }), this.persist()
            }), this.events.on(eW, e => {
                this.logger.info(`Emitting ${eW}`), this.logger.debug({
                    type: "event",
                    event: eW,
                    data: e
                }), this.persist()
            })
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
    }
    class tt extends o.IVerify {
        constructor(e, t, i) {
            super(e, t, i), this.core = e, this.logger = t, this.store = i, this.name = "verify-api", this.verifyUrlV3 = eJ, this.storagePrefix = ew, this.version = 2, this.init = async () => {
                this.isDevEnv || (this.publicKey = await this.store.getItem(this.storeKey), this.publicKey && (0, a.toMiliseconds)(this.publicKey ? .expiresAt) < Date.now() && (this.logger.debug("verify v2 public key expired"), await this.removePublicKey()))
            }, this.register = async e => {
                if (!(0, u.isBrowser)() || this.isDevEnv) return;
                let t = window.location.origin,
                    {
                        id: i,
                        decryptedId: r
                    } = e,
                    s = `${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${i}&decryptedId=${r}`;
                try {
                    let e = (0, em.getDocument)(),
                        t = this.startAbortTimer(5 * a.ONE_SECOND),
                        r = await new Promise((r, n) => {
                            let o = () => {
                                window.removeEventListener("message", l), e.body.removeChild(a), n("attestation aborted")
                            };
                            this.abortController.signal.addEventListener("abort", o);
                            let a = e.createElement("iframe");
                            a.src = s, a.style.display = "none", a.addEventListener("error", o, {
                                signal: this.abortController.signal
                            });
                            let l = s => {
                                if (s.data && "string" == typeof s.data) try {
                                    let n = JSON.parse(s.data);
                                    if ("verify_attestation" === n.type) {
                                        if ((0, c.decodeJWT)(n.attestation).payload.id !== i) return;
                                        clearInterval(t), e.body.removeChild(a), this.abortController.signal.removeEventListener("abort", o), window.removeEventListener("message", l), r(null === n.attestation ? "" : n.attestation)
                                    }
                                } catch (e) {
                                    this.logger.warn(e)
                                }
                            };
                            e.body.appendChild(a), window.addEventListener("message", l, {
                                signal: this.abortController.signal
                            })
                        });
                    return this.logger.debug(r, "jwt attestation"), r
                } catch (e) {
                    this.logger.warn(e)
                }
                return ""
            }, this.resolve = async e => {
                if (this.isDevEnv) return "";
                let {
                    attestationId: t,
                    hash: i,
                    encryptedId: r
                } = e;
                if ("" === t) return void this.logger.debug("resolve: attestationId is empty, skipping");
                if (t) {
                    if ((0, c.decodeJWT)(t).payload.id !== r) return;
                    let e = await this.isValidJwtAttestation(t);
                    if (e) return e.isVerified ? e : void this.logger.warn("resolve: jwt attestation: origin url not verified")
                }
                if (!i) return;
                let s = this.getVerifyUrl(e ? .verifyUrl);
                return this.fetchAttestation(i, s)
            }, this.fetchAttestation = async (e, t) => {
                this.logger.debug(`resolving attestation: ${e} from url: ${t}`);
                let i = this.startAbortTimer(5 * a.ONE_SECOND),
                    r = await fetch(`${t}/attestation/${e}?v2Supported=true`, {
                        signal: this.abortController.signal
                    });
                return clearTimeout(i), 200 === r.status ? await r.json() : void 0
            }, this.getVerifyUrl = e => {
                let t = e || eY;
                return eQ.includes(t) || (this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${eY}`), t = eY), t
            }, this.fetchPublicKey = async () => {
                try {
                    this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);
                    let e = this.startAbortTimer(a.FIVE_SECONDS),
                        t = await fetch(`${this.verifyUrlV3}/public-key`, {
                            signal: this.abortController.signal
                        });
                    return clearTimeout(e), await t.json()
                } catch (e) {
                    this.logger.warn(e)
                }
            }, this.persistPublicKey = async e => {
                this.logger.debug(e, "persisting public key to local storage"), await this.store.setItem(this.storeKey, e), this.publicKey = e
            }, this.removePublicKey = async () => {
                this.logger.debug("removing verify v2 public key from storage"), await this.store.removeItem(this.storeKey), this.publicKey = void 0
            }, this.isValidJwtAttestation = async e => {
                let t = await this.getPublicKey();
                try {
                    if (t) return this.validateAttestation(e, t)
                } catch (e) {
                    this.logger.error(e), this.logger.warn("error validating attestation")
                }
                let i = await this.fetchAndPersistPublicKey();
                try {
                    if (i) return this.validateAttestation(e, i)
                } catch (e) {
                    this.logger.error(e), this.logger.warn("error validating attestation")
                }
            }, this.getPublicKey = async () => this.publicKey ? this.publicKey : await this.fetchAndPersistPublicKey(), this.fetchAndPersistPublicKey = async () => {
                if (this.fetchPromise) return await this.fetchPromise, this.publicKey;
                this.fetchPromise = new Promise(async e => {
                    let t = await this.fetchPublicKey();
                    t && (await this.persistPublicKey(t), e(t))
                });
                let e = await this.fetchPromise;
                return this.fetchPromise = void 0, e
            }, this.validateAttestation = (e, t) => {
                let i = (0, u.verifyP256Jwt)(e, t.publicKey),
                    r = {
                        hasExpired: (0, a.toMiliseconds)(i.exp) < Date.now(),
                        payload: i
                    };
                if (r.hasExpired) throw this.logger.warn("resolve: jwt attestation expired"), Error("JWT attestation expired");
                return {
                    origin: r.payload.origin,
                    isScam: r.payload.isScam,
                    isVerified: r.payload.isVerified
                }
            }, this.logger = (0, n.generateChildLogger)(t, this.name), this.abortController = new AbortController, this.isDevEnv = (0, u.isTestRun)(), this.init()
        }
        get storeKey() {
            return this.storagePrefix + this.version + this.core.customStoragePrefix + "//verify:public:key"
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        startAbortTimer(e) {
            return this.abortController = new AbortController, setTimeout(() => this.abortController.abort(), (0, a.toMiliseconds)(e))
        }
    }
    class ti extends o.IEchoClient {
        constructor(e, t) {
            super(e, t), this.projectId = e, this.logger = t, this.context = "echo", this.registerDeviceToken = async e => {
                let {
                    clientId: t,
                    token: i,
                    notificationType: r,
                    enableEncrypted: s = !1
                } = e, n = `https://echo.walletconnect.com/${this.projectId}/clients`;
                await fetch(n, {
                    method: "POST",
                    headers: {
                        "Content-Type": "application/json"
                    },
                    body: JSON.stringify({
                        client_id: t,
                        type: r,
                        token: i,
                        always_raw: s
                    })
                })
            }, this.logger = (0, n.generateChildLogger)(t, this.context)
        }
    }
    class tr extends o.IEventClient {
        constructor(e, t, i = !0) {
            super(e, t, i), this.core = e, this.logger = t, this.context = "event-client", this.storagePrefix = ew, this.storageVersion = .1, this.events = new Map, this.shouldPersist = !1, this.init = async () => {
                if (!(0, u.isTestRun)()) try {
                    let e = {
                        eventId: (0, u.uuidv4)(),
                        timestamp: Date.now(),
                        domain: this.getAppDomain(),
                        props: {
                            event: "INIT",
                            type: "",
                            properties: {
                                client_id: await this.core.crypto.getClientId(),
                                user_agent: (0, u.formatUA)(this.core.relayer.protocol, this.core.relayer.version, eC)
                            }
                        }
                    };
                    await this.sendEvent([e])
                } catch (e) {
                    this.logger.warn(e)
                }
            }, this.createEvent = e => {
                let {
                    event: t = "ERROR",
                    type: i = "",
                    properties: {
                        topic: r,
                        trace: s
                    }
                } = e, n = (0, u.uuidv4)(), o = this.core.projectId || "", a = {
                    eventId: n,
                    timestamp: Date.now(),
                    props: {
                        event: t,
                        type: i,
                        properties: {
                            topic: r,
                            trace: s
                        }
                    },
                    bundleId: o,
                    domain: this.getAppDomain(),
                    ...this.setMethods(n)
                };
                return this.telemetryEnabled && (this.events.set(n, a), this.shouldPersist = !0), a
            }, this.getEvent = e => {
                let {
                    eventId: t,
                    topic: i
                } = e;
                if (t) return this.events.get(t);
                let r = Array.from(this.events.values()).find(e => e.props.properties.topic === i);
                if (r) return { ...r,
                    ...this.setMethods(r.eventId)
                }
            }, this.deleteEvent = e => {
                let {
                    eventId: t
                } = e;
                this.events.delete(t), this.shouldPersist = !0
            }, this.setEventListeners = () => {
                this.core.heartbeat.on(r.HEARTBEAT_EVENTS.pulse, async () => {
                    this.shouldPersist && await this.persist(), this.events.forEach(e => {
                        (0, a.fromMiliseconds)(Date.now()) - (0, a.fromMiliseconds)(e.timestamp) > 86400 && (this.events.delete(e.eventId), this.shouldPersist = !0)
                    })
                })
            }, this.setMethods = e => ({
                addTrace: t => this.addTrace(e, t),
                setError: t => this.setError(e, t)
            }), this.addTrace = (e, t) => {
                let i = this.events.get(e);
                i && (i.props.properties.trace.push(t), this.events.set(e, i), this.shouldPersist = !0)
            }, this.setError = (e, t) => {
                let i = this.events.get(e);
                i && (i.props.type = t, i.timestamp = Date.now(), this.events.set(e, i), this.shouldPersist = !0)
            }, this.persist = async () => {
                await this.core.storage.setItem(this.storageKey, Array.from(this.events.values())), this.shouldPersist = !1
            }, this.restore = async () => {
                try {
                    let e = await this.core.storage.getItem(this.storageKey) || [];
                    if (!e.length) return;
                    e.forEach(e => {
                        this.events.set(e.eventId, { ...e,
                            ...this.setMethods(e.eventId)
                        })
                    })
                } catch (e) {
                    this.logger.warn(e)
                }
            }, this.submit = async () => {
                if (!this.telemetryEnabled || 0 === this.events.size) return;
                let e = [];
                for (let [t, i] of this.events) i.props.type && e.push(i);
                if (0 !== e.length) try {
                    if ((await this.sendEvent(e)).ok)
                        for (let t of e) this.events.delete(t.eventId), this.shouldPersist = !0
                } catch (e) {
                    this.logger.warn(e)
                }
            }, this.sendEvent = async e => {
                let t = this.getAppDomain() ? "" : "&sp=desktop";
                return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${eC}${t}`, {
                    method: "POST",
                    body: JSON.stringify(e)
                })
            }, this.getAppDomain = () => (0, u.getAppMetadata)().url, this.logger = (0, n.generateChildLogger)(t, this.context), this.telemetryEnabled = i, i ? this.restore().then(async () => {
                await this.submit(), this.setEventListeners()
            }) : this.persist()
        }
        get storageKey() {
            return this.storagePrefix + this.storageVersion + this.core.customStoragePrefix + "//" + this.context
        }
    }
    let ts = class e extends o.ICore {
        constructor(e) {
            super(e), this.protocol = "wc", this.version = 2, this.name = eb, this.events = new t.EventEmitter, this.initialized = !1, this.on = (e, t) => this.events.on(e, t), this.once = (e, t) => this.events.once(e, t), this.off = (e, t) => this.events.off(e, t), this.removeListener = (e, t) => this.events.removeListener(e, t), this.dispatchEnvelope = ({
                topic: e,
                message: t,
                sessionExists: i
            }) => {
                if (!e || !t) return;
                let r = {
                    topic: e,
                    message: t,
                    publishedAt: Date.now(),
                    transportType: ek
                };
                this.relayer.onLinkMessageEvent(r, {
                    sessionExists: i
                })
            };
            const i = this.getGlobalCore(e ? .customStoragePrefix);
            if (i) try {
                return this.customStoragePrefix = i.customStoragePrefix, this.logger = i.logger, this.heartbeat = i.heartbeat, this.crypto = i.crypto, this.history = i.history, this.expirer = i.expirer, this.storage = i.storage, this.relayer = i.relayer, this.pairing = i.pairing, this.verify = i.verify, this.echoClient = i.echoClient, this.linkModeSupportedApps = i.linkModeSupportedApps, this.eventClient = i.eventClient, this.initialized = i.initialized, this.logChunkController = i.logChunkController, i
            } catch (e) {
                console.warn("Failed to copy global core", e)
            }
            this.projectId = e ? .projectId, this.relayUrl = e ? .relayUrl || eS, this.customStoragePrefix = e ? .customStoragePrefix ? `:${e.customStoragePrefix}` : "";
            const o = (0, n.getDefaultLoggerOptions)({
                    level: "string" == typeof e ? .logger && e.logger ? e.logger : "error",
                    name: eb
                }),
                {
                    logger: a,
                    chunkLoggerController: l
                } = (0, n.generatePlatformLogger)({
                    opts: o,
                    maxSizeInBytes: e ? .maxLogBlobSizeInBytes,
                    loggerOverride: e ? .logger
                });
            this.logChunkController = l, this.logChunkController ? .downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => {
                this.logChunkController ? .downloadLogsBlobInBrowser && this.logChunkController ? .downloadLogsBlobInBrowser({
                    clientId: await this.crypto.getClientId()
                })
            }), this.logger = (0, n.generateChildLogger)(a, this.name), this.heartbeat = new r.HeartBeat, this.crypto = new e1(this, this.logger, e ? .keychain), this.history = new e7(this, this.logger), this.expirer = new te(this, this.logger), this.storage = e ? .storage ? e.storage : new s.default({ ...ev,
                ...e ? .storageOptions
            }), this.relayer = new e5({
                core: this,
                logger: this.logger,
                relayUrl: this.relayUrl,
                projectId: this.projectId
            }), this.pairing = new e9(this, this.logger), this.verify = new tt(this, this.logger, this.storage), this.echoClient = new ti(this.projectId || "", this.logger), this.linkModeSupportedApps = [], this.eventClient = new tr(this, this.logger, e ? .telemetryEnabled), this.setGlobalCore(this)
        }
        static async init(t) {
            let i = new e(t);
            await i.initialize();
            let r = await i.crypto.getClientId();
            return await i.storage.setItem("WALLETCONNECT_CLIENT_ID", r), i
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        async start() {
            this.initialized || await this.initialize()
        }
        async getLogsBlob() {
            return this.logChunkController ? .logsToBlob({
                clientId: await this.crypto.getClientId()
            })
        }
        async addLinkModeSupportedApp(e) {
            this.linkModeSupportedApps.includes(e) || (this.linkModeSupportedApps.push(e), await this.storage.setItem(eB, this.linkModeSupportedApps))
        }
        async initialize() {
            this.logger.trace("Initialized");
            try {
                await this.crypto.init(), await this.history.init(), await this.expirer.init(), await this.relayer.init(), await this.heartbeat.init(), await this.pairing.init(), this.linkModeSupportedApps = await this.storage.getItem(eB) || [], this.initialized = !0, this.logger.info("Core Initialization Success")
            } catch (e) {
                throw this.logger.warn(e, `Core Initialization Failure at epoch ${Date.now()}`), this.logger.error(e.message), e
            }
        }
        getGlobalCore(e = "") {
            try {
                if (this.isGlobalCoreDisabled()) return;
                let t = `_walletConnectCore_${e}`,
                    i = `${t}_count`;
                return globalThis[i] = (globalThis[i] || 0) + 1, globalThis[i] > 1 && console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`), globalThis[t]
            } catch (e) {
                console.warn("Failed to get global WalletConnect core", e);
                return
            }
        }
        setGlobalCore(e) {
            try {
                if (this.isGlobalCoreDisabled()) return;
                let t = `_walletConnectCore_${e.opts?.customStoragePrefix||""}`;
                globalThis[t] = e
            } catch (e) {
                console.warn("Failed to set global WalletConnect core", e)
            }
        }
        isGlobalCoreDisabled() {
            try {
                return "u" > typeof i.default && "true" === i.default.env.DISABLE_GLOBAL_CORE
            } catch {
                return !0
            }
        }
    };
    var tn = o;
    let to = "client",
        ta = `wc@2:${to}:`,
        tl = "WALLETCONNECT_DEEPLINK_CHOICE",
        tc = (a.THIRTY_DAYS, "Proposal expired"),
        th = a.SEVEN_DAYS,
        tu = {
            wc_sessionPropose: {
                req: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !0,
                    tag: 1100
                },
                res: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1101
                },
                reject: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1120
                },
                autoReject: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1121
                }
            },
            wc_sessionSettle: {
                req: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1102
                },
                res: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1103
                }
            },
            wc_sessionUpdate: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1104
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1105
                }
            },
            wc_sessionExtend: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1106
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1107
                }
            },
            wc_sessionRequest: {
                req: {
                    ttl: 3 * a.FIVE_MINUTES,
                    prompt: !0,
                    tag: 1108
                },
                res: {
                    ttl: 3 * a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1109
                }
            },
            wc_sessionEvent: {
                req: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !0,
                    tag: 1110
                },
                res: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1111
                }
            },
            wc_sessionDelete: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1112
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1113
                }
            },
            wc_sessionPing: {
                req: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1114
                },
                res: {
                    ttl: a.ONE_DAY,
                    prompt: !1,
                    tag: 1115
                }
            },
            wc_sessionAuthenticate: {
                req: {
                    ttl: a.ONE_HOUR,
                    prompt: !0,
                    tag: 1116
                },
                res: {
                    ttl: a.ONE_HOUR,
                    prompt: !1,
                    tag: 1117
                },
                reject: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1118
                },
                autoReject: {
                    ttl: a.FIVE_MINUTES,
                    prompt: !1,
                    tag: 1119
                }
            }
        },
        td = {
            min: a.FIVE_MINUTES,
            max: a.SEVEN_DAYS
        },
        tp = "IDLE",
        tf = "ACTIVE",
        tg = {
            eth_sendTransaction: {
                key: ""
            },
            eth_sendRawTransaction: {
                key: ""
            },
            wallet_sendCalls: {
                key: ""
            },
            solana_signTransaction: {
                key: "signature"
            },
            solana_signAllTransactions: {
                key: "transactions"
            },
            solana_signAndSendTransaction: {
                key: "signature"
            },
            sui_signAndExecuteTransaction: {
                key: "digest"
            },
            sui_signTransaction: {
                key: ""
            },
            hedera_signAndExecuteTransaction: {
                key: "transactionId"
            },
            hedera_executeTransaction: {
                key: "transactionId"
            },
            near_signTransaction: {
                key: ""
            },
            near_signTransactions: {
                key: ""
            },
            tron_signTransaction: {
                key: "txID"
            },
            xrpl_signTransaction: {
                key: ""
            },
            xrpl_signTransactionFor: {
                key: ""
            },
            algo_signTxn: {
                key: ""
            },
            sendTransfer: {
                key: "txid"
            },
            stacks_stxTransfer: {
                key: "txId"
            },
            polkadot_signTransaction: {
                key: ""
            },
            cosmos_signDirect: {
                key: ""
            }
        },
        ty = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest", "wc_sessionAuthenticate"],
        tm = "wc@1.5:auth:",
        tb = `${tm}:PUB_KEY`;
    class tw extends tn.IEngine {
        constructor(i) {
            super(i), this.name = "engine", this.events = new t.default, this.initialized = !1, this.requestQueue = {
                state: tp,
                queue: []
            }, this.sessionRequestQueue = {
                state: tp,
                queue: []
            }, this.emittedSessionRequests = new u.LimitedSet({
                limit: 500
            }), this.requestQueueDelay = a.ONE_SECOND, this.expectedPairingMethodMap = new Map, this.recentlyDeletedMap = new Map, this.recentlyDeletedLimit = 200, this.relayMessageCache = [], this.pendingSessions = new Map, this.init = async () => {
                this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.registerSubscriptionCleanup(), await this.registerLinkModeListeners(), this.client.core.pairing.register({
                    methods: Object.keys(tu)
                }), this.initialized = !0, setTimeout(async () => {
                    await this.processPendingMessageEvents(), this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue()
                }, (0, a.toMiliseconds)(this.requestQueueDelay)))
            }, this.connect = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                let t = { ...e,
                    requiredNamespaces: e.requiredNamespaces || {},
                    optionalNamespaces: e.optionalNamespaces || {}
                };
                await this.isValidConnect(t), t.optionalNamespaces = (0, u.mergeRequiredAndOptionalNamespaces)(t.requiredNamespaces, t.optionalNamespaces), t.requiredNamespaces = {};
                let {
                    pairingTopic: i,
                    requiredNamespaces: r,
                    optionalNamespaces: s,
                    sessionProperties: n,
                    scopedProperties: o,
                    relays: l,
                    authentication: c,
                    walletPay: h
                } = t, d = c ? .[0] ? .ttl || tu.wc_sessionPropose.req.ttl || a.FIVE_MINUTES;
                this.validateRequestExpiry(d);
                let p = i,
                    f, g = !1;
                try {
                    if (p) {
                        let e = this.client.core.pairing.pairings.get(p);
                        this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."), g = e.active
                    }
                } catch (e) {
                    throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`), e
                }
                if (!p || !g) {
                    let {
                        topic: e,
                        uri: t
                    } = await this.client.core.pairing.create({
                        internal: {
                            skipSubscribe: !0
                        }
                    });
                    p = e, f = t
                }
                if (!p) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("NO_MATCHING_KEY", `connect() pairing topic: ${p}`);
                    throw Error(e)
                }
                let y = await this.client.core.crypto.generateKeyPair(),
                    m = (0, u.calcExpiry)(d),
                    b = {
                        requiredNamespaces: r,
                        optionalNamespaces: s,
                        relays: l ? ? [{
                            protocol: "irn"
                        }],
                        proposer: {
                            publicKey: y,
                            metadata: this.client.metadata
                        },
                        expiryTimestamp: m,
                        pairingTopic: p,
                        ...n && {
                            sessionProperties: n
                        },
                        ...o && {
                            scopedProperties: o
                        },
                        id: I(),
                        ...(c || h) && {
                            requests: {
                                authentication: c ? .map(e => {
                                    let {
                                        domain: t,
                                        chains: i,
                                        nonce: r,
                                        uri: s,
                                        exp: n,
                                        nbf: o,
                                        type: a,
                                        statement: l,
                                        requestId: c,
                                        resources: h,
                                        signatureTypes: u
                                    } = e;
                                    return {
                                        domain: t,
                                        chains: i,
                                        nonce: r,
                                        type: a ? ? "caip122",
                                        aud: s,
                                        version: "1",
                                        iat: new Date().toISOString(),
                                        exp: n,
                                        nbf: o,
                                        statement: l,
                                        requestId: c,
                                        resources: h,
                                        signatureTypes: u
                                    }
                                }),
                                walletPay: h
                            }
                        }
                    },
                    w = (0, u.engineEvent)("session_connect", b.id),
                    {
                        reject: v,
                        resolve: E,
                        done: x
                    } = (0, u.createDelayedPromise)(d, tc),
                    S = ({
                        id: e
                    }) => {
                        if (e === b.id) {
                            this.client.events.off("proposal_expire", S);
                            let e = this.pendingSessions.get(b.id);
                            if (e) {
                                let {
                                    sessionTopic: t,
                                    publicKey: i
                                } = e;
                                Promise.all([this.client.core.relayer.unsubscribe(t), this.client.core.crypto.keychain.has(t) ? this.client.core.crypto.deleteSymKey(t) : Promise.resolve(), this.client.core.crypto.keychain.has(i) ? this.client.core.crypto.deleteKeyPair(i) : Promise.resolve()]).catch(e => this.client.logger.warn(e))
                            }
                            this.pendingSessions.delete(b.id), this.events.emit(w, {
                                error: {
                                    message: tc,
                                    code: 0
                                }
                            })
                        }
                    };
                return this.client.events.on("proposal_expire", S), this.events.once(w, ({
                    error: e,
                    session: t
                }) => {
                    this.client.events.off("proposal_expire", S), e ? v(e) : t && E(t)
                }), await this.setProposal(b.id, b), await this.sendProposeSession({
                    proposal: b,
                    publishOpts: {
                        internal: {
                            throwOnFailedPublish: !0
                        },
                        tvf: {
                            correlationId: b.id
                        }
                    }
                }).catch(e => {
                    throw this.deleteProposal(b.id), e
                }), {
                    uri: f,
                    approval: x
                }
            }, this.pair = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                try {
                    return await this.client.core.pairing.pair(e)
                } catch (e) {
                    throw this.client.logger.error("pair() failed"), e
                }
            }, this.approve = async e => {
                let t = this.client.core.eventClient.createEvent({
                    properties: {
                        topic: e ? .id ? .toString(),
                        trace: [eX]
                    }
                });
                try {
                    this.isInitialized(), await this.confirmOnlineStateOrThrow()
                } catch (e) {
                    throw t.setError("no_internet_connection"), e
                }
                try {
                    await this.isValidProposalId(e ? .id)
                } catch (i) {
                    throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`), t.setError("proposal_not_found"), i
                }
                try {
                    await this.isValidApprove(e)
                } catch (e) {
                    throw this.client.logger.error("approve() -> isValidApprove() failed"), t.setError("session_approve_namespace_validation_failure"), e
                }
                let {
                    id: i,
                    relayProtocol: r,
                    namespaces: s,
                    sessionProperties: n,
                    scopedProperties: o,
                    sessionConfig: a,
                    proposalRequestsResponses: l
                } = e, c = this.client.proposal.get(i);
                this.client.core.eventClient.deleteEvent({
                    eventId: t.eventId
                });
                let {
                    pairingTopic: h,
                    proposer: d,
                    requiredNamespaces: p,
                    optionalNamespaces: f
                } = c, g = this.client.core.eventClient ? .getEvent({
                    topic: h
                });
                g || (g = this.client.core.eventClient ? .createEvent({
                    type: eX,
                    properties: {
                        topic: h,
                        trace: [eX, "session_namespaces_validation_success"]
                    }
                }));
                let y = await this.client.core.crypto.generateKeyPair(),
                    m = d.publicKey,
                    b = await this.client.core.crypto.generateSharedKey(y, m),
                    w = {
                        relay: {
                            protocol: r ? ? "irn"
                        },
                        namespaces: s,
                        controller: {
                            publicKey: y,
                            metadata: this.client.metadata
                        },
                        expiry: (0, u.calcExpiry)(th),
                        ...n && {
                            sessionProperties: n
                        },
                        ...o && {
                            scopedProperties: o
                        },
                        ...a && {
                            sessionConfig: a
                        },
                        proposalRequestsResponses: l
                    };
                g.addTrace("subscribing_session_topic");
                try {
                    await this.client.core.relayer.subscribe(b, {
                        transportType: eL,
                        internal: {
                            skipSubscribe: !0
                        }
                    })
                } catch (e) {
                    throw g.setError("subscribe_session_topic_failure"), e
                }
                g.addTrace("subscribe_session_topic_success");
                let v = { ...w,
                    topic: b,
                    requiredNamespaces: p,
                    optionalNamespaces: f,
                    pairingTopic: h,
                    acknowledged: !1,
                    self: w.controller,
                    peer: {
                        publicKey: d.publicKey,
                        metadata: d.metadata
                    },
                    controller: y,
                    transportType: eL,
                    authentication: l ? .authentication,
                    walletPayResult: l ? .walletPay
                };
                await this.client.session.set(b, v), g.addTrace("store_session");
                try {
                    await this.sendApproveSession({
                        sessionTopic: b,
                        proposal: c,
                        pairingProposalResponse: {
                            relay: {
                                protocol: r ? ? "irn"
                            },
                            responderPublicKey: y
                        },
                        sessionSettleRequest: w,
                        publishOpts: {
                            internal: {
                                throwOnFailedPublish: !0
                            },
                            tvf: {
                                correlationId: i,
                                ...this.getTVFApproveParams(v)
                            }
                        }
                    }), g.addTrace("session_approve_publish_success")
                } catch (e) {
                    throw this.client.logger.error(e), this.client.session.delete(b, (0, u.getSdkError)("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(b), e
                }
                return this.client.core.eventClient.deleteEvent({
                    eventId: g.eventId
                }), await this.client.core.pairing.updateMetadata({
                    topic: h,
                    metadata: d.metadata
                }), await this.deleteProposal(i), await this.client.core.pairing.activate({
                    topic: h
                }), await this.setExpiry(b, (0, u.calcExpiry)(th)), {
                    topic: b,
                    acknowledged: () => Promise.resolve(this.client.session.get(b))
                }
            }, this.reject = async e => {
                let t;
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                try {
                    await this.isValidReject(e)
                } catch (e) {
                    throw this.client.logger.error("reject() -> isValidReject() failed"), e
                }
                let {
                    id: i,
                    reason: r
                } = e;
                try {
                    t = this.client.proposal.get(i).pairingTopic
                } catch (e) {
                    throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`), e
                }
                t && await this.sendError({
                    id: i,
                    topic: t,
                    error: r,
                    rpcOpts: tu.wc_sessionPropose.reject
                }), await this.deleteProposal(i)
            }, this.update = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                try {
                    await this.isValidUpdate(e)
                } catch (e) {
                    throw this.client.logger.error("update() -> isValidUpdate() failed"), e
                }
                let {
                    topic: t,
                    namespaces: i
                } = e, {
                    done: r,
                    resolve: s,
                    reject: n
                } = (0, u.createDelayedPromise)(a.FIVE_MINUTES, "Session update request expired without receiving any acknowledgement"), o = I(), l = S().toString(), c = this.client.session.get(t).namespaces;
                return this.events.once((0, u.engineEvent)("session_update", o), ({
                    error: e
                }) => {
                    e ? n(e) : s()
                }), await this.client.session.update(t, {
                    namespaces: i
                }), await this.sendRequest({
                    topic: t,
                    method: "wc_sessionUpdate",
                    params: {
                        namespaces: i
                    },
                    throwOnFailedPublish: !0,
                    clientRpcId: o,
                    relayRpcId: l
                }).catch(e => {
                    this.client.logger.error(e), this.client.session.update(t, {
                        namespaces: c
                    }), n(e)
                }), {
                    acknowledged: r
                }
            }, this.extend = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                try {
                    await this.isValidExtend(e)
                } catch (e) {
                    throw this.client.logger.error("extend() -> isValidExtend() failed"), e
                }
                let {
                    topic: t
                } = e, i = I(), {
                    done: r,
                    resolve: s,
                    reject: n
                } = (0, u.createDelayedPromise)(a.FIVE_MINUTES, "Session extend request expired without receiving any acknowledgement");
                return this.events.once((0, u.engineEvent)("session_extend", i), ({
                    error: e
                }) => {
                    e ? n(e) : s()
                }), await this.setExpiry(t, (0, u.calcExpiry)(th)), this.sendRequest({
                    topic: t,
                    method: "wc_sessionExtend",
                    params: {},
                    clientRpcId: i,
                    throwOnFailedPublish: !0
                }).catch(e => {
                    n(e)
                }), {
                    acknowledged: r
                }
            }, this.request = async e => {
                this.isInitialized();
                try {
                    await this.isValidRequest(e)
                } catch (e) {
                    throw this.client.logger.error("request() -> isValidRequest() failed"), e
                }
                let {
                    chainId: t,
                    request: i,
                    topic: r,
                    expiry: s = tu.wc_sessionRequest.req.ttl
                } = e, n = this.client.session.get(r);
                n ? .transportType === eL && await this.confirmOnlineStateOrThrow();
                let o = I(),
                    a = S().toString(),
                    {
                        done: l,
                        resolve: c,
                        reject: h
                    } = (0, u.createDelayedPromise)(s, "Request expired. Please try again.");
                this.events.once((0, u.engineEvent)("session_request", o), ({
                    error: e,
                    result: t
                }) => {
                    e ? h(e) : c(t)
                });
                let d = "wc_sessionRequest",
                    p = this.getAppLinkIfEnabled(n.peer.metadata, n.transportType);
                if (p) return await this.sendRequest({
                    clientRpcId: o,
                    relayRpcId: a,
                    topic: r,
                    method: d,
                    params: {
                        request: { ...i,
                            expiryTimestamp: (0, u.calcExpiry)(s)
                        },
                        chainId: t
                    },
                    expiry: s,
                    throwOnFailedPublish: !0,
                    appLink: p
                }).catch(e => h(e)), this.client.events.emit("session_request_sent", {
                    topic: r,
                    request: i,
                    chainId: t,
                    id: o
                }), await l();
                let f = {
                    request: { ...i,
                        expiryTimestamp: (0, u.calcExpiry)(s)
                    },
                    chainId: t
                };
                return await Promise.all([new Promise(async e => {
                    await this.sendRequest({
                        clientRpcId: o,
                        relayRpcId: a,
                        topic: r,
                        method: d,
                        params: f,
                        expiry: s,
                        throwOnFailedPublish: !0,
                        tvf: this.getTVFParams(o, f)
                    }).catch(e => h(e)), this.client.events.emit("session_request_sent", {
                        topic: r,
                        request: i,
                        chainId: t,
                        id: o
                    }), e()
                }), new Promise(async e => {
                    if (!n.sessionConfig ? .disableDeepLink) {
                        let e = await (0, u.getDeepLink)(this.client.core.storage, tl);
                        await (0, u.handleDeeplinkRedirect)({
                            id: o,
                            topic: r,
                            wcDeepLink: e
                        })
                    }
                    e()
                }), l()]).then(e => e[2])
            }, this.respond = async e => {
                this.isInitialized();
                let t = this.client.core.eventClient.createEvent({
                    properties: {
                        topic: e ? .topic || e ? .response ? .id ? .toString(),
                        trace: ["session_request_response_started"]
                    }
                });
                try {
                    await this.isValidRespond(e)
                } catch (e) {
                    throw t.addTrace(e ? .message), t.setError("session_request_response_validation_failure"), e
                }
                t.addTrace("session_request_response_validation_success");
                let {
                    topic: i,
                    response: r
                } = e, {
                    id: s
                } = r, n = this.client.session.get(i);
                n.transportType === eL && await this.confirmOnlineStateOrThrow();
                let o = this.getAppLinkIfEnabled(n.peer.metadata, n.transportType);
                try {
                    t.addTrace("session_request_response_publish_started"), N(r) ? await this.sendResult({
                        id: s,
                        topic: i,
                        result: r.result,
                        throwOnFailedPublish: !0,
                        appLink: o
                    }) : U(r) && await this.sendError({
                        id: s,
                        topic: i,
                        error: r.error,
                        appLink: o
                    }), this.cleanupAfterResponse(e)
                } catch (e) {
                    throw t.addTrace(e ? .message), t.setError("session_request_response_publish_failure"), e
                }
            }, this.ping = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow();
                try {
                    await this.isValidPing(e)
                } catch (e) {
                    throw this.client.logger.error("ping() -> isValidPing() failed"), e
                }
                let {
                    topic: t
                } = e;
                if (this.client.session.keys.includes(t)) {
                    let e = I(),
                        i = S().toString(),
                        {
                            done: r,
                            resolve: s,
                            reject: n
                        } = (0, u.createDelayedPromise)(a.FIVE_MINUTES, "Ping request expired without receiving any acknowledgement");
                    this.events.once((0, u.engineEvent)("session_ping", e), ({
                        error: e
                    }) => {
                        e ? n(e) : s()
                    }), await Promise.all([this.sendRequest({
                        topic: t,
                        method: "wc_sessionPing",
                        params: {},
                        throwOnFailedPublish: !0,
                        clientRpcId: e,
                        relayRpcId: i
                    }), r()])
                } else this.client.core.pairing.pairings.keys.includes(t) && (this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."), await this.client.core.pairing.ping({
                    topic: t
                }))
            }, this.emit = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidEmit(e);
                let {
                    topic: t,
                    event: i,
                    chainId: r
                } = e, s = S().toString(), n = I();
                await this.sendRequest({
                    topic: t,
                    method: "wc_sessionEvent",
                    params: {
                        event: i,
                        chainId: r
                    },
                    throwOnFailedPublish: !0,
                    relayRpcId: s,
                    clientRpcId: n
                })
            }, this.disconnect = async e => {
                this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidDisconnect(e);
                let {
                    topic: t
                } = e;
                if (this.client.session.keys.includes(t)) await this.sendRequest({
                    topic: t,
                    method: "wc_sessionDelete",
                    params: (0, u.getSdkError)("USER_DISCONNECTED"),
                    throwOnFailedPublish: !0
                }), await this.deleteSession({
                    topic: t,
                    emitEvent: !1
                });
                else if (this.client.core.pairing.pairings.keys.includes(t)) await this.client.core.pairing.disconnect({
                    topic: t
                });
                else {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISMATCHED_TOPIC", `Session or pairing topic not found: ${t}`);
                    throw Error(e)
                }
            }, this.find = e => (this.isInitialized(), this.client.session.getAll().filter(t => (0, u.isSessionCompatible)(t, e))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (e, t) => {
                let i;
                this.isInitialized(), this.isValidAuthenticate(e);
                let r = t && this.client.core.linkModeSupportedApps.includes(t) && this.client.metadata.redirect ? .linkMode,
                    s = r ? ek : eL;
                s === eL && await this.confirmOnlineStateOrThrow();
                let {
                    chains: n,
                    statement: o = "",
                    uri: a,
                    domain: l,
                    nonce: c,
                    type: h,
                    exp: d,
                    nbf: p,
                    methods: f = [],
                    expiry: g
                } = e, y = [...e.resources || []], {
                    topic: m,
                    uri: b
                } = await this.client.core.pairing.create({
                    methods: ["wc_sessionAuthenticate"],
                    transportType: s
                });
                if (this.client.logger.info({
                        message: "Generated new pairing",
                        pairing: {
                            topic: m,
                            uri: b
                        }
                    }), this.client.auth.authKeys.keys.includes(tb)) {
                    let {
                        responseTopic: e,
                        publicKey: t
                    } = this.client.auth.authKeys.get(tb);
                    e && (await this.client.core.relayer.unsubscribe(e).catch(e => this.client.logger.warn(e)), await this.client.auth.pairingTopics.delete(e, {
                        message: "replaced",
                        code: 0
                    }).catch(e => this.client.logger.warn(e))), t && this.client.core.crypto.keychain.has(t) && await this.client.core.crypto.deleteKeyPair(t)
                }
                let w = await this.client.core.crypto.generateKeyPair(),
                    v = (0, u.hashKey)(w);
                if (await Promise.all([this.client.auth.authKeys.set(tb, {
                        responseTopic: v,
                        publicKey: w
                    }), this.client.auth.pairingTopics.set(v, {
                        topic: v,
                        pairingTopic: m
                    })]), await this.client.core.relayer.subscribe(v, {
                        transportType: s
                    }), this.client.logger.info(`sending request to new pairing topic: ${m}`), f.length > 0) {
                    let {
                        namespace: e
                    } = (0, u.parseChainId)(n[0]), t = (0, u.createEncodedRecap)(e, "request", f);
                    (0, u.getRecapFromResources)(y) && (t = (0, u.mergeEncodedRecaps)(t, y.pop())), y.push(t)
                }
                let E = g && g > tu.wc_sessionAuthenticate.req.ttl ? g : tu.wc_sessionAuthenticate.req.ttl,
                    x = {
                        authPayload: {
                            type: h ? ? "caip122",
                            chains: n,
                            statement: o,
                            aud: a,
                            domain: l,
                            version: "1",
                            nonce: c,
                            iat: new Date().toISOString(),
                            exp: d,
                            nbf: p,
                            resources: y
                        },
                        requester: {
                            publicKey: w,
                            metadata: this.client.metadata
                        },
                        expiryTimestamp: (0, u.calcExpiry)(E)
                    },
                    S = {
                        requiredNamespaces: {},
                        optionalNamespaces: {
                            eip155: {
                                chains: n,
                                methods: [...new Set(["personal_sign", ...f])],
                                events: ["chainChanged", "accountsChanged"]
                            }
                        },
                        relays: [{
                            protocol: "irn"
                        }],
                        pairingTopic: m,
                        proposer: {
                            publicKey: w,
                            metadata: this.client.metadata
                        },
                        expiryTimestamp: (0, u.calcExpiry)(tu.wc_sessionPropose.req.ttl),
                        id: I()
                    },
                    {
                        done: P,
                        resolve: T,
                        reject: A
                    } = (0, u.createDelayedPromise)(E, "Request expired"),
                    O = I(),
                    R = (0, u.engineEvent)("session_connect", S.id),
                    N = (0, u.engineEvent)("session_request", O),
                    U = async ({
                        error: e,
                        session: t
                    }) => {
                        this.events.off(N, C), e ? A(e) : t && T({
                            session: t
                        })
                    },
                    C = async e => {
                        let i;
                        if (await this.deletePendingAuthRequest(O, {
                                message: "fulfilled",
                                code: 0
                            }), e.error) {
                            let t = (0, u.getSdkError)("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate");
                            return e.error.code === t.code ? void 0 : (this.events.off(R, U), A(e.error.message))
                        }
                        await this.deleteProposal(S.id), this.events.off(R, U);
                        let {
                            cacaos: r,
                            responder: n
                        } = e.result, o = [], a = [];
                        for (let e of r) {
                            await (0, u.validateSignedCacao)({
                                cacao: e,
                                projectId: this.client.core.projectId
                            }) || (this.client.logger.error(e, "Signature verification failed"), A((0, u.getSdkError)("SESSION_SETTLEMENT_FAILED", "Signature verification failed")));
                            let {
                                p: t
                            } = e, i = (0, u.getRecapFromResources)(t.resources), r = [(0, u.getNamespacedDidChainId)(t.iss)], s = (0, u.getDidAddress)(t.iss);
                            if (i) {
                                let e = (0, u.getMethodsFromRecap)(i),
                                    t = (0, u.getChainsFromRecap)(i);
                                o.push(...e), r.push(...t)
                            }
                            for (let e of r) a.push(`${e}:${s}`)
                        }
                        let l = await this.client.core.crypto.generateSharedKey(w, n.publicKey);
                        o.length > 0 && (i = {
                            topic: l,
                            acknowledged: !0,
                            self: {
                                publicKey: w,
                                metadata: this.client.metadata
                            },
                            peer: n,
                            controller: n.publicKey,
                            expiry: (0, u.calcExpiry)(th),
                            requiredNamespaces: {},
                            optionalNamespaces: {},
                            relay: {
                                protocol: "irn"
                            },
                            pairingTopic: m,
                            namespaces: (0, u.buildNamespacesFromAuth)([...new Set(o)], [...new Set(a)]),
                            transportType: s
                        }, await this.client.core.relayer.subscribe(l, {
                            transportType: s
                        }), await this.client.session.set(l, i), m && await this.client.core.pairing.updateMetadata({
                            topic: m,
                            metadata: n.metadata
                        }), i = this.client.session.get(l)), this.client.metadata.redirect ? .linkMode && n.metadata.redirect ? .linkMode && n.metadata.redirect ? .universal && t && (this.client.core.addLinkModeSupportedApp(n.metadata.redirect.universal), this.client.session.update(l, {
                            transportType: ek
                        })), T({
                            auths: r,
                            session: i
                        })
                    };
                this.events.once(R, U), this.events.once(N, C);
                try {
                    if (r) {
                        let e = _("wc_sessionAuthenticate", x, O);
                        this.client.core.history.set(m, e);
                        let r = await this.client.core.crypto.encode("", e, {
                            type: u.TYPE_2,
                            encoding: u.BASE64URL
                        });
                        i = (0, u.getLinkModeURL)(t, m, r)
                    } else await Promise.all([this.sendRequest({
                        topic: m,
                        method: "wc_sessionAuthenticate",
                        params: x,
                        expiry: e.expiry,
                        throwOnFailedPublish: !0,
                        clientRpcId: O
                    }), this.sendRequest({
                        topic: m,
                        method: "wc_sessionPropose",
                        params: S,
                        expiry: tu.wc_sessionPropose.req.ttl,
                        throwOnFailedPublish: !0,
                        clientRpcId: S.id
                    })])
                } catch (e) {
                    throw this.events.off(R, U), this.events.off(N, C), e
                }
                return await this.setProposal(S.id, S), await this.setAuthRequest(O, {
                    request: { ...x,
                        verifyContext: {}
                    },
                    pairingTopic: m,
                    transportType: s
                }), {
                    uri: i ? ? b,
                    response: P
                }
            }, this.approveSessionAuthenticate = async e => {
                let t, {
                        id: i,
                        auths: r
                    } = e,
                    s = this.client.core.eventClient.createEvent({
                        properties: {
                            topic: i.toString(),
                            trace: ["authenticated_session_approve_started"]
                        }
                    });
                try {
                    this.isInitialized()
                } catch (e) {
                    throw s.setError("no_internet_connection"), e
                }
                let n = this.getPendingAuthRequest(i);
                if (!n) throw s.setError("authenticated_session_pending_request_not_found"), Error(`Could not find pending auth request with id ${i}`);
                let o = n.transportType || eL;
                o === eL && await this.confirmOnlineStateOrThrow();
                let a = n.requester.publicKey,
                    l = await this.client.core.crypto.generateKeyPair(),
                    c = (0, u.hashKey)(a),
                    h = {
                        type: u.TYPE_1,
                        receiverPublicKey: a,
                        senderPublicKey: l
                    },
                    d = [],
                    p = [];
                for (let e of r) {
                    if (!await (0, u.validateSignedCacao)({
                            cacao: e,
                            projectId: this.client.core.projectId
                        })) {
                        s.setError("invalid_cacao");
                        let e = (0, u.getSdkError)("SESSION_SETTLEMENT_FAILED", "Signature verification failed");
                        throw await this.sendError({
                            id: i,
                            topic: c,
                            error: e,
                            encodeOpts: h
                        }), Error(e.message)
                    }
                    s.addTrace("cacaos_verified");
                    let {
                        p: t
                    } = e, r = (0, u.getRecapFromResources)(t.resources), n = [(0, u.getNamespacedDidChainId)(t.iss)], o = (0, u.getDidAddress)(t.iss);
                    if (r) {
                        let e = (0, u.getMethodsFromRecap)(r),
                            t = (0, u.getChainsFromRecap)(r);
                        d.push(...e), n.push(...t)
                    }
                    for (let e of n) p.push(`${e}:${o}`)
                }
                let f = await this.client.core.crypto.generateSharedKey(l, a);
                if (s.addTrace("create_authenticated_session_topic"), d ? .length > 0) {
                    t = {
                        topic: f,
                        acknowledged: !0,
                        self: {
                            publicKey: l,
                            metadata: this.client.metadata
                        },
                        peer: {
                            publicKey: a,
                            metadata: n.requester.metadata
                        },
                        controller: a,
                        expiry: (0, u.calcExpiry)(th),
                        authentication: r,
                        requiredNamespaces: {},
                        optionalNamespaces: {},
                        relay: {
                            protocol: "irn"
                        },
                        pairingTopic: n.pairingTopic,
                        namespaces: (0, u.buildNamespacesFromAuth)([...new Set(d)], [...new Set(p)]),
                        transportType: o
                    }, s.addTrace("subscribing_authenticated_session_topic");
                    try {
                        await this.client.core.relayer.subscribe(f, {
                            transportType: o
                        })
                    } catch (e) {
                        throw s.setError("subscribe_authenticated_session_topic_failure"), e
                    }
                    s.addTrace("subscribe_authenticated_session_topic_success"), await this.client.session.set(f, t), s.addTrace("store_authenticated_session"), await this.client.core.pairing.updateMetadata({
                        topic: n.pairingTopic,
                        metadata: n.requester.metadata
                    })
                }
                s.addTrace("publishing_authenticated_session_approve");
                try {
                    await this.sendResult({
                        topic: c,
                        id: i,
                        result: {
                            cacaos: r,
                            responder: {
                                publicKey: l,
                                metadata: this.client.metadata
                            }
                        },
                        encodeOpts: h,
                        throwOnFailedPublish: !0,
                        appLink: this.getAppLinkIfEnabled(n.requester.metadata, o)
                    })
                } catch (e) {
                    throw s.setError("authenticated_session_approve_publish_failure"), e
                }
                return await this.client.auth.requests.delete(i, {
                    message: "fulfilled",
                    code: 0
                }), await this.client.core.pairing.activate({
                    topic: n.pairingTopic
                }), this.client.core.eventClient.deleteEvent({
                    eventId: s.eventId
                }), {
                    session: t
                }
            }, this.rejectSessionAuthenticate = async e => {
                this.isInitialized();
                let {
                    id: t,
                    reason: i
                } = e, r = this.getPendingAuthRequest(t);
                if (!r) throw Error(`Could not find pending auth request with id ${t}`);
                r.transportType === eL && await this.confirmOnlineStateOrThrow();
                let s = r.requester.publicKey,
                    n = await this.client.core.crypto.generateKeyPair(),
                    o = (0, u.hashKey)(s),
                    a = {
                        type: u.TYPE_1,
                        receiverPublicKey: s,
                        senderPublicKey: n
                    };
                await this.sendError({
                    id: t,
                    topic: o,
                    error: i,
                    encodeOpts: a,
                    rpcOpts: tu.wc_sessionAuthenticate.reject,
                    appLink: this.getAppLinkIfEnabled(r.requester.metadata, r.transportType)
                }), await this.client.auth.requests.delete(t, {
                    message: "rejected",
                    code: 0
                }), await this.deleteProposal(t)
            }, this.formatAuthMessage = e => {
                this.isInitialized();
                let {
                    request: t,
                    iss: i
                } = e;
                return (0, u.formatMessage)(t, i)
            }, this.processRelayMessageCache = () => {
                setTimeout(async () => {
                    if (0 !== this.relayMessageCache.length)
                        for (; this.relayMessageCache.length > 0;) try {
                            let e = this.relayMessageCache.shift();
                            e && await this.onRelayMessage(e)
                        } catch (e) {
                            this.client.logger.error(e)
                        }
                }, 50)
            }, this.cleanupDuplicatePairings = async e => {
                if (e.pairingTopic) try {
                    let t = this.client.core.pairing.pairings.get(e.pairingTopic),
                        i = this.client.core.pairing.pairings.getAll().filter(i => i.peerMetadata ? .url && i.peerMetadata ? .url === e.peer.metadata.url && i.topic && i.topic !== t.topic);
                    if (0 === i.length) return;
                    this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`), await Promise.all(i.map(e => this.client.core.pairing.disconnect({
                        topic: e.topic
                    }))), this.client.logger.info("Duplicate pairings clean up finished")
                } catch (e) {
                    this.client.logger.error(e)
                }
            }, this.deleteSession = async e => {
                let {
                    topic: t,
                    expirerHasDeleted: i = !1,
                    emitEvent: r = !0,
                    id: s = 0
                } = e, {
                    self: n
                } = this.client.session.get(t);
                await this.client.core.relayer.unsubscribe(t), await this.client.session.delete(t, (0, u.getSdkError)("USER_DISCONNECTED")), this.addToRecentlyDeleted(t, "session"), this.client.core.crypto.keychain.has(n.publicKey) && await this.client.core.crypto.deleteKeyPair(n.publicKey), this.client.core.crypto.keychain.has(t) && await this.client.core.crypto.deleteSymKey(t), i || this.client.core.expirer.del(t), this.client.core.storage.removeItem(tl).catch(e => this.client.logger.warn(e)), t === this.sessionRequestQueue.queue[0] ? .topic && (this.sessionRequestQueue.state = tp), await Promise.all(this.getPendingSessionRequests().filter(e => e.topic === t).map(e => this.deletePendingSessionRequest(e.id, (0, u.getSdkError)("USER_DISCONNECTED")))), r && this.client.events.emit("session_delete", {
                    id: s,
                    topic: t
                })
            }, this.deleteProposal = async (e, t) => {
                if (t) try {
                    let t = this.client.proposal.get(e);
                    this.client.core.eventClient.getEvent({
                        topic: t.pairingTopic
                    }) ? .setError("proposal_expired")
                } catch {}
                await Promise.all([this.client.proposal.delete(e, (0, u.getSdkError)("USER_DISCONNECTED")), t ? Promise.resolve() : this.client.core.expirer.del(e)]), this.addToRecentlyDeleted(e, "proposal")
            }, this.deletePendingSessionRequest = async (e, t, i = !1) => {
                await Promise.all([this.client.pendingRequest.delete(e, t), i ? Promise.resolve() : this.client.core.expirer.del(e)]), this.addToRecentlyDeleted(e, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter(t => t.id !== e), i && (this.sessionRequestQueue.state = tp, this.client.events.emit("session_request_expire", {
                    id: e
                }))
            }, this.deletePendingAuthRequest = async (e, t, i = !1) => {
                await Promise.all([this.client.auth.requests.delete(e, t), i ? Promise.resolve() : this.client.core.expirer.del(e)])
            }, this.setExpiry = async (e, t) => {
                this.client.session.keys.includes(e) && (this.client.core.expirer.set(e, t), await this.client.session.update(e, {
                    expiry: t
                }))
            }, this.setProposal = async (e, t) => {
                this.client.core.expirer.set(e, (0, u.calcExpiry)(tu.wc_sessionPropose.req.ttl)), await this.client.proposal.set(e, t)
            }, this.setAuthRequest = async (e, t) => {
                let {
                    request: i,
                    pairingTopic: r,
                    transportType: s = eL
                } = t;
                this.client.core.expirer.set(e, i.expiryTimestamp), await this.client.auth.requests.set(e, {
                    authPayload: i.authPayload,
                    requester: i.requester,
                    expiryTimestamp: i.expiryTimestamp,
                    id: e,
                    pairingTopic: r,
                    verifyContext: i.verifyContext,
                    transportType: s
                })
            }, this.setPendingSessionRequest = async e => {
                let {
                    id: t,
                    topic: i,
                    params: r,
                    verifyContext: s
                } = e, n = r.request.expiryTimestamp || (0, u.calcExpiry)(tu.wc_sessionRequest.req.ttl);
                this.client.core.expirer.set(t, n), await this.client.pendingRequest.set(t, {
                    id: t,
                    topic: i,
                    params: r,
                    verifyContext: s
                })
            }, this.sendRequest = async t => {
                let i, r, {
                        topic: s,
                        method: n,
                        params: o,
                        expiry: a,
                        relayRpcId: l,
                        clientRpcId: c,
                        throwOnFailedPublish: h,
                        appLink: d,
                        tvf: p,
                        publishOpts: f = {}
                    } = t,
                    g = _(n, o, c),
                    y = !!d;
                try {
                    let e = y ? u.BASE64URL : u.BASE64;
                    i = await this.client.core.crypto.encode(s, g, {
                        encoding: e
                    })
                } catch (e) {
                    throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${s} failed`), e
                }
                if (ty.includes(n)) {
                    let e = (0, u.hashMessage)(JSON.stringify(g)),
                        t = (0, u.hashMessage)(i);
                    r = await this.client.core.verify.register({
                        id: t,
                        decryptedId: e
                    })
                }
                let m = { ...tu[n].req,
                    ...f
                };
                if (m.attestation = r, a && (m.ttl = a), l && (m.id = l), this.client.core.history.set(s, g), y) {
                    let t = (0, u.getLinkModeURL)(d, s, i);
                    await e.g.Linking.openURL(t, this.client.name)
                } else m.tvf = { ...p,
                    correlationId: g.id
                }, h ? (m.internal = { ...m.internal,
                    throwOnFailedPublish: !0
                }, await this.client.core.relayer.publish(s, i, m)) : this.client.core.relayer.publish(s, i, m).catch(e => this.client.logger.error(e));
                return g.id
            }, this.sendProposeSession = async e => {
                let {
                    proposal: t,
                    publishOpts: i
                } = e, r = _("wc_sessionPropose", t, t.id);
                this.client.core.history.set(t.pairingTopic, r);
                let s = await this.client.core.crypto.encode(t.pairingTopic, r, {
                        encoding: u.BASE64
                    }),
                    n = (0, u.hashMessage)(JSON.stringify(r)),
                    o = (0, u.hashMessage)(s),
                    a = await this.client.core.verify.register({
                        id: o,
                        decryptedId: n
                    });
                await this.client.core.relayer.publishCustom({
                    payload: {
                        pairingTopic: t.pairingTopic,
                        sessionProposal: s
                    },
                    opts: { ...i,
                        publishMethod: "wc_proposeSession",
                        attestation: a
                    }
                })
            }, this.sendApproveSession = async e => {
                let {
                    sessionTopic: t,
                    pairingProposalResponse: i,
                    proposal: r,
                    sessionSettleRequest: s,
                    publishOpts: n
                } = e, o = P(r.id, i), a = await this.client.core.crypto.encode(r.pairingTopic, o, {
                    encoding: u.BASE64
                }), l = _("wc_sessionSettle", s, n ? .id), c = await this.client.core.crypto.encode(t, l, {
                    encoding: u.BASE64
                });
                this.client.core.history.set(t, l), await this.client.core.relayer.publishCustom({
                    payload: {
                        sessionTopic: t,
                        pairingTopic: r.pairingTopic,
                        sessionProposalResponse: a,
                        sessionSettlementRequest: c
                    },
                    opts: { ...n,
                        publishMethod: "wc_approveSession"
                    }
                })
            }, this.sendResult = async t => {
                let i, r, s, {
                        id: n,
                        topic: o,
                        result: a,
                        throwOnFailedPublish: l,
                        encodeOpts: c,
                        appLink: h
                    } = t,
                    d = P(n, a),
                    p = h && "u" > typeof e.g ? .Linking;
                try {
                    let e = p ? u.BASE64URL : u.BASE64;
                    i = await this.client.core.crypto.encode(o, d, { ...c || {},
                        encoding: e
                    })
                } catch (e) {
                    throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${o} failed`), e
                }
                try {
                    let e = (r = await this.client.core.history.get(o, n)).request;
                    try {
                        s = this.getTVFParams(n, e.params, a)
                    } catch (e) {
                        this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${e?.message}`)
                    }
                } catch (e) {
                    throw this.client.logger.error(`sendResult() -> history.get(${o}, ${n}) failed`), e
                }
                if (p) {
                    let t = (0, u.getLinkModeURL)(h, o, i);
                    await e.g.Linking.openURL(t, this.client.name)
                } else {
                    let e = tu[r.request.method].res;
                    e.tvf = { ...s,
                        correlationId: n
                    }, l ? (e.internal = { ...e.internal,
                        throwOnFailedPublish: !0
                    }, await this.client.core.relayer.publish(o, i, e)) : this.client.core.relayer.publish(o, i, e).catch(e => this.client.logger.error(e))
                }
                await this.client.core.history.resolve(d)
            }, this.sendError = async t => {
                let i, r, {
                        id: s,
                        topic: n,
                        error: o,
                        encodeOpts: a,
                        rpcOpts: l,
                        appLink: c
                    } = t,
                    h = T(s, o),
                    d = c && "u" > typeof e.g ? .Linking;
                try {
                    let e = d ? u.BASE64URL : u.BASE64;
                    i = await this.client.core.crypto.encode(n, h, { ...a || {},
                        encoding: e
                    })
                } catch (e) {
                    throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`), e
                }
                try {
                    r = await this.client.core.history.get(n, s)
                } catch (e) {
                    throw this.client.logger.error(`sendError() -> history.get(${n}, ${s}) failed`), e
                }
                if (d) {
                    let t = (0, u.getLinkModeURL)(c, n, i);
                    await e.g.Linking.openURL(t, this.client.name)
                } else {
                    let e = r.request.method,
                        t = l || tu[e].res;
                    this.client.core.relayer.publish(n, i, t)
                }
                await this.client.core.history.resolve(h)
            }, this.cleanup = async () => {
                let e = [],
                    t = [];
                this.client.session.getAll().forEach(t => {
                    let i = !1;
                    (0, u.isExpired)(t.expiry) && (i = !0), this.client.core.crypto.keychain.has(t.topic) || (i = !0), i && e.push(t.topic)
                }), this.client.proposal.getAll().forEach(e => {
                    (0, u.isExpired)(e.expiryTimestamp) && t.push(e.id)
                }), await Promise.all([...e.map(e => this.deleteSession({
                    topic: e
                })), ...t.map(e => this.deleteProposal(e))])
            }, this.onProviderMessageEvent = async e => {
                !this.initialized || this.relayMessageCache.length > 0 ? this.relayMessageCache.push(e) : await this.onRelayMessage(e)
            }, this.onRelayEventRequest = async e => {
                this.requestQueue.queue.push(e), await this.processRequestsQueue()
            }, this.processRequestsQueue = async () => {
                if (this.requestQueue.state === tf) return void this.client.logger.info("Request queue already active, skipping...");
                for (this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`); this.requestQueue.queue.length > 0;) {
                    this.requestQueue.state = tf;
                    let e = this.requestQueue.queue.shift();
                    if (e) try {
                        await this.processRequest(e)
                    } catch (e) {
                        this.client.logger.warn(e)
                    }
                }
                this.requestQueue.state = tp
            }, this.processRequest = async e => {
                let {
                    topic: t,
                    payload: i,
                    attestation: r,
                    transportType: s,
                    encryptedId: n
                } = e, o = i.method;
                if (!this.shouldIgnorePairingRequest({
                        topic: t,
                        requestMethod: o
                    })) switch (o) {
                    case "wc_sessionPropose":
                        return await this.onSessionProposeRequest({
                            topic: t,
                            payload: i,
                            attestation: r,
                            encryptedId: n
                        });
                    case "wc_sessionSettle":
                        return await this.onSessionSettleRequest(t, i);
                    case "wc_sessionUpdate":
                        return await this.onSessionUpdateRequest(t, i);
                    case "wc_sessionExtend":
                        return await this.onSessionExtendRequest(t, i);
                    case "wc_sessionPing":
                        return await this.onSessionPingRequest(t, i);
                    case "wc_sessionDelete":
                        return await this.onSessionDeleteRequest(t, i);
                    case "wc_sessionRequest":
                        return await this.onSessionRequest({
                            topic: t,
                            payload: i,
                            attestation: r,
                            encryptedId: n,
                            transportType: s
                        });
                    case "wc_sessionEvent":
                        return await this.onSessionEventRequest(t, i);
                    case "wc_sessionAuthenticate":
                        return await this.onSessionAuthenticateRequest({
                            topic: t,
                            payload: i,
                            attestation: r,
                            encryptedId: n,
                            transportType: s
                        });
                    default:
                        return this.client.logger.info(`Unsupported request method ${o}`)
                }
            }, this.onRelayEventResponse = async e => {
                let {
                    topic: t,
                    payload: i,
                    transportType: r
                } = e, s = (await this.client.core.history.get(t, i.id)).request.method;
                switch (s) {
                    case "wc_sessionPropose":
                        return this.onSessionProposeResponse(t, i, r);
                    case "wc_sessionSettle":
                        return this.onSessionSettleResponse(t, i);
                    case "wc_sessionUpdate":
                        return this.onSessionUpdateResponse(t, i);
                    case "wc_sessionExtend":
                        return this.onSessionExtendResponse(t, i);
                    case "wc_sessionPing":
                        return this.onSessionPingResponse(t, i);
                    case "wc_sessionRequest":
                        return this.onSessionRequestResponse(t, i);
                    case "wc_sessionAuthenticate":
                        return this.onSessionAuthenticateResponse(t, i);
                    default:
                        return this.client.logger.info(`Unsupported response method ${s}`)
                }
            }, this.onRelayEventUnknownPayload = e => {
                let {
                    topic: t
                } = e, {
                    message: i
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);
                throw Error(i)
            }, this.shouldIgnorePairingRequest = e => {
                let {
                    topic: t,
                    requestMethod: i
                } = e, r = this.expectedPairingMethodMap.get(t);
                return !(!r || r.includes(i)) && !!(r.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0)
            }, this.onSessionProposeRequest = async e => {
                let {
                    topic: t,
                    payload: i,
                    attestation: r,
                    encryptedId: s
                } = e, {
                    params: n,
                    id: o
                } = i;
                try {
                    let e = this.client.core.eventClient.getEvent({
                        topic: t
                    });
                    0 === this.client.events.listenerCount("session_proposal") && (console.warn("No listener for session_proposal event"), e ? .setError("proposal_listener_not_found")), this.isValidConnect({ ...i.params
                    });
                    let a = n.expiryTimestamp || (0, u.calcExpiry)(tu.wc_sessionPropose.req.ttl),
                        l = {
                            id: o,
                            pairingTopic: t,
                            expiryTimestamp: a,
                            attestation: r,
                            encryptedId: s,
                            ...n
                        };
                    await this.setProposal(o, l);
                    let c = await this.getVerifyContext({
                        attestationId: r,
                        hash: (0, u.hashMessage)(JSON.stringify(i)),
                        encryptedId: s,
                        metadata: l.proposer.metadata
                    });
                    e ? .addTrace("emit_session_proposal"), this.client.events.emit("session_proposal", {
                        id: o,
                        params: l,
                        verifyContext: c
                    })
                } catch (e) {
                    await this.sendError({
                        id: o,
                        topic: t,
                        error: e,
                        rpcOpts: tu.wc_sessionPropose.autoReject
                    }), this.client.logger.error(e)
                }
            }, this.onSessionProposeResponse = async (e, t, i) => {
                let {
                    id: r
                } = t;
                if (N(t)) {
                    let {
                        result: s
                    } = t;
                    this.client.logger.trace({
                        type: "method",
                        method: "onSessionProposeResponse",
                        result: s
                    });
                    let n = this.client.proposal.get(r);
                    this.client.logger.trace({
                        type: "method",
                        method: "onSessionProposeResponse",
                        proposal: n
                    });
                    let o = n.proposer.publicKey;
                    this.client.logger.trace({
                        type: "method",
                        method: "onSessionProposeResponse",
                        selfPublicKey: o
                    });
                    let a = s.responderPublicKey;
                    this.client.logger.trace({
                        type: "method",
                        method: "onSessionProposeResponse",
                        peerPublicKey: a
                    });
                    let l = await this.client.core.crypto.generateSharedKey(o, a);
                    this.pendingSessions.set(r, {
                        sessionTopic: l,
                        pairingTopic: e,
                        proposalId: r,
                        publicKey: o
                    });
                    let c = await this.client.core.relayer.subscribe(l, {
                        transportType: i
                    });
                    this.client.logger.trace({
                        type: "method",
                        method: "onSessionProposeResponse",
                        subscriptionId: c
                    }), await this.client.core.pairing.activate({
                        topic: e
                    })
                } else if (U(t)) {
                    await this.deleteProposal(r);
                    let e = (0, u.engineEvent)("session_connect", r);
                    if (0 === this.events.listenerCount(e)) throw Error(`emitting ${e} without any listeners, 954`);
                    this.events.emit(e, {
                        error: t.error
                    })
                }
            }, this.onSessionSettleRequest = async (e, t) => {
                let {
                    id: i,
                    params: r
                } = t;
                try {
                    this.isValidSessionSettleRequest(r);
                    let {
                        relay: i,
                        controller: s,
                        expiry: n,
                        namespaces: o,
                        sessionProperties: a,
                        scopedProperties: l,
                        sessionConfig: c,
                        proposalRequestsResponses: h
                    } = t.params, d = [...this.pendingSessions.values()].find(t => t.sessionTopic === e);
                    if (!d) return this.client.logger.error(`Pending session not found for topic ${e}`);
                    let p = this.client.proposal.get(d.proposalId),
                        f = {
                            topic: e,
                            relay: i,
                            expiry: n,
                            namespaces: o,
                            acknowledged: !0,
                            pairingTopic: d.pairingTopic,
                            requiredNamespaces: p.requiredNamespaces,
                            optionalNamespaces: p.optionalNamespaces,
                            controller: s.publicKey,
                            self: {
                                publicKey: d.publicKey,
                                metadata: this.client.metadata
                            },
                            peer: {
                                publicKey: s.publicKey,
                                metadata: s.metadata
                            },
                            ...a && {
                                sessionProperties: a
                            },
                            ...l && {
                                scopedProperties: l
                            },
                            ...c && {
                                sessionConfig: c
                            },
                            transportType: eL,
                            authentication: h ? .authentication,
                            walletPayResult: h ? .walletPay
                        };
                    await this.client.session.set(f.topic, f), await this.setExpiry(f.topic, f.expiry), await this.client.core.pairing.updateMetadata({
                        topic: d.pairingTopic,
                        metadata: f.peer.metadata
                    }), this.pendingSessions.delete(d.proposalId), this.deleteProposal(d.proposalId, !1), this.cleanupDuplicatePairings(f), await this.sendResult({
                        id: t.id,
                        topic: e,
                        throwOnFailedPublish: !0,
                        result: !0
                    }), this.client.events.emit("session_connect", {
                        session: f
                    }), this.events.emit((0, u.engineEvent)("session_connect", d.proposalId), {
                        session: f
                    })
                } catch (t) {
                    await this.sendError({
                        id: i,
                        topic: e,
                        error: t
                    }), this.client.logger.error(t)
                }
            }, this.onSessionSettleResponse = async (e, t) => {
                let {
                    id: i
                } = t;
                N(t) ? (await this.client.session.update(e, {
                    acknowledged: !0
                }), this.events.emit((0, u.engineEvent)("session_approve", i), {})) : U(t) && (await this.deleteSession({
                    topic: e,
                    emitEvent: !1
                }), this.events.emit((0, u.engineEvent)("session_approve", i), {
                    error: t.error
                }))
            }, this.onSessionUpdateRequest = async (e, t) => {
                let {
                    params: i,
                    id: r
                } = t;
                try {
                    let t = `${e}_session_update`,
                        s = u.MemoryStore.get(t);
                    if (s && this.isRequestOutOfSync(s, r)) {
                        this.client.logger.warn(`Discarding out of sync request - ${r}`), this.sendError({
                            id: r,
                            topic: e,
                            error: (0, u.getSdkError)("INVALID_UPDATE_REQUEST")
                        });
                        return
                    }
                    this.isValidUpdate({
                        topic: e,
                        ...i
                    });
                    try {
                        u.MemoryStore.set(t, r), await this.client.session.update(e, {
                            namespaces: i.namespaces
                        }), await this.sendResult({
                            id: r,
                            topic: e,
                            result: !0
                        })
                    } catch (e) {
                        throw u.MemoryStore.delete(t), e
                    }
                    this.client.events.emit("session_update", {
                        id: r,
                        topic: e,
                        params: i
                    })
                } catch (t) {
                    await this.sendError({
                        id: r,
                        topic: e,
                        error: t
                    }), this.client.logger.error(t)
                }
            }, this.isRequestOutOfSync = (e, t) => t.toString().slice(0, -3) < e.toString().slice(0, -3), this.onSessionUpdateResponse = (e, t) => {
                let {
                    id: i
                } = t, r = (0, u.engineEvent)("session_update", i);
                if (0 === this.events.listenerCount(r)) throw Error(`emitting ${r} without any listeners`);
                N(t) ? this.events.emit((0, u.engineEvent)("session_update", i), {}) : U(t) && this.events.emit((0, u.engineEvent)("session_update", i), {
                    error: t.error
                })
            }, this.onSessionExtendRequest = async (e, t) => {
                let {
                    id: i
                } = t;
                try {
                    this.isValidExtend({
                        topic: e
                    }), await this.setExpiry(e, (0, u.calcExpiry)(th)), await this.sendResult({
                        id: i,
                        topic: e,
                        result: !0
                    }), this.client.events.emit("session_extend", {
                        id: i,
                        topic: e
                    })
                } catch (t) {
                    await this.sendError({
                        id: i,
                        topic: e,
                        error: t
                    }), this.client.logger.error(t)
                }
            }, this.onSessionExtendResponse = (e, t) => {
                let {
                    id: i
                } = t, r = (0, u.engineEvent)("session_extend", i);
                if (0 === this.events.listenerCount(r)) throw Error(`emitting ${r} without any listeners`);
                N(t) ? this.events.emit((0, u.engineEvent)("session_extend", i), {}) : U(t) && this.events.emit((0, u.engineEvent)("session_extend", i), {
                    error: t.error
                })
            }, this.onSessionPingRequest = async (e, t) => {
                let {
                    id: i
                } = t;
                try {
                    this.isValidPing({
                        topic: e
                    }), await this.sendResult({
                        id: i,
                        topic: e,
                        result: !0,
                        throwOnFailedPublish: !0
                    }), this.client.events.emit("session_ping", {
                        id: i,
                        topic: e
                    })
                } catch (t) {
                    await this.sendError({
                        id: i,
                        topic: e,
                        error: t
                    }), this.client.logger.error(t)
                }
            }, this.onSessionPingResponse = (e, t) => {
                let {
                    id: i
                } = t, r = (0, u.engineEvent)("session_ping", i);
                setTimeout(() => {
                    if (0 === this.events.listenerCount(r)) throw Error(`emitting ${r} without any listeners 2176`);
                    N(t) ? this.events.emit((0, u.engineEvent)("session_ping", i), {}) : U(t) && this.events.emit((0, u.engineEvent)("session_ping", i), {
                        error: t.error
                    })
                }, 500)
            }, this.onSessionDeleteRequest = async (e, t) => {
                let {
                    id: i
                } = t;
                try {
                    await this.isValidDisconnect({
                        topic: e,
                        reason: t.params
                    }), this.cleanupPendingSentRequestsForTopic({
                        topic: e,
                        error: (0, u.getSdkError)("USER_DISCONNECTED")
                    }), await this.deleteSession({
                        topic: e,
                        id: i
                    })
                } catch (e) {
                    this.client.logger.error(e)
                }
            }, this.onSessionRequest = async e => {
                let {
                    topic: t,
                    payload: i,
                    attestation: r,
                    encryptedId: s,
                    transportType: n
                } = e, {
                    id: o,
                    params: a
                } = i;
                try {
                    await this.isValidRequest({
                        topic: t,
                        ...a
                    });
                    let e = this.client.session.get(t),
                        i = await this.getVerifyContext({
                            attestationId: r,
                            hash: (0, u.hashMessage)(JSON.stringify(_("wc_sessionRequest", a, o))),
                            encryptedId: s,
                            metadata: e.peer.metadata,
                            transportType: n
                        }),
                        l = {
                            id: o,
                            topic: t,
                            params: a,
                            verifyContext: i
                        };
                    await this.setPendingSessionRequest(l), n === ek && e.peer.metadata.redirect ? .universal && this.client.core.addLinkModeSupportedApp(e.peer.metadata.redirect ? .universal), this.client.signConfig ? .disableRequestQueue ? this.emitSessionRequest(l) : (this.addSessionRequestToSessionRequestQueue(l), this.processSessionRequestQueue())
                } catch (e) {
                    await this.sendError({
                        id: o,
                        topic: t,
                        error: e
                    }), this.client.logger.error(e)
                }
            }, this.onSessionRequestResponse = (e, t) => {
                let {
                    id: i
                } = t, r = (0, u.engineEvent)("session_request", i);
                if (0 === this.events.listenerCount(r)) throw Error(`emitting ${r} without any listeners`);
                N(t) ? this.events.emit((0, u.engineEvent)("session_request", i), {
                    result: t.result
                }) : U(t) && this.events.emit((0, u.engineEvent)("session_request", i), {
                    error: t.error
                })
            }, this.onSessionEventRequest = async (e, t) => {
                let {
                    id: i,
                    params: r
                } = t;
                try {
                    let t = `${e}_session_event_${r.event.name}`,
                        s = u.MemoryStore.get(t);
                    if (s && this.isRequestOutOfSync(s, i)) return void this.client.logger.info(`Discarding out of sync request - ${i}`);
                    this.isValidEmit({
                        topic: e,
                        ...r
                    }), this.client.events.emit("session_event", {
                        id: i,
                        topic: e,
                        params: r
                    }), u.MemoryStore.set(t, i)
                } catch (t) {
                    await this.sendError({
                        id: i,
                        topic: e,
                        error: t
                    }), this.client.logger.error(t)
                }
            }, this.onSessionAuthenticateResponse = (e, t) => {
                let {
                    id: i
                } = t;
                this.client.logger.trace({
                    type: "method",
                    method: "onSessionAuthenticateResponse",
                    topic: e,
                    payload: t
                }), N(t) ? this.events.emit((0, u.engineEvent)("session_request", i), {
                    result: t.result
                }) : U(t) && this.events.emit((0, u.engineEvent)("session_request", i), {
                    error: t.error
                })
            }, this.onSessionAuthenticateRequest = async e => {
                let {
                    topic: t,
                    payload: i,
                    attestation: r,
                    encryptedId: s,
                    transportType: n
                } = e;
                try {
                    let {
                        requester: e,
                        authPayload: o,
                        expiryTimestamp: a
                    } = i.params, l = await this.getVerifyContext({
                        attestationId: r,
                        hash: (0, u.hashMessage)(JSON.stringify(i)),
                        encryptedId: s,
                        metadata: e.metadata,
                        transportType: n
                    }), c = {
                        requester: e,
                        pairingTopic: t,
                        id: i.id,
                        authPayload: o,
                        verifyContext: l,
                        expiryTimestamp: a
                    };
                    await this.setAuthRequest(i.id, {
                        request: c,
                        pairingTopic: t,
                        transportType: n
                    }), n === ek && e.metadata.redirect ? .universal && this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal), this.client.events.emit("session_authenticate", {
                        topic: t,
                        params: i.params,
                        id: i.id,
                        verifyContext: l
                    })
                } catch (a) {
                    this.client.logger.error(a);
                    let e = i.params.requester.publicKey,
                        r = await this.client.core.crypto.generateKeyPair(),
                        s = this.getAppLinkIfEnabled(i.params.requester.metadata, n),
                        o = {
                            type: u.TYPE_1,
                            receiverPublicKey: e,
                            senderPublicKey: r
                        };
                    await this.sendError({
                        id: i.id,
                        topic: t,
                        error: a,
                        encodeOpts: o,
                        rpcOpts: tu.wc_sessionAuthenticate.autoReject,
                        appLink: s
                    })
                }
            }, this.addSessionRequestToSessionRequestQueue = e => {
                this.sessionRequestQueue.queue.push(e)
            }, this.cleanupAfterResponse = e => {
                this.deletePendingSessionRequest(e.response.id, {
                    message: "fulfilled",
                    code: 0
                }), setTimeout(() => {
                    this.sessionRequestQueue.state = tp, this.processSessionRequestQueue()
                }, (0, a.toMiliseconds)(this.requestQueueDelay))
            }, this.cleanupPendingSentRequestsForTopic = ({
                topic: e,
                error: t
            }) => {
                let i = this.client.core.history.pending;
                i.length > 0 && i.filter(t => t.topic === e && "wc_sessionRequest" === t.request.method).forEach(e => {
                    this.events.emit((0, u.engineEvent)("session_request", e.request.id), {
                        error: t
                    })
                })
            }, this.processSessionRequestQueue = () => {
                if (this.sessionRequestQueue.state === tf) return void this.client.logger.info("session request queue is already active.");
                let e = this.sessionRequestQueue.queue[0];
                if (!e) return void this.client.logger.info("session request queue is empty.");
                try {
                    this.emitSessionRequest(e)
                } catch (e) {
                    this.client.logger.error(e)
                }
            }, this.emitSessionRequest = e => {
                this.emittedSessionRequests.has(e.id) ? this.client.logger.warn({
                    id: e.id
                }, `Skipping emitting \`session_request\` event for duplicate request. id: ${e.id}`) : (this.sessionRequestQueue.state = tf, this.emittedSessionRequests.add(e.id), this.client.events.emit("session_request", e))
            }, this.cleanupInProgress = !1, this.cleanupOrphanedSubscriptions = async () => {
                let e, t = this.client.core.relayer.subscriber.topics;
                if (0 === t.length) return;
                let i = new Set(this.client.session.keys),
                    r = new Set(this.client.core.pairing.pairings.keys),
                    s = new Set([...this.pendingSessions.values()].map(e => e.sessionTopic));
                if (this.client.auth.authKeys.keys.includes(tb)) {
                    let {
                        responseTopic: t
                    } = this.client.auth.authKeys.get(tb);
                    e = t
                }
                for (let n of t)
                    if (!i.has(n) && !r.has(n) && !s.has(n) && n !== e) {
                        this.client.logger.info(`Cleaning up orphaned subscriber topic: ${n}`);
                        try {
                            await this.client.core.relayer.subscriber.unsubscribe(n)
                        } catch (e) {
                            this.client.logger.warn(e, `Failed to clean up orphaned subscription: ${n}`)
                        }
                    }
            }, this.onPairingCreated = e => {
                if (e.methods && this.expectedPairingMethodMap.set(e.topic, e.methods), e.active) return;
                let t = this.client.proposal.getAll().find(t => t.pairingTopic === e.topic);
                t && this.onSessionProposeRequest({
                    topic: e.topic,
                    payload: _("wc_sessionPropose", { ...t,
                        requiredNamespaces: t.requiredNamespaces,
                        optionalNamespaces: t.optionalNamespaces,
                        relays: t.relays,
                        proposer: t.proposer,
                        sessionProperties: t.sessionProperties,
                        scopedProperties: t.scopedProperties
                    }, t.id),
                    attestation: t.attestation,
                    encryptedId: t.encryptedId
                })
            }, this.isValidConnect = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e)}`);
                    throw Error(t)
                }
                let {
                    pairingTopic: t,
                    requiredNamespaces: i,
                    optionalNamespaces: r,
                    sessionProperties: s,
                    scopedProperties: n,
                    relays: o
                } = e;
                if ((0, u.isUndefined)(t) || await this.isValidPairingTopic(t), !(0, u.isValidRelays)(o, !0)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `connect() relays: ${o}`);
                    throw Error(e)
                }
                if (i && !(0, u.isUndefined)(i) && 0 !== (0, u.isValidObject)(i)) {
                    let e = "requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";
                    ["fatal", "error", "silent"].includes(this.client.logger.level) ? console.warn(e) : this.client.logger.warn(e), this.validateNamespaces(i, "requiredNamespaces")
                }
                if (r && !(0, u.isUndefined)(r) && 0 !== (0, u.isValidObject)(r) && this.validateNamespaces(r, "optionalNamespaces"), s && !(0, u.isUndefined)(s) && this.validateSessionProps(s, "sessionProperties"), n && !(0, u.isUndefined)(n)) {
                    this.validateSessionProps(n, "scopedProperties");
                    let e = Object.keys(i || {}).concat(Object.keys(r || {}));
                    if (!Object.keys(n).every(t => e.includes(t.split(":")[0]))) throw Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(e)}`)
                }
            }, this.validateNamespaces = (e, t) => {
                let i = (0, u.isValidRequiredNamespaces)(e, "connect()", t);
                if (i) throw Error(i.message)
            }, this.isValidApprove = async e => {
                if (!(0, u.isValidParams)(e)) throw Error((0, u.getInternalError)("MISSING_OR_INVALID", `approve() params: ${e}`).message);
                let {
                    id: t,
                    namespaces: i,
                    relayProtocol: r,
                    sessionProperties: s,
                    scopedProperties: n
                } = e;
                this.checkRecentlyDeleted(t), await this.isValidProposalId(t);
                let o = this.client.proposal.get(t),
                    a = (0, u.isValidNamespaces)(i, "approve()");
                if (a) throw Error(a.message);
                let l = (0, u.isConformingNamespaces)(o.requiredNamespaces, i, "approve()");
                if (l) throw Error(l.message);
                if (!(0, u.isValidString)(r, !0)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `approve() relayProtocol: ${r}`);
                    throw Error(e)
                }
                if (s && !(0, u.isUndefined)(s) && this.validateSessionProps(s, "sessionProperties"), n && !(0, u.isUndefined)(n)) {
                    this.validateSessionProps(n, "scopedProperties");
                    let e = new Set(Object.keys(i));
                    if (!Object.keys(n).every(t => e.has(t.split(":")[0]))) throw Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)
                }
            }, this.isValidReject = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `reject() params: ${e}`);
                    throw Error(t)
                }
                let {
                    id: t,
                    reason: i
                } = e;
                if (this.checkRecentlyDeleted(t), await this.isValidProposalId(t), !(0, u.isValidErrorReason)(i)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(i)}`);
                    throw Error(e)
                }
            }, this.isValidSessionSettleRequest = e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e}`);
                    throw Error(t)
                }
                let {
                    relay: t,
                    controller: i,
                    namespaces: r,
                    expiry: s
                } = e;
                if (!(0, u.isValidRelay)(t)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string");
                    throw Error(e)
                }
                let n = (0, u.isValidController)(i, "onSessionSettleRequest()");
                if (n) throw Error(n.message);
                let o = (0, u.isValidNamespaces)(r, "onSessionSettleRequest()");
                if (o) throw Error(o.message);
                if ((0, u.isExpired)(s)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("EXPIRED", "onSessionSettleRequest()");
                    throw Error(e)
                }
            }, this.isValidUpdate = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `update() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t,
                    namespaces: i
                } = e;
                this.checkRecentlyDeleted(t), await this.isValidSessionTopic(t);
                let r = this.client.session.get(t),
                    s = (0, u.isValidNamespaces)(i, "update()");
                if (s) throw Error(s.message);
                let n = (0, u.isConformingNamespaces)(r.requiredNamespaces, i, "update()");
                if (n) throw Error(n.message)
            }, this.isValidExtend = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `extend() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t
                } = e;
                this.checkRecentlyDeleted(t), await this.isValidSessionTopic(t)
            }, this.isValidRequest = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `request() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t,
                    request: i,
                    chainId: r,
                    expiry: s
                } = e;
                this.checkRecentlyDeleted(t), await this.isValidSessionTopic(t);
                let {
                    namespaces: n
                } = this.client.session.get(t);
                if (!(0, u.isValidNamespacesChainId)(n, r)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `request() chainId: ${r}`);
                    throw Error(e)
                }
                if (!(0, u.isValidRequest)(i)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `request() ${JSON.stringify(i)}`);
                    throw Error(e)
                }
                if (!(0, u.isValidNamespacesRequest)(n, r, i.method)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `request() method: ${i.method}`);
                    throw Error(e)
                }
                this.validateRequestExpiry(s)
            }, this.isValidRespond = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `respond() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t,
                    response: i
                } = e;
                try {
                    await this.isValidSessionTopic(t)
                } catch (t) {
                    throw e ? .response ? .id && this.cleanupAfterResponse(e), t
                }
                if (!(0, u.isValidResponse)(i)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i)}`);
                    throw Error(e)
                }
                let r = this.client.pendingRequest.get(i.id);
                if (r.topic !== t) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISMATCHED_TOPIC", `Request response topic mismatch. reqId: ${i.id}, expected topic: ${r.topic}, received topic: ${t}`);
                    throw Error(e)
                }
            }, this.isValidPing = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `ping() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t
                } = e;
                await this.isValidSessionOrPairingTopic(t)
            }, this.isValidEmit = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `emit() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t,
                    event: i,
                    chainId: r
                } = e;
                await this.isValidSessionTopic(t);
                let {
                    namespaces: s
                } = this.client.session.get(t);
                if (!(0, u.isValidNamespacesChainId)(s, r)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `emit() chainId: ${r}`);
                    throw Error(e)
                }
                if (!(0, u.isValidEvent)(i) || !(0, u.isValidNamespacesEvent)(s, r, i.name)) {
                    let {
                        message: e
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(i)}`);
                    throw Error(e)
                }
            }, this.isValidDisconnect = async e => {
                if (!(0, u.isValidParams)(e)) {
                    let {
                        message: t
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `disconnect() params: ${e}`);
                    throw Error(t)
                }
                let {
                    topic: t
                } = e;
                await this.isValidSessionOrPairingTopic(t)
            }, this.isValidAuthenticate = e => {
                let {
                    chains: t,
                    uri: i,
                    domain: r,
                    nonce: s
                } = e;
                if (!Array.isArray(t) || 0 === t.length) throw Error("chains is required and must be a non-empty array");
                if (!(0, u.isValidString)(i, !1)) throw Error("uri is required parameter");
                if (!(0, u.isValidString)(r, !1)) throw Error("domain is required parameter");
                if (!(0, u.isValidString)(s, !1)) throw Error("nonce is required parameter");
                if ([...new Set(t.map(e => (0, u.parseChainId)(e).namespace))].length > 1) throw Error("Multi-namespace requests are not supported. Please request single namespace only.");
                let {
                    namespace: n
                } = (0, u.parseChainId)(t[0]);
                if ("eip155" !== n) throw Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")
            }, this.getVerifyContext = async e => {
                let {
                    attestationId: t,
                    hash: i,
                    encryptedId: r,
                    metadata: s,
                    transportType: n
                } = e, o = {
                    verified: {
                        verifyUrl: s.verifyUrl || eY,
                        validation: "UNKNOWN",
                        origin: s.url || ""
                    }
                };
                try {
                    if (n === ek) {
                        let e = this.getAppLinkIfEnabled(s, n);
                        return o.verified.validation = e && new URL(e).origin === new URL(s.url).origin ? "VALID" : "INVALID", o
                    }
                    let e = await this.client.core.verify.resolve({
                        attestationId: t,
                        hash: i,
                        encryptedId: r,
                        verifyUrl: s.verifyUrl
                    });
                    e && (o.verified.origin = e.origin, o.verified.isScam = e.isScam, o.verified.validation = e.origin === new URL(s.url).origin ? "VALID" : "INVALID")
                } catch (e) {
                    this.client.logger.warn(e)
                }
                return this.client.logger.debug(`Verify context: ${JSON.stringify(o)}`), o
            }, this.validateSessionProps = (e, t) => {
                Object.values(e).forEach((i, r) => {
                    if (null == i) {
                        let {
                            message: s
                        } = (0, u.getInternalError)("MISSING_OR_INVALID", `${t} must contain an existing value for each key. Received: ${i} for key ${Object.keys(e)[r]}`);
                        throw Error(s)
                    }
                })
            }, this.getPendingAuthRequest = e => {
                let t = this.client.auth.requests.get(e);
                return "object" == typeof t ? t : void 0
            }, this.addToRecentlyDeleted = (e, t) => {
                if (this.recentlyDeletedMap.set(e, t), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) {
                    let e = 0,
                        t = this.recentlyDeletedLimit / 2;
                    for (let i of this.recentlyDeletedMap.keys()) {
                        if (e++ >= t) break;
                        this.recentlyDeletedMap.delete(i)
                    }
                }
            }, this.checkRecentlyDeleted = e => {
                let t = this.recentlyDeletedMap.get(e);
                if (t) {
                    let {
                        message: i
                    } = (0, u.getInternalError)("MISSING_OR_INVALID", `Record was recently deleted - ${t}: ${e}`);
                    throw Error(i)
                }
            }, this.isLinkModeEnabled = (t, i) => !!t && i === ek && this.client.metadata ? .redirect ? .linkMode === !0 && this.client.metadata ? .redirect ? .universal !== void 0 && this.client.metadata ? .redirect ? .universal !== "" && t ? .redirect ? .universal !== void 0 && t ? .redirect ? .universal !== "" && t ? .redirect ? .linkMode === !0 && this.client.core.linkModeSupportedApps.includes(t.redirect.universal) && "u" > typeof e.g ? .Linking, this.getAppLinkIfEnabled = (e, t) => this.isLinkModeEnabled(e, t) ? e ? .redirect ? .universal : void 0, this.handleLinkModeMessage = ({
                url: e
            }) => {
                if (!e || !e.includes("wc_ev") || !e.includes("topic")) return;
                let t = (0, u.getSearchParamFromURL)(e, "topic") || "",
                    i = decodeURIComponent((0, u.getSearchParamFromURL)(e, "wc_ev") || ""),
                    r = this.client.session.keys.includes(t);
                r && this.client.session.update(t, {
                    transportType: ek
                }), this.client.core.dispatchEnvelope({
                    topic: t,
                    message: i,
                    sessionExists: r
                })
            }, this.registerLinkModeListeners = async () => {
                if ((0, u.isTestRun)() || (0, u.isReactNative)() && this.client.metadata.redirect ? .linkMode) {
                    let t = e.g ? .Linking;
                    if ("u" > typeof t) {
                        t.addEventListener("url", this.handleLinkModeMessage, this.client.name);
                        let e = await t.getInitialURL();
                        e && setTimeout(() => {
                            this.handleLinkModeMessage({
                                url: e
                            })
                        }, 50)
                    }
                }
            }, this.getTVFApproveParams = e => {
                try {
                    let t = (0, u.getNamespacesChains)(e.namespaces),
                        i = (0, u.getNamespacesMethods)(e.namespaces),
                        r = (0, u.getNamespacesEvents)(e.namespaces),
                        s = e.sessionProperties,
                        n = e.scopedProperties;
                    return {
                        approvedChains: t,
                        approvedMethods: i,
                        approvedEvents: r,
                        sessionProperties: s,
                        scopedProperties: n
                    }
                } catch (e) {
                    return this.client.logger.warn(e, "Error getting TVF approve params"), {}
                }
            }, this.getTVFParams = (e, t, i) => {
                if (!t.request ? .method) return {};
                let r = {
                    correlationId: e,
                    rpcMethods: [t.request.method],
                    chainId: t.chainId
                };
                try {
                    r.txHashes = this.extractTxHashesFromResult(t.request, i), r.contractAddresses = this.isValidContractData(t.request.params) ? [t.request.params ? .[0] ? .to] : []
                } catch (e) {
                    this.client.logger.warn(e, "Error getting TVF params")
                }
                return r
            }, this.isValidContractData = e => {
                if (!e) return !1;
                try {
                    let t = e ? .data || e ? .[0] ? .data;
                    if (!t.startsWith("0x")) return !1;
                    let i = t.slice(2);
                    return !!/^[0-9a-fA-F]*$/.test(i) && i.length % 2 == 0
                } catch {}
                return !1
            }, this.extractTxHashesFromResult = (e, t) => {
                try {
                    if (!t) return [];
                    let i = e.method,
                        r = tg[i];
                    if ("sui_signTransaction" === i) return [(0, u.getSuiDigest)(t.transactionBytes)];
                    if ("near_signTransaction" === i) return [(0, u.getNearTransactionIdFromSignedTransaction)(t)];
                    if ("near_signTransactions" === i) return t.map(e => (0, u.getNearTransactionIdFromSignedTransaction)(e));
                    if ("xrpl_signTransactionFor" === i || "xrpl_signTransaction" === i) return [t.tx_json ? .hash];
                    if ("polkadot_signTransaction" === i) return [(0, u.buildSignedExtrinsicHash)({
                        transaction: e.params.transactionPayload,
                        signature: t.signature
                    })];
                    if ("algo_signTxn" === i) return (0, u.isValidArray)(t) ? t.map(e => (0, u.getAlgorandTransactionId)(e)) : [(0, u.getAlgorandTransactionId)(t)];
                    if ("cosmos_signDirect" === i) return [(0, u.getSignDirectHash)(t)];
                    if ("wallet_sendCalls" === i) return (0, u.getWalletSendCallsHashes)(t);
                    if ("string" == typeof t) return [t];
                    let s = t[r.key];
                    if ((0, u.isValidArray)(s)) return "solana_signAllTransactions" === i ? s.map(e => (0, u.extractSolanaTransactionId)(e)) : s;
                    if ("string" == typeof s) return [s]
                } catch (e) {
                    this.client.logger.warn(e, "Error extracting tx hashes from result")
                }
                return []
            }
        }
        async processPendingMessageEvents() {
            try {
                let e = this.client.session.keys,
                    t = this.client.core.relayer.messages.getWithoutAck(e);
                for (let [e, i] of Object.entries(t))
                    for (let t of i) try {
                        await this.onProviderMessageEvent({
                            topic: e,
                            message: t,
                            publishedAt: Date.now()
                        })
                    } catch {
                        this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)
                    }
            } catch (e) {
                this.client.logger.warn(e, "processPendingMessageEvents failed")
            }
        }
        isInitialized() {
            if (!this.initialized) {
                let {
                    message: e
                } = (0, u.getInternalError)("NOT_INITIALIZED", this.name);
                throw Error(e)
            }
        }
        async confirmOnlineStateOrThrow() {
            await this.client.core.relayer.confirmOnlineStateOrThrow()
        }
        registerRelayerEvents() {
            this.client.core.relayer.on(e_, e => {
                this.onProviderMessageEvent(e)
            })
        }
        async onRelayMessage(e) {
            let {
                topic: t,
                message: i,
                attestation: r,
                transportType: s
            } = e, {
                publicKey: n
            } = this.client.auth.authKeys.keys.includes(tb) ? this.client.auth.authKeys.get(tb) : {
                publicKey: void 0
            };
            try {
                let e = await this.client.core.crypto.decode(t, i, {
                    receiverPublicKey: n,
                    encoding: s === ek ? u.BASE64URL : u.BASE64
                });
                O(e) ? (this.client.core.history.set(t, e), await this.onRelayEventRequest({
                    topic: t,
                    payload: e,
                    attestation: r,
                    transportType: s,
                    encryptedId: (0, u.hashMessage)(i)
                })) : R(e) ? (await this.client.core.history.resolve(e), await this.onRelayEventResponse({
                    topic: t,
                    payload: e,
                    transportType: s
                }), this.client.core.history.delete(t, e.id)) : (this.client.logger.error(`onRelayMessage() -> unknown payload: ${JSON.stringify(e)}`), await this.onRelayEventUnknownPayload({
                    topic: t,
                    payload: e,
                    transportType: s
                })), await this.client.core.relayer.messages.ack(t, i)
            } catch (e) {
                this.client.logger.error(`onRelayMessage() -> failed to process an inbound message: ${i}`), this.client.logger.error(e)
            }
        }
        registerExpirerEvents() {
            this.client.core.expirer.on(eG, async e => {
                let {
                    topic: t,
                    id: i
                } = (0, u.parseExpirerTarget)(e.target);
                return i && this.client.pendingRequest.keys.includes(i) ? await this.deletePendingSessionRequest(i, (0, u.getInternalError)("EXPIRED"), !0) : i && this.client.auth.requests.keys.includes(i) ? await this.deletePendingAuthRequest(i, (0, u.getInternalError)("EXPIRED"), !0) : void(t ? this.client.session.keys.includes(t) && (await this.deleteSession({
                    topic: t,
                    expirerHasDeleted: !0
                }), this.client.events.emit("session_expire", {
                    topic: t
                })) : i && (await this.deleteProposal(i, !0), this.client.events.emit("proposal_expire", {
                    id: i
                })))
            })
        }
        registerSubscriptionCleanup() {
            this.client.core.heartbeat.on("heartbeat_pulse", async () => {
                if (!this.cleanupInProgress) {
                    this.cleanupInProgress = !0;
                    try {
                        await this.cleanupOrphanedSubscriptions()
                    } catch (e) {
                        this.client.logger.warn(e)
                    } finally {
                        this.cleanupInProgress = !1
                    }
                }
            })
        }
        registerPairingEvents() {
            this.client.core.pairing.events.on(eq, e => this.onPairingCreated(e)), this.client.core.pairing.events.on(ez, e => {
                this.addToRecentlyDeleted(e.topic, "pairing")
            })
        }
        isValidPairingTopic(e) {
            if (!(0, u.isValidString)(e, !1)) {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `pairing topic should be a string: ${e}`);
                throw Error(t)
            }
            if (!this.client.core.pairing.pairings.keys.includes(e)) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `pairing topic doesn't exist: ${e}`);
                throw Error(t)
            }
            if ((0, u.isExpired)(this.client.core.pairing.pairings.get(e).expiry)) {
                let {
                    message: t
                } = (0, u.getInternalError)("EXPIRED", `pairing topic: ${e}`);
                throw Error(t)
            }
        }
        async isValidSessionTopic(e) {
            if (!(0, u.isValidString)(e, !1)) {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `session topic should be a string: ${e}`);
                throw Error(t)
            }
            if (this.checkRecentlyDeleted(e), !this.client.session.keys.includes(e)) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `session topic doesn't exist: ${e}`);
                throw Error(t)
            }
            if ((0, u.isExpired)(this.client.session.get(e).expiry)) {
                await this.deleteSession({
                    topic: e
                });
                let {
                    message: t
                } = (0, u.getInternalError)("EXPIRED", `session topic: ${e}`);
                throw Error(t)
            }
            if (!this.client.core.crypto.keychain.has(e)) {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `session topic does not exist in keychain: ${e}`);
                throw await this.deleteSession({
                    topic: e
                }), Error(t)
            }
        }
        async isValidSessionOrPairingTopic(e) {
            if (this.checkRecentlyDeleted(e), this.client.session.keys.includes(e)) await this.isValidSessionTopic(e);
            else if (this.client.core.pairing.pairings.keys.includes(e)) this.isValidPairingTopic(e);
            else if ((0, u.isValidString)(e, !1)) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${e}`);
                throw Error(t)
            } else {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `session or pairing topic should be a string: ${e}`);
                throw Error(t)
            }
        }
        async isValidProposalId(e) {
            if (!(0, u.isValidId)(e)) {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `proposal id should be a number: ${e}`);
                throw Error(t)
            }
            if (!this.client.proposal.keys.includes(e)) {
                let {
                    message: t
                } = (0, u.getInternalError)("NO_MATCHING_KEY", `proposal id doesn't exist: ${e}`);
                throw Error(t)
            }
            if ((0, u.isExpired)(this.client.proposal.get(e).expiryTimestamp)) {
                await this.deleteProposal(e);
                let {
                    message: t
                } = (0, u.getInternalError)("EXPIRED", `proposal id: ${e}`);
                throw Error(t)
            }
        }
        validateRequestExpiry(e) {
            if (e && !(0, u.isValidRequestExpiry)(e, td)) {
                let {
                    message: t
                } = (0, u.getInternalError)("MISSING_OR_INVALID", `request() expiry: ${e}. Expiry must be a number (in seconds) between ${td.min} and ${td.max}`);
                throw Error(t)
            }
        }
    }
    class tv extends e4 {
        constructor(e, t) {
            super(e, t, "proposal", ta), this.core = e, this.logger = t
        }
    }
    class tE extends e4 {
        constructor(e, t) {
            super(e, t, "session", ta), this.core = e, this.logger = t
        }
    }
    class tx extends e4 {
        constructor(e, t) {
            super(e, t, "request", ta, e => e.id), this.core = e, this.logger = t
        }
    }
    class tI extends e4 {
        constructor(e, t) {
            super(e, t, "authKeys", tm, () => tb), this.core = e, this.logger = t
        }
    }
    class tS extends e4 {
        constructor(e, t) {
            super(e, t, "pairingTopics", tm), this.core = e, this.logger = t
        }
    }
    class t_ extends e4 {
        constructor(e, t) {
            super(e, t, "requests", tm, e => e.id), this.core = e, this.logger = t
        }
    }
    class tP {
        constructor(e, t) {
            this.core = e, this.logger = t, this.authKeys = new tI(this.core, this.logger), this.pairingTopics = new tS(this.core, this.logger), this.requests = new t_(this.core, this.logger)
        }
        async init() {
            await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init()
        }
    }
    let tT = class e extends tn.ISignClient {
        constructor(e) {
            super(e), this.protocol = "wc", this.version = 2, this.name = to, this.events = new t.EventEmitter, this.on = (e, t) => this.events.on(e, t), this.once = (e, t) => this.events.once(e, t), this.off = (e, t) => this.events.off(e, t), this.removeListener = (e, t) => this.events.removeListener(e, t), this.removeAllListeners = e => this.events.removeAllListeners(e), this.connect = async e => {
                try {
                    return await this.engine.connect(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.pair = async e => {
                try {
                    return await this.engine.pair(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.approve = async e => {
                try {
                    return await this.engine.approve(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.reject = async e => {
                try {
                    return await this.engine.reject(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.update = async e => {
                try {
                    return await this.engine.update(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.extend = async e => {
                try {
                    return await this.engine.extend(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.request = async e => {
                try {
                    return await this.engine.request(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.respond = async e => {
                try {
                    return await this.engine.respond(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.ping = async e => {
                try {
                    return await this.engine.ping(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.emit = async e => {
                try {
                    return await this.engine.emit(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.disconnect = async e => {
                try {
                    return await this.engine.disconnect(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.find = e => {
                try {
                    return this.engine.find(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.getPendingSessionRequests = () => {
                try {
                    return this.engine.getPendingSessionRequests()
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.authenticate = async (e, t) => {
                try {
                    return await this.engine.authenticate(e, t)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.formatAuthMessage = e => {
                try {
                    return this.engine.formatAuthMessage(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.approveSessionAuthenticate = async e => {
                try {
                    return await this.engine.approveSessionAuthenticate(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.rejectSessionAuthenticate = async e => {
                try {
                    return await this.engine.rejectSessionAuthenticate(e)
                } catch (e) {
                    throw this.logger.error(e.message), e
                }
            }, this.name = e ? .name || to, this.metadata = (0, u.populateAppMetadata)(e ? .metadata), this.signConfig = e ? .signConfig;
            const i = (0, u.createLogger)({
                logger: e ? .logger || "error",
                name: this.name
            });
            this.logger = i, this.core = e ? .core || new ts(e), this.session = new tE(this.core, this.logger), this.proposal = new tv(this.core, this.logger), this.pendingRequest = new tx(this.core, this.logger), this.engine = new tw(this), this.auth = new tP(this.core, this.logger)
        }
        static async init(t) {
            let i = new e(t);
            return await i.initialize(), i
        }
        get context() {
            return (0, n.getLoggerContext)(this.logger)
        }
        get pairing() {
            return this.core.pairing.pairings
        }
        async initialize() {
            this.logger.trace("Initialized");
            try {
                await this.core.start(), await this.session.init(), await this.proposal.init(), await this.pendingRequest.init(), await this.auth.init(), await this.engine.init(), this.logger.info("SignClient Initialization Success")
            } catch (e) {
                throw this.logger.info("SignClient Initialization Failure"), this.logger.error(e.message), e
            }
        }
    };
    e.s(["SignClient", 0, tT], 492005);
    var tA = e.i(540022),
        tO = Object.defineProperty,
        tR = Object.defineProperties,
        tN = Object.getOwnPropertyDescriptors,
        tU = Object.getOwnPropertySymbols,
        tC = Object.prototype.hasOwnProperty,
        tk = Object.prototype.propertyIsEnumerable,
        tL = (e, t, i) => t in e ? tO(e, t, {
            enumerable: !0,
            configurable: !0,
            writable: !0,
            value: i
        }) : e[t] = i,
        tD = (e, t) => {
            for (var i in t || (t = {})) tC.call(t, i) && tL(e, i, t[i]);
            if (tU)
                for (var i of tU(t)) tk.call(t, i) && tL(e, i, t[i]);
            return e
        };
    let tB = {
        headers: {
            Accept: "application/json",
            "Content-Type": "application/json"
        },
        method: "POST"
    };
    class tM {
        constructor(e, i = !1) {
            if (this.url = e, this.disableProviderPing = i, this.events = new t.EventEmitter, this.isAvailable = !1, this.registering = !1, !L(e)) throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);
            this.url = e, this.disableProviderPing = i
        }
        get connected() {
            return this.isAvailable
        }
        get connecting() {
            return this.registering
        }
        on(e, t) {
            this.events.on(e, t)
        }
        once(e, t) {
            this.events.once(e, t)
        }
        off(e, t) {
            this.events.off(e, t)
        }
        removeListener(e, t) {
            this.events.removeListener(e, t)
        }
        async open(e = this.url) {
            await this.register(e)
        }
        async close() {
            if (!this.isAvailable) throw Error("Connection already closed");
            this.onClose()
        }
        async send(e) {
            this.isAvailable || await this.register();
            try {
                let t, i, r = (0, l.safeJsonStringify)(e),
                    s = await (await (0, tA.default)(this.url, (t = tD({}, tB), i = {
                        body: r
                    }, tR(t, tN(i))))).json();
                this.onPayload({
                    data: s
                })
            } catch (t) {
                this.onError(e.id, t)
            }
        }
        async register(e = this.url) {
            if (!L(e)) throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);
            if (this.registering) {
                let e = this.events.getMaxListeners();
                return (this.events.listenerCount("register_error") >= e || this.events.listenerCount("open") >= e) && this.events.setMaxListeners(e + 1), new Promise((e, t) => {
                    this.events.once("register_error", e => {
                        this.resetMaxListeners(), t(e)
                    }), this.events.once("open", () => {
                        if (this.resetMaxListeners(), typeof this.isAvailable > "u") return t(Error("HTTP connection is missing or invalid"));
                        e()
                    })
                })
            }
            this.url = e, this.registering = !0;
            try {
                if (!this.disableProviderPing) {
                    let t, i, r = (0, l.safeJsonStringify)({
                        id: 1,
                        jsonrpc: "2.0",
                        method: "test",
                        params: []
                    });
                    await (0, tA.default)(e, (t = tD({}, tB), i = {
                        body: r
                    }, tR(t, tN(i))))
                }
                this.onOpen()
            } catch (t) {
                let e = this.parseError(t);
                throw this.events.emit("register_error", e), this.onClose(), e
            }
        }
        onOpen() {
            this.isAvailable = !0, this.registering = !1, this.events.emit("open")
        }
        onClose() {
            this.isAvailable = !1, this.registering = !1, this.events.emit("close")
        }
        onPayload(e) {
            if (typeof e.data > "u") return;
            let t = "string" == typeof e.data ? (0, l.safeJsonParse)(e.data) : e.data;
            this.events.emit("payload", t)
        }
        onError(e, t) {
            let i = this.parseError(t),
                r = T(e, i.message || i.toString());
            this.events.emit("payload", r)
        }
        parseError(e, t = this.url) {
            return x(e, t, "HTTP")
        }
        resetMaxListeners() {
            this.events.getMaxListeners() > 10 && this.events.setMaxListeners(10)
        }
    }
    e.s(["HttpConnection", 0, tM, "default", 0, tM], 984956)
}]);

//# debugId=bc7ea281-0571-6388-e7b0-a3bf188c64a3