import { s as ee, d as f, f as Ae, G as y, g as we, i as B, h as X, D as L, O as me, j as ve, k as nt, n as tt, o as It, p as _t, q as rt, r as Fe, t as xe, u as it, v as Le, w as Pe, x as oe, y as yt, z as Dt, A as at, B as se, F as Ne, H as st, I as Ot, J as bt, L as Xe, N as W, Q as St, V as At, W as Be, X as $e, Y as qe, Z as Je, _ as Qe, $ as Ge, a0 as wt, a1 as We, a2 as He, a3 as Ft, a4 as xt, a5 as Lt, a6 as Pt, a7 as ze, e as j, l as q, U as Ct } from "./index-95c7a92d.js";
import "react";
import "react-dom";
function Mt(e) {
  const r = /* @__PURE__ */ Object.create(null), i = e.getSchema(), t = i ? i.getDirectives() : ee;
  for (const s of t)
    r[s.name] = s.args.map((c) => c.name);
  const n = e.getDocument().definitions;
  for (const s of n)
    if (s.kind === f.DIRECTIVE_DEFINITION) {
      var a;
      const c = (a = s.arguments) !== null && a !== void 0 ? a : [];
      r[s.name.value] = c.map((d) => d.name.value);
    }
  return {
    Directive(s) {
      const c = s.name.value, d = r[c];
      if (s.arguments && d)
        for (const l of s.arguments) {
          const g = l.name.value;
          if (!d.includes(g)) {
            const h = Ae(g, d);
            e.reportError(
              new y(
                `Unknown argument "${g}" on directive "@${c}".` + we(h),
                {
                  nodes: l
                }
              )
            );
          }
        }
      return !1;
    }
  };
}
function Ut(e) {
  const r = /* @__PURE__ */ Object.create(null), i = e.getSchema(), t = i ? i.getDirectives() : ee;
  for (const a of t)
    r[a.name] = a.locations;
  const n = e.getDocument().definitions;
  for (const a of n)
    a.kind === f.DIRECTIVE_DEFINITION && (r[a.name.value] = a.locations.map((s) => s.value));
  return {
    Directive(a, s, c, d, l) {
      const g = a.name.value, h = r[g];
      if (!h) {
        e.reportError(
          new y(`Unknown directive "@${g}".`, {
            nodes: a
          })
        );
        return;
      }
      const T = kt(l);
      T && !h.includes(T) && e.reportError(
        new y(
          `Directive "@${g}" may not be used on ${T}.`,
          {
            nodes: a
          }
        )
      );
    }
  };
}
function kt(e) {
  const r = e[e.length - 1];
  switch ("kind" in r || B(!1), r.kind) {
    case f.OPERATION_DEFINITION:
      return Rt(r.operation);
    case f.FIELD:
      return L.FIELD;
    case f.FRAGMENT_SPREAD:
      return L.FRAGMENT_SPREAD;
    case f.INLINE_FRAGMENT:
      return L.INLINE_FRAGMENT;
    case f.FRAGMENT_DEFINITION:
      return L.FRAGMENT_DEFINITION;
    case f.VARIABLE_DEFINITION:
      return L.VARIABLE_DEFINITION;
    case f.SCHEMA_DEFINITION:
    case f.SCHEMA_EXTENSION:
      return L.SCHEMA;
    case f.SCALAR_TYPE_DEFINITION:
    case f.SCALAR_TYPE_EXTENSION:
      return L.SCALAR;
    case f.OBJECT_TYPE_DEFINITION:
    case f.OBJECT_TYPE_EXTENSION:
      return L.OBJECT;
    case f.FIELD_DEFINITION:
      return L.FIELD_DEFINITION;
    case f.INTERFACE_TYPE_DEFINITION:
    case f.INTERFACE_TYPE_EXTENSION:
      return L.INTERFACE;
    case f.UNION_TYPE_DEFINITION:
    case f.UNION_TYPE_EXTENSION:
      return L.UNION;
    case f.ENUM_TYPE_DEFINITION:
    case f.ENUM_TYPE_EXTENSION:
      return L.ENUM;
    case f.ENUM_VALUE_DEFINITION:
      return L.ENUM_VALUE;
    case f.INPUT_OBJECT_TYPE_DEFINITION:
    case f.INPUT_OBJECT_TYPE_EXTENSION:
      return L.INPUT_OBJECT;
    case f.INPUT_VALUE_DEFINITION: {
      const i = e[e.length - 3];
      return "kind" in i || B(!1), i.kind === f.INPUT_OBJECT_TYPE_DEFINITION ? L.INPUT_FIELD_DEFINITION : L.ARGUMENT_DEFINITION;
    }
    default:
      B(!1, "Unexpected kind: " + X(r.kind));
  }
}
function Rt(e) {
  switch (e) {
    case me.QUERY:
      return L.QUERY;
    case me.MUTATION:
      return L.MUTATION;
    case me.SUBSCRIPTION:
      return L.SUBSCRIPTION;
  }
}
function jt(e) {
  const r = e.getSchema(), i = r ? r.getTypeMap() : /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null);
  for (const a of e.getDocument().definitions)
    ve(a) && (t[a.name.value] = !0);
  const n = [
    ...Object.keys(i),
    ...Object.keys(t)
  ];
  return {
    NamedType(a, s, c, d, l) {
      const g = a.name.value;
      if (!i[g] && !t[g]) {
        var h;
        const T = (h = l[2]) !== null && h !== void 0 ? h : c, m = T != null && Vt(T);
        if (m && Ze.includes(g))
          return;
        const A = Ae(
          g,
          m ? Ze.concat(n) : n
        );
        e.reportError(
          new y(
            `Unknown type "${g}".` + we(A),
            {
              nodes: a
            }
          )
        );
      }
    }
  };
}
const Ze = [...nt, ...tt].map(
  (e) => e.name
);
function Vt(e) {
  return "kind" in e && (It(e) || _t(e));
}
function Yt(e) {
  var r, i, t;
  const n = e.getSchema(), a = (r = (i = (t = n?.astNode) !== null && t !== void 0 ? t : n?.getQueryType()) !== null && i !== void 0 ? i : n?.getMutationType()) !== null && r !== void 0 ? r : n?.getSubscriptionType();
  let s = 0;
  return {
    SchemaDefinition(c) {
      if (a) {
        e.reportError(
          new y(
            "Cannot define a new schema within a schema extension.",
            {
              nodes: c
            }
          )
        );
        return;
      }
      s > 0 && e.reportError(
        new y("Must provide only one schema definition.", {
          nodes: c
        })
      ), ++s;
    }
  };
}
function Xt(e) {
  const r = e.getSchema(), i = /* @__PURE__ */ Object.create(null);
  for (const n of e.getDocument().definitions)
    ve(n) && (i[n.name.value] = n);
  return {
    ScalarTypeExtension: t,
    ObjectTypeExtension: t,
    InterfaceTypeExtension: t,
    UnionTypeExtension: t,
    EnumTypeExtension: t,
    InputObjectTypeExtension: t
  };
  function t(n) {
    const a = n.name.value, s = i[a], c = r?.getType(a);
    let d;
    if (s ? d = Bt[s.kind] : c && (d = $t(c)), d) {
      if (d !== n.kind) {
        const l = qt(n.kind);
        e.reportError(
          new y(`Cannot extend non-${l} type "${a}".`, {
            nodes: s ? [s, n] : n
          })
        );
      }
    } else {
      const l = Object.keys({
        ...i,
        ...r?.getTypeMap()
      }), g = Ae(a, l);
      e.reportError(
        new y(
          `Cannot extend type "${a}" because it is not defined.` + we(g),
          {
            nodes: n.name
          }
        )
      );
    }
  }
}
const Bt = {
  [f.SCALAR_TYPE_DEFINITION]: f.SCALAR_TYPE_EXTENSION,
  [f.OBJECT_TYPE_DEFINITION]: f.OBJECT_TYPE_EXTENSION,
  [f.INTERFACE_TYPE_DEFINITION]: f.INTERFACE_TYPE_EXTENSION,
  [f.UNION_TYPE_DEFINITION]: f.UNION_TYPE_EXTENSION,
  [f.ENUM_TYPE_DEFINITION]: f.ENUM_TYPE_EXTENSION,
  [f.INPUT_OBJECT_TYPE_DEFINITION]: f.INPUT_OBJECT_TYPE_EXTENSION
};
function $t(e) {
  if (rt(e))
    return f.SCALAR_TYPE_EXTENSION;
  if (Fe(e))
    return f.OBJECT_TYPE_EXTENSION;
  if (xe(e))
    return f.INTERFACE_TYPE_EXTENSION;
  if (it(e))
    return f.UNION_TYPE_EXTENSION;
  if (Le(e))
    return f.ENUM_TYPE_EXTENSION;
  if (Pe(e))
    return f.INPUT_OBJECT_TYPE_EXTENSION;
  B(!1, "Unexpected type: " + X(e));
}
function qt(e) {
  switch (e) {
    case f.SCALAR_TYPE_EXTENSION:
      return "scalar";
    case f.OBJECT_TYPE_EXTENSION:
      return "object";
    case f.INTERFACE_TYPE_EXTENSION:
      return "interface";
    case f.UNION_TYPE_EXTENSION:
      return "union";
    case f.ENUM_TYPE_EXTENSION:
      return "enum";
    case f.INPUT_OBJECT_TYPE_EXTENSION:
      return "input object";
    default:
      B(!1, "Unexpected kind: " + X(e));
  }
}
function Jt(e) {
  var r;
  const i = /* @__PURE__ */ Object.create(null), t = e.getSchema(), n = (r = t?.getDirectives()) !== null && r !== void 0 ? r : ee;
  for (const c of n)
    i[c.name] = oe(
      c.args.filter(yt),
      (d) => d.name
    );
  const a = e.getDocument().definitions;
  for (const c of a)
    if (c.kind === f.DIRECTIVE_DEFINITION) {
      var s;
      const d = (s = c.arguments) !== null && s !== void 0 ? s : [];
      i[c.name.value] = oe(
        d.filter(Qt),
        (l) => l.name.value
      );
    }
  return {
    Directive: {
      // Validate on leave to allow for deeper errors to appear first.
      leave(c) {
        const d = c.name.value, l = i[d];
        if (l) {
          var g;
          const h = (g = c.arguments) !== null && g !== void 0 ? g : [], T = new Set(h.map((m) => m.name.value));
          for (const [m, A] of Object.entries(l))
            if (!T.has(m)) {
              const M = Dt(A.type) ? X(A.type) : at(A.type);
              e.reportError(
                new y(
                  `Directive "@${d}" argument "${m}" of type "${M}" is required, but it was not provided.`,
                  {
                    nodes: c
                  }
                )
              );
            }
        }
      }
    }
  };
}
function Qt(e) {
  return e.type.kind === f.NON_NULL_TYPE && e.defaultValue == null;
}
function Gt(e, r, i) {
  var t;
  const n = {}, a = (t = r.arguments) !== null && t !== void 0 ? t : [], s = oe(a, (c) => c.name.value);
  for (const c of e.args) {
    const d = c.name, l = c.type, g = s[d];
    if (!g) {
      if (c.defaultValue !== void 0)
        n[d] = c.defaultValue;
      else if (se(l))
        throw new y(
          `Argument "${d}" of required type "${X(l)}" was not provided.`,
          {
            nodes: r
          }
        );
      continue;
    }
    const h = g.value;
    let T = h.kind === f.NULL;
    if (h.kind === f.VARIABLE) {
      const A = h.name.value;
      if (i == null || !Wt(i, A)) {
        if (c.defaultValue !== void 0)
          n[d] = c.defaultValue;
        else if (se(l))
          throw new y(
            `Argument "${d}" of required type "${X(l)}" was provided the variable "$${A}" which was not provided a runtime value.`,
            {
              nodes: h
            }
          );
        continue;
      }
      T = i[A] == null;
    }
    if (T && se(l))
      throw new y(
        `Argument "${d}" of non-null type "${X(l)}" must not be null.`,
        {
          nodes: h
        }
      );
    const m = Ne(h, l, i);
    if (m === void 0)
      throw new y(
        `Argument "${d}" has invalid value ${at(h)}.`,
        {
          nodes: h
        }
      );
    n[d] = m;
  }
  return n;
}
function ot(e, r, i) {
  var t;
  const n = (t = r.directives) === null || t === void 0 ? void 0 : t.find(
    (a) => a.name.value === e.name
  );
  if (n)
    return Gt(e, n, i);
}
function Wt(e, r) {
  return Object.prototype.hasOwnProperty.call(e, r);
}
function ct(e, r) {
  const i = /* @__PURE__ */ new Map();
  for (const t of e) {
    const n = r(t), a = i.get(n);
    a === void 0 ? i.set(n, [t]) : a.push(t);
  }
  return i;
}
function Ht(e) {
  return {
    DirectiveDefinition(t) {
      var n;
      const a = (n = t.arguments) !== null && n !== void 0 ? n : [];
      return i(`@${t.name.value}`, a);
    },
    InterfaceTypeDefinition: r,
    InterfaceTypeExtension: r,
    ObjectTypeDefinition: r,
    ObjectTypeExtension: r
  };
  function r(t) {
    var n;
    const a = t.name.value, s = (n = t.fields) !== null && n !== void 0 ? n : [];
    for (const d of s) {
      var c;
      const l = d.name.value, g = (c = d.arguments) !== null && c !== void 0 ? c : [];
      i(`${a}.${l}`, g);
    }
    return !1;
  }
  function i(t, n) {
    const a = ct(n, (s) => s.name.value);
    for (const [s, c] of a)
      c.length > 1 && e.reportError(
        new y(
          `Argument "${t}(${s}:)" can only be defined once.`,
          {
            nodes: c.map((d) => d.name)
          }
        )
      );
    return !1;
  }
}
function zt(e) {
  return {
    Field: r,
    Directive: r
  };
  function r(i) {
    var t;
    const n = (t = i.arguments) !== null && t !== void 0 ? t : [], a = ct(n, (s) => s.name.value);
    for (const [s, c] of a)
      c.length > 1 && e.reportError(
        new y(
          `There can be only one argument named "${s}".`,
          {
            nodes: c.map((d) => d.name)
          }
        )
      );
  }
}
function Zt(e) {
  const r = /* @__PURE__ */ Object.create(null), i = e.getSchema();
  return {
    DirectiveDefinition(t) {
      const n = t.name.value;
      if (i != null && i.getDirective(n)) {
        e.reportError(
          new y(
            `Directive "@${n}" already exists in the schema. It cannot be redefined.`,
            {
              nodes: t.name
            }
          )
        );
        return;
      }
      return r[n] ? e.reportError(
        new y(
          `There can be only one directive named "@${n}".`,
          {
            nodes: [r[n], t.name]
          }
        )
      ) : r[n] = t.name, !1;
    }
  };
}
function Kt(e) {
  const r = /* @__PURE__ */ Object.create(null), i = e.getSchema(), t = i ? i.getDirectives() : ee;
  for (const c of t)
    r[c.name] = !c.isRepeatable;
  const n = e.getDocument().definitions;
  for (const c of n)
    c.kind === f.DIRECTIVE_DEFINITION && (r[c.name.value] = !c.repeatable);
  const a = /* @__PURE__ */ Object.create(null), s = /* @__PURE__ */ Object.create(null);
  return {
    // Many different AST nodes may contain directives. Rather than listing
    // them all, just listen for entering any node, and check to see if it
    // defines any directives.
    enter(c) {
      if (!("directives" in c) || !c.directives)
        return;
      let d;
      if (c.kind === f.SCHEMA_DEFINITION || c.kind === f.SCHEMA_EXTENSION)
        d = a;
      else if (ve(c) || st(c)) {
        const l = c.name.value;
        d = s[l], d === void 0 && (s[l] = d = /* @__PURE__ */ Object.create(null));
      } else
        d = /* @__PURE__ */ Object.create(null);
      for (const l of c.directives) {
        const g = l.name.value;
        r[g] && (d[g] ? e.reportError(
          new y(
            `The directive "@${g}" can only be used once at this location.`,
            {
              nodes: [d[g], l]
            }
          )
        ) : d[g] = l);
      }
    }
  };
}
function er(e) {
  const r = e.getSchema(), i = r ? r.getTypeMap() : /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null);
  return {
    EnumTypeDefinition: n,
    EnumTypeExtension: n
  };
  function n(a) {
    var s;
    const c = a.name.value;
    t[c] || (t[c] = /* @__PURE__ */ Object.create(null));
    const d = (s = a.values) !== null && s !== void 0 ? s : [], l = t[c];
    for (const g of d) {
      const h = g.name.value, T = i[c];
      Le(T) && T.getValue(h) ? e.reportError(
        new y(
          `Enum value "${c}.${h}" already exists in the schema. It cannot also be defined in this type extension.`,
          {
            nodes: g.name
          }
        )
      ) : l[h] ? e.reportError(
        new y(
          `Enum value "${c}.${h}" can only be defined once.`,
          {
            nodes: [l[h], g.name]
          }
        )
      ) : l[h] = g.name;
    }
    return !1;
  }
}
function nr(e) {
  const r = e.getSchema(), i = r ? r.getTypeMap() : /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null);
  return {
    InputObjectTypeDefinition: n,
    InputObjectTypeExtension: n,
    InterfaceTypeDefinition: n,
    InterfaceTypeExtension: n,
    ObjectTypeDefinition: n,
    ObjectTypeExtension: n
  };
  function n(a) {
    var s;
    const c = a.name.value;
    t[c] || (t[c] = /* @__PURE__ */ Object.create(null));
    const d = (s = a.fields) !== null && s !== void 0 ? s : [], l = t[c];
    for (const g of d) {
      const h = g.name.value;
      tr(i[c], h) ? e.reportError(
        new y(
          `Field "${c}.${h}" already exists in the schema. It cannot also be defined in this type extension.`,
          {
            nodes: g.name
          }
        )
      ) : l[h] ? e.reportError(
        new y(
          `Field "${c}.${h}" can only be defined once.`,
          {
            nodes: [l[h], g.name]
          }
        )
      ) : l[h] = g.name;
    }
    return !1;
  }
}
function tr(e, r) {
  return Fe(e) || xe(e) || Pe(e) ? e.getFields()[r] != null : !1;
}
function rr(e) {
  const r = [];
  let i = /* @__PURE__ */ Object.create(null);
  return {
    ObjectValue: {
      enter() {
        r.push(i), i = /* @__PURE__ */ Object.create(null);
      },
      leave() {
        const t = r.pop();
        t || B(!1), i = t;
      }
    },
    ObjectField(t) {
      const n = t.name.value;
      i[n] ? e.reportError(
        new y(
          `There can be only one input field named "${n}".`,
          {
            nodes: [i[n], t.name]
          }
        )
      ) : i[n] = t.name;
    }
  };
}
function ir(e) {
  const r = e.getSchema(), i = /* @__PURE__ */ Object.create(null), t = r ? {
    query: r.getQueryType(),
    mutation: r.getMutationType(),
    subscription: r.getSubscriptionType()
  } : {};
  return {
    SchemaDefinition: n,
    SchemaExtension: n
  };
  function n(a) {
    var s;
    const c = (s = a.operationTypes) !== null && s !== void 0 ? s : [];
    for (const d of c) {
      const l = d.operation, g = i[l];
      t[l] ? e.reportError(
        new y(
          `Type for ${l} already defined in the schema. It cannot be redefined.`,
          {
            nodes: d
          }
        )
      ) : g ? e.reportError(
        new y(
          `There can be only one ${l} type in schema.`,
          {
            nodes: [g, d]
          }
        )
      ) : i[l] = d;
    }
    return !1;
  }
}
function ar(e) {
  const r = /* @__PURE__ */ Object.create(null), i = e.getSchema();
  return {
    ScalarTypeDefinition: t,
    ObjectTypeDefinition: t,
    InterfaceTypeDefinition: t,
    UnionTypeDefinition: t,
    EnumTypeDefinition: t,
    InputObjectTypeDefinition: t
  };
  function t(n) {
    const a = n.name.value;
    if (i != null && i.getType(a)) {
      e.reportError(
        new y(
          `Type "${a}" already exists in the schema. It cannot also be defined in this type definition.`,
          {
            nodes: n.name
          }
        )
      );
      return;
    }
    return r[a] ? e.reportError(
      new y(`There can be only one type named "${a}".`, {
        nodes: [r[a], n.name]
      })
    ) : r[a] = n.name, !1;
  }
}
const sr = Object.freeze([
  Yt,
  ir,
  ar,
  er,
  nr,
  Ht,
  Zt,
  jt,
  Ut,
  Kt,
  Xt,
  Mt,
  zt,
  rr,
  Jt
]);
class or {
  constructor(r, i) {
    this._ast = r, this._fragments = void 0, this._fragmentSpreads = /* @__PURE__ */ new Map(), this._recursivelyReferencedFragments = /* @__PURE__ */ new Map(), this._onError = i;
  }
  get [Symbol.toStringTag]() {
    return "ASTValidationContext";
  }
  reportError(r) {
    this._onError(r);
  }
  getDocument() {
    return this._ast;
  }
  getFragment(r) {
    let i;
    if (this._fragments)
      i = this._fragments;
    else {
      i = /* @__PURE__ */ Object.create(null);
      for (const t of this.getDocument().definitions)
        t.kind === f.FRAGMENT_DEFINITION && (i[t.name.value] = t);
      this._fragments = i;
    }
    return i[r];
  }
  getFragmentSpreads(r) {
    let i = this._fragmentSpreads.get(r);
    if (!i) {
      i = [];
      const t = [r];
      let n;
      for (; n = t.pop(); )
        for (const a of n.selections)
          a.kind === f.FRAGMENT_SPREAD ? i.push(a) : a.selectionSet && t.push(a.selectionSet);
      this._fragmentSpreads.set(r, i);
    }
    return i;
  }
  getRecursivelyReferencedFragments(r) {
    let i = this._recursivelyReferencedFragments.get(r);
    if (!i) {
      i = [];
      const t = /* @__PURE__ */ Object.create(null), n = [r.selectionSet];
      let a;
      for (; a = n.pop(); )
        for (const s of this.getFragmentSpreads(a)) {
          const c = s.name.value;
          if (t[c] !== !0) {
            t[c] = !0;
            const d = this.getFragment(c);
            d && (i.push(d), n.push(d.selectionSet));
          }
        }
      this._recursivelyReferencedFragments.set(r, i);
    }
    return i;
  }
}
class cr extends or {
  constructor(r, i, t) {
    super(r, t), this._schema = i;
  }
  get [Symbol.toStringTag]() {
    return "SDLValidationContext";
  }
  getSchema() {
    return this._schema;
  }
}
function ur(e, r, i = sr) {
  const t = [], n = new cr(
    e,
    r,
    (s) => {
      t.push(s);
    }
  ), a = i.map((s) => s(n));
  return Ot(e, bt(a)), t;
}
function dr(e) {
  const r = ur(e);
  if (r.length !== 0)
    throw new Error(r.map((i) => i.message).join(`

`));
}
function fr(e, r, i) {
  var t, n, a, s;
  const c = [], d = /* @__PURE__ */ Object.create(null), l = [];
  let g;
  const h = [];
  for (const u of r.definitions)
    if (u.kind === f.SCHEMA_DEFINITION)
      g = u;
    else if (u.kind === f.SCHEMA_EXTENSION)
      h.push(u);
    else if (ve(u))
      c.push(u);
    else if (st(u)) {
      const v = u.name.value, p = d[v];
      d[v] = p ? p.concat([u]) : [u];
    } else
      u.kind === f.DIRECTIVE_DEFINITION && l.push(u);
  if (Object.keys(d).length === 0 && c.length === 0 && l.length === 0 && h.length === 0 && g == null)
    return e;
  const T = /* @__PURE__ */ Object.create(null);
  for (const u of e.types)
    T[u.name] = lt(u);
  for (const u of c) {
    var m;
    const v = u.name.value;
    T[v] = (m = Ke[v]) !== null && m !== void 0 ? m : Nt(u);
  }
  const A = {
    // Get the extended root operation types.
    query: e.query && R(e.query),
    mutation: e.mutation && R(e.mutation),
    subscription: e.subscription && R(e.subscription),
    // Then, incorporate schema definition and all schema extensions.
    ...g && ke([g]),
    ...ke(h)
  };
  return {
    description: (t = g) === null || t === void 0 || (n = t.description) === null || n === void 0 ? void 0 : n.value,
    ...A,
    types: Object.values(T),
    directives: [
      ...e.directives.map(ft),
      ...l.map(Tt)
    ],
    extensions: /* @__PURE__ */ Object.create(null),
    astNode: (a = g) !== null && a !== void 0 ? a : e.astNode,
    extensionASTNodes: e.extensionASTNodes.concat(h),
    assumeValid: (s = i?.assumeValid) !== null && s !== void 0 ? s : !1
  };
  function M(u) {
    return wt(u) ? new We(M(u.ofType)) : se(u) ? new He(M(u.ofType)) : R(u);
  }
  function R(u) {
    return T[u.name];
  }
  function ft(u) {
    const v = u.toConfig();
    return new Xe({
      ...v,
      args: W(v.args, Ue)
    });
  }
  function lt(u) {
    if (St(u) || At(u))
      return u;
    if (rt(u))
      return vt(u);
    if (Fe(u))
      return Et(u);
    if (xe(u))
      return ht(u);
    if (it(u))
      return mt(u);
    if (Le(u))
      return pt(u);
    if (Pe(u))
      return gt(u);
    B(!1, "Unexpected type: " + X(u));
  }
  function gt(u) {
    var v;
    const p = u.toConfig(), E = (v = d[p.name]) !== null && v !== void 0 ? v : [];
    return new Be({
      ...p,
      fields: () => ({
        ...W(p.fields, (b) => ({
          ...b,
          type: M(b.type)
        })),
        ...je(E)
      }),
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function pt(u) {
    var v;
    const p = u.toConfig(), E = (v = d[u.name]) !== null && v !== void 0 ? v : [];
    return new $e({
      ...p,
      values: { ...p.values, ...Ve(E) },
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function vt(u) {
    var v;
    const p = u.toConfig(), E = (v = d[p.name]) !== null && v !== void 0 ? v : [];
    let b = p.specifiedByURL;
    for (const S of E) {
      var x;
      b = (x = en(S)) !== null && x !== void 0 ? x : b;
    }
    return new qe({
      ...p,
      specifiedByURL: b,
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function Et(u) {
    var v;
    const p = u.toConfig(), E = (v = d[p.name]) !== null && v !== void 0 ? v : [];
    return new Je({
      ...p,
      interfaces: () => [
        ...u.getInterfaces().map(R),
        ...re(E)
      ],
      fields: () => ({
        ...W(p.fields, Me),
        ...te(E)
      }),
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function ht(u) {
    var v;
    const p = u.toConfig(), E = (v = d[p.name]) !== null && v !== void 0 ? v : [];
    return new Qe({
      ...p,
      interfaces: () => [
        ...u.getInterfaces().map(R),
        ...re(E)
      ],
      fields: () => ({
        ...W(p.fields, Me),
        ...te(E)
      }),
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function mt(u) {
    var v;
    const p = u.toConfig(), E = (v = d[p.name]) !== null && v !== void 0 ? v : [];
    return new Ge({
      ...p,
      types: () => [
        ...u.getTypes().map(R),
        ...Ye(E)
      ],
      extensionASTNodes: p.extensionASTNodes.concat(E)
    });
  }
  function Me(u) {
    return {
      ...u,
      type: M(u.type),
      args: u.args && W(u.args, Ue)
    };
  }
  function Ue(u) {
    return { ...u, type: M(u.type) };
  }
  function ke(u) {
    const v = {};
    for (const E of u) {
      var p;
      const b = (
        /* c8 ignore next */
        (p = E.operationTypes) !== null && p !== void 0 ? p : []
      );
      for (const x of b)
        v[x.operation] = ne(x.type);
    }
    return v;
  }
  function ne(u) {
    var v;
    const p = u.name.value, E = (v = Ke[p]) !== null && v !== void 0 ? v : T[p];
    if (E === void 0)
      throw new Error(`Unknown type: "${p}".`);
    return E;
  }
  function G(u) {
    return u.kind === f.LIST_TYPE ? new We(G(u.type)) : u.kind === f.NON_NULL_TYPE ? new He(G(u.type)) : ne(u);
  }
  function Tt(u) {
    var v;
    return new Xe({
      name: u.name.value,
      description: (v = u.description) === null || v === void 0 ? void 0 : v.value,
      // @ts-expect-error
      locations: u.locations.map(({ value: p }) => p),
      isRepeatable: u.repeatable,
      args: Re(u.arguments),
      astNode: u
    });
  }
  function te(u) {
    const v = /* @__PURE__ */ Object.create(null);
    for (const b of u) {
      var p;
      const x = (
        /* c8 ignore next */
        (p = b.fields) !== null && p !== void 0 ? p : []
      );
      for (const S of x) {
        var E;
        v[S.name.value] = {
          // Note: While this could make assertions to get the correctly typed
          // value, that would throw immediately while type system validation
          // with validateSchema() will produce more actionable results.
          type: G(S.type),
          description: (E = S.description) === null || E === void 0 ? void 0 : E.value,
          args: Re(S.arguments),
          deprecationReason: ie(S),
          astNode: S
        };
      }
    }
    return v;
  }
  function Re(u) {
    const v = (
      /* c8 ignore next */
      u ?? []
    ), p = /* @__PURE__ */ Object.create(null);
    for (const b of v) {
      var E;
      const x = G(b.type);
      p[b.name.value] = {
        type: x,
        description: (E = b.description) === null || E === void 0 ? void 0 : E.value,
        defaultValue: Ne(b.defaultValue, x),
        deprecationReason: ie(b),
        astNode: b
      };
    }
    return p;
  }
  function je(u) {
    const v = /* @__PURE__ */ Object.create(null);
    for (const b of u) {
      var p;
      const x = (
        /* c8 ignore next */
        (p = b.fields) !== null && p !== void 0 ? p : []
      );
      for (const S of x) {
        var E;
        const $ = G(S.type);
        v[S.name.value] = {
          type: $,
          description: (E = S.description) === null || E === void 0 ? void 0 : E.value,
          defaultValue: Ne(S.defaultValue, $),
          deprecationReason: ie(S),
          astNode: S
        };
      }
    }
    return v;
  }
  function Ve(u) {
    const v = /* @__PURE__ */ Object.create(null);
    for (const b of u) {
      var p;
      const x = (
        /* c8 ignore next */
        (p = b.values) !== null && p !== void 0 ? p : []
      );
      for (const S of x) {
        var E;
        v[S.name.value] = {
          description: (E = S.description) === null || E === void 0 ? void 0 : E.value,
          deprecationReason: ie(S),
          astNode: S
        };
      }
    }
    return v;
  }
  function re(u) {
    return u.flatMap(
      // FIXME: https://github.com/graphql/graphql-js/issues/2203
      (v) => {
        var p, E;
        return (
          /* c8 ignore next */
          (p = (E = v.interfaces) === null || E === void 0 ? void 0 : E.map(ne)) !== null && p !== void 0 ? p : []
        );
      }
    );
  }
  function Ye(u) {
    return u.flatMap(
      // FIXME: https://github.com/graphql/graphql-js/issues/2203
      (v) => {
        var p, E;
        return (
          /* c8 ignore next */
          (p = (E = v.types) === null || E === void 0 ? void 0 : E.map(ne)) !== null && p !== void 0 ? p : []
        );
      }
    );
  }
  function Nt(u) {
    var v;
    const p = u.name.value, E = (v = d[p]) !== null && v !== void 0 ? v : [];
    switch (u.kind) {
      case f.OBJECT_TYPE_DEFINITION: {
        var b;
        const U = [u, ...E];
        return new Je({
          name: p,
          description: (b = u.description) === null || b === void 0 ? void 0 : b.value,
          interfaces: () => re(U),
          fields: () => te(U),
          astNode: u,
          extensionASTNodes: E
        });
      }
      case f.INTERFACE_TYPE_DEFINITION: {
        var x;
        const U = [u, ...E];
        return new Qe({
          name: p,
          description: (x = u.description) === null || x === void 0 ? void 0 : x.value,
          interfaces: () => re(U),
          fields: () => te(U),
          astNode: u,
          extensionASTNodes: E
        });
      }
      case f.ENUM_TYPE_DEFINITION: {
        var S;
        const U = [u, ...E];
        return new $e({
          name: p,
          description: (S = u.description) === null || S === void 0 ? void 0 : S.value,
          values: Ve(U),
          astNode: u,
          extensionASTNodes: E
        });
      }
      case f.UNION_TYPE_DEFINITION: {
        var $;
        const U = [u, ...E];
        return new Ge({
          name: p,
          description: ($ = u.description) === null || $ === void 0 ? void 0 : $.value,
          types: () => Ye(U),
          astNode: u,
          extensionASTNodes: E
        });
      }
      case f.SCALAR_TYPE_DEFINITION: {
        var Ee;
        return new qe({
          name: p,
          description: (Ee = u.description) === null || Ee === void 0 ? void 0 : Ee.value,
          specifiedByURL: en(u),
          astNode: u,
          extensionASTNodes: E
        });
      }
      case f.INPUT_OBJECT_TYPE_DEFINITION: {
        var he;
        const U = [u, ...E];
        return new Be({
          name: p,
          description: (he = u.description) === null || he === void 0 ? void 0 : he.value,
          fields: () => je(U),
          astNode: u,
          extensionASTNodes: E
        });
      }
    }
  }
}
const Ke = oe(
  [...nt, ...tt],
  (e) => e.name
);
function ie(e) {
  const r = ot(Ft, e);
  return r?.reason;
}
function en(e) {
  const r = ot(xt, e);
  return r?.url;
}
function lr(e, r) {
  e != null && e.kind === f.DOCUMENT || Lt(!1, "Must provide valid Document AST."), r?.assumeValid !== !0 && r?.assumeValidSDL !== !0 && dr(e);
  const t = fr({
    description: void 0,
    types: [],
    directives: [],
    extensions: /* @__PURE__ */ Object.create(null),
    extensionASTNodes: [],
    assumeValid: !1
  }, e, r);
  if (t.astNode == null)
    for (const a of t.types)
      switch (a.name) {
        case "Query":
          t.query = a;
          break;
        case "Mutation":
          t.mutation = a;
          break;
        case "Subscription":
          t.subscription = a;
          break;
      }
  const n = [
    ...t.directives,
    // If specified directives were not explicitly declared, add them.
    ...ee.filter(
      (a) => t.directives.every(
        (s) => s.name !== a.name
      )
    )
  ];
  return new Pt({ ...t, directives: n });
}
var nn;
(function(e) {
  function r(i) {
    return typeof i == "string";
  }
  e.is = r;
})(nn || (nn = {}));
var Ie;
(function(e) {
  function r(i) {
    return typeof i == "string";
  }
  e.is = r;
})(Ie || (Ie = {}));
var tn;
(function(e) {
  e.MIN_VALUE = -2147483648, e.MAX_VALUE = 2147483647;
  function r(i) {
    return typeof i == "number" && e.MIN_VALUE <= i && i <= e.MAX_VALUE;
  }
  e.is = r;
})(tn || (tn = {}));
var ce;
(function(e) {
  e.MIN_VALUE = 0, e.MAX_VALUE = 2147483647;
  function r(i) {
    return typeof i == "number" && e.MIN_VALUE <= i && i <= e.MAX_VALUE;
  }
  e.is = r;
})(ce || (ce = {}));
var k;
(function(e) {
  function r(t, n) {
    return t === Number.MAX_VALUE && (t = ce.MAX_VALUE), n === Number.MAX_VALUE && (n = ce.MAX_VALUE), { line: t, character: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && o.uinteger(n.line) && o.uinteger(n.character);
  }
  e.is = i;
})(k || (k = {}));
var F;
(function(e) {
  function r(t, n, a, s) {
    if (o.uinteger(t) && o.uinteger(n) && o.uinteger(a) && o.uinteger(s))
      return { start: k.create(t, n), end: k.create(a, s) };
    if (k.is(t) && k.is(n))
      return { start: t, end: n };
    throw new Error("Range#create called with invalid arguments[".concat(t, ", ").concat(n, ", ").concat(a, ", ").concat(s, "]"));
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && k.is(n.start) && k.is(n.end);
  }
  e.is = i;
})(F || (F = {}));
var ue;
(function(e) {
  function r(t, n) {
    return { uri: t, range: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && F.is(n.range) && (o.string(n.uri) || o.undefined(n.uri));
  }
  e.is = i;
})(ue || (ue = {}));
var rn;
(function(e) {
  function r(t, n, a, s) {
    return { targetUri: t, targetRange: n, targetSelectionRange: a, originSelectionRange: s };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && F.is(n.targetRange) && o.string(n.targetUri) && F.is(n.targetSelectionRange) && (F.is(n.originSelectionRange) || o.undefined(n.originSelectionRange));
  }
  e.is = i;
})(rn || (rn = {}));
var _e;
(function(e) {
  function r(t, n, a, s) {
    return {
      red: t,
      green: n,
      blue: a,
      alpha: s
    };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && o.numberRange(n.red, 0, 1) && o.numberRange(n.green, 0, 1) && o.numberRange(n.blue, 0, 1) && o.numberRange(n.alpha, 0, 1);
  }
  e.is = i;
})(_e || (_e = {}));
var an;
(function(e) {
  function r(t, n) {
    return {
      range: t,
      color: n
    };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && F.is(n.range) && _e.is(n.color);
  }
  e.is = i;
})(an || (an = {}));
var sn;
(function(e) {
  function r(t, n, a) {
    return {
      label: t,
      textEdit: n,
      additionalTextEdits: a
    };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && o.string(n.label) && (o.undefined(n.textEdit) || V.is(n)) && (o.undefined(n.additionalTextEdits) || o.typedArray(n.additionalTextEdits, V.is));
  }
  e.is = i;
})(sn || (sn = {}));
var on;
(function(e) {
  e.Comment = "comment", e.Imports = "imports", e.Region = "region";
})(on || (on = {}));
var cn;
(function(e) {
  function r(t, n, a, s, c, d) {
    var l = {
      startLine: t,
      endLine: n
    };
    return o.defined(a) && (l.startCharacter = a), o.defined(s) && (l.endCharacter = s), o.defined(c) && (l.kind = c), o.defined(d) && (l.collapsedText = d), l;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && o.uinteger(n.startLine) && o.uinteger(n.startLine) && (o.undefined(n.startCharacter) || o.uinteger(n.startCharacter)) && (o.undefined(n.endCharacter) || o.uinteger(n.endCharacter)) && (o.undefined(n.kind) || o.string(n.kind));
  }
  e.is = i;
})(cn || (cn = {}));
var ye;
(function(e) {
  function r(t, n) {
    return {
      location: t,
      message: n
    };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && ue.is(n.location) && o.string(n.message);
  }
  e.is = i;
})(ye || (ye = {}));
var un;
(function(e) {
  e.Error = 1, e.Warning = 2, e.Information = 3, e.Hint = 4;
})(un || (un = {}));
var dn;
(function(e) {
  e.Unnecessary = 1, e.Deprecated = 2;
})(dn || (dn = {}));
var fn;
(function(e) {
  function r(i) {
    var t = i;
    return o.objectLiteral(t) && o.string(t.href);
  }
  e.is = r;
})(fn || (fn = {}));
var de;
(function(e) {
  function r(t, n, a, s, c, d) {
    var l = { range: t, message: n };
    return o.defined(a) && (l.severity = a), o.defined(s) && (l.code = s), o.defined(c) && (l.source = c), o.defined(d) && (l.relatedInformation = d), l;
  }
  e.create = r;
  function i(t) {
    var n, a = t;
    return o.defined(a) && F.is(a.range) && o.string(a.message) && (o.number(a.severity) || o.undefined(a.severity)) && (o.integer(a.code) || o.string(a.code) || o.undefined(a.code)) && (o.undefined(a.codeDescription) || o.string((n = a.codeDescription) === null || n === void 0 ? void 0 : n.href)) && (o.string(a.source) || o.undefined(a.source)) && (o.undefined(a.relatedInformation) || o.typedArray(a.relatedInformation, ye.is));
  }
  e.is = i;
})(de || (de = {}));
var Q;
(function(e) {
  function r(t, n) {
    for (var a = [], s = 2; s < arguments.length; s++)
      a[s - 2] = arguments[s];
    var c = { title: t, command: n };
    return o.defined(a) && a.length > 0 && (c.arguments = a), c;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.string(n.title) && o.string(n.command);
  }
  e.is = i;
})(Q || (Q = {}));
var V;
(function(e) {
  function r(a, s) {
    return { range: a, newText: s };
  }
  e.replace = r;
  function i(a, s) {
    return { range: { start: a, end: a }, newText: s };
  }
  e.insert = i;
  function t(a) {
    return { range: a, newText: "" };
  }
  e.del = t;
  function n(a) {
    var s = a;
    return o.objectLiteral(s) && o.string(s.newText) && F.is(s.range);
  }
  e.is = n;
})(V || (V = {}));
var J;
(function(e) {
  function r(t, n, a) {
    var s = { label: t };
    return n !== void 0 && (s.needsConfirmation = n), a !== void 0 && (s.description = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && o.string(n.label) && (o.boolean(n.needsConfirmation) || n.needsConfirmation === void 0) && (o.string(n.description) || n.description === void 0);
  }
  e.is = i;
})(J || (J = {}));
var C;
(function(e) {
  function r(i) {
    var t = i;
    return o.string(t);
  }
  e.is = r;
})(C || (C = {}));
var Y;
(function(e) {
  function r(a, s, c) {
    return { range: a, newText: s, annotationId: c };
  }
  e.replace = r;
  function i(a, s, c) {
    return { range: { start: a, end: a }, newText: s, annotationId: c };
  }
  e.insert = i;
  function t(a, s) {
    return { range: a, newText: "", annotationId: s };
  }
  e.del = t;
  function n(a) {
    var s = a;
    return V.is(s) && (J.is(s.annotationId) || C.is(s.annotationId));
  }
  e.is = n;
})(Y || (Y = {}));
var fe;
(function(e) {
  function r(t, n) {
    return { textDocument: t, edits: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && le.is(n.textDocument) && Array.isArray(n.edits);
  }
  e.is = i;
})(fe || (fe = {}));
var H;
(function(e) {
  function r(t, n, a) {
    var s = {
      kind: "create",
      uri: t
    };
    return n !== void 0 && (n.overwrite !== void 0 || n.ignoreIfExists !== void 0) && (s.options = n), a !== void 0 && (s.annotationId = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && n.kind === "create" && o.string(n.uri) && (n.options === void 0 || (n.options.overwrite === void 0 || o.boolean(n.options.overwrite)) && (n.options.ignoreIfExists === void 0 || o.boolean(n.options.ignoreIfExists))) && (n.annotationId === void 0 || C.is(n.annotationId));
  }
  e.is = i;
})(H || (H = {}));
var z;
(function(e) {
  function r(t, n, a, s) {
    var c = {
      kind: "rename",
      oldUri: t,
      newUri: n
    };
    return a !== void 0 && (a.overwrite !== void 0 || a.ignoreIfExists !== void 0) && (c.options = a), s !== void 0 && (c.annotationId = s), c;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && n.kind === "rename" && o.string(n.oldUri) && o.string(n.newUri) && (n.options === void 0 || (n.options.overwrite === void 0 || o.boolean(n.options.overwrite)) && (n.options.ignoreIfExists === void 0 || o.boolean(n.options.ignoreIfExists))) && (n.annotationId === void 0 || C.is(n.annotationId));
  }
  e.is = i;
})(z || (z = {}));
var Z;
(function(e) {
  function r(t, n, a) {
    var s = {
      kind: "delete",
      uri: t
    };
    return n !== void 0 && (n.recursive !== void 0 || n.ignoreIfNotExists !== void 0) && (s.options = n), a !== void 0 && (s.annotationId = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && n.kind === "delete" && o.string(n.uri) && (n.options === void 0 || (n.options.recursive === void 0 || o.boolean(n.options.recursive)) && (n.options.ignoreIfNotExists === void 0 || o.boolean(n.options.ignoreIfNotExists))) && (n.annotationId === void 0 || C.is(n.annotationId));
  }
  e.is = i;
})(Z || (Z = {}));
var De;
(function(e) {
  function r(i) {
    var t = i;
    return t && (t.changes !== void 0 || t.documentChanges !== void 0) && (t.documentChanges === void 0 || t.documentChanges.every(function(n) {
      return o.string(n.kind) ? H.is(n) || z.is(n) || Z.is(n) : fe.is(n);
    }));
  }
  e.is = r;
})(De || (De = {}));
var ae = (
  /** @class */
  function() {
    function e(r, i) {
      this.edits = r, this.changeAnnotations = i;
    }
    return e.prototype.insert = function(r, i, t) {
      var n, a;
      if (t === void 0 ? n = V.insert(r, i) : C.is(t) ? (a = t, n = Y.insert(r, i, t)) : (this.assertChangeAnnotations(this.changeAnnotations), a = this.changeAnnotations.manage(t), n = Y.insert(r, i, a)), this.edits.push(n), a !== void 0)
        return a;
    }, e.prototype.replace = function(r, i, t) {
      var n, a;
      if (t === void 0 ? n = V.replace(r, i) : C.is(t) ? (a = t, n = Y.replace(r, i, t)) : (this.assertChangeAnnotations(this.changeAnnotations), a = this.changeAnnotations.manage(t), n = Y.replace(r, i, a)), this.edits.push(n), a !== void 0)
        return a;
    }, e.prototype.delete = function(r, i) {
      var t, n;
      if (i === void 0 ? t = V.del(r) : C.is(i) ? (n = i, t = Y.del(r, i)) : (this.assertChangeAnnotations(this.changeAnnotations), n = this.changeAnnotations.manage(i), t = Y.del(r, n)), this.edits.push(t), n !== void 0)
        return n;
    }, e.prototype.add = function(r) {
      this.edits.push(r);
    }, e.prototype.all = function() {
      return this.edits;
    }, e.prototype.clear = function() {
      this.edits.splice(0, this.edits.length);
    }, e.prototype.assertChangeAnnotations = function(r) {
      if (r === void 0)
        throw new Error("Text edit change is not configured to manage change annotations.");
    }, e;
  }()
), ln = (
  /** @class */
  function() {
    function e(r) {
      this._annotations = r === void 0 ? /* @__PURE__ */ Object.create(null) : r, this._counter = 0, this._size = 0;
    }
    return e.prototype.all = function() {
      return this._annotations;
    }, Object.defineProperty(e.prototype, "size", {
      get: function() {
        return this._size;
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.manage = function(r, i) {
      var t;
      if (C.is(r) ? t = r : (t = this.nextId(), i = r), this._annotations[t] !== void 0)
        throw new Error("Id ".concat(t, " is already in use."));
      if (i === void 0)
        throw new Error("No annotation provided for id ".concat(t));
      return this._annotations[t] = i, this._size++, t;
    }, e.prototype.nextId = function() {
      return this._counter++, this._counter.toString();
    }, e;
  }()
);
(function() {
  function e(r) {
    var i = this;
    this._textEditChanges = /* @__PURE__ */ Object.create(null), r !== void 0 ? (this._workspaceEdit = r, r.documentChanges ? (this._changeAnnotations = new ln(r.changeAnnotations), r.changeAnnotations = this._changeAnnotations.all(), r.documentChanges.forEach(function(t) {
      if (fe.is(t)) {
        var n = new ae(t.edits, i._changeAnnotations);
        i._textEditChanges[t.textDocument.uri] = n;
      }
    })) : r.changes && Object.keys(r.changes).forEach(function(t) {
      var n = new ae(r.changes[t]);
      i._textEditChanges[t] = n;
    })) : this._workspaceEdit = {};
  }
  return Object.defineProperty(e.prototype, "edit", {
    /**
     * Returns the underlying {@link WorkspaceEdit} literal
     * use to be returned from a workspace edit operation like rename.
     */
    get: function() {
      return this.initDocumentChanges(), this._changeAnnotations !== void 0 && (this._changeAnnotations.size === 0 ? this._workspaceEdit.changeAnnotations = void 0 : this._workspaceEdit.changeAnnotations = this._changeAnnotations.all()), this._workspaceEdit;
    },
    enumerable: !1,
    configurable: !0
  }), e.prototype.getTextEditChange = function(r) {
    if (le.is(r)) {
      if (this.initDocumentChanges(), this._workspaceEdit.documentChanges === void 0)
        throw new Error("Workspace edit is not configured for document changes.");
      var i = { uri: r.uri, version: r.version }, t = this._textEditChanges[i.uri];
      if (!t) {
        var n = [], a = {
          textDocument: i,
          edits: n
        };
        this._workspaceEdit.documentChanges.push(a), t = new ae(n, this._changeAnnotations), this._textEditChanges[i.uri] = t;
      }
      return t;
    } else {
      if (this.initChanges(), this._workspaceEdit.changes === void 0)
        throw new Error("Workspace edit is not configured for normal text edit changes.");
      var t = this._textEditChanges[r];
      if (!t) {
        var n = [];
        this._workspaceEdit.changes[r] = n, t = new ae(n), this._textEditChanges[r] = t;
      }
      return t;
    }
  }, e.prototype.initDocumentChanges = function() {
    this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0 && (this._changeAnnotations = new ln(), this._workspaceEdit.documentChanges = [], this._workspaceEdit.changeAnnotations = this._changeAnnotations.all());
  }, e.prototype.initChanges = function() {
    this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0 && (this._workspaceEdit.changes = /* @__PURE__ */ Object.create(null));
  }, e.prototype.createFile = function(r, i, t) {
    if (this.initDocumentChanges(), this._workspaceEdit.documentChanges === void 0)
      throw new Error("Workspace edit is not configured for document changes.");
    var n;
    J.is(i) || C.is(i) ? n = i : t = i;
    var a, s;
    if (n === void 0 ? a = H.create(r, t) : (s = C.is(n) ? n : this._changeAnnotations.manage(n), a = H.create(r, t, s)), this._workspaceEdit.documentChanges.push(a), s !== void 0)
      return s;
  }, e.prototype.renameFile = function(r, i, t, n) {
    if (this.initDocumentChanges(), this._workspaceEdit.documentChanges === void 0)
      throw new Error("Workspace edit is not configured for document changes.");
    var a;
    J.is(t) || C.is(t) ? a = t : n = t;
    var s, c;
    if (a === void 0 ? s = z.create(r, i, n) : (c = C.is(a) ? a : this._changeAnnotations.manage(a), s = z.create(r, i, n, c)), this._workspaceEdit.documentChanges.push(s), c !== void 0)
      return c;
  }, e.prototype.deleteFile = function(r, i, t) {
    if (this.initDocumentChanges(), this._workspaceEdit.documentChanges === void 0)
      throw new Error("Workspace edit is not configured for document changes.");
    var n;
    J.is(i) || C.is(i) ? n = i : t = i;
    var a, s;
    if (n === void 0 ? a = Z.create(r, t) : (s = C.is(n) ? n : this._changeAnnotations.manage(n), a = Z.create(r, t, s)), this._workspaceEdit.documentChanges.push(a), s !== void 0)
      return s;
  }, e;
})();
var gn;
(function(e) {
  function r(t) {
    return { uri: t };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.string(n.uri);
  }
  e.is = i;
})(gn || (gn = {}));
var pn;
(function(e) {
  function r(t, n) {
    return { uri: t, version: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.string(n.uri) && o.integer(n.version);
  }
  e.is = i;
})(pn || (pn = {}));
var le;
(function(e) {
  function r(t, n) {
    return { uri: t, version: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.string(n.uri) && (n.version === null || o.integer(n.version));
  }
  e.is = i;
})(le || (le = {}));
var vn;
(function(e) {
  function r(t, n, a, s) {
    return { uri: t, languageId: n, version: a, text: s };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.string(n.uri) && o.string(n.languageId) && o.integer(n.version) && o.string(n.text);
  }
  e.is = i;
})(vn || (vn = {}));
var Oe;
(function(e) {
  e.PlainText = "plaintext", e.Markdown = "markdown";
  function r(i) {
    var t = i;
    return t === e.PlainText || t === e.Markdown;
  }
  e.is = r;
})(Oe || (Oe = {}));
var K;
(function(e) {
  function r(i) {
    var t = i;
    return o.objectLiteral(i) && Oe.is(t.kind) && o.string(t.value);
  }
  e.is = r;
})(K || (K = {}));
var En;
(function(e) {
  e.Text = 1, e.Method = 2, e.Function = 3, e.Constructor = 4, e.Field = 5, e.Variable = 6, e.Class = 7, e.Interface = 8, e.Module = 9, e.Property = 10, e.Unit = 11, e.Value = 12, e.Enum = 13, e.Keyword = 14, e.Snippet = 15, e.Color = 16, e.File = 17, e.Reference = 18, e.Folder = 19, e.EnumMember = 20, e.Constant = 21, e.Struct = 22, e.Event = 23, e.Operator = 24, e.TypeParameter = 25;
})(En || (En = {}));
var hn;
(function(e) {
  e.PlainText = 1, e.Snippet = 2;
})(hn || (hn = {}));
var mn;
(function(e) {
  e.Deprecated = 1;
})(mn || (mn = {}));
var Tn;
(function(e) {
  function r(t, n, a) {
    return { newText: t, insert: n, replace: a };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && o.string(n.newText) && F.is(n.insert) && F.is(n.replace);
  }
  e.is = i;
})(Tn || (Tn = {}));
var Nn;
(function(e) {
  e.asIs = 1, e.adjustIndentation = 2;
})(Nn || (Nn = {}));
var In;
(function(e) {
  function r(i) {
    var t = i;
    return t && (o.string(t.detail) || t.detail === void 0) && (o.string(t.description) || t.description === void 0);
  }
  e.is = r;
})(In || (In = {}));
var _n;
(function(e) {
  function r(i) {
    return { label: i };
  }
  e.create = r;
})(_n || (_n = {}));
var yn;
(function(e) {
  function r(i, t) {
    return { items: i || [], isIncomplete: !!t };
  }
  e.create = r;
})(yn || (yn = {}));
var ge;
(function(e) {
  function r(t) {
    return t.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
  }
  e.fromPlainText = r;
  function i(t) {
    var n = t;
    return o.string(n) || o.objectLiteral(n) && o.string(n.language) && o.string(n.value);
  }
  e.is = i;
})(ge || (ge = {}));
var Dn;
(function(e) {
  function r(i) {
    var t = i;
    return !!t && o.objectLiteral(t) && (K.is(t.contents) || ge.is(t.contents) || o.typedArray(t.contents, ge.is)) && (i.range === void 0 || F.is(i.range));
  }
  e.is = r;
})(Dn || (Dn = {}));
var On;
(function(e) {
  function r(i, t) {
    return t ? { label: i, documentation: t } : { label: i };
  }
  e.create = r;
})(On || (On = {}));
var bn;
(function(e) {
  function r(i, t) {
    for (var n = [], a = 2; a < arguments.length; a++)
      n[a - 2] = arguments[a];
    var s = { label: i };
    return o.defined(t) && (s.documentation = t), o.defined(n) ? s.parameters = n : s.parameters = [], s;
  }
  e.create = r;
})(bn || (bn = {}));
var Sn;
(function(e) {
  e.Text = 1, e.Read = 2, e.Write = 3;
})(Sn || (Sn = {}));
var An;
(function(e) {
  function r(i, t) {
    var n = { range: i };
    return o.number(t) && (n.kind = t), n;
  }
  e.create = r;
})(An || (An = {}));
var wn;
(function(e) {
  e.File = 1, e.Module = 2, e.Namespace = 3, e.Package = 4, e.Class = 5, e.Method = 6, e.Property = 7, e.Field = 8, e.Constructor = 9, e.Enum = 10, e.Interface = 11, e.Function = 12, e.Variable = 13, e.Constant = 14, e.String = 15, e.Number = 16, e.Boolean = 17, e.Array = 18, e.Object = 19, e.Key = 20, e.Null = 21, e.EnumMember = 22, e.Struct = 23, e.Event = 24, e.Operator = 25, e.TypeParameter = 26;
})(wn || (wn = {}));
var Fn;
(function(e) {
  e.Deprecated = 1;
})(Fn || (Fn = {}));
var xn;
(function(e) {
  function r(i, t, n, a, s) {
    var c = {
      name: i,
      kind: t,
      location: { uri: a, range: n }
    };
    return s && (c.containerName = s), c;
  }
  e.create = r;
})(xn || (xn = {}));
var Ln;
(function(e) {
  function r(i, t, n, a) {
    return a !== void 0 ? { name: i, kind: t, location: { uri: n, range: a } } : { name: i, kind: t, location: { uri: n } };
  }
  e.create = r;
})(Ln || (Ln = {}));
var Pn;
(function(e) {
  function r(t, n, a, s, c, d) {
    var l = {
      name: t,
      detail: n,
      kind: a,
      range: s,
      selectionRange: c
    };
    return d !== void 0 && (l.children = d), l;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && o.string(n.name) && o.number(n.kind) && F.is(n.range) && F.is(n.selectionRange) && (n.detail === void 0 || o.string(n.detail)) && (n.deprecated === void 0 || o.boolean(n.deprecated)) && (n.children === void 0 || Array.isArray(n.children)) && (n.tags === void 0 || Array.isArray(n.tags));
  }
  e.is = i;
})(Pn || (Pn = {}));
var Cn;
(function(e) {
  e.Empty = "", e.QuickFix = "quickfix", e.Refactor = "refactor", e.RefactorExtract = "refactor.extract", e.RefactorInline = "refactor.inline", e.RefactorRewrite = "refactor.rewrite", e.Source = "source", e.SourceOrganizeImports = "source.organizeImports", e.SourceFixAll = "source.fixAll";
})(Cn || (Cn = {}));
var pe;
(function(e) {
  e.Invoked = 1, e.Automatic = 2;
})(pe || (pe = {}));
var Mn;
(function(e) {
  function r(t, n, a) {
    var s = { diagnostics: t };
    return n != null && (s.only = n), a != null && (s.triggerKind = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.typedArray(n.diagnostics, de.is) && (n.only === void 0 || o.typedArray(n.only, o.string)) && (n.triggerKind === void 0 || n.triggerKind === pe.Invoked || n.triggerKind === pe.Automatic);
  }
  e.is = i;
})(Mn || (Mn = {}));
var Un;
(function(e) {
  function r(t, n, a) {
    var s = { title: t }, c = !0;
    return typeof n == "string" ? (c = !1, s.kind = n) : Q.is(n) ? s.command = n : s.edit = n, c && a !== void 0 && (s.kind = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n && o.string(n.title) && (n.diagnostics === void 0 || o.typedArray(n.diagnostics, de.is)) && (n.kind === void 0 || o.string(n.kind)) && (n.edit !== void 0 || n.command !== void 0) && (n.command === void 0 || Q.is(n.command)) && (n.isPreferred === void 0 || o.boolean(n.isPreferred)) && (n.edit === void 0 || De.is(n.edit));
  }
  e.is = i;
})(Un || (Un = {}));
var kn;
(function(e) {
  function r(t, n) {
    var a = { range: t };
    return o.defined(n) && (a.data = n), a;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && F.is(n.range) && (o.undefined(n.command) || Q.is(n.command));
  }
  e.is = i;
})(kn || (kn = {}));
var Rn;
(function(e) {
  function r(t, n) {
    return { tabSize: t, insertSpaces: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && o.uinteger(n.tabSize) && o.boolean(n.insertSpaces);
  }
  e.is = i;
})(Rn || (Rn = {}));
var jn;
(function(e) {
  function r(t, n, a) {
    return { range: t, target: n, data: a };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && F.is(n.range) && (o.undefined(n.target) || o.string(n.target));
  }
  e.is = i;
})(jn || (jn = {}));
var Vn;
(function(e) {
  function r(t, n) {
    return { range: t, parent: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && F.is(n.range) && (n.parent === void 0 || e.is(n.parent));
  }
  e.is = i;
})(Vn || (Vn = {}));
var Yn;
(function(e) {
  e.namespace = "namespace", e.type = "type", e.class = "class", e.enum = "enum", e.interface = "interface", e.struct = "struct", e.typeParameter = "typeParameter", e.parameter = "parameter", e.variable = "variable", e.property = "property", e.enumMember = "enumMember", e.event = "event", e.function = "function", e.method = "method", e.macro = "macro", e.keyword = "keyword", e.modifier = "modifier", e.comment = "comment", e.string = "string", e.number = "number", e.regexp = "regexp", e.operator = "operator", e.decorator = "decorator";
})(Yn || (Yn = {}));
var Xn;
(function(e) {
  e.declaration = "declaration", e.definition = "definition", e.readonly = "readonly", e.static = "static", e.deprecated = "deprecated", e.abstract = "abstract", e.async = "async", e.modification = "modification", e.documentation = "documentation", e.defaultLibrary = "defaultLibrary";
})(Xn || (Xn = {}));
var Bn;
(function(e) {
  function r(i) {
    var t = i;
    return o.objectLiteral(t) && (t.resultId === void 0 || typeof t.resultId == "string") && Array.isArray(t.data) && (t.data.length === 0 || typeof t.data[0] == "number");
  }
  e.is = r;
})(Bn || (Bn = {}));
var $n;
(function(e) {
  function r(t, n) {
    return { range: t, text: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n != null && F.is(n.range) && o.string(n.text);
  }
  e.is = i;
})($n || ($n = {}));
var qn;
(function(e) {
  function r(t, n, a) {
    return { range: t, variableName: n, caseSensitiveLookup: a };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n != null && F.is(n.range) && o.boolean(n.caseSensitiveLookup) && (o.string(n.variableName) || n.variableName === void 0);
  }
  e.is = i;
})(qn || (qn = {}));
var Jn;
(function(e) {
  function r(t, n) {
    return { range: t, expression: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return n != null && F.is(n.range) && (o.string(n.expression) || n.expression === void 0);
  }
  e.is = i;
})(Jn || (Jn = {}));
var Qn;
(function(e) {
  function r(t, n) {
    return { frameId: t, stoppedLocation: n };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.defined(n) && F.is(t.stoppedLocation);
  }
  e.is = i;
})(Qn || (Qn = {}));
var be;
(function(e) {
  e.Type = 1, e.Parameter = 2;
  function r(i) {
    return i === 1 || i === 2;
  }
  e.is = r;
})(be || (be = {}));
var Se;
(function(e) {
  function r(t) {
    return { value: t };
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && (n.tooltip === void 0 || o.string(n.tooltip) || K.is(n.tooltip)) && (n.location === void 0 || ue.is(n.location)) && (n.command === void 0 || Q.is(n.command));
  }
  e.is = i;
})(Se || (Se = {}));
var Gn;
(function(e) {
  function r(t, n, a) {
    var s = { position: t, label: n };
    return a !== void 0 && (s.kind = a), s;
  }
  e.create = r;
  function i(t) {
    var n = t;
    return o.objectLiteral(n) && k.is(n.position) && (o.string(n.label) || o.typedArray(n.label, Se.is)) && (n.kind === void 0 || be.is(n.kind)) && n.textEdits === void 0 || o.typedArray(n.textEdits, V.is) && (n.tooltip === void 0 || o.string(n.tooltip) || K.is(n.tooltip)) && (n.paddingLeft === void 0 || o.boolean(n.paddingLeft)) && (n.paddingRight === void 0 || o.boolean(n.paddingRight));
  }
  e.is = i;
})(Gn || (Gn = {}));
var Wn;
(function(e) {
  function r(i) {
    var t = i;
    return o.objectLiteral(t) && Ie.is(t.uri) && o.string(t.name);
  }
  e.is = r;
})(Wn || (Wn = {}));
var Hn;
(function(e) {
  function r(a, s, c, d) {
    return new gr(a, s, c, d);
  }
  e.create = r;
  function i(a) {
    var s = a;
    return !!(o.defined(s) && o.string(s.uri) && (o.undefined(s.languageId) || o.string(s.languageId)) && o.uinteger(s.lineCount) && o.func(s.getText) && o.func(s.positionAt) && o.func(s.offsetAt));
  }
  e.is = i;
  function t(a, s) {
    for (var c = a.getText(), d = n(s, function(A, M) {
      var R = A.range.start.line - M.range.start.line;
      return R === 0 ? A.range.start.character - M.range.start.character : R;
    }), l = c.length, g = d.length - 1; g >= 0; g--) {
      var h = d[g], T = a.offsetAt(h.range.start), m = a.offsetAt(h.range.end);
      if (m <= l)
        c = c.substring(0, T) + h.newText + c.substring(m, c.length);
      else
        throw new Error("Overlapping edit");
      l = T;
    }
    return c;
  }
  e.applyEdits = t;
  function n(a, s) {
    if (a.length <= 1)
      return a;
    var c = a.length / 2 | 0, d = a.slice(0, c), l = a.slice(c);
    n(d, s), n(l, s);
    for (var g = 0, h = 0, T = 0; g < d.length && h < l.length; ) {
      var m = s(d[g], l[h]);
      m <= 0 ? a[T++] = d[g++] : a[T++] = l[h++];
    }
    for (; g < d.length; )
      a[T++] = d[g++];
    for (; h < l.length; )
      a[T++] = l[h++];
    return a;
  }
})(Hn || (Hn = {}));
var gr = (
  /** @class */
  function() {
    function e(r, i, t, n) {
      this._uri = r, this._languageId = i, this._version = t, this._content = n, this._lineOffsets = void 0;
    }
    return Object.defineProperty(e.prototype, "uri", {
      get: function() {
        return this._uri;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e.prototype, "languageId", {
      get: function() {
        return this._languageId;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e.prototype, "version", {
      get: function() {
        return this._version;
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.getText = function(r) {
      if (r) {
        var i = this.offsetAt(r.start), t = this.offsetAt(r.end);
        return this._content.substring(i, t);
      }
      return this._content;
    }, e.prototype.update = function(r, i) {
      this._content = r.text, this._version = i, this._lineOffsets = void 0;
    }, e.prototype.getLineOffsets = function() {
      if (this._lineOffsets === void 0) {
        for (var r = [], i = this._content, t = !0, n = 0; n < i.length; n++) {
          t && (r.push(n), t = !1);
          var a = i.charAt(n);
          t = a === "\r" || a === `
`, a === "\r" && n + 1 < i.length && i.charAt(n + 1) === `
` && n++;
        }
        t && i.length > 0 && r.push(i.length), this._lineOffsets = r;
      }
      return this._lineOffsets;
    }, e.prototype.positionAt = function(r) {
      r = Math.max(Math.min(r, this._content.length), 0);
      var i = this.getLineOffsets(), t = 0, n = i.length;
      if (n === 0)
        return k.create(0, r);
      for (; t < n; ) {
        var a = Math.floor((t + n) / 2);
        i[a] > r ? n = a : t = a + 1;
      }
      var s = t - 1;
      return k.create(s, r - i[s]);
    }, e.prototype.offsetAt = function(r) {
      var i = this.getLineOffsets();
      if (r.line >= i.length)
        return this._content.length;
      if (r.line < 0)
        return 0;
      var t = i[r.line], n = r.line + 1 < i.length ? i[r.line + 1] : this._content.length;
      return Math.max(Math.min(t + r.character, n), t);
    }, Object.defineProperty(e.prototype, "lineCount", {
      get: function() {
        return this.getLineOffsets().length;
      },
      enumerable: !1,
      configurable: !0
    }), e;
  }()
), o;
(function(e) {
  var r = Object.prototype.toString;
  function i(m) {
    return typeof m < "u";
  }
  e.defined = i;
  function t(m) {
    return typeof m > "u";
  }
  e.undefined = t;
  function n(m) {
    return m === !0 || m === !1;
  }
  e.boolean = n;
  function a(m) {
    return r.call(m) === "[object String]";
  }
  e.string = a;
  function s(m) {
    return r.call(m) === "[object Number]";
  }
  e.number = s;
  function c(m, A, M) {
    return r.call(m) === "[object Number]" && A <= m && m <= M;
  }
  e.numberRange = c;
  function d(m) {
    return r.call(m) === "[object Number]" && -2147483648 <= m && m <= 2147483647;
  }
  e.integer = d;
  function l(m) {
    return r.call(m) === "[object Number]" && 0 <= m && m <= 2147483647;
  }
  e.uinteger = l;
  function g(m) {
    return r.call(m) === "[object Function]";
  }
  e.func = g;
  function h(m) {
    return m !== null && typeof m == "object";
  }
  e.objectLiteral = h;
  function T(m, A) {
    return Array.isArray(m) && m.every(A);
  }
  e.typedArray = T;
})(o || (o = {}));
var _;
(function(e) {
  e.Text = 1, e.Method = 2, e.Function = 3, e.Constructor = 4, e.Field = 5, e.Variable = 6, e.Class = 7, e.Interface = 8, e.Module = 9, e.Property = 10, e.Unit = 11, e.Value = 12, e.Enum = 13, e.Keyword = 14, e.Snippet = 15, e.Color = 16, e.File = 17, e.Reference = 18, e.Folder = 19, e.EnumMember = 20, e.Constant = 21, e.Struct = 22, e.Event = 23, e.Operator = 24, e.TypeParameter = 25;
})(_ || (_ = {}));
function w(e) {
  return { ofRule: e };
}
function I(e, r) {
  return { ofRule: e, isList: !0, separator: r };
}
function pr(e, r) {
  const i = e.match;
  return e.match = (t) => {
    let n = !1;
    return i && (n = i(t)), n && r.every((a) => a.match && !a.match(t));
  }, e;
}
function Te(e, r) {
  return { style: r, match: (i) => i.kind === e };
}
function N(e, r) {
  return {
    style: r || "punctuation",
    match: (i) => i.kind === "Punctuation" && i.value === e
  };
}
I("Definition"), P("query"), w(D("def")), w("VariableDefinitions"), I("Directive"), P("mutation"), w(D("def")), w("VariableDefinitions"), I("Directive"), P("subscription"), w(D("def")), w("VariableDefinitions"), I("Directive"), N("("), I("VariableDefinition"), N(")"), N(":"), w("DefaultValue"), N("$", "variable"), D("variable"), N("="), N("{"), I("Selection"), N("}"), D("property"), N(":"), D("qualifier"), w("Arguments"), I("Directive"), w("SelectionSet"), D("property"), w("Arguments"), I("Directive"), w("SelectionSet"), N("("), I("Argument"), N(")"), D("attribute"), N(":"), N("..."), D("def"), I("Directive"), N("..."), w("TypeCondition"), I("Directive"), P("fragment"), w(pr(D("def"), [P("on")])), I("Directive"), P("on"), Te("Number", "number"), Te("Name", "builtin"), Te("Name", "keyword"), D("string-2"), N("["), I("Value"), N("]"), N("{"), I("ObjectField"), N("}"), D("attribute"), N(":"), N("["), N("]"), w(N("!")), w(N("!")), vr("atom"), N("@", "meta"), D("meta"), w("Arguments"), P("directive"), N("@", "meta"), D("meta"), w("ArgumentsDef"), P("on"), I("DirectiveLocation", N("|")), P("interface"), D("atom"), w("Implements"), I("Directive"), N("{"), I("FieldDef"), N("}"), P("implements"), I("NamedType", N("&")), D("string-2"), P("schema"), I("Directive"), N("{"), I("OperationTypeDef"), N("}"), D("keyword"), N(":"), D("atom"), P("scalar"), D("atom"), I("Directive"), P("type"), D("atom"), w("Implements"), I("Directive"), N("{"), I("FieldDef"), N("}"), D("property"), w("ArgumentsDef"), N(":"), I("Directive"), N("("), I("InputValueDef"), N(")"), D("attribute"), N(":"), w("DefaultValue"), I("Directive"), P("union"), D("atom"), I("Directive"), N("="), I("UnionMember", N("|")), P("enum"), D("atom"), I("Directive"), N("{"), I("EnumValueDef"), N("}"), D("string-2"), I("Directive"), P("input"), D("atom"), I("Directive"), N("{"), I("InputValueDef"), N("}"), P("extend"), f.SCHEMA_EXTENSION + "", f.SCALAR_TYPE_EXTENSION + "", f.OBJECT_TYPE_EXTENSION + "", f.INTERFACE_TYPE_EXTENSION + "", f.UNION_TYPE_EXTENSION + "", f.ENUM_TYPE_EXTENSION + "", f.INPUT_OBJECT_TYPE_EXTENSION + "";
function P(e) {
  return {
    style: "keyword",
    match: (r) => r.kind === "Name" && r.value === e
  };
}
function D(e) {
  return {
    style: e,
    match: (r) => r.kind === "Name",
    update(r, i) {
      r.name = i.value;
    }
  };
}
function vr(e) {
  return {
    style: e,
    match: (r) => r.kind === "Name",
    update(r, i) {
      var t;
      !((t = r.prevState) === null || t === void 0) && t.prevState && (r.name = i.value, r.prevState.prevState.type = i.value);
    }
  };
}
const Er = {
  ALIASED_FIELD: "AliasedField",
  ARGUMENTS: "Arguments",
  SHORT_QUERY: "ShortQuery",
  QUERY: "Query",
  MUTATION: "Mutation",
  SUBSCRIPTION: "Subscription",
  TYPE_CONDITION: "TypeCondition",
  INVALID: "Invalid",
  COMMENT: "Comment",
  SCHEMA_DEF: "SchemaDef",
  SCALAR_DEF: "ScalarDef",
  OBJECT_TYPE_DEF: "ObjectTypeDef",
  OBJECT_VALUE: "ObjectValue",
  LIST_VALUE: "ListValue",
  INTERFACE_DEF: "InterfaceDef",
  UNION_DEF: "UnionDef",
  ENUM_DEF: "EnumDef",
  ENUM_VALUE: "EnumValue",
  FIELD_DEF: "FieldDef",
  INPUT_DEF: "InputDef",
  INPUT_VALUE_DEF: "InputValueDef",
  ARGUMENTS_DEF: "ArgumentsDef",
  EXTEND_DEF: "ExtendDef",
  EXTENSION_DEFINITION: "ExtensionDefinition",
  DIRECTIVE_DEF: "DirectiveDef",
  IMPLEMENTS: "Implements",
  VARIABLE_DEFINITIONS: "VariableDefinitions",
  TYPE: "Type"
};
Object.assign(Object.assign({}, f), Er);
f.SCHEMA_DEFINITION, f.OPERATION_TYPE_DEFINITION, f.SCALAR_TYPE_DEFINITION, f.OBJECT_TYPE_DEFINITION, f.INTERFACE_TYPE_DEFINITION, f.UNION_TYPE_DEFINITION, f.ENUM_TYPE_DEFINITION, f.INPUT_OBJECT_TYPE_DEFINITION, f.DIRECTIVE_DEFINITION, f.SCHEMA_EXTENSION, f.SCALAR_TYPE_EXTENSION, f.OBJECT_TYPE_EXTENSION, f.INTERFACE_TYPE_EXTENSION, f.UNION_TYPE_EXTENSION, f.ENUM_TYPE_EXTENSION, f.INPUT_OBJECT_TYPE_EXTENSION;
var zn;
(function(e) {
  e.TYPE_SYSTEM = "TYPE_SYSTEM", e.EXECUTABLE = "EXECUTABLE";
})(zn || (zn = {}));
var Ce = { exports: {} };
function ut(e, r) {
  if (e != null)
    return e;
  var i = new Error(r !== void 0 ? r : "Got unexpected " + e);
  throw i.framesToPop = 1, i;
}
Ce.exports = ut;
Ce.exports.default = ut;
Object.defineProperty(Ce.exports, "__esModule", { value: !0 });
globalThis && globalThis.__awaiter;
const Zn = (e) => "getModeId" in e ? e.getModeId() : e.getLanguageId(), hr = (e) => {
  const { schema: r, documentAST: i, introspectionJSON: t, introspectionJSONString: n, documentString: a, ...s } = e;
  if (r)
    return {
      ...s,
      documentString: ze(r)
    };
  if (n)
    return {
      ...s,
      introspectionJSONString: n
    };
  if (a)
    return {
      ...s,
      documentString: a
    };
  if (t)
    return {
      ...s,
      introspectionJSONString: JSON.stringify(t)
    };
  if (i) {
    const c = lr(i, s.buildSchemaOptions);
    return {
      ...s,
      documentString: ze(c)
    };
  }
  throw new Error("no schema supplied");
}, mr = 2 * 60 * 1e3;
class Tr {
  _defaults;
  _idleCheckInterval;
  _lastUsedTime = 0;
  _configChangeListener;
  _worker = null;
  _client = null;
  constructor(r) {
    this._defaults = r, this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3), this._configChangeListener = this._defaults.onDidChange(() => {
      this._stopWorker();
    });
  }
  _stopWorker() {
    this._worker && (this._worker.dispose(), this._worker = null), this._client = null;
  }
  dispose() {
    clearInterval(this._idleCheckInterval), this._configChangeListener.dispose(), this._stopWorker();
  }
  _checkIfIdle() {
    if (!this._worker)
      return;
    Date.now() - this._lastUsedTime > mr && this._stopWorker();
  }
  async _getClient() {
    if (this._lastUsedTime = Date.now(), !this._client && !this._worker)
      try {
        this._worker = j.createWebWorker({
          moduleId: "monaco-graphql/esm/GraphQLWorker.js",
          label: this._defaults.languageId,
          createData: {
            languageId: this._defaults.languageId,
            formattingOptions: this._defaults.formattingOptions,
            languageConfig: {
              schemas: this._defaults.schemas?.map(hr),
              externalFragmentDefinitions: this._defaults.externalFragmentDefinitions,
              fillLeafsOnComplete: this._defaults.completionSettings.__experimental__fillLeafsOnComplete
            }
          }
        }), this._client = await this._worker.getProxy();
      } catch (r) {
        console.error("error loading worker", r);
      }
    return this._client;
  }
  async getLanguageServiceWorker(...r) {
    const i = await this._getClient();
    return await this._worker.withSyncedResources(r), i;
  }
}
class Nr {
  defaults;
  _worker;
  _disposables = [];
  _listener = /* @__PURE__ */ Object.create(null);
  constructor(r, i) {
    this.defaults = r, this._worker = i, this._worker = i;
    let t;
    const n = (s) => {
      const c = Zn(s);
      if (c !== this.defaults.languageId)
        return;
      const d = s.uri.toString(), l = r.diagnosticSettings?.validateVariablesJSON && r.diagnosticSettings.validateVariablesJSON[d];
      this._listener[d] = s.onDidChangeContent(() => {
        clearTimeout(t), t = setTimeout(() => {
          this._doValidate(s.uri, c, l);
        }, 200);
      });
    }, a = (s) => {
      j.setModelMarkers(s, this.defaults.languageId, []);
      const c = s.uri.toString(), d = this._listener[c];
      d && (d.dispose(), delete this._listener[c]);
    };
    this._disposables.push(j.onDidCreateModel(n), {
      dispose() {
        clearTimeout(t);
      }
    }, j.onWillDisposeModel((s) => {
      a(s);
    }), j.onDidChangeModelLanguage((s) => {
      a(s.model), n(s.model);
    }), {
      dispose: () => {
        for (const s in this._listener)
          this._listener[s].dispose();
      }
    }, r.onDidChange(() => {
      for (const s of j.getModels())
        Zn(s) === this.defaults.languageId && (a(s), n(s));
    }));
    for (const s of j.getModels())
      n(s);
  }
  dispose() {
    for (const r of this._disposables)
      r?.dispose();
    this._disposables = [];
  }
  async _doValidate(r, i, t) {
    const n = await this._worker(r);
    if (!n)
      return;
    const a = await n.doValidation(r.toString());
    if (j.setModelMarkers(j.getModel(r), i, a), t) {
      if (t.length < 1)
        throw new Error("no variables URI strings provided to validate");
      const s = await n.doGetVariablesJSONSchema(r.toString());
      if (!s)
        return;
      const d = {
        uri: Ct.file(t[0].replace(".json", "-schema.json")).toString(),
        schema: s,
        fileMatch: t
      };
      q.json.jsonDefaults.setDiagnosticsOptions({
        schemaValidation: "error",
        validate: !0,
        ...this.defaults?.diagnosticSettings?.jsonDiagnosticSettings,
        schemas: [d],
        enableSchemaRequest: !1
      });
    }
  }
}
const O = q.CompletionItemKind, Kn = {
  [_.Text]: O.Text,
  [_.Method]: O.Method,
  [_.Function]: O.Function,
  [_.Constructor]: O.Constructor,
  [_.Field]: O.Field,
  [_.Variable]: O.Variable,
  [_.Class]: O.Class,
  [_.Interface]: O.Interface,
  [_.Module]: O.Module,
  [_.Property]: O.Property,
  [_.Unit]: O.Unit,
  [_.Value]: O.Value,
  [_.Enum]: O.Enum,
  [_.Keyword]: O.Keyword,
  [_.Snippet]: O.Snippet,
  [_.Color]: O.Color,
  [_.File]: O.File,
  [_.Reference]: O.Reference,
  [_.Folder]: O.Folder,
  [_.EnumMember]: O.EnumMember,
  [_.Constant]: O.Constant,
  [_.Struct]: O.Struct,
  [_.Event]: O.Event,
  [_.Operator]: O.Operator,
  [_.TypeParameter]: O.TypeParameter
};
function Ir(e) {
  return e in Kn ? Kn[e] : O.Text;
}
function _r(e) {
  return {
    range: e.range,
    kind: Ir(e.kind),
    label: e.label,
    insertText: e.insertText ?? e.label,
    insertTextRules: e.insertText ? q.CompletionItemInsertTextRule.InsertAsSnippet : void 0,
    sortText: e.sortText,
    filterText: e.filterText,
    documentation: e.documentation,
    detail: e.detail,
    command: e.command
  };
}
class yr {
  _worker;
  constructor(r) {
    this._worker = r, this._worker = r;
  }
  get triggerCharacters() {
    return [":", "$", " ", "(", "@"];
  }
  async provideCompletionItems(r, i, t, n) {
    try {
      const a = r.uri;
      return {
        incomplete: !0,
        suggestions: (await (await this._worker(r.uri)).doComplete(a.toString(), i)).map(_r)
      };
    } catch (a) {
      return console.error("Error fetching completion items", a), { suggestions: [] };
    }
  }
}
class Dr {
  _worker;
  constructor(r) {
    this._worker = r, this._worker = r;
  }
  async provideDocumentFormattingEdits(r, i, t) {
    const a = await (await this._worker(r.uri)).doFormat(r.uri.toString());
    return a ? [
      {
        range: r.getFullModelRange(),
        text: a
      }
    ] : [];
  }
}
class Or {
  _worker;
  constructor(r) {
    this._worker = r;
  }
  async provideHover(r, i, t) {
    const n = r.uri, s = await (await this._worker(r.uri)).doHover(n.toString(), i);
    return s ? {
      range: s.range,
      contents: [{ value: s.content }]
    } : {
      contents: []
    };
  }
  dispose() {
  }
}
function wr(e) {
  const r = [], i = [], t = new Tr(e);
  r.push(t);
  const n = (...T) => {
    try {
      return t.getLanguageServiceWorker(...T);
    } catch {
      throw new Error("Error fetching graphql language service worker");
    }
  };
  function a() {
    const { modeConfiguration: T, languageId: m } = e;
    T.documentFormattingEdits && i.push(q.registerDocumentFormattingEditProvider(m, new Dr(n)));
  }
  function s(T) {
    const { modeConfiguration: m, languageId: A } = e;
    dt(i), m.completionItems && i.push(q.registerCompletionItemProvider(A, new yr(n))), m.diagnostics && i.push(new Nr(T, n)), m.hovers && i.push(q.registerHoverProvider(A, new Or(n))), a();
  }
  let { modeConfiguration: c, formattingOptions: d, diagnosticSettings: l, externalFragmentDefinitions: g, schemas: h } = e;
  return s(e), e.onDidChange((T) => {
    T.modeConfiguration !== c && (c = T.modeConfiguration, s(T)), T.formattingOptions !== d && (d = T.formattingOptions, a()), T.externalFragmentDefinitions !== g && (g = T.externalFragmentDefinitions, s(T)), T.diagnosticSettings !== l && (l = T.diagnosticSettings, s(T)), T.schemas !== h && (h = T.schemas, s(T));
  }), r.push(et(i)), et(r);
}
function et(e) {
  return { dispose: () => dt(e) };
}
function dt(e) {
  for (; e.length; )
    e.pop().dispose();
}
export {
  wr as setupMode
};
