import { l as ie, a as ae, k as S, e as ce, s as ue, g as K, d as de, _ as c, b as D, __tla as __tla_0 } from "./index-CvUp9klu.js";
import { __tla as __tla_1 } from "./App-BLnEEK_h.js";
import "./request-fingerprint-BANtRL63.js";
import "./Logo1am-CaBWyNpM.js";
import "./_virtual_wxt-plugins-CDnz5Vh6.js";
import "./__vite-plugin-wasm-helper-D7K_KhUE.js";
import { __tla as __tla_2 } from "./cardano-e2kMgYtl.js";
import { __tla as __tla_3 } from "./___vite-browser-external_commonjs-proxy-DIugEvg0.js";
import "./index-BkMDDkpV.js";
let ne, Ce, Re, Fe, x, kt, Ze, ct;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })()
]).then(async ()=>{
    function le(e) {
        return !!(e && typeof e.then == "function");
    }
    Promise.resolve(!1);
    Promise.resolve(!0);
    const g = Promise.resolve();
    function P(e, t) {
        return e || (e = 0), new Promise((o)=>{
            setTimeout(()=>o(t), e);
        });
    }
    function fe(e, t) {
        return Math.floor(Math.random() * (t - e + 1) + e);
    }
    function w() {
        return Math.random().toString(36).substring(2);
    }
    let k = 0;
    function h() {
        let e = Date.now() * 1e3;
        return e <= k && (e = k + 1), k = e, e;
    }
    const l = ie.getLogger("broadcast-channel");
    l.setLevel("error");
    class C {
        ttl;
        map = new Map;
        _to = !1;
        constructor(t){
            this.ttl = t;
        }
        has(t) {
            return this.map.has(t);
        }
        add(t) {
            this.map.set(t, z()), this._to || (this._to = !0, setTimeout(()=>{
                this._to = !1, me(this);
            }, 0));
        }
        clear() {
            this.map.clear();
        }
    }
    function me(e) {
        const t = z() - e.ttl, o = e.map[Symbol.iterator]();
        for(;;){
            const s = o.next().value;
            if (!s) return;
            const n = s[0];
            if (s[1] < t) e.map.delete(n);
            else return;
        }
    }
    function z() {
        return Date.now();
    }
    const he = "https://api.web3auth.io/session-service", pe = "https://session.web3auth.io";
    function M(e = {}) {
        const t = JSON.parse(JSON.stringify(e));
        return typeof t.webWorkerSupport > "u" && (t.webWorkerSupport = !0), t.idb || (t.idb = {}), t.idb.ttl || (t.idb.ttl = 1e3 * 45), t.idb.fallbackInterval || (t.idb.fallbackInterval = 150), e.idb && typeof e.idb.onclose == "function" && (t.idb.onclose = e.idb.onclose), t.localstorage || (t.localstorage = {}), t.localstorage.removeTimeout || (t.localstorage.removeTimeout = 1e3 * 60), t.server || (t.server = {}), t.server.api_url || (t.server.api_url = `${he}/v2`), t.server.socket_url || (t.server.socket_url = `${pe}`), t.server.removeTimeout || (t.server.removeTimeout = 1e3 * 60 * 5), e.methods && (t.methods = e.methods), t;
    }
    const ge = h, _e = "pubkey.broadcast-channel-0-", f = "messages", _ = {
        durability: "relaxed"
    }, ve = "idb";
    function L() {
        if (typeof indexedDB < "u") return indexedDB;
        if (typeof window < "u") {
            const e = window;
            if (typeof e.mozIndexedDB < "u") return e.mozIndexedDB;
            if (typeof e.webkitIndexedDB < "u") return e.webkitIndexedDB;
            if (typeof e.msIndexedDB < "u") return e.msIndexedDB;
        }
        return !1;
    }
    function b(e) {
        e.commit && e.commit();
    }
    function j(e) {
        const t = L();
        if (!t) return Promise.reject(new Error("IndexedDB not available"));
        const o = _e + e, s = t.open(o);
        return s.onupgradeneeded = (r)=>{
            r.target.result.createObjectStore(f, {
                keyPath: "id",
                autoIncrement: !0
            });
        }, new Promise((r, i)=>{
            s.onerror = (a)=>i(a), s.onsuccess = ()=>{
                r(s.result);
            };
        });
    }
    function F(e, t, o) {
        const s = Date.now(), n = {
            uuid: t,
            time: s,
            data: o
        }, r = e.transaction([
            f
        ], "readwrite", _);
        return new Promise((i, a)=>{
            r.oncomplete = ()=>i(), r.onerror = (d)=>a(d), r.objectStore(f).add(n), b(r);
        });
    }
    function ye(e) {
        const t = e.transaction(f, "readonly", _), o = t.objectStore(f), s = [];
        return new Promise((n)=>{
            o.openCursor().onsuccess = (r)=>{
                const i = r.target.result;
                i ? (s.push(i.value), i.continue()) : (b(t), n(s));
            };
        });
    }
    function J(e, t) {
        const o = e.transaction(f, "readonly", _), s = o.objectStore(f), n = [];
        let r = IDBKeyRange.bound(t + 1, 1 / 0);
        if (s.getAll) {
            const a = s.getAll(r);
            return new Promise((u, d)=>{
                a.onerror = (p)=>d(p), a.onsuccess = function(p) {
                    u(p.target.result);
                };
            });
        }
        function i() {
            try {
                return r = IDBKeyRange.bound(t + 1, 1 / 0), s.openCursor(r);
            } catch  {
                return s.openCursor();
            }
        }
        return new Promise((a, u)=>{
            const d = i();
            d.onerror = (p)=>u(p), d.onsuccess = (p)=>{
                const m = p.target.result;
                m ? m.value.id < t + 1 ? m.continue(t + 1) : (n.push(m.value), m.continue()) : (b(o), a(n));
            };
        });
    }
    function V(e, t) {
        const s = e.transaction([
            f
        ], "readwrite", _).objectStore(f);
        return Promise.all(t.map((n)=>{
            const r = s.delete(n);
            return new Promise((i)=>{
                r.onsuccess = ()=>i();
            });
        }));
    }
    function W(e, t) {
        const o = Date.now() - t, s = e.transaction(f, "readonly", _), n = s.objectStore(f), r = [];
        return new Promise((i)=>{
            n.openCursor().onsuccess = (a)=>{
                const u = a.target.result;
                if (u) {
                    const d = u.value;
                    d.time < o ? (r.push(d), u.continue()) : (b(s), i(r));
                } else i(r);
            };
        });
    }
    function q(e, t) {
        return W(e, t).then((o)=>V(e, o.map((s)=>s.id)));
    }
    function we(e, t) {
        return t = M(t), j(e).then((o)=>{
            const s = {
                closed: !1,
                lastCursorId: 0,
                channelName: e,
                options: t,
                uuid: w(),
                eMIs: new C(t.idb.ttl * 2),
                writeBlockPromise: g,
                messagesCallback: null,
                readQueuePromises: [],
                db: o,
                time: h()
            };
            return o.onclose = function() {
                s.closed = !0, t.idb.onclose && t.idb.onclose();
            }, H(s), s;
        });
    }
    function H(e) {
        e.closed || X(e).then(()=>P(e.options.idb.fallbackInterval)).then(()=>H(e)).catch((t)=>{
            throw t;
        });
    }
    function be(e, t) {
        return !(e.uuid === t.uuid || t.eMIs.has(e.id) || e.data.time < t.messagesCallbackTime);
    }
    function X(e) {
        return e.closed || !e.messagesCallback ? g : J(e.db, e.lastCursorId).then((t)=>(t.filter((s)=>!!s).map((s)=>(s.id > e.lastCursorId && (e.lastCursorId = s.id), s)).filter((s)=>be(s, e)).sort((s, n)=>s.time - n.time).forEach((s)=>{
                e.messagesCallback && (e.eMIs.add(s.id), e.messagesCallback(s.data));
            }), g));
    }
    function Me(e) {
        e.closed = !0, e.db.close();
    }
    function ke(e, t) {
        return e.writeBlockPromise = e.writeBlockPromise.then(()=>F(e.db, e.uuid, t)).then(()=>(fe(0, 10) === 0 && q(e.db, e.options.idb.ttl), g)), e.writeBlockPromise;
    }
    function Se(e, t, o) {
        e.messagesCallbackTime = o, e.messagesCallback = t, X(e);
    }
    function Ee() {
        return !!L();
    }
    function Pe(e) {
        return e.idb.fallbackInterval * 2;
    }
    let Le, Ie, Y;
    Ce = Object.freeze(Object.defineProperty({
        __proto__: null,
        TRANSACTION_SETTINGS: _,
        averageResponseTime: Pe,
        canBeUsed: Ee,
        cleanOldMessages: q,
        close: Me,
        commitIndexedDBTransaction: b,
        create: we,
        createDatabase: j,
        getAllMessages: ye,
        getIdb: L,
        getMessagesHigherThan: J,
        getOldMessages: W,
        microSeconds: ge,
        onMessage: Se,
        postMessage: ke,
        removeMessagesById: V,
        type: ve,
        writeMessage: F
    }, Symbol.toStringTag, {
        value: "Module"
    }));
    Le = h;
    Ie = "pubkey.broadcastChannel-";
    Y = "localstorage";
    function I() {
        let e = null;
        if (typeof window > "u") return null;
        try {
            e = window.localStorage, e = window["ie8-eventlistener/storage"] || window.localStorage;
        } catch  {}
        return e;
    }
    function T(e) {
        return Ie + e;
    }
    function Te(e, t) {
        return new Promise((o, s)=>{
            P().then(()=>{
                var n;
                const r = T(e.channelName), i = {
                    token: w(),
                    time: Date.now(),
                    data: t,
                    uuid: e.uuid
                }, a = JSON.stringify(i);
                (n = I()) === null || n === void 0 || n.setItem(r, a);
                const u = document.createEvent("StorageEvent");
                u.initStorageEvent("storage", !0, !0, r, null, a, "", null), window.dispatchEvent(u), o();
            }).catch(s);
        });
    }
    function G(e, t) {
        const o = T(e), s = (n)=>{
            n.key === o && n.newValue && t(JSON.parse(n.newValue));
        };
        return window.addEventListener("storage", s), s;
    }
    function Q(e) {
        window.removeEventListener("storage", e);
    }
    function Z() {
        const e = I();
        if (!e) return !1;
        try {
            const t = "__broadcastchannel_check";
            e.setItem(t, "works"), e.removeItem(t);
        } catch  {
            return !1;
        }
        return !0;
    }
    function $e(e, t) {
        const o = M(t);
        if (!Z()) throw new Error("BroadcastChannel: localstorage cannot be used");
        const s = w(), n = new C(o.localstorage.removeTimeout), r = {
            channelName: e,
            uuid: s,
            time: h(),
            eMIs: n
        };
        return r.listener = G(e, (i)=>{
            r.messagesCallback && i.uuid !== s && (!i.token || n.has(i.token) || i.data.time && i.data.time < (r.messagesCallbackTime || 0) || (n.add(i.token), r.messagesCallback(i.data)));
        }), r;
    }
    function Be(e) {
        e.listener && Q(e.listener);
    }
    function Ne(e, t, o) {
        e.messagesCallbackTime = o, e.messagesCallback = t;
    }
    function De() {
        const t = navigator.userAgent.toLowerCase();
        return t.includes("safari") && !t.includes("chrome") ? 240 : 120;
    }
    let xe, ee;
    Re = Object.freeze(Object.defineProperty({
        __proto__: null,
        addStorageEventListener: G,
        averageResponseTime: De,
        canBeUsed: Z,
        close: Be,
        create: $e,
        getLocalStorage: I,
        microSeconds: Le,
        onMessage: Ne,
        postMessage: Te,
        removeStorageEventListener: Q,
        storageKey: T,
        type: Y
    }, Symbol.toStringTag, {
        value: "Module"
    }));
    xe = h;
    ee = "native";
    function Oe(e) {
        const t = {
            time: h(),
            messagesCallback: null,
            bc: new BroadcastChannel(e),
            subFns: []
        };
        return t.bc.onmessage = (o)=>{
            t.messagesCallback && t.messagesCallback(o.data);
        }, t;
    }
    function Ae(e) {
        e.bc.close(), e.subFns = [];
    }
    function Ue(e, t) {
        try {
            return e.bc.postMessage(t), g;
        } catch (o) {
            return Promise.reject(o);
        }
    }
    function Ke(e, t) {
        e.messagesCallback = t;
    }
    function ze() {
        if (typeof window > "u") return !1;
        if (typeof BroadcastChannel == "function") {
            if (BroadcastChannel._pubkey) throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");
            return !0;
        }
        return !1;
    }
    function je() {
        return 150;
    }
    let Je, Ve, te;
    Fe = Object.freeze(Object.defineProperty({
        __proto__: null,
        averageResponseTime: je,
        canBeUsed: ze,
        close: Ae,
        create: Oe,
        microSeconds: xe,
        onMessage: Ke,
        postMessage: Ue,
        type: ee
    }, Symbol.toStringTag, {
        value: "Module"
    }));
    Je = h;
    Ve = "pubkey.broadcastChannel-";
    te = "server";
    let v = null;
    const y = new Set;
    function $(e) {
        return Ve + e;
    }
    function We(e, t) {
        return new Promise((o, s)=>{
            P().then(async ()=>{
                const n = $(e.channelName), r = S(Buffer.from(n, "utf8")), i = await ce(r.toString("hex"), {
                    token: w(),
                    time: Date.now(),
                    data: t,
                    uuid: e.uuid
                }), a = {
                    allowedOrigin: e.server.allowed_origin,
                    sameIpCheck: !0,
                    key: K(r).toString("hex"),
                    data: i,
                    signature: (await ue(r, S(Buffer.from(i, "utf8")))).toString("hex")
                };
                return e.timeout && (a.timeout = e.timeout), fetch(`${e.server.api_url}/channel/set`, {
                    method: "POST",
                    body: JSON.stringify(a),
                    headers: {
                        "Content-Type": "application/json; charset=utf-8"
                    }
                }).then(o).catch(s);
            }).catch(s);
        });
    }
    function se(e) {
        if (v) return v;
        const t = ae(e, {
            transports: [
                "websocket",
                "polling"
            ],
            withCredentials: !0,
            reconnectionDelayMax: 1e4,
            reconnectionAttempts: 10
        });
        return t.on("connect_error", (o)=>{
            t.io.opts.transports = [
                "polling",
                "websocket"
            ], l.error("connect error", o);
        }), t.on("connect", async ()=>{
            const { engine: o } = t.io;
            l.debug("initially connected to", o.transport.name), o.once("upgrade", ()=>{
                l.debug("upgraded", o.transport.name);
            }), o.once("close", (s)=>{
                l.debug("connection closed", s);
            });
        }), t.on("error", (o)=>{
            l.error("socket errored", o), t.disconnect();
        }), v = t, t;
    }
    function oe(e, t, o) {
        const s = se(e), n = $(t.channelName), r = S(Buffer.from(n, "utf8")), i = K(r).toString("hex");
        s.connected ? s.emit("v2:check_auth_status", i, {
            sameIpCheck: !0,
            allowedOrigin: t.server.allowed_origin
        }) : s.once("connect", ()=>{
            l.debug("connected with socket"), s.emit("v2:check_auth_status", i, {
                sameIpCheck: !0,
                allowedOrigin: t.server.allowed_origin
            });
        });
        const a = ()=>{
            s.once("connect", async ()=>{
                y.has(t.channelName) && s.emit("v2:check_auth_status", i, {
                    sameIpCheck: !0,
                    allowedOrigin: t.server.allowed_origin
                });
            });
        }, u = ()=>{
            if (!s || !y.has(t.channelName)) {
                document.removeEventListener("visibilitychange", u);
                return;
            }
            !s.connected && document.visibilityState === "visible" && a();
        }, d = async (p)=>{
            try {
                const m = await de(r.toString("hex"), p);
                l.info(m), o(m);
            } catch (m) {
                l.error(m);
            }
        };
        return s.on("disconnect", ()=>{
            l.debug("socket disconnected"), y.has(t.channelName) && (l.error("socket disconnected unexpectedly, reconnecting socket"), a());
        }), s.on(`${i}_success`, d), typeof document < "u" && document.addEventListener("visibilitychange", u), s;
    }
    function qe() {
        v && v.disconnect();
    }
    function He() {
        return !0;
    }
    function Xe(e, t) {
        t = M(t);
        const o = w(), s = new C(t.server.removeTimeout), n = {
            channelName: e,
            uuid: o,
            eMIs: s,
            server: {
                api_url: t.server.api_url,
                socket_url: t.server.socket_url,
                allowed_origin: t.server.allowed_origin
            },
            time: h()
        };
        return t.server.timeout && (n.timeout = t.server.timeout), oe(t.server.socket_url, n, (r)=>{
            n.messagesCallback && r.uuid !== n.uuid && (!r.token || n.eMIs.has(r.token) || (n.eMIs.add(r.token), n.messagesCallback(r.data)));
        }), y.add(e), n;
    }
    function Ye(e) {
        y.delete(e.channelName);
    }
    function Ge(e, t, o) {
        e.messagesCallbackTime = o, e.messagesCallback = t;
    }
    function Qe() {
        return 500;
    }
    let et, E, B, N;
    Ze = Object.freeze(Object.defineProperty({
        __proto__: null,
        averageResponseTime: Qe,
        canBeUsed: He,
        close: Ye,
        create: Xe,
        getSocketInstance: se,
        microSeconds: Je,
        onMessage: Ge,
        postMessage: We,
        removeStorageEventListener: qe,
        setupSocketConnection: oe,
        storageKey: $,
        type: te
    }, Symbol.toStringTag, {
        value: "Module"
    }));
    et = h;
    E = "simulate";
    B = new Set;
    N = 5;
    function tt(e) {
        const t = {
            time: h(),
            name: e,
            messagesCallback: null
        };
        return B.add(t), t;
    }
    function st(e) {
        B.delete(e);
    }
    function ot(e, t) {
        return new Promise((o)=>{
            setTimeout(()=>{
                Array.from(B).forEach((n)=>{
                    n.name === e.name && n !== e && n.messagesCallback && n.time < t.time && n.messagesCallback(t);
                }), o();
            }, N);
        });
    }
    function nt(e, t) {
        e.messagesCallback = t;
    }
    function rt() {
        return !0;
    }
    function it() {
        return N;
    }
    const at = Object.freeze(Object.defineProperty({
        __proto__: null,
        SIMULATE_DELAY_TIME: N,
        averageResponseTime: it,
        canBeUsed: rt,
        close: st,
        create: tt,
        microSeconds: et,
        onMessage: nt,
        postMessage: ot,
        type: E
    }, Symbol.toStringTag, {
        value: "Module"
    })), R = [
        Fe,
        Ce,
        Re,
        Ze
    ];
    ct = function(e) {
        let t = [].concat(e.methods || [], R).filter(Boolean);
        if (e.type) {
            if (e.type === "simulate") return at;
            const s = t.find((n)=>n.type === e.type);
            if (s) return s;
            throw new Error(`method-type ${e.type} not found`);
        }
        e.webWorkerSupport || (t = t.filter((s)=>s.type !== "idb"));
        const o = t.find((s)=>s.canBeUsed(e));
        if (o) return o;
        throw new Error(`No useable method found in ${JSON.stringify(R.map((s)=>s.type))}`);
    };
    x = new Set;
    let ut;
    ut = 0;
    ne = class {
        constructor(t, o){
            c(this, "id", void 0), c(this, "name", void 0), c(this, "options", void 0), c(this, "method", void 0), c(this, "closed", void 0), c(this, "_addEL", void 0), c(this, "_prepP", void 0), c(this, "_state", void 0), c(this, "_uMP", void 0), c(this, "_iL", void 0), c(this, "_onML", void 0), c(this, "_befC", void 0), this.id = ut++, x.add(this), this.name = t, this.options = M(o || {}), this.method = ct(this.options), this.closed = !1, this._iL = !1, this._onML = null, this._addEL = {
                message: [],
                internal: []
            }, this._uMP = new Set, this._befC = [], this._prepP = null, dt(this);
        }
        get type() {
            return this.method.type;
        }
        get isClosed() {
            return this.closed;
        }
        set onmessage(t) {
            const s = {
                time: this.method.microSeconds(),
                fn: t
            };
            U(this, "message", this._onML), t && typeof t == "function" ? (this._onML = s, A(this, "message", s)) : this._onML = null;
        }
        postMessage(t) {
            if (this.closed) throw new Error(`BroadcastChannel.postMessage(): Cannot post message after channel has closed ${JSON.stringify(t)}`);
            return O(this, "message", t);
        }
        postInternal(t) {
            return O(this, "internal", t);
        }
        addEventListener(t, o) {
            const n = {
                time: this.method.microSeconds(),
                fn: o
            };
            A(this, t, n);
        }
        removeEventListener(t, o) {
            const s = this._addEL[t].find((n)=>n.fn === o);
            U(this, t, s);
        }
        close() {
            if (this.closed) return Promise.resolve();
            x.delete(this), this.closed = !0;
            const t = this._prepP ? this._prepP : g;
            return this._onML = null, this._addEL.message = [], t.then(()=>Promise.all(Array.from(this._uMP))).then(()=>Promise.all(this._befC.map((o)=>o()))).then(()=>this.method.close ? this.method.close(this._state) : g);
        }
    };
    c(ne, "_pubkey", !0);
    function O(e, t, o) {
        const n = {
            time: e.method.microSeconds(),
            type: t,
            data: o
        };
        return (e._prepP ? e._prepP : g).then(()=>{
            const i = e.method.postMessage(e._state, n);
            return e._uMP.add(i), i.catch(()=>{}).then(()=>e._uMP.delete(i)), i;
        });
    }
    function dt(e) {
        const t = e.method.create(e.name, e.options);
        if (le(t)) {
            const o = t;
            e._prepP = o, o.then((s)=>(e._state = s, s)).catch((s)=>{
                throw s;
            });
        } else e._state = t;
    }
    function re(e) {
        return e._addEL.message.length > 0 || e._addEL.internal.length > 0;
    }
    function lt(e) {
        if (!e._iL && re(e)) {
            const t = (s)=>{
                e._addEL[s.type].forEach((n)=>{
                    (s.time >= n.time || e.method.type === "server") && n.fn(s.data);
                });
            }, o = e.method.microSeconds();
            e._prepP ? e._prepP.then(()=>(e._iL = !0, e.method.onMessage(e._state, t, o), !0)).catch((s)=>{
                throw s;
            }) : (e._iL = !0, e.method.onMessage(e._state, t, o));
        }
    }
    function ft(e) {
        if (e._iL && !re(e)) {
            e._iL = !1;
            const t = e.method.microSeconds();
            e.method.onMessage(e._state, null, t);
        }
    }
    function A(e, t, o) {
        e._addEL[t].push(o), lt(e);
    }
    function U(e, t, o) {
        o && (e._addEL[t] = e._addEL[t].filter((s)=>s !== o), ft(e));
    }
    kt = class {
        constructor(t, o = {}){
            c(this, "name", void 0), c(this, "options", void 0), c(this, "closed", void 0), c(this, "onML", void 0), c(this, "methodPriority", void 0), c(this, "channels", void 0), c(this, "listeners", void 0), c(this, "processedNonces", void 0), c(this, "nonce", void 0), this.name = t, this.options = o, this.closed = !1, this.onML = null, this.methodPriority = [
                ee,
                Y,
                te
            ], this.channels = new Map, this.listeners = new Set, this.processedNonces = new Set, this.nonce = 0, this.initChannels();
        }
        set onmessage(t) {
            this.removeEventListener("message", this.onML), t && typeof t == "function" ? (this.onML = t, this.addEventListener("message", t)) : this.onML = null;
        }
        initChannels() {
            if (this.options.type === E && (this.methodPriority = [
                E
            ]), this.methodPriority.forEach((t)=>{
                try {
                    const o = new ne(this.name, D(D({}, this.options), {}, {
                        type: t
                    }));
                    this.channels.set(t, o), l.debug(`Succeeded to initialize ${t} method in channel ${this.name}`), o.onmessage = (s)=>this.handleMessage(s);
                } catch (o) {
                    l.warn(`Failed to initialize ${t} method in channel ${this.name}: ${o instanceof Error ? o.message : String(o)}`);
                }
            }), this.channels.size === 0) throw new Error("Failed to initialize any communication method");
        }
        allChannels() {
            return Array.from(this.channels.keys());
        }
        hasChannel(t) {
            return this.channels.has(t);
        }
        handleMessage(t) {
            if (t && t.nonce) {
                if (this.processedNonces.has(t.nonce)) return;
                if (this.processedNonces.add(t.nonce), this.processedNonces.size > 1e3) {
                    const s = Array.from(this.processedNonces).sort()[0];
                    this.processedNonces.delete(s);
                }
                this.listeners.forEach((o)=>{
                    o(t.message);
                });
            }
        }
        async postMessage(t) {
            if (this.closed) throw new Error(`AdaptiveBroadcastChannel.postMessage(): Cannot post message after channel has closed ${JSON.stringify(t)}`);
            const s = {
                nonce: this.generateNonce(),
                message: t
            }, n = Array.from(this.channels.entries()).map(([a, u])=>u.postMessage(s).catch((d)=>{
                    throw l.warn(`Failed to send via ${a}: ${d.message}`), d;
                }));
            if (!(await Promise.allSettled(n)).some((a)=>a.status === "fulfilled")) throw new Error("Failed to send message through any method");
            return t;
        }
        generateNonce() {
            return `${Date.now()}-${this.nonce++}`;
        }
        addEventListener(t, o) {
            this.listeners.add(o);
        }
        removeEventListener(t, o) {
            this.listeners.delete(o);
        }
        async close() {
            if (this.closed) return;
            this.onML = null;
            const t = [];
            for (const o of this.channels.values())t.push(o.close());
            await Promise.all(t), this.channels.clear(), this.listeners.clear(), this.closed = !0;
        }
    };
});
export { ne as BroadcastChannel, Ce as IndexedDbMethod, Re as LocalstorageMethod, Fe as NativeMethod, x as OPEN_BROADCAST_CHANNELS, kt as RedundantAdaptiveBroadcastChannel, Ze as ServerMethod, ct as chooseMethod, __tla };
