! function(e, t) {
    "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).EmbeddedSandbox = t()
}(this, (function() {
    "use strict";
    const e = (e = !1) => e ? "https://embed.apollo.local:3000/sandbox/explorer" : "https://sandbox.embed.apollographql.com/sandbox/explorer",
        t = "SchemaError",
        n = "ExplorerResponse",
        i = "ExplorerSubscriptionResponse",
        o = "ExplorerSetSocketStatus",
        r = e => `apollo-embed-${e}`;

    function s(e, t, n, i) {
        return new(n || (n = Promise))((function(o, r) {
            function s(e) {
                try {
                    c(i.next(e))
                } catch (e) {
                    r(e)
                }
            }

            function a(e) {
                try {
                    c(i.throw(e))
                } catch (e) {
                    r(e)
                }
            }

            function c(e) {
                var t;
                e.done ? o(e.value) : (t = e.value, t instanceof n ? t : new n((function(e) {
                    e(t)
                }))).then(s, a)
            }
            c((i = i.apply(e, t || [])).next())
        }))
    }
    var a = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};

    function c(e) {
        var t = e.default;
        if ("function" == typeof t) {
            var n = function() {
                return t.apply(this, arguments)
            };
            n.prototype = t.prototype
        } else n = {};
        return Object.defineProperty(n, "__esModule", {
            value: !0
        }), Object.keys(e).forEach((function(t) {
            var i = Object.getOwnPropertyDescriptor(e, t);
            Object.defineProperty(n, t, i.get ? i : {
                enumerable: !0,
                get: function() {
                    return e[t]
                }
            })
        })), n
    }
    var l = {
        removeLeadingAndTrailingHTTPWhitespace: e => e.replace(/^[ \t\n\r]+/u, "").replace(/[ \t\n\r]+$/u, ""),
        removeTrailingHTTPWhitespace: e => e.replace(/[ \t\n\r]+$/u, ""),
        isHTTPWhitespaceChar: e => " " === e || "\t" === e || "\n" === e || "\r" === e,
        solelyContainsHTTPTokenCodePoints: e => /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(e),
        soleyContainsHTTPQuotedStringTokenCodePoints: e => /^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(e),
        asciiLowercase: e => e.replace(/[A-Z]/gu, (e => e.toLowerCase())),
        collectAnHTTPQuotedString: (e, t) => {
            let n = "";
            for (t++;;) {
                for (; t < e.length && '"' !== e[t] && "\\" !== e[t];) n += e[t], ++t;
                if (t >= e.length) break;
                const i = e[t];
                if (++t, "\\" !== i) break;
                if (t >= e.length) {
                    n += "\\";
                    break
                }
                n += e[t], ++t
            }
            return [n, t]
        }
    };
    const {
        asciiLowercase: u,
        solelyContainsHTTPTokenCodePoints: p,
        soleyContainsHTTPQuotedStringTokenCodePoints: d
    } = l;
    var f = class {
        constructor(e) {
            this._map = e
        }
        get size() {
            return this._map.size
        }
        get(e) {
            return e = u(String(e)), this._map.get(e)
        }
        has(e) {
            return e = u(String(e)), this._map.has(e)
        }
        set(e, t) {
            if (e = u(String(e)), t = String(t), !p(e)) throw new Error(`Invalid MIME type parameter name "${e}": only HTTP token code points are valid.`);
            if (!d(t)) throw new Error(`Invalid MIME type parameter value "${t}": only HTTP quoted-string token code points are valid.`);
            return this._map.set(e, t)
        }
        clear() {
            this._map.clear()
        }
        delete(e) {
            return e = u(String(e)), this._map.delete(e)
        }
        forEach(e, t) {
            this._map.forEach(e, t)
        }
        keys() {
            return this._map.keys()
        }
        values() {
            return this._map.values()
        }
        entries() {
            return this._map.entries()
        } [Symbol.iterator]() {
            return this._map[Symbol.iterator]()
        }
    };
    const {
        removeLeadingAndTrailingHTTPWhitespace: h,
        removeTrailingHTTPWhitespace: m,
        isHTTPWhitespaceChar: y,
        solelyContainsHTTPTokenCodePoints: v,
        soleyContainsHTTPQuotedStringTokenCodePoints: b,
        asciiLowercase: g,
        collectAnHTTPQuotedString: E
    } = l, {
        solelyContainsHTTPTokenCodePoints: w
    } = l, T = f, {
        asciiLowercase: I,
        solelyContainsHTTPTokenCodePoints: _
    } = l;

    function O(e, t) {
        (null == t || t > e.length) && (t = e.length);
        for (var n = 0, i = new Array(t); n < t; n++) i[n] = e[n];
        return i
    }

    function S(e, t) {
        for (var n = 0; n < t.length; n++) {
            var i = t[n];
            i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
        }
    }

    function x(e, t, n) {
        return t && S(e.prototype, t), n && S(e, n), e
    }
    var C = function() {
            return "function" == typeof Symbol
        },
        N = function(e) {
            return C() && Boolean(Symbol[e])
        },
        k = function(e) {
            return N(e) ? Symbol[e] : "@@" + e
        };
    C() && !N("observable") && (Symbol.observable = Symbol("observable"));
    var A = k("iterator"),
        P = k("observable"),
        j = k("species");

    function R(e, t) {
        var n = e[t];
        if (null != n) {
            if ("function" != typeof n) throw new TypeError(n + " is not a function");
            return n
        }
    }

    function M(e) {
        var t = e.constructor;
        return void 0 !== t && null === (t = t[j]) && (t = void 0), void 0 !== t ? t : W
    }

    function F(e) {
        return e instanceof W
    }

    function U(e) {
        U.log ? U.log(e) : setTimeout((function() {
            throw e
        }))
    }

    function L(e) {
        Promise.resolve().then((function() {
            try {
                e()
            } catch (e) {
                U(e)
            }
        }))
    }

    function D(e) {
        var t = e._cleanup;
        if (void 0 !== t && (e._cleanup = void 0, t)) try {
            if ("function" == typeof t) t();
            else {
                var n = R(t, "unsubscribe");
                n && n.call(t)
            }
        } catch (e) {
            U(e)
        }
    }

    function q(e) {
        e._observer = void 0, e._queue = void 0, e._state = "closed"
    }

    function $(e, t, n) {
        e._state = "running";
        var i = e._observer;
        try {
            var o = R(i, t);
            switch (t) {
                case "next":
                    o && o.call(i, n);
                    break;
                case "error":
                    if (q(e), !o) throw n;
                    o.call(i, n);
                    break;
                case "complete":
                    q(e), o && o.call(i)
            }
        } catch (e) {
            U(e)
        }
        "closed" === e._state ? D(e) : "running" === e._state && (e._state = "ready")
    }

    function V(e, t, n) {
        if ("closed" !== e._state) {
            if ("buffering" !== e._state) return "ready" !== e._state ? (e._state = "buffering", e._queue = [{
                type: t,
                value: n
            }], void L((function() {
                return function(e) {
                    var t = e._queue;
                    if (t) {
                        e._queue = void 0, e._state = "ready";
                        for (var n = 0; n < t.length && ($(e, t[n].type, t[n].value), "closed" !== e._state); ++n);
                    }
                }(e)
            }))) : void $(e, t, n);
            e._queue.push({
                type: t,
                value: n
            })
        }
    }
    var G = function() {
            function e(e, t) {
                this._cleanup = void 0, this._observer = e, this._queue = void 0, this._state = "initializing";
                var n = new Q(this);
                try {
                    this._cleanup = t.call(void 0, n)
                } catch (e) {
                    n.error(e)
                }
                "initializing" === this._state && (this._state = "ready")
            }
            return e.prototype.unsubscribe = function() {
                "closed" !== this._state && (q(this), D(this))
            }, x(e, [{
                key: "closed",
                get: function() {
                    return "closed" === this._state
                }
            }]), e
        }(),
        Q = function() {
            function e(e) {
                this._subscription = e
            }
            var t = e.prototype;
            return t.next = function(e) {
                V(this._subscription, "next", e)
            }, t.error = function(e) {
                V(this._subscription, "error", e)
            }, t.complete = function() {
                V(this._subscription, "complete")
            }, x(e, [{
                key: "closed",
                get: function() {
                    return "closed" === this._subscription._state
                }
            }]), e
        }(),
        W = function() {
            function e(t) {
                if (!(this instanceof e)) throw new TypeError("Observable cannot be called as a function");
                if ("function" != typeof t) throw new TypeError("Observable initializer must be a function");
                this._subscriber = t
            }
            var t = e.prototype;
            return t.subscribe = function(e) {
                return "object" == typeof e && null !== e || (e = {
                    next: e,
                    error: arguments[1],
                    complete: arguments[2]
                }), new G(e, this._subscriber)
            }, t.forEach = function(e) {
                var t = this;
                return new Promise((function(n, i) {
                    if ("function" == typeof e) var o = t.subscribe({
                        next: function(t) {
                            try {
                                e(t, r)
                            } catch (e) {
                                i(e), o.unsubscribe()
                            }
                        },
                        error: i,
                        complete: n
                    });
                    else i(new TypeError(e + " is not a function"));

                    function r() {
                        o.unsubscribe(), n()
                    }
                }))
            }, t.map = function(e) {
                var t = this;
                if ("function" != typeof e) throw new TypeError(e + " is not a function");
                return new(M(this))((function(n) {
                    return t.subscribe({
                        next: function(t) {
                            try {
                                t = e(t)
                            } catch (e) {
                                return n.error(e)
                            }
                            n.next(t)
                        },
                        error: function(e) {
                            n.error(e)
                        },
                        complete: function() {
                            n.complete()
                        }
                    })
                }))
            }, t.filter = function(e) {
                var t = this;
                if ("function" != typeof e) throw new TypeError(e + " is not a function");
                return new(M(this))((function(n) {
                    return t.subscribe({
                        next: function(t) {
                            try {
                                if (!e(t)) return
                            } catch (e) {
                                return n.error(e)
                            }
                            n.next(t)
                        },
                        error: function(e) {
                            n.error(e)
                        },
                        complete: function() {
                            n.complete()
                        }
                    })
                }))
            }, t.reduce = function(e) {
                var t = this;
                if ("function" != typeof e) throw new TypeError(e + " is not a function");
                var n = M(this),
                    i = arguments.length > 1,
                    o = !1,
                    r = arguments[1],
                    s = r;
                return new n((function(n) {
                    return t.subscribe({
                        next: function(t) {
                            var r = !o;
                            if (o = !0, !r || i) try {
                                s = e(s, t)
                            } catch (e) {
                                return n.error(e)
                            } else s = t
                        },
                        error: function(e) {
                            n.error(e)
                        },
                        complete: function() {
                            if (!o && !i) return n.error(new TypeError("Cannot reduce an empty sequence"));
                            n.next(s), n.complete()
                        }
                    })
                }))
            }, t.concat = function() {
                for (var e = this, t = arguments.length, n = new Array(t), i = 0; i < t; i++) n[i] = arguments[i];
                var o = M(this);
                return new o((function(t) {
                    var i, r = 0;
                    return function e(s) {
                            i = s.subscribe({
                                next: function(e) {
                                    t.next(e)
                                },
                                error: function(e) {
                                    t.error(e)
                                },
                                complete: function() {
                                    r === n.length ? (i = void 0, t.complete()) : e(o.from(n[r++]))
                                }
                            })
                        }(e),
                        function() {
                            i && (i.unsubscribe(), i = void 0)
                        }
                }))
            }, t.flatMap = function(e) {
                var t = this;
                if ("function" != typeof e) throw new TypeError(e + " is not a function");
                var n = M(this);
                return new n((function(i) {
                    var o = [],
                        r = t.subscribe({
                            next: function(t) {
                                if (e) try {
                                    t = e(t)
                                } catch (e) {
                                    return i.error(e)
                                }
                                var r = n.from(t).subscribe({
                                    next: function(e) {
                                        i.next(e)
                                    },
                                    error: function(e) {
                                        i.error(e)
                                    },
                                    complete: function() {
                                        var e = o.indexOf(r);
                                        e >= 0 && o.splice(e, 1), s()
                                    }
                                });
                                o.push(r)
                            },
                            error: function(e) {
                                i.error(e)
                            },
                            complete: function() {
                                s()
                            }
                        });

                    function s() {
                        r.closed && 0 === o.length && i.complete()
                    }
                    return function() {
                        o.forEach((function(e) {
                            return e.unsubscribe()
                        })), r.unsubscribe()
                    }
                }))
            }, t[P] = function() {
                return this
            }, e.from = function(t) {
                var n = "function" == typeof this ? this : e;
                if (null == t) throw new TypeError(t + " is not an object");
                var i = R(t, P);
                if (i) {
                    var o = i.call(t);
                    if (Object(o) !== o) throw new TypeError(o + " is not an object");
                    return F(o) && o.constructor === n ? o : new n((function(e) {
                        return o.subscribe(e)
                    }))
                }
                if (N("iterator") && (i = R(t, A))) return new n((function(e) {
                    L((function() {
                        if (!e.closed) {
                            for (var n, o = function(e, t) {
                                    var n = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
                                    if (n) return (n = n.call(e)).next.bind(n);
                                    if (Array.isArray(e) || (n = function(e, t) {
                                            if (e) {
                                                if ("string" == typeof e) return O(e, t);
                                                var n = Object.prototype.toString.call(e).slice(8, -1);
                                                return "Object" === n && e.constructor && (n = e.constructor.name), "Map" === n || "Set" === n ? Array.from(e) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? O(e, t) : void 0
                                            }
                                        }(e))) {
                                        n && (e = n);
                                        var i = 0;
                                        return function() {
                                            return i >= e.length ? {
                                                done: !0
                                            } : {
                                                done: !1,
                                                value: e[i++]
                                            }
                                        }
                                    }
                                    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
                                }(i.call(t)); !(n = o()).done;)
                                if (e.next(n.value), e.closed) return;
                            e.complete()
                        }
                    }))
                }));
                if (Array.isArray(t)) return new n((function(e) {
                    L((function() {
                        if (!e.closed) {
                            for (var n = 0; n < t.length; ++n)
                                if (e.next(t[n]), e.closed) return;
                            e.complete()
                        }
                    }))
                }));
                throw new TypeError(t + " is not observable")
            }, e.of = function() {
                for (var t = arguments.length, n = new Array(t), i = 0; i < t; i++) n[i] = arguments[i];
                var o = "function" == typeof this ? this : e;
                return new o((function(e) {
                    L((function() {
                        if (!e.closed) {
                            for (var t = 0; t < n.length; ++t)
                                if (e.next(n[t]), e.closed) return;
                            e.complete()
                        }
                    }))
                }))
            }, x(e, null, [{
                key: j,
                get: function() {
                    return this
                }
            }]), e
        }();

    function B(e) {
        const t = null != e ? e : {};
        return Object.keys(t).every((e => "content-type" !== e.toLowerCase())) && (t["content-type"] = "application/json"), t
    }

    function H({
        message: e,
        embeddedIFrameElement: t,
        embedUrl: n
    }) {
        var i;
        null === (i = null == t ? void 0 : t.contentWindow) || void 0 === i || i.postMessage(e, n)
    }

    function J({
        endpointUrl: e,
        handleRequest: t,
        headers: r,
        includeCookies: a,
        operationId: c,
        operation: l,
        operationName: u,
        variables: p,
        fileVariables: d,
        embeddedIFrameElement: f,
        embedUrl: O,
        isMultipartSubscription: S,
        multipartSubscriptionClient: x
    }) {
        return s(this, void 0, void 0, (function*() {
            const C = {
                query: l,
                variables: p,
                operationName: u
            };
            let N;
            if (d && d.length > 0) {
                const n = yield(({
                    fileVariables: e,
                    requestBody: t
                }) => s(void 0, void 0, void 0, (function*() {
                    const n = e.map((e => Object.assign(Object.assign({}, e), {
                            files: e.files.map((({
                                arrayBuffer: e,
                                fileName: t
                            }) => new File([new Blob([e])], t)))
                        }))),
                        i = {};
                    let o = 0;
                    const r = [];
                    let s = t.variables;
                    n.forEach((({
                        files: e,
                        variableKey: t,
                        isMultiFile: a
                    }, c) => {
                        (null == e ? void 0 : e.length) && (s = Object.assign(Object.assign({}, s), {
                            [t]: a ? new Array(e.length).fill(null) : null
                        }), Array.from(e).forEach((e => {
                            i[o] = [`${n.length>1?`${c}.`:""}variables.${t}${a?`.${o}`:""}`], r.push([o.toString(), e, e.name]), o++
                        })))
                    }));
                    const a = new FormData;
                    return a.append("operations", ((e, t) => {
                        let n;
                        try {
                            n = JSON.stringify(e)
                        } catch (e) {
                            throw new Error("Network request failed. Payload is not serializable")
                        }
                        return n
                    })({
                        query: t.query,
                        operationName: t.operationName,
                        variables: s
                    })), a.append("map", JSON.stringify(i)), r.forEach((e => {
                        a.append(e[0], e[1], e[2])
                    })), a
                })))({
                    fileVariables: d,
                    requestBody: C
                });
                N = t(e, Object.assign({
                    method: "POST",
                    headers: null != r ? r : {},
                    body: n
                }, a ? {
                    credentials: "include"
                } : {}))
            } else N = t(e, Object.assign({
                method: "POST",
                headers: B(r),
                body: JSON.stringify(C)
            }, a ? {
                credentials: "include"
            } : {
                credentials: "omit"
            }));
            N.then((e => s(this, void 0, void 0, (function*() {
                var t;
                const r = {};
                e.headers.forEach(((e, t) => {
                    r[t] = e
                }));
                const s = null === (t = e.headers) || void 0 === t ? void 0 : t.get("content-type"),
                    a = s && new class {
                        constructor(e) {
                            const t = (e => {
                                e = h(e);
                                let t = 0,
                                    n = "";
                                for (; t < e.length && "/" !== e[t];) n += e[t], ++t;
                                if (0 === n.length || !v(n)) return null;
                                if (t >= e.length) return null;
                                ++t;
                                let i = "";
                                for (; t < e.length && ";" !== e[t];) i += e[t], ++t;
                                if (i = m(i), 0 === i.length || !v(i)) return null;
                                const o = {
                                    type: g(n),
                                    subtype: g(i),
                                    parameters: new Map
                                };
                                for (; t < e.length;) {
                                    for (++t; y(e[t]);) ++t;
                                    let n = "";
                                    for (; t < e.length && ";" !== e[t] && "=" !== e[t];) n += e[t], ++t;
                                    if (n = g(n), t < e.length) {
                                        if (";" === e[t]) continue;
                                        ++t
                                    }
                                    let i = null;
                                    if ('"' === e[t])
                                        for ([i, t] = E(e, t); t < e.length && ";" !== e[t];) ++t;
                                    else {
                                        for (i = ""; t < e.length && ";" !== e[t];) i += e[t], ++t;
                                        if (i = m(i), "" === i) continue
                                    }
                                    n.length > 0 && v(n) && b(i) && !o.parameters.has(n) && o.parameters.set(n, i)
                                }
                                return o
                            })(e = String(e));
                            if (null === t) throw new Error(`Could not parse MIME type string "${e}"`);
                            this._type = t.type, this._subtype = t.subtype, this._parameters = new T(t.parameters)
                        }
                        static parse(e) {
                            try {
                                return new this(e)
                            } catch (e) {
                                return null
                            }
                        }
                        get essence() {
                            return `${this.type}/${this.subtype}`
                        }
                        get type() {
                            return this._type
                        }
                        set type(e) {
                            if (0 === (e = I(String(e))).length) throw new Error("Invalid type: must be a non-empty string");
                            if (!_(e)) throw new Error(`Invalid type ${e}: must contain only HTTP token code points`);
                            this._type = e
                        }
                        get subtype() {
                            return this._subtype
                        }
                        set subtype(e) {
                            if (0 === (e = I(String(e))).length) throw new Error("Invalid subtype: must be a non-empty string");
                            if (!_(e)) throw new Error(`Invalid subtype ${e}: must contain only HTTP token code points`);
                            this._subtype = e
                        }
                        get parameters() {
                            return this._parameters
                        }
                        toString() {
                            return (e => {
                                let t = `${e.type}/${e.subtype}`;
                                if (0 === e.parameters.size) return t;
                                for (let [n, i] of e.parameters) t += ";", t += n, t += "=", w(i) && 0 !== i.length || (i = i.replace(/(["\\])/gu, "\\$1"), i = `"${i}"`), t += i;
                                return t
                            })(this)
                        }
                        isJavaScript({
                            prohibitParameters: e = !1
                        } = {}) {
                            switch (this._type) {
                                case "text":
                                    switch (this._subtype) {
                                        case "ecmascript":
                                        case "javascript":
                                        case "javascript1.0":
                                        case "javascript1.1":
                                        case "javascript1.2":
                                        case "javascript1.3":
                                        case "javascript1.4":
                                        case "javascript1.5":
                                        case "jscript":
                                        case "livescript":
                                        case "x-ecmascript":
                                        case "x-javascript":
                                            return !e || 0 === this._parameters.size;
                                        default:
                                            return !1
                                    }
                                case "application":
                                    switch (this._subtype) {
                                        case "ecmascript":
                                        case "javascript":
                                        case "x-ecmascript":
                                        case "x-javascript":
                                            return !e || 0 === this._parameters.size;
                                        default:
                                            return !1
                                    }
                                default:
                                    return !1
                            }
                        }
                        isXML() {
                            return "xml" === this._subtype && ("text" === this._type || "application" === this._type) || this._subtype.endsWith("+xml")
                        }
                        isHTML() {
                            return "html" === this._subtype && "text" === this._type
                        }
                    }(s);
                if (a && "multipart" === a.type && "mixed" === a.subtype) {
                    null == x || x.emit("connected");
                    const {
                        observable: t,
                        closeReadableStream: s
                    } = function(e, t) {
                        if (null === e.body) throw new Error("Missing body");
                        if ("function" != typeof e.body.tee) throw new Error("Streaming bodies not supported by provided fetch implementation");
                        const n = new TextDecoder("utf-8");
                        let i = "";
                        const o = `--${t.parameters.get("boundary")||"-"}`,
                            r = e.body.getReader();
                        return {
                            closeReadableStream: () => r.cancel(),
                            observable: new W((e => {
                                ! function t() {
                                    r.read().then((r => {
                                        var s, a, c;
                                        if (r.done) return void(null === (s = e.complete) || void 0 === s || s.call(e));
                                        const l = n.decode(r.value);
                                        i += l;
                                        let u = i.indexOf(o);
                                        for (; u > -1;) {
                                            const t = i.slice(0, u);
                                            if (i = i.slice(u + o.length), t.trim()) {
                                                const n = "\r\n\r\n";
                                                let i;
                                                if (t.lastIndexOf(n) !== t.indexOf(n)) {
                                                    const e = t.indexOf(n) + n.length;
                                                    i = t.substring(e).indexOf(n) + e
                                                } else i = t.indexOf(n);
                                                const o = Object.fromEntries(t.slice(0, i).split("\n").map((e => {
                                                    const t = e.indexOf(":");
                                                    return t > -1 ? [e.slice(0, t).trim(), e.slice(t + 1).trim()] : null
                                                })).filter((e => !!e)));
                                                if (-1 === (null === (a = o["content-type"]) || void 0 === a ? void 0 : a.toLowerCase().indexOf("application/json"))) throw new Error("Unsupported patch content type");
                                                const r = t.slice(i);
                                                try {
                                                    null === (c = e.next) || void 0 === c || c.call(e, Object.assign({
                                                        data: JSON.parse(r),
                                                        headers: o,
                                                        size: l.length
                                                    }, l.indexOf("--graphql--") > -1 ? {
                                                        shouldTerminate: !0
                                                    } : {}))
                                                } catch (e) {
                                                    throw e
                                                }
                                            }
                                            u = i.indexOf(o)
                                        }
                                        t()
                                    })).catch((t => {
                                        var n, i;
                                        "AbortError" !== t.name && (t.result && t.result.errors && t.result.data && (null === (n = e.next) || void 0 === n || n.call(e, {
                                            data: t.result,
                                            size: Infinity
                                        })), null === (i = e.error) || void 0 === i || i.call(e, t))
                                    }))
                                }()
                            }))
                        }
                    }(e, a);
                    let l = !0;
                    const u = t.subscribe({
                        next(t) {
                            "payload" in t.data ? ("shouldTerminate" in t && t.shouldTerminate && (u.unsubscribe(), s(), H({
                                message: {
                                    name: o,
                                    status: "disconnected"
                                },
                                embeddedIFrameElement: f,
                                embedUrl: O
                            })), H({
                                message: {
                                    name: i,
                                    operationId: c,
                                    response: {
                                        data: t.data,
                                        status: e.status,
                                        headers: l ? [r, ...Array.isArray(t.headers) ? t.headers : t.headers ? [t.headers] : []] : t.headers,
                                        size: t.size
                                    }
                                },
                                embeddedIFrameElement: f,
                                embedUrl: O
                            })) : H({
                                message: {
                                    name: n,
                                    operationId: c,
                                    response: {
                                        incremental: t.data.incremental,
                                        data: t.data.data,
                                        errors: t.data.errors,
                                        extensions: t.data.extensions,
                                        path: t.data.path,
                                        status: e.status,
                                        headers: l ? [r, ...Array.isArray(t.headers) ? t.headers : t.headers ? [t.headers] : []] : t.headers,
                                        hasNext: !0,
                                        size: t.size
                                    }
                                },
                                embeddedIFrameElement: f,
                                embedUrl: O
                            }), l = !1
                        },
                        error(e) {
                            const t = e && "object" == typeof e && "message" in e && "string" == typeof e.message ? Object.assign({
                                message: e.message
                            }, "stack" in e && "string" == typeof e.stack ? {
                                stack: e.stack
                            } : {}) : void 0;
                            H({
                                message: {
                                    name: S ? i : n,
                                    operationId: c,
                                    response: Object.assign({
                                        data: null,
                                        error: t
                                    }, S ? {} : {
                                        hasNext: !1
                                    })
                                },
                                embeddedIFrameElement: f,
                                embedUrl: O
                            })
                        },
                        complete() {
                            H({
                                message: {
                                    name: S ? i : n,
                                    operationId: c,
                                    response: Object.assign({
                                        data: null,
                                        status: e.status,
                                        headers: l ? r : void 0
                                    }, S ? {} : {
                                        hasNext: !1
                                    })
                                },
                                embeddedIFrameElement: f,
                                embedUrl: O
                            })
                        }
                    });
                    x && (x.stopListeningCallback = () => {
                        s(), u.unsubscribe()
                    })
                } else {
                    const t = yield e.json();
                    null == x || x.emit("error"), null == x || x.emit("disconnected"), H({
                        message: {
                            name: S ? i : n,
                            operationId: c,
                            response: Object.assign(Object.assign({}, t), {
                                status: e.status,
                                headers: r,
                                hasNext: !1
                            })
                        },
                        embeddedIFrameElement: f,
                        embedUrl: O
                    })
                }
            })))).catch((e => {
                null == x || x.emit("error", e), null == x || x.emit("disconnected");
                const t = e && "object" == typeof e && "message" in e && "string" == typeof e.message ? Object.assign({
                    message: e.message
                }, "stack" in e && "string" == typeof e.stack ? {
                    stack: e.stack
                } : {}) : void 0;
                H({
                    message: {
                        name: S ? i : n,
                        operationId: c,
                        response: Object.assign({
                            data: null,
                            error: t
                        }, S ? {} : {
                            hasNext: !1
                        })
                    },
                    embeddedIFrameElement: f,
                    embedUrl: O
                })
            }))
        }))
    }
    C() && Object.defineProperty(W, Symbol("extensions"), {
        value: {
            symbol: P,
            hostReportError: U
        },
        configurable: !0
    });
    var z = {
        exports: {}
    };
    ! function(e) {
        var t = Object.prototype.hasOwnProperty,
            n = "~";

        function i() {}

        function o(e, t, n) {
            this.fn = e, this.context = t, this.once = n || !1
        }

        function r(e, t, i, r, s) {
            if ("function" != typeof i) throw new TypeError("The listener must be a function");
            var a = new o(i, r || e, s),
                c = n ? n + t : t;
            return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], a] : e._events[c].push(a) : (e._events[c] = a, e._eventsCount++), e
        }

        function s(e, t) {
            0 == --e._eventsCount ? e._events = new i : delete e._events[t]
        }

        function a() {
            this._events = new i, this._eventsCount = 0
        }
        Object.create && (i.prototype = Object.create(null), (new i).__proto__ || (n = !1)), a.prototype.eventNames = function() {
            var e, i, o = [];
            if (0 === this._eventsCount) return o;
            for (i in e = this._events) t.call(e, i) && o.push(n ? i.slice(1) : i);
            return Object.getOwnPropertySymbols ? o.concat(Object.getOwnPropertySymbols(e)) : o
        }, a.prototype.listeners = function(e) {
            var t = this._events[n ? n + e : e];
            if (!t) return [];
            if (t.fn) return [t.fn];
            for (var i = 0, o = t.length, r = new Array(o); i < o; i++) r[i] = t[i].fn;
            return r
        }, a.prototype.listenerCount = function(e) {
            var t = this._events[n ? n + e : e];
            return t ? t.fn ? 1 : t.length : 0
        }, a.prototype.emit = function(e, t, i, o, r, s) {
            var a = n ? n + e : e;
            if (!this._events[a]) return !1;
            var c, l, u = this._events[a],
                p = arguments.length;
            if (u.fn) {
                switch (u.once && this.removeListener(e, u.fn, void 0, !0), p) {
                    case 1:
                        return u.fn.call(u.context), !0;
                    case 2:
                        return u.fn.call(u.context, t), !0;
                    case 3:
                        return u.fn.call(u.context, t, i), !0;
                    case 4:
                        return u.fn.call(u.context, t, i, o), !0;
                    case 5:
                        return u.fn.call(u.context, t, i, o, r), !0;
                    case 6:
                        return u.fn.call(u.context, t, i, o, r, s), !0
                }
                for (l = 1, c = new Array(p - 1); l < p; l++) c[l - 1] = arguments[l];
                u.fn.apply(u.context, c)
            } else {
                var d, f = u.length;
                for (l = 0; l < f; l++) switch (u[l].once && this.removeListener(e, u[l].fn, void 0, !0), p) {
                    case 1:
                        u[l].fn.call(u[l].context);
                        break;
                    case 2:
                        u[l].fn.call(u[l].context, t);
                        break;
                    case 3:
                        u[l].fn.call(u[l].context, t, i);
                        break;
                    case 4:
                        u[l].fn.call(u[l].context, t, i, o);
                        break;
                    default:
                        if (!c)
                            for (d = 1, c = new Array(p - 1); d < p; d++) c[d - 1] = arguments[d];
                        u[l].fn.apply(u[l].context, c)
                }
            }
            return !0
        }, a.prototype.on = function(e, t, n) {
            return r(this, e, t, n, !1)
        }, a.prototype.once = function(e, t, n) {
            return r(this, e, t, n, !0)
        }, a.prototype.removeListener = function(e, t, i, o) {
            var r = n ? n + e : e;
            if (!this._events[r]) return this;
            if (!t) return s(this, r), this;
            var a = this._events[r];
            if (a.fn) a.fn !== t || o && !a.once || i && a.context !== i || s(this, r);
            else {
                for (var c = 0, l = [], u = a.length; c < u; c++)(a[c].fn !== t || o && !a[c].once || i && a[c].context !== i) && l.push(a[c]);
                l.length ? this._events[r] = 1 === l.length ? l[0] : l : s(this, r)
            }
            return this
        }, a.prototype.removeAllListeners = function(e) {
            var t;
            return e ? this._events[t = n ? n + e : e] && s(this, t) : (this._events = new i, this._eventsCount = 0), this
        }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a
    }(z);
    var K, Y, X = z.exports;

    function Z(e) {
        return null === e ? "null" : Array.isArray(e) ? "array" : typeof e
    }

    function ee(e) {
        return "object" === Z(e)
    }

    function te(e, t) {
        return e.length < 124 ? e : t
    }

    function ne(e) {
        if (!ee(e)) throw new Error(`Message is expected to be an object, but got ${Z(e)}`);
        if (!e.type) throw new Error("Message is missing the 'type' property");
        if ("string" != typeof e.type) throw new Error(`Message is expects the 'type' property to be a string, but got ${Z(e.type)}`);
        switch (e.type) {
            case Y.ConnectionInit:
            case Y.ConnectionAck:
            case Y.Ping:
            case Y.Pong:
                if ("payload" in e && !ee(e.payload)) throw new Error(`"${e.type}" message expects the 'payload' property to be an object or missing, but got "${e.payload}"`);
                break;
            case Y.Subscribe:
                if ("string" != typeof e.id) throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Z(e.id)}`);
                if (!e.id) throw new Error(`"${e.type}" message requires a non-empty 'id' property`);
                if (!ee(e.payload)) throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${Z(e.payload)}`);
                if ("string" != typeof e.payload.query) throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${Z(e.payload.query)}`);
                if (null != e.payload.variables && !ee(e.payload.variables)) throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${Z(e.payload.variables)}`);
                if (null != e.payload.operationName && "string" !== Z(e.payload.operationName)) throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${Z(e.payload.operationName)}`);
                if (null != e.payload.extensions && !ee(e.payload.extensions)) throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${Z(e.payload.extensions)}`);
                break;
            case Y.Next:
                if ("string" != typeof e.id) throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Z(e.id)}`);
                if (!e.id) throw new Error(`"${e.type}" message requires a non-empty 'id' property`);
                if (!ee(e.payload)) throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${Z(e.payload)}`);
                break;
            case Y.Error:
                if ("string" != typeof e.id) throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Z(e.id)}`);
                if (!e.id) throw new Error(`"${e.type}" message requires a non-empty 'id' property`);
                if (t = e.payload, !(Array.isArray(t) && t.length > 0 && t.every((e => "message" in e)))) throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);
                break;
            case Y.Complete:
                if ("string" != typeof e.id) throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${Z(e.id)}`);
                if (!e.id) throw new Error(`"${e.type}" message requires a non-empty 'id' property`);
                break;
            default:
                throw new Error(`Invalid message 'type' property "${e.type}"`)
        }
        var t;
        return e
    }

    function ie(e, t) {
        return ne(e), JSON.stringify(e, t)
    }

    function oe(e) {
        return ee(e) && "code" in e && "reason" in e
    }

    function re(e, t) {
        if (!Boolean(e)) throw new Error(t)
    }! function(e) {
        e[e.InternalServerError = 4500] = "InternalServerError", e[e.InternalClientError = 4005] = "InternalClientError", e[e.BadRequest = 4400] = "BadRequest", e[e.BadResponse = 4004] = "BadResponse", e[e.Unauthorized = 4401] = "Unauthorized", e[e.Forbidden = 4403] = "Forbidden", e[e.SubprotocolNotAcceptable = 4406] = "SubprotocolNotAcceptable", e[e.ConnectionInitialisationTimeout = 4408] = "ConnectionInitialisationTimeout", e[e.ConnectionAcknowledgementTimeout = 4504] = "ConnectionAcknowledgementTimeout", e[e.SubscriberAlreadyExists = 4409] = "SubscriberAlreadyExists", e[e.TooManyInitialisationRequests = 4429] = "TooManyInitialisationRequests"
    }(K || (K = {})),
    function(e) {
        e.ConnectionInit = "connection_init", e.ConnectionAck = "connection_ack", e.Ping = "ping", e.Pong = "pong", e.Subscribe = "subscribe", e.Next = "next", e.Error = "error", e.Complete = "complete"
    }(Y || (Y = {}));
    const se = {
            Name: [],
            Document: ["definitions"],
            OperationDefinition: ["name", "variableDefinitions", "directives", "selectionSet"],
            VariableDefinition: ["variable", "type", "defaultValue", "directives"],
            Variable: ["name"],
            SelectionSet: ["selections"],
            Field: ["alias", "name", "arguments", "directives", "selectionSet"],
            Argument: ["name", "value"],
            FragmentSpread: ["name", "directives"],
            InlineFragment: ["typeCondition", "directives", "selectionSet"],
            FragmentDefinition: ["name", "variableDefinitions", "typeCondition", "directives", "selectionSet"],
            IntValue: [],
            FloatValue: [],
            StringValue: [],
            BooleanValue: [],
            NullValue: [],
            EnumValue: [],
            ListValue: ["values"],
            ObjectValue: ["fields"],
            ObjectField: ["name", "value"],
            Directive: ["name", "arguments"],
            NamedType: ["name"],
            ListType: ["type"],
            NonNullType: ["type"],
            SchemaDefinition: ["description", "directives", "operationTypes"],
            OperationTypeDefinition: ["type"],
            ScalarTypeDefinition: ["description", "name", "directives"],
            ObjectTypeDefinition: ["description", "name", "interfaces", "directives", "fields"],
            FieldDefinition: ["description", "name", "arguments", "type", "directives"],
            InputValueDefinition: ["description", "name", "type", "defaultValue", "directives"],
            InterfaceTypeDefinition: ["description", "name", "interfaces", "directives", "fields"],
            UnionTypeDefinition: ["description", "name", "directives", "types"],
            EnumTypeDefinition: ["description", "name", "directives", "values"],
            EnumValueDefinition: ["description", "name", "directives"],
            InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
            DirectiveDefinition: ["description", "name", "arguments", "locations"],
            SchemaExtension: ["directives", "operationTypes"],
            ScalarTypeExtension: ["name", "directives"],
            ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
            InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
            UnionTypeExtension: ["name", "directives", "types"],
            EnumTypeExtension: ["name", "directives", "values"],
            InputObjectTypeExtension: ["name", "directives", "fields"]
        },
        ae = new Set(Object.keys(se));

    function ce(e) {
        const t = null == e ? void 0 : e.kind;
        return "string" == typeof t && ae.has(t)
    }
    var le, ue;

    function pe(e) {
        return 9 === e || 32 === e
    }

    function de(e, t) {
        switch (typeof e) {
            case "string":
                return JSON.stringify(e);
            case "function":
                return e.name ? `[function ${e.name}]` : "[function]";
            case "object":
                return function(e, t) {
                    if (null === e) return "null";
                    if (t.includes(e)) return "[Circular]";
                    const n = [...t, e];
                    if (function(e) {
                            return "function" == typeof e.toJSON
                        }(e)) {
                        const t = e.toJSON();
                        if (t !== e) return "string" == typeof t ? t : de(t, n)
                    } else if (Array.isArray(e)) return function(e, t) {
                        if (0 === e.length) return "[]";
                        if (t.length > 2) return "[Array]";
                        const n = Math.min(10, e.length),
                            i = e.length - n,
                            o = [];
                        for (let i = 0; i < n; ++i) o.push(de(e[i], t));
                        return 1 === i ? o.push("... 1 more item") : i > 1 && o.push(`... ${i} more items`), "[" + o.join(", ") + "]"
                    }(e, n);
                    return function(e, t) {
                        const n = Object.entries(e);
                        if (0 === n.length) return "{}";
                        if (t.length > 2) return "[" + function(e) {
                            const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
                            if ("Object" === t && "function" == typeof e.constructor) {
                                const t = e.constructor.name;
                                if ("string" == typeof t && "" !== t) return t
                            }
                            return t
                        }(e) + "]";
                        const i = n.map((([e, n]) => e + ": " + de(n, t)));
                        return "{ " + i.join(", ") + " }"
                    }(e, n)
                }(e, t);
            default:
                return String(e)
        }
    }! function(e) {
        e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription"
    }(le || (le = {})),
    function(e) {
        e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension"
    }(ue || (ue = {}));
    const fe = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;

    function he(e) {
        return me[e.charCodeAt(0)]
    }
    const me = ["\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000B", "\\f", "\\r", "\\u000E", "\\u000F", "\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001A", "\\u001B", "\\u001C", "\\u001D", "\\u001E", "\\u001F", "", "", '\\"', "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "\\\\", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "\\u007F", "\\u0080", "\\u0081", "\\u0082", "\\u0083", "\\u0084", "\\u0085", "\\u0086", "\\u0087", "\\u0088", "\\u0089", "\\u008A", "\\u008B", "\\u008C", "\\u008D", "\\u008E", "\\u008F", "\\u0090", "\\u0091", "\\u0092", "\\u0093", "\\u0094", "\\u0095", "\\u0096", "\\u0097", "\\u0098", "\\u0099", "\\u009A", "\\u009B", "\\u009C", "\\u009D", "\\u009E", "\\u009F"],
        ye = Object.freeze({});

    function ve(e, t) {
        const n = e[t];
        return "object" == typeof n ? n : "function" == typeof n ? {
            enter: n,
            leave: void 0
        } : {
            enter: e.enter,
            leave: e.leave
        }
    }
    const be = {
        Name: {
            leave: e => e.value
        },
        Variable: {
            leave: e => "$" + e.name
        },
        Document: {
            leave: e => ge(e.definitions, "\n\n")
        },
        OperationDefinition: {
            leave(e) {
                const t = we("(", ge(e.variableDefinitions, ", "), ")"),
                    n = ge([e.operation, ge([e.name, t]), ge(e.directives, " ")], " ");
                return ("query" === n ? "" : n + " ") + e.selectionSet
            }
        },
        VariableDefinition: {
            leave: ({
                variable: e,
                type: t,
                defaultValue: n,
                directives: i
            }) => e + ": " + t + we(" = ", n) + we(" ", ge(i, " "))
        },
        SelectionSet: {
            leave: ({
                selections: e
            }) => Ee(e)
        },
        Field: {
            leave({
                alias: e,
                name: t,
                arguments: n,
                directives: i,
                selectionSet: o
            }) {
                const r = we("", e, ": ") + t;
                let s = r + we("(", ge(n, ", "), ")");
                return s.length > 80 && (s = r + we("(\n", Te(ge(n, "\n")), "\n)")), ge([s, ge(i, " "), o], " ")
            }
        },
        Argument: {
            leave: ({
                name: e,
                value: t
            }) => e + ": " + t
        },
        FragmentSpread: {
            leave: ({
                name: e,
                directives: t
            }) => "..." + e + we(" ", ge(t, " "))
        },
        InlineFragment: {
            leave: ({
                typeCondition: e,
                directives: t,
                selectionSet: n
            }) => ge(["...", we("on ", e), ge(t, " "), n], " ")
        },
        FragmentDefinition: {
            leave: ({
                name: e,
                typeCondition: t,
                variableDefinitions: n,
                directives: i,
                selectionSet: o
            }) => `fragment ${e}${we("(",ge(n,", "),")")} on ${t} ${we("",ge(i," ")," ")}` + o
        },
        IntValue: {
            leave: ({
                value: e
            }) => e
        },
        FloatValue: {
            leave: ({
                value: e
            }) => e
        },
        StringValue: {
            leave: ({
                value: e,
                block: t
            }) => t ? function(e, t) {
                const n = e.replace(/"""/g, '\\"""'),
                    i = n.split(/\r\n|[\n\r]/g),
                    o = 1 === i.length,
                    r = i.length > 1 && i.slice(1).every((e => 0 === e.length || pe(e.charCodeAt(0)))),
                    s = n.endsWith('\\"""'),
                    a = e.endsWith('"') && !s,
                    c = e.endsWith("\\"),
                    l = a || c,
                    u = !o || e.length > 70 || l || r || s;
                let p = "";
                const d = o && pe(e.charCodeAt(0));
                return (u && !d || r) && (p += "\n"), p += n, (u || l) && (p += "\n"), '"""' + p + '"""'
            }(e) : `"${e.replace(fe,he)}"`
        },
        BooleanValue: {
            leave: ({
                value: e
            }) => e ? "true" : "false"
        },
        NullValue: {
            leave: () => "null"
        },
        EnumValue: {
            leave: ({
                value: e
            }) => e
        },
        ListValue: {
            leave: ({
                values: e
            }) => "[" + ge(e, ", ") + "]"
        },
        ObjectValue: {
            leave: ({
                fields: e
            }) => "{" + ge(e, ", ") + "}"
        },
        ObjectField: {
            leave: ({
                name: e,
                value: t
            }) => e + ": " + t
        },
        Directive: {
            leave: ({
                name: e,
                arguments: t
            }) => "@" + e + we("(", ge(t, ", "), ")")
        },
        NamedType: {
            leave: ({
                name: e
            }) => e
        },
        ListType: {
            leave: ({
                type: e
            }) => "[" + e + "]"
        },
        NonNullType: {
            leave: ({
                type: e
            }) => e + "!"
        },
        SchemaDefinition: {
            leave: ({
                description: e,
                directives: t,
                operationTypes: n
            }) => we("", e, "\n") + ge(["schema", ge(t, " "), Ee(n)], " ")
        },
        OperationTypeDefinition: {
            leave: ({
                operation: e,
                type: t
            }) => e + ": " + t
        },
        ScalarTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                directives: n
            }) => we("", e, "\n") + ge(["scalar", t, ge(n, " ")], " ")
        },
        ObjectTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                interfaces: n,
                directives: i,
                fields: o
            }) => we("", e, "\n") + ge(["type", t, we("implements ", ge(n, " & ")), ge(i, " "), Ee(o)], " ")
        },
        FieldDefinition: {
            leave: ({
                description: e,
                name: t,
                arguments: n,
                type: i,
                directives: o
            }) => we("", e, "\n") + t + (Ie(n) ? we("(\n", Te(ge(n, "\n")), "\n)") : we("(", ge(n, ", "), ")")) + ": " + i + we(" ", ge(o, " "))
        },
        InputValueDefinition: {
            leave: ({
                description: e,
                name: t,
                type: n,
                defaultValue: i,
                directives: o
            }) => we("", e, "\n") + ge([t + ": " + n, we("= ", i), ge(o, " ")], " ")
        },
        InterfaceTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                interfaces: n,
                directives: i,
                fields: o
            }) => we("", e, "\n") + ge(["interface", t, we("implements ", ge(n, " & ")), ge(i, " "), Ee(o)], " ")
        },
        UnionTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                directives: n,
                types: i
            }) => we("", e, "\n") + ge(["union", t, ge(n, " "), we("= ", ge(i, " | "))], " ")
        },
        EnumTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                directives: n,
                values: i
            }) => we("", e, "\n") + ge(["enum", t, ge(n, " "), Ee(i)], " ")
        },
        EnumValueDefinition: {
            leave: ({
                description: e,
                name: t,
                directives: n
            }) => we("", e, "\n") + ge([t, ge(n, " ")], " ")
        },
        InputObjectTypeDefinition: {
            leave: ({
                description: e,
                name: t,
                directives: n,
                fields: i
            }) => we("", e, "\n") + ge(["input", t, ge(n, " "), Ee(i)], " ")
        },
        DirectiveDefinition: {
            leave: ({
                description: e,
                name: t,
                arguments: n,
                repeatable: i,
                locations: o
            }) => we("", e, "\n") + "directive @" + t + (Ie(n) ? we("(\n", Te(ge(n, "\n")), "\n)") : we("(", ge(n, ", "), ")")) + (i ? " repeatable" : "") + " on " + ge(o, " | ")
        },
        SchemaExtension: {
            leave: ({
                directives: e,
                operationTypes: t
            }) => ge(["extend schema", ge(e, " "), Ee(t)], " ")
        },
        ScalarTypeExtension: {
            leave: ({
                name: e,
                directives: t
            }) => ge(["extend scalar", e, ge(t, " ")], " ")
        },
        ObjectTypeExtension: {
            leave: ({
                name: e,
                interfaces: t,
                directives: n,
                fields: i
            }) => ge(["extend type", e, we("implements ", ge(t, " & ")), ge(n, " "), Ee(i)], " ")
        },
        InterfaceTypeExtension: {
            leave: ({
                name: e,
                interfaces: t,
                directives: n,
                fields: i
            }) => ge(["extend interface", e, we("implements ", ge(t, " & ")), ge(n, " "), Ee(i)], " ")
        },
        UnionTypeExtension: {
            leave: ({
                name: e,
                directives: t,
                types: n
            }) => ge(["extend union", e, ge(t, " "), we("= ", ge(n, " | "))], " ")
        },
        EnumTypeExtension: {
            leave: ({
                name: e,
                directives: t,
                values: n
            }) => ge(["extend enum", e, ge(t, " "), Ee(n)], " ")
        },
        InputObjectTypeExtension: {
            leave: ({
                name: e,
                directives: t,
                fields: n
            }) => ge(["extend input", e, ge(t, " "), Ee(n)], " ")
        }
    };

    function ge(e, t = "") {
        var n;
        return null !== (n = null == e ? void 0 : e.filter((e => e)).join(t)) && void 0 !== n ? n : ""
    }

    function Ee(e) {
        return we("{\n", Te(ge(e, "\n")), "\n}")
    }

    function we(e, t, n = "") {
        return null != t && "" !== t ? e + t + n : ""
    }

    function Te(e) {
        return we("  ", e.replace(/\n/g, "\n  "))
    }

    function Ie(e) {
        var t;
        return null !== (t = null == e ? void 0 : e.some((e => e.includes("\n")))) && void 0 !== t && t
    }
    var _e = {
            __proto__: null,
            print: function(e) {
                return function(e, t, n = se) {
                    const i = new Map;
                    for (const e of Object.values(ue)) i.set(e, ve(t, e));
                    let o, r, s, a = Array.isArray(e),
                        c = [e],
                        l = -1,
                        u = [],
                        p = e;
                    const d = [],
                        f = [];
                    do {
                        l++;
                        const e = l === c.length,
                            b = e && 0 !== u.length;
                        if (e) {
                            if (r = 0 === f.length ? void 0 : d[d.length - 1], p = s, s = f.pop(), b)
                                if (a) {
                                    p = p.slice();
                                    let e = 0;
                                    for (const [t, n] of u) {
                                        const i = t - e;
                                        null === n ? (p.splice(i, 1), e++) : p[i] = n
                                    }
                                } else {
                                    p = Object.defineProperties({}, Object.getOwnPropertyDescriptors(p));
                                    for (const [e, t] of u) p[e] = t
                                } l = o.index, c = o.keys, u = o.edits, a = o.inArray, o = o.prev
                        } else if (s) {
                            if (r = a ? l : c[l], p = s[r], null == p) continue;
                            d.push(r)
                        }
                        let g;
                        if (!Array.isArray(p)) {
                            var h, m;
                            ce(p) || re(!1, `Invalid AST Node: ${v=p,de(v,[])}.`);
                            const n = e ? null === (h = i.get(p.kind)) || void 0 === h ? void 0 : h.leave : null === (m = i.get(p.kind)) || void 0 === m ? void 0 : m.enter;
                            if (g = null == n ? void 0 : n.call(t, p, r, s, d, f), g === ye) break;
                            if (!1 === g) {
                                if (!e) {
                                    d.pop();
                                    continue
                                }
                            } else if (void 0 !== g && (u.push([r, g]), !e)) {
                                if (!ce(g)) {
                                    d.pop();
                                    continue
                                }
                                p = g
                            }
                        }
                        var y;
                        void 0 === g && b && u.push([r, p]), e ? d.pop() : (o = {
                            inArray: a,
                            index: l,
                            keys: c,
                            edits: u,
                            prev: o
                        }, a = Array.isArray(p), c = a ? p : null !== (y = n[p.kind]) && void 0 !== y ? y : [], l = -1, u = [], s && f.push(s), s = p)
                    } while (void 0 !== o);
                    var v;
                    return 0 !== u.length ? u[u.length - 1][1] : e
                }(e, be)
            }
        },
        Oe = {
            __proto__: null,
            getOperationAST: function(e, t) {
                let n = null;
                for (const o of e.definitions) {
                    var i;
                    if (o.kind === ue.OPERATION_DEFINITION)
                        if (null == t) {
                            if (n) return null;
                            n = o
                        } else if ((null === (i = o.name) || void 0 === i ? void 0 : i.value) === t) return o
                }
                return n
            }
        },
        Se = {},
        xe = Ce;

    function Ce(e) {
        this.ms = (e = e || {}).min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0
    }
    Ce.prototype.duration = function() {
        var e = this.ms * Math.pow(this.factor, this.attempts++);
        if (this.jitter) {
            var t = Math.random(),
                n = Math.floor(t * this.jitter * e);
            e = 0 == (1 & Math.floor(10 * t)) ? e - n : e + n
        }
        return 0 | Math.min(e, this.max)
    }, Ce.prototype.reset = function() {
        this.attempts = 0
    }, Ce.prototype.setMin = function(e) {
        this.ms = e
    }, Ce.prototype.setMax = function(e) {
        this.max = e
    }, Ce.prototype.setJitter = function(e) {
        this.jitter = e
    };
    var Ne = {
        exports: {}
    };
    ! function(e) {
        var t = Object.prototype.hasOwnProperty,
            n = "~";

        function i() {}

        function o(e, t, n) {
            this.fn = e, this.context = t, this.once = n || !1
        }

        function r(e, t, i, r, s) {
            if ("function" != typeof i) throw new TypeError("The listener must be a function");
            var a = new o(i, r || e, s),
                c = n ? n + t : t;
            return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], a] : e._events[c].push(a) : (e._events[c] = a, e._eventsCount++), e
        }

        function s(e, t) {
            0 == --e._eventsCount ? e._events = new i : delete e._events[t]
        }

        function a() {
            this._events = new i, this._eventsCount = 0
        }
        Object.create && (i.prototype = Object.create(null), (new i).__proto__ || (n = !1)), a.prototype.eventNames = function() {
            var e, i, o = [];
            if (0 === this._eventsCount) return o;
            for (i in e = this._events) t.call(e, i) && o.push(n ? i.slice(1) : i);
            return Object.getOwnPropertySymbols ? o.concat(Object.getOwnPropertySymbols(e)) : o
        }, a.prototype.listeners = function(e) {
            var t = this._events[n ? n + e : e];
            if (!t) return [];
            if (t.fn) return [t.fn];
            for (var i = 0, o = t.length, r = new Array(o); i < o; i++) r[i] = t[i].fn;
            return r
        }, a.prototype.listenerCount = function(e) {
            var t = this._events[n ? n + e : e];
            return t ? t.fn ? 1 : t.length : 0
        }, a.prototype.emit = function(e, t, i, o, r, s) {
            var a = n ? n + e : e;
            if (!this._events[a]) return !1;
            var c, l, u = this._events[a],
                p = arguments.length;
            if (u.fn) {
                switch (u.once && this.removeListener(e, u.fn, void 0, !0), p) {
                    case 1:
                        return u.fn.call(u.context), !0;
                    case 2:
                        return u.fn.call(u.context, t), !0;
                    case 3:
                        return u.fn.call(u.context, t, i), !0;
                    case 4:
                        return u.fn.call(u.context, t, i, o), !0;
                    case 5:
                        return u.fn.call(u.context, t, i, o, r), !0;
                    case 6:
                        return u.fn.call(u.context, t, i, o, r, s), !0
                }
                for (l = 1, c = new Array(p - 1); l < p; l++) c[l - 1] = arguments[l];
                u.fn.apply(u.context, c)
            } else {
                var d, f = u.length;
                for (l = 0; l < f; l++) switch (u[l].once && this.removeListener(e, u[l].fn, void 0, !0), p) {
                    case 1:
                        u[l].fn.call(u[l].context);
                        break;
                    case 2:
                        u[l].fn.call(u[l].context, t);
                        break;
                    case 3:
                        u[l].fn.call(u[l].context, t, i);
                        break;
                    case 4:
                        u[l].fn.call(u[l].context, t, i, o);
                        break;
                    default:
                        if (!c)
                            for (d = 1, c = new Array(p - 1); d < p; d++) c[d - 1] = arguments[d];
                        u[l].fn.apply(u[l].context, c)
                }
            }
            return !0
        }, a.prototype.on = function(e, t, n) {
            return r(this, e, t, n, !1)
        }, a.prototype.once = function(e, t, n) {
            return r(this, e, t, n, !0)
        }, a.prototype.removeListener = function(e, t, i, o) {
            var r = n ? n + e : e;
            if (!this._events[r]) return this;
            if (!t) return s(this, r), this;
            var a = this._events[r];
            if (a.fn) a.fn !== t || o && !a.once || i && a.context !== i || s(this, r);
            else {
                for (var c = 0, l = [], u = a.length; c < u; c++)(a[c].fn !== t || o && !a[c].once || i && a[c].context !== i) && l.push(a[c]);
                l.length ? this._events[r] = 1 === l.length ? l[0] : l : s(this, r)
            }
            return this
        }, a.prototype.removeAllListeners = function(e) {
            var t;
            return e ? this._events[t = n ? n + e : e] && s(this, t) : (this._events = new i, this._eventsCount = 0), this
        }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a
    }(Ne);
    var ke = {};
    Object.defineProperty(ke, "__esModule", {
        value: !0
    }), ke.default = function(e) {
        return "string" == typeof e
    };
    var Ae = {};
    Object.defineProperty(Ae, "__esModule", {
        value: !0
    }), Ae.default = function(e) {
        return null !== e && "object" == typeof e
    };
    var Pe = c(_e),
        je = c(Oe),
        Re = c({
            __proto__: null,
            default: function(e) {
                var t, n = ("undefined" != typeof self ? self : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof module ? module : Function("return this")()).Symbol;
                return "function" == typeof n ? n.observable ? t = n.observable : (t = n("observable"), n.observable = t) : t = "@@observable", t
            }()
        }),
        Me = {};
    Object.defineProperty(Me, "__esModule", {
        value: !0
    }), Me.GRAPHQL_SUBSCRIPTIONS = Me.GRAPHQL_WS = void 0, Me.GRAPHQL_WS = "graphql-ws", Me.GRAPHQL_SUBSCRIPTIONS = "graphql-subscriptions";
    var Fe = {};
    Object.defineProperty(Fe, "__esModule", {
        value: !0
    }), Fe.WS_TIMEOUT = Fe.MIN_WS_TIMEOUT = void 0, Fe.MIN_WS_TIMEOUT = 1e3, Fe.WS_TIMEOUT = 3e4;
    var Ue = {};
    Object.defineProperty(Ue, "__esModule", {
        value: !0
    });
    var Le = function() {
        function e() {
            throw new Error("Static Class")
        }
        return e.GQL_CONNECTION_INIT = "connection_init", e.GQL_CONNECTION_ACK = "connection_ack", e.GQL_CONNECTION_ERROR = "connection_error", e.GQL_CONNECTION_KEEP_ALIVE = "ka", e.GQL_CONNECTION_TERMINATE = "connection_terminate", e.GQL_START = "start", e.GQL_DATA = "data", e.GQL_ERROR = "error", e.GQL_COMPLETE = "complete", e.GQL_STOP = "stop", e.SUBSCRIPTION_START = "subscription_start", e.SUBSCRIPTION_DATA = "subscription_data", e.SUBSCRIPTION_SUCCESS = "subscription_success", e.SUBSCRIPTION_FAIL = "subscription_fail", e.SUBSCRIPTION_END = "subscription_end", e.INIT = "init", e.INIT_SUCCESS = "init_success", e.INIT_FAIL = "init_fail", e.KEEP_ALIVE = "keepalive", e
    }();
    Ue.default = Le;
    var De = a && a.__assign || function() {
            return De = Object.assign || function(e) {
                for (var t, n = 1, i = arguments.length; n < i; n++)
                    for (var o in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
                return e
            }, De.apply(this, arguments)
        },
        qe = a && a.__awaiter || function(e, t, n, i) {
            return new(n || (n = Promise))((function(o, r) {
                function s(e) {
                    try {
                        c(i.next(e))
                    } catch (e) {
                        r(e)
                    }
                }

                function a(e) {
                    try {
                        c(i.throw(e))
                    } catch (e) {
                        r(e)
                    }
                }

                function c(e) {
                    var t;
                    e.done ? o(e.value) : (t = e.value, t instanceof n ? t : new n((function(e) {
                        e(t)
                    }))).then(s, a)
                }
                c((i = i.apply(e, t || [])).next())
            }))
        },
        $e = a && a.__generator || function(e, t) {
            var n, i, o, r, s = {
                label: 0,
                sent: function() {
                    if (1 & o[0]) throw o[1];
                    return o[1]
                },
                trys: [],
                ops: []
            };
            return r = {
                next: a(0),
                throw: a(1),
                return: a(2)
            }, "function" == typeof Symbol && (r[Symbol.iterator] = function() {
                return this
            }), r;

            function a(r) {
                return function(a) {
                    return function(r) {
                        if (n) throw new TypeError("Generator is already executing.");
                        for (; s;) try {
                            if (n = 1, i && (o = 2 & r[0] ? i.return : r[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, r[1])).done) return o;
                            switch (i = 0, o && (r = [2 & r[0], o.value]), r[0]) {
                                case 0:
                                case 1:
                                    o = r;
                                    break;
                                case 4:
                                    return s.label++, {
                                        value: r[1],
                                        done: !1
                                    };
                                case 5:
                                    s.label++, i = r[1], r = [0];
                                    continue;
                                case 7:
                                    r = s.ops.pop(), s.trys.pop();
                                    continue;
                                default:
                                    if (!((o = (o = s.trys).length > 0 && o[o.length - 1]) || 6 !== r[0] && 2 !== r[0])) {
                                        s = 0;
                                        continue
                                    }
                                    if (3 === r[0] && (!o || r[1] > o[0] && r[1] < o[3])) {
                                        s.label = r[1];
                                        break
                                    }
                                    if (6 === r[0] && s.label < o[1]) {
                                        s.label = o[1], o = r;
                                        break
                                    }
                                    if (o && s.label < o[2]) {
                                        s.label = o[2], s.ops.push(r);
                                        break
                                    }
                                    o[2] && s.ops.pop(), s.trys.pop();
                                    continue
                            }
                            r = t.call(e, s)
                        } catch (e) {
                            r = [6, e], i = 0
                        } finally {
                            n = o = 0
                        }
                        if (5 & r[0]) throw r[1];
                        return {
                            value: r[0] ? r[1] : void 0,
                            done: !0
                        }
                    }([r, a])
                }
            }
        },
        Ve = a && a.__spreadArray || function(e, t, n) {
            if (n || 2 === arguments.length)
                for (var i, o = 0, r = t.length; o < r; o++) !i && o in t || (i || (i = Array.prototype.slice.call(t, 0, o)), i[o] = t[o]);
            return e.concat(i || Array.prototype.slice.call(t))
        };
    Object.defineProperty(Se, "__esModule", {
        value: !0
    });
    var Ge = Se.SubscriptionClient = void 0,
        Qe = void 0 !== a ? a : "undefined" != typeof window ? window : {},
        We = Qe.WebSocket || Qe.MozWebSocket,
        Be = xe,
        He = Ne.exports,
        Je = ke,
        ze = Ae,
        Ke = Pe,
        Ye = je,
        Xe = Re,
        Ze = Me,
        et = Fe,
        tt = Ue,
        nt = function() {
            function e(e, t, n, i) {
                var o = t || {},
                    r = o.connectionCallback,
                    s = void 0 === r ? void 0 : r,
                    a = o.connectionParams,
                    c = void 0 === a ? {} : a,
                    l = o.minTimeout,
                    u = void 0 === l ? et.MIN_WS_TIMEOUT : l,
                    p = o.timeout,
                    d = void 0 === p ? et.WS_TIMEOUT : p,
                    f = o.reconnect,
                    h = void 0 !== f && f,
                    m = o.reconnectionAttempts,
                    y = void 0 === m ? Infinity : m,
                    v = o.lazy,
                    b = void 0 !== v && v,
                    g = o.inactivityTimeout,
                    E = void 0 === g ? 0 : g,
                    w = o.wsOptionArguments,
                    T = void 0 === w ? [] : w;
                if (this.wsImpl = n || We, !this.wsImpl) throw new Error("Unable to find native implementation, or alternative implementation for WebSocket!");
                this.wsProtocols = i || Ze.GRAPHQL_WS, this.connectionCallback = s, this.url = e, this.operations = {}, this.nextOperationId = 0, this.minWsTimeout = u, this.wsTimeout = d, this.unsentMessagesQueue = [], this.reconnect = h, this.reconnecting = !1, this.reconnectionAttempts = y, this.lazy = !!b, this.inactivityTimeout = E, this.closedByUser = !1, this.backoff = new Be({
                    jitter: .5
                }), this.eventEmitter = new He.EventEmitter, this.middlewares = [], this.client = null, this.maxConnectTimeGenerator = this.createMaxConnectTimeGenerator(), this.connectionParams = this.getConnectionParams(c), this.wsOptionArguments = T, this.lazy || this.connect()
            }
            return Object.defineProperty(e.prototype, "status", {
                get: function() {
                    return null === this.client ? this.wsImpl.CLOSED : this.client.readyState
                },
                enumerable: !1,
                configurable: !0
            }), e.prototype.close = function(e, t) {
                void 0 === e && (e = !0), void 0 === t && (t = !0), this.clearInactivityTimeout(), null !== this.client && (this.closedByUser = t, e && (this.clearCheckConnectionInterval(), this.clearMaxConnectTimeout(), this.clearTryReconnectTimeout(), this.unsubscribeAll(), this.sendMessage(void 0, tt.default.GQL_CONNECTION_TERMINATE, null)), this.client.close(), this.client.onopen = null, this.client.onclose = null, this.client.onerror = null, this.client.onmessage = null, this.client = null, this.eventEmitter.emit("disconnected"), e || this.tryReconnect())
            }, e.prototype.request = function(e) {
                var t, n, i = this.getObserver.bind(this),
                    o = this.executeOperation.bind(this),
                    r = this.unsubscribe.bind(this);
                return this.clearInactivityTimeout(), (t = {})[Xe.default] = function() {
                    return this
                }, t.subscribe = function(t, s, a) {
                    var c = i(t, s, a);
                    return n = o(e, (function(e, t) {
                        null === e && null === t ? c.complete && c.complete() : e ? c.error && c.error(e[0]) : c.next && c.next(t)
                    })), {
                        unsubscribe: function() {
                            n && (r(n), n = null)
                        }
                    }
                }, t
            }, e.prototype.on = function(e, t, n) {
                var i = this.eventEmitter.on(e, t, n);
                return function() {
                    i.off(e, t, n)
                }
            }, e.prototype.onConnected = function(e, t) {
                return this.on("connected", e, t)
            }, e.prototype.onConnecting = function(e, t) {
                return this.on("connecting", e, t)
            }, e.prototype.onDisconnected = function(e, t) {
                return this.on("disconnected", e, t)
            }, e.prototype.onReconnected = function(e, t) {
                return this.on("reconnected", e, t)
            }, e.prototype.onReconnecting = function(e, t) {
                return this.on("reconnecting", e, t)
            }, e.prototype.onError = function(e, t) {
                return this.on("error", e, t)
            }, e.prototype.unsubscribeAll = function() {
                var e = this;
                Object.keys(this.operations).forEach((function(t) {
                    e.unsubscribe(t)
                }))
            }, e.prototype.applyMiddlewares = function(e) {
                var t = this;
                return new Promise((function(n, i) {
                    var o, r, s;
                    o = Ve([], t.middlewares, !0), r = t, (s = function(t) {
                        if (t) i(t);
                        else if (o.length > 0) {
                            var a = o.shift();
                            a && a.applyMiddleware.apply(r, [e, s])
                        } else n(e)
                    })()
                }))
            }, e.prototype.use = function(e) {
                var t = this;
                return e.map((function(e) {
                    if ("function" != typeof e.applyMiddleware) throw new Error("Middleware must implement the applyMiddleware function.");
                    t.middlewares.push(e)
                })), this
            }, e.prototype.getConnectionParams = function(e) {
                return function() {
                    return new Promise((function(t, n) {
                        if ("function" == typeof e) try {
                            return t(e.call(null))
                        } catch (e) {
                            return n(e)
                        }
                        t(e)
                    }))
                }
            }, e.prototype.executeOperation = function(e, t) {
                var n = this;
                null === this.client && this.connect();
                var i = this.generateOperationId();
                return this.operations[i] = {
                    options: e,
                    handler: t
                }, this.applyMiddlewares(e).then((function(e) {
                    n.checkOperationOptions(e, t), n.operations[i] && (n.operations[i] = {
                        options: e,
                        handler: t
                    }, n.sendMessage(i, tt.default.GQL_START, e))
                })).catch((function(e) {
                    n.unsubscribe(i), t(n.formatErrors(e))
                })), i
            }, e.prototype.getObserver = function(e, t, n) {
                return "function" == typeof e ? {
                    next: function(t) {
                        return e(t)
                    },
                    error: function(e) {
                        return t && t(e)
                    },
                    complete: function() {
                        return n && n()
                    }
                } : e
            }, e.prototype.createMaxConnectTimeGenerator = function() {
                return new Be({
                    min: this.minWsTimeout,
                    max: this.wsTimeout,
                    factor: 1.2
                })
            }, e.prototype.clearCheckConnectionInterval = function() {
                this.checkConnectionIntervalId && (clearInterval(this.checkConnectionIntervalId), this.checkConnectionIntervalId = null)
            }, e.prototype.clearMaxConnectTimeout = function() {
                this.maxConnectTimeoutId && (clearTimeout(this.maxConnectTimeoutId), this.maxConnectTimeoutId = null)
            }, e.prototype.clearTryReconnectTimeout = function() {
                this.tryReconnectTimeoutId && (clearTimeout(this.tryReconnectTimeoutId), this.tryReconnectTimeoutId = null)
            }, e.prototype.clearInactivityTimeout = function() {
                this.inactivityTimeoutId && (clearTimeout(this.inactivityTimeoutId), this.inactivityTimeoutId = null)
            }, e.prototype.setInactivityTimeout = function() {
                var e = this;
                this.inactivityTimeout > 0 && 0 === Object.keys(this.operations).length && (this.inactivityTimeoutId = setTimeout((function() {
                    0 === Object.keys(e.operations).length && e.close()
                }), this.inactivityTimeout))
            }, e.prototype.checkOperationOptions = function(e, t) {
                var n = e.query,
                    i = e.variables,
                    o = e.operationName;
                if (!n) throw new Error("Must provide a query.");
                if (!t) throw new Error("Must provide an handler.");
                if (!(0, Je.default)(n) && !(0, Ye.getOperationAST)(n, o) || o && !(0, Je.default)(o) || i && !(0, ze.default)(i)) throw new Error("Incorrect option types. query must be a string or a document,`operationName` must be a string, and `variables` must be an object.")
            }, e.prototype.buildMessage = function(e, t, n) {
                return {
                    id: e,
                    type: t,
                    payload: n && n.query ? De(De({}, n), {
                        query: "string" == typeof n.query ? n.query : (0, Ke.print)(n.query)
                    }) : n
                }
            }, e.prototype.formatErrors = function(e) {
                return Array.isArray(e) ? e : e && e.errors ? this.formatErrors(e.errors) : e && e.message ? [e] : [{
                    name: "FormatedError",
                    message: "Unknown error",
                    originalError: e
                }]
            }, e.prototype.sendMessage = function(e, t, n) {
                this.sendMessageRaw(this.buildMessage(e, t, n))
            }, e.prototype.sendMessageRaw = function(e) {
                switch (this.status) {
                    case this.wsImpl.OPEN:
                        var t = JSON.stringify(e);
                        try {
                            JSON.parse(t)
                        } catch (t) {
                            this.eventEmitter.emit("error", new Error("Message must be JSON-serializable. Got: " + e))
                        }
                        this.client.send(t);
                        break;
                    case this.wsImpl.CONNECTING:
                        this.unsentMessagesQueue.push(e);
                        break;
                    default:
                        this.reconnecting || this.eventEmitter.emit("error", new Error("A message was not sent because socket is not connected, is closing or is already closed. Message was: " + JSON.stringify(e)))
                }
            }, e.prototype.generateOperationId = function() {
                return String(++this.nextOperationId)
            }, e.prototype.tryReconnect = function() {
                var e = this;
                if (this.reconnect && !(this.backoff.attempts >= this.reconnectionAttempts)) {
                    this.reconnecting || (Object.keys(this.operations).forEach((function(t) {
                        e.unsentMessagesQueue.push(e.buildMessage(t, tt.default.GQL_START, e.operations[t].options))
                    })), this.reconnecting = !0), this.clearTryReconnectTimeout();
                    var t = this.backoff.duration();
                    this.tryReconnectTimeoutId = setTimeout((function() {
                        e.connect()
                    }), t)
                }
            }, e.prototype.flushUnsentMessagesQueue = function() {
                var e = this;
                this.unsentMessagesQueue.forEach((function(t) {
                    e.sendMessageRaw(t)
                })), this.unsentMessagesQueue = []
            }, e.prototype.checkConnection = function() {
                this.wasKeepAliveReceived ? this.wasKeepAliveReceived = !1 : this.reconnecting || this.close(!1, !0)
            }, e.prototype.checkMaxConnectTimeout = function() {
                var e = this;
                this.clearMaxConnectTimeout(), this.maxConnectTimeoutId = setTimeout((function() {
                    e.status !== e.wsImpl.OPEN && (e.reconnecting = !0, e.close(!1, !0))
                }), this.maxConnectTimeGenerator.duration())
            }, e.prototype.connect = function() {
                var e, t = this;
                this.client = new((e = this.wsImpl).bind.apply(e, Ve([void 0, this.url, this.wsProtocols], this.wsOptionArguments, !1))), this.checkMaxConnectTimeout(), this.client.onopen = function() {
                    return qe(t, void 0, void 0, (function() {
                        var e, t;
                        return $e(this, (function(n) {
                            switch (n.label) {
                                case 0:
                                    if (this.status !== this.wsImpl.OPEN) return [3, 4];
                                    this.clearMaxConnectTimeout(), this.closedByUser = !1, this.eventEmitter.emit(this.reconnecting ? "reconnecting" : "connecting"), n.label = 1;
                                case 1:
                                    return n.trys.push([1, 3, , 4]), [4, this.connectionParams()];
                                case 2:
                                    return e = n.sent(), this.sendMessage(void 0, tt.default.GQL_CONNECTION_INIT, e), this.flushUnsentMessagesQueue(), [3, 4];
                                case 3:
                                    return t = n.sent(), this.sendMessage(void 0, tt.default.GQL_CONNECTION_ERROR, t), this.flushUnsentMessagesQueue(), [3, 4];
                                case 4:
                                    return [2]
                            }
                        }))
                    }))
                }, this.client.onclose = function() {
                    t.closedByUser || t.close(!1, !1)
                }, this.client.onerror = function(e) {
                    t.eventEmitter.emit("error", e)
                }, this.client.onmessage = function(e) {
                    t.processReceivedData(e.data)
                }
            }, e.prototype.processReceivedData = function(e) {
                var t, n;
                try {
                    n = (t = JSON.parse(e)).id
                } catch (t) {
                    throw new Error("Message must be JSON-parseable. Got: " + e)
                }
                if (-1 === [tt.default.GQL_DATA, tt.default.GQL_COMPLETE, tt.default.GQL_ERROR].indexOf(t.type) || this.operations[n]) switch (t.type) {
                    case tt.default.GQL_CONNECTION_ERROR:
                        this.connectionCallback && this.connectionCallback(t.payload);
                        break;
                    case tt.default.GQL_CONNECTION_ACK:
                        this.eventEmitter.emit(this.reconnecting ? "reconnected" : "connected", t.payload), this.reconnecting = !1, this.backoff.reset(), this.maxConnectTimeGenerator.reset(), this.connectionCallback && this.connectionCallback();
                        break;
                    case tt.default.GQL_COMPLETE:
                        var i = this.operations[n].handler;
                        delete this.operations[n], i.call(this, null, null);
                        break;
                    case tt.default.GQL_ERROR:
                        this.operations[n].handler(this.formatErrors(t.payload), null), delete this.operations[n];
                        break;
                    case tt.default.GQL_DATA:
                        var o = t.payload.errors ? De(De({}, t.payload), {
                            errors: this.formatErrors(t.payload.errors)
                        }) : t.payload;
                        this.operations[n].handler(null, o);
                        break;
                    case tt.default.GQL_CONNECTION_KEEP_ALIVE:
                        var r = void 0 === this.wasKeepAliveReceived;
                        this.wasKeepAliveReceived = !0, r && this.checkConnection(), this.checkConnectionIntervalId && (clearInterval(this.checkConnectionIntervalId), this.checkConnection()), this.checkConnectionIntervalId = setInterval(this.checkConnection.bind(this), this.wsTimeout);
                        break;
                    default:
                        throw new Error("Invalid message type!")
                } else this.unsubscribe(n)
            }, e.prototype.unsubscribe = function(e) {
                this.operations[e] && (delete this.operations[e], this.setInactivityTimeout(), this.sendMessage(e, tt.default.GQL_STOP, void 0))
            }, e
        }();

    function it(e) {
        throw new Error(`Didn't expect to get here ${e}`)
    }
    Ge = Se.SubscriptionClient = nt;
    class ot {
        constructor(e, t, n) {
            this.unsubscribeFunctions = [], this.protocol = n, this.url = e, this.headers = t
        }
        get graphWsClient() {
            var e, t;
            const n = null !== (e = this._graphWsClient) && void 0 !== e ? e : function(e) {
                const {
                    url: t,
                    connectionParams: n,
                    lazy: i = !0,
                    onNonLazyError: o = console.error,
                    lazyCloseTimeout: r = 0,
                    keepAlive: s = 0,
                    disablePong: a,
                    connectionAckWaitTimeout: c = 0,
                    retryAttempts: l = 5,
                    retryWait: u = async function(e) {
                        let t = 1e3;
                        for (let n = 0; n < e; n++) t *= 2;
                        await new Promise((e => setTimeout(e, t + Math.floor(2700 * Math.random() + 300))))
                    },
                    shouldRetry: p = oe,
                    isFatalConnectionProblem: d,
                    on: f,
                    webSocketImpl: h,
                    generateID: m = function() {
                        return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e => {
                            const t = 16 * Math.random() | 0;
                            return ("x" == e ? t : 3 & t | 8).toString(16)
                        }))
                    },
                    jsonMessageReplacer: y,
                    jsonMessageReviver: v
                } = e;
                let b;
                if (h) {
                    if (!("function" == typeof(g = h) && "constructor" in g && "CLOSED" in g && "CLOSING" in g && "CONNECTING" in g && "OPEN" in g)) throw new Error("Invalid WebSocket implementation provided");
                    b = h
                } else "undefined" != typeof WebSocket ? b = WebSocket : "undefined" != typeof global ? b = global.WebSocket || global.MozWebSocket : "undefined" != typeof window && (b = window.WebSocket || window.MozWebSocket);
                var g;
                if (!b) throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");
                const E = b,
                    w = (() => {
                        const e = (() => {
                                const e = {};
                                return {
                                    on: (t, n) => (e[t] = n, () => {
                                        delete e[t]
                                    }),
                                    emit(t) {
                                        var n;
                                        "id" in t && (null === (n = e[t.id]) || void 0 === n || n.call(e, t))
                                    }
                                }
                            })(),
                            t = {
                                connecting: (null == f ? void 0 : f.connecting) ? [f.connecting] : [],
                                opened: (null == f ? void 0 : f.opened) ? [f.opened] : [],
                                connected: (null == f ? void 0 : f.connected) ? [f.connected] : [],
                                ping: (null == f ? void 0 : f.ping) ? [f.ping] : [],
                                pong: (null == f ? void 0 : f.pong) ? [f.pong] : [],
                                message: (null == f ? void 0 : f.message) ? [e.emit, f.message] : [e.emit],
                                closed: (null == f ? void 0 : f.closed) ? [f.closed] : [],
                                error: (null == f ? void 0 : f.error) ? [f.error] : []
                            };
                        return {
                            onMessage: e.on,
                            on(e, n) {
                                const i = t[e];
                                return i.push(n), () => {
                                    i.splice(i.indexOf(n), 1)
                                }
                            },
                            emit(e, ...n) {
                                for (const i of [...t[e]]) i(...n)
                            }
                        }
                    })();

                function T(e) {
                    const t = [w.on("error", (n => {
                        t.forEach((e => e())), e(n)
                    })), w.on("closed", (n => {
                        t.forEach((e => e())), e(n)
                    }))]
                }
                let I, _ = 0,
                    O = !1,
                    S = 0,
                    x = !1;
                async function C() {
                    const [e, i] = await (null != I ? I : I = new Promise(((e, i) => (async () => {
                        if (O) {
                            if (await u(S), !_) return I = void 0, i({
                                code: 1e3,
                                reason: "All Subscriptions Gone"
                            });
                            S++
                        }
                        w.emit("connecting");
                        const o = new E("function" == typeof t ? await t() : t, "graphql-transport-ws");
                        let r, l;

                        function p() {
                            isFinite(s) && s > 0 && (clearTimeout(l), l = setTimeout((() => {
                                o.readyState === E.OPEN && (o.send(ie({
                                    type: Y.Ping
                                })), w.emit("ping", !1, void 0))
                            }), s))
                        }
                        T((e => {
                            I = void 0, clearTimeout(r), clearTimeout(l), i(e), oe(e) && 4499 === e.code && (o.close(4499, "Terminated"), o.onerror = null, o.onclose = null)
                        })), o.onerror = e => w.emit("error", e), o.onclose = e => w.emit("closed", e), o.onopen = async () => {
                            try {
                                w.emit("opened", o);
                                const e = "function" == typeof n ? await n() : n;
                                if (o.readyState !== E.OPEN) return;
                                o.send(ie(e ? {
                                    type: Y.ConnectionInit,
                                    payload: e
                                } : {
                                    type: Y.ConnectionInit
                                }, y)), isFinite(c) && c > 0 && (r = setTimeout((() => {
                                    o.close(K.ConnectionAcknowledgementTimeout, "Connection acknowledgement timeout")
                                }), c)), p()
                            } catch (e) {
                                w.emit("error", e), o.close(K.InternalClientError, te(e instanceof Error ? e.message : new Error(e).message, "Internal client error"))
                            }
                        };
                        let d = !1;
                        o.onmessage = ({
                            data: t
                        }) => {
                            try {
                                const n = function(e, t) {
                                    try {
                                        return ne(e)
                                    } catch (n) {
                                        if ("string" != typeof e) throw new Error("Only strings are parsable messages");
                                        return ne(JSON.parse(e, t))
                                    }
                                }(t, v);
                                if (w.emit("message", n), "ping" === n.type || "pong" === n.type) return w.emit(n.type, !0, n.payload), void("pong" === n.type ? p() : a || (o.send(ie(n.payload ? {
                                    type: Y.Pong,
                                    payload: n.payload
                                } : {
                                    type: Y.Pong
                                })), w.emit("pong", !1, n.payload)));
                                if (d) return;
                                if (n.type !== Y.ConnectionAck) throw new Error(`First message cannot be of type ${n.type}`);
                                clearTimeout(r), d = !0, w.emit("connected", o, n.payload), O = !1, S = 0, e([o, new Promise(((e, t) => T(t)))])
                            } catch (e) {
                                o.onmessage = null, w.emit("error", e), o.close(K.BadResponse, te(e instanceof Error ? e.message : new Error(e).message, "Bad response"))
                            }
                        }
                    })())));
                    e.readyState === E.CLOSING && await i;
                    let o = () => {};
                    const l = new Promise((e => o = e));
                    return [e, o, Promise.race([l.then((() => {
                        if (!_) {
                            const t = () => e.close(1e3, "Normal Closure");
                            isFinite(r) && r > 0 ? setTimeout((() => {
                                _ || e.readyState !== E.OPEN || t()
                            }), r) : t()
                        }
                    })), i])]
                }

                function N(e) {
                    if (oe(e) && (![1e3, 1001, 1006, 1005, 1012, 1013, 1013].includes(t = e.code) && t >= 1e3 && t <= 1999 || [K.InternalServerError, K.InternalClientError, K.BadRequest, K.BadResponse, K.Unauthorized, K.SubprotocolNotAcceptable, K.SubscriberAlreadyExists, K.TooManyInitialisationRequests].includes(e.code))) throw e;
                    var t;
                    if (x) return !1;
                    if (oe(e) && 1e3 === e.code) return _ > 0;
                    if (!l || S >= l) throw e;
                    if (!p(e)) throw e;
                    if (null == d ? void 0 : d(e)) throw e;
                    return O = !0
                }
                return i || (async () => {
                    for (_++;;) try {
                        const [, , e] = await C();
                        await e
                    } catch (e) {
                        try {
                            if (!N(e)) return
                        } catch (e) {
                            return null == o ? void 0 : o(e)
                        }
                    }
                })(), {
                    on: w.on,
                    subscribe(e, t) {
                        const n = m();
                        let i = !1,
                            o = !1,
                            r = () => {
                                _--, i = !0
                            };
                        return (async () => {
                            for (_++;;) try {
                                const [s, a, c] = await C();
                                if (i) return a();
                                const l = w.onMessage(n, (e => {
                                    switch (e.type) {
                                        case Y.Next:
                                            return void t.next(e.payload);
                                        case Y.Error:
                                            return o = !0, i = !0, t.error(e.payload), void r();
                                        case Y.Complete:
                                            return i = !0, void r()
                                    }
                                }));
                                return s.send(ie({
                                    id: n,
                                    type: Y.Subscribe,
                                    payload: e
                                }, y)), r = () => {
                                    i || s.readyState !== E.OPEN || s.send(ie({
                                        id: n,
                                        type: Y.Complete
                                    }, y)), _--, i = !0, a()
                                }, void await c.finally(l)
                            } catch (e) {
                                if (!N(e)) return
                            }
                        })().then((() => {
                            o || t.complete()
                        })).catch((e => {
                            t.error(e)
                        })), () => {
                            i || r()
                        }
                    },
                    async dispose() {
                        if (x = !0, I) {
                            const [e] = await I;
                            e.close(1e3, "Normal Closure")
                        }
                    },
                    terminate() {
                        I && w.emit("closed", {
                            code: 4499,
                            reason: "Terminated",
                            wasClean: !1
                        })
                    }
                }
            }({
                url: this.url,
                lazy: !0,
                connectionParams: null !== (t = this.headers) && void 0 !== t ? t : {},
                keepAlive: 1e4
            });
            return this._graphWsClient = n, n
        }
        get transportSubscriptionClient() {
            var e, t;
            const n = null !== (e = this._transportSubscriptionClient) && void 0 !== e ? e : new Ge(this.url, {
                reconnect: !0,
                lazy: !0,
                connectionParams: null !== (t = this.headers) && void 0 !== t ? t : {}
            });
            return this._transportSubscriptionClient = n, n
        }
        get multipartClient() {
            var e;
            const t = null !== (e = this._multipartClient) && void 0 !== e ? e : Object.assign(new X, {
                stopListeningCallback: void 0
            });
            return this._multipartClient = t, t
        }
        onConnected(e) {
            return "http-multipart" === this.protocol ? (this.multipartClient.on("connected", e), () => this.multipartClient.off("connected", e)) : "graphql-ws" === this.protocol ? this.graphWsClient.on("connected", e) : "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onConnected(e) : void it(this.protocol)
        }
        onConnecting(e) {
            if ("http-multipart" !== this.protocol) return "graphql-ws" === this.protocol ? this.graphWsClient.on("connecting", e) : "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onConnecting(e) : void it(this.protocol)
        }
        onError(e) {
            return "http-multipart" === this.protocol ? (this.multipartClient.on("error", e), () => this.multipartClient.off("error", e)) : "graphql-ws" === this.protocol ? this.graphWsClient.on("error", (t => e(t))) : "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onError((t => e(t))) : void it(this.protocol)
        }
        onReconnecting(e) {
            if ("http-multipart" !== this.protocol && "graphql-ws" !== this.protocol) return "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onReconnecting(e) : void it(this.protocol)
        }
        onReconnected(e) {
            if ("http-multipart" !== this.protocol && "graphql-ws" !== this.protocol) return "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onReconnected(e) : void it(this.protocol)
        }
        onDisconnected(e) {
            return "http-multipart" === this.protocol ? (this.multipartClient.on("disconnected", e), () => this.multipartClient.off("disconnected", e)) : "graphql-ws" === this.protocol ? this.graphWsClient.on("closed", e) : "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.onDisconnected(e) : void it(this.protocol)
        }
        dispose() {
            var e, t;
            if ("http-multipart" !== this.protocol) return "graphql-ws" === this.protocol ? this.graphWsClient.dispose() : "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.close() : void it(this.protocol);
            null === (t = (e = this.multipartClient).stopListeningCallback) || void 0 === t || t.call(e)
        }
        request(e) {
            return {
                subscribe: t => s(this, void 0, void 0, (function*() {
                    var n, i, o, r;
                    return "http-multipart" === this.protocol && e.httpMultipartParams && (yield J({
                        operation: e.query,
                        operationName: e.operationName,
                        variables: e.variables,
                        headers: null !== (n = this.headers) && void 0 !== n ? n : {},
                        includeCookies: null !== (o = null === (i = e.httpMultipartParams) || void 0 === i ? void 0 : i.includeCookies) && void 0 !== o && o,
                        endpointUrl: this.url,
                        embeddedIFrameElement: e.embeddedIFrameElement,
                        embedUrl: e.embedUrl,
                        operationId: e.operationId,
                        handleRequest: null === (r = e.httpMultipartParams) || void 0 === r ? void 0 : r.handleRequest,
                        isMultipartSubscription: !0,
                        multipartSubscriptionClient: this.multipartClient
                    })), "graphql-ws" === this.protocol && this.unsubscribeFunctions.push(this.graphWsClient.subscribe(e, Object.assign(Object.assign({}, t), {
                        next: e => {
                            var n;
                            return null === (n = t.next) || void 0 === n ? void 0 : n.call(t, e)
                        },
                        error: e => {
                            var n;
                            return null === (n = t.error) || void 0 === n ? void 0 : n.call(t, e)
                        },
                        complete: () => {}
                    }))), "subscriptions-transport-ws" === this.protocol ? this.transportSubscriptionClient.request(e).subscribe(t) : void 0
                }))
            }
        }
        unsubscribeAll() {
            var e, t;
            if ("http-multipart" === this.protocol && (null === (t = (e = this.multipartClient).stopListeningCallback) || void 0 === t || t.call(e)), "graphql-ws" === this.protocol && (this.unsubscribeFunctions.forEach((e => {
                    e()
                })), this.unsubscribeFunctions = []), "subscriptions-transport-ws" === this.protocol) return this.transportSubscriptionClient.unsubscribeAll()
        }
    }

    function rt({
        error: e,
        embeddedIFrameElement: t,
        embedUrl: n
    }) {
        H({
            message: {
                name: "ExplorerSetSocketError",
                error: e
            },
            embeddedIFrameElement: t,
            embedUrl: n
        })
    }

    function st({
        status: e,
        embeddedIFrameElement: t,
        embedUrl: n
    }) {
        H({
            message: {
                name: o,
                status: e
            },
            embeddedIFrameElement: t,
            embedUrl: n
        })
    }
    let at = 0;
    return class {
        constructor(n) {
            var o;
            this.options = n, this.__testLocal__ = !!this.options.__testLocal__, this.validateOptions(), this.handleRequest = null !== (o = this.options.handleRequest) && void 0 !== o ? o : (({
                legacyIncludeCookies: e
            }) => (t, n) => fetch(t, Object.assign(Object.assign({}, n), e ? {
                credentials: "include"
            } : void 0 !== e ? {
                credentials: "omit"
            } : {})))({
                legacyIncludeCookies: this.options.includeCookies
            }), this.uniqueEmbedInstanceId = at++, this.embeddedSandboxIFrameElement = this.injectEmbed(), this.disposable = function({
                handleRequest: n,
                embeddedSandboxIFrameElement: o,
                __testLocal__: r
            }) {
                const a = e(r),
                    c = ((e = !1) => e ? "https://embed.apollo.local:3000" : "https://sandbox.embed.apollographql.com")(r),
                    l = e => {
                        (({
                            event: e,
                            embeddedIFrameElement: t,
                            embedUrl: n,
                            embedUrlOrigin: i
                        }) => {
                            const {
                                data: o
                            } = e;
                            if (e.origin === i) {
                                if ("PreflightOAuthRequest" === o.name) {
                                    const e = o => {
                                        "PreflightOAuthProviderResponse" === o.data.name && o.origin === i && (window.removeEventListener("message", e), H({
                                            message: {
                                                name: "PreflightOAuthResponse",
                                                queryParams: o.data.queryParams
                                            },
                                            embeddedIFrameElement: t,
                                            embedUrl: n
                                        }))
                                    };
                                    window.addEventListener("message", e), window.open(o.oauthUrl, void 0, "_blank")
                                }
                                if ("SetPartialAuthenticationTokenForParent" === o.name) {
                                    const e = window.localStorage.getItem("apolloStudioEmbeddedExplorerEncodedApiKey"),
                                        t = e ? JSON.parse(e) : {};
                                    t[o.localStorageKey] = o.partialToken, window.localStorage.setItem("apolloStudioEmbeddedExplorerEncodedApiKey", JSON.stringify(t))
                                }
                                if ("TriggerLogoutInParent" === o.name) {
                                    const e = window.localStorage.getItem("apolloStudioEmbeddedExplorerEncodedApiKey"),
                                        i = e ? JSON.parse(e) : {};
                                    delete i[o.localStorageKey], window.localStorage.setItem("apolloStudioEmbeddedExplorerEncodedApiKey", JSON.stringify(i)), H({
                                        message: {
                                            name: "ParentLogoutSuccess"
                                        },
                                        embeddedIFrameElement: t,
                                        embedUrl: n
                                    })
                                }
                                if ("ExplorerListeningForPartialToken" === o.name && o.localStorageKey) {
                                    const e = window.localStorage.getItem("apolloStudioEmbeddedExplorerEncodedApiKey"),
                                        i = e ? JSON.parse(e) : {};
                                    i && i[o.localStorageKey] && H({
                                        message: {
                                            name: "PartialAuthenticationTokenResponse",
                                            partialToken: i[o.localStorageKey]
                                        },
                                        embeddedIFrameElement: t,
                                        embedUrl: n
                                    })
                                }
                            }
                        })({
                            event: e,
                            embedUrl: a,
                            embedUrlOrigin: c,
                            embeddedIFrameElement: o
                        });
                        const r = "object" == typeof e.data ? e.data : void 0;
                        if (r && "name" in r && e.origin === c) {
                            if ("ExplorerListeningForHandshake" === r.name && H({
                                    message: {
                                        name: "HandshakeResponse",
                                        parentHref: window.location.href
                                    },
                                    embeddedIFrameElement: o,
                                    embedUrl: a
                                }), "IntrospectionQueryWithHeaders" === r.name) {
                                const {
                                    introspectionRequestBody: e,
                                    introspectionRequestHeaders: i,
                                    includeCookies: c,
                                    sandboxEndpointUrl: l,
                                    operationId: u
                                } = r;
                                l && function({
                                    endpointUrl: e,
                                    headers: n,
                                    includeCookies: i,
                                    introspectionRequestBody: o,
                                    embeddedIFrameElement: r,
                                    embedUrl: a,
                                    handleRequest: c,
                                    operationId: l
                                }) {
                                    s(this, void 0, void 0, (function*() {
                                        const {
                                            query: s,
                                            operationName: u
                                        } = JSON.parse(o);
                                        return c(e, Object.assign({
                                            method: "POST",
                                            headers: B(n),
                                            body: JSON.stringify({
                                                query: s,
                                                operationName: u
                                            })
                                        }, i ? {
                                            credentials: "include"
                                        } : {
                                            credentials: "omit"
                                        })).then((e => e.json())).then((e => {
                                            e.errors && e.errors.length && H({
                                                message: {
                                                    name: t,
                                                    errors: e.errors,
                                                    operationId: l
                                                },
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            }), H({
                                                message: {
                                                    name: "SchemaResponse",
                                                    schema: e.data,
                                                    operationId: l
                                                },
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            })
                                        })).catch((e => {
                                            H({
                                                message: {
                                                    name: t,
                                                    error: e,
                                                    operationId: l
                                                },
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            })
                                        }))
                                    }))
                                }({
                                    endpointUrl: l,
                                    introspectionRequestBody: e,
                                    headers: i,
                                    includeCookies: c,
                                    embeddedIFrameElement: o,
                                    embedUrl: a,
                                    handleRequest: n,
                                    operationId: u
                                })
                            }
                            const e = "ExplorerRequest" === r.name,
                                l = "ExplorerSubscriptionRequest" === r.name;
                            if ((e || l) && r.operation && r.operationId) {
                                const {
                                    operation: t,
                                    variables: s,
                                    operationName: u,
                                    operationId: p,
                                    headers: d
                                } = r;
                                if (e) {
                                    const {
                                        endpointUrl: e,
                                        includeCookies: i
                                    } = r;
                                    if (!e) throw new Error("Something went wrong, we should not have gotten here. The sandbox endpoint url was not sent.");
                                    J({
                                        endpointUrl: e,
                                        handleRequest: n,
                                        headers: d,
                                        includeCookies: i,
                                        embeddedIFrameElement: o,
                                        operationId: p,
                                        operation: t,
                                        variables: s,
                                        fileVariables: "fileVariables" in r ? r.fileVariables : void 0,
                                        operationName: u,
                                        embedUrl: a,
                                        isMultipartSubscription: !1
                                    })
                                } else if (l) {
                                    const {
                                        httpMultipartParams: e
                                    } = r;
                                    ! function({
                                        operation: e,
                                        operationName: t,
                                        variables: n,
                                        headers: o,
                                        embeddedIFrameElement: r,
                                        operationId: s,
                                        embedUrl: a,
                                        embedUrlOrigin: c,
                                        subscriptionUrl: l,
                                        protocol: u,
                                        httpMultipartParams: p
                                    }) {
                                        const d = new ot(l, null != o ? o : {}, u),
                                            f = e => {
                                                "ExplorerSubscriptionTermination" === e.data.name && e.origin === c && (d.unsubscribeAll(), window.removeEventListener("message", f))
                                            };
                                        window.addEventListener("message", f), d.onError((e => rt({
                                            error: JSON.parse(JSON.stringify(e)),
                                            embeddedIFrameElement: r,
                                            embedUrl: a
                                        }))), d.onConnected((() => {
                                            rt({
                                                error: void 0,
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            }), st({
                                                status: "connected",
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            })
                                        })), d.onReconnected((() => {
                                            rt({
                                                error: void 0,
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            }), st({
                                                status: "connected",
                                                embeddedIFrameElement: r,
                                                embedUrl: a
                                            })
                                        })), d.onConnecting((() => st({
                                            status: "connecting",
                                            embeddedIFrameElement: r,
                                            embedUrl: a
                                        }))), d.onReconnecting((() => st({
                                            status: "connecting",
                                            embeddedIFrameElement: r,
                                            embedUrl: a
                                        }))), d.onDisconnected((() => st({
                                            status: "disconnected",
                                            embeddedIFrameElement: r,
                                            embedUrl: a
                                        }))), d.request({
                                            query: e,
                                            variables: null != n ? n : {},
                                            operationName: t,
                                            embeddedIFrameElement: r,
                                            embedUrl: a,
                                            httpMultipartParams: p,
                                            operationId: s
                                        }).subscribe({
                                            next(e) {
                                                H({
                                                    message: {
                                                        name: i,
                                                        operationId: s,
                                                        response: {
                                                            data: e
                                                        }
                                                    },
                                                    embeddedIFrameElement: r,
                                                    embedUrl: a
                                                })
                                            },
                                            error: e => {
                                                H({
                                                    message: {
                                                        name: i,
                                                        operationId: s,
                                                        response: {
                                                            error: JSON.parse(JSON.stringify(e))
                                                        }
                                                    },
                                                    embeddedIFrameElement: r,
                                                    embedUrl: a
                                                })
                                            }
                                        })
                                    }({
                                        operation: t,
                                        operationName: u,
                                        variables: s,
                                        headers: d,
                                        embeddedIFrameElement: o,
                                        operationId: p,
                                        embedUrl: a,
                                        embedUrlOrigin: c,
                                        subscriptionUrl: r.subscriptionUrl,
                                        protocol: r.protocol,
                                        httpMultipartParams: Object.assign(Object.assign({}, e), {
                                            handleRequest: n
                                        })
                                    })
                                }
                            }
                        }
                    };
                return window.addEventListener("message", l), {
                    dispose: () => window.removeEventListener("message", l)
                }
            }({
                embeddedSandboxIFrameElement: this.embeddedSandboxIFrameElement,
                handleRequest: this.handleRequest,
                __testLocal__: !!this.__testLocal__
            })
        }
        dispose() {
            var e;
            null === (e = document.getElementById(r(this.uniqueEmbedInstanceId))) || void 0 === e || e.remove(), this.disposable.dispose()
        }
        injectEmbed() {
            var t, n, i, o, s, a, c;
            let l;
            const {
                target: u,
                runTelemetry: p
            } = this.options, {
                includeCookies: d,
                sharedHeaders: f
            } = this.options.initialState || {}, h = Object.assign(Object.assign(Object.assign({
                runtime: this.options.runtime,
                endpoint: this.options.initialEndpoint,
                subscriptionEndpoint: this.options.initialSubscriptionEndpoint,
                sendOperationHeadersInIntrospection: null === (t = this.options.sendOperationHeadersInIntrospection) || void 0 === t || t
            }, this.options.initialState && "collectionId" in this.options.initialState ? {
                defaultCollectionEntryId: this.options.initialState.operationId,
                defaultCollectionId: this.options.initialState.collectionId
            } : {}), this.options.initialState && "document" in this.options.initialState ? {
                defaultDocument: this.options.initialState.document ? encodeURIComponent(this.options.initialState.document) : void 0,
                defaultVariables: this.options.initialState.variables ? encodeURIComponent(JSON.stringify(this.options.initialState.variables, null, 2)) : void 0,
                defaultHeaders: this.options.initialState.headers ? encodeURIComponent(JSON.stringify(this.options.initialState.headers)) : void 0
            } : {}), {
                sharedHeaders: f ? encodeURIComponent(JSON.stringify(f)) : void 0,
                defaultIncludeCookies: d,
                hideCookieToggle: null === (n = this.options.hideCookieToggle) || void 0 === n || n,
                parentSupportsSubscriptions: !0,
                version: "2.7.2",
                runTelemetry: void 0 === p || p,
                initialRequestQueryPlan: null !== (i = this.options.initialRequestQueryPlan) && void 0 !== i && i,
                initialRequestConnectorsDebugging: null !== (o = this.options.initialRequestConnectorsDebugging) && void 0 !== o && o,
                shouldDefaultAutoupdateSchema: null === (a = null === (s = this.options.initialState) || void 0 === s ? void 0 : s.pollForSchemaUpdates) || void 0 === a || a,
                endpointIsEditable: this.options.endpointIsEditable
            }), m = Object.entries(h).filter((([e, t]) => void 0 !== t)).map((([e, t]) => `${e}=${t}`)).join("&");
            l = "string" == typeof u ? null === (c = null === document || void 0 === document ? void 0 : document.querySelector) || void 0 === c ? void 0 : c.call(document, u) : u;
            const y = document.createElement("iframe");
            return y.src = `${e(this.__testLocal__)}?${m}`, y.id = r(this.uniqueEmbedInstanceId), !1 !== this.options.allowDynamicStyles && y.setAttribute("style", "height: 100%; width: 100%; border: none;"), null == l || l.appendChild(y), fetch(`${window.location.origin}/favicon.ico`).then((e => {
                if (404 === e.status && !document.querySelector('link[rel*="icon"]')) {
                    var t = window.matchMedia("(prefers-color-scheme: dark)").matches;
                    ["icon", "apple-touch-icon"].forEach((e => {
                        var n = document.createElement("link");
                        n.rel = e, n.href = `https://embeddable-explorer.cdn.apollographql.com/_latest/public/assets/favicon${t?"-dark":""}.png`, document.head.appendChild(n)
                    }))
                }
            })).catch((() => {})), y
        }
        validateOptions() {
            var e;
            if (!this.options.target) throw new Error('"target" is required');
            if (void 0 !== this.options.includeCookies && console.warn("Passing `includeCookies` is deprecated. If you would like to set a default includeCookies value, please use `initialState.includeCookies` instead."), void 0 !== this.options.includeCookies && (void 0 !== this.options.hideCookieToggle || void 0 !== (null === (e = this.options.initialState) || void 0 === e ? void 0 : e.includeCookies))) throw new Error("Passing `includeCookies` is deprecated and will override your sandbox connection settings configuration.")
        }
    }
}));
//# sourceMappingURL=embeddable-sandbox.umd.production.min.js.map