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,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e) => e ? parseInt(e, 36) : 1);
  for (let e = 0, t = 0; e < r.length; e++)
    (e % 2 ? qu : gl).push(t = t + r[e]);
})();
function kg(r) {
  if (r < 768) return !1;
  for (let e = 0, t = gl.length; ; ) {
    let i = e + t >> 1;
    if (r < gl[i]) t = i;
    else if (r >= qu[i]) e = i + 1;
    else return !0;
    if (e == t) return !1;
  }
}
function _h(r) {
  return r >= 127462 && r <= 127487;
}
const Bh = 8205;
function Qg(r, e, t = !0, i = !0) {
  return (t ? Yu : vg)(r, e, i);
}
function Yu(r, e, t) {
  if (e == r.length) return e;
  e && Nu(r.charCodeAt(e)) && Wu(r.charCodeAt(e - 1)) && e--;
  let i = So(r, e);
  for (e += Ih(i); e < r.length; ) {
    let n = So(r, e);
    if (i == Bh || n == Bh || t && kg(n))
      e += Ih(n), i = n;
    else if (_h(n)) {
      let s = 0, o = e - 2;
      for (; o >= 0 && _h(So(r, o)); )
        s++, o -= 2;
      if (s % 2 == 0) break;
      e += 2;
    } else
      break;
  }
  return e;
}
function vg(r, e, t) {
  for (; e > 0; ) {
    let i = Yu(r, e - 2, t);
    if (i < e) return i;
    e--;
  }
  return 0;
}
function So(r, e) {
  let t = r.charCodeAt(e);
  if (!Wu(t) || e + 1 == r.length) return t;
  let i = r.charCodeAt(e + 1);
  return Nu(i) ? (t - 55296 << 10) + (i - 56320) + 65536 : t;
}
function Nu(r) {
  return r >= 56320 && r < 57344;
}
function Wu(r) {
  return r >= 55296 && r < 56320;
}
function Ih(r) {
  return r < 65536 ? 1 : 2;
}
class K {
  /**
  Get the line description around the given position.
  */
  lineAt(e) {
    if (e < 0 || e > this.length)
      throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);
    return this.lineInner(e, !1, 1, 0);
  }
  /**
  Get the description for the given (1-based) line number.
  */
  line(e) {
    if (e < 1 || e > this.lines)
      throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);
    return this.lineInner(e, !0, 1, 0);
  }
  /**
  Replace a range of the text with the given content.
  */
  replace(e, t, i) {
    [e, t] = Vi(this, e, t);
    let n = [];
    return this.decompose(
      0,
      e,
      n,
      2
      /* Open.To */
    ), i.length && i.decompose(
      0,
      i.length,
      n,
      3
      /* Open.To */
    ), this.decompose(
      t,
      this.length,
      n,
      1
      /* Open.From */
    ), St.from(n, this.length - (t - e) + i.length);
  }
  /**
  Append another document to this one.
  */
  append(e) {
    return this.replace(this.length, this.length, e);
  }
  /**
  Retrieve the text between the given points.
  */
  slice(e, t = this.length) {
    [e, t] = Vi(this, e, t);
    let i = [];
    return this.decompose(e, t, i, 0), St.from(i, t - e);
  }
  /**
  Test whether this text is equal to another instance.
  */
  eq(e) {
    if (e == this)
      return !0;
    if (e.length != this.length || e.lines != this.lines)
      return !1;
    let t = this.scanIdentical(e, 1), i = this.length - this.scanIdentical(e, -1), n = new Pr(this), s = new Pr(e);
    for (let o = t, l = t; ; ) {
      if (n.next(o), s.next(o), o = 0, n.lineBreak != s.lineBreak || n.done != s.done || n.value != s.value)
        return !1;
      if (l += n.value.length, n.done || l >= i)
        return !0;
    }
  }
  /**
  Iterate over the text. When `dir` is `-1`, iteration happens
  from end to start. This will return lines and the breaks between
  them as separate strings.
  */
  iter(e = 1) {
    return new Pr(this, e);
  }
  /**
  Iterate over a range of the text. When `from` > `to`, the
  iterator will run in reverse.
  */
  iterRange(e, t = this.length) {
    return new ju(this, e, t);
  }
  /**
  Return a cursor that iterates over the given range of lines,
  _without_ returning the line breaks between, and yielding empty
  strings for empty lines.
  
  When `from` and `to` are given, they should be 1-based line numbers.
  */
  iterLines(e, t) {
    let i;
    if (e == null)
      i = this.iter();
    else {
      t == null && (t = this.lines + 1);
      let n = this.line(e).from;
      i = this.iterRange(n, Math.max(n, t == this.lines + 1 ? this.length : t <= 1 ? 0 : this.line(t - 1).to));
    }
    return new Gu(i);
  }
  /**
  Return the document as a string, using newline characters to
  separate lines.
  */
  toString() {
    return this.sliceString(0);
  }
  /**
  Convert the document to an array of lines (which can be
  deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
  */
  toJSON() {
    let e = [];
    return this.flatten(e), e;
  }
  /**
  @internal
  */
  constructor() {
  }
  /**
  Create a `Text` instance for the given array of lines.
  */
  static of(e) {
    if (e.length == 0)
      throw new RangeError("A document must have at least one line");
    return e.length == 1 && !e[0] ? K.empty : e.length <= 32 ? new de(e) : St.from(de.split(e, []));
  }
}
class de extends K {
  constructor(e, t = $g(e)) {
    super(), this.text = e, this.length = t;
  }
  get lines() {
    return this.text.length;
  }
  get children() {
    return null;
  }
  lineInner(e, t, i, n) {
    for (let s = 0; ; s++) {
      let o = this.text[s], l = n + o.length;
      if ((t ? i : l) >= e)
        return new Pg(n, l, i, o);
      n = l + 1, i++;
    }
  }
  decompose(e, t, i, n) {
    let s = e <= 0 && t >= this.length ? this : new de(Vh(this.text, e, t), Math.min(t, this.length) - Math.max(0, e));
    if (n & 1) {
      let o = i.pop(), l = Fn(s.text, o.text.slice(), 0, s.length);
      if (l.length <= 32)
        i.push(new de(l, o.length + s.length));
      else {
        let a = l.length >> 1;
        i.push(new de(l.slice(0, a)), new de(l.slice(a)));
      }
    } else
      i.push(s);
  }
  replace(e, t, i) {
    if (!(i instanceof de))
      return super.replace(e, t, i);
    [e, t] = Vi(this, e, t);
    let n = Fn(this.text, Fn(i.text, Vh(this.text, 0, e)), t), s = this.length + i.length - (t - e);
    return n.length <= 32 ? new de(n, s) : St.from(de.split(n, []), s);
  }
  sliceString(e, t = this.length, i = `
`) {
    [e, t] = Vi(this, e, t);
    let n = "";
    for (let s = 0, o = 0; s <= t && o < this.text.length; o++) {
      let l = this.text[o], a = s + l.length;
      s > e && o && (n += i), e < a && t > s && (n += l.slice(Math.max(0, e - s), t - s)), s = a + 1;
    }
    return n;
  }
  flatten(e) {
    for (let t of this.text)
      e.push(t);
  }
  scanIdentical() {
    return 0;
  }
  static split(e, t) {
    let i = [], n = -1;
    for (let s of e)
      i.push(s), n += s.length + 1, i.length == 32 && (t.push(new de(i, n)), i = [], n = -1);
    return n > -1 && t.push(new de(i, n)), t;
  }
}
class St extends K {
  constructor(e, t) {
    super(), this.children = e, this.length = t, this.lines = 0;
    for (let i of e)
      this.lines += i.lines;
  }
  lineInner(e, t, i, n) {
    for (let s = 0; ; s++) {
      let o = this.children[s], l = n + o.length, a = i + o.lines - 1;
      if ((t ? a : l) >= e)
        return o.lineInner(e, t, i, n);
      n = l + 1, i = a + 1;
    }
  }
  decompose(e, t, i, n) {
    for (let s = 0, o = 0; o <= t && s < this.children.length; s++) {
      let l = this.children[s], a = o + l.length;
      if (e <= a && t >= o) {
        let h = n & ((o <= e ? 1 : 0) | (a >= t ? 2 : 0));
        o >= e && a <= t && !h ? i.push(l) : l.decompose(e - o, t - o, i, h);
      }
      o = a + 1;
    }
  }
  replace(e, t, i) {
    if ([e, t] = Vi(this, e, t), i.lines < this.lines)
      for (let n = 0, s = 0; n < this.children.length; n++) {
        let o = this.children[n], l = s + o.length;
        if (e >= s && t <= l) {
          let a = o.replace(e - s, t - s, i), h = this.lines - o.lines + a.lines;
          if (a.lines < h >> 4 && a.lines > h >> 6) {
            let c = this.children.slice();
            return c[n] = a, new St(c, this.length - (t - e) + i.length);
          }
          return super.replace(s, l, a);
        }
        s = l + 1;
      }
    return super.replace(e, t, i);
  }
  sliceString(e, t = this.length, i = `
`) {
    [e, t] = Vi(this, e, t);
    let n = "";
    for (let s = 0, o = 0; s < this.children.length && o <= t; s++) {
      let l = this.children[s], a = o + l.length;
      o > e && s && (n += i), e < a && t > o && (n += l.sliceString(e - o, t - o, i)), o = a + 1;
    }
    return n;
  }
  flatten(e) {
    for (let t of this.children)
      t.flatten(e);
  }
  scanIdentical(e, t) {
    if (!(e instanceof St))
      return 0;
    let i = 0, [n, s, o, l] = t > 0 ? [0, 0, this.children.length, e.children.length] : [this.children.length - 1, e.children.length - 1, -1, -1];
    for (; ; n += t, s += t) {
      if (n == o || s == l)
        return i;
      let a = this.children[n], h = e.children[s];
      if (a != h)
        return i + a.scanIdentical(h, t);
      i += a.length + 1;
    }
  }
  static from(e, t = e.reduce((i, n) => i + n.length + 1, -1)) {
    let i = 0;
    for (let d of e)
      i += d.lines;
    if (i < 32) {
      let d = [];
      for (let p of e)
        p.flatten(d);
      return new de(d, t);
    }
    let n = Math.max(
      32,
      i >> 5
      /* Tree.BranchShift */
    ), s = n << 1, o = n >> 1, l = [], a = 0, h = -1, c = [];
    function f(d) {
      let p;
      if (d.lines > s && d instanceof St)
        for (let O of d.children)
          f(O);
      else d.lines > o && (a > o || !a) ? (u(), l.push(d)) : d instanceof de && a && (p = c[c.length - 1]) instanceof de && d.lines + p.lines <= 32 ? (a += d.lines, h += d.length + 1, c[c.length - 1] = new de(p.text.concat(d.text), p.length + 1 + d.length)) : (a + d.lines > n && u(), a += d.lines, h += d.length + 1, c.push(d));
    }
    function u() {
      a != 0 && (l.push(c.length == 1 ? c[0] : St.from(c, h)), h = -1, a = c.length = 0);
    }
    for (let d of e)
      f(d);
    return u(), l.length == 1 ? l[0] : new St(l, t);
  }
}
K.empty = /* @__PURE__ */ new de([""], 0);
function $g(r) {
  let e = -1;
  for (let t of r)
    e += t.length + 1;
  return e;
}
function Fn(r, e, t = 0, i = 1e9) {
  for (let n = 0, s = 0, o = !0; s < r.length && n <= i; s++) {
    let l = r[s], a = n + l.length;
    a >= t && (a > i && (l = l.slice(0, i - n)), n < t && (l = l.slice(t - n)), o ? (e[e.length - 1] += l, o = !1) : e.push(l)), n = a + 1;
  }
  return e;
}
function Vh(r, e, t) {
  return Fn(r, [""], e, t);
}
class Pr {
  constructor(e, t = 1) {
    this.dir = t, this.done = !1, this.lineBreak = !1, this.value = "", this.nodes = [e], this.offsets = [t > 0 ? 1 : (e instanceof de ? e.text.length : e.children.length) << 1];
  }
  nextInner(e, t) {
    for (this.done = this.lineBreak = !1; ; ) {
      let i = this.nodes.length - 1, n = this.nodes[i], s = this.offsets[i], o = s >> 1, l = n instanceof de ? n.text.length : n.children.length;
      if (o == (t > 0 ? l : 0)) {
        if (i == 0)
          return this.done = !0, this.value = "", this;
        t > 0 && this.offsets[i - 1]++, this.nodes.pop(), this.offsets.pop();
      } else if ((s & 1) == (t > 0 ? 0 : 1)) {
        if (this.offsets[i] += t, e == 0)
          return this.lineBreak = !0, this.value = `
`, this;
        e--;
      } else if (n instanceof de) {
        let a = n.text[o + (t < 0 ? -1 : 0)];
        if (this.offsets[i] += t, a.length > Math.max(0, e))
          return this.value = e == 0 ? a : t > 0 ? a.slice(e) : a.slice(0, a.length - e), this;
        e -= a.length;
      } else {
        let a = n.children[o + (t < 0 ? -1 : 0)];
        e > a.length ? (e -= a.length, this.offsets[i] += t) : (t < 0 && this.offsets[i]--, this.nodes.push(a), this.offsets.push(t > 0 ? 1 : (a instanceof de ? a.text.length : a.children.length) << 1));
      }
    }
  }
  next(e = 0) {
    return e < 0 && (this.nextInner(-e, -this.dir), e = this.value.length), this.nextInner(e, this.dir);
  }
}
class ju {
  constructor(e, t, i) {
    this.value = "", this.done = !1, this.cursor = new Pr(e, t > i ? -1 : 1), this.pos = t > i ? e.length : 0, this.from = Math.min(t, i), this.to = Math.max(t, i);
  }
  nextInner(e, t) {
    if (t < 0 ? this.pos <= this.from : this.pos >= this.to)
      return this.value = "", this.done = !0, this;
    e += Math.max(0, t < 0 ? this.pos - this.to : this.from - this.pos);
    let i = t < 0 ? this.pos - this.from : this.to - this.pos;
    e > i && (e = i), i -= e;
    let { value: n } = this.cursor.next(e);
    return this.pos += (n.length + e) * t, this.value = n.length <= i ? n : t < 0 ? n.slice(n.length - i) : n.slice(0, i), this.done = !this.value, this;
  }
  next(e = 0) {
    return e < 0 ? e = Math.max(e, this.from - this.pos) : e > 0 && (e = Math.min(e, this.to - this.pos)), this.nextInner(e, this.cursor.dir);
  }
  get lineBreak() {
    return this.cursor.lineBreak && this.value != "";
  }
}
class Gu {
  constructor(e) {
    this.inner = e, this.afterBreak = !0, this.value = "", this.done = !1;
  }
  next(e = 0) {
    let { done: t, lineBreak: i, value: n } = this.inner.next(e);
    return t && this.afterBreak ? (this.value = "", this.afterBreak = !1) : t ? (this.done = !0, this.value = "") : i ? this.afterBreak ? this.value = "" : (this.afterBreak = !0, this.next()) : (this.value = n, this.afterBreak = !1), this;
  }
  get lineBreak() {
    return !1;
  }
}
typeof Symbol < "u" && (K.prototype[Symbol.iterator] = function() {
  return this.iter();
}, Pr.prototype[Symbol.iterator] = ju.prototype[Symbol.iterator] = Gu.prototype[Symbol.iterator] = function() {
  return this;
});
let Pg = class {
  /**
  @internal
  */
  constructor(e, t, i, n) {
    this.from = e, this.to = t, this.number = i, this.text = n;
  }
  /**
  The length of the line (not including any line break after it).
  */
  get length() {
    return this.to - this.from;
  }
};
function Vi(r, e, t) {
  return e = Math.max(0, Math.min(r.length, e)), [e, Math.max(e, Math.min(r.length, t))];
}
function De(r, e, t = !0, i = !0) {
  return Qg(r, e, t, i);
}
function Cg(r) {
  return r >= 56320 && r < 57344;
}
function Tg(r) {
  return r >= 55296 && r < 56320;
}
function Ee(r, e) {
  let t = r.charCodeAt(e);
  if (!Tg(t) || e + 1 == r.length)
    return t;
  let i = r.charCodeAt(e + 1);
  return Cg(i) ? (t - 55296 << 10) + (i - 56320) + 65536 : t;
}
function Da(r) {
  return r <= 65535 ? String.fromCharCode(r) : (r -= 65536, String.fromCharCode((r >> 10) + 55296, (r & 1023) + 56320));
}
function ot(r) {
  return r < 65536 ? 1 : 2;
}
const bl = /\r\n?|\n/;
var ke = /* @__PURE__ */ (function(r) {
  return r[r.Simple = 0] = "Simple", r[r.TrackDel = 1] = "TrackDel", r[r.TrackBefore = 2] = "TrackBefore", r[r.TrackAfter = 3] = "TrackAfter", r;
})(ke || (ke = {}));
class vt {
  // Sections are encoded as pairs of integers. The first is the
  // length in the current document, and the second is -1 for
  // unaffected sections, and the length of the replacement content
  // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
  // 0), and a replacement two positive numbers.
  /**
  @internal
  */
  constructor(e) {
    this.sections = e;
  }
  /**
  The length of the document before the change.
  */
  get length() {
    let e = 0;
    for (let t = 0; t < this.sections.length; t += 2)
      e += this.sections[t];
    return e;
  }
  /**
  The length of the document after the change.
  */
  get newLength() {
    let e = 0;
    for (let t = 0; t < this.sections.length; t += 2) {
      let i = this.sections[t + 1];
      e += i < 0 ? this.sections[t] : i;
    }
    return e;
  }
  /**
  False when there are actual changes in this set.
  */
  get empty() {
    return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
  }
  /**
  Iterate over the unchanged parts left by these changes. `posA`
  provides the position of the range in the old document, `posB`
  the new position in the changed document.
  */
  iterGaps(e) {
    for (let t = 0, i = 0, n = 0; t < this.sections.length; ) {
      let s = this.sections[t++], o = this.sections[t++];
      o < 0 ? (e(i, n, s), n += s) : n += o, i += s;
    }
  }
  /**
  Iterate over the ranges changed by these changes. (See
  [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
  variant that also provides you with the inserted text.)
  `fromA`/`toA` provides the extent of the change in the starting
  document, `fromB`/`toB` the extent of the replacement in the
  changed document.
  
  When `individual` is true, adjacent changes (which are kept
  separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
  reported separately.
  */
  iterChangedRanges(e, t = !1) {
    yl(this, e, t);
  }
  /**
  Get a description of the inverted form of these changes.
  */
  get invertedDesc() {
    let e = [];
    for (let t = 0; t < this.sections.length; ) {
      let i = this.sections[t++], n = this.sections[t++];
      n < 0 ? e.push(i, n) : e.push(n, i);
    }
    return new vt(e);
  }
  /**
  Compute the combined effect of applying another set of changes
  after this one. The length of the document after this set should
  match the length before `other`.
  */
  composeDesc(e) {
    return this.empty ? e : e.empty ? this : Uu(this, e);
  }
  /**
  Map this description, which should start with the same document
  as `other`, over another set of changes, so that it can be
  applied after it. When `before` is true, map as if the changes
  in `this` happened before the ones in `other`.
  */
  mapDesc(e, t = !1) {
    return e.empty ? this : Sl(this, e, t);
  }
  mapPos(e, t = -1, i = ke.Simple) {
    let n = 0, s = 0;
    for (let o = 0; o < this.sections.length; ) {
      let l = this.sections[o++], a = this.sections[o++], h = n + l;
      if (a < 0) {
        if (h > e)
          return s + (e - n);
        s += l;
      } else {
        if (i != ke.Simple && h >= e && (i == ke.TrackDel && n < e && h > e || i == ke.TrackBefore && n < e || i == ke.TrackAfter && h > e))
          return null;
        if (h > e || h == e && t < 0 && !l)
          return e == n || t < 0 ? s : s + a;
        s += a;
      }
      n = h;
    }
    if (e > n)
      throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);
    return s;
  }
  /**
  Check whether these changes touch a given range. When one of the
  changes entirely covers the range, the string `"cover"` is
  returned.
  */
  touchesRange(e, t = e) {
    for (let i = 0, n = 0; i < this.sections.length && n <= t; ) {
      let s = this.sections[i++], o = this.sections[i++], l = n + s;
      if (o >= 0 && n <= t && l >= e)
        return n < e && l > t ? "cover" : !0;
      n = l;
    }
    return !1;
  }
  /**
  @internal
  */
  toString() {
    let e = "";
    for (let t = 0; t < this.sections.length; ) {
      let i = this.sections[t++], n = this.sections[t++];
      e += (e ? " " : "") + i + (n >= 0 ? ":" + n : "");
    }
    return e;
  }
  /**
  Serialize this change desc to a JSON-representable value.
  */
  toJSON() {
    return this.sections;
  }
  /**
  Create a change desc from its JSON representation (as produced
  by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
  */
  static fromJSON(e) {
    if (!Array.isArray(e) || e.length % 2 || e.some((t) => typeof t != "number"))
      throw new RangeError("Invalid JSON representation of ChangeDesc");
    return new vt(e);
  }
  /**
  @internal
  */
  static create(e) {
    return new vt(e);
  }
}
class ye extends vt {
  constructor(e, t) {
    super(e), this.inserted = t;
  }
  /**
  Apply the changes to a document, returning the modified
  document.
  */
  apply(e) {
    if (this.length != e.length)
      throw new RangeError("Applying change set to a document with the wrong length");
    return yl(this, (t, i, n, s, o) => e = e.replace(n, n + (i - t), o), !1), e;
  }
  mapDesc(e, t = !1) {
    return Sl(this, e, t, !0);
  }
  /**
  Given the document as it existed _before_ the changes, return a
  change set that represents the inverse of this set, which could
  be used to go from the document created by the changes back to
  the document as it existed before the changes.
  */
  invert(e) {
    let t = this.sections.slice(), i = [];
    for (let n = 0, s = 0; n < t.length; n += 2) {
      let o = t[n], l = t[n + 1];
      if (l >= 0) {
        t[n] = l, t[n + 1] = o;
        let a = n >> 1;
        for (; i.length < a; )
          i.push(K.empty);
        i.push(o ? e.slice(s, s + o) : K.empty);
      }
      s += o;
    }
    return new ye(t, i);
  }
  /**
  Combine two subsequent change sets into a single set. `other`
  must start in the document produced by `this`. If `this` goes
  `docA` → `docB` and `other` represents `docB` → `docC`, the
  returned value will represent the change `docA` → `docC`.
  */
  compose(e) {
    return this.empty ? e : e.empty ? this : Uu(this, e, !0);
  }
  /**
  Given another change set starting in the same document, maps this
  change set over the other, producing a new change set that can be
  applied to the document produced by applying `other`. When
  `before` is `true`, order changes as if `this` comes before
  `other`, otherwise (the default) treat `other` as coming first.
  
  Given two changes `A` and `B`, `A.compose(B.map(A))` and
  `B.compose(A.map(B, true))` will produce the same document. This
  provides a basic form of [operational
  transformation](https://en.wikipedia.org/wiki/Operational_transformation),
  and can be used for collaborative editing.
  */
  map(e, t = !1) {
    return e.empty ? this : Sl(this, e, t, !0);
  }
  /**
  Iterate over the changed ranges in the document, calling `f` for
  each, with the range in the original document (`fromA`-`toA`)
  and the range that replaces it in the new document
  (`fromB`-`toB`).
  
  When `individual` is true, adjacent changes are reported
  separately.
  */
  iterChanges(e, t = !1) {
    yl(this, e, t);
  }
  /**
  Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
  set.
  */
  get desc() {
    return vt.create(this.sections);
  }
  /**
  @internal
  */
  filter(e) {
    let t = [], i = [], n = [], s = new zr(this);
    e: for (let o = 0, l = 0; ; ) {
      let a = o == e.length ? 1e9 : e[o++];
      for (; l < a || l == a && s.len == 0; ) {
        if (s.done)
          break e;
        let c = Math.min(s.len, a - l);
        $e(n, c, -1);
        let f = s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0;
        $e(t, c, f), f > 0 && ti(i, t, s.text), s.forward(c), l += c;
      }
      let h = e[o++];
      for (; l < h; ) {
        if (s.done)
          break e;
        let c = Math.min(s.len, h - l);
        $e(t, c, -1), $e(n, c, s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0), s.forward(c), l += c;
      }
    }
    return {
      changes: new ye(t, i),
      filtered: vt.create(n)
    };
  }
  /**
  Serialize this change set to a JSON-representable value.
  */
  toJSON() {
    let e = [];
    for (let t = 0; t < this.sections.length; t += 2) {
      let i = this.sections[t], n = this.sections[t + 1];
      n < 0 ? e.push(i) : n == 0 ? e.push([i]) : e.push([i].concat(this.inserted[t >> 1].toJSON()));
    }
    return e;
  }
  /**
  Create a change set for the given changes, for a document of the
  given length, using `lineSep` as line separator.
  */
  static of(e, t, i) {
    let n = [], s = [], o = 0, l = null;
    function a(c = !1) {
      if (!c && !n.length)
        return;
      o < t && $e(n, t - o, -1);
      let f = new ye(n, s);
      l = l ? l.compose(f.map(l)) : f, n = [], s = [], o = 0;
    }
    function h(c) {
      if (Array.isArray(c))
        for (let f of c)
          h(f);
      else if (c instanceof ye) {
        if (c.length != t)
          throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);
        a(), l = l ? l.compose(c.map(l)) : c;
      } else {
        let { from: f, to: u = f, insert: d } = c;
        if (f > u || f < 0 || u > t)
          throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);
        let p = d ? typeof d == "string" ? K.of(d.split(i || bl)) : d : K.empty, O = p.length;
        if (f == u && O == 0)
          return;
        f < o && a(), f > o && $e(n, f - o, -1), $e(n, u - f, O), ti(s, n, p), o = u;
      }
    }
    return h(e), a(!l), l;
  }
  /**
  Create an empty changeset of the given length.
  */
  static empty(e) {
    return new ye(e ? [e, -1] : [], []);
  }
  /**
  Create a changeset from its JSON representation (as produced by
  [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
  */
  static fromJSON(e) {
    if (!Array.isArray(e))
      throw new RangeError("Invalid JSON representation of ChangeSet");
    let t = [], i = [];
    for (let n = 0; n < e.length; n++) {
      let s = e[n];
      if (typeof s == "number")
        t.push(s, -1);
      else {
        if (!Array.isArray(s) || typeof s[0] != "number" || s.some((o, l) => l && typeof o != "string"))
          throw new RangeError("Invalid JSON representation of ChangeSet");
        if (s.length == 1)
          t.push(s[0], 0);
        else {
          for (; i.length < n; )
            i.push(K.empty);
          i[n] = K.of(s.slice(1)), t.push(s[0], i[n].length);
        }
      }
    }
    return new ye(t, i);
  }
  /**
  @internal
  */
  static createSet(e, t) {
    return new ye(e, t);
  }
}
function $e(r, e, t, i = !1) {
  if (e == 0 && t <= 0)
    return;
  let n = r.length - 2;
  n >= 0 && t <= 0 && t == r[n + 1] ? r[n] += e : n >= 0 && e == 0 && r[n] == 0 ? r[n + 1] += t : i ? (r[n] += e, r[n + 1] += t) : r.push(e, t);
}
function ti(r, e, t) {
  if (t.length == 0)
    return;
  let i = e.length - 2 >> 1;
  if (i < r.length)
    r[r.length - 1] = r[r.length - 1].append(t);
  else {
    for (; r.length < i; )
      r.push(K.empty);
    r.push(t);
  }
}
function yl(r, e, t) {
  let i = r.inserted;
  for (let n = 0, s = 0, o = 0; o < r.sections.length; ) {
    let l = r.sections[o++], a = r.sections[o++];
    if (a < 0)
      n += l, s += l;
    else {
      let h = n, c = s, f = K.empty;
      for (; h += l, c += a, a && i && (f = f.append(i[o - 2 >> 1])), !(t || o == r.sections.length || r.sections[o + 1] < 0); )
        l = r.sections[o++], a = r.sections[o++];
      e(n, h, s, c, f), n = h, s = c;
    }
  }
}
function Sl(r, e, t, i = !1) {
  let n = [], s = i ? [] : null, o = new zr(r), l = new zr(e);
  for (let a = -1; ; ) {
    if (o.done && l.len || l.done && o.len)
      throw new Error("Mismatched change set lengths");
    if (o.ins == -1 && l.ins == -1) {
      let h = Math.min(o.len, l.len);
      $e(n, h, -1), o.forward(h), l.forward(h);
    } else if (l.ins >= 0 && (o.ins < 0 || a == o.i || o.off == 0 && (l.len < o.len || l.len == o.len && !t))) {
      let h = l.len;
      for ($e(n, l.ins, -1); h; ) {
        let c = Math.min(o.len, h);
        o.ins >= 0 && a < o.i && o.len <= c && ($e(n, 0, o.ins), s && ti(s, n, o.text), a = o.i), o.forward(c), h -= c;
      }
      l.next();
    } else if (o.ins >= 0) {
      let h = 0, c = o.len;
      for (; c; )
        if (l.ins == -1) {
          let f = Math.min(c, l.len);
          h += f, c -= f, l.forward(f);
        } else if (l.ins == 0 && l.len < c)
          c -= l.len, l.next();
        else
          break;
      $e(n, h, a < o.i ? o.ins : 0), s && a < o.i && ti(s, n, o.text), a = o.i, o.forward(o.len - c);
    } else {
      if (o.done && l.done)
        return s ? ye.createSet(n, s) : vt.create(n);
      throw new Error("Mismatched change set lengths");
    }
  }
}
function Uu(r, e, t = !1) {
  let i = [], n = t ? [] : null, s = new zr(r), o = new zr(e);
  for (let l = !1; ; ) {
    if (s.done && o.done)
      return n ? ye.createSet(i, n) : vt.create(i);
    if (s.ins == 0)
      $e(i, s.len, 0, l), s.next();
    else if (o.len == 0 && !o.done)
      $e(i, 0, o.ins, l), n && ti(n, i, o.text), o.next();
    else {
      if (s.done || o.done)
        throw new Error("Mismatched change set lengths");
      {
        let a = Math.min(s.len2, o.len), h = i.length;
        if (s.ins == -1) {
          let c = o.ins == -1 ? -1 : o.off ? 0 : o.ins;
          $e(i, a, c, l), n && c && ti(n, i, o.text);
        } else o.ins == -1 ? ($e(i, s.off ? 0 : s.len, a, l), n && ti(n, i, s.textBit(a))) : ($e(i, s.off ? 0 : s.len, o.off ? 0 : o.ins, l), n && !o.off && ti(n, i, o.text));
        l = (s.ins > a || o.ins >= 0 && o.len > a) && (l || i.length > h), s.forward2(a), o.forward(a);
      }
    }
  }
}
class zr {
  constructor(e) {
    this.set = e, this.i = 0, this.next();
  }
  next() {
    let { sections: e } = this.set;
    this.i < e.length ? (this.len = e[this.i++], this.ins = e[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
  }
  get done() {
    return this.ins == -2;
  }
  get len2() {
    return this.ins < 0 ? this.len : this.ins;
  }
  get text() {
    let { inserted: e } = this.set, t = this.i - 2 >> 1;
    return t >= e.length ? K.empty : e[t];
  }
  textBit(e) {
    let { inserted: t } = this.set, i = this.i - 2 >> 1;
    return i >= t.length && !e ? K.empty : t[i].slice(this.off, e == null ? void 0 : this.off + e);
  }
  forward(e) {
    e == this.len ? this.next() : (this.len -= e, this.off += e);
  }
  forward2(e) {
    this.ins == -1 ? this.forward(e) : e == this.ins ? this.next() : (this.ins -= e, this.off += e);
  }
}
class xi {
  constructor(e, t, i) {
    this.from = e, this.to = t, this.flags = i;
  }
  /**
  The anchor of the range—the side that doesn't move when you
  extend it.
  */
  get anchor() {
    return this.flags & 32 ? this.to : this.from;
  }
  /**
  The head of the range, which is moved when the range is
  [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
  */
  get head() {
    return this.flags & 32 ? this.from : this.to;
  }
  /**
  True when `anchor` and `head` are at the same position.
  */
  get empty() {
    return this.from == this.to;
  }
  /**
  If this is a cursor that is explicitly associated with the
  character on one of its sides, this returns the side. -1 means
  the character before its position, 1 the character after, and 0
  means no association.
  */
  get assoc() {
    return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
  }
  /**
  The bidirectional text level associated with this cursor, if
  any.
  */
  get bidiLevel() {
    let e = this.flags & 7;
    return e == 7 ? null : e;
  }
  /**
  The goal column (stored vertical offset) associated with a
  cursor. This is used to preserve the vertical position when
  [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
  lines of different length.
  */
  get goalColumn() {
    let e = this.flags >> 6;
    return e == 16777215 ? void 0 : e;
  }
  /**
  Map this range through a change, producing a valid range in the
  updated document.
  */
  map(e, t = -1) {
    let i, n;
    return this.empty ? i = n = e.mapPos(this.from, t) : (i = e.mapPos(this.from, 1), n = e.mapPos(this.to, -1)), i == this.from && n == this.to ? this : new xi(i, n, this.flags);
  }
  /**
  Extend this range to cover at least `from` to `to`.
  */
  extend(e, t = e) {
    if (e <= this.anchor && t >= this.anchor)
      return v.range(e, t);
    let i = Math.abs(e - this.anchor) > Math.abs(t - this.anchor) ? e : t;
    return v.range(this.anchor, i);
  }
  /**
  Compare this range to another range.
  */
  eq(e, t = !1) {
    return this.anchor == e.anchor && this.head == e.head && (!t || !this.empty || this.assoc == e.assoc);
  }
  /**
  Return a JSON-serializable object representing the range.
  */
  toJSON() {
    return { anchor: this.anchor, head: this.head };
  }
  /**
  Convert a JSON representation of a range to a `SelectionRange`
  instance.
  */
  static fromJSON(e) {
    if (!e || typeof e.anchor != "number" || typeof e.head != "number")
      throw new RangeError("Invalid JSON representation for SelectionRange");
    return v.range(e.anchor, e.head);
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new xi(e, t, i);
  }
}
class v {
  constructor(e, t) {
    this.ranges = e, this.mainIndex = t;
  }
  /**
  Map a selection through a change. Used to adjust the selection
  position for changes.
  */
  map(e, t = -1) {
    return e.empty ? this : v.create(this.ranges.map((i) => i.map(e, t)), this.mainIndex);
  }
  /**
  Compare this selection to another selection. By default, ranges
  are compared only by position. When `includeAssoc` is true,
  cursor ranges must also have the same
  [`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
  */
  eq(e, t = !1) {
    if (this.ranges.length != e.ranges.length || this.mainIndex != e.mainIndex)
      return !1;
    for (let i = 0; i < this.ranges.length; i++)
      if (!this.ranges[i].eq(e.ranges[i], t))
        return !1;
    return !0;
  }
  /**
  Get the primary selection range. Usually, you should make sure
  your code applies to _all_ ranges, by using methods like
  [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
  */
  get main() {
    return this.ranges[this.mainIndex];
  }
  /**
  Make sure the selection only has one range. Returns a selection
  holding only the main range from this selection.
  */
  asSingle() {
    return this.ranges.length == 1 ? this : new v([this.main], 0);
  }
  /**
  Extend this selection with an extra range.
  */
  addRange(e, t = !0) {
    return v.create([e].concat(this.ranges), t ? 0 : this.mainIndex + 1);
  }
  /**
  Replace a given range with another range, and then normalize the
  selection to merge and sort ranges if necessary.
  */
  replaceRange(e, t = this.mainIndex) {
    let i = this.ranges.slice();
    return i[t] = e, v.create(i, this.mainIndex);
  }
  /**
  Convert this selection to an object that can be serialized to
  JSON.
  */
  toJSON() {
    return { ranges: this.ranges.map((e) => e.toJSON()), main: this.mainIndex };
  }
  /**
  Create a selection from a JSON representation.
  */
  static fromJSON(e) {
    if (!e || !Array.isArray(e.ranges) || typeof e.main != "number" || e.main >= e.ranges.length)
      throw new RangeError("Invalid JSON representation for EditorSelection");
    return new v(e.ranges.map((t) => xi.fromJSON(t)), e.main);
  }
  /**
  Create a selection holding a single range.
  */
  static single(e, t = e) {
    return new v([v.range(e, t)], 0);
  }
  /**
  Sort and merge the given set of ranges, creating a valid
  selection.
  */
  static create(e, t = 0) {
    if (e.length == 0)
      throw new RangeError("A selection needs at least one range");
    for (let i = 0, n = 0; n < e.length; n++) {
      let s = e[n];
      if (s.empty ? s.from <= i : s.from < i)
        return v.normalized(e.slice(), t);
      i = s.to;
    }
    return new v(e, t);
  }
  /**
  Create a cursor selection range at the given position. You can
  safely ignore the optional arguments in most situations.
  */
  static cursor(e, t = 0, i, n) {
    return xi.create(e, e, (t == 0 ? 0 : t < 0 ? 8 : 16) | (i == null ? 7 : Math.min(6, i)) | (n ?? 16777215) << 6);
  }
  /**
  Create a selection range.
  */
  static range(e, t, i, n) {
    let s = (i ?? 16777215) << 6 | (n == null ? 7 : Math.min(6, n));
    return t < e ? xi.create(t, e, 48 | s) : xi.create(e, t, (t > e ? 8 : 0) | s);
  }
  /**
  @internal
  */
  static normalized(e, t = 0) {
    let i = e[t];
    e.sort((n, s) => n.from - s.from), t = e.indexOf(i);
    for (let n = 1; n < e.length; n++) {
      let s = e[n], o = e[n - 1];
      if (s.empty ? s.from <= o.to : s.from < o.to) {
        let l = o.from, a = Math.max(s.to, o.to);
        n <= t && t--, e.splice(--n, 2, s.anchor > s.head ? v.range(a, l) : v.range(l, a));
      }
    }
    return new v(e, t);
  }
}
function Fu(r, e) {
  for (let t of r.ranges)
    if (t.to > e)
      throw new RangeError("Selection points outside of document");
}
let _a = 0;
class R {
  constructor(e, t, i, n, s) {
    this.combine = e, this.compareInput = t, this.compare = i, this.isStatic = n, this.id = _a++, this.default = e([]), this.extensions = typeof s == "function" ? s(this) : s;
  }
  /**
  Returns a facet reader for this facet, which can be used to
  [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
  */
  get reader() {
    return this;
  }
  /**
  Define a new facet.
  */
  static define(e = {}) {
    return new R(e.combine || ((t) => t), e.compareInput || ((t, i) => t === i), e.compare || (e.combine ? (t, i) => t === i : Ba), !!e.static, e.enables);
  }
  /**
  Returns an extension that adds the given value to this facet.
  */
  of(e) {
    return new Hn([], this, 0, e);
  }
  /**
  Create an extension that computes a value for the facet from a
  state. You must take care to declare the parts of the state that
  this value depends on, since your function is only called again
  for a new state when one of those parts changed.
  
  In cases where your value depends only on a single field, you'll
  want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
  */
  compute(e, t) {
    if (this.isStatic)
      throw new Error("Can't compute a static facet");
    return new Hn(e, this, 1, t);
  }
  /**
  Create an extension that computes zero or more values for this
  facet from a state.
  */
  computeN(e, t) {
    if (this.isStatic)
      throw new Error("Can't compute a static facet");
    return new Hn(e, this, 2, t);
  }
  from(e, t) {
    return t || (t = (i) => i), this.compute([e], (i) => t(i.field(e)));
  }
}
function Ba(r, e) {
  return r == e || r.length == e.length && r.every((t, i) => t === e[i]);
}
class Hn {
  constructor(e, t, i, n) {
    this.dependencies = e, this.facet = t, this.type = i, this.value = n, this.id = _a++;
  }
  dynamicSlot(e) {
    var t;
    let i = this.value, n = this.facet.compareInput, s = this.id, o = e[s] >> 1, l = this.type == 2, a = !1, h = !1, c = [];
    for (let f of this.dependencies)
      f == "doc" ? a = !0 : f == "selection" ? h = !0 : (((t = e[f.id]) !== null && t !== void 0 ? t : 1) & 1) == 0 && c.push(e[f.id]);
    return {
      create(f) {
        return f.values[o] = i(f), 1;
      },
      update(f, u) {
        if (a && u.docChanged || h && (u.docChanged || u.selection) || wl(f, c)) {
          let d = i(f);
          if (l ? !qh(d, f.values[o], n) : !n(d, f.values[o]))
            return f.values[o] = d, 1;
        }
        return 0;
      },
      reconfigure: (f, u) => {
        let d, p = u.config.address[s];
        if (p != null) {
          let O = gs(u, p);
          if (this.dependencies.every((g) => g instanceof R ? u.facet(g) === f.facet(g) : g instanceof ge ? u.field(g, !1) == f.field(g, !1) : !0) || (l ? qh(d = i(f), O, n) : n(d = i(f), O)))
            return f.values[o] = O, 0;
        } else
          d = i(f);
        return f.values[o] = d, 1;
      }
    };
  }
}
function qh(r, e, t) {
  if (r.length != e.length)
    return !1;
  for (let i = 0; i < r.length; i++)
    if (!t(r[i], e[i]))
      return !1;
  return !0;
}
function wl(r, e) {
  let t = !1;
  for (let i of e)
    Cr(r, i) & 1 && (t = !0);
  return t;
}
function Ag(r, e, t) {
  let i = t.map((a) => r[a.id]), n = t.map((a) => a.type), s = i.filter((a) => !(a & 1)), o = r[e.id] >> 1;
  function l(a) {
    let h = [];
    for (let c = 0; c < i.length; c++) {
      let f = gs(a, i[c]);
      if (n[c] == 2)
        for (let u of f)
          h.push(u);
      else
        h.push(f);
    }
    return e.combine(h);
  }
  return {
    create(a) {
      for (let h of i)
        Cr(a, h);
      return a.values[o] = l(a), 1;
    },
    update(a, h) {
      if (!wl(a, s))
        return 0;
      let c = l(a);
      return e.compare(c, a.values[o]) ? 0 : (a.values[o] = c, 1);
    },
    reconfigure(a, h) {
      let c = wl(a, i), f = h.config.facets[e.id], u = h.facet(e);
      if (f && !c && Ba(t, f))
        return a.values[o] = u, 0;
      let d = l(a);
      return e.compare(d, u) ? (a.values[o] = u, 0) : (a.values[o] = d, 1);
    }
  };
}
const bn = /* @__PURE__ */ R.define({ static: !0 });
class ge {
  constructor(e, t, i, n, s) {
    this.id = e, this.createF = t, this.updateF = i, this.compareF = n, this.spec = s, this.provides = void 0;
  }
  /**
  Define a state field.
  */
  static define(e) {
    let t = new ge(_a++, e.create, e.update, e.compare || ((i, n) => i === n), e);
    return e.provide && (t.provides = e.provide(t)), t;
  }
  create(e) {
    let t = e.facet(bn).find((i) => i.field == this);
    return (t?.create || this.createF)(e);
  }
  /**
  @internal
  */
  slot(e) {
    let t = e[this.id] >> 1;
    return {
      create: (i) => (i.values[t] = this.create(i), 1),
      update: (i, n) => {
        let s = i.values[t], o = this.updateF(s, n);
        return this.compareF(s, o) ? 0 : (i.values[t] = o, 1);
      },
      reconfigure: (i, n) => {
        let s = i.facet(bn), o = n.facet(bn), l;
        return (l = s.find((a) => a.field == this)) && l != o.find((a) => a.field == this) ? (i.values[t] = l.create(i), 1) : n.config.address[this.id] != null ? (i.values[t] = n.field(this), 0) : (i.values[t] = this.create(i), 1);
      }
    };
  }
  /**
  Returns an extension that enables this field and overrides the
  way it is initialized. Can be useful when you need to provide a
  non-default starting value for the field.
  */
  init(e) {
    return [this, bn.of({ field: this, create: e })];
  }
  /**
  State field instances can be used as
  [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
  given state.
  */
  get extension() {
    return this;
  }
}
const yi = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
function lr(r) {
  return (e) => new Hu(e, r);
}
const Vt = {
  /**
  The highest precedence level, for extensions that should end up
  near the start of the precedence ordering.
  */
  highest: /* @__PURE__ */ lr(yi.highest),
  /**
  A higher-than-default precedence, for extensions that should
  come before those with default precedence.
  */
  high: /* @__PURE__ */ lr(yi.high),
  /**
  The default precedence, which is also used for extensions
  without an explicit precedence.
  */
  default: /* @__PURE__ */ lr(yi.default),
  /**
  A lower-than-default precedence.
  */
  low: /* @__PURE__ */ lr(yi.low),
  /**
  The lowest precedence level. Meant for things that should end up
  near the end of the extension order.
  */
  lowest: /* @__PURE__ */ lr(yi.lowest)
};
class Hu {
  constructor(e, t) {
    this.inner = e, this.prec = t;
  }
}
class eo {
  /**
  Create an instance of this compartment to add to your [state
  configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
  */
  of(e) {
    return new xl(this, e);
  }
  /**
  Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
  reconfigures this compartment.
  */
  reconfigure(e) {
    return eo.reconfigure.of({ compartment: this, extension: e });
  }
  /**
  Get the current content of the compartment in the state, or
  `undefined` if it isn't present.
  */
  get(e) {
    return e.config.compartments.get(this);
  }
}
class xl {
  constructor(e, t) {
    this.compartment = e, this.inner = t;
  }
}
class ms {
  constructor(e, t, i, n, s, o) {
    for (this.base = e, this.compartments = t, this.dynamicSlots = i, this.address = n, this.staticValues = s, this.facets = o, this.statusTemplate = []; this.statusTemplate.length < i.length; )
      this.statusTemplate.push(
        0
        /* SlotStatus.Unresolved */
      );
  }
  staticFacet(e) {
    let t = this.address[e.id];
    return t == null ? e.default : this.staticValues[t >> 1];
  }
  static resolve(e, t, i) {
    let n = [], s = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ new Map();
    for (let u of Mg(e, t, o))
      u instanceof ge ? n.push(u) : (s[u.facet.id] || (s[u.facet.id] = [])).push(u);
    let l = /* @__PURE__ */ Object.create(null), a = [], h = [];
    for (let u of n)
      l[u.id] = h.length << 1, h.push((d) => u.slot(d));
    let c = i?.config.facets;
    for (let u in s) {
      let d = s[u], p = d[0].facet, O = c && c[u] || [];
      if (d.every(
        (g) => g.type == 0
        /* Provider.Static */
      ))
        if (l[p.id] = a.length << 1 | 1, Ba(O, d))
          a.push(i.facet(p));
        else {
          let g = p.combine(d.map((b) => b.value));
          a.push(i && p.compare(g, i.facet(p)) ? i.facet(p) : g);
        }
      else {
        for (let g of d)
          g.type == 0 ? (l[g.id] = a.length << 1 | 1, a.push(g.value)) : (l[g.id] = h.length << 1, h.push((b) => g.dynamicSlot(b)));
        l[p.id] = h.length << 1, h.push((g) => Ag(g, p, d));
      }
    }
    let f = h.map((u) => u(l));
    return new ms(e, o, f, l, a, s);
  }
}
function Mg(r, e, t) {
  let i = [[], [], [], [], []], n = /* @__PURE__ */ new Map();
  function s(o, l) {
    let a = n.get(o);
    if (a != null) {
      if (a <= l)
        return;
      let h = i[a].indexOf(o);
      h > -1 && i[a].splice(h, 1), o instanceof xl && t.delete(o.compartment);
    }
    if (n.set(o, l), Array.isArray(o))
      for (let h of o)
        s(h, l);
    else if (o instanceof xl) {
      if (t.has(o.compartment))
        throw new RangeError("Duplicate use of compartment in extensions");
      let h = e.get(o.compartment) || o.inner;
      t.set(o.compartment, h), s(h, l);
    } else if (o instanceof Hu)
      s(o.inner, o.prec);
    else if (o instanceof ge)
      i[l].push(o), o.provides && s(o.provides, l);
    else if (o instanceof Hn)
      i[l].push(o), o.facet.extensions && s(o.facet.extensions, yi.default);
    else {
      let h = o.extension;
      if (!h)
        throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
      s(h, l);
    }
  }
  return s(r, yi.default), i.reduce((o, l) => o.concat(l));
}
function Cr(r, e) {
  if (e & 1)
    return 2;
  let t = e >> 1, i = r.status[t];
  if (i == 4)
    throw new Error("Cyclic dependency between fields and/or facets");
  if (i & 2)
    return i;
  r.status[t] = 4;
  let n = r.computeSlot(r, r.config.dynamicSlots[t]);
  return r.status[t] = 2 | n;
}
function gs(r, e) {
  return e & 1 ? r.config.staticValues[e >> 1] : r.values[e >> 1];
}
const Ku = /* @__PURE__ */ R.define(), kl = /* @__PURE__ */ R.define({
  combine: (r) => r.some((e) => e),
  static: !0
}), Ju = /* @__PURE__ */ R.define({
  combine: (r) => r.length ? r[0] : void 0,
  static: !0
}), ed = /* @__PURE__ */ R.define(), td = /* @__PURE__ */ R.define(), id = /* @__PURE__ */ R.define(), rd = /* @__PURE__ */ R.define({
  combine: (r) => r.length ? r[0] : !1
});
class qt {
  /**
  @internal
  */
  constructor(e, t) {
    this.type = e, this.value = t;
  }
  /**
  Define a new type of annotation.
  */
  static define() {
    return new Zg();
  }
}
class Zg {
  /**
  Create an instance of this annotation.
  */
  of(e) {
    return new qt(this, e);
  }
}
class Xg {
  /**
  @internal
  */
  constructor(e) {
    this.map = e;
  }
  /**
  Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
  type.
  */
  of(e) {
    return new V(this, e);
  }
}
class V {
  /**
  @internal
  */
  constructor(e, t) {
    this.type = e, this.value = t;
  }
  /**
  Map this effect through a position mapping. Will return
  `undefined` when that ends up deleting the effect.
  */
  map(e) {
    let t = this.type.map(this.value, e);
    return t === void 0 ? void 0 : t == this.value ? this : new V(this.type, t);
  }
  /**
  Tells you whether this effect object is of a given
  [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
  */
  is(e) {
    return this.type == e;
  }
  /**
  Define a new effect type. The type parameter indicates the type
  of values that his effect holds. It should be a type that
  doesn't include `undefined`, since that is used in
  [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
  removed.
  */
  static define(e = {}) {
    return new Xg(e.map || ((t) => t));
  }
  /**
  Map an array of effects through a change set.
  */
  static mapEffects(e, t) {
    if (!e.length)
      return e;
    let i = [];
    for (let n of e) {
      let s = n.map(t);
      s && i.push(s);
    }
    return i;
  }
}
V.reconfigure = /* @__PURE__ */ V.define();
V.appendConfig = /* @__PURE__ */ V.define();
class me {
  constructor(e, t, i, n, s, o) {
    this.startState = e, this.changes = t, this.selection = i, this.effects = n, this.annotations = s, this.scrollIntoView = o, this._doc = null, this._state = null, i && Fu(i, t.newLength), s.some((l) => l.type == me.time) || (this.annotations = s.concat(me.time.of(Date.now())));
  }
  /**
  @internal
  */
  static create(e, t, i, n, s, o) {
    return new me(e, t, i, n, s, o);
  }
  /**
  The new document produced by the transaction. Contrary to
  [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
  force the entire new state to be computed right away, so it is
  recommended that [transaction
  filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
  when they need to look at the new document.
  */
  get newDoc() {
    return this._doc || (this._doc = this.changes.apply(this.startState.doc));
  }
  /**
  The new selection produced by the transaction. If
  [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
  this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
  current selection through the changes made by the transaction.
  */
  get newSelection() {
    return this.selection || this.startState.selection.map(this.changes);
  }
  /**
  The new state created by the transaction. Computed on demand
  (but retained for subsequent access), so it is recommended not to
  access it in [transaction
  filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
  */
  get state() {
    return this._state || this.startState.applyTransaction(this), this._state;
  }
  /**
  Get the value of the given annotation type, if any.
  */
  annotation(e) {
    for (let t of this.annotations)
      if (t.type == e)
        return t.value;
  }
  /**
  Indicates whether the transaction changed the document.
  */
  get docChanged() {
    return !this.changes.empty;
  }
  /**
  Indicates whether this transaction reconfigures the state
  (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
  with a top-level configuration
  [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
  */
  get reconfigured() {
    return this.startState.config != this.state.config;
  }
  /**
  Returns true if the transaction has a [user
  event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
  or more specific than `event`. For example, if the transaction
  has `"select.pointer"` as user event, `"select"` and
  `"select.pointer"` will match it.
  */
  isUserEvent(e) {
    let t = this.annotation(me.userEvent);
    return !!(t && (t == e || t.length > e.length && t.slice(0, e.length) == e && t[e.length] == "."));
  }
}
me.time = /* @__PURE__ */ qt.define();
me.userEvent = /* @__PURE__ */ qt.define();
me.addToHistory = /* @__PURE__ */ qt.define();
me.remote = /* @__PURE__ */ qt.define();
function Rg(r, e) {
  let t = [];
  for (let i = 0, n = 0; ; ) {
    let s, o;
    if (i < r.length && (n == e.length || e[n] >= r[i]))
      s = r[i++], o = r[i++];
    else if (n < e.length)
      s = e[n++], o = e[n++];
    else
      return t;
    !t.length || t[t.length - 1] < s ? t.push(s, o) : t[t.length - 1] < o && (t[t.length - 1] = o);
  }
}
function nd(r, e, t) {
  var i;
  let n, s, o;
  return t ? (n = e.changes, s = ye.empty(e.changes.length), o = r.changes.compose(e.changes)) : (n = e.changes.map(r.changes), s = r.changes.mapDesc(e.changes, !0), o = r.changes.compose(n)), {
    changes: o,
    selection: e.selection ? e.selection.map(s) : (i = r.selection) === null || i === void 0 ? void 0 : i.map(n),
    effects: V.mapEffects(r.effects, n).concat(V.mapEffects(e.effects, s)),
    annotations: r.annotations.length ? r.annotations.concat(e.annotations) : e.annotations,
    scrollIntoView: r.scrollIntoView || e.scrollIntoView
  };
}
function Ql(r, e, t) {
  let i = e.selection, n = zi(e.annotations);
  return e.userEvent && (n = n.concat(me.userEvent.of(e.userEvent))), {
    changes: e.changes instanceof ye ? e.changes : ye.of(e.changes || [], t, r.facet(Ju)),
    selection: i && (i instanceof v ? i : v.single(i.anchor, i.head)),
    effects: zi(e.effects),
    annotations: n,
    scrollIntoView: !!e.scrollIntoView
  };
}
function sd(r, e, t) {
  let i = Ql(r, e.length ? e[0] : {}, r.doc.length);
  e.length && e[0].filter === !1 && (t = !1);
  for (let s = 1; s < e.length; s++) {
    e[s].filter === !1 && (t = !1);
    let o = !!e[s].sequential;
    i = nd(i, Ql(r, e[s], o ? i.changes.newLength : r.doc.length), o);
  }
  let n = me.create(r, i.changes, i.selection, i.effects, i.annotations, i.scrollIntoView);
  return Eg(t ? Lg(n) : n);
}
function Lg(r) {
  let e = r.startState, t = !0;
  for (let n of e.facet(ed)) {
    let s = n(r);
    if (s === !1) {
      t = !1;
      break;
    }
    Array.isArray(s) && (t = t === !0 ? s : Rg(t, s));
  }
  if (t !== !0) {
    let n, s;
    if (t === !1)
      s = r.changes.invertedDesc, n = ye.empty(e.doc.length);
    else {
      let o = r.changes.filter(t);
      n = o.changes, s = o.filtered.mapDesc(o.changes).invertedDesc;
    }
    r = me.create(e, n, r.selection && r.selection.map(s), V.mapEffects(r.effects, s), r.annotations, r.scrollIntoView);
  }
  let i = e.facet(td);
  for (let n = i.length - 1; n >= 0; n--) {
    let s = i[n](r);
    s instanceof me ? r = s : Array.isArray(s) && s.length == 1 && s[0] instanceof me ? r = s[0] : r = sd(e, zi(s), !1);
  }
  return r;
}
function Eg(r) {
  let e = r.startState, t = e.facet(id), i = r;
  for (let n = t.length - 1; n >= 0; n--) {
    let s = t[n](r);
    s && Object.keys(s).length && (i = nd(i, Ql(e, s, r.changes.newLength), !0));
  }
  return i == r ? r : me.create(e, r.changes, r.selection, i.effects, i.annotations, i.scrollIntoView);
}
const zg = [];
function zi(r) {
  return r == null ? zg : Array.isArray(r) ? r : [r];
}
var Ze = /* @__PURE__ */ (function(r) {
  return r[r.Word = 0] = "Word", r[r.Space = 1] = "Space", r[r.Other = 2] = "Other", r;
})(Ze || (Ze = {}));
const Dg = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
let vl;
try {
  vl = /* @__PURE__ */ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
} catch {
}
function _g(r) {
  if (vl)
    return vl.test(r);
  for (let e = 0; e < r.length; e++) {
    let t = r[e];
    if (/\w/.test(t) || t > "" && (t.toUpperCase() != t.toLowerCase() || Dg.test(t)))
      return !0;
  }
  return !1;
}
function Bg(r) {
  return (e) => {
    if (!/\S/.test(e))
      return Ze.Space;
    if (_g(e))
      return Ze.Word;
    for (let t = 0; t < r.length; t++)
      if (e.indexOf(r[t]) > -1)
        return Ze.Word;
    return Ze.Other;
  };
}
class W {
  constructor(e, t, i, n, s, o) {
    this.config = e, this.doc = t, this.selection = i, this.values = n, this.status = e.statusTemplate.slice(), this.computeSlot = s, o && (o._state = this);
    for (let l = 0; l < this.config.dynamicSlots.length; l++)
      Cr(this, l << 1);
    this.computeSlot = null;
  }
  field(e, t = !0) {
    let i = this.config.address[e.id];
    if (i == null) {
      if (t)
        throw new RangeError("Field is not present in this state");
      return;
    }
    return Cr(this, i), gs(this, i);
  }
  /**
  Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
  state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
  can be passed. Unless
  [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
  [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
  are assumed to start in the _current_ document (not the document
  produced by previous specs), and its
  [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
  [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
  to the document created by its _own_ changes. The resulting
  transaction contains the combined effect of all the different
  specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
  specs take precedence over earlier ones.
  */
  update(...e) {
    return sd(this, e, !0);
  }
  /**
  @internal
  */
  applyTransaction(e) {
    let t = this.config, { base: i, compartments: n } = t;
    for (let l of e.effects)
      l.is(eo.reconfigure) ? (t && (n = /* @__PURE__ */ new Map(), t.compartments.forEach((a, h) => n.set(h, a)), t = null), n.set(l.value.compartment, l.value.extension)) : l.is(V.reconfigure) ? (t = null, i = l.value) : l.is(V.appendConfig) && (t = null, i = zi(i).concat(l.value));
    let s;
    t ? s = e.startState.values.slice() : (t = ms.resolve(i, n, this), s = new W(t, this.doc, this.selection, t.dynamicSlots.map(() => null), (a, h) => h.reconfigure(a, this), null).values);
    let o = e.startState.facet(kl) ? e.newSelection : e.newSelection.asSingle();
    new W(t, e.newDoc, o, s, (l, a) => a.update(l, e), e);
  }
  /**
  Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
  replaces every selection range with the given content.
  */
  replaceSelection(e) {
    return typeof e == "string" && (e = this.toText(e)), this.changeByRange((t) => ({
      changes: { from: t.from, to: t.to, insert: e },
      range: v.cursor(t.from + e.length)
    }));
  }
  /**
  Create a set of changes and a new selection by running the given
  function for each range in the active selection. The function
  can return an optional set of changes (in the coordinate space
  of the start document), plus an updated range (in the coordinate
  space of the document produced by the call's own changes). This
  method will merge all the changes and ranges into a single
  changeset and selection, and return it as a [transaction
  spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
  [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
  */
  changeByRange(e) {
    let t = this.selection, i = e(t.ranges[0]), n = this.changes(i.changes), s = [i.range], o = zi(i.effects);
    for (let l = 1; l < t.ranges.length; l++) {
      let a = e(t.ranges[l]), h = this.changes(a.changes), c = h.map(n);
      for (let u = 0; u < l; u++)
        s[u] = s[u].map(c);
      let f = n.mapDesc(h, !0);
      s.push(a.range.map(f)), n = n.compose(c), o = V.mapEffects(o, c).concat(V.mapEffects(zi(a.effects), f));
    }
    return {
      changes: n,
      selection: v.create(s, t.mainIndex),
      effects: o
    };
  }
  /**
  Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
  description, taking the state's document length and line
  separator into account.
  */
  changes(e = []) {
    return e instanceof ye ? e : ye.of(e, this.doc.length, this.facet(W.lineSeparator));
  }
  /**
  Using the state's [line
  separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
  [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
  */
  toText(e) {
    return K.of(e.split(this.facet(W.lineSeparator) || bl));
  }
  /**
  Return the given range of the document as a string.
  */
  sliceDoc(e = 0, t = this.doc.length) {
    return this.doc.sliceString(e, t, this.lineBreak);
  }
  /**
  Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
  */
  facet(e) {
    let t = this.config.address[e.id];
    return t == null ? e.default : (Cr(this, t), gs(this, t));
  }
  /**
  Convert this state to a JSON-serializable object. When custom
  fields should be serialized, you can pass them in as an object
  mapping property names (in the resulting object, which should
  not use `doc` or `selection`) to fields.
  */
  toJSON(e) {
    let t = {
      doc: this.sliceDoc(),
      selection: this.selection.toJSON()
    };
    if (e)
      for (let i in e) {
        let n = e[i];
        n instanceof ge && this.config.address[n.id] != null && (t[i] = n.spec.toJSON(this.field(e[i]), this));
      }
    return t;
  }
  /**
  Deserialize a state from its JSON representation. When custom
  fields should be deserialized, pass the same object you passed
  to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
  third argument.
  */
  static fromJSON(e, t = {}, i) {
    if (!e || typeof e.doc != "string")
      throw new RangeError("Invalid JSON representation for EditorState");
    let n = [];
    if (i) {
      for (let s in i)
        if (Object.prototype.hasOwnProperty.call(e, s)) {
          let o = i[s], l = e[s];
          n.push(o.init((a) => o.spec.fromJSON(l, a)));
        }
    }
    return W.create({
      doc: e.doc,
      selection: v.fromJSON(e.selection),
      extensions: t.extensions ? n.concat([t.extensions]) : n
    });
  }
  /**
  Create a new state. You'll usually only need this when
  initializing an editor—updated states are created by applying
  transactions.
  */
  static create(e = {}) {
    let t = ms.resolve(e.extensions || [], /* @__PURE__ */ new Map()), i = e.doc instanceof K ? e.doc : K.of((e.doc || "").split(t.staticFacet(W.lineSeparator) || bl)), n = e.selection ? e.selection instanceof v ? e.selection : v.single(e.selection.anchor, e.selection.head) : v.single(0);
    return Fu(n, i.length), t.staticFacet(kl) || (n = n.asSingle()), new W(t, i, n, t.dynamicSlots.map(() => null), (s, o) => o.create(s), null);
  }
  /**
  The size (in columns) of a tab in the document, determined by
  the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
  */
  get tabSize() {
    return this.facet(W.tabSize);
  }
  /**
  Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
  string for this state.
  */
  get lineBreak() {
    return this.facet(W.lineSeparator) || `
`;
  }
  /**
  Returns true when the editor is
  [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
  */
  get readOnly() {
    return this.facet(rd);
  }
  /**
  Look up a translation for the given phrase (via the
  [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
  original string if no translation is found.
  
  If additional arguments are passed, they will be inserted in
  place of markers like `$1` (for the first value) and `$2`, etc.
  A single `$` is equivalent to `$1`, and `$$` will produce a
  literal dollar sign.
  */
  phrase(e, ...t) {
    for (let i of this.facet(W.phrases))
      if (Object.prototype.hasOwnProperty.call(i, e)) {
        e = i[e];
        break;
      }
    return t.length && (e = e.replace(/\$(\$|\d*)/g, (i, n) => {
      if (n == "$")
        return "$";
      let s = +(n || 1);
      return !s || s > t.length ? i : t[s - 1];
    })), e;
  }
  /**
  Find the values for a given language data field, provided by the
  the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
  
  Examples of language data fields are...
  
  - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
    comment syntax.
  - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
    for providing language-specific completion sources.
  - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
    characters that should be considered part of words in this
    language.
  - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
    bracket closing behavior.
  */
  languageDataAt(e, t, i = -1) {
    let n = [];
    for (let s of this.facet(Ku))
      for (let o of s(this, t, i))
        Object.prototype.hasOwnProperty.call(o, e) && n.push(o[e]);
    return n;
  }
  /**
  Return a function that can categorize strings (expected to
  represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
  into one of:
  
   - Word (contains an alphanumeric character or a character
     explicitly listed in the local language's `"wordChars"`
     language data, which should be a string)
   - Space (contains only whitespace)
   - Other (anything else)
  */
  charCategorizer(e) {
    return Bg(this.languageDataAt("wordChars", e).join(""));
  }
  /**
  Find the word at the given position, meaning the range
  containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
  around it. If no word characters are adjacent to the position,
  this returns null.
  */
  wordAt(e) {
    let { text: t, from: i, length: n } = this.doc.lineAt(e), s = this.charCategorizer(e), o = e - i, l = e - i;
    for (; o > 0; ) {
      let a = De(t, o, !1);
      if (s(t.slice(a, o)) != Ze.Word)
        break;
      o = a;
    }
    for (; l < n; ) {
      let a = De(t, l);
      if (s(t.slice(l, a)) != Ze.Word)
        break;
      l = a;
    }
    return o == l ? null : v.range(o + i, l + i);
  }
}
W.allowMultipleSelections = kl;
W.tabSize = /* @__PURE__ */ R.define({
  combine: (r) => r.length ? r[0] : 4
});
W.lineSeparator = Ju;
W.readOnly = rd;
W.phrases = /* @__PURE__ */ R.define({
  compare(r, e) {
    let t = Object.keys(r), i = Object.keys(e);
    return t.length == i.length && t.every((n) => r[n] == e[n]);
  }
});
W.languageData = Ku;
W.changeFilter = ed;
W.transactionFilter = td;
W.transactionExtender = id;
eo.reconfigure = /* @__PURE__ */ V.define();
function Yt(r, e, t = {}) {
  let i = {};
  for (let n of r)
    for (let s of Object.keys(n)) {
      let o = n[s], l = i[s];
      if (l === void 0)
        i[s] = o;
      else if (!(l === o || o === void 0)) if (Object.hasOwnProperty.call(t, s))
        i[s] = t[s](l, o);
      else
        throw new Error("Config merge conflict for field " + s);
    }
  for (let n in e)
    i[n] === void 0 && (i[n] = e[n]);
  return i;
}
class oi {
  /**
  Compare this value with another value. Used when comparing
  rangesets. The default implementation compares by identity.
  Unless you are only creating a fixed number of unique instances
  of your value type, it is a good idea to implement this
  properly.
  */
  eq(e) {
    return this == e;
  }
  /**
  Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
  */
  range(e, t = e) {
    return $l.create(e, t, this);
  }
}
oi.prototype.startSide = oi.prototype.endSide = 0;
oi.prototype.point = !1;
oi.prototype.mapMode = ke.TrackDel;
let $l = class od {
  constructor(e, t, i) {
    this.from = e, this.to = t, this.value = i;
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new od(e, t, i);
  }
};
function Pl(r, e) {
  return r.from - e.from || r.value.startSide - e.value.startSide;
}
class Ia {
  constructor(e, t, i, n) {
    this.from = e, this.to = t, this.value = i, this.maxPoint = n;
  }
  get length() {
    return this.to[this.to.length - 1];
  }
  // Find the index of the given position and side. Use the ranges'
  // `from` pos when `end == false`, `to` when `end == true`.
  findIndex(e, t, i, n = 0) {
    let s = i ? this.to : this.from;
    for (let o = n, l = s.length; ; ) {
      if (o == l)
        return o;
      let a = o + l >> 1, h = s[a] - e || (i ? this.value[a].endSide : this.value[a].startSide) - t;
      if (a == o)
        return h >= 0 ? o : l;
      h >= 0 ? l = a : o = a + 1;
    }
  }
  between(e, t, i, n) {
    for (let s = this.findIndex(t, -1e9, !0), o = this.findIndex(i, 1e9, !1, s); s < o; s++)
      if (n(this.from[s] + e, this.to[s] + e, this.value[s]) === !1)
        return !1;
  }
  map(e, t) {
    let i = [], n = [], s = [], o = -1, l = -1;
    for (let a = 0; a < this.value.length; a++) {
      let h = this.value[a], c = this.from[a] + e, f = this.to[a] + e, u, d;
      if (c == f) {
        let p = t.mapPos(c, h.startSide, h.mapMode);
        if (p == null || (u = d = p, h.startSide != h.endSide && (d = t.mapPos(c, h.endSide), d < u)))
          continue;
      } else if (u = t.mapPos(c, h.startSide), d = t.mapPos(f, h.endSide), u > d || u == d && h.startSide > 0 && h.endSide <= 0)
        continue;
      (d - u || h.endSide - h.startSide) < 0 || (o < 0 && (o = u), h.point && (l = Math.max(l, d - u)), i.push(h), n.push(u - o), s.push(d - o));
    }
    return { mapped: i.length ? new Ia(n, s, i, l) : null, pos: o };
  }
}
class H {
  constructor(e, t, i, n) {
    this.chunkPos = e, this.chunk = t, this.nextLayer = i, this.maxPoint = n;
  }
  /**
  @internal
  */
  static create(e, t, i, n) {
    return new H(e, t, i, n);
  }
  /**
  @internal
  */
  get length() {
    let e = this.chunk.length - 1;
    return e < 0 ? 0 : Math.max(this.chunkEnd(e), this.nextLayer.length);
  }
  /**
  The number of ranges in the set.
  */
  get size() {
    if (this.isEmpty)
      return 0;
    let e = this.nextLayer.size;
    for (let t of this.chunk)
      e += t.value.length;
    return e;
  }
  /**
  @internal
  */
  chunkEnd(e) {
    return this.chunkPos[e] + this.chunk[e].length;
  }
  /**
  Update the range set, optionally adding new ranges or filtering
  out existing ones.
  
  (Note: The type parameter is just there as a kludge to work
  around TypeScript variance issues that prevented `RangeSet<X>`
  from being a subtype of `RangeSet<Y>` when `X` is a subtype of
  `Y`.)
  */
  update(e) {
    let { add: t = [], sort: i = !1, filterFrom: n = 0, filterTo: s = this.length } = e, o = e.filter;
    if (t.length == 0 && !o)
      return this;
    if (i && (t = t.slice().sort(Pl)), this.isEmpty)
      return t.length ? H.of(t) : this;
    let l = new ld(this, null, -1).goto(0), a = 0, h = [], c = new _t();
    for (; l.value || a < t.length; )
      if (a < t.length && (l.from - t[a].from || l.startSide - t[a].value.startSide) >= 0) {
        let f = t[a++];
        c.addInner(f.from, f.to, f.value) || h.push(f);
      } else l.rangeIndex == 1 && l.chunkIndex < this.chunk.length && (a == t.length || this.chunkEnd(l.chunkIndex) < t[a].from) && (!o || n > this.chunkEnd(l.chunkIndex) || s < this.chunkPos[l.chunkIndex]) && c.addChunk(this.chunkPos[l.chunkIndex], this.chunk[l.chunkIndex]) ? l.nextChunk() : ((!o || n > l.to || s < l.from || o(l.from, l.to, l.value)) && (c.addInner(l.from, l.to, l.value) || h.push($l.create(l.from, l.to, l.value))), l.next());
    return c.finishInner(this.nextLayer.isEmpty && !h.length ? H.empty : this.nextLayer.update({ add: h, filter: o, filterFrom: n, filterTo: s }));
  }
  /**
  Map this range set through a set of changes, return the new set.
  */
  map(e) {
    if (e.empty || this.isEmpty)
      return this;
    let t = [], i = [], n = -1;
    for (let o = 0; o < this.chunk.length; o++) {
      let l = this.chunkPos[o], a = this.chunk[o], h = e.touchesRange(l, l + a.length);
      if (h === !1)
        n = Math.max(n, a.maxPoint), t.push(a), i.push(e.mapPos(l));
      else if (h === !0) {
        let { mapped: c, pos: f } = a.map(l, e);
        c && (n = Math.max(n, c.maxPoint), t.push(c), i.push(f));
      }
    }
    let s = this.nextLayer.map(e);
    return t.length == 0 ? s : new H(i, t, s || H.empty, n);
  }
  /**
  Iterate over the ranges that touch the region `from` to `to`,
  calling `f` for each. There is no guarantee that the ranges will
  be reported in any specific order. When the callback returns
  `false`, iteration stops.
  */
  between(e, t, i) {
    if (!this.isEmpty) {
      for (let n = 0; n < this.chunk.length; n++) {
        let s = this.chunkPos[n], o = this.chunk[n];
        if (t >= s && e <= s + o.length && o.between(s, e - s, t - s, i) === !1)
          return;
      }
      this.nextLayer.between(e, t, i);
    }
  }
  /**
  Iterate over the ranges in this set, in order, including all
  ranges that end at or after `from`.
  */
  iter(e = 0) {
    return Dr.from([this]).goto(e);
  }
  /**
  @internal
  */
  get isEmpty() {
    return this.nextLayer == this;
  }
  /**
  Iterate over the ranges in a collection of sets, in order,
  starting from `from`.
  */
  static iter(e, t = 0) {
    return Dr.from(e).goto(t);
  }
  /**
  Iterate over two groups of sets, calling methods on `comparator`
  to notify it of possible differences.
  */
  static compare(e, t, i, n, s = -1) {
    let o = e.filter((f) => f.maxPoint > 0 || !f.isEmpty && f.maxPoint >= s), l = t.filter((f) => f.maxPoint > 0 || !f.isEmpty && f.maxPoint >= s), a = Yh(o, l, i), h = new ar(o, a, s), c = new ar(l, a, s);
    i.iterGaps((f, u, d) => Nh(h, f, c, u, d, n)), i.empty && i.length == 0 && Nh(h, 0, c, 0, 0, n);
  }
  /**
  Compare the contents of two groups of range sets, returning true
  if they are equivalent in the given range.
  */
  static eq(e, t, i = 0, n) {
    n == null && (n = 999999999);
    let s = e.filter((c) => !c.isEmpty && t.indexOf(c) < 0), o = t.filter((c) => !c.isEmpty && e.indexOf(c) < 0);
    if (s.length != o.length)
      return !1;
    if (!s.length)
      return !0;
    let l = Yh(s, o), a = new ar(s, l, 0).goto(i), h = new ar(o, l, 0).goto(i);
    for (; ; ) {
      if (a.to != h.to || !Cl(a.active, h.active) || a.point && (!h.point || !a.point.eq(h.point)))
        return !1;
      if (a.to > n)
        return !0;
      a.next(), h.next();
    }
  }
  /**
  Iterate over a group of range sets at the same time, notifying
  the iterator about the ranges covering every given piece of
  content. Returns the open count (see
  [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
  of the iteration.
  */
  static spans(e, t, i, n, s = -1) {
    let o = new ar(e, null, s).goto(t), l = t, a = o.openStart;
    for (; ; ) {
      let h = Math.min(o.to, i);
      if (o.point) {
        let c = o.activeForPoint(o.to), f = o.pointFrom < t ? c.length + 1 : o.point.startSide < 0 ? c.length : Math.min(c.length, a);
        n.point(l, h, o.point, c, f, o.pointRank), a = Math.min(o.openEnd(h), c.length);
      } else h > l && (n.span(l, h, o.active, a), a = o.openEnd(h));
      if (o.to > i)
        return a + (o.point && o.to > i ? 1 : 0);
      l = o.to, o.next();
    }
  }
  /**
  Create a range set for the given range or array of ranges. By
  default, this expects the ranges to be _sorted_ (by start
  position and, if two start at the same position,
  `value.startSide`). You can pass `true` as second argument to
  cause the method to sort them.
  */
  static of(e, t = !1) {
    let i = new _t();
    for (let n of e instanceof $l ? [e] : t ? Ig(e) : e)
      i.add(n.from, n.to, n.value);
    return i.finish();
  }
  /**
  Join an array of range sets into a single set.
  */
  static join(e) {
    if (!e.length)
      return H.empty;
    let t = e[e.length - 1];
    for (let i = e.length - 2; i >= 0; i--)
      for (let n = e[i]; n != H.empty; n = n.nextLayer)
        t = new H(n.chunkPos, n.chunk, t, Math.max(n.maxPoint, t.maxPoint));
    return t;
  }
}
H.empty = /* @__PURE__ */ new H([], [], null, -1);
function Ig(r) {
  if (r.length > 1)
    for (let e = r[0], t = 1; t < r.length; t++) {
      let i = r[t];
      if (Pl(e, i) > 0)
        return r.slice().sort(Pl);
      e = i;
    }
  return r;
}
H.empty.nextLayer = H.empty;
class _t {
  finishChunk(e) {
    this.chunks.push(new Ia(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, e && (this.from = [], this.to = [], this.value = []);
  }
  /**
  Create an empty builder.
  */
  constructor() {
    this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
  }
  /**
  Add a range. Ranges should be added in sorted (by `from` and
  `value.startSide`) order.
  */
  add(e, t, i) {
    this.addInner(e, t, i) || (this.nextLayer || (this.nextLayer = new _t())).add(e, t, i);
  }
  /**
  @internal
  */
  addInner(e, t, i) {
    let n = e - this.lastTo || i.startSide - this.last.endSide;
    if (n <= 0 && (e - this.lastFrom || i.startSide - this.last.startSide) < 0)
      throw new Error("Ranges must be added sorted by `from` position and `startSide`");
    return n < 0 ? !1 : (this.from.length == 250 && this.finishChunk(!0), this.chunkStart < 0 && (this.chunkStart = e), this.from.push(e - this.chunkStart), this.to.push(t - this.chunkStart), this.last = i, this.lastFrom = e, this.lastTo = t, this.value.push(i), i.point && (this.maxPoint = Math.max(this.maxPoint, t - e)), !0);
  }
  /**
  @internal
  */
  addChunk(e, t) {
    if ((e - this.lastTo || t.value[0].startSide - this.last.endSide) < 0)
      return !1;
    this.from.length && this.finishChunk(!0), this.setMaxPoint = Math.max(this.setMaxPoint, t.maxPoint), this.chunks.push(t), this.chunkPos.push(e);
    let i = t.value.length - 1;
    return this.last = t.value[i], this.lastFrom = t.from[i] + e, this.lastTo = t.to[i] + e, !0;
  }
  /**
  Finish the range set. Returns the new set. The builder can't be
  used anymore after this has been called.
  */
  finish() {
    return this.finishInner(H.empty);
  }
  /**
  @internal
  */
  finishInner(e) {
    if (this.from.length && this.finishChunk(!1), this.chunks.length == 0)
      return e;
    let t = H.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(e) : e, this.setMaxPoint);
    return this.from = null, t;
  }
}
function Yh(r, e, t) {
  let i = /* @__PURE__ */ new Map();
  for (let s of r)
    for (let o = 0; o < s.chunk.length; o++)
      s.chunk[o].maxPoint <= 0 && i.set(s.chunk[o], s.chunkPos[o]);
  let n = /* @__PURE__ */ new Set();
  for (let s of e)
    for (let o = 0; o < s.chunk.length; o++) {
      let l = i.get(s.chunk[o]);
      l != null && (t ? t.mapPos(l) : l) == s.chunkPos[o] && !t?.touchesRange(l, l + s.chunk[o].length) && n.add(s.chunk[o]);
    }
  return n;
}
class ld {
  constructor(e, t, i, n = 0) {
    this.layer = e, this.skip = t, this.minPoint = i, this.rank = n;
  }
  get startSide() {
    return this.value ? this.value.startSide : 0;
  }
  get endSide() {
    return this.value ? this.value.endSide : 0;
  }
  goto(e, t = -1e9) {
    return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(e, t, !1), this;
  }
  gotoInner(e, t, i) {
    for (; this.chunkIndex < this.layer.chunk.length; ) {
      let n = this.layer.chunk[this.chunkIndex];
      if (!(this.skip && this.skip.has(n) || this.layer.chunkEnd(this.chunkIndex) < e || n.maxPoint < this.minPoint))
        break;
      this.chunkIndex++, i = !1;
    }
    if (this.chunkIndex < this.layer.chunk.length) {
      let n = this.layer.chunk[this.chunkIndex].findIndex(e - this.layer.chunkPos[this.chunkIndex], t, !0);
      (!i || this.rangeIndex < n) && this.setRangeIndex(n);
    }
    this.next();
  }
  forward(e, t) {
    (this.to - e || this.endSide - t) < 0 && this.gotoInner(e, t, !0);
  }
  next() {
    for (; ; )
      if (this.chunkIndex == this.layer.chunk.length) {
        this.from = this.to = 1e9, this.value = null;
        break;
      } else {
        let e = this.layer.chunkPos[this.chunkIndex], t = this.layer.chunk[this.chunkIndex], i = e + t.from[this.rangeIndex];
        if (this.from = i, this.to = e + t.to[this.rangeIndex], this.value = t.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
          break;
      }
  }
  setRangeIndex(e) {
    if (e == this.layer.chunk[this.chunkIndex].value.length) {
      if (this.chunkIndex++, this.skip)
        for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
          this.chunkIndex++;
      this.rangeIndex = 0;
    } else
      this.rangeIndex = e;
  }
  nextChunk() {
    this.chunkIndex++, this.rangeIndex = 0, this.next();
  }
  compare(e) {
    return this.from - e.from || this.startSide - e.startSide || this.rank - e.rank || this.to - e.to || this.endSide - e.endSide;
  }
}
class Dr {
  constructor(e) {
    this.heap = e;
  }
  static from(e, t = null, i = -1) {
    let n = [];
    for (let s = 0; s < e.length; s++)
      for (let o = e[s]; !o.isEmpty; o = o.nextLayer)
        o.maxPoint >= i && n.push(new ld(o, t, i, s));
    return n.length == 1 ? n[0] : new Dr(n);
  }
  get startSide() {
    return this.value ? this.value.startSide : 0;
  }
  goto(e, t = -1e9) {
    for (let i of this.heap)
      i.goto(e, t);
    for (let i = this.heap.length >> 1; i >= 0; i--)
      wo(this.heap, i);
    return this.next(), this;
  }
  forward(e, t) {
    for (let i of this.heap)
      i.forward(e, t);
    for (let i = this.heap.length >> 1; i >= 0; i--)
      wo(this.heap, i);
    (this.to - e || this.value.endSide - t) < 0 && this.next();
  }
  next() {
    if (this.heap.length == 0)
      this.from = this.to = 1e9, this.value = null, this.rank = -1;
    else {
      let e = this.heap[0];
      this.from = e.from, this.to = e.to, this.value = e.value, this.rank = e.rank, e.value && e.next(), wo(this.heap, 0);
    }
  }
}
function wo(r, e) {
  for (let t = r[e]; ; ) {
    let i = (e << 1) + 1;
    if (i >= r.length)
      break;
    let n = r[i];
    if (i + 1 < r.length && n.compare(r[i + 1]) >= 0 && (n = r[i + 1], i++), t.compare(n) < 0)
      break;
    r[i] = t, r[e] = n, e = i;
  }
}
class ar {
  constructor(e, t, i) {
    this.minPoint = i, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = Dr.from(e, t, i);
  }
  goto(e, t = -1e9) {
    return this.cursor.goto(e, t), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = e, this.endSide = t, this.openStart = -1, this.next(), this;
  }
  forward(e, t) {
    for (; this.minActive > -1 && (this.activeTo[this.minActive] - e || this.active[this.minActive].endSide - t) < 0; )
      this.removeActive(this.minActive);
    this.cursor.forward(e, t);
  }
  removeActive(e) {
    yn(this.active, e), yn(this.activeTo, e), yn(this.activeRank, e), this.minActive = Wh(this.active, this.activeTo);
  }
  addActive(e) {
    let t = 0, { value: i, to: n, rank: s } = this.cursor;
    for (; t < this.activeRank.length && (s - this.activeRank[t] || n - this.activeTo[t]) > 0; )
      t++;
    Sn(this.active, t, i), Sn(this.activeTo, t, n), Sn(this.activeRank, t, s), e && Sn(e, t, this.cursor.from), this.minActive = Wh(this.active, this.activeTo);
  }
  // After calling this, if `this.point` != null, the next range is a
  // point. Otherwise, it's a regular range, covered by `this.active`.
  next() {
    let e = this.to, t = this.point;
    this.point = null;
    let i = this.openStart < 0 ? [] : null;
    for (; ; ) {
      let n = this.minActive;
      if (n > -1 && (this.activeTo[n] - this.cursor.from || this.active[n].endSide - this.cursor.startSide) < 0) {
        if (this.activeTo[n] > e) {
          this.to = this.activeTo[n], this.endSide = this.active[n].endSide;
          break;
        }
        this.removeActive(n), i && yn(i, n);
      } else if (this.cursor.value)
        if (this.cursor.from > e) {
          this.to = this.cursor.from, this.endSide = this.cursor.startSide;
          break;
        } else {
          let s = this.cursor.value;
          if (!s.point)
            this.addActive(i), this.cursor.next();
          else if (t && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
            this.cursor.next();
          else {
            this.point = s, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = s.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
            break;
          }
        }
      else {
        this.to = this.endSide = 1e9;
        break;
      }
    }
    if (i) {
      this.openStart = 0;
      for (let n = i.length - 1; n >= 0 && i[n] < e; n--)
        this.openStart++;
    }
  }
  activeForPoint(e) {
    if (!this.active.length)
      return this.active;
    let t = [];
    for (let i = this.active.length - 1; i >= 0 && !(this.activeRank[i] < this.pointRank); i--)
      (this.activeTo[i] > e || this.activeTo[i] == e && this.active[i].endSide >= this.point.endSide) && t.push(this.active[i]);
    return t.reverse();
  }
  openEnd(e) {
    let t = 0;
    for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > e; i--)
      t++;
    return t;
  }
}
function Nh(r, e, t, i, n, s) {
  r.goto(e), t.goto(i);
  let o = i + n, l = i, a = i - e;
  for (; ; ) {
    let h = r.to + a - t.to, c = h || r.endSide - t.endSide, f = c < 0 ? r.to + a : t.to, u = Math.min(f, o);
    if (r.point || t.point ? r.point && t.point && (r.point == t.point || r.point.eq(t.point)) && Cl(r.activeForPoint(r.to), t.activeForPoint(t.to)) || s.comparePoint(l, u, r.point, t.point) : u > l && !Cl(r.active, t.active) && s.compareRange(l, u, r.active, t.active), f > o)
      break;
    (h || r.openEnd != t.openEnd) && s.boundChange && s.boundChange(f), l = f, c <= 0 && r.next(), c >= 0 && t.next();
  }
}
function Cl(r, e) {
  if (r.length != e.length)
    return !1;
  for (let t = 0; t < r.length; t++)
    if (r[t] != e[t] && !r[t].eq(e[t]))
      return !1;
  return !0;
}
function yn(r, e) {
  for (let t = e, i = r.length - 1; t < i; t++)
    r[t] = r[t + 1];
  r.pop();
}
function Sn(r, e, t) {
  for (let i = r.length - 1; i >= e; i--)
    r[i + 1] = r[i];
  r[e] = t;
}
function Wh(r, e) {
  let t = -1, i = 1e9;
  for (let n = 0; n < e.length; n++)
    (e[n] - i || r[n].endSide - r[t].endSide) < 0 && (t = n, i = e[n]);
  return t;
}
function lt(r, e, t = r.length) {
  let i = 0;
  for (let n = 0; n < t && n < r.length; )
    r.charCodeAt(n) == 9 ? (i += e - i % e, n++) : (i++, n = De(r, n));
  return i;
}
function Tl(r, e, t, i) {
  for (let n = 0, s = 0; ; ) {
    if (s >= e)
      return n;
    if (n == r.length)
      break;
    s += r.charCodeAt(n) == 9 ? t - s % t : 1, n = De(r, n);
  }
  return i === !0 ? -1 : r.length;
}
const Al = "ͼ", jh = typeof Symbol > "u" ? "__" + Al : Symbol.for(Al), Ml = typeof Symbol > "u" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet"), Gh = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : {};
class Pt {
  // :: (Object<Style>, ?{finish: ?(string) → string})
  // Create a style module from the given spec.
  //
  // When `finish` is given, it is called on regular (non-`@`)
  // selectors (after `&` expansion) to compute the final selector.
  constructor(e, t) {
    this.rules = [];
    let { finish: i } = t || {};
    function n(o) {
      return /^@/.test(o) ? [o] : o.split(/,\s*/);
    }
    function s(o, l, a, h) {
      let c = [], f = /^@(\w+)\b/.exec(o[0]), u = f && f[1] == "keyframes";
      if (f && l == null) return a.push(o[0] + ";");
      for (let d in l) {
        let p = l[d];
        if (/&/.test(d))
          s(
            d.split(/,\s*/).map((O) => o.map((g) => O.replace(/&/, g))).reduce((O, g) => O.concat(g)),
            p,
            a
          );
        else if (p && typeof p == "object") {
          if (!f) throw new RangeError("The value of a property (" + d + ") should be a primitive value.");
          s(n(d), p, c, u);
        } else p != null && c.push(d.replace(/_.*/, "").replace(/[A-Z]/g, (O) => "-" + O.toLowerCase()) + ": " + p + ";");
      }
      (c.length || u) && a.push((i && !f && !h ? o.map(i) : o).join(", ") + " {" + c.join(" ") + "}");
    }
    for (let o in e) s(n(o), e[o], this.rules);
  }
  // :: () → string
  // Returns a string containing the module's CSS rules.
  getRules() {
    return this.rules.join(`
`);
  }
  // :: () → string
  // Generate a new unique CSS class name.
  static newName() {
    let e = Gh[jh] || 1;
    return Gh[jh] = e + 1, Al + e.toString(36);
  }
  // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
  //
  // Mount the given set of modules in the given DOM root, which ensures
  // that the CSS rules defined by the module are available in that
  // context.
  //
  // Rules are only added to the document once per root.
  //
  // Rule order will follow the order of the modules, so that rules from
  // modules later in the array take precedence of those from earlier
  // modules. If you call this function multiple times for the same root
  // in a way that changes the order of already mounted modules, the old
  // order will be changed.
  //
  // If a Content Security Policy nonce is provided, it is added to
  // the `<style>` tag generated by the library.
  static mount(e, t, i) {
    let n = e[Ml], s = i && i.nonce;
    n ? s && n.setNonce(s) : n = new Vg(e, s), n.mount(Array.isArray(t) ? t : [t], e);
  }
}
let Uh = /* @__PURE__ */ new Map();
class Vg {
  constructor(e, t) {
    let i = e.ownerDocument || e, n = i.defaultView;
    if (!e.head && e.adoptedStyleSheets && n.CSSStyleSheet) {
      let s = Uh.get(i);
      if (s) return e[Ml] = s;
      this.sheet = new n.CSSStyleSheet(), Uh.set(i, this);
    } else
      this.styleTag = i.createElement("style"), t && this.styleTag.setAttribute("nonce", t);
    this.modules = [], e[Ml] = this;
  }
  mount(e, t) {
    let i = this.sheet, n = 0, s = 0;
    for (let o = 0; o < e.length; o++) {
      let l = e[o], a = this.modules.indexOf(l);
      if (a < s && a > -1 && (this.modules.splice(a, 1), s--, a = -1), a == -1) {
        if (this.modules.splice(s++, 0, l), i) for (let h = 0; h < l.rules.length; h++)
          i.insertRule(l.rules[h], n++);
      } else {
        for (; s < a; ) n += this.modules[s++].rules.length;
        n += l.rules.length, s++;
      }
    }
    if (i)
      t.adoptedStyleSheets.indexOf(this.sheet) < 0 && (t.adoptedStyleSheets = [this.sheet, ...t.adoptedStyleSheets]);
    else {
      let o = "";
      for (let a = 0; a < this.modules.length; a++)
        o += this.modules[a].getRules() + `
`;
      this.styleTag.textContent = o;
      let l = t.head || t;
      this.styleTag.parentNode != l && l.insertBefore(this.styleTag, l.firstChild);
    }
  }
  setNonce(e) {
    this.styleTag && this.styleTag.getAttribute("nonce") != e && this.styleTag.setAttribute("nonce", e);
  }
}
var li = {
  8: "Backspace",
  9: "Tab",
  10: "Enter",
  12: "NumLock",
  13: "Enter",
  16: "Shift",
  17: "Control",
  18: "Alt",
  20: "CapsLock",
  27: "Escape",
  32: " ",
  33: "PageUp",
  34: "PageDown",
  35: "End",
  36: "Home",
  37: "ArrowLeft",
  38: "ArrowUp",
  39: "ArrowRight",
  40: "ArrowDown",
  44: "PrintScreen",
  45: "Insert",
  46: "Delete",
  59: ";",
  61: "=",
  91: "Meta",
  92: "Meta",
  106: "*",
  107: "+",
  108: ",",
  109: "-",
  110: ".",
  111: "/",
  144: "NumLock",
  145: "ScrollLock",
  160: "Shift",
  161: "Shift",
  162: "Control",
  163: "Control",
  164: "Alt",
  165: "Alt",
  173: "-",
  186: ";",
  187: "=",
  188: ",",
  189: "-",
  190: ".",
  191: "/",
  192: "`",
  219: "[",
  220: "\\",
  221: "]",
  222: "'"
}, _r = {
  48: ")",
  49: "!",
  50: "@",
  51: "#",
  52: "$",
  53: "%",
  54: "^",
  55: "&",
  56: "*",
  57: "(",
  59: ":",
  61: "+",
  173: "_",
  186: ":",
  187: "+",
  188: "<",
  189: "_",
  190: ">",
  191: "?",
  192: "~",
  219: "{",
  220: "|",
  221: "}",
  222: '"'
}, qg = typeof navigator < "u" && /Mac/.test(navigator.platform), Yg = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
for (var xe = 0; xe < 10; xe++) li[48 + xe] = li[96 + xe] = String(xe);
for (var xe = 1; xe <= 24; xe++) li[xe + 111] = "F" + xe;
for (var xe = 65; xe <= 90; xe++)
  li[xe] = String.fromCharCode(xe + 32), _r[xe] = String.fromCharCode(xe);
for (var xo in li) _r.hasOwnProperty(xo) || (_r[xo] = li[xo]);
function Ng(r) {
  var e = qg && r.metaKey && r.shiftKey && !r.ctrlKey && !r.altKey || Yg && r.shiftKey && r.key && r.key.length == 1 || r.key == "Unidentified", t = !e && r.key || (r.shiftKey ? _r : li)[r.keyCode] || r.key || "Unidentified";
  return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t;
}
function fe() {
  var r = arguments[0];
  typeof r == "string" && (r = document.createElement(r));
  var e = 1, t = arguments[1];
  if (t && typeof t == "object" && t.nodeType == null && !Array.isArray(t)) {
    for (var i in t) if (Object.prototype.hasOwnProperty.call(t, i)) {
      var n = t[i];
      typeof n == "string" ? r.setAttribute(i, n) : n != null && (r[i] = n);
    }
    e++;
  }
  for (; e < arguments.length; e++) ad(r, arguments[e]);
  return r;
}
function ad(r, e) {
  if (typeof e == "string")
    r.appendChild(document.createTextNode(e));
  else if (e != null) if (e.nodeType != null)
    r.appendChild(e);
  else if (Array.isArray(e))
    for (var t = 0; t < e.length; t++) ad(r, e[t]);
  else
    throw new RangeError("Unsupported child node: " + e);
}
let Me = typeof navigator < "u" ? navigator : { userAgent: "", vendor: "", platform: "" }, Zl = typeof document < "u" ? document : { documentElement: { style: {} } };
const Xl = /* @__PURE__ */ /Edge\/(\d+)/.exec(Me.userAgent), hd = /* @__PURE__ */ /MSIE \d/.test(Me.userAgent), Rl = /* @__PURE__ */ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Me.userAgent), to = !!(hd || Rl || Xl), Fh = !to && /* @__PURE__ */ /gecko\/(\d+)/i.test(Me.userAgent), ko = !to && /* @__PURE__ */ /Chrome\/(\d+)/.exec(Me.userAgent), Wg = "webkitFontSmoothing" in Zl.documentElement.style, Ll = !to && /* @__PURE__ */ /Apple Computer/.test(Me.vendor), Hh = Ll && (/* @__PURE__ */ /Mobile\/\w+/.test(Me.userAgent) || Me.maxTouchPoints > 2);
var E = {
  mac: Hh || /* @__PURE__ */ /Mac/.test(Me.platform),
  windows: /* @__PURE__ */ /Win/.test(Me.platform),
  linux: /* @__PURE__ */ /Linux|X11/.test(Me.platform),
  ie: to,
  ie_version: hd ? Zl.documentMode || 6 : Rl ? +Rl[1] : Xl ? +Xl[1] : 0,
  gecko: Fh,
  gecko_version: Fh ? +(/* @__PURE__ */ /Firefox\/(\d+)/.exec(Me.userAgent) || [0, 0])[1] : 0,
  chrome: !!ko,
  chrome_version: ko ? +ko[1] : 0,
  ios: Hh,
  android: /* @__PURE__ */ /Android\b/.test(Me.userAgent),
  webkit_version: Wg ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(Me.userAgent) || [0, 0])[1] : 0,
  safari: Ll,
  safari_version: Ll ? +(/* @__PURE__ */ /\bVersion\/(\d+(\.\d+)?)/.exec(Me.userAgent) || [0, 0])[1] : 0,
  tabSize: Zl.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
};
function Br(r) {
  let e;
  return r.nodeType == 11 ? e = r.getSelection ? r : r.ownerDocument : e = r, e.getSelection();
}
function El(r, e) {
  return e ? r == e || r.contains(e.nodeType != 1 ? e.parentNode : e) : !1;
}
function Kn(r, e) {
  if (!e.anchorNode)
    return !1;
  try {
    return El(r, e.anchorNode);
  } catch {
    return !1;
  }
}
function Ir(r) {
  return r.nodeType == 3 ? $i(r, 0, r.nodeValue.length).getClientRects() : r.nodeType == 1 ? r.getClientRects() : [];
}
function Tr(r, e, t, i) {
  return t ? Kh(r, e, t, i, -1) || Kh(r, e, t, i, 1) : !1;
}
function vi(r) {
  for (var e = 0; ; e++)
    if (r = r.previousSibling, !r)
      return e;
}
function bs(r) {
  return r.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName);
}
function Kh(r, e, t, i, n) {
  for (; ; ) {
    if (r == t && e == i)
      return !0;
    if (e == (n < 0 ? 0 : Ct(r))) {
      if (r.nodeName == "DIV")
        return !1;
      let s = r.parentNode;
      if (!s || s.nodeType != 1)
        return !1;
      e = vi(r) + (n < 0 ? 0 : 1), r = s;
    } else if (r.nodeType == 1) {
      if (r = r.childNodes[e + (n < 0 ? -1 : 0)], r.nodeType == 1 && r.contentEditable == "false")
        return !1;
      e = n < 0 ? Ct(r) : 0;
    } else
      return !1;
  }
}
function Ct(r) {
  return r.nodeType == 3 ? r.nodeValue.length : r.childNodes.length;
}
function io(r, e) {
  let t = e ? r.left : r.right;
  return { left: t, right: t, top: r.top, bottom: r.bottom };
}
function jg(r) {
  let e = r.visualViewport;
  return e ? {
    left: 0,
    right: e.width,
    top: 0,
    bottom: e.height
  } : {
    left: 0,
    right: r.innerWidth,
    top: 0,
    bottom: r.innerHeight
  };
}
function cd(r, e) {
  let t = e.width / r.offsetWidth, i = e.height / r.offsetHeight;
  return (t > 0.995 && t < 1.005 || !isFinite(t) || Math.abs(e.width - r.offsetWidth) < 1) && (t = 1), (i > 0.995 && i < 1.005 || !isFinite(i) || Math.abs(e.height - r.offsetHeight) < 1) && (i = 1), { scaleX: t, scaleY: i };
}
function Gg(r, e, t, i, n, s, o, l) {
  let a = r.ownerDocument, h = a.defaultView || window;
  for (let c = r, f = !1; c && !f; )
    if (c.nodeType == 1) {
      let u, d = c == a.body, p = 1, O = 1;
      if (d)
        u = jg(h);
      else {
        if (/^(fixed|sticky)$/.test(getComputedStyle(c).position) && (f = !0), c.scrollHeight <= c.clientHeight && c.scrollWidth <= c.clientWidth) {
          c = c.assignedSlot || c.parentNode;
          continue;
        }
        let w = c.getBoundingClientRect();
        ({ scaleX: p, scaleY: O } = cd(c, w)), u = {
          left: w.left,
          right: w.left + c.clientWidth * p,
          top: w.top,
          bottom: w.top + c.clientHeight * O
        };
      }
      let g = 0, b = 0;
      if (n == "nearest")
        e.top < u.top ? (b = e.top - (u.top + o), t > 0 && e.bottom > u.bottom + b && (b = e.bottom - u.bottom + o)) : e.bottom > u.bottom && (b = e.bottom - u.bottom + o, t < 0 && e.top - b < u.top && (b = e.top - (u.top + o)));
      else {
        let w = e.bottom - e.top, k = u.bottom - u.top;
        b = (n == "center" && w <= k ? e.top + w / 2 - k / 2 : n == "start" || n == "center" && t < 0 ? e.top - o : e.bottom - k + o) - u.top;
      }
      if (i == "nearest" ? e.left < u.left ? (g = e.left - (u.left + s), t > 0 && e.right > u.right + g && (g = e.right - u.right + s)) : e.right > u.right && (g = e.right - u.right + s, t < 0 && e.left < u.left + g && (g = e.left - (u.left + s))) : g = (i == "center" ? e.left + (e.right - e.left) / 2 - (u.right - u.left) / 2 : i == "start" == l ? e.left - s : e.right - (u.right - u.left) + s) - u.left, g || b)
        if (d)
          h.scrollBy(g, b);
        else {
          let w = 0, k = 0;
          if (b) {
            let x = c.scrollTop;
            c.scrollTop += b / O, k = (c.scrollTop - x) * O;
          }
          if (g) {
            let x = c.scrollLeft;
            c.scrollLeft += g / p, w = (c.scrollLeft - x) * p;
          }
          e = {
            left: e.left - w,
            top: e.top - k,
            right: e.right - w,
            bottom: e.bottom - k
          }, w && Math.abs(w - g) < 1 && (i = "nearest"), k && Math.abs(k - b) < 1 && (n = "nearest");
        }
      if (d)
        break;
      (e.top < u.top || e.bottom > u.bottom || e.left < u.left || e.right > u.right) && (e = {
        left: Math.max(e.left, u.left),
        right: Math.min(e.right, u.right),
        top: Math.max(e.top, u.top),
        bottom: Math.min(e.bottom, u.bottom)
      }), c = c.assignedSlot || c.parentNode;
    } else if (c.nodeType == 11)
      c = c.host;
    else
      break;
}
function Ug(r) {
  let e = r.ownerDocument, t, i;
  for (let n = r.parentNode; n && !(n == e.body || t && i); )
    if (n.nodeType == 1)
      !i && n.scrollHeight > n.clientHeight && (i = n), !t && n.scrollWidth > n.clientWidth && (t = n), n = n.assignedSlot || n.parentNode;
    else if (n.nodeType == 11)
      n = n.host;
    else
      break;
  return { x: t, y: i };
}
class Fg {
  constructor() {
    this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
  }
  eq(e) {
    return this.anchorNode == e.anchorNode && this.anchorOffset == e.anchorOffset && this.focusNode == e.focusNode && this.focusOffset == e.focusOffset;
  }
  setRange(e) {
    let { anchorNode: t, focusNode: i } = e;
    this.set(t, Math.min(e.anchorOffset, t ? Ct(t) : 0), i, Math.min(e.focusOffset, i ? Ct(i) : 0));
  }
  set(e, t, i, n) {
    this.anchorNode = e, this.anchorOffset = t, this.focusNode = i, this.focusOffset = n;
  }
}
let bi = null;
E.safari && E.safari_version >= 26 && (bi = !1);
function fd(r) {
  if (r.setActive)
    return r.setActive();
  if (bi)
    return r.focus(bi);
  let e = [];
  for (let t = r; t && (e.push(t, t.scrollTop, t.scrollLeft), t != t.ownerDocument); t = t.parentNode)
    ;
  if (r.focus(bi == null ? {
    get preventScroll() {
      return bi = { preventScroll: !0 }, !0;
    }
  } : void 0), !bi) {
    bi = !1;
    for (let t = 0; t < e.length; ) {
      let i = e[t++], n = e[t++], s = e[t++];
      i.scrollTop != n && (i.scrollTop = n), i.scrollLeft != s && (i.scrollLeft = s);
    }
  }
}
let Jh;
function $i(r, e, t = e) {
  let i = Jh || (Jh = document.createRange());
  return i.setEnd(r, t), i.setStart(r, e), i;
}
function Di(r, e, t, i) {
  let n = { key: e, code: e, keyCode: t, which: t, cancelable: !0 };
  i && ({ altKey: n.altKey, ctrlKey: n.ctrlKey, shiftKey: n.shiftKey, metaKey: n.metaKey } = i);
  let s = new KeyboardEvent("keydown", n);
  s.synthetic = !0, r.dispatchEvent(s);
  let o = new KeyboardEvent("keyup", n);
  return o.synthetic = !0, r.dispatchEvent(o), s.defaultPrevented || o.defaultPrevented;
}
function Hg(r) {
  for (; r; ) {
    if (r && (r.nodeType == 9 || r.nodeType == 11 && r.host))
      return r;
    r = r.assignedSlot || r.parentNode;
  }
  return null;
}
function ud(r) {
  for (; r.attributes.length; )
    r.removeAttributeNode(r.attributes[0]);
}
function Kg(r, e) {
  let t = e.focusNode, i = e.focusOffset;
  if (!t || e.anchorNode != t || e.anchorOffset != i)
    return !1;
  for (i = Math.min(i, Ct(t)); ; )
    if (i) {
      if (t.nodeType != 1)
        return !1;
      let n = t.childNodes[i - 1];
      n.contentEditable == "false" ? i-- : (t = n, i = Ct(t));
    } else {
      if (t == r)
        return !0;
      i = vi(t), t = t.parentNode;
    }
}
function dd(r) {
  return r.scrollTop > Math.max(1, r.scrollHeight - r.clientHeight - 4);
}
function pd(r, e) {
  for (let t = r, i = e; ; ) {
    if (t.nodeType == 3 && i > 0)
      return { node: t, offset: i };
    if (t.nodeType == 1 && i > 0) {
      if (t.contentEditable == "false")
        return null;
      t = t.childNodes[i - 1], i = Ct(t);
    } else if (t.parentNode && !bs(t))
      i = vi(t), t = t.parentNode;
    else
      return null;
  }
}
function Od(r, e) {
  for (let t = r, i = e; ; ) {
    if (t.nodeType == 3 && i < t.nodeValue.length)
      return { node: t, offset: i };
    if (t.nodeType == 1 && i < t.childNodes.length) {
      if (t.contentEditable == "false")
        return null;
      t = t.childNodes[i], i = 0;
    } else if (t.parentNode && !bs(t))
      i = vi(t) + 1, t = t.parentNode;
    else
      return null;
  }
}
class Te {
  constructor(e, t, i = !0) {
    this.node = e, this.offset = t, this.precise = i;
  }
  static before(e, t) {
    return new Te(e.parentNode, vi(e), t);
  }
  static after(e, t) {
    return new Te(e.parentNode, vi(e) + 1, t);
  }
}
const Va = [];
class ne {
  constructor() {
    this.parent = null, this.dom = null, this.flags = 2;
  }
  get overrideDOMText() {
    return null;
  }
  get posAtStart() {
    return this.parent ? this.parent.posBefore(this) : 0;
  }
  get posAtEnd() {
    return this.posAtStart + this.length;
  }
  posBefore(e) {
    let t = this.posAtStart;
    for (let i of this.children) {
      if (i == e)
        return t;
      t += i.length + i.breakAfter;
    }
    throw new RangeError("Invalid child in posBefore");
  }
  posAfter(e) {
    return this.posBefore(e) + e.length;
  }
  sync(e, t) {
    if (this.flags & 2) {
      let i = this.dom, n = null, s;
      for (let o of this.children) {
        if (o.flags & 7) {
          if (!o.dom && (s = n ? n.nextSibling : i.firstChild)) {
            let l = ne.get(s);
            (!l || !l.parent && l.canReuseDOM(o)) && o.reuseDOM(s);
          }
          o.sync(e, t), o.flags &= -8;
        }
        if (s = n ? n.nextSibling : i.firstChild, t && !t.written && t.node == i && s != o.dom && (t.written = !0), o.dom.parentNode == i)
          for (; s && s != o.dom; )
            s = ec(s);
        else
          i.insertBefore(o.dom, s);
        n = o.dom;
      }
      for (s = n ? n.nextSibling : i.firstChild, s && t && t.node == i && (t.written = !0); s; )
        s = ec(s);
    } else if (this.flags & 1)
      for (let i of this.children)
        i.flags & 7 && (i.sync(e, t), i.flags &= -8);
  }
  reuseDOM(e) {
  }
  localPosFromDOM(e, t) {
    let i;
    if (e == this.dom)
      i = this.dom.childNodes[t];
    else {
      let n = Ct(e) == 0 ? 0 : t == 0 ? -1 : 1;
      for (; ; ) {
        let s = e.parentNode;
        if (s == this.dom)
          break;
        n == 0 && s.firstChild != s.lastChild && (e == s.firstChild ? n = -1 : n = 1), e = s;
      }
      n < 0 ? i = e : i = e.nextSibling;
    }
    if (i == this.dom.firstChild)
      return 0;
    for (; i && !ne.get(i); )
      i = i.nextSibling;
    if (!i)
      return this.length;
    for (let n = 0, s = 0; ; n++) {
      let o = this.children[n];
      if (o.dom == i)
        return s;
      s += o.length + o.breakAfter;
    }
  }
  domBoundsAround(e, t, i = 0) {
    let n = -1, s = -1, o = -1, l = -1;
    for (let a = 0, h = i, c = i; a < this.children.length; a++) {
      let f = this.children[a], u = h + f.length;
      if (h < e && u > t)
        return f.domBoundsAround(e, t, h);
      if (u >= e && n == -1 && (n = a, s = h), h > t && f.dom.parentNode == this.dom) {
        o = a, l = c;
        break;
      }
      c = u, h = u + f.breakAfter;
    }
    return {
      from: s,
      to: l < 0 ? i + this.length : l,
      startDOM: (n ? this.children[n - 1].dom.nextSibling : null) || this.dom.firstChild,
      endDOM: o < this.children.length && o >= 0 ? this.children[o].dom : null
    };
  }
  markDirty(e = !1) {
    this.flags |= 2, this.markParentsDirty(e);
  }
  markParentsDirty(e) {
    for (let t = this.parent; t; t = t.parent) {
      if (e && (t.flags |= 2), t.flags & 1)
        return;
      t.flags |= 1, e = !1;
    }
  }
  setParent(e) {
    this.parent != e && (this.parent = e, this.flags & 7 && this.markParentsDirty(!0));
  }
  setDOM(e) {
    this.dom != e && (this.dom && (this.dom.cmView = null), this.dom = e, e.cmView = this);
  }
  get rootView() {
    for (let e = this; ; ) {
      let t = e.parent;
      if (!t)
        return e;
      e = t;
    }
  }
  replaceChildren(e, t, i = Va) {
    this.markDirty();
    for (let n = e; n < t; n++) {
      let s = this.children[n];
      s.parent == this && i.indexOf(s) < 0 && s.destroy();
    }
    i.length < 250 ? this.children.splice(e, t - e, ...i) : this.children = [].concat(this.children.slice(0, e), i, this.children.slice(t));
    for (let n = 0; n < i.length; n++)
      i[n].setParent(this);
  }
  ignoreMutation(e) {
    return !1;
  }
  ignoreEvent(e) {
    return !1;
  }
  childCursor(e = this.length) {
    return new md(this.children, e, this.children.length);
  }
  childPos(e, t = 1) {
    return this.childCursor().findPos(e, t);
  }
  toString() {
    let e = this.constructor.name.replace("View", "");
    return e + (this.children.length ? "(" + this.children.join() + ")" : this.length ? "[" + (e == "Text" ? this.text : this.length) + "]" : "") + (this.breakAfter ? "#" : "");
  }
  static get(e) {
    return e.cmView;
  }
  get isEditable() {
    return !0;
  }
  get isWidget() {
    return !1;
  }
  get isHidden() {
    return !1;
  }
  merge(e, t, i, n, s, o) {
    return !1;
  }
  become(e) {
    return !1;
  }
  canReuseDOM(e) {
    return e.constructor == this.constructor && !((this.flags | e.flags) & 8);
  }
  // When this is a zero-length view with a side, this should return a
  // number <= 0 to indicate it is before its position, or a
  // number > 0 when after its position.
  getSide() {
    return 0;
  }
  destroy() {
    for (let e of this.children)
      e.parent == this && e.destroy();
    this.parent = null;
  }
}
ne.prototype.breakAfter = 0;
function ec(r) {
  let e = r.nextSibling;
  return r.parentNode.removeChild(r), e;
}
class md {
  constructor(e, t, i) {
    this.children = e, this.pos = t, this.i = i, this.off = 0;
  }
  findPos(e, t = 1) {
    for (; ; ) {
      if (e > this.pos || e == this.pos && (t > 0 || this.i == 0 || this.children[this.i - 1].breakAfter))
        return this.off = e - this.pos, this;
      let i = this.children[--this.i];
      this.pos -= i.length + i.breakAfter;
    }
  }
}
function gd(r, e, t, i, n, s, o, l, a) {
  let { children: h } = r, c = h.length ? h[e] : null, f = s.length ? s[s.length - 1] : null, u = f ? f.breakAfter : o;
  if (!(e == i && c && !o && !u && s.length < 2 && c.merge(t, n, s.length ? f : null, t == 0, l, a))) {
    if (i < h.length) {
      let d = h[i];
      d && (n < d.length || d.breakAfter && f?.breakAfter) ? (e == i && (d = d.split(n), n = 0), !u && f && d.merge(0, n, f, !0, 0, a) ? s[s.length - 1] = d : ((n || d.children.length && !d.children[0].length) && d.merge(0, n, null, !1, 0, a), s.push(d))) : d?.breakAfter && (f ? f.breakAfter = 1 : o = 1), i++;
    }
    for (c && (c.breakAfter = o, t > 0 && (!o && s.length && c.merge(t, c.length, s[0], !1, l, 0) ? c.breakAfter = s.shift().breakAfter : (t < c.length || c.children.length && c.children[c.children.length - 1].length == 0) && c.merge(t, c.length, null, !1, l, 0), e++)); e < i && s.length; )
      if (h[i - 1].become(s[s.length - 1]))
        i--, s.pop(), a = s.length ? 0 : l;
      else if (h[e].become(s[0]))
        e++, s.shift(), l = s.length ? 0 : a;
      else
        break;
    !s.length && e && i < h.length && !h[e - 1].breakAfter && h[i].merge(0, 0, h[e - 1], !1, l, a) && e--, (e < i || s.length) && r.replaceChildren(e, i, s);
  }
}
function bd(r, e, t, i, n, s) {
  let o = r.childCursor(), { i: l, off: a } = o.findPos(t, 1), { i: h, off: c } = o.findPos(e, -1), f = e - t;
  for (let u of i)
    f += u.length;
  r.length += f, gd(r, h, c, l, a, i, 0, n, s);
}
const Jg = 256;
class at extends ne {
  constructor(e) {
    super(), this.text = e;
  }
  get length() {
    return this.text.length;
  }
  createDOM(e) {
    this.setDOM(e || document.createTextNode(this.text));
  }
  sync(e, t) {
    this.dom || this.createDOM(), this.dom.nodeValue != this.text && (t && t.node == this.dom && (t.written = !0), this.dom.nodeValue = this.text);
  }
  reuseDOM(e) {
    e.nodeType == 3 && this.createDOM(e);
  }
  merge(e, t, i) {
    return this.flags & 8 || i && (!(i instanceof at) || this.length - (t - e) + i.length > Jg || i.flags & 8) ? !1 : (this.text = this.text.slice(0, e) + (i ? i.text : "") + this.text.slice(t), this.markDirty(), !0);
  }
  split(e) {
    let t = new at(this.text.slice(e));
    return this.text = this.text.slice(0, e), this.markDirty(), t.flags |= this.flags & 8, t;
  }
  localPosFromDOM(e, t) {
    return e == this.dom ? t : t ? this.text.length : 0;
  }
  domAtPos(e) {
    return new Te(this.dom, e);
  }
  domBoundsAround(e, t, i) {
    return { from: i, to: i + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
  }
  coordsAt(e, t) {
    return e0(this.dom, e, t);
  }
}
class Bt extends ne {
  constructor(e, t = [], i = 0) {
    super(), this.mark = e, this.children = t, this.length = i;
    for (let n of t)
      n.setParent(this);
  }
  setAttrs(e) {
    if (ud(e), this.mark.class && (e.className = this.mark.class), this.mark.attrs)
      for (let t in this.mark.attrs)
        e.setAttribute(t, this.mark.attrs[t]);
    return e;
  }
  canReuseDOM(e) {
    return super.canReuseDOM(e) && !((this.flags | e.flags) & 8);
  }
  reuseDOM(e) {
    e.nodeName == this.mark.tagName.toUpperCase() && (this.setDOM(e), this.flags |= 6);
  }
  sync(e, t) {
    this.dom ? this.flags & 4 && this.setAttrs(this.dom) : this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))), super.sync(e, t);
  }
  merge(e, t, i, n, s, o) {
    return i && (!(i instanceof Bt && i.mark.eq(this.mark)) || e && s <= 0 || t < this.length && o <= 0) ? !1 : (bd(this, e, t, i ? i.children.slice() : [], s - 1, o - 1), this.markDirty(), !0);
  }
  split(e) {
    let t = [], i = 0, n = -1, s = 0;
    for (let l of this.children) {
      let a = i + l.length;
      a > e && t.push(i < e ? l.split(e - i) : l), n < 0 && i >= e && (n = s), i = a, s++;
    }
    let o = this.length - e;
    return this.length = e, n > -1 && (this.children.length = n, this.markDirty()), new Bt(this.mark, t, o);
  }
  domAtPos(e) {
    return yd(this, e);
  }
  coordsAt(e, t) {
    return wd(this, e, t);
  }
}
function e0(r, e, t) {
  let i = r.nodeValue.length;
  e > i && (e = i);
  let n = e, s = e, o = 0;
  e == 0 && t < 0 || e == i && t >= 0 ? E.chrome || E.gecko || (e ? (n--, o = 1) : s < i && (s++, o = -1)) : t < 0 ? n-- : s < i && s++;
  let l = $i(r, n, s).getClientRects();
  if (!l.length)
    return null;
  let a = l[(o ? o < 0 : t >= 0) ? 0 : l.length - 1];
  return E.safari && !o && a.width == 0 && (a = Array.prototype.find.call(l, (h) => h.width) || a), o ? io(a, o < 0) : a || null;
}
class ii extends ne {
  static create(e, t, i) {
    return new ii(e, t, i);
  }
  constructor(e, t, i) {
    super(), this.widget = e, this.length = t, this.side = i, this.prevWidget = null;
  }
  split(e) {
    let t = ii.create(this.widget, this.length - e, this.side);
    return this.length -= e, t;
  }
  sync(e) {
    (!this.dom || !this.widget.updateDOM(this.dom, e)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(e)), this.widget.editable || (this.dom.contentEditable = "false"));
  }
  getSide() {
    return this.side;
  }
  merge(e, t, i, n, s, o) {
    return i && (!(i instanceof ii) || !this.widget.compare(i.widget) || e > 0 && s <= 0 || t < this.length && o <= 0) ? !1 : (this.length = e + (i ? i.length : 0) + (this.length - t), !0);
  }
  become(e) {
    return e instanceof ii && e.side == this.side && this.widget.constructor == e.widget.constructor ? (this.widget.compare(e.widget) || this.markDirty(!0), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = e.widget, this.length = e.length, !0) : !1;
  }
  ignoreMutation() {
    return !0;
  }
  ignoreEvent(e) {
    return this.widget.ignoreEvent(e);
  }
  get overrideDOMText() {
    if (this.length == 0)
      return K.empty;
    let e = this;
    for (; e.parent; )
      e = e.parent;
    let { view: t } = e, i = t && t.state.doc, n = this.posAtStart;
    return i ? i.slice(n, n + this.length) : K.empty;
  }
  domAtPos(e) {
    return (this.length ? e == 0 : this.side > 0) ? Te.before(this.dom) : Te.after(this.dom, e == this.length);
  }
  domBoundsAround() {
    return null;
  }
  coordsAt(e, t) {
    let i = this.widget.coordsAt(this.dom, e, t);
    if (i)
      return i;
    let n = this.dom.getClientRects(), s = null;
    if (!n.length)
      return null;
    let o = this.side ? this.side < 0 : e > 0;
    for (let l = o ? n.length - 1 : 0; s = n[l], !(e > 0 ? l == 0 : l == n.length - 1 || s.top < s.bottom); l += o ? -1 : 1)
      ;
    return io(s, !o);
  }
  get isEditable() {
    return !1;
  }
  get isWidget() {
    return !0;
  }
  get isHidden() {
    return this.widget.isHidden;
  }
  destroy() {
    super.destroy(), this.dom && this.widget.destroy(this.dom);
  }
}
class qi extends ne {
  constructor(e) {
    super(), this.side = e;
  }
  get length() {
    return 0;
  }
  merge() {
    return !1;
  }
  become(e) {
    return e instanceof qi && e.side == this.side;
  }
  split() {
    return new qi(this.side);
  }
  sync() {
    if (!this.dom) {
      let e = document.createElement("img");
      e.className = "cm-widgetBuffer", e.setAttribute("aria-hidden", "true"), this.setDOM(e);
    }
  }
  getSide() {
    return this.side;
  }
  domAtPos(e) {
    return this.side > 0 ? Te.before(this.dom) : Te.after(this.dom);
  }
  localPosFromDOM() {
    return 0;
  }
  domBoundsAround() {
    return null;
  }
  coordsAt(e) {
    return this.dom.getBoundingClientRect();
  }
  get overrideDOMText() {
    return K.empty;
  }
  get isHidden() {
    return !0;
  }
}
at.prototype.children = ii.prototype.children = qi.prototype.children = Va;
function yd(r, e) {
  let t = r.dom, { children: i } = r, n = 0;
  for (let s = 0; n < i.length; n++) {
    let o = i[n], l = s + o.length;
    if (!(l == s && o.getSide() <= 0)) {
      if (e > s && e < l && o.dom.parentNode == t)
        return o.domAtPos(e - s);
      if (e <= s)
        break;
      s = l;
    }
  }
  for (let s = n; s > 0; s--) {
    let o = i[s - 1];
    if (o.dom.parentNode == t)
      return o.domAtPos(o.length);
  }
  for (let s = n; s < i.length; s++) {
    let o = i[s];
    if (o.dom.parentNode == t)
      return o.domAtPos(0);
  }
  return new Te(t, 0);
}
function Sd(r, e, t) {
  let i, { children: n } = r;
  t > 0 && e instanceof Bt && n.length && (i = n[n.length - 1]) instanceof Bt && i.mark.eq(e.mark) ? Sd(i, e.children[0], t - 1) : (n.push(e), e.setParent(r)), r.length += e.length;
}
function wd(r, e, t) {
  let i = null, n = -1, s = null, o = -1;
  function l(h, c) {
    for (let f = 0, u = 0; f < h.children.length && u <= c; f++) {
      let d = h.children[f], p = u + d.length;
      p >= c && (d.children.length ? l(d, c - u) : (!s || s.isHidden && (t > 0 || i0(s, d))) && (p > c || u == p && d.getSide() > 0) ? (s = d, o = c - u) : (u < c || u == p && d.getSide() < 0 && !d.isHidden) && (i = d, n = c - u)), u = p;
    }
  }
  l(r, e);
  let a = (t < 0 ? i : s) || i || s;
  return a ? a.coordsAt(Math.max(0, a == i ? n : o), t) : t0(r);
}
function t0(r) {
  let e = r.dom.lastChild;
  if (!e)
    return r.dom.getBoundingClientRect();
  let t = Ir(e);
  return t[t.length - 1] || null;
}
function i0(r, e) {
  let t = r.coordsAt(0, 1), i = e.coordsAt(0, 1);
  return t && i && i.top < t.bottom;
}
function zl(r, e) {
  for (let t in r)
    t == "class" && e.class ? e.class += " " + r.class : t == "style" && e.style ? e.style += ";" + r.style : e[t] = r[t];
  return e;
}
const tc = /* @__PURE__ */ Object.create(null);
function ys(r, e, t) {
  if (r == e)
    return !0;
  r || (r = tc), e || (e = tc);
  let i = Object.keys(r), n = Object.keys(e);
  if (i.length - (t && i.indexOf(t) > -1 ? 1 : 0) != n.length - (t && n.indexOf(t) > -1 ? 1 : 0))
    return !1;
  for (let s of i)
    if (s != t && (n.indexOf(s) == -1 || r[s] !== e[s]))
      return !1;
  return !0;
}
function Dl(r, e, t) {
  let i = !1;
  if (e)
    for (let n in e)
      t && n in t || (i = !0, n == "style" ? r.style.cssText = "" : r.removeAttribute(n));
  if (t)
    for (let n in t)
      e && e[n] == t[n] || (i = !0, n == "style" ? r.style.cssText = t[n] : r.setAttribute(n, t[n]));
  return i;
}
function r0(r) {
  let e = /* @__PURE__ */ Object.create(null);
  for (let t = 0; t < r.attributes.length; t++) {
    let i = r.attributes[t];
    e[i.name] = i.value;
  }
  return e;
}
class di {
  /**
  Compare this instance to another instance of the same type.
  (TypeScript can't express this, but only instances of the same
  specific class will be passed to this method.) This is used to
  avoid redrawing widgets when they are replaced by a new
  decoration of the same type. The default implementation just
  returns `false`, which will cause new instances of the widget to
  always be redrawn.
  */
  eq(e) {
    return !1;
  }
  /**
  Update a DOM element created by a widget of the same type (but
  different, non-`eq` content) to reflect this widget. May return
  true to indicate that it could update, false to indicate it
  couldn't (in which case the widget will be redrawn). The default
  implementation just returns false.
  */
  updateDOM(e, t) {
    return !1;
  }
  /**
  @internal
  */
  compare(e) {
    return this == e || this.constructor == e.constructor && this.eq(e);
  }
  /**
  The estimated height this widget will have, to be used when
  estimating the height of content that hasn't been drawn. May
  return -1 to indicate you don't know. The default implementation
  returns -1.
  */
  get estimatedHeight() {
    return -1;
  }
  /**
  For inline widgets that are displayed inline (as opposed to
  `inline-block`) and introduce line breaks (through `<br>` tags
  or textual newlines), this must indicate the amount of line
  breaks they introduce. Defaults to 0.
  */
  get lineBreaks() {
    return 0;
  }
  /**
  Can be used to configure which kinds of events inside the widget
  should be ignored by the editor. The default is to ignore all
  events.
  */
  ignoreEvent(e) {
    return !0;
  }
  /**
  Override the way screen coordinates for positions at/in the
  widget are found. `pos` will be the offset into the widget, and
  `side` the side of the position that is being queried—less than
  zero for before, greater than zero for after, and zero for
  directly at that position.
  */
  coordsAt(e, t, i) {
    return null;
  }
  /**
  @internal
  */
  get isHidden() {
    return !1;
  }
  /**
  @internal
  */
  get editable() {
    return !1;
  }
  /**
  This is called when the an instance of the widget is removed
  from the editor view.
  */
  destroy(e) {
  }
}
var Xe = /* @__PURE__ */ (function(r) {
  return r[r.Text = 0] = "Text", r[r.WidgetBefore = 1] = "WidgetBefore", r[r.WidgetAfter = 2] = "WidgetAfter", r[r.WidgetRange = 3] = "WidgetRange", r;
})(Xe || (Xe = {}));
class B extends oi {
  constructor(e, t, i, n) {
    super(), this.startSide = e, this.endSide = t, this.widget = i, this.spec = n;
  }
  /**
  @internal
  */
  get heightRelevant() {
    return !1;
  }
  /**
  Create a mark decoration, which influences the styling of the
  content in its range. Nested mark decorations will cause nested
  DOM elements to be created. Nesting order is determined by
  precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
  the higher-precedence decorations creating the inner DOM nodes.
  Such elements are split on line boundaries and on the boundaries
  of lower-precedence decorations.
  */
  static mark(e) {
    return new on(e);
  }
  /**
  Create a widget decoration, which displays a DOM element at the
  given position.
  */
  static widget(e) {
    let t = Math.max(-1e4, Math.min(1e4, e.side || 0)), i = !!e.block;
    return t += i && !e.inlineOrder ? t > 0 ? 3e8 : -4e8 : t > 0 ? 1e8 : -1e8, new ai(e, t, t, i, e.widget || null, !1);
  }
  /**
  Create a replace decoration which replaces the given range with
  a widget, or simply hides it.
  */
  static replace(e) {
    let t = !!e.block, i, n;
    if (e.isBlockGap)
      i = -5e8, n = 4e8;
    else {
      let { start: s, end: o } = xd(e, t);
      i = (s ? t ? -3e8 : -1 : 5e8) - 1, n = (o ? t ? 2e8 : 1 : -6e8) + 1;
    }
    return new ai(e, i, n, t, e.widget || null, !0);
  }
  /**
  Create a line decoration, which can add DOM attributes to the
  line starting at the given position.
  */
  static line(e) {
    return new ln(e);
  }
  /**
  Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
  decorated range or ranges. If the ranges aren't already sorted,
  pass `true` for `sort` to make the library sort them for you.
  */
  static set(e, t = !1) {
    return H.of(e, t);
  }
  /**
  @internal
  */
  hasHeight() {
    return this.widget ? this.widget.estimatedHeight > -1 : !1;
  }
}
B.none = H.empty;
class on extends B {
  constructor(e) {
    let { start: t, end: i } = xd(e);
    super(t ? -1 : 5e8, i ? 1 : -6e8, null, e), this.tagName = e.tagName || "span", this.class = e.class || "", this.attrs = e.attributes || null;
  }
  eq(e) {
    var t, i;
    return this == e || e instanceof on && this.tagName == e.tagName && (this.class || ((t = this.attrs) === null || t === void 0 ? void 0 : t.class)) == (e.class || ((i = e.attrs) === null || i === void 0 ? void 0 : i.class)) && ys(this.attrs, e.attrs, "class");
  }
  range(e, t = e) {
    if (e >= t)
      throw new RangeError("Mark decorations may not be empty");
    return super.range(e, t);
  }
}
on.prototype.point = !1;
class ln extends B {
  constructor(e) {
    super(-2e8, -2e8, null, e);
  }
  eq(e) {
    return e instanceof ln && this.spec.class == e.spec.class && ys(this.spec.attributes, e.spec.attributes);
  }
  range(e, t = e) {
    if (t != e)
      throw new RangeError("Line decoration ranges must be zero-length");
    return super.range(e, t);
  }
}
ln.prototype.mapMode = ke.TrackBefore;
ln.prototype.point = !0;
class ai extends B {
  constructor(e, t, i, n, s, o) {
    super(t, i, s, e), this.block = n, this.isReplace = o, this.mapMode = n ? t <= 0 ? ke.TrackBefore : ke.TrackAfter : ke.TrackDel;
  }
  // Only relevant when this.block == true
  get type() {
    return this.startSide != this.endSide ? Xe.WidgetRange : this.startSide <= 0 ? Xe.WidgetBefore : Xe.WidgetAfter;
  }
  get heightRelevant() {
    return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
  }
  eq(e) {
    return e instanceof ai && n0(this.widget, e.widget) && this.block == e.block && this.startSide == e.startSide && this.endSide == e.endSide;
  }
  range(e, t = e) {
    if (this.isReplace && (e > t || e == t && this.startSide > 0 && this.endSide <= 0))
      throw new RangeError("Invalid range for replacement decoration");
    if (!this.isReplace && t != e)
      throw new RangeError("Widget decorations can only have zero-length ranges");
    return super.range(e, t);
  }
}
ai.prototype.point = !0;
function xd(r, e = !1) {
  let { inclusiveStart: t, inclusiveEnd: i } = r;
  return t == null && (t = r.inclusive), i == null && (i = r.inclusive), { start: t ?? e, end: i ?? e };
}
function n0(r, e) {
  return r == e || !!(r && e && r.compare(e));
}
function Jn(r, e, t, i = 0) {
  let n = t.length - 1;
  n >= 0 && t[n] + i >= r ? t[n] = Math.max(t[n], e) : t.push(r, e);
}
class Oe extends ne {
  constructor() {
    super(...arguments), this.children = [], this.length = 0, this.prevAttrs = void 0, this.attrs = null, this.breakAfter = 0;
  }
  // Consumes source
  merge(e, t, i, n, s, o) {
    if (i) {
      if (!(i instanceof Oe))
        return !1;
      this.dom || i.transferDOM(this);
    }
    return n && this.setDeco(i ? i.attrs : null), bd(this, e, t, i ? i.children.slice() : [], s, o), !0;
  }
  split(e) {
    let t = new Oe();
    if (t.breakAfter = this.breakAfter, this.length == 0)
      return t;
    let { i, off: n } = this.childPos(e);
    n && (t.append(this.children[i].split(n), 0), this.children[i].merge(n, this.children[i].length, null, !1, 0, 0), i++);
    for (let s = i; s < this.children.length; s++)
      t.append(this.children[s], 0);
    for (; i > 0 && this.children[i - 1].length == 0; )
      this.children[--i].destroy();
    return this.children.length = i, this.markDirty(), this.length = e, t;
  }
  transferDOM(e) {
    this.dom && (this.markDirty(), e.setDOM(this.dom), e.prevAttrs = this.prevAttrs === void 0 ? this.attrs : this.prevAttrs, this.prevAttrs = void 0, this.dom = null);
  }
  setDeco(e) {
    ys(this.attrs, e) || (this.dom && (this.prevAttrs = this.attrs, this.markDirty()), this.attrs = e);
  }
  append(e, t) {
    Sd(this, e, t);
  }
  // Only called when building a line view in ContentBuilder
  addLineDeco(e) {
    let t = e.spec.attributes, i = e.spec.class;
    t && (this.attrs = zl(t, this.attrs || {})), i && (this.attrs = zl({ class: i }, this.attrs || {}));
  }
  domAtPos(e) {
    return yd(this, e);
  }
  reuseDOM(e) {
    e.nodeName == "DIV" && (this.setDOM(e), this.flags |= 6);
  }
  sync(e, t) {
    var i;
    this.dom ? this.flags & 4 && (ud(this.dom), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0) : (this.setDOM(document.createElement("div")), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0), this.prevAttrs !== void 0 && (Dl(this.dom, this.prevAttrs, this.attrs), this.dom.classList.add("cm-line"), this.prevAttrs = void 0), super.sync(e, t);
    let n = this.dom.lastChild;
    for (; n && ne.get(n) instanceof Bt; )
      n = n.lastChild;
    if (!n || !this.length || n.nodeName != "BR" && ((i = ne.get(n)) === null || i === void 0 ? void 0 : i.isEditable) == !1 && (!E.ios || !this.children.some((s) => s instanceof at))) {
      let s = document.createElement("BR");
      s.cmIgnore = !0, this.dom.appendChild(s);
    }
  }
  measureTextSize() {
    if (this.children.length == 0 || this.length > 20)
      return null;
    let e = 0, t;
    for (let i of this.children) {
      if (!(i instanceof at) || /[^ -~]/.test(i.text))
        return null;
      let n = Ir(i.dom);
      if (n.length != 1)
        return null;
      e += n[0].width, t = n[0].height;
    }
    return e ? {
      lineHeight: this.dom.getBoundingClientRect().height,
      charWidth: e / this.length,
      textHeight: t
    } : null;
  }
  coordsAt(e, t) {
    let i = wd(this, e, t);
    if (!this.children.length && i && this.parent) {
      let { heightOracle: n } = this.parent.view.viewState, s = i.bottom - i.top;
      if (Math.abs(s - n.lineHeight) < 2 && n.textHeight < s) {
        let o = (s - n.textHeight) / 2;
        return { top: i.top + o, bottom: i.bottom - o, left: i.left, right: i.left };
      }
    }
    return i;
  }
  become(e) {
    return e instanceof Oe && this.children.length == 0 && e.children.length == 0 && ys(this.attrs, e.attrs) && this.breakAfter == e.breakAfter;
  }
  covers() {
    return !0;
  }
  static find(e, t) {
    for (let i = 0, n = 0; i < e.children.length; i++) {
      let s = e.children[i], o = n + s.length;
      if (o >= t) {
        if (s instanceof Oe)
          return s;
        if (o > t)
          break;
      }
      n = o + s.breakAfter;
    }
    return null;
  }
}
class zt extends ne {
  constructor(e, t, i) {
    super(), this.widget = e, this.length = t, this.deco = i, this.breakAfter = 0, this.prevWidget = null;
  }
  merge(e, t, i, n, s, o) {
    return i && (!(i instanceof zt) || !this.widget.compare(i.widget) || e > 0 && s <= 0 || t < this.length && o <= 0) ? !1 : (this.length = e + (i ? i.length : 0) + (this.length - t), !0);
  }
  domAtPos(e) {
    return e == 0 ? Te.before(this.dom) : Te.after(this.dom, e == this.length);
  }
  split(e) {
    let t = this.length - e;
    this.length = e;
    let i = new zt(this.widget, t, this.deco);
    return i.breakAfter = this.breakAfter, i;
  }
  get children() {
    return Va;
  }
  sync(e) {
    (!this.dom || !this.widget.updateDOM(this.dom, e)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(e)), this.widget.editable || (this.dom.contentEditable = "false"));
  }
  get overrideDOMText() {
    return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : K.empty;
  }
  domBoundsAround() {
    return null;
  }
  become(e) {
    return e instanceof zt && e.widget.constructor == this.widget.constructor ? (e.widget.compare(this.widget) || this.markDirty(!0), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = e.widget, this.length = e.length, this.deco = e.deco, this.breakAfter = e.breakAfter, !0) : !1;
  }
  ignoreMutation() {
    return !0;
  }
  ignoreEvent(e) {
    return this.widget.ignoreEvent(e);
  }
  get isEditable() {
    return !1;
  }
  get isWidget() {
    return !0;
  }
  coordsAt(e, t) {
    let i = this.widget.coordsAt(this.dom, e, t);
    return i || (this.widget instanceof _l ? null : io(this.dom.getBoundingClientRect(), this.length ? e == 0 : t <= 0));
  }
  destroy() {
    super.destroy(), this.dom && this.widget.destroy(this.dom);
  }
  covers(e) {
    let { startSide: t, endSide: i } = this.deco;
    return t == i ? !1 : e < 0 ? t < 0 : i > 0;
  }
}
class _l extends di {
  constructor(e) {
    super(), this.height = e;
  }
  toDOM() {
    let e = document.createElement("div");
    return e.className = "cm-gap", this.updateDOM(e), e;
  }
  eq(e) {
    return e.height == this.height;
  }
  updateDOM(e) {
    return e.style.height = this.height + "px", !0;
  }
  get editable() {
    return !0;
  }
  get estimatedHeight() {
    return this.height;
  }
  ignoreEvent() {
    return !1;
  }
}
class Ar {
  constructor(e, t, i, n) {
    this.doc = e, this.pos = t, this.end = i, this.disallowBlockEffectsFor = n, this.content = [], this.curLine = null, this.breakAtStart = 0, this.pendingBuffer = 0, this.bufferMarks = [], this.atCursorPos = !0, this.openStart = -1, this.openEnd = -1, this.text = "", this.textOff = 0, this.cursor = e.iter(), this.skip = t;
  }
  posCovered() {
    if (this.content.length == 0)
      return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
    let e = this.content[this.content.length - 1];
    return !(e.breakAfter || e instanceof zt && e.deco.endSide < 0);
  }
  getLine() {
    return this.curLine || (this.content.push(this.curLine = new Oe()), this.atCursorPos = !0), this.curLine;
  }
  flushBuffer(e = this.bufferMarks) {
    this.pendingBuffer && (this.curLine.append(wn(new qi(-1), e), e.length), this.pendingBuffer = 0);
  }
  addBlockWidget(e) {
    this.flushBuffer(), this.curLine = null, this.content.push(e);
  }
  finish(e) {
    this.pendingBuffer && e <= this.bufferMarks.length ? this.flushBuffer() : this.pendingBuffer = 0, !this.posCovered() && !(e && this.content.length && this.content[this.content.length - 1] instanceof zt) && this.getLine();
  }
  buildText(e, t, i) {
    for (; e > 0; ) {
      if (this.textOff == this.text.length) {
        let { value: o, lineBreak: l, done: a } = this.cursor.next(this.skip);
        if (this.skip = 0, a)
          throw new Error("Ran out of text content when drawing inline views");
        if (l) {
          this.posCovered() || this.getLine(), this.content.length ? this.content[this.content.length - 1].breakAfter = 1 : this.breakAtStart = 1, this.flushBuffer(), this.curLine = null, this.atCursorPos = !0, e--;
          continue;
        } else
          this.text = o, this.textOff = 0;
      }
      let n = Math.min(this.text.length - this.textOff, e), s = Math.min(
        n,
        512
        /* T.Chunk */
      );
      this.flushBuffer(t.slice(t.length - i)), this.getLine().append(wn(new at(this.text.slice(this.textOff, this.textOff + s)), t), i), this.atCursorPos = !0, this.textOff += s, e -= s, i = n <= s ? 0 : t.length;
    }
  }
  span(e, t, i, n) {
    this.buildText(t - e, i, n), this.pos = t, this.openStart < 0 && (this.openStart = n);
  }
  point(e, t, i, n, s, o) {
    if (this.disallowBlockEffectsFor[o] && i instanceof ai) {
      if (i.block)
        throw new RangeError("Block decorations may not be specified via plugins");
      if (t > this.doc.lineAt(this.pos).to)
        throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
    }
    let l = t - e;
    if (i instanceof ai)
      if (i.block)
        i.startSide > 0 && !this.posCovered() && this.getLine(), this.addBlockWidget(new zt(i.widget || Yi.block, l, i));
      else {
        let a = ii.create(i.widget || Yi.inline, l, l ? 0 : i.startSide), h = this.atCursorPos && !a.isEditable && s <= n.length && (e < t || i.startSide > 0), c = !a.isEditable && (e < t || s > n.length || i.startSide <= 0), f = this.getLine();
        this.pendingBuffer == 2 && !h && !a.isEditable && (this.pendingBuffer = 0), this.flushBuffer(n), h && (f.append(wn(new qi(1), n), s), s = n.length + Math.max(0, s - n.length)), f.append(wn(a, n), s), this.atCursorPos = c, this.pendingBuffer = c ? e < t || s > n.length ? 1 : 2 : 0, this.pendingBuffer && (this.bufferMarks = n.slice());
      }
    else this.doc.lineAt(this.pos).from == this.pos && this.getLine().addLineDeco(i);
    l && (this.textOff + l <= this.text.length ? this.textOff += l : (this.skip += l - (this.text.length - this.textOff), this.text = "", this.textOff = 0), this.pos = t), this.openStart < 0 && (this.openStart = s);
  }
  static build(e, t, i, n, s) {
    let o = new Ar(e, t, i, s);
    return o.openEnd = H.spans(n, t, i, o), o.openStart < 0 && (o.openStart = o.openEnd), o.finish(o.openEnd), o;
  }
}
function wn(r, e) {
  for (let t of e)
    r = new Bt(t, [r], r.length);
  return r;
}
class Yi extends di {
  constructor(e) {
    super(), this.tag = e;
  }
  eq(e) {
    return e.tag == this.tag;
  }
  toDOM() {
    return document.createElement(this.tag);
  }
  updateDOM(e) {
    return e.nodeName.toLowerCase() == this.tag;
  }
  get isHidden() {
    return !0;
  }
}
Yi.inline = /* @__PURE__ */ new Yi("span");
Yi.block = /* @__PURE__ */ new Yi("div");
var ce = /* @__PURE__ */ (function(r) {
  return r[r.LTR = 0] = "LTR", r[r.RTL = 1] = "RTL", r;
})(ce || (ce = {}));
const Pi = ce.LTR, qa = ce.RTL;
function kd(r) {
  let e = [];
  for (let t = 0; t < r.length; t++)
    e.push(1 << +r[t]);
  return e;
}
const s0 = /* @__PURE__ */ kd("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"), o0 = /* @__PURE__ */ kd("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"), Bl = /* @__PURE__ */ Object.create(null), ct = [];
for (let r of ["()", "[]", "{}"]) {
  let e = /* @__PURE__ */ r.charCodeAt(0), t = /* @__PURE__ */ r.charCodeAt(1);
  Bl[e] = t, Bl[t] = -e;
}
function Qd(r) {
  return r <= 247 ? s0[r] : 1424 <= r && r <= 1524 ? 2 : 1536 <= r && r <= 1785 ? o0[r - 1536] : 1774 <= r && r <= 2220 ? 4 : 8192 <= r && r <= 8204 ? 256 : 64336 <= r && r <= 65023 ? 4 : 1;
}
const l0 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
class ri {
  /**
  The direction of this span.
  */
  get dir() {
    return this.level % 2 ? qa : Pi;
  }
  /**
  @internal
  */
  constructor(e, t, i) {
    this.from = e, this.to = t, this.level = i;
  }
  /**
  @internal
  */
  side(e, t) {
    return this.dir == t == e ? this.to : this.from;
  }
  /**
  @internal
  */
  forward(e, t) {
    return e == (this.dir == t);
  }
  /**
  @internal
  */
  static find(e, t, i, n) {
    let s = -1;
    for (let o = 0; o < e.length; o++) {
      let l = e[o];
      if (l.from <= t && l.to >= t) {
        if (l.level == i)
          return o;
        (s < 0 || (n != 0 ? n < 0 ? l.from < t : l.to > t : e[s].level > l.level)) && (s = o);
      }
    }
    if (s < 0)
      throw new RangeError("Index out of range");
    return s;
  }
}
function vd(r, e) {
  if (r.length != e.length)
    return !1;
  for (let t = 0; t < r.length; t++) {
    let i = r[t], n = e[t];
    if (i.from != n.from || i.to != n.to || i.direction != n.direction || !vd(i.inner, n.inner))
      return !1;
  }
  return !0;
}
const se = [];
function a0(r, e, t, i, n) {
  for (let s = 0; s <= i.length; s++) {
    let o = s ? i[s - 1].to : e, l = s < i.length ? i[s].from : t, a = s ? 256 : n;
    for (let h = o, c = a, f = a; h < l; h++) {
      let u = Qd(r.charCodeAt(h));
      u == 512 ? u = c : u == 8 && f == 4 && (u = 16), se[h] = u == 4 ? 2 : u, u & 7 && (f = u), c = u;
    }
    for (let h = o, c = a, f = a; h < l; h++) {
      let u = se[h];
      if (u == 128)
        h < l - 1 && c == se[h + 1] && c & 24 ? u = se[h] = c : se[h] = 256;
      else if (u == 64) {
        let d = h + 1;
        for (; d < l && se[d] == 64; )
          d++;
        let p = h && c == 8 || d < t && se[d] == 8 ? f == 1 ? 1 : 8 : 256;
        for (let O = h; O < d; O++)
          se[O] = p;
        h = d - 1;
      } else u == 8 && f == 1 && (se[h] = 1);
      c = u, u & 7 && (f = u);
    }
  }
}
function h0(r, e, t, i, n) {
  let s = n == 1 ? 2 : 1;
  for (let o = 0, l = 0, a = 0; o <= i.length; o++) {
    let h = o ? i[o - 1].to : e, c = o < i.length ? i[o].from : t;
    for (let f = h, u, d, p; f < c; f++)
      if (d = Bl[u = r.charCodeAt(f)])
        if (d < 0) {
          for (let O = l - 3; O >= 0; O -= 3)
            if (ct[O + 1] == -d) {
              let g = ct[O + 2], b = g & 2 ? n : g & 4 ? g & 1 ? s : n : 0;
              b && (se[f] = se[ct[O]] = b), l = O;
              break;
            }
        } else {
          if (ct.length == 189)
            break;
          ct[l++] = f, ct[l++] = u, ct[l++] = a;
        }
      else if ((p = se[f]) == 2 || p == 1) {
        let O = p == n;
        a = O ? 0 : 1;
        for (let g = l - 3; g >= 0; g -= 3) {
          let b = ct[g + 2];
          if (b & 2)
            break;
          if (O)
            ct[g + 2] |= 2;
          else {
            if (b & 4)
              break;
            ct[g + 2] |= 4;
          }
        }
      }
  }
}
function c0(r, e, t, i) {
  for (let n = 0, s = i; n <= t.length; n++) {
    let o = n ? t[n - 1].to : r, l = n < t.length ? t[n].from : e;
    for (let a = o; a < l; ) {
      let h = se[a];
      if (h == 256) {
        let c = a + 1;
        for (; ; )
          if (c == l) {
            if (n == t.length)
              break;
            c = t[n++].to, l = n < t.length ? t[n].from : e;
          } else if (se[c] == 256)
            c++;
          else
            break;
        let f = s == 1, u = (c < e ? se[c] : i) == 1, d = f == u ? f ? 1 : 2 : i;
        for (let p = c, O = n, g = O ? t[O - 1].to : r; p > a; )
          p == g && (p = t[--O].from, g = O ? t[O - 1].to : r), se[--p] = d;
        a = c;
      } else
        s = h, a++;
    }
  }
}
function Il(r, e, t, i, n, s, o) {
  let l = i % 2 ? 2 : 1;
  if (i % 2 == n % 2)
    for (let a = e, h = 0; a < t; ) {
      let c = !0, f = !1;
      if (h == s.length || a < s[h].from) {
        let O = se[a];
        O != l && (c = !1, f = O == 16);
      }
      let u = !c && l == 1 ? [] : null, d = c ? i : i + 1, p = a;
      e: for (; ; )
        if (h < s.length && p == s[h].from) {
          if (f)
            break e;
          let O = s[h];
          if (!c)
            for (let g = O.to, b = h + 1; ; ) {
              if (g == t)
                break e;
              if (b < s.length && s[b].from == g)
                g = s[b++].to;
              else {
                if (se[g] == l)
                  break e;
                break;
              }
            }
          if (h++, u)
            u.push(O);
          else {
            O.from > a && o.push(new ri(a, O.from, d));
            let g = O.direction == Pi != !(d % 2);
            Vl(r, g ? i + 1 : i, n, O.inner, O.from, O.to, o), a = O.to;
          }
          p = O.to;
        } else {
          if (p == t || (c ? se[p] != l : se[p] == l))
            break;
          p++;
        }
      u ? Il(r, a, p, i + 1, n, u, o) : a < p && o.push(new ri(a, p, d)), a = p;
    }
  else
    for (let a = t, h = s.length; a > e; ) {
      let c = !0, f = !1;
      if (!h || a > s[h - 1].to) {
        let O = se[a - 1];
        O != l && (c = !1, f = O == 16);
      }
      let u = !c && l == 1 ? [] : null, d = c ? i : i + 1, p = a;
      e: for (; ; )
        if (h && p == s[h - 1].to) {
          if (f)
            break e;
          let O = s[--h];
          if (!c)
            for (let g = O.from, b = h; ; ) {
              if (g == e)
                break e;
              if (b && s[b - 1].to == g)
                g = s[--b].from;
              else {
                if (se[g - 1] == l)
                  break e;
                break;
              }
            }
          if (u)
            u.push(O);
          else {
            O.to < a && o.push(new ri(O.to, a, d));
            let g = O.direction == Pi != !(d % 2);
            Vl(r, g ? i + 1 : i, n, O.inner, O.from, O.to, o), a = O.from;
          }
          p = O.from;
        } else {
          if (p == e || (c ? se[p - 1] != l : se[p - 1] == l))
            break;
          p--;
        }
      u ? Il(r, p, a, i + 1, n, u, o) : p < a && o.push(new ri(p, a, d)), a = p;
    }
}
function Vl(r, e, t, i, n, s, o) {
  let l = e % 2 ? 2 : 1;
  a0(r, n, s, i, l), h0(r, n, s, i, l), c0(n, s, i, l), Il(r, n, s, e, t, i, o);
}
function f0(r, e, t) {
  if (!r)
    return [new ri(0, 0, e == qa ? 1 : 0)];
  if (e == Pi && !t.length && !l0.test(r))
    return $d(r.length);
  if (t.length)
    for (; r.length > se.length; )
      se[se.length] = 256;
  let i = [], n = e == Pi ? 0 : 1;
  return Vl(r, n, n, t, 0, r.length, i), i;
}
function $d(r) {
  return [new ri(0, r, 0)];
}
let Pd = "";
function u0(r, e, t, i, n) {
  var s;
  let o = i.head - r.from, l = ri.find(e, o, (s = i.bidiLevel) !== null && s !== void 0 ? s : -1, i.assoc), a = e[l], h = a.side(n, t);
  if (o == h) {
    let u = l += n ? 1 : -1;
    if (u < 0 || u >= e.length)
      return null;
    a = e[l = u], o = a.side(!n, t), h = a.side(n, t);
  }
  let c = De(r.text, o, a.forward(n, t));
  (c < a.from || c > a.to) && (c = h), Pd = r.text.slice(Math.min(o, c), Math.max(o, c));
  let f = l == (n ? e.length - 1 : 0) ? null : e[l + (n ? 1 : -1)];
  return f && c == h && f.level + (n ? 0 : 1) < a.level ? v.cursor(f.side(!n, t) + r.from, f.forward(n, t) ? 1 : -1, f.level) : v.cursor(c + r.from, a.forward(n, t) ? -1 : 1, a.level);
}
function d0(r, e, t) {
  for (let i = e; i < t; i++) {
    let n = Qd(r.charCodeAt(i));
    if (n == 1)
      return Pi;
    if (n == 2 || n == 4)
      return qa;
  }
  return Pi;
}
const Cd = /* @__PURE__ */ R.define(), Td = /* @__PURE__ */ R.define(), Ad = /* @__PURE__ */ R.define(), Md = /* @__PURE__ */ R.define(), ql = /* @__PURE__ */ R.define(), Zd = /* @__PURE__ */ R.define(), Xd = /* @__PURE__ */ R.define(), Ya = /* @__PURE__ */ R.define(), Na = /* @__PURE__ */ R.define(), Rd = /* @__PURE__ */ R.define({
  combine: (r) => r.some((e) => e)
}), Ld = /* @__PURE__ */ R.define({
  combine: (r) => r.some((e) => e)
}), Ed = /* @__PURE__ */ R.define();
class _i {
  constructor(e, t = "nearest", i = "nearest", n = 5, s = 5, o = !1) {
    this.range = e, this.y = t, this.x = i, this.yMargin = n, this.xMargin = s, this.isSnapshot = o;
  }
  map(e) {
    return e.empty ? this : new _i(this.range.map(e), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
  }
  clip(e) {
    return this.range.to <= e.doc.length ? this : new _i(v.cursor(e.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
  }
}
const xn = /* @__PURE__ */ V.define({ map: (r, e) => r.map(e) }), zd = /* @__PURE__ */ V.define();
function Qe(r, e, t) {
  let i = r.facet(Md);
  i.length ? i[0](e) : window.onerror && window.onerror(String(e), t, void 0, void 0, e) || (t ? console.error(t + ":", e) : console.error(e));
}
const Lt = /* @__PURE__ */ R.define({ combine: (r) => r.length ? r[0] : !0 });
let p0 = 0;
const Xi = /* @__PURE__ */ R.define({
  combine(r) {
    return r.filter((e, t) => {
      for (let i = 0; i < t; i++)
        if (r[i].plugin == e.plugin)
          return !1;
      return !0;
    });
  }
});
class ue {
  constructor(e, t, i, n, s) {
    this.id = e, this.create = t, this.domEventHandlers = i, this.domEventObservers = n, this.baseExtensions = s(this), this.extension = this.baseExtensions.concat(Xi.of({ plugin: this, arg: void 0 }));
  }
  /**
  Create an extension for this plugin with the given argument.
  */
  of(e) {
    return this.baseExtensions.concat(Xi.of({ plugin: this, arg: e }));
  }
  /**
  Define a plugin from a constructor function that creates the
  plugin's value, given an editor view.
  */
  static define(e, t) {
    const { eventHandlers: i, eventObservers: n, provide: s, decorations: o } = t || {};
    return new ue(p0++, e, i, n, (l) => {
      let a = [];
      return o && a.push(Vr.of((h) => {
        let c = h.plugin(l);
        return c ? o(c) : B.none;
      })), s && a.push(s(l)), a;
    });
  }
  /**
  Create a plugin for a class whose constructor takes a single
  editor view as argument.
  */
  static fromClass(e, t) {
    return ue.define((i, n) => new e(i, n), t);
  }
}
class Qo {
  constructor(e) {
    this.spec = e, this.mustUpdate = null, this.value = null;
  }
  get plugin() {
    return this.spec && this.spec.plugin;
  }
  update(e) {
    if (this.value) {
      if (this.mustUpdate) {
        let t = this.mustUpdate;
        if (this.mustUpdate = null, this.value.update)
          try {
            this.value.update(t);
          } catch (i) {
            if (Qe(t.state, i, "CodeMirror plugin crashed"), this.value.destroy)
              try {
                this.value.destroy();
              } catch {
              }
            this.deactivate();
          }
      }
    } else if (this.spec)
      try {
        this.value = this.spec.plugin.create(e, this.spec.arg);
      } catch (t) {
        Qe(e.state, t, "CodeMirror plugin crashed"), this.deactivate();
      }
    return this;
  }
  destroy(e) {
    var t;
    if (!((t = this.value) === null || t === void 0) && t.destroy)
      try {
        this.value.destroy();
      } catch (i) {
        Qe(e.state, i, "CodeMirror plugin crashed");
      }
  }
  deactivate() {
    this.spec = this.value = null;
  }
}
const Dd = /* @__PURE__ */ R.define(), Wa = /* @__PURE__ */ R.define(), Vr = /* @__PURE__ */ R.define(), _d = /* @__PURE__ */ R.define(), an = /* @__PURE__ */ R.define(), Bd = /* @__PURE__ */ R.define();
function ic(r, e) {
  let t = r.state.facet(Bd);
  if (!t.length)
    return t;
  let i = t.map((s) => s instanceof Function ? s(r) : s), n = [];
  return H.spans(i, e.from, e.to, {
    point() {
    },
    span(s, o, l, a) {
      let h = s - e.from, c = o - e.from, f = n;
      for (let u = l.length - 1; u >= 0; u--, a--) {
        let d = l[u].spec.bidiIsolate, p;
        if (d == null && (d = d0(e.text, h, c)), a > 0 && f.length && (p = f[f.length - 1]).to == h && p.direction == d)
          p.to = c, f = p.inner;
        else {
          let O = { from: h, to: c, direction: d, inner: [] };
          f.push(O), f = O.inner;
        }
      }
    }
  }), n;
}
const Id = /* @__PURE__ */ R.define();
function ja(r) {
  let e = 0, t = 0, i = 0, n = 0;
  for (let s of r.state.facet(Id)) {
    let o = s(r);
    o && (o.left != null && (e = Math.max(e, o.left)), o.right != null && (t = Math.max(t, o.right)), o.top != null && (i = Math.max(i, o.top)), o.bottom != null && (n = Math.max(n, o.bottom)));
  }
  return { left: e, right: t, top: i, bottom: n };
}
const Sr = /* @__PURE__ */ R.define();
class it {
  constructor(e, t, i, n) {
    this.fromA = e, this.toA = t, this.fromB = i, this.toB = n;
  }
  join(e) {
    return new it(Math.min(this.fromA, e.fromA), Math.max(this.toA, e.toA), Math.min(this.fromB, e.fromB), Math.max(this.toB, e.toB));
  }
  addToSet(e) {
    let t = e.length, i = this;
    for (; t > 0; t--) {
      let n = e[t - 1];
      if (!(n.fromA > i.toA)) {
        if (n.toA < i.fromA)
          break;
        i = i.join(n), e.splice(t - 1, 1);
      }
    }
    return e.splice(t, 0, i), e;
  }
  static extendWithRanges(e, t) {
    if (t.length == 0)
      return e;
    let i = [];
    for (let n = 0, s = 0, o = 0, l = 0; ; n++) {
      let a = n == e.length ? null : e[n], h = o - l, c = a ? a.fromB : 1e9;
      for (; s < t.length && t[s] < c; ) {
        let f = t[s], u = t[s + 1], d = Math.max(l, f), p = Math.min(c, u);
        if (d <= p && new it(d + h, p + h, d, p).addToSet(i), u > c)
          break;
        s += 2;
      }
      if (!a)
        return i;
      new it(a.fromA, a.toA, a.fromB, a.toB).addToSet(i), o = a.toA, l = a.toB;
    }
  }
}
class Ss {
  constructor(e, t, i) {
    this.view = e, this.state = t, this.transactions = i, this.flags = 0, this.startState = e.state, this.changes = ye.empty(this.startState.doc.length);
    for (let s of i)
      this.changes = this.changes.compose(s.changes);
    let n = [];
    this.changes.iterChangedRanges((s, o, l, a) => n.push(new it(s, o, l, a))), this.changedRanges = n;
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new Ss(e, t, i);
  }
  /**
  Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
  [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
  update.
  */
  get viewportChanged() {
    return (this.flags & 4) > 0;
  }
  /**
  Returns true when
  [`viewportChanged`](https://codemirror.net/6/docs/ref/#view.ViewUpdate.viewportChanged) is true
  and the viewport change is not just the result of mapping it in
  response to document changes.
  */
  get viewportMoved() {
    return (this.flags & 8) > 0;
  }
  /**
  Indicates whether the height of a block element in the editor
  changed in this update.
  */
  get heightChanged() {
    return (this.flags & 2) > 0;
  }
  /**
  Returns true when the document was modified or the size of the
  editor, or elements within the editor, changed.
  */
  get geometryChanged() {
    return this.docChanged || (this.flags & 18) > 0;
  }
  /**
  True when this update indicates a focus change.
  */
  get focusChanged() {
    return (this.flags & 1) > 0;
  }
  /**
  Whether the document changed in this update.
  */
  get docChanged() {
    return !this.changes.empty;
  }
  /**
  Whether the selection was explicitly set in this update.
  */
  get selectionSet() {
    return this.transactions.some((e) => e.selection);
  }
  /**
  @internal
  */
  get empty() {
    return this.flags == 0 && this.transactions.length == 0;
  }
}
class rc extends ne {
  get length() {
    return this.view.state.doc.length;
  }
  constructor(e) {
    super(), this.view = e, this.decorations = [], this.dynamicDecorationMap = [!1], this.domChanged = null, this.hasComposition = null, this.markedForComposition = /* @__PURE__ */ new Set(), this.editContextFormatting = B.none, this.lastCompositionAfterCursor = !1, this.minWidth = 0, this.minWidthFrom = 0, this.minWidthTo = 0, this.impreciseAnchor = null, this.impreciseHead = null, this.forceSelection = !1, this.lastUpdate = Date.now(), this.setDOM(e.contentDOM), this.children = [new Oe()], this.children[0].setParent(this), this.updateDeco(), this.updateInner([new it(0, 0, 0, e.state.doc.length)], 0, null);
  }
  // Update the document view to a given state.
  update(e) {
    var t;
    let i = e.changedRanges;
    this.minWidth > 0 && i.length && (i.every(({ fromA: h, toA: c }) => c < this.minWidthFrom || h > this.minWidthTo) ? (this.minWidthFrom = e.changes.mapPos(this.minWidthFrom, 1), this.minWidthTo = e.changes.mapPos(this.minWidthTo, 1)) : this.minWidth = this.minWidthFrom = this.minWidthTo = 0), this.updateEditContextFormatting(e);
    let n = -1;
    this.view.inputState.composing >= 0 && !this.view.observer.editContext && (!((t = this.domChanged) === null || t === void 0) && t.newSel ? n = this.domChanged.newSel.head : !w0(e.changes, this.hasComposition) && !e.selectionSet && (n = e.state.selection.main.head));
    let s = n > -1 ? m0(this.view, e.changes, n) : null;
    if (this.domChanged = null, this.hasComposition) {
      this.markedForComposition.clear();
      let { from: h, to: c } = this.hasComposition;
      i = new it(h, c, e.changes.mapPos(h, -1), e.changes.mapPos(c, 1)).addToSet(i.slice());
    }
    this.hasComposition = s ? { from: s.range.fromB, to: s.range.toB } : null, (E.ie || E.chrome) && !s && e && e.state.doc.lines != e.startState.doc.lines && (this.forceSelection = !0);
    let o = this.decorations, l = this.updateDeco(), a = y0(o, l, e.changes);
    return i = it.extendWithRanges(i, a), !(this.flags & 7) && i.length == 0 ? !1 : (this.updateInner(i, e.startState.doc.length, s), e.transactions.length && (this.lastUpdate = Date.now()), !0);
  }
  // Used by update and the constructor do perform the actual DOM
  // update
  updateInner(e, t, i) {
    this.view.viewState.mustMeasureContent = !0, this.updateChildren(e, t, i);
    let { observer: n } = this.view;
    n.ignore(() => {
      this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px", this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
      let o = E.chrome || E.ios ? { node: n.selectionRange.focusNode, written: !1 } : void 0;
      this.sync(this.view, o), this.flags &= -8, o && (o.written || n.selectionRange.focusNode != o.node) && (this.forceSelection = !0), this.dom.style.height = "";
    }), this.markedForComposition.forEach(
      (o) => o.flags &= -9
      /* ViewFlag.Composition */
    );
    let s = [];
    if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
      for (let o of this.children)
        o instanceof zt && o.widget instanceof _l && s.push(o.dom);
    n.updateGaps(s);
  }
  updateChildren(e, t, i) {
    let n = i ? i.range.addToSet(e.slice()) : e, s = this.childCursor(t);
    for (let o = n.length - 1; ; o--) {
      let l = o >= 0 ? n[o] : null;
      if (!l)
        break;
      let { fromA: a, toA: h, fromB: c, toB: f } = l, u, d, p, O;
      if (i && i.range.fromB < f && i.range.toB > c) {
        let x = Ar.build(this.view.state.doc, c, i.range.fromB, this.decorations, this.dynamicDecorationMap), S = Ar.build(this.view.state.doc, i.range.toB, f, this.decorations, this.dynamicDecorationMap);
        d = x.breakAtStart, p = x.openStart, O = S.openEnd;
        let y = this.compositionView(i);
        S.breakAtStart ? y.breakAfter = 1 : S.content.length && y.merge(y.length, y.length, S.content[0], !1, S.openStart, 0) && (y.breakAfter = S.content[0].breakAfter, S.content.shift()), x.content.length && y.merge(0, 0, x.content[x.content.length - 1], !0, 0, x.openEnd) && x.content.pop(), u = x.content.concat(y).concat(S.content);
      } else
        ({ content: u, breakAtStart: d, openStart: p, openEnd: O } = Ar.build(this.view.state.doc, c, f, this.decorations, this.dynamicDecorationMap));
      let { i: g, off: b } = s.findPos(h, 1), { i: w, off: k } = s.findPos(a, -1);
      gd(this, w, k, g, b, u, d, p, O);
    }
    i && this.fixCompositionDOM(i);
  }
  updateEditContextFormatting(e) {
    this.editContextFormatting = this.editContextFormatting.map(e.changes);
    for (let t of e.transactions)
      for (let i of t.effects)
        i.is(zd) && (this.editContextFormatting = i.value);
  }
  compositionView(e) {
    let t = new at(e.text.nodeValue);
    t.flags |= 8;
    for (let { deco: n } of e.marks)
      t = new Bt(n, [t], t.length);
    let i = new Oe();
    return i.append(t, 0), i;
  }
  fixCompositionDOM(e) {
    let t = (s, o) => {
      o.flags |= 8 | (o.children.some(
        (a) => a.flags & 7
        /* ViewFlag.Dirty */
      ) ? 1 : 0), this.markedForComposition.add(o);
      let l = ne.get(s);
      l && l != o && (l.dom = null), o.setDOM(s);
    }, i = this.childPos(e.range.fromB, 1), n = this.children[i.i];
    t(e.line, n);
    for (let s = e.marks.length - 1; s >= -1; s--)
      i = n.childPos(i.off, 1), n = n.children[i.i], t(s >= 0 ? e.marks[s].node : e.text, n);
  }
  // Sync the DOM selection to this.state.selection
  updateSelection(e = !1, t = !1) {
    (e || !this.view.observer.selectionRange.focusNode) && this.view.observer.readSelectionRange();
    let i = this.view.root.activeElement, n = i == this.dom, s = !n && !(this.view.state.facet(Lt) || this.dom.tabIndex > -1) && Kn(this.dom, this.view.observer.selectionRange) && !(i && this.dom.contains(i));
    if (!(n || t || s))
      return;
    let o = this.forceSelection;
    this.forceSelection = !1;
    let l = this.view.state.selection.main, a = this.moveToLine(this.domAtPos(l.anchor)), h = l.empty ? a : this.moveToLine(this.domAtPos(l.head));
    if (E.gecko && l.empty && !this.hasComposition && O0(a)) {
      let f = document.createTextNode("");
      this.view.observer.ignore(() => a.node.insertBefore(f, a.node.childNodes[a.offset] || null)), a = h = new Te(f, 0), o = !0;
    }
    let c = this.view.observer.selectionRange;
    (o || !c.focusNode || (!Tr(a.node, a.offset, c.anchorNode, c.anchorOffset) || !Tr(h.node, h.offset, c.focusNode, c.focusOffset)) && !this.suppressWidgetCursorChange(c, l)) && (this.view.observer.ignore(() => {
      E.android && E.chrome && this.dom.contains(c.focusNode) && S0(c.focusNode, this.dom) && (this.dom.blur(), this.dom.focus({ preventScroll: !0 }));
      let f = Br(this.view.root);
      if (f) if (l.empty) {
        if (E.gecko) {
          let u = g0(a.node, a.offset);
          if (u && u != 3) {
            let d = (u == 1 ? pd : Od)(a.node, a.offset);
            d && (a = new Te(d.node, d.offset));
          }
        }
        f.collapse(a.node, a.offset), l.bidiLevel != null && f.caretBidiLevel !== void 0 && (f.caretBidiLevel = l.bidiLevel);
      } else if (f.extend) {
        f.collapse(a.node, a.offset);
        try {
          f.extend(h.node, h.offset);
        } catch {
        }
      } else {
        let u = document.createRange();
        l.anchor > l.head && ([a, h] = [h, a]), u.setEnd(h.node, h.offset), u.setStart(a.node, a.offset), f.removeAllRanges(), f.addRange(u);
      }
      s && this.view.root.activeElement == this.dom && (this.dom.blur(), i && i.focus());
    }), this.view.observer.setSelectionRange(a, h)), this.impreciseAnchor = a.precise ? null : new Te(c.anchorNode, c.anchorOffset), this.impreciseHead = h.precise ? null : new Te(c.focusNode, c.focusOffset);
  }
  // If a zero-length widget is inserted next to the cursor during
  // composition, avoid moving it across it and disrupting the
  // composition.
  suppressWidgetCursorChange(e, t) {
    return this.hasComposition && t.empty && Tr(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset) && this.posFromDOM(e.focusNode, e.focusOffset) == t.head;
  }
  enforceCursorAssoc() {
    if (this.hasComposition)
      return;
    let { view: e } = this, t = e.state.selection.main, i = Br(e.root), { anchorNode: n, anchorOffset: s } = e.observer.selectionRange;
    if (!i || !t.empty || !t.assoc || !i.modify)
      return;
    let o = Oe.find(this, t.head);
    if (!o)
      return;
    let l = o.posAtStart;
    if (t.head == l || t.head == l + o.length)
      return;
    let a = this.coordsAt(t.head, -1), h = this.coordsAt(t.head, 1);
    if (!a || !h || a.bottom > h.top)
      return;
    let c = this.domAtPos(t.head + t.assoc);
    i.collapse(c.node, c.offset), i.modify("move", t.assoc < 0 ? "forward" : "backward", "lineboundary"), e.observer.readSelectionRange();
    let f = e.observer.selectionRange;
    e.docView.posFromDOM(f.anchorNode, f.anchorOffset) != t.from && i.collapse(n, s);
  }
  // If a position is in/near a block widget, move it to a nearby text
  // line, since we don't want the cursor inside a block widget.
  moveToLine(e) {
    let t = this.dom, i;
    if (e.node != t)
      return e;
    for (let n = e.offset; !i && n < t.childNodes.length; n++) {
      let s = ne.get(t.childNodes[n]);
      s instanceof Oe && (i = s.domAtPos(0));
    }
    for (let n = e.offset - 1; !i && n >= 0; n--) {
      let s = ne.get(t.childNodes[n]);
      s instanceof Oe && (i = s.domAtPos(s.length));
    }
    return i ? new Te(i.node, i.offset, !0) : e;
  }
  nearest(e) {
    for (let t = e; t; ) {
      let i = ne.get(t);
      if (i && i.rootView == this)
        return i;
      t = t.parentNode;
    }
    return null;
  }
  posFromDOM(e, t) {
    let i = this.nearest(e);
    if (!i)
      throw new RangeError("Trying to find position for a DOM position outside of the document");
    return i.localPosFromDOM(e, t) + i.posAtStart;
  }
  domAtPos(e) {
    let { i: t, off: i } = this.childCursor().findPos(e, -1);
    for (; t < this.children.length - 1; ) {
      let n = this.children[t];
      if (i < n.length || n instanceof Oe)
        break;
      t++, i = 0;
    }
    return this.children[t].domAtPos(i);
  }
  coordsAt(e, t) {
    let i = null, n = 0;
    for (let s = this.length, o = this.children.length - 1; o >= 0; o--) {
      let l = this.children[o], a = s - l.breakAfter, h = a - l.length;
      if (a < e)
        break;
      if (h <= e && (h < e || l.covers(-1)) && (a > e || l.covers(1)) && (!i || l instanceof Oe && !(i instanceof Oe && t >= 0)))
        i = l, n = h;
      else if (i && h == e && a == e && l instanceof zt && Math.abs(t) < 2) {
        if (l.deco.startSide < 0)
          break;
        o && (i = null);
      }
      s = h;
    }
    return i ? i.coordsAt(e - n, t) : null;
  }
  coordsForChar(e) {
    let { i: t, off: i } = this.childPos(e, 1), n = this.children[t];
    if (!(n instanceof Oe))
      return null;
    for (; n.children.length; ) {
      let { i: l, off: a } = n.childPos(i, 1);
      for (; ; l++) {
        if (l == n.children.length)
          return null;
        if ((n = n.children[l]).length)
          break;
      }
      i = a;
    }
    if (!(n instanceof at))
      return null;
    let s = De(n.text, i);
    if (s == i)
      return null;
    let o = $i(n.dom, i, s).getClientRects();
    for (let l = 0; l < o.length; l++) {
      let a = o[l];
      if (l == o.length - 1 || a.top < a.bottom && a.left < a.right)
        return a;
    }
    return null;
  }
  measureVisibleLineHeights(e) {
    let t = [], { from: i, to: n } = e, s = this.view.contentDOM.clientWidth, o = s > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1, l = -1, a = this.view.textDirection == ce.LTR;
    for (let h = 0, c = 0; c < this.children.length; c++) {
      let f = this.children[c], u = h + f.length;
      if (u > n)
        break;
      if (h >= i) {
        let d = f.dom.getBoundingClientRect();
        if (t.push(d.height), o) {
          let p = f.dom.lastChild, O = p ? Ir(p) : [];
          if (O.length) {
            let g = O[O.length - 1], b = a ? g.right - d.left : d.right - g.left;
            b > l && (l = b, this.minWidth = s, this.minWidthFrom = h, this.minWidthTo = u);
          }
        }
      }
      h = u + f.breakAfter;
    }
    return t;
  }
  textDirectionAt(e) {
    let { i: t } = this.childPos(e, 1);
    return getComputedStyle(this.children[t].dom).direction == "rtl" ? ce.RTL : ce.LTR;
  }
  measureTextSize() {
    for (let s of this.children)
      if (s instanceof Oe) {
        let o = s.measureTextSize();
        if (o)
          return o;
      }
    let e = document.createElement("div"), t, i, n;
    return e.className = "cm-line", e.style.width = "99999px", e.style.position = "absolute", e.textContent = "abc def ghi jkl mno pqr stu", this.view.observer.ignore(() => {
      this.dom.appendChild(e);
      let s = Ir(e.firstChild)[0];
      t = e.getBoundingClientRect().height, i = s ? s.width / 27 : 7, n = s ? s.height : t, e.remove();
    }), { lineHeight: t, charWidth: i, textHeight: n };
  }
  childCursor(e = this.length) {
    let t = this.children.length;
    return t && (e -= this.children[--t].length), new md(this.children, e, t);
  }
  computeBlockGapDeco() {
    let e = [], t = this.view.viewState;
    for (let i = 0, n = 0; ; n++) {
      let s = n == t.viewports.length ? null : t.viewports[n], o = s ? s.from - 1 : this.length;
      if (o > i) {
        let l = (t.lineBlockAt(o).bottom - t.lineBlockAt(i).top) / this.view.scaleY;
        e.push(B.replace({
          widget: new _l(l),
          block: !0,
          inclusive: !0,
          isBlockGap: !0
        }).range(i, o));
      }
      if (!s)
        break;
      i = s.to + 1;
    }
    return B.set(e);
  }
  updateDeco() {
    let e = 1, t = this.view.state.facet(Vr).map((s) => (this.dynamicDecorationMap[e++] = typeof s == "function") ? s(this.view) : s), i = !1, n = this.view.state.facet(_d).map((s, o) => {
      let l = typeof s == "function";
      return l && (i = !0), l ? s(this.view) : s;
    });
    for (n.length && (this.dynamicDecorationMap[e++] = i, t.push(H.join(n))), this.decorations = [
      this.editContextFormatting,
      ...t,
      this.computeBlockGapDeco(),
      this.view.viewState.lineGapDeco
    ]; e < this.decorations.length; )
      this.dynamicDecorationMap[e++] = !1;
    return this.decorations;
  }
  scrollIntoView(e) {
    if (e.isSnapshot) {
      let h = this.view.viewState.lineBlockAt(e.range.head);
      this.view.scrollDOM.scrollTop = h.top - e.yMargin, this.view.scrollDOM.scrollLeft = e.xMargin;
      return;
    }
    for (let h of this.view.state.facet(Ed))
      try {
        if (h(this.view, e.range, e))
          return !0;
      } catch (c) {
        Qe(this.view.state, c, "scroll handler");
      }
    let { range: t } = e, i = this.coordsAt(t.head, t.empty ? t.assoc : t.head > t.anchor ? -1 : 1), n;
    if (!i)
      return;
    !t.empty && (n = this.coordsAt(t.anchor, t.anchor > t.head ? -1 : 1)) && (i = {
      left: Math.min(i.left, n.left),
      top: Math.min(i.top, n.top),
      right: Math.max(i.right, n.right),
      bottom: Math.max(i.bottom, n.bottom)
    });
    let s = ja(this.view), o = {
      left: i.left - s.left,
      top: i.top - s.top,
      right: i.right + s.right,
      bottom: i.bottom + s.bottom
    }, { offsetWidth: l, offsetHeight: a } = this.view.scrollDOM;
    Gg(this.view.scrollDOM, o, t.head < t.anchor ? -1 : 1, e.x, e.y, Math.max(Math.min(e.xMargin, l), -l), Math.max(Math.min(e.yMargin, a), -a), this.view.textDirection == ce.LTR);
  }
}
function O0(r) {
  return r.node.nodeType == 1 && r.node.firstChild && (r.offset == 0 || r.node.childNodes[r.offset - 1].contentEditable == "false") && (r.offset == r.node.childNodes.length || r.node.childNodes[r.offset].contentEditable == "false");
}
function Vd(r, e) {
  let t = r.observer.selectionRange;
  if (!t.focusNode)
    return null;
  let i = pd(t.focusNode, t.focusOffset), n = Od(t.focusNode, t.focusOffset), s = i || n;
  if (n && i && n.node != i.node) {
    let l = ne.get(n.node);
    if (!l || l instanceof at && l.text != n.node.nodeValue)
      s = n;
    else if (r.docView.lastCompositionAfterCursor) {
      let a = ne.get(i.node);
      !a || a instanceof at && a.text != i.node.nodeValue || (s = n);
    }
  }
  if (r.docView.lastCompositionAfterCursor = s != i, !s)
    return null;
  let o = e - s.offset;
  return { from: o, to: o + s.node.nodeValue.length, node: s.node };
}
function m0(r, e, t) {
  let i = Vd(r, t);
  if (!i)
    return null;
  let { node: n, from: s, to: o } = i, l = n.nodeValue;
  if (/[\n\r]/.test(l) || r.state.doc.sliceString(i.from, i.to) != l)
    return null;
  let a = e.invertedDesc, h = new it(a.mapPos(s), a.mapPos(o), s, o), c = [];
  for (let f = n.parentNode; ; f = f.parentNode) {
    let u = ne.get(f);
    if (u instanceof Bt)
      c.push({ node: f, deco: u.mark });
    else {
      if (u instanceof Oe || f.nodeName == "DIV" && f.parentNode == r.contentDOM)
        return { range: h, text: n, marks: c, line: f };
      if (f != r.contentDOM)
        c.push({ node: f, deco: new on({
          inclusive: !0,
          attributes: r0(f),
          tagName: f.tagName.toLowerCase()
        }) });
      else
        return null;
    }
  }
}
function g0(r, e) {
  return r.nodeType != 1 ? 0 : (e && r.childNodes[e - 1].contentEditable == "false" ? 1 : 0) | (e < r.childNodes.length && r.childNodes[e].contentEditable == "false" ? 2 : 0);
}
let b0 = class {
  constructor() {
    this.changes = [];
  }
  compareRange(e, t) {
    Jn(e, t, this.changes);
  }
  comparePoint(e, t) {
    Jn(e, t, this.changes);
  }
  boundChange(e) {
    Jn(e, e, this.changes);
  }
};
function y0(r, e, t) {
  let i = new b0();
  return H.compare(r, e, t, i), i.changes;
}
function S0(r, e) {
  for (let t = r; t && t != e; t = t.assignedSlot || t.parentNode)
    if (t.nodeType == 1 && t.contentEditable == "false")
      return !0;
  return !1;
}
function w0(r, e) {
  let t = !1;
  return e && r.iterChangedRanges((i, n) => {
    i < e.to && n > e.from && (t = !0);
  }), t;
}
function x0(r, e, t = 1) {
  let i = r.charCategorizer(e), n = r.doc.lineAt(e), s = e - n.from;
  if (n.length == 0)
    return v.cursor(e);
  s == 0 ? t = 1 : s == n.length && (t = -1);
  let o = s, l = s;
  t < 0 ? o = De(n.text, s, !1) : l = De(n.text, s);
  let a = i(n.text.slice(o, l));
  for (; o > 0; ) {
    let h = De(n.text, o, !1);
    if (i(n.text.slice(h, o)) != a)
      break;
    o = h;
  }
  for (; l < n.length; ) {
    let h = De(n.text, l);
    if (i(n.text.slice(l, h)) != a)
      break;
    l = h;
  }
  return v.range(o + n.from, l + n.from);
}
function k0(r, e) {
  return e.left > r ? e.left - r : Math.max(0, r - e.right);
}
function Q0(r, e) {
  return e.top > r ? e.top - r : Math.max(0, r - e.bottom);
}
function vo(r, e) {
  return r.top < e.bottom - 1 && r.bottom > e.top + 1;
}
function nc(r, e) {
  return e < r.top ? { top: e, left: r.left, right: r.right, bottom: r.bottom } : r;
}
function sc(r, e) {
  return e > r.bottom ? { top: r.top, left: r.left, right: r.right, bottom: e } : r;
}
function Yl(r, e, t) {
  let i, n, s, o, l = !1, a, h, c, f;
  for (let p = r.firstChild; p; p = p.nextSibling) {
    let O = Ir(p);
    for (let g = 0; g < O.length; g++) {
      let b = O[g];
      n && vo(n, b) && (b = nc(sc(b, n.bottom), n.top));
      let w = k0(e, b), k = Q0(t, b);
      if (w == 0 && k == 0)
        return p.nodeType == 3 ? oc(p, e, t) : Yl(p, e, t);
      (!i || o > k || o == k && s > w) && (i = p, n = b, s = w, o = k, l = w ? e < b.left ? g > 0 : g < O.length - 1 : !0), w == 0 ? t > b.bottom && (!c || c.bottom < b.bottom) ? (a = p, c = b) : t < b.top && (!f || f.top > b.top) && (h = p, f = b) : c && vo(c, b) ? c = sc(c, b.bottom) : f && vo(f, b) && (f = nc(f, b.top));
    }
  }
  if (c && c.bottom >= t ? (i = a, n = c) : f && f.top <= t && (i = h, n = f), !i)
    return { node: r, offset: 0 };
  let u = Math.max(n.left, Math.min(n.right, e));
  if (i.nodeType == 3)
    return oc(i, u, t);
  if (l && i.contentEditable != "false")
    return Yl(i, u, t);
  let d = Array.prototype.indexOf.call(r.childNodes, i) + (e >= (n.left + n.right) / 2 ? 1 : 0);
  return { node: r, offset: d };
}
function oc(r, e, t) {
  let i = r.nodeValue.length, n = -1, s = 1e9, o = 0;
  for (let l = 0; l < i; l++) {
    let a = $i(r, l, l + 1).getClientRects();
    for (let h = 0; h < a.length; h++) {
      let c = a[h];
      if (c.top == c.bottom)
        continue;
      o || (o = e - c.left);
      let f = (c.top > t ? c.top - t : t - c.bottom) - 1;
      if (c.left - 1 <= e && c.right + 1 >= e && f < s) {
        let u = e >= (c.left + c.right) / 2, d = u;
        if ((E.chrome || E.gecko) && $i(r, l).getBoundingClientRect().left == c.right && (d = !u), f <= 0)
          return { node: r, offset: l + (d ? 1 : 0) };
        n = l + (d ? 1 : 0), s = f;
      }
    }
  }
  return { node: r, offset: n > -1 ? n : o > 0 ? r.nodeValue.length : 0 };
}
function qd(r, e, t, i = -1) {
  var n, s;
  let o = r.contentDOM.getBoundingClientRect(), l = o.top + r.viewState.paddingTop, a, { docHeight: h } = r.viewState, { x: c, y: f } = e, u = f - l;
  if (u < 0)
    return 0;
  if (u > h)
    return r.state.doc.length;
  for (let x = r.viewState.heightOracle.textHeight / 2, S = !1; a = r.elementAtHeight(u), a.type != Xe.Text; )
    for (; u = i > 0 ? a.bottom + x : a.top - x, !(u >= 0 && u <= h); ) {
      if (S)
        return t ? null : 0;
      S = !0, i = -i;
    }
  f = l + u;
  let d = a.from;
  if (d < r.viewport.from)
    return r.viewport.from == 0 ? 0 : t ? null : lc(r, o, a, c, f);
  if (d > r.viewport.to)
    return r.viewport.to == r.state.doc.length ? r.state.doc.length : t ? null : lc(r, o, a, c, f);
  let p = r.dom.ownerDocument, O = r.root.elementFromPoint ? r.root : p, g = O.elementFromPoint(c, f);
  g && !r.contentDOM.contains(g) && (g = null), g || (c = Math.max(o.left + 1, Math.min(o.right - 1, c)), g = O.elementFromPoint(c, f), g && !r.contentDOM.contains(g) && (g = null));
  let b, w = -1;
  if (g && ((n = r.docView.nearest(g)) === null || n === void 0 ? void 0 : n.isEditable) != !1) {
    if (p.caretPositionFromPoint) {
      let x = p.caretPositionFromPoint(c, f);
      x && ({ offsetNode: b, offset: w } = x);
    } else if (p.caretRangeFromPoint) {
      let x = p.caretRangeFromPoint(c, f);
      x && ({ startContainer: b, startOffset: w } = x);
    }
    b && (!r.contentDOM.contains(b) || E.safari && v0(b, w, c) || E.chrome && $0(b, w, c)) && (b = void 0), b && (w = Math.min(Ct(b), w));
  }
  if (!b || !r.docView.dom.contains(b)) {
    let x = Oe.find(r.docView, d);
    if (!x)
      return u > a.top + a.height / 2 ? a.to : a.from;
    ({ node: b, offset: w } = Yl(x.dom, c, f));
  }
  let k = r.docView.nearest(b);
  if (!k)
    return null;
  if (k.isWidget && ((s = k.dom) === null || s === void 0 ? void 0 : s.nodeType) == 1) {
    let x = k.dom.getBoundingClientRect();
    return e.y < x.top || e.y <= x.bottom && e.x <= (x.left + x.right) / 2 ? k.posAtStart : k.posAtEnd;
  } else
    return k.localPosFromDOM(b, w) + k.posAtStart;
}
function lc(r, e, t, i, n) {
  let s = Math.round((i - e.left) * r.defaultCharacterWidth);
  if (r.lineWrapping && t.height > r.defaultLineHeight * 1.5) {
    let l = r.viewState.heightOracle.textHeight, a = Math.floor((n - t.top - (r.defaultLineHeight - l) * 0.5) / l);
    s += a * r.viewState.heightOracle.lineLength;
  }
  let o = r.state.sliceDoc(t.from, t.to);
  return t.from + Tl(o, s, r.state.tabSize);
}
function Yd(r, e, t) {
  let i, n = r;
  if (r.nodeType != 3 || e != (i = r.nodeValue.length))
    return !1;
  for (; ; ) {
    let s = n.nextSibling;
    if (s) {
      if (s.nodeName == "BR")
        break;
      return !1;
    } else {
      let o = n.parentNode;
      if (!o || o.nodeName == "DIV")
        break;
      n = o;
    }
  }
  return $i(r, i - 1, i).getBoundingClientRect().right > t;
}
function v0(r, e, t) {
  return Yd(r, e, t);
}
function $0(r, e, t) {
  if (e != 0)
    return Yd(r, e, t);
  for (let n = r; ; ) {
    let s = n.parentNode;
    if (!s || s.nodeType != 1 || s.firstChild != n)
      return !1;
    if (s.classList.contains("cm-line"))
      break;
    n = s;
  }
  let i = r.nodeType == 1 ? r.getBoundingClientRect() : $i(r, 0, Math.max(r.nodeValue.length, 1)).getBoundingClientRect();
  return t - i.left > 5;
}
function Nl(r, e, t) {
  let i = r.lineBlockAt(e);
  if (Array.isArray(i.type)) {
    let n;
    for (let s of i.type) {
      if (s.from > e)
        break;
      if (!(s.to < e)) {
        if (s.from < e && s.to > e)
          return s;
        (!n || s.type == Xe.Text && (n.type != s.type || (t < 0 ? s.from < e : s.to > e))) && (n = s);
      }
    }
    return n || i;
  }
  return i;
}
function P0(r, e, t, i) {
  let n = Nl(r, e.head, e.assoc || -1), s = !i || n.type != Xe.Text || !(r.lineWrapping || n.widgetLineBreaks) ? null : r.coordsAtPos(e.assoc < 0 && e.head > n.from ? e.head - 1 : e.head);
  if (s) {
    let o = r.dom.getBoundingClientRect(), l = r.textDirectionAt(n.from), a = r.posAtCoords({
      x: t == (l == ce.LTR) ? o.right - 1 : o.left + 1,
      y: (s.top + s.bottom) / 2
    });
    if (a != null)
      return v.cursor(a, t ? -1 : 1);
  }
  return v.cursor(t ? n.to : n.from, t ? -1 : 1);
}
function ac(r, e, t, i) {
  let n = r.state.doc.lineAt(e.head), s = r.bidiSpans(n), o = r.textDirectionAt(n.from);
  for (let l = e, a = null; ; ) {
    let h = u0(n, s, o, l, t), c = Pd;
    if (!h) {
      if (n.number == (t ? r.state.doc.lines : 1))
        return l;
      c = `
`, n = r.state.doc.line(n.number + (t ? 1 : -1)), s = r.bidiSpans(n), h = r.visualLineSide(n, !t);
    }
    if (a) {
      if (!a(c))
        return l;
    } else {
      if (!i)
        return h;
      a = i(c);
    }
    l = h;
  }
}
function C0(r, e, t) {
  let i = r.state.charCategorizer(e), n = i(t);
  return (s) => {
    let o = i(s);
    return n == Ze.Space && (n = o), n == o;
  };
}
function T0(r, e, t, i) {
  let n = e.head, s = t ? 1 : -1;
  if (n == (t ? r.state.doc.length : 0))
    return v.cursor(n, e.assoc);
  let o = e.goalColumn, l, a = r.contentDOM.getBoundingClientRect(), h = r.coordsAtPos(n, e.assoc || -1), c = r.documentTop;
  if (h)
    o == null && (o = h.left - a.left), l = s < 0 ? h.top : h.bottom;
  else {
    let d = r.viewState.lineBlockAt(n);
    o == null && (o = Math.min(a.right - a.left, r.defaultCharacterWidth * (n - d.from))), l = (s < 0 ? d.top : d.bottom) + c;
  }
  let f = a.left + o, u = i ?? r.viewState.heightOracle.textHeight >> 1;
  for (let d = 0; ; d += 10) {
    let p = l + (u + d) * s, O = qd(r, { x: f, y: p }, !1, s);
    if (p < a.top || p > a.bottom || (s < 0 ? O < n : O > n)) {
      let g = r.docView.coordsForChar(O), b = !g || p < g.top ? -1 : 1;
      return v.cursor(O, b, void 0, o);
    }
  }
}
function Mr(r, e, t) {
  for (; ; ) {
    let i = 0;
    for (let n of r)
      n.between(e - 1, e + 1, (s, o, l) => {
        if (e > s && e < o) {
          let a = i || t || (e - s < o - e ? -1 : 1);
          e = a < 0 ? s : o, i = a;
        }
      });
    if (!i)
      return e;
  }
}
function Nd(r, e) {
  let t = null;
  for (let i = 0; i < e.ranges.length; i++) {
    let n = e.ranges[i], s = null;
    if (n.empty) {
      let o = Mr(r, n.from, 0);
      o != n.from && (s = v.cursor(o, -1));
    } else {
      let o = Mr(r, n.from, -1), l = Mr(r, n.to, 1);
      (o != n.from || l != n.to) && (s = v.range(n.from == n.anchor ? o : l, n.from == n.head ? o : l));
    }
    s && (t || (t = e.ranges.slice()), t[i] = s);
  }
  return t ? v.create(t, e.mainIndex) : e;
}
function $o(r, e, t) {
  let i = Mr(r.state.facet(an).map((n) => n(r)), t.from, e.head > t.from ? -1 : 1);
  return i == t.from ? t : v.cursor(i, i < t.from ? 1 : -1);
}
const wr = "";
class A0 {
  constructor(e, t) {
    this.points = e, this.text = "", this.lineSeparator = t.facet(W.lineSeparator);
  }
  append(e) {
    this.text += e;
  }
  lineBreak() {
    this.text += wr;
  }
  readRange(e, t) {
    if (!e)
      return this;
    let i = e.parentNode;
    for (let n = e; ; ) {
      this.findPointBefore(i, n);
      let s = this.text.length;
      this.readNode(n);
      let o = n.nextSibling;
      if (o == t)
        break;
      let l = ne.get(n), a = ne.get(o);
      (l && a ? l.breakAfter : (l ? l.breakAfter : bs(n)) || bs(o) && (n.nodeName != "BR" || n.cmIgnore) && this.text.length > s) && !Z0(o, t) && this.lineBreak(), n = o;
    }
    return this.findPointBefore(i, t), this;
  }
  readTextNode(e) {
    let t = e.nodeValue;
    for (let i of this.points)
      i.node == e && (i.pos = this.text.length + Math.min(i.offset, t.length));
    for (let i = 0, n = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
      let s = -1, o = 1, l;
      if (this.lineSeparator ? (s = t.indexOf(this.lineSeparator, i), o = this.lineSeparator.length) : (l = n.exec(t)) && (s = l.index, o = l[0].length), this.append(t.slice(i, s < 0 ? t.length : s)), s < 0)
        break;
      if (this.lineBreak(), o > 1)
        for (let a of this.points)
          a.node == e && a.pos > this.text.length && (a.pos -= o - 1);
      i = s + o;
    }
  }
  readNode(e) {
    if (e.cmIgnore)
      return;
    let t = ne.get(e), i = t && t.overrideDOMText;
    if (i != null) {
      this.findPointInside(e, i.length);
      for (let n = i.iter(); !n.next().done; )
        n.lineBreak ? this.lineBreak() : this.append(n.value);
    } else e.nodeType == 3 ? this.readTextNode(e) : e.nodeName == "BR" ? e.nextSibling && this.lineBreak() : e.nodeType == 1 && this.readRange(e.firstChild, null);
  }
  findPointBefore(e, t) {
    for (let i of this.points)
      i.node == e && e.childNodes[i.offset] == t && (i.pos = this.text.length);
  }
  findPointInside(e, t) {
    for (let i of this.points)
      (e.nodeType == 3 ? i.node == e : e.contains(i.node)) && (i.pos = this.text.length + (M0(e, i.node, i.offset) ? t : 0));
  }
}
function M0(r, e, t) {
  for (; ; ) {
    if (!e || t < Ct(e))
      return !1;
    if (e == r)
      return !0;
    t = vi(e) + 1, e = e.parentNode;
  }
}
function Z0(r, e) {
  let t;
  for (; !(r == e || !r); r = r.nextSibling) {
    let i = ne.get(r);
    if (!(i?.isWidget || r.cmIgnore))
      return !1;
    i && (t || (t = [])).push(i);
  }
  if (t)
    for (let i of t) {
      let n = i.overrideDOMText;
      if (n?.length)
        return !1;
    }
  return !0;
}
class hc {
  constructor(e, t) {
    this.node = e, this.offset = t, this.pos = -1;
  }
}
class X0 {
  constructor(e, t, i, n) {
    this.typeOver = n, this.bounds = null, this.text = "", this.domChanged = t > -1;
    let { impreciseHead: s, impreciseAnchor: o } = e.docView;
    if (e.state.readOnly && t > -1)
      this.newSel = null;
    else if (t > -1 && (this.bounds = e.docView.domBoundsAround(t, i, 0))) {
      let l = s || o ? [] : L0(e), a = new A0(l, e.state);
      a.readRange(this.bounds.startDOM, this.bounds.endDOM), this.text = a.text, this.newSel = E0(l, this.bounds.from);
    } else {
      let l = e.observer.selectionRange, a = s && s.node == l.focusNode && s.offset == l.focusOffset || !El(e.contentDOM, l.focusNode) ? e.state.selection.main.head : e.docView.posFromDOM(l.focusNode, l.focusOffset), h = o && o.node == l.anchorNode && o.offset == l.anchorOffset || !El(e.contentDOM, l.anchorNode) ? e.state.selection.main.anchor : e.docView.posFromDOM(l.anchorNode, l.anchorOffset), c = e.viewport;
      if ((E.ios || E.chrome) && e.state.selection.main.empty && a != h && (c.from > 0 || c.to < e.state.doc.length)) {
        let f = Math.min(a, h), u = Math.max(a, h), d = c.from - f, p = c.to - u;
        (d == 0 || d == 1 || f == 0) && (p == 0 || p == -1 || u == e.state.doc.length) && (a = 0, h = e.state.doc.length);
      }
      this.newSel = v.single(h, a);
    }
  }
}
function Wd(r, e) {
  let t, { newSel: i } = e, n = r.state.selection.main, s = r.inputState.lastKeyTime > Date.now() - 100 ? r.inputState.lastKeyCode : -1;
  if (e.bounds) {
    let { from: o, to: l } = e.bounds, a = n.from, h = null;
    (s === 8 || E.android && e.text.length < l - o) && (a = n.to, h = "end");
    let c = jd(r.state.doc.sliceString(o, l, wr), e.text, a - o, h);
    c && (E.chrome && s == 13 && c.toB == c.from + 2 && e.text.slice(c.from, c.toB) == wr + wr && c.toB--, t = {
      from: o + c.from,
      to: o + c.toA,
      insert: K.of(e.text.slice(c.from, c.toB).split(wr))
    });
  } else i && (!r.hasFocus && r.state.facet(Lt) || i.main.eq(n)) && (i = null);
  if (!t && !i)
    return !1;
  if (!t && e.typeOver && !n.empty && i && i.main.empty ? t = { from: n.from, to: n.to, insert: r.state.doc.slice(n.from, n.to) } : (E.mac || E.android) && t && t.from == t.to && t.from == n.head - 1 && /^\. ?$/.test(t.insert.toString()) && r.contentDOM.getAttribute("autocorrect") == "off" ? (i && t.insert.length == 2 && (i = v.single(i.main.anchor - 1, i.main.head - 1)), t = { from: t.from, to: t.to, insert: K.of([t.insert.toString().replace(".", " ")]) }) : t && t.from >= n.from && t.to <= n.to && (t.from != n.from || t.to != n.to) && n.to - n.from - (t.to - t.from) <= 4 ? t = {
    from: n.from,
    to: n.to,
    insert: r.state.doc.slice(n.from, t.from).append(t.insert).append(r.state.doc.slice(t.to, n.to))
  } : E.chrome && t && t.from == t.to && t.from == n.head && t.insert.toString() == `
 ` && r.lineWrapping && (i && (i = v.single(i.main.anchor - 1, i.main.head - 1)), t = { from: n.from, to: n.to, insert: K.of([" "]) }), t)
    return Ga(r, t, i, s);
  if (i && !i.main.eq(n)) {
    let o = !1, l = "select";
    return r.inputState.lastSelectionTime > Date.now() - 50 && (r.inputState.lastSelectionOrigin == "select" && (o = !0), l = r.inputState.lastSelectionOrigin, l == "select.pointer" && (i = Nd(r.state.facet(an).map((a) => a(r)), i))), r.dispatch({ selection: i, scrollIntoView: o, userEvent: l }), !0;
  } else
    return !1;
}
function Ga(r, e, t, i = -1) {
  if (E.ios && r.inputState.flushIOSKey(e))
    return !0;
  let n = r.state.selection.main;
  if (E.android && (e.to == n.to && // GBoard will sometimes remove a space it just inserted
  // after a completion when you press enter
  (e.from == n.from || e.from == n.from - 1 && r.state.sliceDoc(e.from, n.from) == " ") && e.insert.length == 1 && e.insert.lines == 2 && Di(r.contentDOM, "Enter", 13) || (e.from == n.from - 1 && e.to == n.to && e.insert.length == 0 || i == 8 && e.insert.length < e.to - e.from && e.to > n.head) && Di(r.contentDOM, "Backspace", 8) || e.from == n.from && e.to == n.to + 1 && e.insert.length == 0 && Di(r.contentDOM, "Delete", 46)))
    return !0;
  let s = e.insert.toString();
  r.inputState.composing >= 0 && r.inputState.composing++;
  let o, l = () => o || (o = R0(r, e, t));
  return r.state.facet(Zd).some((a) => a(r, e.from, e.to, s, l)) || r.dispatch(l()), !0;
}
function R0(r, e, t) {
  let i, n = r.state, s = n.selection.main, o = -1;
  if (e.from == e.to && e.from < s.from || e.from > s.to) {
    let a = e.from < s.from ? -1 : 1, h = a < 0 ? s.from : s.to, c = Mr(n.facet(an).map((f) => f(r)), h, a);
    e.from == c && (o = c);
  }
  if (o > -1)
    i = {
      changes: e,
      selection: v.cursor(e.from + e.insert.length, -1)
    };
  else if (e.from >= s.from && e.to <= s.to && e.to - e.from >= (s.to - s.from) / 3 && (!t || t.main.empty && t.main.from == e.from + e.insert.length) && r.inputState.composing < 0) {
    let a = s.from < e.from ? n.sliceDoc(s.from, e.from) : "", h = s.to > e.to ? n.sliceDoc(e.to, s.to) : "";
    i = n.replaceSelection(r.state.toText(a + e.insert.sliceString(0, void 0, r.state.lineBreak) + h));
  } else {
    let a = n.changes(e), h = t && t.main.to <= a.newLength ? t.main : void 0;
    if (n.selection.ranges.length > 1 && r.inputState.composing >= 0 && e.to <= s.to && e.to >= s.to - 10) {
      let c = r.state.sliceDoc(e.from, e.to), f, u = t && Vd(r, t.main.head);
      if (u) {
        let O = e.insert.length - (e.to - e.from);
        f = { from: u.from, to: u.to - O };
      } else
        f = r.state.doc.lineAt(s.head);
      let d = s.to - e.to, p = s.to - s.from;
      i = n.changeByRange((O) => {
        if (O.from == s.from && O.to == s.to)
          return { changes: a, range: h || O.map(a) };
        let g = O.to - d, b = g - c.length;
        if (O.to - O.from != p || r.state.sliceDoc(b, g) != c || // Unfortunately, there's no way to make multiple
        // changes in the same node work without aborting
        // composition, so cursors in the composition range are
        // ignored.
        O.to >= f.from && O.from <= f.to)
          return { range: O };
        let w = n.changes({ from: b, to: g, insert: e.insert }), k = O.to - s.to;
        return {
          changes: w,
          range: h ? v.range(Math.max(0, h.anchor + k), Math.max(0, h.head + k)) : O.map(w)
        };
      });
    } else
      i = {
        changes: a,
        selection: h && n.selection.replaceRange(h)
      };
  }
  let l = "input.type";
  return (r.composing || r.inputState.compositionPendingChange && r.inputState.compositionEndedAt > Date.now() - 50) && (r.inputState.compositionPendingChange = !1, l += ".compose", r.inputState.compositionFirstChange && (l += ".start", r.inputState.compositionFirstChange = !1)), n.update(i, { userEvent: l, scrollIntoView: !0 });
}
function jd(r, e, t, i) {
  let n = Math.min(r.length, e.length), s = 0;
  for (; s < n && r.charCodeAt(s) == e.charCodeAt(s); )
    s++;
  if (s == n && r.length == e.length)
    return null;
  let o = r.length, l = e.length;
  for (; o > 0 && l > 0 && r.charCodeAt(o - 1) == e.charCodeAt(l - 1); )
    o--, l--;
  if (i == "end") {
    let a = Math.max(0, s - Math.min(o, l));
    t -= o + a - s;
  }
  if (o < s && r.length < e.length) {
    let a = t <= s && t >= o ? s - t : 0;
    s -= a, l = s + (l - o), o = s;
  } else if (l < s) {
    let a = t <= s && t >= l ? s - t : 0;
    s -= a, o = s + (o - l), l = s;
  }
  return { from: s, toA: o, toB: l };
}
function L0(r) {
  let e = [];
  if (r.root.activeElement != r.contentDOM)
    return e;
  let { anchorNode: t, anchorOffset: i, focusNode: n, focusOffset: s } = r.observer.selectionRange;
  return t && (e.push(new hc(t, i)), (n != t || s != i) && e.push(new hc(n, s))), e;
}
function E0(r, e) {
  if (r.length == 0)
    return null;
  let t = r[0].pos, i = r.length == 2 ? r[1].pos : t;
  return t > -1 && i > -1 ? v.single(t + e, i + e) : null;
}
class z0 {
  setSelectionOrigin(e) {
    this.lastSelectionOrigin = e, this.lastSelectionTime = Date.now();
  }
  constructor(e) {
    this.view = e, this.lastKeyCode = 0, this.lastKeyTime = 0, this.lastTouchTime = 0, this.lastFocusTime = 0, this.lastScrollTop = 0, this.lastScrollLeft = 0, this.pendingIOSKey = void 0, this.tabFocusMode = -1, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastContextMenu = 0, this.scrollHandlers = [], this.handlers = /* @__PURE__ */ Object.create(null), this.composing = -1, this.compositionFirstChange = null, this.compositionEndedAt = 0, this.compositionPendingKey = !1, this.compositionPendingChange = !1, this.mouseSelection = null, this.draggedContent = null, this.handleEvent = this.handleEvent.bind(this), this.notifiedFocused = e.hasFocus, E.safari && e.contentDOM.addEventListener("input", () => null), E.gecko && J0(e.contentDOM.ownerDocument);
  }
  handleEvent(e) {
    !N0(this.view, e) || this.ignoreDuringComposition(e) || e.type == "keydown" && this.keydown(e) || (this.view.updateState != 0 ? Promise.resolve().then(() => this.runHandlers(e.type, e)) : this.runHandlers(e.type, e));
  }
  runHandlers(e, t) {
    let i = this.handlers[e];
    if (i) {
      for (let n of i.observers)
        n(this.view, t);
      for (let n of i.handlers) {
        if (t.defaultPrevented)
          break;
        if (n(this.view, t)) {
          t.preventDefault();
          break;
        }
      }
    }
  }
  ensureHandlers(e) {
    let t = D0(e), i = this.handlers, n = this.view.contentDOM;
    for (let s in t)
      if (s != "scroll") {
        let o = !t[s].handlers.length, l = i[s];
        l && o != !l.handlers.length && (n.removeEventListener(s, this.handleEvent), l = null), l || n.addEventListener(s, this.handleEvent, { passive: o });
      }
    for (let s in i)
      s != "scroll" && !t[s] && n.removeEventListener(s, this.handleEvent);
    this.handlers = t;
  }
  keydown(e) {
    if (this.lastKeyCode = e.keyCode, this.lastKeyTime = Date.now(), e.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
      return !0;
    if (this.tabFocusMode > 0 && e.keyCode != 27 && Ud.indexOf(e.keyCode) < 0 && (this.tabFocusMode = -1), E.android && E.chrome && !e.synthetic && (e.keyCode == 13 || e.keyCode == 8))
      return this.view.observer.delayAndroidKey(e.key, e.keyCode), !0;
    let t;
    return E.ios && !e.synthetic && !e.altKey && !e.metaKey && ((t = Gd.find((i) => i.keyCode == e.keyCode)) && !e.ctrlKey || _0.indexOf(e.key) > -1 && e.ctrlKey && !e.shiftKey) ? (this.pendingIOSKey = t || e, setTimeout(() => this.flushIOSKey(), 250), !0) : (e.keyCode != 229 && this.view.observer.forceFlush(), !1);
  }
  flushIOSKey(e) {
    let t = this.pendingIOSKey;
    return !t || t.key == "Enter" && e && e.from < e.to && /^\S+$/.test(e.insert.toString()) ? !1 : (this.pendingIOSKey = void 0, Di(this.view.contentDOM, t.key, t.keyCode, t instanceof KeyboardEvent ? t : void 0));
  }
  ignoreDuringComposition(e) {
    return !/^key/.test(e.type) || e.synthetic ? !1 : this.composing > 0 ? !0 : E.safari && !E.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100 ? (this.compositionPendingKey = !1, !0) : !1;
  }
  startMouseSelection(e) {
    this.mouseSelection && this.mouseSelection.destroy(), this.mouseSelection = e;
  }
  update(e) {
    this.view.observer.update(e), this.mouseSelection && this.mouseSelection.update(e), this.draggedContent && e.docChanged && (this.draggedContent = this.draggedContent.map(e.changes)), e.transactions.length && (this.lastKeyCode = this.lastSelectionTime = 0);
  }
  destroy() {
    this.mouseSelection && this.mouseSelection.destroy();
  }
}
function cc(r, e) {
  return (t, i) => {
    try {
      return e.call(r, i, t);
    } catch (n) {
      Qe(t.state, n);
    }
  };
}
function D0(r) {
  let e = /* @__PURE__ */ Object.create(null);
  function t(i) {
    return e[i] || (e[i] = { observers: [], handlers: [] });
  }
  for (let i of r) {
    let n = i.spec, s = n && n.plugin.domEventHandlers, o = n && n.plugin.domEventObservers;
    if (s)
      for (let l in s) {
        let a = s[l];
        a && t(l).handlers.push(cc(i.value, a));
      }
    if (o)
      for (let l in o) {
        let a = o[l];
        a && t(l).observers.push(cc(i.value, a));
      }
  }
  for (let i in ht)
    t(i).handlers.push(ht[i]);
  for (let i in rt)
    t(i).observers.push(rt[i]);
  return e;
}
const Gd = [
  { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
  { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
  { key: "Enter", keyCode: 13, inputType: "insertLineBreak" },
  { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
], _0 = "dthko", Ud = [16, 17, 18, 20, 91, 92, 224, 225], kn = 6;
function Qn(r) {
  return Math.max(0, r) * 0.7 + 8;
}
function B0(r, e) {
  return Math.max(Math.abs(r.clientX - e.clientX), Math.abs(r.clientY - e.clientY));
}
class I0 {
  constructor(e, t, i, n) {
    this.view = e, this.startEvent = t, this.style = i, this.mustSelect = n, this.scrollSpeed = { x: 0, y: 0 }, this.scrolling = -1, this.lastEvent = t, this.scrollParents = Ug(e.contentDOM), this.atoms = e.state.facet(an).map((o) => o(e));
    let s = e.contentDOM.ownerDocument;
    s.addEventListener("mousemove", this.move = this.move.bind(this)), s.addEventListener("mouseup", this.up = this.up.bind(this)), this.extend = t.shiftKey, this.multiple = e.state.facet(W.allowMultipleSelections) && V0(e, t), this.dragging = Y0(e, t) && Kd(t) == 1 ? null : !1;
  }
  start(e) {
    this.dragging === !1 && this.select(e);
  }
  move(e) {
    if (e.buttons == 0)
      return this.destroy();
    if (this.dragging || this.dragging == null && B0(this.startEvent, e) < 10)
      return;
    this.select(this.lastEvent = e);
    let t = 0, i = 0, n = 0, s = 0, o = this.view.win.innerWidth, l = this.view.win.innerHeight;
    this.scrollParents.x && ({ left: n, right: o } = this.scrollParents.x.getBoundingClientRect()), this.scrollParents.y && ({ top: s, bottom: l } = this.scrollParents.y.getBoundingClientRect());
    let a = ja(this.view);
    e.clientX - a.left <= n + kn ? t = -Qn(n - e.clientX) : e.clientX + a.right >= o - kn && (t = Qn(e.clientX - o)), e.clientY - a.top <= s + kn ? i = -Qn(s - e.clientY) : e.clientY + a.bottom >= l - kn && (i = Qn(e.clientY - l)), this.setScrollSpeed(t, i);
  }
  up(e) {
    this.dragging == null && this.select(this.lastEvent), this.dragging || e.preventDefault(), this.destroy();
  }
  destroy() {
    this.setScrollSpeed(0, 0);
    let e = this.view.contentDOM.ownerDocument;
    e.removeEventListener("mousemove", this.move), e.removeEventListener("mouseup", this.up), this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
  }
  setScrollSpeed(e, t) {
    this.scrollSpeed = { x: e, y: t }, e || t ? this.scrolling < 0 && (this.scrolling = setInterval(() => this.scroll(), 50)) : this.scrolling > -1 && (clearInterval(this.scrolling), this.scrolling = -1);
  }
  scroll() {
    let { x: e, y: t } = this.scrollSpeed;
    e && this.scrollParents.x && (this.scrollParents.x.scrollLeft += e, e = 0), t && this.scrollParents.y && (this.scrollParents.y.scrollTop += t, t = 0), (e || t) && this.view.win.scrollBy(e, t), this.dragging === !1 && this.select(this.lastEvent);
  }
  select(e) {
    let { view: t } = this, i = Nd(this.atoms, this.style.get(e, this.extend, this.multiple));
    (this.mustSelect || !i.eq(t.state.selection, this.dragging === !1)) && this.view.dispatch({
      selection: i,
      userEvent: "select.pointer"
    }), this.mustSelect = !1;
  }
  update(e) {
    e.transactions.some((t) => t.isUserEvent("input.type")) ? this.destroy() : this.style.update(e) && setTimeout(() => this.select(this.lastEvent), 20);
  }
}
function V0(r, e) {
  let t = r.state.facet(Cd);
  return t.length ? t[0](e) : E.mac ? e.metaKey : e.ctrlKey;
}
function q0(r, e) {
  let t = r.state.facet(Td);
  return t.length ? t[0](e) : E.mac ? !e.altKey : !e.ctrlKey;
}
function Y0(r, e) {
  let { main: t } = r.state.selection;
  if (t.empty)
    return !1;
  let i = Br(r.root);
  if (!i || i.rangeCount == 0)
    return !0;
  let n = i.getRangeAt(0).getClientRects();
  for (let s = 0; s < n.length; s++) {
    let o = n[s];
    if (o.left <= e.clientX && o.right >= e.clientX && o.top <= e.clientY && o.bottom >= e.clientY)
      return !0;
  }
  return !1;
}
function N0(r, e) {
  if (!e.bubbles)
    return !0;
  if (e.defaultPrevented)
    return !1;
  for (let t = e.target, i; t != r.contentDOM; t = t.parentNode)
    if (!t || t.nodeType == 11 || (i = ne.get(t)) && i.ignoreEvent(e))
      return !1;
  return !0;
}
const ht = /* @__PURE__ */ Object.create(null), rt = /* @__PURE__ */ Object.create(null), Fd = E.ie && E.ie_version < 15 || E.ios && E.webkit_version < 604;
function W0(r) {
  let e = r.dom.parentNode;
  if (!e)
    return;
  let t = e.appendChild(document.createElement("textarea"));
  t.style.cssText = "position: fixed; left: -10000px; top: 10px", t.focus(), setTimeout(() => {
    r.focus(), t.remove(), Hd(r, t.value);
  }, 50);
}
function ro(r, e, t) {
  for (let i of r.facet(e))
    t = i(t, r);
  return t;
}
function Hd(r, e) {
  e = ro(r.state, Ya, e);
  let { state: t } = r, i, n = 1, s = t.toText(e), o = s.lines == t.selection.ranges.length;
  if (Wl != null && t.selection.ranges.every((a) => a.empty) && Wl == s.toString()) {
    let a = -1;
    i = t.changeByRange((h) => {
      let c = t.doc.lineAt(h.from);
      if (c.from == a)
        return { range: h };
      a = c.from;
      let f = t.toText((o ? s.line(n++).text : e) + t.lineBreak);
      return {
        changes: { from: c.from, insert: f },
        range: v.cursor(h.from + f.length)
      };
    });
  } else o ? i = t.changeByRange((a) => {
    let h = s.line(n++);
    return {
      changes: { from: a.from, to: a.to, insert: h.text },
      range: v.cursor(a.from + h.length)
    };
  }) : i = t.replaceSelection(s);
  r.dispatch(i, {
    userEvent: "input.paste",
    scrollIntoView: !0
  });
}
rt.scroll = (r) => {
  r.inputState.lastScrollTop = r.scrollDOM.scrollTop, r.inputState.lastScrollLeft = r.scrollDOM.scrollLeft;
};
ht.keydown = (r, e) => (r.inputState.setSelectionOrigin("select"), e.keyCode == 27 && r.inputState.tabFocusMode != 0 && (r.inputState.tabFocusMode = Date.now() + 2e3), !1);
rt.touchstart = (r, e) => {
  r.inputState.lastTouchTime = Date.now(), r.inputState.setSelectionOrigin("select.pointer");
};
rt.touchmove = (r) => {
  r.inputState.setSelectionOrigin("select.pointer");
};
ht.mousedown = (r, e) => {
  if (r.observer.flush(), r.inputState.lastTouchTime > Date.now() - 2e3)
    return !1;
  let t = null;
  for (let i of r.state.facet(Ad))
    if (t = i(r, e), t)
      break;
  if (!t && e.button == 0 && (t = U0(r, e)), t) {
    let i = !r.hasFocus;
    r.inputState.startMouseSelection(new I0(r, e, t, i)), i && r.observer.ignore(() => {
      fd(r.contentDOM);
      let s = r.root.activeElement;
      s && !s.contains(r.contentDOM) && s.blur();
    });
    let n = r.inputState.mouseSelection;
    if (n)
      return n.start(e), n.dragging === !1;
  } else
    r.inputState.setSelectionOrigin("select.pointer");
  return !1;
};
function fc(r, e, t, i) {
  if (i == 1)
    return v.cursor(e, t);
  if (i == 2)
    return x0(r.state, e, t);
  {
    let n = Oe.find(r.docView, e), s = r.state.doc.lineAt(n ? n.posAtEnd : e), o = n ? n.posAtStart : s.from, l = n ? n.posAtEnd : s.to;
    return l < r.state.doc.length && l == s.to && l++, v.range(o, l);
  }
}
let uc = (r, e, t) => e >= t.top && e <= t.bottom && r >= t.left && r <= t.right;
function j0(r, e, t, i) {
  let n = Oe.find(r.docView, e);
  if (!n)
    return 1;
  let s = e - n.posAtStart;
  if (s == 0)
    return 1;
  if (s == n.length)
    return -1;
  let o = n.coordsAt(s, -1);
  if (o && uc(t, i, o))
    return -1;
  let l = n.coordsAt(s, 1);
  return l && uc(t, i, l) ? 1 : o && o.bottom >= i ? -1 : 1;
}
function dc(r, e) {
  let t = r.posAtCoords({ x: e.clientX, y: e.clientY }, !1);
  return { pos: t, bias: j0(r, t, e.clientX, e.clientY) };
}
const G0 = E.ie && E.ie_version <= 11;
let pc = null, Oc = 0, mc = 0;
function Kd(r) {
  if (!G0)
    return r.detail;
  let e = pc, t = mc;
  return pc = r, mc = Date.now(), Oc = !e || t > Date.now() - 400 && Math.abs(e.clientX - r.clientX) < 2 && Math.abs(e.clientY - r.clientY) < 2 ? (Oc + 1) % 3 : 1;
}
function U0(r, e) {
  let t = dc(r, e), i = Kd(e), n = r.state.selection;
  return {
    update(s) {
      s.docChanged && (t.pos = s.changes.mapPos(t.pos), n = n.map(s.changes));
    },
    get(s, o, l) {
      let a = dc(r, s), h, c = fc(r, a.pos, a.bias, i);
      if (t.pos != a.pos && !o) {
        let f = fc(r, t.pos, t.bias, i), u = Math.min(f.from, c.from), d = Math.max(f.to, c.to);
        c = u < c.from ? v.range(u, d) : v.range(d, u);
      }
      return o ? n.replaceRange(n.main.extend(c.from, c.to)) : l && i == 1 && n.ranges.length > 1 && (h = F0(n, a.pos)) ? h : l ? n.addRange(c) : v.create([c]);
    }
  };
}
function F0(r, e) {
  for (let t = 0; t < r.ranges.length; t++) {
    let { from: i, to: n } = r.ranges[t];
    if (i <= e && n >= e)
      return v.create(r.ranges.slice(0, t).concat(r.ranges.slice(t + 1)), r.mainIndex == t ? 0 : r.mainIndex - (r.mainIndex > t ? 1 : 0));
  }
  return null;
}
ht.dragstart = (r, e) => {
  let { selection: { main: t } } = r.state;
  if (e.target.draggable) {
    let n = r.docView.nearest(e.target);
    if (n && n.isWidget) {
      let s = n.posAtStart, o = s + n.length;
      (s >= t.to || o <= t.from) && (t = v.range(s, o));
    }
  }
  let { inputState: i } = r;
  return i.mouseSelection && (i.mouseSelection.dragging = !0), i.draggedContent = t, e.dataTransfer && (e.dataTransfer.setData("Text", ro(r.state, Na, r.state.sliceDoc(t.from, t.to))), e.dataTransfer.effectAllowed = "copyMove"), !1;
};
ht.dragend = (r) => (r.inputState.draggedContent = null, !1);
function gc(r, e, t, i) {
  if (t = ro(r.state, Ya, t), !t)
    return;
  let n = r.posAtCoords({ x: e.clientX, y: e.clientY }, !1), { draggedContent: s } = r.inputState, o = i && s && q0(r, e) ? { from: s.from, to: s.to } : null, l = { from: n, insert: t }, a = r.state.changes(o ? [o, l] : l);
  r.focus(), r.dispatch({
    changes: a,
    selection: { anchor: a.mapPos(n, -1), head: a.mapPos(n, 1) },
    userEvent: o ? "move.drop" : "input.drop"
  }), r.inputState.draggedContent = null;
}
ht.drop = (r, e) => {
  if (!e.dataTransfer)
    return !1;
  if (r.state.readOnly)
    return !0;
  let t = e.dataTransfer.files;
  if (t && t.length) {
    let i = Array(t.length), n = 0, s = () => {
      ++n == t.length && gc(r, e, i.filter((o) => o != null).join(r.state.lineBreak), !1);
    };
    for (let o = 0; o < t.length; o++) {
      let l = new FileReader();
      l.onerror = s, l.onload = () => {
        /[\x00-\x08\x0e-\x1f]{2}/.test(l.result) || (i[o] = l.result), s();
      }, l.readAsText(t[o]);
    }
    return !0;
  } else {
    let i = e.dataTransfer.getData("Text");
    if (i)
      return gc(r, e, i, !0), !0;
  }
  return !1;
};
ht.paste = (r, e) => {
  if (r.state.readOnly)
    return !0;
  r.observer.flush();
  let t = Fd ? null : e.clipboardData;
  return t ? (Hd(r, t.getData("text/plain") || t.getData("text/uri-list")), !0) : (W0(r), !1);
};
function H0(r, e) {
  let t = r.dom.parentNode;
  if (!t)
    return;
  let i = t.appendChild(document.createElement("textarea"));
  i.style.cssText = "position: fixed; left: -10000px; top: 10px", i.value = e, i.focus(), i.selectionEnd = e.length, i.selectionStart = 0, setTimeout(() => {
    i.remove(), r.focus();
  }, 50);
}
function K0(r) {
  let e = [], t = [], i = !1;
  for (let n of r.selection.ranges)
    n.empty || (e.push(r.sliceDoc(n.from, n.to)), t.push(n));
  if (!e.length) {
    let n = -1;
    for (let { from: s } of r.selection.ranges) {
      let o = r.doc.lineAt(s);
      o.number > n && (e.push(o.text), t.push({ from: o.from, to: Math.min(r.doc.length, o.to + 1) })), n = o.number;
    }
    i = !0;
  }
  return { text: ro(r, Na, e.join(r.lineBreak)), ranges: t, linewise: i };
}
let Wl = null;
ht.copy = ht.cut = (r, e) => {
  let { text: t, ranges: i, linewise: n } = K0(r.state);
  if (!t && !n)
    return !1;
  Wl = n ? t : null, e.type == "cut" && !r.state.readOnly && r.dispatch({
    changes: i,
    scrollIntoView: !0,
    userEvent: "delete.cut"
  });
  let s = Fd ? null : e.clipboardData;
  return s ? (s.clearData(), s.setData("text/plain", t), !0) : (H0(r, t), !1);
};
const Jd = /* @__PURE__ */ qt.define();
function ep(r, e) {
  let t = [];
  for (let i of r.facet(Xd)) {
    let n = i(r, e);
    n && t.push(n);
  }
  return t.length ? r.update({ effects: t, annotations: Jd.of(!0) }) : null;
}
function tp(r) {
  setTimeout(() => {
    let e = r.hasFocus;
    if (e != r.inputState.notifiedFocused) {
      let t = ep(r.state, e);
      t ? r.dispatch(t) : r.update([]);
    }
  }, 10);
}
rt.focus = (r) => {
  r.inputState.lastFocusTime = Date.now(), !r.scrollDOM.scrollTop && (r.inputState.lastScrollTop || r.inputState.lastScrollLeft) && (r.scrollDOM.scrollTop = r.inputState.lastScrollTop, r.scrollDOM.scrollLeft = r.inputState.lastScrollLeft), tp(r);
};
rt.blur = (r) => {
  r.observer.clearSelectionRange(), tp(r);
};
rt.compositionstart = rt.compositionupdate = (r) => {
  r.observer.editContext || (r.inputState.compositionFirstChange == null && (r.inputState.compositionFirstChange = !0), r.inputState.composing < 0 && (r.inputState.composing = 0));
};
rt.compositionend = (r) => {
  r.observer.editContext || (r.inputState.composing = -1, r.inputState.compositionEndedAt = Date.now(), r.inputState.compositionPendingKey = !0, r.inputState.compositionPendingChange = r.observer.pendingRecords().length > 0, r.inputState.compositionFirstChange = null, E.chrome && E.android ? r.observer.flushSoon() : r.inputState.compositionPendingChange ? Promise.resolve().then(() => r.observer.flush()) : setTimeout(() => {
    r.inputState.composing < 0 && r.docView.hasComposition && r.update([]);
  }, 50));
};
rt.contextmenu = (r) => {
  r.inputState.lastContextMenu = Date.now();
};
ht.beforeinput = (r, e) => {
  var t, i;
  if (e.inputType == "insertReplacementText" && r.observer.editContext) {
    let s = (t = e.dataTransfer) === null || t === void 0 ? void 0 : t.getData("text/plain"), o = e.getTargetRanges();
    if (s && o.length) {
      let l = o[0], a = r.posAtDOM(l.startContainer, l.startOffset), h = r.posAtDOM(l.endContainer, l.endOffset);
      return Ga(r, { from: a, to: h, insert: r.state.toText(s) }, null), !0;
    }
  }
  let n;
  if (E.chrome && E.android && (n = Gd.find((s) => s.inputType == e.inputType)) && (r.observer.delayAndroidKey(n.key, n.keyCode), n.key == "Backspace" || n.key == "Delete")) {
    let s = ((i = window.visualViewport) === null || i === void 0 ? void 0 : i.height) || 0;
    setTimeout(() => {
      var o;
      (((o = window.visualViewport) === null || o === void 0 ? void 0 : o.height) || 0) > s + 10 && r.hasFocus && (r.contentDOM.blur(), r.focus());
    }, 100);
  }
  return E.ios && e.inputType == "deleteContentForward" && r.observer.flushSoon(), E.safari && e.inputType == "insertText" && r.inputState.composing >= 0 && setTimeout(() => rt.compositionend(r, e), 20), !1;
};
const bc = /* @__PURE__ */ new Set();
function J0(r) {
  bc.has(r) || (bc.add(r), r.addEventListener("copy", () => {
  }), r.addEventListener("cut", () => {
  }));
}
const yc = ["pre-wrap", "normal", "pre-line", "break-spaces"];
let Ni = !1;
function Sc() {
  Ni = !1;
}
class e1 {
  constructor(e) {
    this.lineWrapping = e, this.doc = K.empty, this.heightSamples = {}, this.lineHeight = 14, this.charWidth = 7, this.textHeight = 14, this.lineLength = 30;
  }
  heightForGap(e, t) {
    let i = this.doc.lineAt(t).number - this.doc.lineAt(e).number + 1;
    return this.lineWrapping && (i += Math.max(0, Math.ceil((t - e - i * this.lineLength * 0.5) / this.lineLength))), this.lineHeight * i;
  }
  heightForLine(e) {
    return this.lineWrapping ? (1 + Math.max(0, Math.ceil((e - this.lineLength) / Math.max(1, this.lineLength - 5)))) * this.lineHeight : this.lineHeight;
  }
  setDoc(e) {
    return this.doc = e, this;
  }
  mustRefreshForWrapping(e) {
    return yc.indexOf(e) > -1 != this.lineWrapping;
  }
  mustRefreshForHeights(e) {
    let t = !1;
    for (let i = 0; i < e.length; i++) {
      let n = e[i];
      n < 0 ? i++ : this.heightSamples[Math.floor(n * 10)] || (t = !0, this.heightSamples[Math.floor(n * 10)] = !0);
    }
    return t;
  }
  refresh(e, t, i, n, s, o) {
    let l = yc.indexOf(e) > -1, a = Math.round(t) != Math.round(this.lineHeight) || this.lineWrapping != l;
    if (this.lineWrapping = l, this.lineHeight = t, this.charWidth = i, this.textHeight = n, this.lineLength = s, a) {
      this.heightSamples = {};
      for (let h = 0; h < o.length; h++) {
        let c = o[h];
        c < 0 ? h++ : this.heightSamples[Math.floor(c * 10)] = !0;
      }
    }
    return a;
  }
}
class t1 {
  constructor(e, t) {
    this.from = e, this.heights = t, this.index = 0;
  }
  get more() {
    return this.index < this.heights.length;
  }
}
class wt {
  /**
  @internal
  */
  constructor(e, t, i, n, s) {
    this.from = e, this.length = t, this.top = i, this.height = n, this._content = s;
  }
  /**
  The type of element this is. When querying lines, this may be
  an array of all the blocks that make up the line.
  */
  get type() {
    return typeof this._content == "number" ? Xe.Text : Array.isArray(this._content) ? this._content : this._content.type;
  }
  /**
  The end of the element as a document position.
  */
  get to() {
    return this.from + this.length;
  }
  /**
  The bottom position of the element.
  */
  get bottom() {
    return this.top + this.height;
  }
  /**
  If this is a widget block, this will return the widget
  associated with it.
  */
  get widget() {
    return this._content instanceof ai ? this._content.widget : null;
  }
  /**
  If this is a textblock, this holds the number of line breaks
  that appear in widgets inside the block.
  */
  get widgetLineBreaks() {
    return typeof this._content == "number" ? this._content : 0;
  }
  /**
  @internal
  */
  join(e) {
    let t = (Array.isArray(this._content) ? this._content : [this]).concat(Array.isArray(e._content) ? e._content : [e]);
    return new wt(this.from, this.length + e.length, this.top, this.height + e.height, t);
  }
}
var he = /* @__PURE__ */ (function(r) {
  return r[r.ByPos = 0] = "ByPos", r[r.ByHeight = 1] = "ByHeight", r[r.ByPosNoHeight = 2] = "ByPosNoHeight", r;
})(he || (he = {}));
const es = 1e-3;
class Re {
  constructor(e, t, i = 2) {
    this.length = e, this.height = t, this.flags = i;
  }
  get outdated() {
    return (this.flags & 2) > 0;
  }
  set outdated(e) {
    this.flags = (e ? 2 : 0) | this.flags & -3;
  }
  setHeight(e) {
    this.height != e && (Math.abs(this.height - e) > es && (Ni = !0), this.height = e);
  }
  // Base case is to replace a leaf node, which simply builds a tree
  // from the new nodes and returns that (HeightMapBranch and
  // HeightMapGap override this to actually use from/to)
  replace(e, t, i) {
    return Re.of(i);
  }
  // Again, these are base cases, and are overridden for branch and gap nodes.
  decomposeLeft(e, t) {
    t.push(this);
  }
  decomposeRight(e, t) {
    t.push(this);
  }
  applyChanges(e, t, i, n) {
    let s = this, o = i.doc;
    for (let l = n.length - 1; l >= 0; l--) {
      let { fromA: a, toA: h, fromB: c, toB: f } = n[l], u = s.lineAt(a, he.ByPosNoHeight, i.setDoc(t), 0, 0), d = u.to >= h ? u : s.lineAt(h, he.ByPosNoHeight, i, 0, 0);
      for (f += d.to - h, h = d.to; l > 0 && u.from <= n[l - 1].toA; )
        a = n[l - 1].fromA, c = n[l - 1].fromB, l--, a < u.from && (u = s.lineAt(a, he.ByPosNoHeight, i, 0, 0));
      c += u.from - a, a = u.from;
      let p = Ua.build(i.setDoc(o), e, c, f);
      s = ws(s, s.replace(a, h, p));
    }
    return s.updateHeight(i, 0);
  }
  static empty() {
    return new qe(0, 0);
  }
  // nodes uses null values to indicate the position of line breaks.
  // There are never line breaks at the start or end of the array, or
  // two line breaks next to each other, and the array isn't allowed
  // to be empty (same restrictions as return value from the builder).
  static of(e) {
    if (e.length == 1)
      return e[0];
    let t = 0, i = e.length, n = 0, s = 0;
    for (; ; )
      if (t == i)
        if (n > s * 2) {
          let l = e[t - 1];
          l.break ? e.splice(--t, 1, l.left, null, l.right) : e.splice(--t, 1, l.left, l.right), i += 1 + l.break, n -= l.size;
        } else if (s > n * 2) {
          let l = e[i];
          l.break ? e.splice(i, 1, l.left, null, l.right) : e.splice(i, 1, l.left, l.right), i += 2 + l.break, s -= l.size;
        } else
          break;
      else if (n < s) {
        let l = e[t++];
        l && (n += l.size);
      } else {
        let l = e[--i];
        l && (s += l.size);
      }
    let o = 0;
    return e[t - 1] == null ? (o = 1, t--) : e[t] == null && (o = 1, i++), new i1(Re.of(e.slice(0, t)), o, Re.of(e.slice(i)));
  }
}
function ws(r, e) {
  return r == e ? r : (r.constructor != e.constructor && (Ni = !0), e);
}
Re.prototype.size = 1;
class ip extends Re {
  constructor(e, t, i) {
    super(e, t), this.deco = i;
  }
  blockAt(e, t, i, n) {
    return new wt(n, this.length, i, this.height, this.deco || 0);
  }
  lineAt(e, t, i, n, s) {
    return this.blockAt(0, i, n, s);
  }
  forEachLine(e, t, i, n, s, o) {
    e <= s + this.length && t >= s && o(this.blockAt(0, i, n, s));
  }
  updateHeight(e, t = 0, i = !1, n) {
    return n && n.from <= t && n.more && this.setHeight(n.heights[n.index++]), this.outdated = !1, this;
  }
  toString() {
    return `block(${this.length})`;
  }
}
class qe extends ip {
  constructor(e, t) {
    super(e, t, null), this.collapsed = 0, this.widgetHeight = 0, this.breaks = 0;
  }
  blockAt(e, t, i, n) {
    return new wt(n, this.length, i, this.height, this.breaks);
  }
  replace(e, t, i) {
    let n = i[0];
    return i.length == 1 && (n instanceof qe || n instanceof we && n.flags & 4) && Math.abs(this.length - n.length) < 10 ? (n instanceof we ? n = new qe(n.length, this.height) : n.height = this.height, this.outdated || (n.outdated = !1), n) : Re.of(i);
  }
  updateHeight(e, t = 0, i = !1, n) {
    return n && n.from <= t && n.more ? this.setHeight(n.heights[n.index++]) : (i || this.outdated) && this.setHeight(Math.max(this.widgetHeight, e.heightForLine(this.length - this.collapsed)) + this.breaks * e.lineHeight), this.outdated = !1, this;
  }
  toString() {
    return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
  }
}
class we extends Re {
  constructor(e) {
    super(e, 0);
  }
  heightMetrics(e, t) {
    let i = e.doc.lineAt(t).number, n = e.doc.lineAt(t + this.length).number, s = n - i + 1, o, l = 0;
    if (e.lineWrapping) {
      let a = Math.min(this.height, e.lineHeight * s);
      o = a / s, this.length > s + 1 && (l = (this.height - a) / (this.length - s - 1));
    } else
      o = this.height / s;
    return { firstLine: i, lastLine: n, perLine: o, perChar: l };
  }
  blockAt(e, t, i, n) {
    let { firstLine: s, lastLine: o, perLine: l, perChar: a } = this.heightMetrics(t, n);
    if (t.lineWrapping) {
      let h = n + (e < t.lineHeight ? 0 : Math.round(Math.max(0, Math.min(1, (e - i) / this.height)) * this.length)), c = t.doc.lineAt(h), f = l + c.length * a, u = Math.max(i, e - f / 2);
      return new wt(c.from, c.length, u, f, 0);
    } else {
      let h = Math.max(0, Math.min(o - s, Math.floor((e - i) / l))), { from: c, length: f } = t.doc.line(s + h);
      return new wt(c, f, i + l * h, l, 0);
    }
  }
  lineAt(e, t, i, n, s) {
    if (t == he.ByHeight)
      return this.blockAt(e, i, n, s);
    if (t == he.ByPosNoHeight) {
      let { from: d, to: p } = i.doc.lineAt(e);
      return new wt(d, p - d, 0, 0, 0);
    }
    let { firstLine: o, perLine: l, perChar: a } = this.heightMetrics(i, s), h = i.doc.lineAt(e), c = l + h.length * a, f = h.number - o, u = n + l * f + a * (h.from - s - f);
    return new wt(h.from, h.length, Math.max(n, Math.min(u, n + this.height - c)), c, 0);
  }
  forEachLine(e, t, i, n, s, o) {
    e = Math.max(e, s), t = Math.min(t, s + this.length);
    let { firstLine: l, perLine: a, perChar: h } = this.heightMetrics(i, s);
    for (let c = e, f = n; c <= t; ) {
      let u = i.doc.lineAt(c);
      if (c == e) {
        let p = u.number - l;
        f += a * p + h * (e - s - p);
      }
      let d = a + h * u.length;
      o(new wt(u.from, u.length, f, d, 0)), f += d, c = u.to + 1;
    }
  }
  replace(e, t, i) {
    let n = this.length - t;
    if (n > 0) {
      let s = i[i.length - 1];
      s instanceof we ? i[i.length - 1] = new we(s.length + n) : i.push(null, new we(n - 1));
    }
    if (e > 0) {
      let s = i[0];
      s instanceof we ? i[0] = new we(e + s.length) : i.unshift(new we(e - 1), null);
    }
    return Re.of(i);
  }
  decomposeLeft(e, t) {
    t.push(new we(e - 1), null);
  }
  decomposeRight(e, t) {
    t.push(null, new we(this.length - e - 1));
  }
  updateHeight(e, t = 0, i = !1, n) {
    let s = t + this.length;
    if (n && n.from <= t + this.length && n.more) {
      let o = [], l = Math.max(t, n.from), a = -1;
      for (n.from > t && o.push(new we(n.from - t - 1).updateHeight(e, t)); l <= s && n.more; ) {
        let c = e.doc.lineAt(l).length;
        o.length && o.push(null);
        let f = n.heights[n.index++];
        a == -1 ? a = f : Math.abs(f - a) >= es && (a = -2);
        let u = new qe(c, f);
        u.outdated = !1, o.push(u), l += c + 1;
      }
      l <= s && o.push(null, new we(s - l).updateHeight(e, l));
      let h = Re.of(o);
      return (a < 0 || Math.abs(h.height - this.height) >= es || Math.abs(a - this.heightMetrics(e, t).perLine) >= es) && (Ni = !0), ws(this, h);
    } else (i || this.outdated) && (this.setHeight(e.heightForGap(t, t + this.length)), this.outdated = !1);
    return this;
  }
  toString() {
    return `gap(${this.length})`;
  }
}
class i1 extends Re {
  constructor(e, t, i) {
    super(e.length + t + i.length, e.height + i.height, t | (e.outdated || i.outdated ? 2 : 0)), this.left = e, this.right = i, this.size = e.size + i.size;
  }
  get break() {
    return this.flags & 1;
  }
  blockAt(e, t, i, n) {
    let s = i + this.left.height;
    return e < s ? this.left.blockAt(e, t, i, n) : this.right.blockAt(e, t, s, n + this.left.length + this.break);
  }
  lineAt(e, t, i, n, s) {
    let o = n + this.left.height, l = s + this.left.length + this.break, a = t == he.ByHeight ? e < o : e < l, h = a ? this.left.lineAt(e, t, i, n, s) : this.right.lineAt(e, t, i, o, l);
    if (this.break || (a ? h.to < l : h.from > l))
      return h;
    let c = t == he.ByPosNoHeight ? he.ByPosNoHeight : he.ByPos;
    return a ? h.join(this.right.lineAt(l, c, i, o, l)) : this.left.lineAt(l, c, i, n, s).join(h);
  }
  forEachLine(e, t, i, n, s, o) {
    let l = n + this.left.height, a = s + this.left.length + this.break;
    if (this.break)
      e < a && this.left.forEachLine(e, t, i, n, s, o), t >= a && this.right.forEachLine(e, t, i, l, a, o);
    else {
      let h = this.lineAt(a, he.ByPos, i, n, s);
      e < h.from && this.left.forEachLine(e, h.from - 1, i, n, s, o), h.to >= e && h.from <= t && o(h), t > h.to && this.right.forEachLine(h.to + 1, t, i, l, a, o);
    }
  }
  replace(e, t, i) {
    let n = this.left.length + this.break;
    if (t < n)
      return this.balanced(this.left.replace(e, t, i), this.right);
    if (e > this.left.length)
      return this.balanced(this.left, this.right.replace(e - n, t - n, i));
    let s = [];
    e > 0 && this.decomposeLeft(e, s);
    let o = s.length;
    for (let l of i)
      s.push(l);
    if (e > 0 && wc(s, o - 1), t < this.length) {
      let l = s.length;
      this.decomposeRight(t, s), wc(s, l);
    }
    return Re.of(s);
  }
  decomposeLeft(e, t) {
    let i = this.left.length;
    if (e <= i)
      return this.left.decomposeLeft(e, t);
    t.push(this.left), this.break && (i++, e >= i && t.push(null)), e > i && this.right.decomposeLeft(e - i, t);
  }
  decomposeRight(e, t) {
    let i = this.left.length, n = i + this.break;
    if (e >= n)
      return this.right.decomposeRight(e - n, t);
    e < i && this.left.decomposeRight(e, t), this.break && e < n && t.push(null), t.push(this.right);
  }
  balanced(e, t) {
    return e.size > 2 * t.size || t.size > 2 * e.size ? Re.of(this.break ? [e, null, t] : [e, t]) : (this.left = ws(this.left, e), this.right = ws(this.right, t), this.setHeight(e.height + t.height), this.outdated = e.outdated || t.outdated, this.size = e.size + t.size, this.length = e.length + this.break + t.length, this);
  }
  updateHeight(e, t = 0, i = !1, n) {
    let { left: s, right: o } = this, l = t + s.length + this.break, a = null;
    return n && n.from <= t + s.length && n.more ? a = s = s.updateHeight(e, t, i, n) : s.updateHeight(e, t, i), n && n.from <= l + o.length && n.more ? a = o = o.updateHeight(e, l, i, n) : o.updateHeight(e, l, i), a ? this.balanced(s, o) : (this.height = this.left.height + this.right.height, this.outdated = !1, this);
  }
  toString() {
    return this.left + (this.break ? " " : "-") + this.right;
  }
}
function wc(r, e) {
  let t, i;
  r[e] == null && (t = r[e - 1]) instanceof we && (i = r[e + 1]) instanceof we && r.splice(e - 1, 3, new we(t.length + 1 + i.length));
}
const r1 = 5;
class Ua {
  constructor(e, t) {
    this.pos = e, this.oracle = t, this.nodes = [], this.lineStart = -1, this.lineEnd = -1, this.covering = null, this.writtenTo = e;
  }
  get isCovered() {
    return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
  }
  span(e, t) {
    if (this.lineStart > -1) {
      let i = Math.min(t, this.lineEnd), n = this.nodes[this.nodes.length - 1];
      n instanceof qe ? n.length += i - this.pos : (i > this.pos || !this.isCovered) && this.nodes.push(new qe(i - this.pos, -1)), this.writtenTo = i, t > i && (this.nodes.push(null), this.writtenTo++, this.lineStart = -1);
    }
    this.pos = t;
  }
  point(e, t, i) {
    if (e < t || i.heightRelevant) {
      let n = i.widget ? i.widget.estimatedHeight : 0, s = i.widget ? i.widget.lineBreaks : 0;
      n < 0 && (n = this.oracle.lineHeight);
      let o = t - e;
      i.block ? this.addBlock(new ip(o, n, i)) : (o || s || n >= r1) && this.addLineDeco(n, s, o);
    } else t > e && this.span(e, t);
    this.lineEnd > -1 && this.lineEnd < this.pos && (this.lineEnd = this.oracle.doc.lineAt(this.pos).to);
  }
  enterLine() {
    if (this.lineStart > -1)
      return;
    let { from: e, to: t } = this.oracle.doc.lineAt(this.pos);
    this.lineStart = e, this.lineEnd = t, this.writtenTo < e && ((this.writtenTo < e - 1 || this.nodes[this.nodes.length - 1] == null) && this.nodes.push(this.blankContent(this.writtenTo, e - 1)), this.nodes.push(null)), this.pos > e && this.nodes.push(new qe(this.pos - e, -1)), this.writtenTo = this.pos;
  }
  blankContent(e, t) {
    let i = new we(t - e);
    return this.oracle.doc.lineAt(e).to == t && (i.flags |= 4), i;
  }
  ensureLine() {
    this.enterLine();
    let e = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
    if (e instanceof qe)
      return e;
    let t = new qe(0, -1);
    return this.nodes.push(t), t;
  }
  addBlock(e) {
    this.enterLine();
    let t = e.deco;
    t && t.startSide > 0 && !this.isCovered && this.ensureLine(), this.nodes.push(e), this.writtenTo = this.pos = this.pos + e.length, t && t.endSide > 0 && (this.covering = e);
  }
  addLineDeco(e, t, i) {
    let n = this.ensureLine();
    n.length += i, n.collapsed += i, n.widgetHeight = Math.max(n.widgetHeight, e), n.breaks += t, this.writtenTo = this.pos = this.pos + i;
  }
  finish(e) {
    let t = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
    this.lineStart > -1 && !(t instanceof qe) && !this.isCovered ? this.nodes.push(new qe(0, -1)) : (this.writtenTo < this.pos || t == null) && this.nodes.push(this.blankContent(this.writtenTo, this.pos));
    let i = e;
    for (let n of this.nodes)
      n instanceof qe && n.updateHeight(this.oracle, i), i += n ? n.length : 1;
    return this.nodes;
  }
  // Always called with a region that on both sides either stretches
  // to a line break or the end of the document.
  // The returned array uses null to indicate line breaks, but never
  // starts or ends in a line break, or has multiple line breaks next
  // to each other.
  static build(e, t, i, n) {
    let s = new Ua(i, e);
    return H.spans(t, i, n, s, 0), s.finish(i);
  }
}
function n1(r, e, t) {
  let i = new s1();
  return H.compare(r, e, t, i, 0), i.changes;
}
class s1 {
  constructor() {
    this.changes = [];
  }
  compareRange() {
  }
  comparePoint(e, t, i, n) {
    (e < t || i && i.heightRelevant || n && n.heightRelevant) && Jn(e, t, this.changes, 5);
  }
}
function o1(r, e) {
  let t = r.getBoundingClientRect(), i = r.ownerDocument, n = i.defaultView || window, s = Math.max(0, t.left), o = Math.min(n.innerWidth, t.right), l = Math.max(0, t.top), a = Math.min(n.innerHeight, t.bottom);
  for (let h = r.parentNode; h && h != i.body; )
    if (h.nodeType == 1) {
      let c = h, f = window.getComputedStyle(c);
      if ((c.scrollHeight > c.clientHeight || c.scrollWidth > c.clientWidth) && f.overflow != "visible") {
        let u = c.getBoundingClientRect();
        s = Math.max(s, u.left), o = Math.min(o, u.right), l = Math.max(l, u.top), a = Math.min(h == r.parentNode ? n.innerHeight : a, u.bottom);
      }
      h = f.position == "absolute" || f.position == "fixed" ? c.offsetParent : c.parentNode;
    } else if (h.nodeType == 11)
      h = h.host;
    else
      break;
  return {
    left: s - t.left,
    right: Math.max(s, o) - t.left,
    top: l - (t.top + e),
    bottom: Math.max(l, a) - (t.top + e)
  };
}
function l1(r) {
  let e = r.getBoundingClientRect(), t = r.ownerDocument.defaultView || window;
  return e.left < t.innerWidth && e.right > 0 && e.top < t.innerHeight && e.bottom > 0;
}
function a1(r, e) {
  let t = r.getBoundingClientRect();
  return {
    left: 0,
    right: t.right - t.left,
    top: e,
    bottom: t.bottom - (t.top + e)
  };
}
class Po {
  constructor(e, t, i, n) {
    this.from = e, this.to = t, this.size = i, this.displaySize = n;
  }
  static same(e, t) {
    if (e.length != t.length)
      return !1;
    for (let i = 0; i < e.length; i++) {
      let n = e[i], s = t[i];
      if (n.from != s.from || n.to != s.to || n.size != s.size)
        return !1;
    }
    return !0;
  }
  draw(e, t) {
    return B.replace({
      widget: new h1(this.displaySize * (t ? e.scaleY : e.scaleX), t)
    }).range(this.from, this.to);
  }
}
class h1 extends di {
  constructor(e, t) {
    super(), this.size = e, this.vertical = t;
  }
  eq(e) {
    return e.size == this.size && e.vertical == this.vertical;
  }
  toDOM() {
    let e = document.createElement("div");
    return this.vertical ? e.style.height = this.size + "px" : (e.style.width = this.size + "px", e.style.height = "2px", e.style.display = "inline-block"), e;
  }
  get estimatedHeight() {
    return this.vertical ? this.size : -1;
  }
}
class xc {
  constructor(e) {
    this.state = e, this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 }, this.inView = !0, this.paddingTop = 0, this.paddingBottom = 0, this.contentDOMWidth = 0, this.contentDOMHeight = 0, this.editorHeight = 0, this.editorWidth = 0, this.scrollTop = 0, this.scrolledToBottom = !1, this.scaleX = 1, this.scaleY = 1, this.scrollAnchorPos = 0, this.scrollAnchorHeight = -1, this.scaler = kc, this.scrollTarget = null, this.printing = !1, this.mustMeasureContent = !0, this.defaultTextDirection = ce.LTR, this.visibleRanges = [], this.mustEnforceCursorAssoc = !1;
    let t = e.facet(Wa).some((i) => typeof i != "function" && i.class == "cm-lineWrapping");
    this.heightOracle = new e1(t), this.stateDeco = e.facet(Vr).filter((i) => typeof i != "function"), this.heightMap = Re.empty().applyChanges(this.stateDeco, K.empty, this.heightOracle.setDoc(e.doc), [new it(0, 0, 0, e.doc.length)]);
    for (let i = 0; i < 2 && (this.viewport = this.getViewport(0, null), !!this.updateForViewport()); i++)
      ;
    this.updateViewportLines(), this.lineGaps = this.ensureLineGaps([]), this.lineGapDeco = B.set(this.lineGaps.map((i) => i.draw(this, !1))), this.computeVisibleRanges();
  }
  updateForViewport() {
    let e = [this.viewport], { main: t } = this.state.selection;
    for (let i = 0; i <= 1; i++) {
      let n = i ? t.head : t.anchor;
      if (!e.some(({ from: s, to: o }) => n >= s && n <= o)) {
        let { from: s, to: o } = this.lineBlockAt(n);
        e.push(new vn(s, o));
      }
    }
    return this.viewports = e.sort((i, n) => i.from - n.from), this.updateScaler();
  }
  updateScaler() {
    let e = this.scaler;
    return this.scaler = this.heightMap.height <= 7e6 ? kc : new Fa(this.heightOracle, this.heightMap, this.viewports), e.eq(this.scaler) ? 0 : 2;
  }
  updateViewportLines() {
    this.viewportLines = [], this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, (e) => {
      this.viewportLines.push(xr(e, this.scaler));
    });
  }
  update(e, t = null) {
    this.state = e.state;
    let i = this.stateDeco;
    this.stateDeco = this.state.facet(Vr).filter((c) => typeof c != "function");
    let n = e.changedRanges, s = it.extendWithRanges(n, n1(i, this.stateDeco, e ? e.changes : ye.empty(this.state.doc.length))), o = this.heightMap.height, l = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
    Sc(), this.heightMap = this.heightMap.applyChanges(this.stateDeco, e.startState.doc, this.heightOracle.setDoc(this.state.doc), s), (this.heightMap.height != o || Ni) && (e.flags |= 2), l ? (this.scrollAnchorPos = e.changes.mapPos(l.from, -1), this.scrollAnchorHeight = l.top) : (this.scrollAnchorPos = -1, this.scrollAnchorHeight = o);
    let a = s.length ? this.mapViewport(this.viewport, e.changes) : this.viewport;
    (t && (t.range.head < a.from || t.range.head > a.to) || !this.viewportIsAppropriate(a)) && (a = this.getViewport(0, t));
    let h = a.from != this.viewport.from || a.to != this.viewport.to;
    this.viewport = a, e.flags |= this.updateForViewport(), (h || !e.changes.empty || e.flags & 2) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, e.changes))), e.flags |= this.computeVisibleRanges(e.changes), t && (this.scrollTarget = t), !this.mustEnforceCursorAssoc && e.selectionSet && e.view.lineWrapping && e.state.selection.main.empty && e.state.selection.main.assoc && !e.state.facet(Ld) && (this.mustEnforceCursorAssoc = !0);
  }
  measure(e) {
    let t = e.contentDOM, i = window.getComputedStyle(t), n = this.heightOracle, s = i.whiteSpace;
    this.defaultTextDirection = i.direction == "rtl" ? ce.RTL : ce.LTR;
    let o = this.heightOracle.mustRefreshForWrapping(s), l = t.getBoundingClientRect(), a = o || this.mustMeasureContent || this.contentDOMHeight != l.height;
    this.contentDOMHeight = l.height, this.mustMeasureContent = !1;
    let h = 0, c = 0;
    if (l.width && l.height) {
      let { scaleX: x, scaleY: S } = cd(t, l);
      (x > 5e-3 && Math.abs(this.scaleX - x) > 5e-3 || S > 5e-3 && Math.abs(this.scaleY - S) > 5e-3) && (this.scaleX = x, this.scaleY = S, h |= 16, o = a = !0);
    }
    let f = (parseInt(i.paddingTop) || 0) * this.scaleY, u = (parseInt(i.paddingBottom) || 0) * this.scaleY;
    (this.paddingTop != f || this.paddingBottom != u) && (this.paddingTop = f, this.paddingBottom = u, h |= 18), this.editorWidth != e.scrollDOM.clientWidth && (n.lineWrapping && (a = !0), this.editorWidth = e.scrollDOM.clientWidth, h |= 16);
    let d = e.scrollDOM.scrollTop * this.scaleY;
    this.scrollTop != d && (this.scrollAnchorHeight = -1, this.scrollTop = d), this.scrolledToBottom = dd(e.scrollDOM);
    let p = (this.printing ? a1 : o1)(t, this.paddingTop), O = p.top - this.pixelViewport.top, g = p.bottom - this.pixelViewport.bottom;
    this.pixelViewport = p;
    let b = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
    if (b != this.inView && (this.inView = b, b && (a = !0)), !this.inView && !this.scrollTarget && !l1(e.dom))
      return 0;
    let w = l.width;
    if ((this.contentDOMWidth != w || this.editorHeight != e.scrollDOM.clientHeight) && (this.contentDOMWidth = l.width, this.editorHeight = e.scrollDOM.clientHeight, h |= 16), a) {
      let x = e.docView.measureVisibleLineHeights(this.viewport);
      if (n.mustRefreshForHeights(x) && (o = !0), o || n.lineWrapping && Math.abs(w - this.contentDOMWidth) > n.charWidth) {
        let { lineHeight: S, charWidth: y, textHeight: Q } = e.docView.measureTextSize();
        o = S > 0 && n.refresh(s, S, y, Q, Math.max(5, w / y), x), o && (e.docView.minWidth = 0, h |= 16);
      }
      O > 0 && g > 0 ? c = Math.max(O, g) : O < 0 && g < 0 && (c = Math.min(O, g)), Sc();
      for (let S of this.viewports) {
        let y = S.from == this.viewport.from ? x : e.docView.measureVisibleLineHeights(S);
        this.heightMap = (o ? Re.empty().applyChanges(this.stateDeco, K.empty, this.heightOracle, [new it(0, 0, 0, e.state.doc.length)]) : this.heightMap).updateHeight(n, 0, o, new t1(S.from, y));
      }
      Ni && (h |= 2);
    }
    let k = !this.viewportIsAppropriate(this.viewport, c) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
    return k && (h & 2 && (h |= this.updateScaler()), this.viewport = this.getViewport(c, this.scrollTarget), h |= this.updateForViewport()), (h & 2 || k) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(o ? [] : this.lineGaps, e)), h |= this.computeVisibleRanges(), this.mustEnforceCursorAssoc && (this.mustEnforceCursorAssoc = !1, e.docView.enforceCursorAssoc()), h;
  }
  get visibleTop() {
    return this.scaler.fromDOM(this.pixelViewport.top);
  }
  get visibleBottom() {
    return this.scaler.fromDOM(this.pixelViewport.bottom);
  }
  getViewport(e, t) {
    let i = 0.5 - Math.max(-0.5, Math.min(0.5, e / 1e3 / 2)), n = this.heightMap, s = this.heightOracle, { visibleTop: o, visibleBottom: l } = this, a = new vn(n.lineAt(o - i * 1e3, he.ByHeight, s, 0, 0).from, n.lineAt(l + (1 - i) * 1e3, he.ByHeight, s, 0, 0).to);
    if (t) {
      let { head: h } = t.range;
      if (h < a.from || h > a.to) {
        let c = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top), f = n.lineAt(h, he.ByPos, s, 0, 0), u;
        t.y == "center" ? u = (f.top + f.bottom) / 2 - c / 2 : t.y == "start" || t.y == "nearest" && h < a.from ? u = f.top : u = f.bottom - c, a = new vn(n.lineAt(u - 1e3 / 2, he.ByHeight, s, 0, 0).from, n.lineAt(u + c + 1e3 / 2, he.ByHeight, s, 0, 0).to);
      }
    }
    return a;
  }
  mapViewport(e, t) {
    let i = t.mapPos(e.from, -1), n = t.mapPos(e.to, 1);
    return new vn(this.heightMap.lineAt(i, he.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(n, he.ByPos, this.heightOracle, 0, 0).to);
  }
  // Checks if a given viewport covers the visible part of the
  // document and not too much beyond that.
  viewportIsAppropriate({ from: e, to: t }, i = 0) {
    if (!this.inView)
      return !0;
    let { top: n } = this.heightMap.lineAt(e, he.ByPos, this.heightOracle, 0, 0), { bottom: s } = this.heightMap.lineAt(t, he.ByPos, this.heightOracle, 0, 0), { visibleTop: o, visibleBottom: l } = this;
    return (e == 0 || n <= o - Math.max(10, Math.min(
      -i,
      250
      /* VP.MaxCoverMargin */
    ))) && (t == this.state.doc.length || s >= l + Math.max(10, Math.min(
      i,
      250
      /* VP.MaxCoverMargin */
    ))) && n > o - 2 * 1e3 && s < l + 2 * 1e3;
  }
  mapLineGaps(e, t) {
    if (!e.length || t.empty)
      return e;
    let i = [];
    for (let n of e)
      t.touchesRange(n.from, n.to) || i.push(new Po(t.mapPos(n.from), t.mapPos(n.to), n.size, n.displaySize));
    return i;
  }
  // Computes positions in the viewport where the start or end of a
  // line should be hidden, trying to reuse existing line gaps when
  // appropriate to avoid unneccesary redraws.
  // Uses crude character-counting for the positioning and sizing,
  // since actual DOM coordinates aren't always available and
  // predictable. Relies on generous margins (see LG.Margin) to hide
  // the artifacts this might produce from the user.
  ensureLineGaps(e, t) {
    let i = this.heightOracle.lineWrapping, n = i ? 1e4 : 2e3, s = n >> 1, o = n << 1;
    if (this.defaultTextDirection != ce.LTR && !i)
      return [];
    let l = [], a = (c, f, u, d) => {
      if (f - c < s)
        return;
      let p = this.state.selection.main, O = [p.from];
      p.empty || O.push(p.to);
      for (let b of O)
        if (b > c && b < f) {
          a(c, b - 10, u, d), a(b + 10, f, u, d);
          return;
        }
      let g = f1(e, (b) => b.from >= u.from && b.to <= u.to && Math.abs(b.from - c) < s && Math.abs(b.to - f) < s && !O.some((w) => b.from < w && b.to > w));
      if (!g) {
        if (f < u.to && t && i && t.visibleRanges.some((k) => k.from <= f && k.to >= f)) {
          let k = t.moveToLineBoundary(v.cursor(f), !1, !0).head;
          k > c && (f = k);
        }
        let b = this.gapSize(u, c, f, d), w = i || b < 2e6 ? b : 2e6;
        g = new Po(c, f, b, w);
      }
      l.push(g);
    }, h = (c) => {
      if (c.length < o || c.type != Xe.Text)
        return;
      let f = c1(c.from, c.to, this.stateDeco);
      if (f.total < o)
        return;
      let u = this.scrollTarget ? this.scrollTarget.range.head : null, d, p;
      if (i) {
        let O = n / this.heightOracle.lineLength * this.heightOracle.lineHeight, g, b;
        if (u != null) {
          let w = Pn(f, u), k = ((this.visibleBottom - this.visibleTop) / 2 + O) / c.height;
          g = w - k, b = w + k;
        } else
          g = (this.visibleTop - c.top - O) / c.height, b = (this.visibleBottom - c.top + O) / c.height;
        d = $n(f, g), p = $n(f, b);
      } else {
        let O = f.total * this.heightOracle.charWidth, g = n * this.heightOracle.charWidth, b = 0;
        if (O > 2e6)
          for (let y of e)
            y.from >= c.from && y.from < c.to && y.size != y.displaySize && y.from * this.heightOracle.charWidth + b < this.pixelViewport.left && (b = y.size - y.displaySize);
        let w = this.pixelViewport.left + b, k = this.pixelViewport.right + b, x, S;
        if (u != null) {
          let y = Pn(f, u), Q = ((k - w) / 2 + g) / O;
          x = y - Q, S = y + Q;
        } else
          x = (w - g) / O, S = (k + g) / O;
        d = $n(f, x), p = $n(f, S);
      }
      d > c.from && a(c.from, d, c, f), p < c.to && a(p, c.to, c, f);
    };
    for (let c of this.viewportLines)
      Array.isArray(c.type) ? c.type.forEach(h) : h(c);
    return l;
  }
  gapSize(e, t, i, n) {
    let s = Pn(n, i) - Pn(n, t);
    return this.heightOracle.lineWrapping ? e.height * s : n.total * this.heightOracle.charWidth * s;
  }
  updateLineGaps(e) {
    Po.same(e, this.lineGaps) || (this.lineGaps = e, this.lineGapDeco = B.set(e.map((t) => t.draw(this, this.heightOracle.lineWrapping))));
  }
  computeVisibleRanges(e) {
    let t = this.stateDeco;
    this.lineGaps.length && (t = t.concat(this.lineGapDeco));
    let i = [];
    H.spans(t, this.viewport.from, this.viewport.to, {
      span(s, o) {
        i.push({ from: s, to: o });
      },
      point() {
      }
    }, 20);
    let n = 0;
    if (i.length != this.visibleRanges.length)
      n = 12;
    else
      for (let s = 0; s < i.length && !(n & 8); s++) {
        let o = this.visibleRanges[s], l = i[s];
        (o.from != l.from || o.to != l.to) && (n |= 4, e && e.mapPos(o.from, -1) == l.from && e.mapPos(o.to, 1) == l.to || (n |= 8));
      }
    return this.visibleRanges = i, n;
  }
  lineBlockAt(e) {
    return e >= this.viewport.from && e <= this.viewport.to && this.viewportLines.find((t) => t.from <= e && t.to >= e) || xr(this.heightMap.lineAt(e, he.ByPos, this.heightOracle, 0, 0), this.scaler);
  }
  lineBlockAtHeight(e) {
    return e >= this.viewportLines[0].top && e <= this.viewportLines[this.viewportLines.length - 1].bottom && this.viewportLines.find((t) => t.top <= e && t.bottom >= e) || xr(this.heightMap.lineAt(this.scaler.fromDOM(e), he.ByHeight, this.heightOracle, 0, 0), this.scaler);
  }
  scrollAnchorAt(e) {
    let t = this.lineBlockAtHeight(e + 8);
    return t.from >= this.viewport.from || this.viewportLines[0].top - e > 200 ? t : this.viewportLines[0];
  }
  elementAtHeight(e) {
    return xr(this.heightMap.blockAt(this.scaler.fromDOM(e), this.heightOracle, 0, 0), this.scaler);
  }
  get docHeight() {
    return this.scaler.toDOM(this.heightMap.height);
  }
  get contentHeight() {
    return this.docHeight + this.paddingTop + this.paddingBottom;
  }
}
class vn {
  constructor(e, t) {
    this.from = e, this.to = t;
  }
}
function c1(r, e, t) {
  let i = [], n = r, s = 0;
  return H.spans(t, r, e, {
    span() {
    },
    point(o, l) {
      o > n && (i.push({ from: n, to: o }), s += o - n), n = l;
    }
  }, 20), n < e && (i.push({ from: n, to: e }), s += e - n), { total: s, ranges: i };
}
function $n({ total: r, ranges: e }, t) {
  if (t <= 0)
    return e[0].from;
  if (t >= 1)
    return e[e.length - 1].to;
  let i = Math.floor(r * t);
  for (let n = 0; ; n++) {
    let { from: s, to: o } = e[n], l = o - s;
    if (i <= l)
      return s + i;
    i -= l;
  }
}
function Pn(r, e) {
  let t = 0;
  for (let { from: i, to: n } of r.ranges) {
    if (e <= n) {
      t += e - i;
      break;
    }
    t += n - i;
  }
  return t / r.total;
}
function f1(r, e) {
  for (let t of r)
    if (e(t))
      return t;
}
const kc = {
  toDOM(r) {
    return r;
  },
  fromDOM(r) {
    return r;
  },
  scale: 1,
  eq(r) {
    return r == this;
  }
};
class Fa {
  constructor(e, t, i) {
    let n = 0, s = 0, o = 0;
    this.viewports = i.map(({ from: l, to: a }) => {
      let h = t.lineAt(l, he.ByPos, e, 0, 0).top, c = t.lineAt(a, he.ByPos, e, 0, 0).bottom;
      return n += c - h, { from: l, to: a, top: h, bottom: c, domTop: 0, domBottom: 0 };
    }), this.scale = (7e6 - n) / (t.height - n);
    for (let l of this.viewports)
      l.domTop = o + (l.top - s) * this.scale, o = l.domBottom = l.domTop + (l.bottom - l.top), s = l.bottom;
  }
  toDOM(e) {
    for (let t = 0, i = 0, n = 0; ; t++) {
      let s = t < this.viewports.length ? this.viewports[t] : null;
      if (!s || e < s.top)
        return n + (e - i) * this.scale;
      if (e <= s.bottom)
        return s.domTop + (e - s.top);
      i = s.bottom, n = s.domBottom;
    }
  }
  fromDOM(e) {
    for (let t = 0, i = 0, n = 0; ; t++) {
      let s = t < this.viewports.length ? this.viewports[t] : null;
      if (!s || e < s.domTop)
        return i + (e - n) / this.scale;
      if (e <= s.domBottom)
        return s.top + (e - s.domTop);
      i = s.bottom, n = s.domBottom;
    }
  }
  eq(e) {
    return e instanceof Fa ? this.scale == e.scale && this.viewports.length == e.viewports.length && this.viewports.every((t, i) => t.from == e.viewports[i].from && t.to == e.viewports[i].to) : !1;
  }
}
function xr(r, e) {
  if (e.scale == 1)
    return r;
  let t = e.toDOM(r.top), i = e.toDOM(r.bottom);
  return new wt(r.from, r.length, t, i - t, Array.isArray(r._content) ? r._content.map((n) => xr(n, e)) : r._content);
}
const Cn = /* @__PURE__ */ R.define({ combine: (r) => r.join(" ") }), jl = /* @__PURE__ */ R.define({ combine: (r) => r.indexOf(!0) > -1 }), Gl = /* @__PURE__ */ Pt.newName(), rp = /* @__PURE__ */ Pt.newName(), np = /* @__PURE__ */ Pt.newName(), sp = { "&light": "." + rp, "&dark": "." + np };
function Ul(r, e, t) {
  return new Pt(e, {
    finish(i) {
      return /&/.test(i) ? i.replace(/&\w*/, (n) => {
        if (n == "&")
          return r;
        if (!t || !t[n])
          throw new RangeError(`Unsupported selector: ${n}`);
        return t[n];
      }) : r + " " + i;
    }
  });
}
const u1 = /* @__PURE__ */ Ul("." + Gl, {
  "&": {
    position: "relative !important",
    boxSizing: "border-box",
    "&.cm-focused": {
      // Provide a simple default outline to make sure a focused
      // editor is visually distinct. Can't leave the default behavior
      // because that will apply to the content element, which is
      // inside the scrollable container and doesn't include the
      // gutters. We also can't use an 'auto' outline, since those
      // are, for some reason, drawn behind the element content, which
      // will cause things like the active line background to cover
      // the outline (#297).
      outline: "1px dotted #212121"
    },
    display: "flex !important",
    flexDirection: "column"
  },
  ".cm-scroller": {
    display: "flex !important",
    alignItems: "flex-start !important",
    fontFamily: "monospace",
    lineHeight: 1.4,
    height: "100%",
    overflowX: "auto",
    position: "relative",
    zIndex: 0,
    overflowAnchor: "none"
  },
  ".cm-content": {
    margin: 0,
    flexGrow: 2,
    flexShrink: 0,
    display: "block",
    whiteSpace: "pre",
    wordWrap: "normal",
    // https://github.com/codemirror/dev/issues/456
    boxSizing: "border-box",
    minHeight: "100%",
    padding: "4px 0",
    outline: "none",
    "&[contenteditable=true]": {
      WebkitUserModify: "read-write-plaintext-only"
    }
  },
  ".cm-lineWrapping": {
    whiteSpace_fallback: "pre-wrap",
    // For IE
    whiteSpace: "break-spaces",
    wordBreak: "break-word",
    // For Safari, which doesn't support overflow-wrap: anywhere
    overflowWrap: "anywhere",
    flexShrink: 1
  },
  "&light .cm-content": { caretColor: "black" },
  "&dark .cm-content": { caretColor: "white" },
  ".cm-line": {
    display: "block",
    padding: "0 2px 0 6px"
  },
  ".cm-layer": {
    position: "absolute",
    left: 0,
    top: 0,
    contain: "size style",
    "& > *": {
      position: "absolute"
    }
  },
  "&light .cm-selectionBackground": {
    background: "#d9d9d9"
  },
  "&dark .cm-selectionBackground": {
    background: "#222"
  },
  "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
    background: "#d7d4f0"
  },
  "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
    background: "#233"
  },
  ".cm-cursorLayer": {
    pointerEvents: "none"
  },
  "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
    animation: "steps(1) cm-blink 1.2s infinite"
  },
  // Two animations defined so that we can switch between them to
  // restart the animation without forcing another style
  // recomputation.
  "@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
  "@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
  ".cm-cursor, .cm-dropCursor": {
    borderLeft: "1.2px solid black",
    marginLeft: "-0.6px",
    pointerEvents: "none"
  },
  ".cm-cursor": {
    display: "none"
  },
  "&dark .cm-cursor": {
    borderLeftColor: "#ddd"
  },
  ".cm-dropCursor": {
    position: "absolute"
  },
  "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
    display: "block"
  },
  ".cm-iso": {
    unicodeBidi: "isolate"
  },
  ".cm-announced": {
    position: "fixed",
    top: "-10000px"
  },
  "@media print": {
    ".cm-announced": { display: "none" }
  },
  "&light .cm-activeLine": { backgroundColor: "#cceeff44" },
  "&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
  "&light .cm-specialChar": { color: "red" },
  "&dark .cm-specialChar": { color: "#f78" },
  ".cm-gutters": {
    flexShrink: 0,
    display: "flex",
    height: "100%",
    boxSizing: "border-box",
    zIndex: 200
  },
  ".cm-gutters-before": { insetInlineStart: 0 },
  ".cm-gutters-after": { insetInlineEnd: 0 },
  "&light .cm-gutters": {
    backgroundColor: "#f5f5f5",
    color: "#6c6c6c",
    border: "0px solid #ddd",
    "&.cm-gutters-before": { borderRightWidth: "1px" },
    "&.cm-gutters-after": { borderLeftWidth: "1px" }
  },
  "&dark .cm-gutters": {
    backgroundColor: "#333338",
    color: "#ccc"
  },
  ".cm-gutter": {
    display: "flex !important",
    // Necessary -- prevents margin collapsing
    flexDirection: "column",
    flexShrink: 0,
    boxSizing: "border-box",
    minHeight: "100%",
    overflow: "hidden"
  },
  ".cm-gutterElement": {
    boxSizing: "border-box"
  },
  ".cm-lineNumbers .cm-gutterElement": {
    padding: "0 3px 0 5px",
    minWidth: "20px",
    textAlign: "right",
    whiteSpace: "nowrap"
  },
  "&light .cm-activeLineGutter": {
    backgroundColor: "#e2f2ff"
  },
  "&dark .cm-activeLineGutter": {
    backgroundColor: "#222227"
  },
  ".cm-panels": {
    boxSizing: "border-box",
    position: "sticky",
    left: 0,
    right: 0,
    zIndex: 300
  },
  "&light .cm-panels": {
    backgroundColor: "#f5f5f5",
    color: "black"
  },
  "&light .cm-panels-top": {
    borderBottom: "1px solid #ddd"
  },
  "&light .cm-panels-bottom": {
    borderTop: "1px solid #ddd"
  },
  "&dark .cm-panels": {
    backgroundColor: "#333338",
    color: "white"
  },
  ".cm-dialog": {
    padding: "2px 19px 4px 6px",
    position: "relative",
    "& label": { fontSize: "80%" }
  },
  ".cm-dialog-close": {
    position: "absolute",
    top: "3px",
    right: "4px",
    backgroundColor: "inherit",
    border: "none",
    font: "inherit",
    fontSize: "14px",
    padding: "0"
  },
  ".cm-tab": {
    display: "inline-block",
    overflow: "hidden",
    verticalAlign: "bottom"
  },
  ".cm-widgetBuffer": {
    verticalAlign: "text-top",
    height: "1em",
    width: 0,
    display: "inline"
  },
  ".cm-placeholder": {
    color: "#888",
    display: "inline-block",
    verticalAlign: "top",
    userSelect: "none"
  },
  ".cm-highlightSpace": {
    backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
    backgroundPosition: "center"
  },
  ".cm-highlightTab": {
    backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
    backgroundSize: "auto 100%",
    backgroundPosition: "right 90%",
    backgroundRepeat: "no-repeat"
  },
  ".cm-trailingSpace": {
    backgroundColor: "#ff332255"
  },
  ".cm-button": {
    verticalAlign: "middle",
    color: "inherit",
    fontSize: "70%",
    padding: ".2em 1em",
    borderRadius: "1px"
  },
  "&light .cm-button": {
    backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
    border: "1px solid #888",
    "&:active": {
      backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
    }
  },
  "&dark .cm-button": {
    backgroundImage: "linear-gradient(#393939, #111)",
    border: "1px solid #888",
    "&:active": {
      backgroundImage: "linear-gradient(#111, #333)"
    }
  },
  ".cm-textfield": {
    verticalAlign: "middle",
    color: "inherit",
    fontSize: "70%",
    border: "1px solid silver",
    padding: ".2em .5em"
  },
  "&light .cm-textfield": {
    backgroundColor: "white"
  },
  "&dark .cm-textfield": {
    border: "1px solid #555",
    backgroundColor: "inherit"
  }
}, sp), d1 = {
  childList: !0,
  characterData: !0,
  subtree: !0,
  attributes: !0,
  characterDataOldValue: !0
}, Co = E.ie && E.ie_version <= 11;
class p1 {
  constructor(e) {
    this.view = e, this.active = !1, this.editContext = null, this.selectionRange = new Fg(), this.selectionChanged = !1, this.delayedFlush = -1, this.resizeTimeout = -1, this.queue = [], this.delayedAndroidKey = null, this.flushingAndroidKey = -1, this.lastChange = 0, this.scrollTargets = [], this.intersection = null, this.resizeScroll = null, this.intersecting = !1, this.gapIntersection = null, this.gaps = [], this.printQuery = null, this.parentCheck = -1, this.dom = e.contentDOM, this.observer = new MutationObserver((t) => {
      for (let i of t)
        this.queue.push(i);
      (E.ie && E.ie_version <= 11 || E.ios && e.composing) && t.some((i) => i.type == "childList" && i.removedNodes.length || i.type == "characterData" && i.oldValue.length > i.target.nodeValue.length) ? this.flushSoon() : this.flush();
    }), window.EditContext && E.android && e.constructor.EDIT_CONTEXT !== !1 && // Chrome <126 doesn't support inverted selections in edit context (#1392)
    !(E.chrome && E.chrome_version < 126) && (this.editContext = new m1(e), e.state.facet(Lt) && (e.contentDOM.editContext = this.editContext.editContext)), Co && (this.onCharData = (t) => {
      this.queue.push({
        target: t.target,
        type: "characterData",
        oldValue: t.prevValue
      }), this.flushSoon();
    }), this.onSelectionChange = this.onSelectionChange.bind(this), this.onResize = this.onResize.bind(this), this.onPrint = this.onPrint.bind(this), this.onScroll = this.onScroll.bind(this), window.matchMedia && (this.printQuery = window.matchMedia("print")), typeof ResizeObserver == "function" && (this.resizeScroll = new ResizeObserver(() => {
      var t;
      ((t = this.view.docView) === null || t === void 0 ? void 0 : t.lastUpdate) < Date.now() - 75 && this.onResize();
    }), this.resizeScroll.observe(e.scrollDOM)), this.addWindowListeners(this.win = e.win), this.start(), typeof IntersectionObserver == "function" && (this.intersection = new IntersectionObserver((t) => {
      this.parentCheck < 0 && (this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1e3)), t.length > 0 && t[t.length - 1].intersectionRatio > 0 != this.intersecting && (this.intersecting = !this.intersecting, this.intersecting != this.view.inView && this.onScrollChanged(document.createEvent("Event")));
    }, { threshold: [0, 1e-3] }), this.intersection.observe(this.dom), this.gapIntersection = new IntersectionObserver((t) => {
      t.length > 0 && t[t.length - 1].intersectionRatio > 0 && this.onScrollChanged(document.createEvent("Event"));
    }, {})), this.listenForScroll(), this.readSelectionRange();
  }
  onScrollChanged(e) {
    this.view.inputState.runHandlers("scroll", e), this.intersecting && this.view.measure();
  }
  onScroll(e) {
    this.intersecting && this.flush(!1), this.editContext && this.view.requestMeasure(this.editContext.measureReq), this.onScrollChanged(e);
  }
  onResize() {
    this.resizeTimeout < 0 && (this.resizeTimeout = setTimeout(() => {
      this.resizeTimeout = -1, this.view.requestMeasure();
    }, 50));
  }
  onPrint(e) {
    (e.type == "change" || !e.type) && !e.matches || (this.view.viewState.printing = !0, this.view.measure(), setTimeout(() => {
      this.view.viewState.printing = !1, this.view.requestMeasure();
    }, 500));
  }
  updateGaps(e) {
    if (this.gapIntersection && (e.length != this.gaps.length || this.gaps.some((t, i) => t != e[i]))) {
      this.gapIntersection.disconnect();
      for (let t of e)
        this.gapIntersection.observe(t);
      this.gaps = e;
    }
  }
  onSelectionChange(e) {
    let t = this.selectionChanged;
    if (!this.readSelectionRange() || this.delayedAndroidKey)
      return;
    let { view: i } = this, n = this.selectionRange;
    if (i.state.facet(Lt) ? i.root.activeElement != this.dom : !Kn(this.dom, n))
      return;
    let s = n.anchorNode && i.docView.nearest(n.anchorNode);
    if (s && s.ignoreEvent(e)) {
      t || (this.selectionChanged = !1);
      return;
    }
    (E.ie && E.ie_version <= 11 || E.android && E.chrome) && !i.state.selection.main.empty && // (Selection.isCollapsed isn't reliable on IE)
    n.focusNode && Tr(n.focusNode, n.focusOffset, n.anchorNode, n.anchorOffset) ? this.flushSoon() : this.flush(!1);
  }
  readSelectionRange() {
    let { view: e } = this, t = Br(e.root);
    if (!t)
      return !1;
    let i = E.safari && e.root.nodeType == 11 && e.root.activeElement == this.dom && O1(this.view, t) || t;
    if (!i || this.selectionRange.eq(i))
      return !1;
    let n = Kn(this.dom, i);
    return n && !this.selectionChanged && e.inputState.lastFocusTime > Date.now() - 200 && e.inputState.lastTouchTime < Date.now() - 300 && Kg(this.dom, i) ? (this.view.inputState.lastFocusTime = 0, e.docView.updateSelection(), !1) : (this.selectionRange.setRange(i), n && (this.selectionChanged = !0), !0);
  }
  setSelectionRange(e, t) {
    this.selectionRange.set(e.node, e.offset, t.node, t.offset), this.selectionChanged = !1;
  }
  clearSelectionRange() {
    this.selectionRange.set(null, 0, null, 0);
  }
  listenForScroll() {
    this.parentCheck = -1;
    let e = 0, t = null;
    for (let i = this.dom; i; )
      if (i.nodeType == 1)
        !t && e < this.scrollTargets.length && this.scrollTargets[e] == i ? e++ : t || (t = this.scrollTargets.slice(0, e)), t && t.push(i), i = i.assignedSlot || i.parentNode;
      else if (i.nodeType == 11)
        i = i.host;
      else
        break;
    if (e < this.scrollTargets.length && !t && (t = this.scrollTargets.slice(0, e)), t) {
      for (let i of this.scrollTargets)
        i.removeEventListener("scroll", this.onScroll);
      for (let i of this.scrollTargets = t)
        i.addEventListener("scroll", this.onScroll);
    }
  }
  ignore(e) {
    if (!this.active)
      return e();
    try {
      return this.stop(), e();
    } finally {
      this.start(), this.clear();
    }
  }
  start() {
    this.active || (this.observer.observe(this.dom, d1), Co && this.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.active = !0);
  }
  stop() {
    this.active && (this.active = !1, this.observer.disconnect(), Co && this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData));
  }
  // Throw away any pending changes
  clear() {
    this.processRecords(), this.queue.length = 0, this.selectionChanged = !1;
  }
  // Chrome Android, especially in combination with GBoard, not only
  // doesn't reliably fire regular key events, but also often
  // surrounds the effect of enter or backspace with a bunch of
  // composition events that, when interrupted, cause text duplication
  // or other kinds of corruption. This hack makes the editor back off
  // from handling DOM changes for a moment when such a key is
  // detected (via beforeinput or keydown), and then tries to flush
  // them or, if that has no effect, dispatches the given key.
  delayAndroidKey(e, t) {
    var i;
    if (!this.delayedAndroidKey) {
      let n = () => {
        let s = this.delayedAndroidKey;
        s && (this.clearDelayedAndroidKey(), this.view.inputState.lastKeyCode = s.keyCode, this.view.inputState.lastKeyTime = Date.now(), !this.flush() && s.force && Di(this.dom, s.key, s.keyCode));
      };
      this.flushingAndroidKey = this.view.win.requestAnimationFrame(n);
    }
    (!this.delayedAndroidKey || e == "Enter") && (this.delayedAndroidKey = {
      key: e,
      keyCode: t,
      // Only run the key handler when no changes are detected if
      // this isn't coming right after another change, in which case
      // it is probably part of a weird chain of updates, and should
      // be ignored if it returns the DOM to its previous state.
      force: this.lastChange < Date.now() - 50 || !!(!((i = this.delayedAndroidKey) === null || i === void 0) && i.force)
    });
  }
  clearDelayedAndroidKey() {
    this.win.cancelAnimationFrame(this.flushingAndroidKey), this.delayedAndroidKey = null, this.flushingAndroidKey = -1;
  }
  flushSoon() {
    this.delayedFlush < 0 && (this.delayedFlush = this.view.win.requestAnimationFrame(() => {
      this.delayedFlush = -1, this.flush();
    }));
  }
  forceFlush() {
    this.delayedFlush >= 0 && (this.view.win.cancelAnimationFrame(this.delayedFlush), this.delayedFlush = -1), this.flush();
  }
  pendingRecords() {
    for (let e of this.observer.takeRecords())
      this.queue.push(e);
    return this.queue;
  }
  processRecords() {
    let e = this.pendingRecords();
    e.length && (this.queue = []);
    let t = -1, i = -1, n = !1;
    for (let s of e) {
      let o = this.readMutation(s);
      o && (o.typeOver && (n = !0), t == -1 ? { from: t, to: i } = o : (t = Math.min(o.from, t), i = Math.max(o.to, i)));
    }
    return { from: t, to: i, typeOver: n };
  }
  readChange() {
    let { from: e, to: t, typeOver: i } = this.processRecords(), n = this.selectionChanged && Kn(this.dom, this.selectionRange);
    if (e < 0 && !n)
      return null;
    e > -1 && (this.lastChange = Date.now()), this.view.inputState.lastFocusTime = 0, this.selectionChanged = !1;
    let s = new X0(this.view, e, t, i);
    return this.view.docView.domChanged = { newSel: s.newSel ? s.newSel.main : null }, s;
  }
  // Apply pending changes, if any
  flush(e = !0) {
    if (this.delayedFlush >= 0 || this.delayedAndroidKey)
      return !1;
    e && this.readSelectionRange();
    let t = this.readChange();
    if (!t)
      return this.view.requestMeasure(), !1;
    let i = this.view.state, n = Wd(this.view, t);
    return this.view.state == i && (t.domChanged || t.newSel && !t.newSel.main.eq(this.view.state.selection.main)) && this.view.update([]), n;
  }
  readMutation(e) {
    let t = this.view.docView.nearest(e.target);
    if (!t || t.ignoreMutation(e))
      return null;
    if (t.markDirty(e.type == "attributes"), e.type == "attributes" && (t.flags |= 4), e.type == "childList") {
      let i = Qc(t, e.previousSibling || e.target.previousSibling, -1), n = Qc(t, e.nextSibling || e.target.nextSibling, 1);
      return {
        from: i ? t.posAfter(i) : t.posAtStart,
        to: n ? t.posBefore(n) : t.posAtEnd,
        typeOver: !1
      };
    } else return e.type == "characterData" ? { from: t.posAtStart, to: t.posAtEnd, typeOver: e.target.nodeValue == e.oldValue } : null;
  }
  setWindow(e) {
    e != this.win && (this.removeWindowListeners(this.win), this.win = e, this.addWindowListeners(this.win));
  }
  addWindowListeners(e) {
    e.addEventListener("resize", this.onResize), this.printQuery ? this.printQuery.addEventListener ? this.printQuery.addEventListener("change", this.onPrint) : this.printQuery.addListener(this.onPrint) : e.addEventListener("beforeprint", this.onPrint), e.addEventListener("scroll", this.onScroll), e.document.addEventListener("selectionchange", this.onSelectionChange);
  }
  removeWindowListeners(e) {
    e.removeEventListener("scroll", this.onScroll), e.removeEventListener("resize", this.onResize), this.printQuery ? this.printQuery.removeEventListener ? this.printQuery.removeEventListener("change", this.onPrint) : this.printQuery.removeListener(this.onPrint) : e.removeEventListener("beforeprint", this.onPrint), e.document.removeEventListener("selectionchange", this.onSelectionChange);
  }
  update(e) {
    this.editContext && (this.editContext.update(e), e.startState.facet(Lt) != e.state.facet(Lt) && (e.view.contentDOM.editContext = e.state.facet(Lt) ? this.editContext.editContext : null));
  }
  destroy() {
    var e, t, i;
    this.stop(), (e = this.intersection) === null || e === void 0 || e.disconnect(), (t = this.gapIntersection) === null || t === void 0 || t.disconnect(), (i = this.resizeScroll) === null || i === void 0 || i.disconnect();
    for (let n of this.scrollTargets)
      n.removeEventListener("scroll", this.onScroll);
    this.removeWindowListeners(this.win), clearTimeout(this.parentCheck), clearTimeout(this.resizeTimeout), this.win.cancelAnimationFrame(this.delayedFlush), this.win.cancelAnimationFrame(this.flushingAndroidKey), this.editContext && (this.view.contentDOM.editContext = null, this.editContext.destroy());
  }
}
function Qc(r, e, t) {
  for (; e; ) {
    let i = ne.get(e);
    if (i && i.parent == r)
      return i;
    let n = e.parentNode;
    e = n != r.dom ? n : t > 0 ? e.nextSibling : e.previousSibling;
  }
  return null;
}
function vc(r, e) {
  let t = e.startContainer, i = e.startOffset, n = e.endContainer, s = e.endOffset, o = r.docView.domAtPos(r.state.selection.main.anchor);
  return Tr(o.node, o.offset, n, s) && ([t, i, n, s] = [n, s, t, i]), { anchorNode: t, anchorOffset: i, focusNode: n, focusOffset: s };
}
function O1(r, e) {
  if (e.getComposedRanges) {
    let n = e.getComposedRanges(r.root)[0];
    if (n)
      return vc(r, n);
  }
  let t = null;
  function i(n) {
    n.preventDefault(), n.stopImmediatePropagation(), t = n.getTargetRanges()[0];
  }
  return r.contentDOM.addEventListener("beforeinput", i, !0), r.dom.ownerDocument.execCommand("indent"), r.contentDOM.removeEventListener("beforeinput", i, !0), t ? vc(r, t) : null;
}
class m1 {
  constructor(e) {
    this.from = 0, this.to = 0, this.pendingContextChange = null, this.handlers = /* @__PURE__ */ Object.create(null), this.composing = null, this.resetRange(e.state);
    let t = this.editContext = new window.EditContext({
      text: e.state.doc.sliceString(this.from, this.to),
      selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, e.state.selection.main.anchor))),
      selectionEnd: this.toContextPos(e.state.selection.main.head)
    });
    this.handlers.textupdate = (i) => {
      let n = e.state.selection.main, { anchor: s, head: o } = n, l = this.toEditorPos(i.updateRangeStart), a = this.toEditorPos(i.updateRangeEnd);
      e.inputState.composing >= 0 && !this.composing && (this.composing = { contextBase: i.updateRangeStart, editorBase: l, drifted: !1 });
      let h = a - l > i.text.length;
      l == this.from && s < this.from ? l = s : a == this.to && s > this.to && (a = s);
      let c = jd(e.state.sliceDoc(l, a), i.text, (h ? n.from : n.to) - l, h ? "end" : null);
      if (!c) {
        let u = v.single(this.toEditorPos(i.selectionStart), this.toEditorPos(i.selectionEnd));
        u.main.eq(n) || e.dispatch({ selection: u, userEvent: "select" });
        return;
      }
      let f = {
        from: c.from + l,
        to: c.toA + l,
        insert: K.of(i.text.slice(c.from, c.toB).split(`
`))
      };
      if ((E.mac || E.android) && f.from == o - 1 && /^\. ?$/.test(i.text) && e.contentDOM.getAttribute("autocorrect") == "off" && (f = { from: l, to: a, insert: K.of([i.text.replace(".", " ")]) }), this.pendingContextChange = f, !e.state.readOnly) {
        let u = this.to - this.from + (f.to - f.from + f.insert.length);
        Ga(e, f, v.single(this.toEditorPos(i.selectionStart, u), this.toEditorPos(i.selectionEnd, u)));
      }
      this.pendingContextChange && (this.revertPending(e.state), this.setSelection(e.state)), f.from < f.to && !f.insert.length && e.inputState.composing >= 0 && !/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0, i.updateRangeStart - 1), Math.min(t.text.length, i.updateRangeStart + 1))) && this.handlers.compositionend(i);
    }, this.handlers.characterboundsupdate = (i) => {
      let n = [], s = null;
      for (let o = this.toEditorPos(i.rangeStart), l = this.toEditorPos(i.rangeEnd); o < l; o++) {
        let a = e.coordsForChar(o);
        s = a && new DOMRect(a.left, a.top, a.right - a.left, a.bottom - a.top) || s || new DOMRect(), n.push(s);
      }
      t.updateCharacterBounds(i.rangeStart, n);
    }, this.handlers.textformatupdate = (i) => {
      let n = [];
      for (let s of i.getTextFormats()) {
        let o = s.underlineStyle, l = s.underlineThickness;
        if (!/none/i.test(o) && !/none/i.test(l)) {
          let a = this.toEditorPos(s.rangeStart), h = this.toEditorPos(s.rangeEnd);
          if (a < h) {
            let c = `text-decoration: underline ${/^[a-z]/.test(o) ? o + " " : o == "Dashed" ? "dashed " : o == "Squiggle" ? "wavy " : ""}${/thin/i.test(l) ? 1 : 2}px`;
            n.push(B.mark({ attributes: { style: c } }).range(a, h));
          }
        }
      }
      e.dispatch({ effects: zd.of(B.set(n)) });
    }, this.handlers.compositionstart = () => {
      e.inputState.composing < 0 && (e.inputState.composing = 0, e.inputState.compositionFirstChange = !0);
    }, this.handlers.compositionend = () => {
      if (e.inputState.composing = -1, e.inputState.compositionFirstChange = null, this.composing) {
        let { drifted: i } = this.composing;
        this.composing = null, i && this.reset(e.state);
      }
    };
    for (let i in this.handlers)
      t.addEventListener(i, this.handlers[i]);
    this.measureReq = { read: (i) => {
      this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());
      let n = Br(i.root);
      n && n.rangeCount && this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect());
    } };
  }
  applyEdits(e) {
    let t = 0, i = !1, n = this.pendingContextChange;
    return e.changes.iterChanges((s, o, l, a, h) => {
      if (i)
        return;
      let c = h.length - (o - s);
      if (n && o >= n.to)
        if (n.from == s && n.to == o && n.insert.eq(h)) {
          n = this.pendingContextChange = null, t += c, this.to += c;
          return;
        } else
          n = null, this.revertPending(e.state);
      if (s += t, o += t, o <= this.from)
        this.from += c, this.to += c;
      else if (s < this.to) {
        if (s < this.from || o > this.to || this.to - this.from + h.length > 3e4) {
          i = !0;
          return;
        }
        this.editContext.updateText(this.toContextPos(s), this.toContextPos(o), h.toString()), this.to += c;
      }
      t += c;
    }), n && !i && this.revertPending(e.state), !i;
  }
  update(e) {
    let t = this.pendingContextChange, i = e.startState.selection.main;
    this.composing && (this.composing.drifted || !e.changes.touchesRange(i.from, i.to) && e.transactions.some((n) => !n.isUserEvent("input.type") && n.changes.touchesRange(this.from, this.to))) ? (this.composing.drifted = !0, this.composing.editorBase = e.changes.mapPos(this.composing.editorBase)) : !this.applyEdits(e) || !this.rangeIsValid(e.state) ? (this.pendingContextChange = null, this.reset(e.state)) : (e.docChanged || e.selectionSet || t) && this.setSelection(e.state), (e.geometryChanged || e.docChanged || e.selectionSet) && e.view.requestMeasure(this.measureReq);
  }
  resetRange(e) {
    let { head: t } = e.selection.main;
    this.from = Math.max(
      0,
      t - 1e4
      /* CxVp.Margin */
    ), this.to = Math.min(
      e.doc.length,
      t + 1e4
      /* CxVp.Margin */
    );
  }
  reset(e) {
    this.resetRange(e), this.editContext.updateText(0, this.editContext.text.length, e.doc.sliceString(this.from, this.to)), this.setSelection(e);
  }
  revertPending(e) {
    let t = this.pendingContextChange;
    this.pendingContextChange = null, this.editContext.updateText(this.toContextPos(t.from), this.toContextPos(t.from + t.insert.length), e.doc.sliceString(t.from, t.to));
  }
  setSelection(e) {
    let { main: t } = e.selection, i = this.toContextPos(Math.max(this.from, Math.min(this.to, t.anchor))), n = this.toContextPos(t.head);
    (this.editContext.selectionStart != i || this.editContext.selectionEnd != n) && this.editContext.updateSelection(i, n);
  }
  rangeIsValid(e) {
    let { head: t } = e.selection.main;
    return !(this.from > 0 && t - this.from < 500 || this.to < e.doc.length && this.to - t < 500 || this.to - this.from > 1e4 * 3);
  }
  toEditorPos(e, t = this.to - this.from) {
    e = Math.min(e, t);
    let i = this.composing;
    return i && i.drifted ? i.editorBase + (e - i.contextBase) : e + this.from;
  }
  toContextPos(e) {
    let t = this.composing;
    return t && t.drifted ? t.contextBase + (e - t.editorBase) : e - this.from;
  }
  destroy() {
    for (let e in this.handlers)
      this.editContext.removeEventListener(e, this.handlers[e]);
  }
}
class D {
  /**
  The current editor state.
  */
  get state() {
    return this.viewState.state;
  }
  /**
  To be able to display large documents without consuming too much
  memory or overloading the browser, CodeMirror only draws the
  code that is visible (plus a margin around it) to the DOM. This
  property tells you the extent of the current drawn viewport, in
  document positions.
  */
  get viewport() {
    return this.viewState.viewport;
  }
  /**
  When there are, for example, large collapsed ranges in the
  viewport, its size can be a lot bigger than the actual visible
  content. Thus, if you are doing something like styling the
  content in the viewport, it is preferable to only do so for
  these ranges, which are the subset of the viewport that is
  actually drawn.
  */
  get visibleRanges() {
    return this.viewState.visibleRanges;
  }
  /**
  Returns false when the editor is entirely scrolled out of view
  or otherwise hidden.
  */
  get inView() {
    return this.viewState.inView;
  }
  /**
  Indicates whether the user is currently composing text via
  [IME](https://en.wikipedia.org/wiki/Input_method), and at least
  one change has been made in the current composition.
  */
  get composing() {
    return !!this.inputState && this.inputState.composing > 0;
  }
  /**
  Indicates whether the user is currently in composing state. Note
  that on some platforms, like Android, this will be the case a
  lot, since just putting the cursor on a word starts a
  composition there.
  */
  get compositionStarted() {
    return !!this.inputState && this.inputState.composing >= 0;
  }
  /**
  The document or shadow root that the view lives in.
  */
  get root() {
    return this._root;
  }
  /**
  @internal
  */
  get win() {
    return this.dom.ownerDocument.defaultView || window;
  }
  /**
  Construct a new view. You'll want to either provide a `parent`
  option, or put `view.dom` into your document after creating a
  view, so that the user can see the editor.
  */
  constructor(e = {}) {
    var t;
    this.plugins = [], this.pluginMap = /* @__PURE__ */ new Map(), this.editorAttrs = {}, this.contentAttrs = {}, this.bidiCache = [], this.destroyed = !1, this.updateState = 2, this.measureScheduled = -1, this.measureRequests = [], this.contentDOM = document.createElement("div"), this.scrollDOM = document.createElement("div"), this.scrollDOM.tabIndex = -1, this.scrollDOM.className = "cm-scroller", this.scrollDOM.appendChild(this.contentDOM), this.announceDOM = document.createElement("div"), this.announceDOM.className = "cm-announced", this.announceDOM.setAttribute("aria-live", "polite"), this.dom = document.createElement("div"), this.dom.appendChild(this.announceDOM), this.dom.appendChild(this.scrollDOM), e.parent && e.parent.appendChild(this.dom);
    let { dispatch: i } = e;
    this.dispatchTransactions = e.dispatchTransactions || i && ((n) => n.forEach((s) => i(s, this))) || ((n) => this.update(n)), this.dispatch = this.dispatch.bind(this), this._root = e.root || Hg(e.parent) || document, this.viewState = new xc(e.state || W.create(e)), e.scrollTo && e.scrollTo.is(xn) && (this.viewState.scrollTarget = e.scrollTo.value.clip(this.viewState.state)), this.plugins = this.state.facet(Xi).map((n) => new Qo(n));
    for (let n of this.plugins)
      n.update(this);
    this.observer = new p1(this), this.inputState = new z0(this), this.inputState.ensureHandlers(this.plugins), this.docView = new rc(this), this.mountStyles(), this.updateAttrs(), this.updateState = 0, this.requestMeasure(), !((t = document.fonts) === null || t === void 0) && t.ready && document.fonts.ready.then(() => this.requestMeasure());
  }
  dispatch(...e) {
    let t = e.length == 1 && e[0] instanceof me ? e : e.length == 1 && Array.isArray(e[0]) ? e[0] : [this.state.update(...e)];
    this.dispatchTransactions(t, this);
  }
  /**
  Update the view for the given array of transactions. This will
  update the visible document and selection to match the state
  produced by the transactions, and notify view plugins of the
  change. You should usually call
  [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
  as a primitive.
  */
  update(e) {
    if (this.updateState != 0)
      throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
    let t = !1, i = !1, n, s = this.state;
    for (let u of e) {
      if (u.startState != s)
        throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
      s = u.state;
    }
    if (this.destroyed) {
      this.viewState.state = s;
      return;
    }
    let o = this.hasFocus, l = 0, a = null;
    e.some((u) => u.annotation(Jd)) ? (this.inputState.notifiedFocused = o, l = 1) : o != this.inputState.notifiedFocused && (this.inputState.notifiedFocused = o, a = ep(s, o), a || (l = 1));
    let h = this.observer.delayedAndroidKey, c = null;
    if (h ? (this.observer.clearDelayedAndroidKey(), c = this.observer.readChange(), (c && !this.state.doc.eq(s.doc) || !this.state.selection.eq(s.selection)) && (c = null)) : this.observer.clear(), s.facet(W.phrases) != this.state.facet(W.phrases))
      return this.setState(s);
    n = Ss.create(this, s, e), n.flags |= l;
    let f = this.viewState.scrollTarget;
    try {
      this.updateState = 2;
      for (let u of e) {
        if (f && (f = f.map(u.changes)), u.scrollIntoView) {
          let { main: d } = u.state.selection;
          f = new _i(d.empty ? d : v.cursor(d.head, d.head > d.anchor ? -1 : 1));
        }
        for (let d of u.effects)
          d.is(xn) && (f = d.value.clip(this.state));
      }
      this.viewState.update(n, f), this.bidiCache = xs.update(this.bidiCache, n.changes), n.empty || (this.updatePlugins(n), this.inputState.update(n)), t = this.docView.update(n), this.state.facet(Sr) != this.styleModules && this.mountStyles(), i = this.updateAttrs(), this.showAnnouncements(e), this.docView.updateSelection(t, e.some((u) => u.isUserEvent("select.pointer")));
    } finally {
      this.updateState = 0;
    }
    if (n.startState.facet(Cn) != n.state.facet(Cn) && (this.viewState.mustMeasureContent = !0), (t || i || f || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent) && this.requestMeasure(), t && this.docViewUpdate(), !n.empty)
      for (let u of this.state.facet(ql))
        try {
          u(n);
        } catch (d) {
          Qe(this.state, d, "update listener");
        }
    (a || c) && Promise.resolve().then(() => {
      a && this.state == a.startState && this.dispatch(a), c && !Wd(this, c) && h.force && Di(this.contentDOM, h.key, h.keyCode);
    });
  }
  /**
  Reset the view to the given state. (This will cause the entire
  document to be redrawn and all view plugins to be reinitialized,
  so you should probably only use it when the new state isn't
  derived from the old state. Otherwise, use
  [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
  */
  setState(e) {
    if (this.updateState != 0)
      throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
    if (this.destroyed) {
      this.viewState.state = e;
      return;
    }
    this.updateState = 2;
    let t = this.hasFocus;
    try {
      for (let i of this.plugins)
        i.destroy(this);
      this.viewState = new xc(e), this.plugins = e.facet(Xi).map((i) => new Qo(i)), this.pluginMap.clear();
      for (let i of this.plugins)
        i.update(this);
      this.docView.destroy(), this.docView = new rc(this), this.inputState.ensureHandlers(this.plugins), this.mountStyles(), this.updateAttrs(), this.bidiCache = [];
    } finally {
      this.updateState = 0;
    }
    t && this.focus(), this.requestMeasure();
  }
  updatePlugins(e) {
    let t = e.startState.facet(Xi), i = e.state.facet(Xi);
    if (t != i) {
      let n = [];
      for (let s of i) {
        let o = t.indexOf(s);
        if (o < 0)
          n.push(new Qo(s));
        else {
          let l = this.plugins[o];
          l.mustUpdate = e, n.push(l);
        }
      }
      for (let s of this.plugins)
        s.mustUpdate != e && s.destroy(this);
      this.plugins = n, this.pluginMap.clear();
    } else
      for (let n of this.plugins)
        n.mustUpdate = e;
    for (let n = 0; n < this.plugins.length; n++)
      this.plugins[n].update(this);
    t != i && this.inputState.ensureHandlers(this.plugins);
  }
  docViewUpdate() {
    for (let e of this.plugins) {
      let t = e.value;
      if (t && t.docViewUpdate)
        try {
          t.docViewUpdate(this);
        } catch (i) {
          Qe(this.state, i, "doc view update listener");
        }
    }
  }
  /**
  @internal
  */
  measure(e = !0) {
    if (this.destroyed)
      return;
    if (this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.observer.delayedAndroidKey) {
      this.measureScheduled = -1, this.requestMeasure();
      return;
    }
    this.measureScheduled = 0, e && this.observer.forceFlush();
    let t = null, i = this.scrollDOM, n = i.scrollTop * this.scaleY, { scrollAnchorPos: s, scrollAnchorHeight: o } = this.viewState;
    Math.abs(n - this.viewState.scrollTop) > 1 && (o = -1), this.viewState.scrollAnchorHeight = -1;
    try {
      for (let l = 0; ; l++) {
        if (o < 0)
          if (dd(i))
            s = -1, o = this.viewState.heightMap.height;
          else {
            let d = this.viewState.scrollAnchorAt(n);
            s = d.from, o = d.top;
          }
        this.updateState = 1;
        let a = this.viewState.measure(this);
        if (!a && !this.measureRequests.length && this.viewState.scrollTarget == null)
          break;
        if (l > 5) {
          console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
          break;
        }
        let h = [];
        a & 4 || ([this.measureRequests, h] = [h, this.measureRequests]);
        let c = h.map((d) => {
          try {
            return d.read(this);
          } catch (p) {
            return Qe(this.state, p), $c;
          }
        }), f = Ss.create(this, this.state, []), u = !1;
        f.flags |= a, t ? t.flags |= a : t = f, this.updateState = 2, f.empty || (this.updatePlugins(f), this.inputState.update(f), this.updateAttrs(), u = this.docView.update(f), u && this.docViewUpdate());
        for (let d = 0; d < h.length; d++)
          if (c[d] != $c)
            try {
              let p = h[d];
              p.write && p.write(c[d], this);
            } catch (p) {
              Qe(this.state, p);
            }
        if (u && this.docView.updateSelection(!0), !f.viewportChanged && this.measureRequests.length == 0) {
          if (this.viewState.editorHeight)
            if (this.viewState.scrollTarget) {
              this.docView.scrollIntoView(this.viewState.scrollTarget), this.viewState.scrollTarget = null, o = -1;
              continue;
            } else {
              let p = (s < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(s).top) - o;
              if (p > 1 || p < -1) {
                n = n + p, i.scrollTop = n / this.scaleY, o = -1;
                continue;
              }
            }
          break;
        }
      }
    } finally {
      this.updateState = 0, this.measureScheduled = -1;
    }
    if (t && !t.empty)
      for (let l of this.state.facet(ql))
        l(t);
  }
  /**
  Get the CSS classes for the currently active editor themes.
  */
  get themeClasses() {
    return Gl + " " + (this.state.facet(jl) ? np : rp) + " " + this.state.facet(Cn);
  }
  updateAttrs() {
    let e = Pc(this, Dd, {
      class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
    }), t = {
      spellcheck: "false",
      autocorrect: "off",
      autocapitalize: "off",
      writingsuggestions: "false",
      translate: "no",
      contenteditable: this.state.facet(Lt) ? "true" : "false",
      class: "cm-content",
      style: `${E.tabSize}: ${this.state.tabSize}`,
      role: "textbox",
      "aria-multiline": "true"
    };
    this.state.readOnly && (t["aria-readonly"] = "true"), Pc(this, Wa, t);
    let i = this.observer.ignore(() => {
      let n = Dl(this.contentDOM, this.contentAttrs, t), s = Dl(this.dom, this.editorAttrs, e);
      return n || s;
    });
    return this.editorAttrs = e, this.contentAttrs = t, i;
  }
  showAnnouncements(e) {
    let t = !0;
    for (let i of e)
      for (let n of i.effects)
        if (n.is(D.announce)) {
          t && (this.announceDOM.textContent = ""), t = !1;
          let s = this.announceDOM.appendChild(document.createElement("div"));
          s.textContent = n.value;
        }
  }
  mountStyles() {
    this.styleModules = this.state.facet(Sr);
    let e = this.state.facet(D.cspNonce);
    Pt.mount(this.root, this.styleModules.concat(u1).reverse(), e ? { nonce: e } : void 0);
  }
  readMeasured() {
    if (this.updateState == 2)
      throw new Error("Reading the editor layout isn't allowed during an update");
    this.updateState == 0 && this.measureScheduled > -1 && this.measure(!1);
  }
  /**
  Schedule a layout measurement, optionally providing callbacks to
  do custom DOM measuring followed by a DOM write phase. Using
  this is preferable reading DOM layout directly from, for
  example, an event handler, because it'll make sure measuring and
  drawing done by other components is synchronized, avoiding
  unnecessary DOM layout computations.
  */
  requestMeasure(e) {
    if (this.measureScheduled < 0 && (this.measureScheduled = this.win.requestAnimationFrame(() => this.measure())), e) {
      if (this.measureRequests.indexOf(e) > -1)
        return;
      if (e.key != null) {
        for (let t = 0; t < this.measureRequests.length; t++)
          if (this.measureRequests[t].key === e.key) {
            this.measureRequests[t] = e;
            return;
          }
      }
      this.measureRequests.push(e);
    }
  }
  /**
  Get the value of a specific plugin, if present. Note that
  plugins that crash can be dropped from a view, so even when you
  know you registered a given plugin, it is recommended to check
  the return value of this method.
  */
  plugin(e) {
    let t = this.pluginMap.get(e);
    return (t === void 0 || t && t.plugin != e) && this.pluginMap.set(e, t = this.plugins.find((i) => i.plugin == e) || null), t && t.update(this).value;
  }
  /**
  The top position of the document, in screen coordinates. This
  may be negative when the editor is scrolled down. Points
  directly to the top of the first line, not above the padding.
  */
  get documentTop() {
    return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
  }
  /**
  Reports the padding above and below the document.
  */
  get documentPadding() {
    return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
  }
  /**
  If the editor is transformed with CSS, this provides the scale
  along the X axis. Otherwise, it will just be 1. Note that
  transforms other than translation and scaling are not supported.
  */
  get scaleX() {
    return this.viewState.scaleX;
  }
  /**
  Provide the CSS transformed scale along the Y axis.
  */
  get scaleY() {
    return this.viewState.scaleY;
  }
  /**
  Find the text line or block widget at the given vertical
  position (which is interpreted as relative to the [top of the
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
  */
  elementAtHeight(e) {
    return this.readMeasured(), this.viewState.elementAtHeight(e);
  }
  /**
  Find the line block (see
  [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt)) at the given
  height, again interpreted relative to the [top of the
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
  */
  lineBlockAtHeight(e) {
    return this.readMeasured(), this.viewState.lineBlockAtHeight(e);
  }
  /**
  Get the extent and vertical position of all [line
  blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
  are relative to the [top of the
  document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
  */
  get viewportLineBlocks() {
    return this.viewState.viewportLines;
  }
  /**
  Find the line block around the given document position. A line
  block is a range delimited on both sides by either a
  non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line break, or the
  start/end of the document. It will usually just hold a line of
  text, but may be broken into multiple textblocks by block
  widgets.
  */
  lineBlockAt(e) {
    return this.viewState.lineBlockAt(e);
  }
  /**
  The editor's total content height.
  */
  get contentHeight() {
    return this.viewState.contentHeight;
  }
  /**
  Move a cursor position by [grapheme
  cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
  the motion is away from the line start, or towards it. In
  bidirectional text, the line is traversed in visual order, using
  the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
  When the start position was the last one on the line, the
  returned position will be across the line break. If there is no
  further line, the original position is returned.
  
  By default, this method moves over a single cluster. The
  optional `by` argument can be used to move across more. It will
  be called with the first cluster as argument, and should return
  a predicate that determines, for each subsequent cluster,
  whether it should also be moved over.
  */
  moveByChar(e, t, i) {
    return $o(this, e, ac(this, e, t, i));
  }
  /**
  Move a cursor position across the next group of either
  [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
  non-whitespace characters.
  */
  moveByGroup(e, t) {
    return $o(this, e, ac(this, e, t, (i) => C0(this, e.head, i)));
  }
  /**
  Get the cursor position visually at the start or end of a line.
  Note that this may differ from the _logical_ position at its
  start or end (which is simply at `line.from`/`line.to`) if text
  at the start or end goes against the line's base text direction.
  */
  visualLineSide(e, t) {
    let i = this.bidiSpans(e), n = this.textDirectionAt(e.from), s = i[t ? i.length - 1 : 0];
    return v.cursor(s.side(t, n) + e.from, s.forward(!t, n) ? 1 : -1);
  }
  /**
  Move to the next line boundary in the given direction. If
  `includeWrap` is true, line wrapping is on, and there is a
  further wrap point on the current line, the wrap point will be
  returned. Otherwise this function will return the start or end
  of the line.
  */
  moveToLineBoundary(e, t, i = !0) {
    return P0(this, e, t, i);
  }
  /**
  Move a cursor position vertically. When `distance` isn't given,
  it defaults to moving to the next line (including wrapped
  lines). Otherwise, `distance` should provide a positive distance
  in pixels.
  
  When `start` has a
  [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
  motion will use that as a target horizontal position. Otherwise,
  the cursor's own horizontal position is used. The returned
  cursor will have its goal column set to whichever column was
  used.
  */
  moveVertically(e, t, i) {
    return $o(this, e, T0(this, e, t, i));
  }
  /**
  Find the DOM parent node and offset (child offset if `node` is
  an element, character offset when it is a text node) at the
  given document position.
  
  Note that for positions that aren't currently in
  `visibleRanges`, the resulting DOM position isn't necessarily
  meaningful (it may just point before or after a placeholder
  element).
  */
  domAtPos(e) {
    return this.docView.domAtPos(e);
  }
  /**
  Find the document position at the given DOM node. Can be useful
  for associating positions with DOM events. Will raise an error
  when `node` isn't part of the editor content.
  */
  posAtDOM(e, t = 0) {
    return this.docView.posFromDOM(e, t);
  }
  posAtCoords(e, t = !0) {
    return this.readMeasured(), qd(this, e, t);
  }
  /**
  Get the screen coordinates at the given document position.
  `side` determines whether the coordinates are based on the
  element before (-1) or after (1) the position (if no element is
  available on the given side, the method will transparently use
  another strategy to get reasonable coordinates).
  */
  coordsAtPos(e, t = 1) {
    this.readMeasured();
    let i = this.docView.coordsAt(e, t);
    if (!i || i.left == i.right)
      return i;
    let n = this.state.doc.lineAt(e), s = this.bidiSpans(n), o = s[ri.find(s, e - n.from, -1, t)];
    return io(i, o.dir == ce.LTR == t > 0);
  }
  /**
  Return the rectangle around a given character. If `pos` does not
  point in front of a character that is in the viewport and
  rendered (i.e. not replaced, not a line break), this will return
  null. For space characters that are a line wrap point, this will
  return the position before the line break.
  */
  coordsForChar(e) {
    return this.readMeasured(), this.docView.coordsForChar(e);
  }
  /**
  The default width of a character in the editor. May not
  accurately reflect the width of all characters (given variable
  width fonts or styling of invididual ranges).
  */
  get defaultCharacterWidth() {
    return this.viewState.heightOracle.charWidth;
  }
  /**
  The default height of a line in the editor. May not be accurate
  for all lines.
  */
  get defaultLineHeight() {
    return this.viewState.heightOracle.lineHeight;
  }
  /**
  The text direction
  ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
  CSS property) of the editor's content element.
  */
  get textDirection() {
    return this.viewState.defaultTextDirection;
  }
  /**
  Find the text direction of the block at the given position, as
  assigned by CSS. If
  [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
  isn't enabled, or the given position is outside of the viewport,
  this will always return the same as
  [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
  this may trigger a DOM layout.
  */
  textDirectionAt(e) {
    return !this.state.facet(Rd) || e < this.viewport.from || e > this.viewport.to ? this.textDirection : (this.readMeasured(), this.docView.textDirectionAt(e));
  }
  /**
  Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
  (as determined by the
  [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
  CSS property of its content element).
  */
  get lineWrapping() {
    return this.viewState.heightOracle.lineWrapping;
  }
  /**
  Returns the bidirectional text structure of the given line
  (which should be in the current document) as an array of span
  objects. The order of these spans matches the [text
  direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
  left-to-right, the leftmost spans come first, otherwise the
  rightmost spans come first.
  */
  bidiSpans(e) {
    if (e.length > g1)
      return $d(e.length);
    let t = this.textDirectionAt(e.from), i;
    for (let s of this.bidiCache)
      if (s.from == e.from && s.dir == t && (s.fresh || vd(s.isolates, i = ic(this, e))))
        return s.order;
    i || (i = ic(this, e));
    let n = f0(e.text, t, i);
    return this.bidiCache.push(new xs(e.from, e.to, t, i, !0, n)), n;
  }
  /**
  Check whether the editor has focus.
  */
  get hasFocus() {
    var e;
    return (this.dom.ownerDocument.hasFocus() || E.safari && ((e = this.inputState) === null || e === void 0 ? void 0 : e.lastContextMenu) > Date.now() - 3e4) && this.root.activeElement == this.contentDOM;
  }
  /**
  Put focus on the editor.
  */
  focus() {
    this.observer.ignore(() => {
      fd(this.contentDOM), this.docView.updateSelection();
    });
  }
  /**
  Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
  necessary when moving the editor's existing DOM to a new window or shadow root.
  */
  setRoot(e) {
    this._root != e && (this._root = e, this.observer.setWindow((e.nodeType == 9 ? e : e.ownerDocument).defaultView || window), this.mountStyles());
  }
  /**
  Clean up this editor view, removing its element from the
  document, unregistering event handlers, and notifying
  plugins. The view instance can no longer be used after
  calling this.
  */
  destroy() {
    this.root.activeElement == this.contentDOM && this.contentDOM.blur();
    for (let e of this.plugins)
      e.destroy(this);
    this.plugins = [], this.inputState.destroy(), this.docView.destroy(), this.dom.remove(), this.observer.destroy(), this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.destroyed = !0;
  }
  /**
  Returns an effect that can be
  [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
  cause it to scroll the given position or range into view.
  */
  static scrollIntoView(e, t = {}) {
    return xn.of(new _i(typeof e == "number" ? v.cursor(e) : e, t.y, t.x, t.yMargin, t.xMargin));
  }
  /**
  Return an effect that resets the editor to its current (at the
  time this method was called) scroll position. Note that this
  only affects the editor's own scrollable element, not parents.
  See also
  [`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).
  
  The effect should be used with a document identical to the one
  it was created for. Failing to do so is not an error, but may
  not scroll to the expected position. You can
  [map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.
  */
  scrollSnapshot() {
    let { scrollTop: e, scrollLeft: t } = this.scrollDOM, i = this.viewState.scrollAnchorAt(e);
    return xn.of(new _i(v.cursor(i.from), "start", "start", i.top - e, t, !0));
  }
  /**
  Enable or disable tab-focus mode, which disables key bindings
  for Tab and Shift-Tab, letting the browser's default
  focus-changing behavior go through instead. This is useful to
  prevent trapping keyboard users in your editor.
  
  Without argument, this toggles the mode. With a boolean, it
  enables (true) or disables it (false). Given a number, it
  temporarily enables the mode until that number of milliseconds
  have passed or another non-Tab key is pressed.
  */
  setTabFocusMode(e) {
    e == null ? this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1 : typeof e == "boolean" ? this.inputState.tabFocusMode = e ? 0 : -1 : this.inputState.tabFocusMode != 0 && (this.inputState.tabFocusMode = Date.now() + e);
  }
  /**
  Returns an extension that can be used to add DOM event handlers.
  The value should be an object mapping event names to handler
  functions. For any given event, such functions are ordered by
  extension precedence, and the first handler to return true will
  be assumed to have handled that event, and no other handlers or
  built-in behavior will be activated for it. These are registered
  on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
  for `scroll` handlers, which will be called any time the
  editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
  its parent nodes is scrolled.
  */
  static domEventHandlers(e) {
    return ue.define(() => ({}), { eventHandlers: e });
  }
  /**
  Create an extension that registers DOM event observers. Contrary
  to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),
  observers can't be prevented from running by a higher-precedence
  handler returning true. They also don't prevent other handlers
  and observers from running when they return true, and should not
  call `preventDefault`.
  */
  static domEventObservers(e) {
    return ue.define(() => ({}), { eventObservers: e });
  }
  /**
  Create a theme extension. The first argument can be a
  [`style-mod`](https://github.com/marijnh/style-mod#documentation)
  style spec providing the styles for the theme. These will be
  prefixed with a generated class for the style.
  
  Because the selectors will be prefixed with a scope class, rule
  that directly match the editor's [wrapper
  element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
  added—need to be explicitly differentiated by adding an `&` to
  the selector for that element—for example
  `&.cm-focused`.
  
  When `dark` is set to true, the theme will be marked as dark,
  which will cause the `&dark` rules from [base
  themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
  `&light` when a light theme is active).
  */
  static theme(e, t) {
    let i = Pt.newName(), n = [Cn.of(i), Sr.of(Ul(`.${i}`, e))];
    return t && t.dark && n.push(jl.of(!0)), n;
  }
  /**
  Create an extension that adds styles to the base theme. Like
  with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
  place of the editor wrapper element when directly targeting
  that. You can also use `&dark` or `&light` instead to only
  target editors with a dark or light theme.
  */
  static baseTheme(e) {
    return Vt.lowest(Sr.of(Ul("." + Gl, e, sp)));
  }
  /**
  Retrieve an editor view instance from the view's DOM
  representation.
  */
  static findFromDOM(e) {
    var t;
    let i = e.querySelector(".cm-content"), n = i && ne.get(i) || ne.get(e);
    return ((t = n?.rootView) === null || t === void 0 ? void 0 : t.view) || null;
  }
}
D.styleModule = Sr;
D.inputHandler = Zd;
D.clipboardInputFilter = Ya;
D.clipboardOutputFilter = Na;
D.scrollHandler = Ed;
D.focusChangeEffect = Xd;
D.perLineTextDirection = Rd;
D.exceptionSink = Md;
D.updateListener = ql;
D.editable = Lt;
D.mouseSelectionStyle = Ad;
D.dragMovesSelection = Td;
D.clickAddsSelectionRange = Cd;
D.decorations = Vr;
D.outerDecorations = _d;
D.atomicRanges = an;
D.bidiIsolatedRanges = Bd;
D.scrollMargins = Id;
D.darkTheme = jl;
D.cspNonce = /* @__PURE__ */ R.define({ combine: (r) => r.length ? r[0] : "" });
D.contentAttributes = Wa;
D.editorAttributes = Dd;
D.lineWrapping = /* @__PURE__ */ D.contentAttributes.of({ class: "cm-lineWrapping" });
D.announce = /* @__PURE__ */ V.define();
const g1 = 4096, $c = {};
class xs {
  constructor(e, t, i, n, s, o) {
    this.from = e, this.to = t, this.dir = i, this.isolates = n, this.fresh = s, this.order = o;
  }
  static update(e, t) {
    if (t.empty && !e.some((s) => s.fresh))
      return e;
    let i = [], n = e.length ? e[e.length - 1].dir : ce.LTR;
    for (let s = Math.max(0, e.length - 10); s < e.length; s++) {
      let o = e[s];
      o.dir == n && !t.touchesRange(o.from, o.to) && i.push(new xs(t.mapPos(o.from, 1), t.mapPos(o.to, -1), o.dir, o.isolates, !1, o.order));
    }
    return i;
  }
}
function Pc(r, e, t) {
  for (let i = r.state.facet(e), n = i.length - 1; n >= 0; n--) {
    let s = i[n], o = typeof s == "function" ? s(r) : s;
    o && zl(o, t);
  }
  return t;
}
const b1 = E.mac ? "mac" : E.windows ? "win" : E.linux ? "linux" : "key";
function y1(r, e) {
  const t = r.split(/-(?!$)/);
  let i = t[t.length - 1];
  i == "Space" && (i = " ");
  let n, s, o, l;
  for (let a = 0; a < t.length - 1; ++a) {
    const h = t[a];
    if (/^(cmd|meta|m)$/i.test(h))
      l = !0;
    else if (/^a(lt)?$/i.test(h))
      n = !0;
    else if (/^(c|ctrl|control)$/i.test(h))
      s = !0;
    else if (/^s(hift)?$/i.test(h))
      o = !0;
    else if (/^mod$/i.test(h))
      e == "mac" ? l = !0 : s = !0;
    else
      throw new Error("Unrecognized modifier name: " + h);
  }
  return n && (i = "Alt-" + i), s && (i = "Ctrl-" + i), l && (i = "Meta-" + i), o && (i = "Shift-" + i), i;
}
function Tn(r, e, t) {
  return e.altKey && (r = "Alt-" + r), e.ctrlKey && (r = "Ctrl-" + r), e.metaKey && (r = "Meta-" + r), t !== !1 && e.shiftKey && (r = "Shift-" + r), r;
}
const S1 = /* @__PURE__ */ Vt.default(/* @__PURE__ */ D.domEventHandlers({
  keydown(r, e) {
    return lp(op(e.state), r, e, "editor");
  }
})), Ci = /* @__PURE__ */ R.define({ enables: S1 }), Cc = /* @__PURE__ */ new WeakMap();
function op(r) {
  let e = r.facet(Ci), t = Cc.get(e);
  return t || Cc.set(e, t = k1(e.reduce((i, n) => i.concat(n), []))), t;
}
function w1(r, e, t) {
  return lp(op(r.state), e, r, t);
}
let ei = null;
const x1 = 4e3;
function k1(r, e = b1) {
  let t = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), n = (o, l) => {
    let a = i[o];
    if (a == null)
      i[o] = l;
    else if (a != l)
      throw new Error("Key binding " + o + " is used both as a regular binding and as a multi-stroke prefix");
  }, s = (o, l, a, h, c) => {
    var f, u;
    let d = t[o] || (t[o] = /* @__PURE__ */ Object.create(null)), p = l.split(/ (?!$)/).map((b) => y1(b, e));
    for (let b = 1; b < p.length; b++) {
      let w = p.slice(0, b).join(" ");
      n(w, !0), d[w] || (d[w] = {
        preventDefault: !0,
        stopPropagation: !1,
        run: [(k) => {
          let x = ei = { view: k, prefix: w, scope: o };
          return setTimeout(() => {
            ei == x && (ei = null);
          }, x1), !0;
        }]
      });
    }
    let O = p.join(" ");
    n(O, !1);
    let g = d[O] || (d[O] = {
      preventDefault: !1,
      stopPropagation: !1,
      run: ((u = (f = d._any) === null || f === void 0 ? void 0 : f.run) === null || u === void 0 ? void 0 : u.slice()) || []
    });
    a && g.run.push(a), h && (g.preventDefault = !0), c && (g.stopPropagation = !0);
  };
  for (let o of r) {
    let l = o.scope ? o.scope.split(" ") : ["editor"];
    if (o.any)
      for (let h of l) {
        let c = t[h] || (t[h] = /* @__PURE__ */ Object.create(null));
        c._any || (c._any = { preventDefault: !1, stopPropagation: !1, run: [] });
        let { any: f } = o;
        for (let u in c)
          c[u].run.push((d) => f(d, Fl));
      }
    let a = o[e] || o.key;
    if (a)
      for (let h of l)
        s(h, a, o.run, o.preventDefault, o.stopPropagation), o.shift && s(h, "Shift-" + a, o.shift, o.preventDefault, o.stopPropagation);
  }
  return t;
}
let Fl = null;
function lp(r, e, t, i) {
  Fl = e;
  let n = Ng(e), s = Ee(n, 0), o = ot(s) == n.length && n != " ", l = "", a = !1, h = !1, c = !1;
  ei && ei.view == t && ei.scope == i && (l = ei.prefix + " ", Ud.indexOf(e.keyCode) < 0 && (h = !0, ei = null));
  let f = /* @__PURE__ */ new Set(), u = (g) => {
    if (g) {
      for (let b of g.run)
        if (!f.has(b) && (f.add(b), b(t)))
          return g.stopPropagation && (c = !0), !0;
      g.preventDefault && (g.stopPropagation && (c = !0), h = !0);
    }
    return !1;
  }, d = r[i], p, O;
  return d && (u(d[l + Tn(n, e, !o)]) ? a = !0 : o && (e.altKey || e.metaKey || e.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
  !(E.windows && e.ctrlKey && e.altKey) && // Alt-combinations on macOS tend to be typed characters
  !(E.mac && e.altKey && !(e.ctrlKey || e.metaKey)) && (p = li[e.keyCode]) && p != n ? (u(d[l + Tn(p, e, !0)]) || e.shiftKey && (O = _r[e.keyCode]) != n && O != p && u(d[l + Tn(O, e, !1)])) && (a = !0) : o && e.shiftKey && u(d[l + Tn(n, e, !0)]) && (a = !0), !a && u(d._any) && (a = !0)), h && (a = !0), a && c && e.stopPropagation(), Fl = null, a;
}
class hn {
  /**
  Create a marker with the given class and dimensions. If `width`
  is null, the DOM element will get no width style.
  */
  constructor(e, t, i, n, s) {
    this.className = e, this.left = t, this.top = i, this.width = n, this.height = s;
  }
  draw() {
    let e = document.createElement("div");
    return e.className = this.className, this.adjust(e), e;
  }
  update(e, t) {
    return t.className != this.className ? !1 : (this.adjust(e), !0);
  }
  adjust(e) {
    e.style.left = this.left + "px", e.style.top = this.top + "px", this.width != null && (e.style.width = this.width + "px"), e.style.height = this.height + "px";
  }
  eq(e) {
    return this.left == e.left && this.top == e.top && this.width == e.width && this.height == e.height && this.className == e.className;
  }
  /**
  Create a set of rectangles for the given selection range,
  assigning them theclass`className`. Will create a single
  rectangle for empty ranges, and a set of selection-style
  rectangles covering the range's content (in a bidi-aware
  way) for non-empty ones.
  */
  static forRange(e, t, i) {
    if (i.empty) {
      let n = e.coordsAtPos(i.head, i.assoc || 1);
      if (!n)
        return [];
      let s = ap(e);
      return [new hn(t, n.left - s.left, n.top - s.top, null, n.bottom - n.top)];
    } else
      return Q1(e, t, i);
  }
}
function ap(r) {
  let e = r.scrollDOM.getBoundingClientRect();
  return { left: (r.textDirection == ce.LTR ? e.left : e.right - r.scrollDOM.clientWidth * r.scaleX) - r.scrollDOM.scrollLeft * r.scaleX, top: e.top - r.scrollDOM.scrollTop * r.scaleY };
}
function Tc(r, e, t, i) {
  let n = r.coordsAtPos(e, t * 2);
  if (!n)
    return i;
  let s = r.dom.getBoundingClientRect(), o = (n.top + n.bottom) / 2, l = r.posAtCoords({ x: s.left + 1, y: o }), a = r.posAtCoords({ x: s.right - 1, y: o });
  return l == null || a == null ? i : { from: Math.max(i.from, Math.min(l, a)), to: Math.min(i.to, Math.max(l, a)) };
}
function Q1(r, e, t) {
  if (t.to <= r.viewport.from || t.from >= r.viewport.to)
    return [];
  let i = Math.max(t.from, r.viewport.from), n = Math.min(t.to, r.viewport.to), s = r.textDirection == ce.LTR, o = r.contentDOM, l = o.getBoundingClientRect(), a = ap(r), h = o.querySelector(".cm-line"), c = h && window.getComputedStyle(h), f = l.left + (c ? parseInt(c.paddingLeft) + Math.min(0, parseInt(c.textIndent)) : 0), u = l.right - (c ? parseInt(c.paddingRight) : 0), d = Nl(r, i, 1), p = Nl(r, n, -1), O = d.type == Xe.Text ? d : null, g = p.type == Xe.Text ? p : null;
  if (O && (r.lineWrapping || d.widgetLineBreaks) && (O = Tc(r, i, 1, O)), g && (r.lineWrapping || p.widgetLineBreaks) && (g = Tc(r, n, -1, g)), O && g && O.from == g.from && O.to == g.to)
    return w(k(t.from, t.to, O));
  {
    let S = O ? k(t.from, null, O) : x(d, !1), y = g ? k(null, t.to, g) : x(p, !0), Q = [];
    return (O || d).to < (g || p).from - (O && g ? 1 : 0) || d.widgetLineBreaks > 1 && S.bottom + r.defaultLineHeight / 2 < y.top ? Q.push(b(f, S.bottom, u, y.top)) : S.bottom < y.top && r.elementAtHeight((S.bottom + y.top) / 2).type == Xe.Text && (S.bottom = y.top = (S.bottom + y.top) / 2), w(S).concat(Q).concat(w(y));
  }
  function b(S, y, Q, L) {
    return new hn(e, S - a.left, y - a.top, Q - S, L - y);
  }
  function w({ top: S, bottom: y, horizontal: Q }) {
    let L = [];
    for (let $ = 0; $ < Q.length; $ += 2)
      L.push(b(Q[$], S, Q[$ + 1], y));
    return L;
  }
  function k(S, y, Q) {
    let L = 1e9, $ = -1e9, P = [];
    function T(q, Y, U, be, re) {
      let N = r.coordsAtPos(q, q == Q.to ? -2 : 2), J = r.coordsAtPos(U, U == Q.from ? 2 : -2);
      !N || !J || (L = Math.min(N.top, J.top, L), $ = Math.max(N.bottom, J.bottom, $), re == ce.LTR ? P.push(s && Y ? f : N.left, s && be ? u : J.right) : P.push(!s && be ? f : J.left, !s && Y ? u : N.right));
    }
    let A = S ?? Q.from, I = y ?? Q.to;
    for (let q of r.visibleRanges)
      if (q.to > A && q.from < I)
        for (let Y = Math.max(q.from, A), U = Math.min(q.to, I); ; ) {
          let be = r.state.doc.lineAt(Y);
          for (let re of r.bidiSpans(be)) {
            let N = re.from + be.from, J = re.to + be.from;
            if (N >= U)
              break;
            J > Y && T(Math.max(N, Y), S == null && N <= A, Math.min(J, U), y == null && J >= I, re.dir);
          }
          if (Y = be.to + 1, Y >= U)
            break;
        }
    return P.length == 0 && T(A, S == null, I, y == null, r.textDirection), { top: L, bottom: $, horizontal: P };
  }
  function x(S, y) {
    let Q = l.top + (y ? S.top : S.bottom);
    return { top: Q, bottom: Q, horizontal: [] };
  }
}
function v1(r, e) {
  return r.constructor == e.constructor && r.eq(e);
}
class $1 {
  constructor(e, t) {
    this.view = e, this.layer = t, this.drawn = [], this.scaleX = 1, this.scaleY = 1, this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) }, this.dom = e.scrollDOM.appendChild(document.createElement("div")), this.dom.classList.add("cm-layer"), t.above && this.dom.classList.add("cm-layer-above"), t.class && this.dom.classList.add(t.class), this.scale(), this.dom.setAttribute("aria-hidden", "true"), this.setOrder(e.state), e.requestMeasure(this.measureReq), t.mount && t.mount(this.dom, e);
  }
  update(e) {
    e.startState.facet(ts) != e.state.facet(ts) && this.setOrder(e.state), (this.layer.update(e, this.dom) || e.geometryChanged) && (this.scale(), e.view.requestMeasure(this.measureReq));
  }
  docViewUpdate(e) {
    this.layer.updateOnDocViewUpdate !== !1 && e.requestMeasure(this.measureReq);
  }
  setOrder(e) {
    let t = 0, i = e.facet(ts);
    for (; t < i.length && i[t] != this.layer; )
      t++;
    this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - t);
  }
  measure() {
    return this.layer.markers(this.view);
  }
  scale() {
    let { scaleX: e, scaleY: t } = this.view;
    (e != this.scaleX || t != this.scaleY) && (this.scaleX = e, this.scaleY = t, this.dom.style.transform = `scale(${1 / e}, ${1 / t})`);
  }
  draw(e) {
    if (e.length != this.drawn.length || e.some((t, i) => !v1(t, this.drawn[i]))) {
      let t = this.dom.firstChild, i = 0;
      for (let n of e)
        n.update && t && n.constructor && this.drawn[i].constructor && n.update(t, this.drawn[i]) ? (t = t.nextSibling, i++) : this.dom.insertBefore(n.draw(), t);
      for (; t; ) {
        let n = t.nextSibling;
        t.remove(), t = n;
      }
      this.drawn = e, E.safari && E.safari_version >= 26 && (this.dom.style.display = this.dom.firstChild ? "" : "none");
    }
  }
  destroy() {
    this.layer.destroy && this.layer.destroy(this.dom, this.view), this.dom.remove();
  }
}
const ts = /* @__PURE__ */ R.define();
function hp(r) {
  return [
    ue.define((e) => new $1(e, r)),
    ts.of(r)
  ];
}
const qr = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, {
      cursorBlinkRate: 1200,
      drawRangeCursor: !0
    }, {
      cursorBlinkRate: (e, t) => Math.min(e, t),
      drawRangeCursor: (e, t) => e || t
    });
  }
});
function P1(r = {}) {
  return [
    qr.of(r),
    C1,
    T1,
    A1,
    Ld.of(!0)
  ];
}
function cp(r) {
  return r.startState.facet(qr) != r.state.facet(qr);
}
const C1 = /* @__PURE__ */ hp({
  above: !0,
  markers(r) {
    let { state: e } = r, t = e.facet(qr), i = [];
    for (let n of e.selection.ranges) {
      let s = n == e.selection.main;
      if (n.empty || t.drawRangeCursor) {
        let o = s ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary", l = n.empty ? n : v.cursor(n.head, n.head > n.anchor ? -1 : 1);
        for (let a of hn.forRange(r, o, l))
          i.push(a);
      }
    }
    return i;
  },
  update(r, e) {
    r.transactions.some((i) => i.selection) && (e.style.animationName = e.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink");
    let t = cp(r);
    return t && Ac(r.state, e), r.docChanged || r.selectionSet || t;
  },
  mount(r, e) {
    Ac(e.state, r);
  },
  class: "cm-cursorLayer"
});
function Ac(r, e) {
  e.style.animationDuration = r.facet(qr).cursorBlinkRate + "ms";
}
const T1 = /* @__PURE__ */ hp({
  above: !1,
  markers(r) {
    return r.state.selection.ranges.map((e) => e.empty ? [] : hn.forRange(r, "cm-selectionBackground", e)).reduce((e, t) => e.concat(t));
  },
  update(r, e) {
    return r.docChanged || r.selectionSet || r.viewportChanged || cp(r);
  },
  class: "cm-selectionLayer"
}), A1 = /* @__PURE__ */ Vt.highest(/* @__PURE__ */ D.theme({
  ".cm-line": {
    "& ::selection, &::selection": { backgroundColor: "transparent !important" },
    caretColor: "transparent !important"
  },
  ".cm-content": {
    caretColor: "transparent !important",
    "& :focus": {
      caretColor: "initial !important",
      "&::selection, & ::selection": {
        backgroundColor: "Highlight !important"
      }
    }
  }
})), fp = /* @__PURE__ */ V.define({
  map(r, e) {
    return r == null ? null : e.mapPos(r);
  }
}), kr = /* @__PURE__ */ ge.define({
  create() {
    return null;
  },
  update(r, e) {
    return r != null && (r = e.changes.mapPos(r)), e.effects.reduce((t, i) => i.is(fp) ? i.value : t, r);
  }
}), M1 = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.cursor = null, this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
  }
  update(r) {
    var e;
    let t = r.state.field(kr);
    t == null ? this.cursor != null && ((e = this.cursor) === null || e === void 0 || e.remove(), this.cursor = null) : (this.cursor || (this.cursor = this.view.scrollDOM.appendChild(document.createElement("div")), this.cursor.className = "cm-dropCursor"), (r.startState.field(kr) != t || r.docChanged || r.geometryChanged) && this.view.requestMeasure(this.measureReq));
  }
  readPos() {
    let { view: r } = this, e = r.state.field(kr), t = e != null && r.coordsAtPos(e);
    if (!t)
      return null;
    let i = r.scrollDOM.getBoundingClientRect();
    return {
      left: t.left - i.left + r.scrollDOM.scrollLeft * r.scaleX,
      top: t.top - i.top + r.scrollDOM.scrollTop * r.scaleY,
      height: t.bottom - t.top
    };
  }
  drawCursor(r) {
    if (this.cursor) {
      let { scaleX: e, scaleY: t } = this.view;
      r ? (this.cursor.style.left = r.left / e + "px", this.cursor.style.top = r.top / t + "px", this.cursor.style.height = r.height / t + "px") : this.cursor.style.left = "-100000px";
    }
  }
  destroy() {
    this.cursor && this.cursor.remove();
  }
  setDropPos(r) {
    this.view.state.field(kr) != r && this.view.dispatch({ effects: fp.of(r) });
  }
}, {
  eventObservers: {
    dragover(r) {
      this.setDropPos(this.view.posAtCoords({ x: r.clientX, y: r.clientY }));
    },
    dragleave(r) {
      (r.target == this.view.contentDOM || !this.view.contentDOM.contains(r.relatedTarget)) && this.setDropPos(null);
    },
    dragend() {
      this.setDropPos(null);
    },
    drop() {
      this.setDropPos(null);
    }
  }
});
function Z1() {
  return [kr, M1];
}
function Mc(r, e, t, i, n) {
  e.lastIndex = 0;
  for (let s = r.iterRange(t, i), o = t, l; !s.next().done; o += s.value.length)
    if (!s.lineBreak)
      for (; l = e.exec(s.value); )
        n(o + l.index, l);
}
function X1(r, e) {
  let t = r.visibleRanges;
  if (t.length == 1 && t[0].from == r.viewport.from && t[0].to == r.viewport.to)
    return t;
  let i = [];
  for (let { from: n, to: s } of t)
    n = Math.max(r.state.doc.lineAt(n).from, n - e), s = Math.min(r.state.doc.lineAt(s).to, s + e), i.length && i[i.length - 1].to >= n ? i[i.length - 1].to = s : i.push({ from: n, to: s });
  return i;
}
class R1 {
  /**
  Create a decorator.
  */
  constructor(e) {
    const { regexp: t, decoration: i, decorate: n, boundary: s, maxLength: o = 1e3 } = e;
    if (!t.global)
      throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
    if (this.regexp = t, n)
      this.addMatch = (l, a, h, c) => n(c, h, h + l[0].length, l, a);
    else if (typeof i == "function")
      this.addMatch = (l, a, h, c) => {
        let f = i(l, a, h);
        f && c(h, h + l[0].length, f);
      };
    else if (i)
      this.addMatch = (l, a, h, c) => c(h, h + l[0].length, i);
    else
      throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
    this.boundary = s, this.maxLength = o;
  }
  /**
  Compute the full set of decorations for matches in the given
  view's viewport. You'll want to call this when initializing your
  plugin.
  */
  createDeco(e) {
    let t = new _t(), i = t.add.bind(t);
    for (let { from: n, to: s } of X1(e, this.maxLength))
      Mc(e.state.doc, this.regexp, n, s, (o, l) => this.addMatch(l, e, o, i));
    return t.finish();
  }
  /**
  Update a set of decorations for a view update. `deco` _must_ be
  the set of decorations produced by _this_ `MatchDecorator` for
  the view state before the update.
  */
  updateDeco(e, t) {
    let i = 1e9, n = -1;
    return e.docChanged && e.changes.iterChanges((s, o, l, a) => {
      a >= e.view.viewport.from && l <= e.view.viewport.to && (i = Math.min(l, i), n = Math.max(a, n));
    }), e.viewportMoved || n - i > 1e3 ? this.createDeco(e.view) : n > -1 ? this.updateRange(e.view, t.map(e.changes), i, n) : t;
  }
  updateRange(e, t, i, n) {
    for (let s of e.visibleRanges) {
      let o = Math.max(s.from, i), l = Math.min(s.to, n);
      if (l >= o) {
        let a = e.state.doc.lineAt(o), h = a.to < l ? e.state.doc.lineAt(l) : a, c = Math.max(s.from, a.from), f = Math.min(s.to, h.to);
        if (this.boundary) {
          for (; o > a.from; o--)
            if (this.boundary.test(a.text[o - 1 - a.from])) {
              c = o;
              break;
            }
          for (; l < h.to; l++)
            if (this.boundary.test(h.text[l - h.from])) {
              f = l;
              break;
            }
        }
        let u = [], d, p = (O, g, b) => u.push(b.range(O, g));
        if (a == h)
          for (this.regexp.lastIndex = c - a.from; (d = this.regexp.exec(a.text)) && d.index < f - a.from; )
            this.addMatch(d, e, d.index + a.from, p);
        else
          Mc(e.state.doc, this.regexp, c, f, (O, g) => this.addMatch(g, e, O, p));
        t = t.update({ filterFrom: c, filterTo: f, filter: (O, g) => O < c || g > f, add: u });
      }
    }
    return t;
  }
}
const Hl = /x/.unicode != null ? "gu" : "g", L1 = /* @__PURE__ */ new RegExp(`[\0-\b
--­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF￹-￼]`, Hl), E1 = {
  0: "null",
  7: "bell",
  8: "backspace",
  10: "newline",
  11: "vertical tab",
  13: "carriage return",
  27: "escape",
  8203: "zero width space",
  8204: "zero width non-joiner",
  8205: "zero width joiner",
  8206: "left-to-right mark",
  8207: "right-to-left mark",
  8232: "line separator",
  8237: "left-to-right override",
  8238: "right-to-left override",
  8294: "left-to-right isolate",
  8295: "right-to-left isolate",
  8297: "pop directional isolate",
  8233: "paragraph separator",
  65279: "zero width no-break space",
  65532: "object replacement"
};
let To = null;
function z1() {
  var r;
  if (To == null && typeof document < "u" && document.body) {
    let e = document.body.style;
    To = ((r = e.tabSize) !== null && r !== void 0 ? r : e.MozTabSize) != null;
  }
  return To || !1;
}
const is = /* @__PURE__ */ R.define({
  combine(r) {
    let e = Yt(r, {
      render: null,
      specialChars: L1,
      addSpecialChars: null
    });
    return (e.replaceTabs = !z1()) && (e.specialChars = new RegExp("	|" + e.specialChars.source, Hl)), e.addSpecialChars && (e.specialChars = new RegExp(e.specialChars.source + "|" + e.addSpecialChars.source, Hl)), e;
  }
});
function D1(r = {}) {
  return [is.of(r), _1()];
}
let Zc = null;
function _1() {
  return Zc || (Zc = ue.fromClass(class {
    constructor(r) {
      this.view = r, this.decorations = B.none, this.decorationCache = /* @__PURE__ */ Object.create(null), this.decorator = this.makeDecorator(r.state.facet(is)), this.decorations = this.decorator.createDeco(r);
    }
    makeDecorator(r) {
      return new R1({
        regexp: r.specialChars,
        decoration: (e, t, i) => {
          let { doc: n } = t.state, s = Ee(e[0], 0);
          if (s == 9) {
            let o = n.lineAt(i), l = t.state.tabSize, a = lt(o.text, l, i - o.from);
            return B.replace({
              widget: new q1((l - a % l) * this.view.defaultCharacterWidth / this.view.scaleX)
            });
          }
          return this.decorationCache[s] || (this.decorationCache[s] = B.replace({ widget: new V1(r, s) }));
        },
        boundary: r.replaceTabs ? void 0 : /[^]/
      });
    }
    update(r) {
      let e = r.state.facet(is);
      r.startState.facet(is) != e ? (this.decorator = this.makeDecorator(e), this.decorations = this.decorator.createDeco(r.view)) : this.decorations = this.decorator.updateDeco(r, this.decorations);
    }
  }, {
    decorations: (r) => r.decorations
  }));
}
const B1 = "•";
function I1(r) {
  return r >= 32 ? B1 : r == 10 ? "␤" : String.fromCharCode(9216 + r);
}
class V1 extends di {
  constructor(e, t) {
    super(), this.options = e, this.code = t;
  }
  eq(e) {
    return e.code == this.code;
  }
  toDOM(e) {
    let t = I1(this.code), i = e.state.phrase("Control character") + " " + (E1[this.code] || "0x" + this.code.toString(16)), n = this.options.render && this.options.render(this.code, i, t);
    if (n)
      return n;
    let s = document.createElement("span");
    return s.textContent = t, s.title = i, s.setAttribute("aria-label", i), s.className = "cm-specialChar", s;
  }
  ignoreEvent() {
    return !1;
  }
}
class q1 extends di {
  constructor(e) {
    super(), this.width = e;
  }
  eq(e) {
    return e.width == this.width;
  }
  toDOM() {
    let e = document.createElement("span");
    return e.textContent = "	", e.className = "cm-tab", e.style.width = this.width + "px", e;
  }
  ignoreEvent() {
    return !1;
  }
}
function Y1() {
  return W1;
}
const N1 = /* @__PURE__ */ B.line({ class: "cm-activeLine" }), W1 = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.decorations = this.getDeco(r);
  }
  update(r) {
    (r.docChanged || r.selectionSet) && (this.decorations = this.getDeco(r.view));
  }
  getDeco(r) {
    let e = -1, t = [];
    for (let i of r.state.selection.ranges) {
      let n = r.lineBlockAt(i.head);
      n.from > e && (t.push(N1.range(n.from)), e = n.from);
    }
    return B.set(t);
  }
}, {
  decorations: (r) => r.decorations
}), Kl = 2e3;
function j1(r, e, t) {
  let i = Math.min(e.line, t.line), n = Math.max(e.line, t.line), s = [];
  if (e.off > Kl || t.off > Kl || e.col < 0 || t.col < 0) {
    let o = Math.min(e.off, t.off), l = Math.max(e.off, t.off);
    for (let a = i; a <= n; a++) {
      let h = r.doc.line(a);
      h.length <= l && s.push(v.range(h.from + o, h.to + l));
    }
  } else {
    let o = Math.min(e.col, t.col), l = Math.max(e.col, t.col);
    for (let a = i; a <= n; a++) {
      let h = r.doc.line(a), c = Tl(h.text, o, r.tabSize, !0);
      if (c < 0)
        s.push(v.cursor(h.to));
      else {
        let f = Tl(h.text, l, r.tabSize);
        s.push(v.range(h.from + c, h.from + f));
      }
    }
  }
  return s;
}
function G1(r, e) {
  let t = r.coordsAtPos(r.viewport.from);
  return t ? Math.round(Math.abs((t.left - e) / r.defaultCharacterWidth)) : -1;
}
function Xc(r, e) {
  let t = r.posAtCoords({ x: e.clientX, y: e.clientY }, !1), i = r.state.doc.lineAt(t), n = t - i.from, s = n > Kl ? -1 : n == i.length ? G1(r, e.clientX) : lt(i.text, r.state.tabSize, t - i.from);
  return { line: i.number, col: s, off: n };
}
function U1(r, e) {
  let t = Xc(r, e), i = r.state.selection;
  return t ? {
    update(n) {
      if (n.docChanged) {
        let s = n.changes.mapPos(n.startState.doc.line(t.line).from), o = n.state.doc.lineAt(s);
        t = { line: o.number, col: t.col, off: Math.min(t.off, o.length) }, i = i.map(n.changes);
      }
    },
    get(n, s, o) {
      let l = Xc(r, n);
      if (!l)
        return i;
      let a = j1(r.state, t, l);
      return a.length ? o ? v.create(a.concat(i.ranges)) : v.create(a) : i;
    }
  } : null;
}
function F1(r) {
  let e = ((t) => t.altKey && t.button == 0);
  return D.mouseSelectionStyle.of((t, i) => e(i) ? U1(t, i) : null);
}
const H1 = {
  Alt: [18, (r) => !!r.altKey],
  Control: [17, (r) => !!r.ctrlKey],
  Shift: [16, (r) => !!r.shiftKey],
  Meta: [91, (r) => !!r.metaKey]
}, K1 = { style: "cursor: crosshair" };
function J1(r = {}) {
  let [e, t] = H1[r.key || "Alt"], i = ue.fromClass(class {
    constructor(n) {
      this.view = n, this.isDown = !1;
    }
    set(n) {
      this.isDown != n && (this.isDown = n, this.view.update([]));
    }
  }, {
    eventObservers: {
      keydown(n) {
        this.set(n.keyCode == e || t(n));
      },
      keyup(n) {
        (n.keyCode == e || !t(n)) && this.set(!1);
      },
      mousemove(n) {
        this.set(t(n));
      }
    }
  });
  return [
    i,
    D.contentAttributes.of((n) => {
      var s;
      return !((s = n.plugin(i)) === null || s === void 0) && s.isDown ? K1 : null;
    })
  ];
}
const hr = "-10000px";
class up {
  constructor(e, t, i, n) {
    this.facet = t, this.createTooltipView = i, this.removeTooltipView = n, this.input = e.state.facet(t), this.tooltips = this.input.filter((o) => o);
    let s = null;
    this.tooltipViews = this.tooltips.map((o) => s = i(o, s));
  }
  update(e, t) {
    var i;
    let n = e.state.facet(this.facet), s = n.filter((a) => a);
    if (n === this.input) {
      for (let a of this.tooltipViews)
        a.update && a.update(e);
      return !1;
    }
    let o = [], l = t ? [] : null;
    for (let a = 0; a < s.length; a++) {
      let h = s[a], c = -1;
      if (h) {
        for (let f = 0; f < this.tooltips.length; f++) {
          let u = this.tooltips[f];
          u && u.create == h.create && (c = f);
        }
        if (c < 0)
          o[a] = this.createTooltipView(h, a ? o[a - 1] : null), l && (l[a] = !!h.above);
        else {
          let f = o[a] = this.tooltipViews[c];
          l && (l[a] = t[c]), f.update && f.update(e);
        }
      }
    }
    for (let a of this.tooltipViews)
      o.indexOf(a) < 0 && (this.removeTooltipView(a), (i = a.destroy) === null || i === void 0 || i.call(a));
    return t && (l.forEach((a, h) => t[h] = a), t.length = l.length), this.input = n, this.tooltips = s, this.tooltipViews = o, !0;
  }
}
function eb(r) {
  let e = r.dom.ownerDocument.documentElement;
  return { top: 0, left: 0, bottom: e.clientHeight, right: e.clientWidth };
}
const Ao = /* @__PURE__ */ R.define({
  combine: (r) => {
    var e, t, i;
    return {
      position: E.ios ? "absolute" : ((e = r.find((n) => n.position)) === null || e === void 0 ? void 0 : e.position) || "fixed",
      parent: ((t = r.find((n) => n.parent)) === null || t === void 0 ? void 0 : t.parent) || null,
      tooltipSpace: ((i = r.find((n) => n.tooltipSpace)) === null || i === void 0 ? void 0 : i.tooltipSpace) || eb
    };
  }
}), Rc = /* @__PURE__ */ new WeakMap(), Ha = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.above = [], this.inView = !0, this.madeAbsolute = !1, this.lastTransaction = 0, this.measureTimeout = -1;
    let e = r.state.facet(Ao);
    this.position = e.position, this.parent = e.parent, this.classes = r.themeClasses, this.createContainer(), this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this }, this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null, this.manager = new up(r, Ka, (t, i) => this.createTooltip(t, i), (t) => {
      this.resizeObserver && this.resizeObserver.unobserve(t.dom), t.dom.remove();
    }), this.above = this.manager.tooltips.map((t) => !!t.above), this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver((t) => {
      Date.now() > this.lastTransaction - 50 && t.length > 0 && t[t.length - 1].intersectionRatio < 1 && this.measureSoon();
    }, { threshold: [1] }) : null, this.observeIntersection(), r.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this)), this.maybeMeasure();
  }
  createContainer() {
    this.parent ? (this.container = document.createElement("div"), this.container.style.position = "relative", this.container.className = this.view.themeClasses, this.parent.appendChild(this.container)) : this.container = this.view.dom;
  }
  observeIntersection() {
    if (this.intersectionObserver) {
      this.intersectionObserver.disconnect();
      for (let r of this.manager.tooltipViews)
        this.intersectionObserver.observe(r.dom);
    }
  }
  measureSoon() {
    this.measureTimeout < 0 && (this.measureTimeout = setTimeout(() => {
      this.measureTimeout = -1, this.maybeMeasure();
    }, 50));
  }
  update(r) {
    r.transactions.length && (this.lastTransaction = Date.now());
    let e = this.manager.update(r, this.above);
    e && this.observeIntersection();
    let t = e || r.geometryChanged, i = r.state.facet(Ao);
    if (i.position != this.position && !this.madeAbsolute) {
      this.position = i.position;
      for (let n of this.manager.tooltipViews)
        n.dom.style.position = this.position;
      t = !0;
    }
    if (i.parent != this.parent) {
      this.parent && this.container.remove(), this.parent = i.parent, this.createContainer();
      for (let n of this.manager.tooltipViews)
        this.container.appendChild(n.dom);
      t = !0;
    } else this.parent && this.view.themeClasses != this.classes && (this.classes = this.container.className = this.view.themeClasses);
    t && this.maybeMeasure();
  }
  createTooltip(r, e) {
    let t = r.create(this.view), i = e ? e.dom : null;
    if (t.dom.classList.add("cm-tooltip"), r.arrow && !t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
      let n = document.createElement("div");
      n.className = "cm-tooltip-arrow", t.dom.appendChild(n);
    }
    return t.dom.style.position = this.position, t.dom.style.top = hr, t.dom.style.left = "0px", this.container.insertBefore(t.dom, i), t.mount && t.mount(this.view), this.resizeObserver && this.resizeObserver.observe(t.dom), t;
  }
  destroy() {
    var r, e, t;
    this.view.win.removeEventListener("resize", this.measureSoon);
    for (let i of this.manager.tooltipViews)
      i.dom.remove(), (r = i.destroy) === null || r === void 0 || r.call(i);
    this.parent && this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), (t = this.intersectionObserver) === null || t === void 0 || t.disconnect(), clearTimeout(this.measureTimeout);
  }
  readMeasure() {
    let r = 1, e = 1, t = !1;
    if (this.position == "fixed" && this.manager.tooltipViews.length) {
      let { dom: s } = this.manager.tooltipViews[0];
      if (E.gecko)
        t = s.offsetParent != this.container.ownerDocument.body;
      else if (s.style.top == hr && s.style.left == "0px") {
        let o = s.getBoundingClientRect();
        t = Math.abs(o.top + 1e4) > 1 || Math.abs(o.left) > 1;
      }
    }
    if (t || this.position == "absolute")
      if (this.parent) {
        let s = this.parent.getBoundingClientRect();
        s.width && s.height && (r = s.width / this.parent.offsetWidth, e = s.height / this.parent.offsetHeight);
      } else
        ({ scaleX: r, scaleY: e } = this.view.viewState);
    let i = this.view.scrollDOM.getBoundingClientRect(), n = ja(this.view);
    return {
      visible: {
        left: i.left + n.left,
        top: i.top + n.top,
        right: i.right - n.right,
        bottom: i.bottom - n.bottom
      },
      parent: this.parent ? this.container.getBoundingClientRect() : this.view.dom.getBoundingClientRect(),
      pos: this.manager.tooltips.map((s, o) => {
        let l = this.manager.tooltipViews[o];
        return l.getCoords ? l.getCoords(s.pos) : this.view.coordsAtPos(s.pos);
      }),
      size: this.manager.tooltipViews.map(({ dom: s }) => s.getBoundingClientRect()),
      space: this.view.state.facet(Ao).tooltipSpace(this.view),
      scaleX: r,
      scaleY: e,
      makeAbsolute: t
    };
  }
  writeMeasure(r) {
    var e;
    if (r.makeAbsolute) {
      this.madeAbsolute = !0, this.position = "absolute";
      for (let l of this.manager.tooltipViews)
        l.dom.style.position = "absolute";
    }
    let { visible: t, space: i, scaleX: n, scaleY: s } = r, o = [];
    for (let l = 0; l < this.manager.tooltips.length; l++) {
      let a = this.manager.tooltips[l], h = this.manager.tooltipViews[l], { dom: c } = h, f = r.pos[l], u = r.size[l];
      if (!f || a.clip !== !1 && (f.bottom <= Math.max(t.top, i.top) || f.top >= Math.min(t.bottom, i.bottom) || f.right < Math.max(t.left, i.left) - 0.1 || f.left > Math.min(t.right, i.right) + 0.1)) {
        c.style.top = hr;
        continue;
      }
      let d = a.arrow ? h.dom.querySelector(".cm-tooltip-arrow") : null, p = d ? 7 : 0, O = u.right - u.left, g = (e = Rc.get(h)) !== null && e !== void 0 ? e : u.bottom - u.top, b = h.offset || ib, w = this.view.textDirection == ce.LTR, k = u.width > i.right - i.left ? w ? i.left : i.right - u.width : w ? Math.max(i.left, Math.min(f.left - (d ? 14 : 0) + b.x, i.right - O)) : Math.min(Math.max(i.left, f.left - O + (d ? 14 : 0) - b.x), i.right - O), x = this.above[l];
      !a.strictSide && (x ? f.top - g - p - b.y < i.top : f.bottom + g + p + b.y > i.bottom) && x == i.bottom - f.bottom > f.top - i.top && (x = this.above[l] = !x);
      let S = (x ? f.top - i.top : i.bottom - f.bottom) - p;
      if (S < g && h.resize !== !1) {
        if (S < this.view.defaultLineHeight) {
          c.style.top = hr;
          continue;
        }
        Rc.set(h, g), c.style.height = (g = S) / s + "px";
      } else c.style.height && (c.style.height = "");
      let y = x ? f.top - g - p - b.y : f.bottom + p + b.y, Q = k + O;
      if (h.overlap !== !0)
        for (let L of o)
          L.left < Q && L.right > k && L.top < y + g && L.bottom > y && (y = x ? L.top - g - 2 - p : L.bottom + p + 2);
      if (this.position == "absolute" ? (c.style.top = (y - r.parent.top) / s + "px", Lc(c, (k - r.parent.left) / n)) : (c.style.top = y / s + "px", Lc(c, k / n)), d) {
        let L = f.left + (w ? b.x : -b.x) - (k + 14 - 7);
        d.style.left = L / n + "px";
      }
      h.overlap !== !0 && o.push({ left: k, top: y, right: Q, bottom: y + g }), c.classList.toggle("cm-tooltip-above", x), c.classList.toggle("cm-tooltip-below", !x), h.positioned && h.positioned(r.space);
    }
  }
  maybeMeasure() {
    if (this.manager.tooltips.length && (this.view.inView && this.view.requestMeasure(this.measureReq), this.inView != this.view.inView && (this.inView = this.view.inView, !this.inView)))
      for (let r of this.manager.tooltipViews)
        r.dom.style.top = hr;
  }
}, {
  eventObservers: {
    scroll() {
      this.maybeMeasure();
    }
  }
});
function Lc(r, e) {
  let t = parseInt(r.style.left, 10);
  (isNaN(t) || Math.abs(e - t) > 1) && (r.style.left = e + "px");
}
const tb = /* @__PURE__ */ D.baseTheme({
  ".cm-tooltip": {
    zIndex: 500,
    boxSizing: "border-box"
  },
  "&light .cm-tooltip": {
    border: "1px solid #bbb",
    backgroundColor: "#f5f5f5"
  },
  "&light .cm-tooltip-section:not(:first-child)": {
    borderTop: "1px solid #bbb"
  },
  "&dark .cm-tooltip": {
    backgroundColor: "#333338",
    color: "white"
  },
  ".cm-tooltip-arrow": {
    height: "7px",
    width: "14px",
    position: "absolute",
    zIndex: -1,
    overflow: "hidden",
    "&:before, &:after": {
      content: "''",
      position: "absolute",
      width: 0,
      height: 0,
      borderLeft: "7px solid transparent",
      borderRight: "7px solid transparent"
    },
    ".cm-tooltip-above &": {
      bottom: "-7px",
      "&:before": {
        borderTop: "7px solid #bbb"
      },
      "&:after": {
        borderTop: "7px solid #f5f5f5",
        bottom: "1px"
      }
    },
    ".cm-tooltip-below &": {
      top: "-7px",
      "&:before": {
        borderBottom: "7px solid #bbb"
      },
      "&:after": {
        borderBottom: "7px solid #f5f5f5",
        top: "1px"
      }
    }
  },
  "&dark .cm-tooltip .cm-tooltip-arrow": {
    "&:before": {
      borderTopColor: "#333338",
      borderBottomColor: "#333338"
    },
    "&:after": {
      borderTopColor: "transparent",
      borderBottomColor: "transparent"
    }
  }
}), ib = { x: 0, y: 0 }, Ka = /* @__PURE__ */ R.define({
  enables: [Ha, tb]
}), ks = /* @__PURE__ */ R.define({
  combine: (r) => r.reduce((e, t) => e.concat(t), [])
});
class no {
  // Needs to be static so that host tooltip instances always match
  static create(e) {
    return new no(e);
  }
  constructor(e) {
    this.view = e, this.mounted = !1, this.dom = document.createElement("div"), this.dom.classList.add("cm-tooltip-hover"), this.manager = new up(e, ks, (t, i) => this.createHostedView(t, i), (t) => t.dom.remove());
  }
  createHostedView(e, t) {
    let i = e.create(this.view);
    return i.dom.classList.add("cm-tooltip-section"), this.dom.insertBefore(i.dom, t ? t.dom.nextSibling : this.dom.firstChild), this.mounted && i.mount && i.mount(this.view), i;
  }
  mount(e) {
    for (let t of this.manager.tooltipViews)
      t.mount && t.mount(e);
    this.mounted = !0;
  }
  positioned(e) {
    for (let t of this.manager.tooltipViews)
      t.positioned && t.positioned(e);
  }
  update(e) {
    this.manager.update(e);
  }
  destroy() {
    var e;
    for (let t of this.manager.tooltipViews)
      (e = t.destroy) === null || e === void 0 || e.call(t);
  }
  passProp(e) {
    let t;
    for (let i of this.manager.tooltipViews) {
      let n = i[e];
      if (n !== void 0) {
        if (t === void 0)
          t = n;
        else if (t !== n)
          return;
      }
    }
    return t;
  }
  get offset() {
    return this.passProp("offset");
  }
  get getCoords() {
    return this.passProp("getCoords");
  }
  get overlap() {
    return this.passProp("overlap");
  }
  get resize() {
    return this.passProp("resize");
  }
}
const rb = /* @__PURE__ */ Ka.compute([ks], (r) => {
  let e = r.facet(ks);
  return e.length === 0 ? null : {
    pos: Math.min(...e.map((t) => t.pos)),
    end: Math.max(...e.map((t) => {
      var i;
      return (i = t.end) !== null && i !== void 0 ? i : t.pos;
    })),
    create: no.create,
    above: e[0].above,
    arrow: e.some((t) => t.arrow)
  };
});
class nb {
  constructor(e, t, i, n, s) {
    this.view = e, this.source = t, this.field = i, this.setHover = n, this.hoverTime = s, this.hoverTimeout = -1, this.restartTimeout = -1, this.pending = null, this.lastMove = { x: 0, y: 0, target: e.dom, time: 0 }, this.checkHover = this.checkHover.bind(this), e.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this)), e.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
  }
  update() {
    this.pending && (this.pending = null, clearTimeout(this.restartTimeout), this.restartTimeout = setTimeout(() => this.startHover(), 20));
  }
  get active() {
    return this.view.state.field(this.field);
  }
  checkHover() {
    if (this.hoverTimeout = -1, this.active.length)
      return;
    let e = Date.now() - this.lastMove.time;
    e < this.hoverTime ? this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - e) : this.startHover();
  }
  startHover() {
    clearTimeout(this.restartTimeout);
    let { view: e, lastMove: t } = this, i = e.docView.nearest(t.target);
    if (!i)
      return;
    let n, s = 1;
    if (i instanceof ii)
      n = i.posAtStart;
    else {
      if (n = e.posAtCoords(t), n == null)
        return;
      let l = e.coordsAtPos(n);
      if (!l || t.y < l.top || t.y > l.bottom || t.x < l.left - e.defaultCharacterWidth || t.x > l.right + e.defaultCharacterWidth)
        return;
      let a = e.bidiSpans(e.state.doc.lineAt(n)).find((c) => c.from <= n && c.to >= n), h = a && a.dir == ce.RTL ? -1 : 1;
      s = t.x < l.left ? -h : h;
    }
    let o = this.source(e, n, s);
    if (o?.then) {
      let l = this.pending = { pos: n };
      o.then((a) => {
        this.pending == l && (this.pending = null, a && !(Array.isArray(a) && !a.length) && e.dispatch({ effects: this.setHover.of(Array.isArray(a) ? a : [a]) }));
      }, (a) => Qe(e.state, a, "hover tooltip"));
    } else o && !(Array.isArray(o) && !o.length) && e.dispatch({ effects: this.setHover.of(Array.isArray(o) ? o : [o]) });
  }
  get tooltip() {
    let e = this.view.plugin(Ha), t = e ? e.manager.tooltips.findIndex((i) => i.create == no.create) : -1;
    return t > -1 ? e.manager.tooltipViews[t] : null;
  }
  mousemove(e) {
    var t, i;
    this.lastMove = { x: e.clientX, y: e.clientY, target: e.target, time: Date.now() }, this.hoverTimeout < 0 && (this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime));
    let { active: n, tooltip: s } = this;
    if (n.length && s && !sb(s.dom, e) || this.pending) {
      let { pos: o } = n[0] || this.pending, l = (i = (t = n[0]) === null || t === void 0 ? void 0 : t.end) !== null && i !== void 0 ? i : o;
      (o == l ? this.view.posAtCoords(this.lastMove) != o : !ob(this.view, o, l, e.clientX, e.clientY)) && (this.view.dispatch({ effects: this.setHover.of([]) }), this.pending = null);
    }
  }
  mouseleave(e) {
    clearTimeout(this.hoverTimeout), this.hoverTimeout = -1;
    let { active: t } = this;
    if (t.length) {
      let { tooltip: i } = this;
      i && i.dom.contains(e.relatedTarget) ? this.watchTooltipLeave(i.dom) : this.view.dispatch({ effects: this.setHover.of([]) });
    }
  }
  watchTooltipLeave(e) {
    let t = (i) => {
      e.removeEventListener("mouseleave", t), this.active.length && !this.view.dom.contains(i.relatedTarget) && this.view.dispatch({ effects: this.setHover.of([]) });
    };
    e.addEventListener("mouseleave", t);
  }
  destroy() {
    clearTimeout(this.hoverTimeout), this.view.dom.removeEventListener("mouseleave", this.mouseleave), this.view.dom.removeEventListener("mousemove", this.mousemove);
  }
}
const An = 4;
function sb(r, e) {
  let { left: t, right: i, top: n, bottom: s } = r.getBoundingClientRect(), o;
  if (o = r.querySelector(".cm-tooltip-arrow")) {
    let l = o.getBoundingClientRect();
    n = Math.min(l.top, n), s = Math.max(l.bottom, s);
  }
  return e.clientX >= t - An && e.clientX <= i + An && e.clientY >= n - An && e.clientY <= s + An;
}
function ob(r, e, t, i, n, s) {
  let o = r.scrollDOM.getBoundingClientRect(), l = r.documentTop + r.documentPadding.top + r.contentHeight;
  if (o.left > i || o.right < i || o.top > n || Math.min(o.bottom, l) < n)
    return !1;
  let a = r.posAtCoords({ x: i, y: n }, !1);
  return a >= e && a <= t;
}
function lb(r, e = {}) {
  let t = V.define(), i = ge.define({
    create() {
      return [];
    },
    update(n, s) {
      if (n.length && (e.hideOnChange && (s.docChanged || s.selection) ? n = [] : e.hideOn && (n = n.filter((o) => !e.hideOn(s, o))), s.docChanged)) {
        let o = [];
        for (let l of n) {
          let a = s.changes.mapPos(l.pos, -1, ke.TrackDel);
          if (a != null) {
            let h = Object.assign(/* @__PURE__ */ Object.create(null), l);
            h.pos = a, h.end != null && (h.end = s.changes.mapPos(h.end)), o.push(h);
          }
        }
        n = o;
      }
      for (let o of s.effects)
        o.is(t) && (n = o.value), o.is(hb) && (n = []);
      return n;
    },
    provide: (n) => ks.from(n)
  });
  return {
    active: i,
    extension: [
      i,
      ue.define((n) => new nb(
        n,
        r,
        i,
        t,
        e.hoverTime || 300
        /* Hover.Time */
      )),
      rb
    ]
  };
}
function ab(r, e) {
  let t = r.plugin(Ha);
  if (!t)
    return null;
  let i = t.manager.tooltips.indexOf(e);
  return i < 0 ? null : t.manager.tooltipViews[i];
}
const hb = /* @__PURE__ */ V.define(), Ec = /* @__PURE__ */ R.define({
  combine(r) {
    let e, t;
    for (let i of r)
      e = e || i.topContainer, t = t || i.bottomContainer;
    return { topContainer: e, bottomContainer: t };
  }
});
function Yr(r, e) {
  let t = r.plugin(dp), i = t ? t.specs.indexOf(e) : -1;
  return i > -1 ? t.panels[i] : null;
}
const dp = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.input = r.state.facet(Nr), this.specs = this.input.filter((t) => t), this.panels = this.specs.map((t) => t(r));
    let e = r.state.facet(Ec);
    this.top = new Mn(r, !0, e.topContainer), this.bottom = new Mn(r, !1, e.bottomContainer), this.top.sync(this.panels.filter((t) => t.top)), this.bottom.sync(this.panels.filter((t) => !t.top));
    for (let t of this.panels)
      t.dom.classList.add("cm-panel"), t.mount && t.mount();
  }
  update(r) {
    let e = r.state.facet(Ec);
    this.top.container != e.topContainer && (this.top.sync([]), this.top = new Mn(r.view, !0, e.topContainer)), this.bottom.container != e.bottomContainer && (this.bottom.sync([]), this.bottom = new Mn(r.view, !1, e.bottomContainer)), this.top.syncClasses(), this.bottom.syncClasses();
    let t = r.state.facet(Nr);
    if (t != this.input) {
      let i = t.filter((a) => a), n = [], s = [], o = [], l = [];
      for (let a of i) {
        let h = this.specs.indexOf(a), c;
        h < 0 ? (c = a(r.view), l.push(c)) : (c = this.panels[h], c.update && c.update(r)), n.push(c), (c.top ? s : o).push(c);
      }
      this.specs = i, this.panels = n, this.top.sync(s), this.bottom.sync(o);
      for (let a of l)
        a.dom.classList.add("cm-panel"), a.mount && a.mount();
    } else
      for (let i of this.panels)
        i.update && i.update(r);
  }
  destroy() {
    this.top.sync([]), this.bottom.sync([]);
  }
}, {
  provide: (r) => D.scrollMargins.of((e) => {
    let t = e.plugin(r);
    return t && { top: t.top.scrollMargin(), bottom: t.bottom.scrollMargin() };
  })
});
class Mn {
  constructor(e, t, i) {
    this.view = e, this.top = t, this.container = i, this.dom = void 0, this.classes = "", this.panels = [], this.syncClasses();
  }
  sync(e) {
    for (let t of this.panels)
      t.destroy && e.indexOf(t) < 0 && t.destroy();
    this.panels = e, this.syncDOM();
  }
  syncDOM() {
    if (this.panels.length == 0) {
      this.dom && (this.dom.remove(), this.dom = void 0);
      return;
    }
    if (!this.dom) {
      this.dom = document.createElement("div"), this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom", this.dom.style[this.top ? "top" : "bottom"] = "0";
      let t = this.container || this.view.dom;
      t.insertBefore(this.dom, this.top ? t.firstChild : null);
    }
    let e = this.dom.firstChild;
    for (let t of this.panels)
      if (t.dom.parentNode == this.dom) {
        for (; e != t.dom; )
          e = zc(e);
        e = e.nextSibling;
      } else
        this.dom.insertBefore(t.dom, e);
    for (; e; )
      e = zc(e);
  }
  scrollMargin() {
    return !this.dom || this.container ? 0 : Math.max(0, this.top ? this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) : Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
  }
  syncClasses() {
    if (!(!this.container || this.classes == this.view.themeClasses)) {
      for (let e of this.classes.split(" "))
        e && this.container.classList.remove(e);
      for (let e of (this.classes = this.view.themeClasses).split(" "))
        e && this.container.classList.add(e);
    }
  }
}
function zc(r) {
  let e = r.nextSibling;
  return r.remove(), e;
}
const Nr = /* @__PURE__ */ R.define({
  enables: dp
});
class It extends oi {
  /**
  @internal
  */
  compare(e) {
    return this == e || this.constructor == e.constructor && this.eq(e);
  }
  /**
  Compare this marker to another marker of the same type.
  */
  eq(e) {
    return !1;
  }
  /**
  Called if the marker has a `toDOM` method and its representation
  was removed from a gutter.
  */
  destroy(e) {
  }
}
It.prototype.elementClass = "";
It.prototype.toDOM = void 0;
It.prototype.mapMode = ke.TrackBefore;
It.prototype.startSide = It.prototype.endSide = -1;
It.prototype.point = !0;
const rs = /* @__PURE__ */ R.define(), cb = /* @__PURE__ */ R.define(), fb = {
  class: "",
  renderEmptyElements: !1,
  elementStyle: "",
  markers: () => H.empty,
  lineMarker: () => null,
  widgetMarker: () => null,
  lineMarkerChange: null,
  initialSpacer: null,
  updateSpacer: null,
  domEventHandlers: {},
  side: "before"
}, Zr = /* @__PURE__ */ R.define();
function ub(r) {
  return [pp(), Zr.of({ ...fb, ...r })];
}
const Dc = /* @__PURE__ */ R.define({
  combine: (r) => r.some((e) => e)
});
function pp(r) {
  return [
    db
  ];
}
const db = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.domAfter = null, this.prevViewport = r.viewport, this.dom = document.createElement("div"), this.dom.className = "cm-gutters cm-gutters-before", this.dom.setAttribute("aria-hidden", "true"), this.dom.style.minHeight = this.view.contentHeight / this.view.scaleY + "px", this.gutters = r.state.facet(Zr).map((e) => new Bc(r, e)), this.fixed = !r.state.facet(Dc);
    for (let e of this.gutters)
      e.config.side == "after" ? this.getDOMAfter().appendChild(e.dom) : this.dom.appendChild(e.dom);
    this.fixed && (this.dom.style.position = "sticky"), this.syncGutters(!1), r.scrollDOM.insertBefore(this.dom, r.contentDOM);
  }
  getDOMAfter() {
    return this.domAfter || (this.domAfter = document.createElement("div"), this.domAfter.className = "cm-gutters cm-gutters-after", this.domAfter.setAttribute("aria-hidden", "true"), this.domAfter.style.minHeight = this.view.contentHeight / this.view.scaleY + "px", this.domAfter.style.position = this.fixed ? "sticky" : "", this.view.scrollDOM.appendChild(this.domAfter)), this.domAfter;
  }
  update(r) {
    if (this.updateGutters(r)) {
      let e = this.prevViewport, t = r.view.viewport, i = Math.min(e.to, t.to) - Math.max(e.from, t.from);
      this.syncGutters(i < (t.to - t.from) * 0.8);
    }
    if (r.geometryChanged) {
      let e = this.view.contentHeight / this.view.scaleY + "px";
      this.dom.style.minHeight = e, this.domAfter && (this.domAfter.style.minHeight = e);
    }
    this.view.state.facet(Dc) != !this.fixed && (this.fixed = !this.fixed, this.dom.style.position = this.fixed ? "sticky" : "", this.domAfter && (this.domAfter.style.position = this.fixed ? "sticky" : "")), this.prevViewport = r.view.viewport;
  }
  syncGutters(r) {
    let e = this.dom.nextSibling;
    r && (this.dom.remove(), this.domAfter && this.domAfter.remove());
    let t = H.iter(this.view.state.facet(rs), this.view.viewport.from), i = [], n = this.gutters.map((s) => new pb(s, this.view.viewport, -this.view.documentPadding.top));
    for (let s of this.view.viewportLineBlocks)
      if (i.length && (i = []), Array.isArray(s.type)) {
        let o = !0;
        for (let l of s.type)
          if (l.type == Xe.Text && o) {
            Jl(t, i, l.from);
            for (let a of n)
              a.line(this.view, l, i);
            o = !1;
          } else if (l.widget)
            for (let a of n)
              a.widget(this.view, l);
      } else if (s.type == Xe.Text) {
        Jl(t, i, s.from);
        for (let o of n)
          o.line(this.view, s, i);
      } else if (s.widget)
        for (let o of n)
          o.widget(this.view, s);
    for (let s of n)
      s.finish();
    r && (this.view.scrollDOM.insertBefore(this.dom, e), this.domAfter && this.view.scrollDOM.appendChild(this.domAfter));
  }
  updateGutters(r) {
    let e = r.startState.facet(Zr), t = r.state.facet(Zr), i = r.docChanged || r.heightChanged || r.viewportChanged || !H.eq(r.startState.facet(rs), r.state.facet(rs), r.view.viewport.from, r.view.viewport.to);
    if (e == t)
      for (let n of this.gutters)
        n.update(r) && (i = !0);
    else {
      i = !0;
      let n = [];
      for (let s of t) {
        let o = e.indexOf(s);
        o < 0 ? n.push(new Bc(this.view, s)) : (this.gutters[o].update(r), n.push(this.gutters[o]));
      }
      for (let s of this.gutters)
        s.dom.remove(), n.indexOf(s) < 0 && s.destroy();
      for (let s of n)
        s.config.side == "after" ? this.getDOMAfter().appendChild(s.dom) : this.dom.appendChild(s.dom);
      this.gutters = n;
    }
    return i;
  }
  destroy() {
    for (let r of this.gutters)
      r.destroy();
    this.dom.remove(), this.domAfter && this.domAfter.remove();
  }
}, {
  provide: (r) => D.scrollMargins.of((e) => {
    let t = e.plugin(r);
    if (!t || t.gutters.length == 0 || !t.fixed)
      return null;
    let i = t.dom.offsetWidth * e.scaleX, n = t.domAfter ? t.domAfter.offsetWidth * e.scaleX : 0;
    return e.textDirection == ce.LTR ? { left: i, right: n } : { right: i, left: n };
  })
});
function _c(r) {
  return Array.isArray(r) ? r : [r];
}
function Jl(r, e, t) {
  for (; r.value && r.from <= t; )
    r.from == t && e.push(r.value), r.next();
}
class pb {
  constructor(e, t, i) {
    this.gutter = e, this.height = i, this.i = 0, this.cursor = H.iter(e.markers, t.from);
  }
  addElement(e, t, i) {
    let { gutter: n } = this, s = (t.top - this.height) / e.scaleY, o = t.height / e.scaleY;
    if (this.i == n.elements.length) {
      let l = new Op(e, o, s, i);
      n.elements.push(l), n.dom.appendChild(l.dom);
    } else
      n.elements[this.i].update(e, o, s, i);
    this.height = t.bottom, this.i++;
  }
  line(e, t, i) {
    let n = [];
    Jl(this.cursor, n, t.from), i.length && (n = n.concat(i));
    let s = this.gutter.config.lineMarker(e, t, n);
    s && n.unshift(s);
    let o = this.gutter;
    n.length == 0 && !o.config.renderEmptyElements || this.addElement(e, t, n);
  }
  widget(e, t) {
    let i = this.gutter.config.widgetMarker(e, t.widget, t), n = i ? [i] : null;
    for (let s of e.state.facet(cb)) {
      let o = s(e, t.widget, t);
      o && (n || (n = [])).push(o);
    }
    n && this.addElement(e, t, n);
  }
  finish() {
    let e = this.gutter;
    for (; e.elements.length > this.i; ) {
      let t = e.elements.pop();
      e.dom.removeChild(t.dom), t.destroy();
    }
  }
}
class Bc {
  constructor(e, t) {
    this.view = e, this.config = t, this.elements = [], this.spacer = null, this.dom = document.createElement("div"), this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
    for (let i in t.domEventHandlers)
      this.dom.addEventListener(i, (n) => {
        let s = n.target, o;
        if (s != this.dom && this.dom.contains(s)) {
          for (; s.parentNode != this.dom; )
            s = s.parentNode;
          let a = s.getBoundingClientRect();
          o = (a.top + a.bottom) / 2;
        } else
          o = n.clientY;
        let l = e.lineBlockAtHeight(o - e.documentTop);
        t.domEventHandlers[i](e, l, n) && n.preventDefault();
      });
    this.markers = _c(t.markers(e)), t.initialSpacer && (this.spacer = new Op(e, 0, 0, [t.initialSpacer(e)]), this.dom.appendChild(this.spacer.dom), this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none");
  }
  update(e) {
    let t = this.markers;
    if (this.markers = _c(this.config.markers(e.view)), this.spacer && this.config.updateSpacer) {
      let n = this.config.updateSpacer(this.spacer.markers[0], e);
      n != this.spacer.markers[0] && this.spacer.update(e.view, 0, 0, [n]);
    }
    let i = e.view.viewport;
    return !H.eq(this.markers, t, i.from, i.to) || (this.config.lineMarkerChange ? this.config.lineMarkerChange(e) : !1);
  }
  destroy() {
    for (let e of this.elements)
      e.destroy();
  }
}
class Op {
  constructor(e, t, i, n) {
    this.height = -1, this.above = 0, this.markers = [], this.dom = document.createElement("div"), this.dom.className = "cm-gutterElement", this.update(e, t, i, n);
  }
  update(e, t, i, n) {
    this.height != t && (this.height = t, this.dom.style.height = t + "px"), this.above != i && (this.dom.style.marginTop = (this.above = i) ? i + "px" : ""), Ob(this.markers, n) || this.setMarkers(e, n);
  }
  setMarkers(e, t) {
    let i = "cm-gutterElement", n = this.dom.firstChild;
    for (let s = 0, o = 0; ; ) {
      let l = o, a = s < t.length ? t[s++] : null, h = !1;
      if (a) {
        let c = a.elementClass;
        c && (i += " " + c);
        for (let f = o; f < this.markers.length; f++)
          if (this.markers[f].compare(a)) {
            l = f, h = !0;
            break;
          }
      } else
        l = this.markers.length;
      for (; o < l; ) {
        let c = this.markers[o++];
        if (c.toDOM) {
          c.destroy(n);
          let f = n.nextSibling;
          n.remove(), n = f;
        }
      }
      if (!a)
        break;
      a.toDOM && (h ? n = n.nextSibling : this.dom.insertBefore(a.toDOM(e), n)), h && o++;
    }
    this.dom.className = i, this.markers = t;
  }
  destroy() {
    this.setMarkers(null, []);
  }
}
function Ob(r, e) {
  if (r.length != e.length)
    return !1;
  for (let t = 0; t < r.length; t++)
    if (!r[t].compare(e[t]))
      return !1;
  return !0;
}
const mb = /* @__PURE__ */ R.define(), gb = /* @__PURE__ */ R.define(), Ri = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, { formatNumber: String, domEventHandlers: {} }, {
      domEventHandlers(e, t) {
        let i = Object.assign({}, e);
        for (let n in t) {
          let s = i[n], o = t[n];
          i[n] = s ? (l, a, h) => s(l, a, h) || o(l, a, h) : o;
        }
        return i;
      }
    });
  }
});
class Mo extends It {
  constructor(e) {
    super(), this.number = e;
  }
  eq(e) {
    return this.number == e.number;
  }
  toDOM() {
    return document.createTextNode(this.number);
  }
}
function Zo(r, e) {
  return r.state.facet(Ri).formatNumber(e, r.state);
}
const bb = /* @__PURE__ */ Zr.compute([Ri], (r) => ({
  class: "cm-lineNumbers",
  renderEmptyElements: !1,
  markers(e) {
    return e.state.facet(mb);
  },
  lineMarker(e, t, i) {
    return i.some((n) => n.toDOM) ? null : new Mo(Zo(e, e.state.doc.lineAt(t.from).number));
  },
  widgetMarker: (e, t, i) => {
    for (let n of e.state.facet(gb)) {
      let s = n(e, t, i);
      if (s)
        return s;
    }
    return null;
  },
  lineMarkerChange: (e) => e.startState.facet(Ri) != e.state.facet(Ri),
  initialSpacer(e) {
    return new Mo(Zo(e, Ic(e.state.doc.lines)));
  },
  updateSpacer(e, t) {
    let i = Zo(t.view, Ic(t.view.state.doc.lines));
    return i == e.number ? e : new Mo(i);
  },
  domEventHandlers: r.facet(Ri).domEventHandlers,
  side: "before"
}));
function yb(r = {}) {
  return [
    Ri.of(r),
    pp(),
    bb
  ];
}
function Ic(r) {
  let e = 9;
  for (; e < r; )
    e = e * 10 + 9;
  return e;
}
const Sb = /* @__PURE__ */ new class extends It {
  constructor() {
    super(...arguments), this.elementClass = "cm-activeLineGutter";
  }
}(), wb = /* @__PURE__ */ rs.compute(["selection"], (r) => {
  let e = [], t = -1;
  for (let i of r.selection.ranges) {
    let n = r.doc.lineAt(i.head).from;
    n > t && (t = n, e.push(Sb.range(n)));
  }
  return H.of(e);
});
function xb() {
  return wb;
}
const kb = 1024;
let Qb = 0, Xo = class {
  constructor(e, t) {
    this.from = e, this.to = t;
  }
}, ie = class {
  /// Create a new node prop type.
  constructor(e = {}) {
    this.id = Qb++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
      throw new Error("This node type doesn't define a deserialize function");
    });
  }
  /// This is meant to be used with
  /// [`NodeSet.extend`](#common.NodeSet.extend) or
  /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
  /// prop values for each node type in the set. Takes a [match
  /// object](#common.NodeType^match) or function that returns undefined
  /// if the node type doesn't get this prop, and the prop's value if
  /// it does.
  add(e) {
    if (this.perNode)
      throw new RangeError("Can't add per-node props to node types");
    return typeof e != "function" && (e = Tt.match(e)), (t) => {
      let i = e(t);
      return i === void 0 ? null : [this, i];
    };
  }
};
ie.closedBy = new ie({ deserialize: (r) => r.split(" ") });
ie.openedBy = new ie({ deserialize: (r) => r.split(" ") });
ie.group = new ie({ deserialize: (r) => r.split(" ") });
ie.contextHash = new ie({ perNode: !0 });
ie.lookAhead = new ie({ perNode: !0 });
ie.mounted = new ie({ perNode: !0 });
const vb = /* @__PURE__ */ Object.create(null);
let Tt = class mp {
  /// @internal
  constructor(e, t, i, n = 0) {
    this.name = e, this.props = t, this.id = i, this.flags = n;
  }
  static define(e) {
    let t = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : vb, i = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new mp(e.name || "", t, e.id, i);
    if (e.props) {
      for (let s of e.props)
        if (Array.isArray(s) || (s = s(n)), s) {
          if (s[0].perNode)
            throw new RangeError("Can't store a per-node prop on a node type");
          t[s[0].id] = s[1];
        }
    }
    return n;
  }
  /// Retrieves a node prop for this type. Will return `undefined` if
  /// the prop isn't present on this node.
  prop(e) {
    return this.props[e.id];
  }
  /// True when this is the top node of a grammar.
  get isTop() {
    return (this.flags & 1) > 0;
  }
  /// True when this node is produced by a skip rule.
  get isSkipped() {
    return (this.flags & 2) > 0;
  }
  /// Indicates whether this is an error node.
  get isError() {
    return (this.flags & 4) > 0;
  }
  /// When true, this node type doesn't correspond to a user-declared
  /// named node, for example because it is used to cache repetition.
  get isAnonymous() {
    return (this.flags & 8) > 0;
  }
  /// Returns true when this node's name or one of its
  /// [groups](#common.NodeProp^group) matches the given string.
  is(e) {
    if (typeof e == "string") {
      if (this.name == e)
        return !0;
      let t = this.prop(ie.group);
      return t ? t.indexOf(e) > -1 : !1;
    }
    return this.id == e;
  }
  /// Create a function from node types to arbitrary values by
  /// specifying an object whose property names are node or
  /// [group](#common.NodeProp^group) names. Often useful with
  /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
  /// names, separated by spaces, in a single property name to map
  /// multiple node names to a single value.
  static match(e) {
    let t = /* @__PURE__ */ Object.create(null);
    for (let i in e)
      for (let n of i.split(" "))
        t[n] = e[i];
    return (i) => {
      for (let n = i.prop(ie.group), s = -1; s < (n ? n.length : 0); s++) {
        let o = t[s < 0 ? i.name : n[s]];
        if (o)
          return o;
      }
    };
  }
};
Tt.none = new Tt(
  "",
  /* @__PURE__ */ Object.create(null),
  0,
  8
  /* Anonymous */
);
const Zn = /* @__PURE__ */ new WeakMap(), Vc = /* @__PURE__ */ new WeakMap();
var Pe;
(function(r) {
  r[r.ExcludeBuffers = 1] = "ExcludeBuffers", r[r.IncludeAnonymous = 2] = "IncludeAnonymous", r[r.IgnoreMounts = 4] = "IgnoreMounts", r[r.IgnoreOverlays = 8] = "IgnoreOverlays";
})(Pe || (Pe = {}));
let We = class ea {
  /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
  constructor(e, t, i, n, s) {
    if (this.type = e, this.children = t, this.positions = i, this.length = n, this.props = null, s && s.length) {
      this.props = /* @__PURE__ */ Object.create(null);
      for (let [o, l] of s)
        this.props[typeof o == "number" ? o : o.id] = l;
    }
  }
  /// @internal
  toString() {
    let e = this.prop(ie.mounted);
    if (e && !e.overlay)
      return e.tree.toString();
    let t = "";
    for (let i of this.children) {
      let n = i.toString();
      n && (t && (t += ","), t += n);
    }
    return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (t.length ? "(" + t + ")" : "") : t;
  }
  /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
  /// the tree. Mode can be used to [control](#common.IterMode) which
  /// nodes the cursor visits.
  cursor(e = 0) {
    return new $s(this.topNode, e);
  }
  /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
  /// at the given position and side (see
  /// [`moveTo`](#common.TreeCursor.moveTo).
  cursorAt(e, t = 0, i = 0) {
    let n = Zn.get(this) || this.topNode, s = new $s(n);
    return s.moveTo(e, t), Zn.set(this, s._tree), s;
  }
  /// Get a [syntax node](#common.SyntaxNode) object for the top of the
  /// tree.
  get topNode() {
    return new Wr(this, 0, 0, null);
  }
  /// Get the [syntax node](#common.SyntaxNode) at the given position.
  /// If `side` is -1, this will move into nodes that end at the
  /// position. If 1, it'll move into nodes that start at the
  /// position. With 0, it'll only enter nodes that cover the position
  /// from both sides.
  resolve(e, t = 0) {
    let i = Wi(Zn.get(this) || this.topNode, e, t, !1);
    return Zn.set(this, i), i;
  }
  /// Like [`resolve`](#common.Tree.resolve), but will enter
  /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
  /// pointing into the innermost overlaid tree at the given position
  /// (with parent links going through all parent structure, including
  /// the host trees).
  resolveInner(e, t = 0) {
    let i = Wi(Vc.get(this) || this.topNode, e, t, !0);
    return Vc.set(this, i), i;
  }
  /// Iterate over the tree and its children, calling `enter` for any
  /// node that touches the `from`/`to` region (if given) before
  /// running over such a node's children, and `leave` (if given) when
  /// leaving the node. When `enter` returns `false`, that node will
  /// not have its children iterated over (or `leave` called).
  iterate(e) {
    let { enter: t, leave: i, from: n = 0, to: s = this.length } = e;
    for (let o = this.cursor((e.mode || 0) | Pe.IncludeAnonymous); ; ) {
      let l = !1;
      if (o.from <= s && o.to >= n && (o.type.isAnonymous || t(o) !== !1)) {
        if (o.firstChild())
          continue;
        l = !0;
      }
      for (; l && i && !o.type.isAnonymous && i(o), !o.nextSibling(); ) {
        if (!o.parent())
          return;
        l = !0;
      }
    }
  }
  /// Get the value of the given [node prop](#common.NodeProp) for this
  /// node. Works with both per-node and per-type props.
  prop(e) {
    return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
  }
  /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
  /// format that can be passed to the [`Tree`](#common.Tree)
  /// constructor.
  get propValues() {
    let e = [];
    if (this.props)
      for (let t in this.props)
        e.push([+t, this.props[t]]);
    return e;
  }
  /// Balance the direct children of this tree, producing a copy of
  /// which may have children grouped into subtrees with type
  /// [`NodeType.none`](#common.NodeType^none).
  balance(e = {}) {
    return this.children.length <= 8 ? this : eh(Tt.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, i, n) => new ea(this.type, t, i, n, this.propValues), e.makeTree || ((t, i, n) => new ea(Tt.none, t, i, n)));
  }
  /// Build a tree from a postfix-ordered buffer of node information,
  /// or a cursor over such a buffer.
  static build(e) {
    return Cb(e);
  }
};
We.empty = new We(Tt.none, [], [], 0);
let $b = class gp {
  constructor(e, t) {
    this.buffer = e, this.index = t;
  }
  get id() {
    return this.buffer[this.index - 4];
  }
  get start() {
    return this.buffer[this.index - 3];
  }
  get end() {
    return this.buffer[this.index - 2];
  }
  get size() {
    return this.buffer[this.index - 1];
  }
  get pos() {
    return this.index;
  }
  next() {
    this.index -= 4;
  }
  fork() {
    return new gp(this.buffer, this.index);
  }
}, cn = class bp {
  /// Create a tree buffer.
  constructor(e, t, i) {
    this.buffer = e, this.length = t, this.set = i;
  }
  /// @internal
  get type() {
    return Tt.none;
  }
  /// @internal
  toString() {
    let e = [];
    for (let t = 0; t < this.buffer.length; )
      e.push(this.childString(t)), t = this.buffer[t + 3];
    return e.join(",");
  }
  /// @internal
  childString(e) {
    let t = this.buffer[e], i = this.buffer[e + 3], n = this.set.types[t], s = n.name;
    if (/\W/.test(s) && !n.isError && (s = JSON.stringify(s)), e += 4, i == e)
      return s;
    let o = [];
    for (; e < i; )
      o.push(this.childString(e)), e = this.buffer[e + 3];
    return s + "(" + o.join(",") + ")";
  }
  /// @internal
  findChild(e, t, i, n, s) {
    let { buffer: o } = this, l = -1;
    for (let a = e; a != t && !(yp(s, n, o[a + 1], o[a + 2]) && (l = a, i > 0)); a = o[a + 3])
      ;
    return l;
  }
  /// @internal
  slice(e, t, i, n) {
    let s = this.buffer, o = new Uint16Array(t - e);
    for (let l = e, a = 0; l < t; )
      o[a++] = s[l++], o[a++] = s[l++] - i, o[a++] = s[l++] - i, o[a++] = s[l++] - e;
    return new bp(o, n - i, this.set);
  }
};
function yp(r, e, t, i) {
  switch (r) {
    case -2:
      return t < e;
    case -1:
      return i >= e && t < e;
    case 0:
      return t < e && i > e;
    case 1:
      return t <= e && i > e;
    case 2:
      return i > e;
    case 4:
      return !0;
  }
}
function Sp(r, e) {
  let t = r.childBefore(e);
  for (; t; ) {
    let i = t.lastChild;
    if (!i || i.to != t.to)
      break;
    i.type.isError && i.from == i.to ? (r = t, t = i.prevSibling) : t = i;
  }
  return r;
}
function Wi(r, e, t, i) {
  for (var n; r.from == r.to || (t < 1 ? r.from >= e : r.from > e) || (t > -1 ? r.to <= e : r.to < e); ) {
    let o = !i && r instanceof Wr && r.index < 0 ? null : r.parent;
    if (!o)
      return r;
    r = o;
  }
  let s = i ? 0 : Pe.IgnoreOverlays;
  if (i)
    for (let o = r, l = o.parent; l; o = l, l = o.parent)
      o instanceof Wr && o.index < 0 && ((n = l.enter(e, t, s)) === null || n === void 0 ? void 0 : n.from) != o.from && (r = l);
  for (; ; ) {
    let o = r.enter(e, t, s);
    if (!o)
      return r;
    r = o;
  }
}
let Wr = class ns {
  constructor(e, t, i, n) {
    this._tree = e, this.from = t, this.index = i, this._parent = n;
  }
  get type() {
    return this._tree.type;
  }
  get name() {
    return this._tree.type.name;
  }
  get to() {
    return this.from + this._tree.length;
  }
  nextChild(e, t, i, n, s = 0) {
    for (let o = this; ; ) {
      for (let { children: l, positions: a } = o._tree, h = t > 0 ? l.length : -1; e != h; e += t) {
        let c = l[e], f = a[e] + o.from;
        if (yp(n, i, f, f + c.length)) {
          if (c instanceof cn) {
            if (s & Pe.ExcludeBuffers)
              continue;
            let u = c.findChild(0, c.buffer.length, t, i - f, n);
            if (u > -1)
              return new ta(new Pb(o, c, e, f), null, u);
          } else if (s & Pe.IncludeAnonymous || !c.type.isAnonymous || Ja(c)) {
            let u;
            if (!(s & Pe.IgnoreMounts) && c.props && (u = c.prop(ie.mounted)) && !u.overlay)
              return new ns(u.tree, f, e, o);
            let d = new ns(c, f, e, o);
            return s & Pe.IncludeAnonymous || !d.type.isAnonymous ? d : d.nextChild(t < 0 ? c.children.length - 1 : 0, t, i, n);
          }
        }
      }
      if (s & Pe.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? e = o.index + t : e = t < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
        return null;
    }
  }
  get firstChild() {
    return this.nextChild(
      0,
      1,
      0,
      4
      /* DontCare */
    );
  }
  get lastChild() {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      0,
      4
      /* DontCare */
    );
  }
  childAfter(e) {
    return this.nextChild(
      0,
      1,
      e,
      2
      /* After */
    );
  }
  childBefore(e) {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      e,
      -2
      /* Before */
    );
  }
  enter(e, t, i = 0) {
    let n;
    if (!(i & Pe.IgnoreOverlays) && (n = this._tree.prop(ie.mounted)) && n.overlay) {
      let s = e - this.from;
      for (let { from: o, to: l } of n.overlay)
        if ((t > 0 ? o <= s : o < s) && (t < 0 ? l >= s : l > s))
          return new ns(n.tree, n.overlay[0].from + this.from, -1, this);
    }
    return this.nextChild(0, 1, e, t, i);
  }
  nextSignificantParent() {
    let e = this;
    for (; e.type.isAnonymous && e._parent; )
      e = e._parent;
    return e;
  }
  get parent() {
    return this._parent ? this._parent.nextSignificantParent() : null;
  }
  get nextSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index + 1,
      1,
      0,
      4
      /* DontCare */
    ) : null;
  }
  get prevSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index - 1,
      -1,
      0,
      4
      /* DontCare */
    ) : null;
  }
  cursor(e = 0) {
    return new $s(this, e);
  }
  get tree() {
    return this._tree;
  }
  toTree() {
    return this._tree;
  }
  resolve(e, t = 0) {
    return Wi(this, e, t, !1);
  }
  resolveInner(e, t = 0) {
    return Wi(this, e, t, !0);
  }
  enterUnfinishedNodesBefore(e) {
    return Sp(this, e);
  }
  getChild(e, t = null, i = null) {
    let n = Qs(this, e, t, i);
    return n.length ? n[0] : null;
  }
  getChildren(e, t = null, i = null) {
    return Qs(this, e, t, i);
  }
  /// @internal
  toString() {
    return this._tree.toString();
  }
  get node() {
    return this;
  }
  matchContext(e) {
    return vs(this, e);
  }
};
function Qs(r, e, t, i) {
  let n = r.cursor(), s = [];
  if (!n.firstChild())
    return s;
  if (t != null) {
    for (; !n.type.is(t); )
      if (!n.nextSibling())
        return s;
  }
  for (; ; ) {
    if (i != null && n.type.is(i))
      return s;
    if (n.type.is(e) && s.push(n.node), !n.nextSibling())
      return i == null ? s : [];
  }
}
function vs(r, e, t = e.length - 1) {
  for (let i = r.parent; t >= 0; i = i.parent) {
    if (!i)
      return !1;
    if (!i.type.isAnonymous) {
      if (e[t] && e[t] != i.name)
        return !1;
      t--;
    }
  }
  return !0;
}
let Pb = class {
  constructor(e, t, i, n) {
    this.parent = e, this.buffer = t, this.index = i, this.start = n;
  }
}, ta = class Qr {
  constructor(e, t, i) {
    this.context = e, this._parent = t, this.index = i, this.type = e.buffer.set.types[e.buffer.buffer[i]];
  }
  get name() {
    return this.type.name;
  }
  get from() {
    return this.context.start + this.context.buffer.buffer[this.index + 1];
  }
  get to() {
    return this.context.start + this.context.buffer.buffer[this.index + 2];
  }
  child(e, t, i) {
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.context.start, i);
    return s < 0 ? null : new Qr(this.context, this, s);
  }
  get firstChild() {
    return this.child(
      1,
      0,
      4
      /* DontCare */
    );
  }
  get lastChild() {
    return this.child(
      -1,
      0,
      4
      /* DontCare */
    );
  }
  childAfter(e) {
    return this.child(
      1,
      e,
      2
      /* After */
    );
  }
  childBefore(e) {
    return this.child(
      -1,
      e,
      -2
      /* Before */
    );
  }
  enter(e, t, i = 0) {
    if (i & Pe.ExcludeBuffers)
      return null;
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], t > 0 ? 1 : -1, e - this.context.start, t);
    return s < 0 ? null : new Qr(this.context, this, s);
  }
  get parent() {
    return this._parent || this.context.parent.nextSignificantParent();
  }
  externalSibling(e) {
    return this._parent ? null : this.context.parent.nextChild(
      this.context.index + e,
      e,
      0,
      4
      /* DontCare */
    );
  }
  get nextSibling() {
    let { buffer: e } = this.context, t = e.buffer[this.index + 3];
    return t < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new Qr(this.context, this._parent, t) : this.externalSibling(1);
  }
  get prevSibling() {
    let { buffer: e } = this.context, t = this._parent ? this._parent.index + 4 : 0;
    return this.index == t ? this.externalSibling(-1) : new Qr(this.context, this._parent, e.findChild(
      t,
      this.index,
      -1,
      0,
      4
      /* DontCare */
    ));
  }
  cursor(e = 0) {
    return new $s(this, e);
  }
  get tree() {
    return null;
  }
  toTree() {
    let e = [], t = [], { buffer: i } = this.context, n = this.index + 4, s = i.buffer[this.index + 3];
    if (s > n) {
      let o = i.buffer[this.index + 1], l = i.buffer[this.index + 2];
      e.push(i.slice(n, s, o, l)), t.push(0);
    }
    return new We(this.type, e, t, this.to - this.from);
  }
  resolve(e, t = 0) {
    return Wi(this, e, t, !1);
  }
  resolveInner(e, t = 0) {
    return Wi(this, e, t, !0);
  }
  enterUnfinishedNodesBefore(e) {
    return Sp(this, e);
  }
  /// @internal
  toString() {
    return this.context.buffer.childString(this.index);
  }
  getChild(e, t = null, i = null) {
    let n = Qs(this, e, t, i);
    return n.length ? n[0] : null;
  }
  getChildren(e, t = null, i = null) {
    return Qs(this, e, t, i);
  }
  get node() {
    return this;
  }
  matchContext(e) {
    return vs(this, e);
  }
}, $s = class {
  /// @internal
  constructor(e, t = 0) {
    if (this.mode = t, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, e instanceof Wr)
      this.yieldNode(e);
    else {
      this._tree = e.context.parent, this.buffer = e.context;
      for (let i = e._parent; i; i = i._parent)
        this.stack.unshift(i.index);
      this.bufferNode = e, this.yieldBuf(e.index);
    }
  }
  /// Shorthand for `.type.name`.
  get name() {
    return this.type.name;
  }
  yieldNode(e) {
    return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, !0) : !1;
  }
  yieldBuf(e, t) {
    this.index = e;
    let { start: i, buffer: n } = this.buffer;
    return this.type = t || n.set.types[n.buffer[e]], this.from = i + n.buffer[e + 1], this.to = i + n.buffer[e + 2], !0;
  }
  yield(e) {
    return e ? e instanceof Wr ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : !1;
  }
  /// @internal
  toString() {
    return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
  }
  /// @internal
  enterChild(e, t, i) {
    if (!this.buffer)
      return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, i, this.mode));
    let { buffer: n } = this.buffer, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.buffer.start, i);
    return s < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(s));
  }
  /// Move the cursor to this node's first child. When this returns
  /// false, the node has no child, and the cursor has not been moved.
  firstChild() {
    return this.enterChild(
      1,
      0,
      4
      /* DontCare */
    );
  }
  /// Move the cursor to this node's last child.
  lastChild() {
    return this.enterChild(
      -1,
      0,
      4
      /* DontCare */
    );
  }
  /// Move the cursor to the first child that ends after `pos`.
  childAfter(e) {
    return this.enterChild(
      1,
      e,
      2
      /* After */
    );
  }
  /// Move to the last child that starts before `pos`.
  childBefore(e) {
    return this.enterChild(
      -1,
      e,
      -2
      /* Before */
    );
  }
  /// Move the cursor to the child around `pos`. If side is -1 the
  /// child may end at that position, when 1 it may start there. This
  /// will also enter [overlaid](#common.MountedTree.overlay)
  /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
  /// set to false.
  enter(e, t, i = this.mode) {
    return this.buffer ? i & Pe.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, i));
  }
  /// Move to the node's parent node, if this isn't the top node.
  parent() {
    if (!this.buffer)
      return this.yieldNode(this.mode & Pe.IncludeAnonymous ? this._tree._parent : this._tree.parent);
    if (this.stack.length)
      return this.yieldBuf(this.stack.pop());
    let e = this.mode & Pe.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
    return this.buffer = null, this.yieldNode(e);
  }
  /// @internal
  sibling(e) {
    if (!this.buffer)
      return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : !1;
    let { buffer: t } = this.buffer, i = this.stack.length - 1;
    if (e < 0) {
      let n = i < 0 ? 0 : this.stack[i] + 4;
      if (this.index != n)
        return this.yieldBuf(t.findChild(
          n,
          this.index,
          -1,
          0,
          4
          /* DontCare */
        ));
    } else {
      let n = t.buffer[this.index + 3];
      if (n < (i < 0 ? t.buffer.length : t.buffer[this.stack[i] + 3]))
        return this.yieldBuf(n);
    }
    return i < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : !1;
  }
  /// Move to this node's next sibling, if any.
  nextSibling() {
    return this.sibling(1);
  }
  /// Move to this node's previous sibling, if any.
  prevSibling() {
    return this.sibling(-1);
  }
  atLastNode(e) {
    let t, i, { buffer: n } = this;
    if (n) {
      if (e > 0) {
        if (this.index < n.buffer.buffer.length)
          return !1;
      } else
        for (let s = 0; s < this.index; s++)
          if (n.buffer.buffer[s + 3] < this.index)
            return !1;
      ({ index: t, parent: i } = n);
    } else
      ({ index: t, _parent: i } = this._tree);
    for (; i; { index: t, _parent: i } = i)
      if (t > -1)
        for (let s = t + e, o = e < 0 ? -1 : i._tree.children.length; s != o; s += e) {
          let l = i._tree.children[s];
          if (this.mode & Pe.IncludeAnonymous || l instanceof cn || !l.type.isAnonymous || Ja(l))
            return !1;
        }
    return !0;
  }
  move(e, t) {
    if (t && this.enterChild(
      e,
      0,
      4
      /* DontCare */
    ))
      return !0;
    for (; ; ) {
      if (this.sibling(e))
        return !0;
      if (this.atLastNode(e) || !this.parent())
        return !1;
    }
  }
  /// Move to the next node in a
  /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
  /// traversal, going from a node to its first child or, if the
  /// current node is empty or `enter` is false, its next sibling or
  /// the next sibling of the first parent node that has one.
  next(e = !0) {
    return this.move(1, e);
  }
  /// Move to the next node in a last-to-first pre-order traveral. A
  /// node is followed by its last child or, if it has none, its
  /// previous sibling or the previous sibling of the first parent
  /// node that has one.
  prev(e = !0) {
    return this.move(-1, e);
  }
  /// Move the cursor to the innermost node that covers `pos`. If
  /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
  /// it will enter nodes that start at `pos`.
  moveTo(e, t = 0) {
    for (; (this.from == this.to || (t < 1 ? this.from >= e : this.from > e) || (t > -1 ? this.to <= e : this.to < e)) && this.parent(); )
      ;
    for (; this.enterChild(1, e, t); )
      ;
    return this;
  }
  /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
  /// position.
  get node() {
    if (!this.buffer)
      return this._tree;
    let e = this.bufferNode, t = null, i = 0;
    if (e && e.context == this.buffer)
      e: for (let n = this.index, s = this.stack.length; s >= 0; ) {
        for (let o = e; o; o = o._parent)
          if (o.index == n) {
            if (n == this.index)
              return o;
            t = o, i = s + 1;
            break e;
          }
        n = this.stack[--s];
      }
    for (let n = i; n < this.stack.length; n++)
      t = new ta(this.buffer, t, this.stack[n]);
    return this.bufferNode = new ta(this.buffer, t, this.index);
  }
  /// Get the [tree](#common.Tree) that represents the current node, if
  /// any. Will return null when the node is in a [tree
  /// buffer](#common.TreeBuffer).
  get tree() {
    return this.buffer ? null : this._tree._tree;
  }
  /// Iterate over the current node and all its descendants, calling
  /// `enter` when entering a node and `leave`, if given, when leaving
  /// one. When `enter` returns `false`, any children of that node are
  /// skipped, and `leave` isn't called for it.
  iterate(e, t) {
    for (let i = 0; ; ) {
      let n = !1;
      if (this.type.isAnonymous || e(this) !== !1) {
        if (this.firstChild()) {
          i++;
          continue;
        }
        this.type.isAnonymous || (n = !0);
      }
      for (; n && t && t(this), n = this.type.isAnonymous, !this.nextSibling(); ) {
        if (!i)
          return;
        this.parent(), i--, n = !0;
      }
    }
  }
  /// Test whether the current node matches a given context—a sequence
  /// of direct parent node names. Empty strings in the context array
  /// are treated as wildcards.
  matchContext(e) {
    if (!this.buffer)
      return vs(this.node, e);
    let { buffer: t } = this.buffer, { types: i } = t.set;
    for (let n = e.length - 1, s = this.stack.length - 1; n >= 0; s--) {
      if (s < 0)
        return vs(this.node, e, n);
      let o = i[t.buffer[this.stack[s]]];
      if (!o.isAnonymous) {
        if (e[n] && e[n] != o.name)
          return !1;
        n--;
      }
    }
    return !0;
  }
};
function Ja(r) {
  return r.children.some((e) => e instanceof cn || !e.type.isAnonymous || Ja(e));
}
function Cb(r) {
  var e;
  let { buffer: t, nodeSet: i, maxBufferLength: n = kb, reused: s = [], minRepeatType: o = i.types.length } = r, l = Array.isArray(t) ? new $b(t, t.length) : t, a = i.types, h = 0, c = 0;
  function f(x, S, y, Q, L) {
    let { id: $, start: P, end: T, size: A } = l, I = c;
    for (; A < 0; )
      if (l.next(), A == -1) {
        let re = s[$];
        y.push(re), Q.push(P - x);
        return;
      } else if (A == -3) {
        h = $;
        return;
      } else if (A == -4) {
        c = $;
        return;
      } else
        throw new RangeError(`Unrecognized record size: ${A}`);
    let q = a[$], Y, U, be = P - x;
    if (T - P <= n && (U = O(l.pos - S, L))) {
      let re = new Uint16Array(U.size - U.skip), N = l.pos - U.size, J = re.length;
      for (; l.pos > N; )
        J = g(U.start, re, J);
      Y = new cn(re, T - U.start, i), be = U.start - x;
    } else {
      let re = l.pos - A;
      l.next();
      let N = [], J = [], ae = $ >= o ? $ : -1, oe = 0, pe = T;
      for (; l.pos > re; )
        ae >= 0 && l.id == ae && l.size >= 0 ? (l.end <= pe - n && (d(N, J, P, oe, l.end, pe, ae, I), oe = N.length, pe = l.end), l.next()) : f(P, re, N, J, ae);
      if (ae >= 0 && oe > 0 && oe < N.length && d(N, J, P, oe, P, pe, ae, I), N.reverse(), J.reverse(), ae > -1 && oe > 0) {
        let Be = u(q);
        Y = eh(q, N, J, 0, N.length, 0, T - P, Be, Be);
      } else
        Y = p(q, N, J, T - P, I - T);
    }
    y.push(Y), Q.push(be);
  }
  function u(x) {
    return (S, y, Q) => {
      let L = 0, $ = S.length - 1, P, T;
      if ($ >= 0 && (P = S[$]) instanceof We) {
        if (!$ && P.type == x && P.length == Q)
          return P;
        (T = P.prop(ie.lookAhead)) && (L = y[$] + P.length + T);
      }
      return p(x, S, y, Q, L);
    };
  }
  function d(x, S, y, Q, L, $, P, T) {
    let A = [], I = [];
    for (; x.length > Q; )
      A.push(x.pop()), I.push(S.pop() + y - L);
    x.push(p(i.types[P], A, I, $ - L, T - $)), S.push(L - y);
  }
  function p(x, S, y, Q, L = 0, $) {
    if (h) {
      let P = [ie.contextHash, h];
      $ = $ ? [P].concat($) : [P];
    }
    if (L > 25) {
      let P = [ie.lookAhead, L];
      $ = $ ? [P].concat($) : [P];
    }
    return new We(x, S, y, Q, $);
  }
  function O(x, S) {
    let y = l.fork(), Q = 0, L = 0, $ = 0, P = y.end - n, T = { size: 0, start: 0, skip: 0 };
    e: for (let A = y.pos - x; y.pos > A; ) {
      let I = y.size;
      if (y.id == S && I >= 0) {
        T.size = Q, T.start = L, T.skip = $, $ += 4, Q += 4, y.next();
        continue;
      }
      let q = y.pos - I;
      if (I < 0 || q < A || y.start < P)
        break;
      let Y = y.id >= o ? 4 : 0, U = y.start;
      for (y.next(); y.pos > q; ) {
        if (y.size < 0)
          if (y.size == -3)
            Y += 4;
          else
            break e;
        else y.id >= o && (Y += 4);
        y.next();
      }
      L = U, Q += I, $ += Y;
    }
    return (S < 0 || Q == x) && (T.size = Q, T.start = L, T.skip = $), T.size > 4 ? T : void 0;
  }
  function g(x, S, y) {
    let { id: Q, start: L, end: $, size: P } = l;
    if (l.next(), P >= 0 && Q < o) {
      let T = y;
      if (P > 4) {
        let A = l.pos - (P - 4);
        for (; l.pos > A; )
          y = g(x, S, y);
      }
      S[--y] = T, S[--y] = $ - x, S[--y] = L - x, S[--y] = Q;
    } else P == -3 ? h = Q : P == -4 && (c = Q);
    return y;
  }
  let b = [], w = [];
  for (; l.pos > 0; )
    f(r.start || 0, r.bufferStart || 0, b, w, -1);
  let k = (e = r.length) !== null && e !== void 0 ? e : b.length ? w[0] + b[0].length : 0;
  return new We(a[r.topID], b.reverse(), w.reverse(), k);
}
const qc = /* @__PURE__ */ new WeakMap();
function ss(r, e) {
  if (!r.isAnonymous || e instanceof cn || e.type != r)
    return 1;
  let t = qc.get(e);
  if (t == null) {
    t = 1;
    for (let i of e.children) {
      if (i.type != r || !(i instanceof We)) {
        t = 1;
        break;
      }
      t += ss(r, i);
    }
    qc.set(e, t);
  }
  return t;
}
function eh(r, e, t, i, n, s, o, l, a) {
  let h = 0;
  for (let p = i; p < n; p++)
    h += ss(r, e[p]);
  let c = Math.ceil(
    h * 1.5 / 8
    /* BranchFactor */
  ), f = [], u = [];
  function d(p, O, g, b, w) {
    for (let k = g; k < b; ) {
      let x = k, S = O[k], y = ss(r, p[k]);
      for (k++; k < b; k++) {
        let Q = ss(r, p[k]);
        if (y + Q >= c)
          break;
        y += Q;
      }
      if (k == x + 1) {
        if (y > c) {
          let Q = p[x];
          d(Q.children, Q.positions, 0, Q.children.length, O[x] + w);
          continue;
        }
        f.push(p[x]);
      } else {
        let Q = O[k - 1] + p[k - 1].length - S;
        f.push(eh(r, p, O, x, k, S, Q, null, a));
      }
      u.push(S + w - s);
    }
  }
  return d(e, t, i, n, 0), (l || a)(f, u, o);
}
let os = class ia {
  /// Construct a tree fragment.
  constructor(e, t, i, n, s = !1, o = !1) {
    this.from = e, this.to = t, this.tree = i, this.offset = n, this.open = (s ? 1 : 0) | (o ? 2 : 0);
  }
  /// Whether the start of the fragment represents the start of a
  /// parse, or the end of a change. (In the second case, it may not
  /// be safe to reuse some nodes at the start, depending on the
  /// parsing algorithm.)
  get openStart() {
    return (this.open & 1) > 0;
  }
  /// Whether the end of the fragment represents the end of a
  /// full-document parse, or the start of a change.
  get openEnd() {
    return (this.open & 2) > 0;
  }
  /// Create a set of fragments from a freshly parsed tree, or update
  /// an existing set of fragments by replacing the ones that overlap
  /// with a tree with content from the new tree. When `partial` is
  /// true, the parse is treated as incomplete, and the resulting
  /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
  /// true.
  static addTree(e, t = [], i = !1) {
    let n = [new ia(0, e.length, e, 0, !1, i)];
    for (let s of t)
      s.to > e.length && n.push(s);
    return n;
  }
  /// Apply a set of edits to an array of fragments, removing or
  /// splitting fragments as necessary to remove edited ranges, and
  /// adjusting offsets for fragments that moved.
  static applyChanges(e, t, i = 128) {
    if (!t.length)
      return e;
    let n = [], s = 1, o = e.length ? e[0] : null;
    for (let l = 0, a = 0, h = 0; ; l++) {
      let c = l < t.length ? t[l] : null, f = c ? c.fromA : 1e9;
      if (f - a >= i)
        for (; o && o.from < f; ) {
          let u = o;
          if (a >= u.from || f <= u.to || h) {
            let d = Math.max(u.from, a) - h, p = Math.min(u.to, f) - h;
            u = d >= p ? null : new ia(d, p, u.tree, u.offset + h, l > 0, !!c);
          }
          if (u && n.push(u), o.to > f)
            break;
          o = s < e.length ? e[s++] : null;
        }
      if (!c)
        break;
      a = c.toA, h = c.toA - c.toB;
    }
    return n;
  }
}, Tb = class {
  /// Start a parse, returning a [partial parse](#common.PartialParse)
  /// object. [`fragments`](#common.TreeFragment) can be passed in to
  /// make the parse incremental.
  ///
  /// By default, the entire input is parsed. You can pass `ranges`,
  /// which should be a sorted array of non-empty, non-overlapping
  /// ranges, to parse only those ranges. The tree returned in that
  /// case will start at `ranges[0].from`.
  startParse(e, t, i) {
    return typeof e == "string" && (e = new Ab(e)), i = i ? i.length ? i.map((n) => new Xo(n.from, n.to)) : [new Xo(0, 0)] : [new Xo(0, e.length)], this.createParse(e, t || [], i);
  }
  /// Run a full parse, returning the resulting tree.
  parse(e, t, i) {
    let n = this.startParse(e, t, i);
    for (; ; ) {
      let s = n.advance();
      if (s)
        return s;
    }
  }
}, Ab = class {
  constructor(e) {
    this.string = e;
  }
  get length() {
    return this.string.length;
  }
  chunk(e) {
    return this.string.slice(e);
  }
  get lineChunks() {
    return !1;
  }
  read(e, t) {
    return this.string.slice(e, t);
  }
};
new ie({ perNode: !0 });
let Mb = 0, Wt = class wp {
  /// @internal
  constructor(e, t, i) {
    this.set = e, this.base = t, this.modified = i, this.id = Mb++;
  }
  /// Define a new tag. If `parent` is given, the tag is treated as a
  /// sub-tag of that parent, and
  /// [highlighters](#highlight.tagHighlighter) that don't mention
  /// this tag will try to fall back to the parent tag (or grandparent
  /// tag, etc).
  static define(e) {
    if (e?.base)
      throw new Error("Can not derive from a modified tag");
    let t = new wp([], null, []);
    if (t.set.push(t), e)
      for (let i of e.set)
        t.set.push(i);
    return t;
  }
  /// Define a tag _modifier_, which is a function that, given a tag,
  /// will return a tag that is a subtag of the original. Applying the
  /// same modifier to a twice tag will return the same value (`m1(t1)
  /// == m1(t1)`) and applying multiple modifiers will, regardless or
  /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
  ///
  /// When multiple modifiers are applied to a given base tag, each
  /// smaller set of modifiers is registered as a parent, so that for
  /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
  /// `m1(m3(t1)`, and so on.
  static defineModifier() {
    let e = new Yc();
    return (t) => t.modified.indexOf(e) > -1 ? t : Yc.get(t.base || t, t.modified.concat(e).sort((i, n) => i.id - n.id));
  }
}, Zb = 0, Yc = class xp {
  constructor() {
    this.instances = [], this.id = Zb++;
  }
  static get(e, t) {
    if (!t.length)
      return e;
    let i = t[0].instances.find((l) => l.base == e && Xb(t, l.modified));
    if (i)
      return i;
    let n = [], s = new Wt(n, e, t);
    for (let l of t)
      l.instances.push(s);
    let o = kp(t);
    for (let l of e.set)
      for (let a of o)
        n.push(xp.get(l, a));
    return s;
  }
};
function Xb(r, e) {
  return r.length == e.length && r.every((t, i) => t == e[i]);
}
function kp(r) {
  let e = [r];
  for (let t = 0; t < r.length; t++)
    for (let i of kp(r.slice(0, t).concat(r.slice(t + 1))))
      e.push(i);
  return e;
}
function Rb(r) {
  let e = /* @__PURE__ */ Object.create(null);
  for (let t in r) {
    let i = r[t];
    Array.isArray(i) || (i = [i]);
    for (let n of t.split(" "))
      if (n) {
        let s = [], o = 2, l = n;
        for (let f = 0; ; ) {
          if (l == "..." && f > 0 && f + 3 == n.length) {
            o = 1;
            break;
          }
          let u = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);
          if (!u)
            throw new RangeError("Invalid path: " + n);
          if (s.push(u[0] == "*" ? "" : u[0][0] == '"' ? JSON.parse(u[0]) : u[0]), f += u[0].length, f == n.length)
            break;
          let d = n[f++];
          if (f == n.length && d == "!") {
            o = 0;
            break;
          }
          if (d != "/")
            throw new RangeError("Invalid path: " + n);
          l = n.slice(f);
        }
        let a = s.length - 1, h = s[a];
        if (!h)
          throw new RangeError("Invalid path: " + n);
        let c = new Lb(i, o, a > 0 ? s.slice(0, a) : null);
        e[h] = c.sort(e[h]);
      }
  }
  return Qp.add(e);
}
const Qp = new ie();
let Lb = class {
  constructor(e, t, i, n) {
    this.tags = e, this.mode = t, this.context = i, this.next = n;
  }
  sort(e) {
    return !e || e.depth < this.depth ? (this.next = e, this) : (e.next = this.sort(e.next), e);
  }
  get depth() {
    return this.context ? this.context.length : 0;
  }
};
function vp(r, e) {
  let t = /* @__PURE__ */ Object.create(null);
  for (let s of r)
    if (!Array.isArray(s.tag))
      t[s.tag.id] = s.class;
    else
      for (let o of s.tag)
        t[o.id] = s.class;
  let { scope: i, all: n = null } = e || {};
  return {
    style: (s) => {
      let o = n;
      for (let l of s)
        for (let a of l.set) {
          let h = t[a.id];
          if (h) {
            o = o ? o + " " + h : h;
            break;
          }
        }
      return o;
    },
    scope: i
  };
}
function Eb(r, e) {
  let t = null;
  for (let i of r) {
    let n = i.style(e);
    n && (t = t ? t + " " + n : n);
  }
  return t;
}
function zb(r, e, t, i = 0, n = r.length) {
  let s = new Db(i, Array.isArray(e) ? e : [e], t);
  s.highlightRange(r.cursor(), i, n, "", s.highlighters), s.flush(n);
}
let Db = class {
  constructor(e, t, i) {
    this.at = e, this.highlighters = t, this.span = i, this.class = "";
  }
  startSpan(e, t) {
    t != this.class && (this.flush(e), e > this.at && (this.at = e), this.class = t);
  }
  flush(e) {
    e > this.at && this.class && this.span(this.at, e, this.class);
  }
  highlightRange(e, t, i, n, s) {
    let { type: o, from: l, to: a } = e;
    if (l >= i || a <= t)
      return;
    o.isTop && (s = this.highlighters.filter((d) => !d.scope || d.scope(o)));
    let h = n, c = o.prop(Qp), f = !1;
    for (; c; ) {
      if (!c.context || e.matchContext(c.context)) {
        let d = Eb(s, c.tags);
        d && (h && (h += " "), h += d, c.mode == 1 ? n += (n ? " " : "") + d : c.mode == 0 && (f = !0));
        break;
      }
      c = c.next;
    }
    if (this.startSpan(e.from, h), f)
      return;
    let u = e.tree && e.tree.prop(ie.mounted);
    if (u && u.overlay) {
      let d = e.node.enter(u.overlay[0].from + l, 1), p = this.highlighters.filter((g) => !g.scope || g.scope(u.tree.type)), O = e.firstChild();
      for (let g = 0, b = l; ; g++) {
        let w = g < u.overlay.length ? u.overlay[g] : null, k = w ? w.from + l : a, x = Math.max(t, b), S = Math.min(i, k);
        if (x < S && O)
          for (; e.from < S && (this.highlightRange(e, x, S, n, s), this.startSpan(Math.min(i, e.to), h), !(e.to >= k || !e.nextSibling())); )
            ;
        if (!w || k > i)
          break;
        b = w.to + l, b > t && (this.highlightRange(d.cursor(), Math.max(t, w.from + l), Math.min(i, b), n, p), this.startSpan(b, h));
      }
      O && e.parent();
    } else if (e.firstChild()) {
      do
        if (!(e.to <= t)) {
          if (e.from >= i)
            break;
          this.highlightRange(e, t, i, n, s), this.startSpan(Math.min(i, e.to), h);
        }
      while (e.nextSibling());
      e.parent();
    }
  }
};
const M = Wt.define, Xn = M(), jt = M(), Nc = M(jt), Wc = M(jt), Gt = M(), Rn = M(Gt), Ro = M(Gt), gt = M(), pi = M(gt), ft = M(), ut = M(), ra = M(), cr = M(ra), Ln = M(), z = {
  /// A comment.
  comment: Xn,
  /// A line [comment](#highlight.tags.comment).
  lineComment: M(Xn),
  /// A block [comment](#highlight.tags.comment).
  blockComment: M(Xn),
  /// A documentation [comment](#highlight.tags.comment).
  docComment: M(Xn),
  /// Any kind of identifier.
  name: jt,
  /// The [name](#highlight.tags.name) of a variable.
  variableName: M(jt),
  /// A type [name](#highlight.tags.name).
  typeName: Nc,
  /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
  tagName: M(Nc),
  /// A property or field [name](#highlight.tags.name).
  propertyName: Wc,
  /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
  attributeName: M(Wc),
  /// The [name](#highlight.tags.name) of a class.
  className: M(jt),
  /// A label [name](#highlight.tags.name).
  labelName: M(jt),
  /// A namespace [name](#highlight.tags.name).
  namespace: M(jt),
  /// The [name](#highlight.tags.name) of a macro.
  macroName: M(jt),
  /// A literal value.
  literal: Gt,
  /// A string [literal](#highlight.tags.literal).
  string: Rn,
  /// A documentation [string](#highlight.tags.string).
  docString: M(Rn),
  /// A character literal (subtag of [string](#highlight.tags.string)).
  character: M(Rn),
  /// An attribute value (subtag of [string](#highlight.tags.string)).
  attributeValue: M(Rn),
  /// A number [literal](#highlight.tags.literal).
  number: Ro,
  /// An integer [number](#highlight.tags.number) literal.
  integer: M(Ro),
  /// A floating-point [number](#highlight.tags.number) literal.
  float: M(Ro),
  /// A boolean [literal](#highlight.tags.literal).
  bool: M(Gt),
  /// Regular expression [literal](#highlight.tags.literal).
  regexp: M(Gt),
  /// An escape [literal](#highlight.tags.literal), for example a
  /// backslash escape in a string.
  escape: M(Gt),
  /// A color [literal](#highlight.tags.literal).
  color: M(Gt),
  /// A URL [literal](#highlight.tags.literal).
  url: M(Gt),
  /// A language keyword.
  keyword: ft,
  /// The [keyword](#highlight.tags.keyword) for the self or this
  /// object.
  self: M(ft),
  /// The [keyword](#highlight.tags.keyword) for null.
  null: M(ft),
  /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
  atom: M(ft),
  /// A [keyword](#highlight.tags.keyword) that represents a unit.
  unit: M(ft),
  /// A modifier [keyword](#highlight.tags.keyword).
  modifier: M(ft),
  /// A [keyword](#highlight.tags.keyword) that acts as an operator.
  operatorKeyword: M(ft),
  /// A control-flow related [keyword](#highlight.tags.keyword).
  controlKeyword: M(ft),
  /// A [keyword](#highlight.tags.keyword) that defines something.
  definitionKeyword: M(ft),
  /// A [keyword](#highlight.tags.keyword) related to defining or
  /// interfacing with modules.
  moduleKeyword: M(ft),
  /// An operator.
  operator: ut,
  /// An [operator](#highlight.tags.operator) that defines something.
  derefOperator: M(ut),
  /// Arithmetic-related [operator](#highlight.tags.operator).
  arithmeticOperator: M(ut),
  /// Logical [operator](#highlight.tags.operator).
  logicOperator: M(ut),
  /// Bit [operator](#highlight.tags.operator).
  bitwiseOperator: M(ut),
  /// Comparison [operator](#highlight.tags.operator).
  compareOperator: M(ut),
  /// [Operator](#highlight.tags.operator) that updates its operand.
  updateOperator: M(ut),
  /// [Operator](#highlight.tags.operator) that defines something.
  definitionOperator: M(ut),
  /// Type-related [operator](#highlight.tags.operator).
  typeOperator: M(ut),
  /// Control-flow [operator](#highlight.tags.operator).
  controlOperator: M(ut),
  /// Program or markup punctuation.
  punctuation: ra,
  /// [Punctuation](#highlight.tags.punctuation) that separates
  /// things.
  separator: M(ra),
  /// Bracket-style [punctuation](#highlight.tags.punctuation).
  bracket: cr,
  /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
  /// tokens).
  angleBracket: M(cr),
  /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
  /// tokens).
  squareBracket: M(cr),
  /// Parentheses (usually `(` and `)` tokens). Subtag of
  /// [bracket](#highlight.tags.bracket).
  paren: M(cr),
  /// Braces (usually `{` and `}` tokens). Subtag of
  /// [bracket](#highlight.tags.bracket).
  brace: M(cr),
  /// Content, for example plain text in XML or markup documents.
  content: gt,
  /// [Content](#highlight.tags.content) that represents a heading.
  heading: pi,
  /// A level 1 [heading](#highlight.tags.heading).
  heading1: M(pi),
  /// A level 2 [heading](#highlight.tags.heading).
  heading2: M(pi),
  /// A level 3 [heading](#highlight.tags.heading).
  heading3: M(pi),
  /// A level 4 [heading](#highlight.tags.heading).
  heading4: M(pi),
  /// A level 5 [heading](#highlight.tags.heading).
  heading5: M(pi),
  /// A level 6 [heading](#highlight.tags.heading).
  heading6: M(pi),
  /// A prose separator (such as a horizontal rule).
  contentSeparator: M(gt),
  /// [Content](#highlight.tags.content) that represents a list.
  list: M(gt),
  /// [Content](#highlight.tags.content) that represents a quote.
  quote: M(gt),
  /// [Content](#highlight.tags.content) that is emphasized.
  emphasis: M(gt),
  /// [Content](#highlight.tags.content) that is styled strong.
  strong: M(gt),
  /// [Content](#highlight.tags.content) that is part of a link.
  link: M(gt),
  /// [Content](#highlight.tags.content) that is styled as code or
  /// monospace.
  monospace: M(gt),
  /// [Content](#highlight.tags.content) that has a strike-through
  /// style.
  strikethrough: M(gt),
  /// Inserted text in a change-tracking format.
  inserted: M(),
  /// Deleted text.
  deleted: M(),
  /// Changed text.
  changed: M(),
  /// An invalid or unsyntactic element.
  invalid: M(),
  /// Metadata or meta-instruction.
  meta: Ln,
  /// [Metadata](#highlight.tags.meta) that applies to the entire
  /// document.
  documentMeta: M(Ln),
  /// [Metadata](#highlight.tags.meta) that annotates or adds
  /// attributes to a given syntactic element.
  annotation: M(Ln),
  /// Processing instruction or preprocessor directive. Subtag of
  /// [meta](#highlight.tags.meta).
  processingInstruction: M(Ln),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
  /// given element is being defined. Expected to be used with the
  /// various [name](#highlight.tags.name) tags.
  definition: Wt.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates that
  /// something is constant. Mostly expected to be used with
  /// [variable names](#highlight.tags.variableName).
  constant: Wt.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
  /// a [variable](#highlight.tags.variableName) or [property
  /// name](#highlight.tags.propertyName) is being called or defined
  /// as a function.
  function: Wt.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
  /// [names](#highlight.tags.name) to indicate that they belong to
  /// the language's standard environment.
  standard: Wt.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
  /// [names](#highlight.tags.name) is local to some scope.
  local: Wt.defineModifier(),
  /// A generic variant [modifier](#highlight.Tag^defineModifier) that
  /// can be used to tag language-specific alternative variants of
  /// some common tag. It is recommended for themes to define special
  /// forms of at least the [string](#highlight.tags.string) and
  /// [variable name](#highlight.tags.variableName) tags, since those
  /// come up a lot.
  special: Wt.defineModifier()
};
vp([
  { tag: z.link, class: "tok-link" },
  { tag: z.heading, class: "tok-heading" },
  { tag: z.emphasis, class: "tok-emphasis" },
  { tag: z.strong, class: "tok-strong" },
  { tag: z.keyword, class: "tok-keyword" },
  { tag: z.atom, class: "tok-atom" },
  { tag: z.bool, class: "tok-bool" },
  { tag: z.url, class: "tok-url" },
  { tag: z.labelName, class: "tok-labelName" },
  { tag: z.inserted, class: "tok-inserted" },
  { tag: z.deleted, class: "tok-deleted" },
  { tag: z.literal, class: "tok-literal" },
  { tag: z.string, class: "tok-string" },
  { tag: z.number, class: "tok-number" },
  { tag: [z.regexp, z.escape, z.special(z.string)], class: "tok-string2" },
  { tag: z.variableName, class: "tok-variableName" },
  { tag: z.local(z.variableName), class: "tok-variableName tok-local" },
  { tag: z.definition(z.variableName), class: "tok-variableName tok-definition" },
  { tag: z.special(z.variableName), class: "tok-variableName2" },
  { tag: z.definition(z.propertyName), class: "tok-propertyName tok-definition" },
  { tag: z.typeName, class: "tok-typeName" },
  { tag: z.namespace, class: "tok-namespace" },
  { tag: z.className, class: "tok-className" },
  { tag: z.macroName, class: "tok-macroName" },
  { tag: z.propertyName, class: "tok-propertyName" },
  { tag: z.operator, class: "tok-operator" },
  { tag: z.comment, class: "tok-comment" },
  { tag: z.meta, class: "tok-meta" },
  { tag: z.invalid, class: "tok-invalid" },
  { tag: z.punctuation, class: "tok-punctuation" }
]);
var Lo;
const Ps = /* @__PURE__ */ new ie();
let xt = class {
  /**
  Construct a language object. If you need to invoke this
  directly, first define a data facet with
  [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
  configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
  to the language's outer syntax node.
  */
  constructor(e, t, i = []) {
    this.data = e, W.prototype.hasOwnProperty("tree") || Object.defineProperty(W.prototype, "tree", { get() {
      return Ue(this);
    } }), this.parser = t, this.extension = [
      hi.of(this),
      W.languageData.of((n, s, o) => n.facet(jc(n, s, o)))
    ].concat(i);
  }
  /**
  Query whether this language is active at the given position.
  */
  isActiveAt(e, t, i = -1) {
    return jc(e, t, i) == this.data;
  }
  /**
  Find the document regions that were parsed using this language.
  The returned regions will _include_ any nested languages rooted
  in this language, when those exist.
  */
  findRegions(e) {
    let t = e.facet(hi);
    if (t?.data == this.data)
      return [{ from: 0, to: e.doc.length }];
    if (!t || !t.allowsNesting)
      return [];
    let i = [], n = (s, o) => {
      if (s.prop(Ps) == this.data) {
        i.push({ from: o, to: o + s.length });
        return;
      }
      let l = s.prop(ie.mounted);
      if (l) {
        if (l.tree.prop(Ps) == this.data) {
          if (l.overlay)
            for (let a of l.overlay)
              i.push({ from: a.from + o, to: a.to + o });
          else
            i.push({ from: o, to: o + s.length });
          return;
        } else if (l.overlay) {
          let a = i.length;
          if (n(l.tree, l.overlay[0].from + o), i.length > a)
            return;
        }
      }
      for (let a = 0; a < s.children.length; a++) {
        let h = s.children[a];
        h instanceof We && n(h, s.positions[a] + o);
      }
    };
    return n(Ue(e), 0), i;
  }
  /**
  Indicates whether this language allows nested languages. The
  default implementation returns true.
  */
  get allowsNesting() {
    return !0;
  }
};
xt.setState = /* @__PURE__ */ V.define();
function jc(r, e, t) {
  let i = r.facet(hi);
  if (!i)
    return null;
  let n = i.data;
  if (i.allowsNesting)
    for (let s = Ue(r).topNode; s; s = s.enter(e, t, Pe.ExcludeBuffers))
      n = s.type.prop(Ps) || n;
  return n;
}
function Ue(r) {
  let e = r.field(xt.state, !1);
  return e ? e.tree : We.empty;
}
let _b = class {
  constructor(e, t = e.length) {
    this.doc = e, this.length = t, this.cursorPos = 0, this.string = "", this.cursor = e.iter();
  }
  syncTo(e) {
    return this.string = this.cursor.next(e - this.cursorPos).value, this.cursorPos = e + this.string.length, this.cursorPos - this.string.length;
  }
  chunk(e) {
    return this.syncTo(e), this.string;
  }
  get lineChunks() {
    return !0;
  }
  read(e, t) {
    let i = this.cursorPos - this.string.length;
    return e < i || t >= this.cursorPos ? this.doc.sliceString(e, t) : this.string.slice(e - i, t - i);
  }
}, fr = null, Bb = class na {
  constructor(e, t, i = [], n, s, o, l, a) {
    this.parser = e, this.state = t, this.fragments = i, this.tree = n, this.treeLen = s, this.viewport = o, this.skipped = l, this.scheduleOn = a, this.parse = null, this.tempSkipped = [];
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new na(e, t, [], We.empty, 0, i, [], null);
  }
  startParse() {
    return this.parser.startParse(new _b(this.state.doc), this.fragments);
  }
  /**
  @internal
  */
  work(e, t) {
    return t != null && t >= this.state.doc.length && (t = void 0), this.tree != We.empty && this.isDone(t ?? this.state.doc.length) ? (this.takeTree(), !0) : this.withContext(() => {
      var i;
      if (typeof e == "number") {
        let n = Date.now() + e;
        e = () => Date.now() > n;
      }
      for (this.parse || (this.parse = this.startParse()), t != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > t) && t < this.state.doc.length && this.parse.stopAt(t); ; ) {
        let n = this.parse.advance();
        if (n)
          if (this.fragments = this.withoutTempSkipped(os.addTree(n, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (i = this.parse.stoppedAt) !== null && i !== void 0 ? i : this.state.doc.length, this.tree = n, this.parse = null, this.treeLen < (t ?? this.state.doc.length))
            this.parse = this.startParse();
          else
            return !0;
        if (e())
          return !1;
      }
    });
  }
  /**
  @internal
  */
  takeTree() {
    let e, t;
    this.parse && (e = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > e) && this.parse.stopAt(e), this.withContext(() => {
      for (; !(t = this.parse.advance()); )
        ;
    }), this.treeLen = e, this.tree = t, this.fragments = this.withoutTempSkipped(os.addTree(this.tree, this.fragments, !0)), this.parse = null);
  }
  withContext(e) {
    let t = fr;
    fr = this;
    try {
      return e();
    } finally {
      fr = t;
    }
  }
  withoutTempSkipped(e) {
    for (let t; t = this.tempSkipped.pop(); )
      e = Gc(e, t.from, t.to);
    return e;
  }
  /**
  @internal
  */
  changes(e, t) {
    let { fragments: i, tree: n, treeLen: s, viewport: o, skipped: l } = this;
    if (this.takeTree(), !e.empty) {
      let a = [];
      if (e.iterChangedRanges((h, c, f, u) => a.push({ fromA: h, toA: c, fromB: f, toB: u })), i = os.applyChanges(i, a), n = We.empty, s = 0, o = { from: e.mapPos(o.from, -1), to: e.mapPos(o.to, 1) }, this.skipped.length) {
        l = [];
        for (let h of this.skipped) {
          let c = e.mapPos(h.from, 1), f = e.mapPos(h.to, -1);
          c < f && l.push({ from: c, to: f });
        }
      }
    }
    return new na(this.parser, t, i, n, s, o, l, this.scheduleOn);
  }
  /**
  @internal
  */
  updateViewport(e) {
    if (this.viewport.from == e.from && this.viewport.to == e.to)
      return !1;
    this.viewport = e;
    let t = this.skipped.length;
    for (let i = 0; i < this.skipped.length; i++) {
      let { from: n, to: s } = this.skipped[i];
      n < e.to && s > e.from && (this.fragments = Gc(this.fragments, n, s), this.skipped.splice(i--, 1));
    }
    return this.skipped.length >= t ? !1 : (this.reset(), !0);
  }
  /**
  @internal
  */
  reset() {
    this.parse && (this.takeTree(), this.parse = null);
  }
  /**
  Notify the parse scheduler that the given region was skipped
  because it wasn't in view, and the parse should be restarted
  when it comes into view.
  */
  skipUntilInView(e, t) {
    this.skipped.push({ from: e, to: t });
  }
  /**
  Returns a parser intended to be used as placeholder when
  asynchronously loading a nested parser. It'll skip its input and
  mark it as not-really-parsed, so that the next update will parse
  it again.
  
  When `until` is given, a reparse will be scheduled when that
  promise resolves.
  */
  static getSkippingParser(e) {
    return new class extends Tb {
      createParse(t, i, n) {
        let s = n[0].from, o = n[n.length - 1].to;
        return {
          parsedPos: s,
          advance() {
            let a = fr;
            if (a) {
              for (let h of n)
                a.tempSkipped.push(h);
              e && (a.scheduleOn = a.scheduleOn ? Promise.all([a.scheduleOn, e]) : e);
            }
            return this.parsedPos = o, new We(Tt.none, [], [], o - s);
          },
          stoppedAt: null,
          stopAt() {
          }
        };
      }
    }();
  }
  /**
  @internal
  */
  isDone(e) {
    e = Math.min(e, this.state.doc.length);
    let t = this.fragments;
    return this.treeLen >= e && t.length && t[0].from == 0 && t[0].to >= e;
  }
  /**
  Get the context for the current parse, or `null` if no editor
  parse is in progress.
  */
  static get() {
    return fr;
  }
};
function Gc(r, e, t) {
  return os.applyChanges(r, [{ fromA: e, toA: t, fromB: e, toB: t }]);
}
let sa = class oa {
  constructor(e) {
    this.context = e, this.tree = e.tree;
  }
  apply(e) {
    if (!e.docChanged && this.tree == this.context.tree)
      return this;
    let t = this.context.changes(e.changes, e.state), i = this.context.treeLen == e.startState.doc.length ? void 0 : Math.max(e.changes.mapPos(this.context.treeLen), t.viewport.to);
    return t.work(20, i) || t.takeTree(), new oa(t);
  }
  static init(e) {
    let t = Math.min(3e3, e.doc.length), i = Bb.create(e.facet(hi).parser, e, { from: 0, to: t });
    return i.work(20, t) || i.takeTree(), new oa(i);
  }
};
xt.state = /* @__PURE__ */ ge.define({
  create: sa.init,
  update(r, e) {
    for (let t of e.effects)
      if (t.is(xt.setState))
        return t.value;
    return e.startState.facet(hi) != e.state.facet(hi) ? sa.init(e.state) : r.apply(e);
  }
});
let $p = (r) => {
  let e = setTimeout(
    () => r(),
    500
    /* MaxPause */
  );
  return () => clearTimeout(e);
};
typeof requestIdleCallback < "u" && ($p = (r) => {
  let e = -1, t = setTimeout(
    () => {
      e = requestIdleCallback(r, {
        timeout: 400
        /* MinPause */
      });
    },
    100
    /* MinPause */
  );
  return () => e < 0 ? clearTimeout(t) : cancelIdleCallback(e);
});
const Eo = typeof navigator < "u" && (!((Lo = navigator.scheduling) === null || Lo === void 0) && Lo.isInputPending) ? () => navigator.scheduling.isInputPending() : null, Ib = /* @__PURE__ */ ue.fromClass(class {
  constructor(e) {
    this.view = e, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
  }
  update(e) {
    let t = this.view.state.field(xt.state).context;
    (t.updateViewport(e.view.viewport) || this.view.viewport.to > t.treeLen) && this.scheduleWork(), e.docChanged && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(t);
  }
  scheduleWork() {
    if (this.working)
      return;
    let { state: e } = this.view, t = e.field(xt.state);
    (t.tree != t.context.tree || !t.context.isDone(e.doc.length)) && (this.working = $p(this.work));
  }
  work(e) {
    this.working = null;
    let t = Date.now();
    if (this.chunkEnd < t && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = t + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
      return;
    let { state: i, viewport: { to: n } } = this.view, s = i.field(xt.state);
    if (s.tree == s.context.tree && s.context.isDone(
      n + 1e5
      /* MaxParseAhead */
    ))
      return;
    let o = Date.now() + Math.min(this.chunkBudget, 100, e && !Eo ? Math.max(25, e.timeRemaining() - 5) : 1e9), l = s.context.treeLen < n && i.doc.length > n + 1e3, a = s.context.work(() => Eo && Eo() || Date.now() > o, n + (l ? 0 : 1e5));
    this.chunkBudget -= Date.now() - t, (a || this.chunkBudget <= 0) && (s.context.takeTree(), this.view.dispatch({ effects: xt.setState.of(new sa(s.context)) })), this.chunkBudget > 0 && !(a && !l) && this.scheduleWork(), this.checkAsyncSchedule(s.context);
  }
  checkAsyncSchedule(e) {
    e.scheduleOn && (this.workScheduled++, e.scheduleOn.then(() => this.scheduleWork()).catch((t) => Qe(this.view.state, t)).then(() => this.workScheduled--), e.scheduleOn = null);
  }
  destroy() {
    this.working && this.working();
  }
  isWorking() {
    return !!(this.working || this.workScheduled > 0);
  }
}, {
  eventHandlers: { focus() {
    this.scheduleWork();
  } }
}), hi = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? r[0] : null;
  },
  enables: [xt.state, Ib]
}), Vb = /* @__PURE__ */ R.define(), Pp = /* @__PURE__ */ R.define({
  combine: (r) => {
    if (!r.length)
      return "  ";
    if (!/^(?: +|\t+)$/.test(r[0]))
      throw new Error("Invalid indent unit: " + JSON.stringify(r[0]));
    return r[0];
  }
});
function qb(r) {
  let e = r.facet(Pp);
  return e.charCodeAt(0) == 9 ? r.tabSize * e.length : e.length;
}
function Yb(r, e) {
  let t = "", i = r.tabSize;
  if (r.facet(Pp).charCodeAt(0) == 9)
    for (; e >= i; )
      t += "	", e -= i;
  for (let n = 0; n < e; n++)
    t += " ";
  return t;
}
function Nb(r, e) {
  r instanceof W && (r = new Cp(r));
  for (let i of r.state.facet(Vb)) {
    let n = i(r, e);
    if (n != null)
      return n;
  }
  let t = Ue(r.state);
  return t ? jb(r, t, e) : null;
}
let Cp = class {
  /**
  Create an indent context.
  */
  constructor(e, t = {}) {
    this.state = e, this.options = t, this.unit = qb(e);
  }
  /**
  Get a description of the line at the given position, taking
  [simulated line
  breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
  into account. If there is such a break at `pos`, the `bias`
  argument determines whether the part of the line line before or
  after the break is used.
  */
  lineAt(e, t = 1) {
    let i = this.state.doc.lineAt(e), { simulateBreak: n, simulateDoubleBreak: s } = this.options;
    return n != null && n >= i.from && n <= i.to ? s && n == e ? { text: "", from: e } : (t < 0 ? n < e : n <= e) ? { text: i.text.slice(n - i.from), from: n } : { text: i.text.slice(0, n - i.from), from: i.from } : i;
  }
  /**
  Get the text directly after `pos`, either the entire line
  or the next 100 characters, whichever is shorter.
  */
  textAfterPos(e, t = 1) {
    if (this.options.simulateDoubleBreak && e == this.options.simulateBreak)
      return "";
    let { text: i, from: n } = this.lineAt(e, t);
    return i.slice(e - n, Math.min(i.length, e + 100 - n));
  }
  /**
  Find the column for the given position.
  */
  column(e, t = 1) {
    let { text: i, from: n } = this.lineAt(e, t), s = this.countColumn(i, e - n), o = this.options.overrideIndentation ? this.options.overrideIndentation(n) : -1;
    return o > -1 && (s += o - this.countColumn(i, i.search(/\S|$/))), s;
  }
  /**
  Find the column position (taking tabs into account) of the given
  position in the given string.
  */
  countColumn(e, t = e.length) {
    return lt(e, this.state.tabSize, t);
  }
  /**
  Find the indentation column of the line at the given point.
  */
  lineIndent(e, t = 1) {
    let { text: i, from: n } = this.lineAt(e, t), s = this.options.overrideIndentation;
    if (s) {
      let o = s(n);
      if (o > -1)
        return o;
    }
    return this.countColumn(i, i.search(/\S|$/));
  }
  /**
  Returns the [simulated line
  break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
  for this context, if any.
  */
  get simulatedBreak() {
    return this.options.simulateBreak || null;
  }
};
const Wb = /* @__PURE__ */ new ie();
function jb(r, e, t) {
  return Tp(e.resolveInner(t).enterUnfinishedNodesBefore(t), t, r);
}
function Gb(r) {
  return r.pos == r.options.simulateBreak && r.options.simulateDoubleBreak;
}
function Ub(r) {
  let e = r.type.prop(Wb);
  if (e)
    return e;
  let t = r.firstChild, i;
  if (t && (i = t.type.prop(ie.closedBy))) {
    let n = r.lastChild, s = n && i.indexOf(n.name) > -1;
    return (o) => ey(o, !0, 1, void 0, s && !Gb(o) ? n.from : void 0);
  }
  return r.parent == null ? Fb : null;
}
function Tp(r, e, t) {
  for (; r; r = r.parent) {
    let i = Ub(r);
    if (i)
      return i(Hb.create(t, e, r));
  }
  return null;
}
function Fb() {
  return 0;
}
let Hb = class Ap extends Cp {
  constructor(e, t, i) {
    super(e.state, e.options), this.base = e, this.pos = t, this.node = i;
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new Ap(e, t, i);
  }
  /**
  Get the text directly after `this.pos`, either the entire line
  or the next 100 characters, whichever is shorter.
  */
  get textAfter() {
    return this.textAfterPos(this.pos);
  }
  /**
  Get the indentation at the reference line for `this.node`, which
  is the line on which it starts, unless there is a node that is
  _not_ a parent of this node covering the start of that line. If
  so, the line at the start of that node is tried, again skipping
  on if it is covered by another such node.
  */
  get baseIndent() {
    let e = this.state.doc.lineAt(this.node.from);
    for (; ; ) {
      let t = this.node.resolve(e.from);
      for (; t.parent && t.parent.from == t.from; )
        t = t.parent;
      if (Kb(t, this.node))
        break;
      e = this.state.doc.lineAt(t.from);
    }
    return this.lineIndent(e.from);
  }
  /**
  Continue looking for indentations in the node's parent nodes,
  and return the result of that.
  */
  continue() {
    let e = this.node.parent;
    return e ? Tp(e, this.pos, this.base) : 0;
  }
};
function Kb(r, e) {
  for (let t = e; t; t = t.parent)
    if (r == t)
      return !0;
  return !1;
}
function Jb(r) {
  let e = r.node, t = e.childAfter(e.from), i = e.lastChild;
  if (!t)
    return null;
  let n = r.options.simulateBreak, s = r.state.doc.lineAt(t.from), o = n == null || n <= s.from ? s.to : Math.min(s.to, n);
  for (let l = t.to; ; ) {
    let a = e.childAfter(l);
    if (!a || a == i)
      return null;
    if (!a.type.isSkipped)
      return a.from < o ? t : null;
    l = a.to;
  }
}
function ey(r, e, t, i, n) {
  let s = r.textAfter, o = s.match(/^\s*/)[0].length, l = i && s.slice(o, o + i.length) == i || n == r.pos + o, a = Jb(r);
  return a ? l ? r.column(a.from) : r.column(a.to) : r.baseIndent + (l ? 0 : r.unit * t);
}
const ty = 200;
function iy() {
  return W.transactionFilter.of((r) => {
    if (!r.docChanged || !r.isUserEvent("input.type") && !r.isUserEvent("input.complete"))
      return r;
    let e = r.startState.languageDataAt("indentOnInput", r.startState.selection.main.head);
    if (!e.length)
      return r;
    let t = r.newDoc, { head: i } = r.newSelection.main, n = t.lineAt(i);
    if (i > n.from + ty)
      return r;
    let s = t.sliceString(n.from, i);
    if (!e.some((h) => h.test(s)))
      return r;
    let { state: o } = r, l = -1, a = [];
    for (let { head: h } of o.selection.ranges) {
      let c = o.doc.lineAt(h);
      if (c.from == l)
        continue;
      l = c.from;
      let f = Nb(o, c.from);
      if (f == null)
        continue;
      let u = /^\s*/.exec(c.text)[0], d = Yb(o, f);
      u != d && a.push({ from: c.from, to: c.from + u.length, insert: d });
    }
    return a.length ? [r, { changes: a, sequential: !0 }] : r;
  });
}
const ry = /* @__PURE__ */ R.define(), ny = /* @__PURE__ */ new ie();
function sy(r, e, t) {
  let i = Ue(r);
  if (i.length < t)
    return null;
  let n = i.resolveInner(t), s = null;
  for (let o = n; o; o = o.parent) {
    if (o.to <= t || o.from > t)
      continue;
    if (s && o.from < e)
      break;
    let l = o.type.prop(ny);
    if (l && (o.to < i.length - 50 || i.length == r.doc.length || !oy(o))) {
      let a = l(o, r);
      a && a.from <= t && a.from >= e && a.to > t && (s = a);
    }
  }
  return s;
}
function oy(r) {
  let e = r.lastChild;
  return e && e.to == r.to && e.type.isError;
}
function Cs(r, e, t) {
  for (let i of r.facet(ry)) {
    let n = i(r, e, t);
    if (n)
      return n;
  }
  return sy(r, e, t);
}
function Mp(r, e) {
  let t = e.mapPos(r.from, 1), i = e.mapPos(r.to, -1);
  return t >= i ? void 0 : { from: t, to: i };
}
const so = /* @__PURE__ */ V.define({ map: Mp }), fn = /* @__PURE__ */ V.define({ map: Mp });
function Zp(r) {
  let e = [];
  for (let { head: t } of r.state.selection.ranges)
    e.some((i) => i.from <= t && i.to >= t) || e.push(r.lineBlockAt(t));
  return e;
}
const Ti = /* @__PURE__ */ ge.define({
  create() {
    return B.none;
  },
  update(r, e) {
    r = r.map(e.changes);
    for (let t of e.effects)
      t.is(so) && !ly(r, t.value.from, t.value.to) ? r = r.update({ add: [Oy.range(t.value.from, t.value.to)] }) : t.is(fn) && (r = r.update({
        filter: (i, n) => t.value.from != i || t.value.to != n,
        filterFrom: t.value.from,
        filterTo: t.value.to
      }));
    if (e.selection) {
      let t = !1, { head: i } = e.selection.main;
      r.between(i, i, (n, s) => {
        n < i && s > i && (t = !0);
      }), t && (r = r.update({
        filterFrom: i,
        filterTo: i,
        filter: (n, s) => s <= i || n >= i
      }));
    }
    return r;
  },
  provide: (r) => D.decorations.from(r)
});
function Ts(r, e, t) {
  var i;
  let n = null;
  return (i = r.field(Ti, !1)) === null || i === void 0 || i.between(e, t, (s, o) => {
    (!n || n.from > s) && (n = { from: s, to: o });
  }), n;
}
function ly(r, e, t) {
  let i = !1;
  return r.between(e, e, (n, s) => {
    n == e && s == t && (i = !0);
  }), i;
}
function Xp(r, e) {
  return r.field(Ti, !1) ? e : e.concat(V.appendConfig.of(Lp()));
}
const ay = (r) => {
  for (let e of Zp(r)) {
    let t = Cs(r.state, e.from, e.to);
    if (t)
      return r.dispatch({ effects: Xp(r.state, [so.of(t), Rp(r, t)]) }), !0;
  }
  return !1;
}, hy = (r) => {
  if (!r.state.field(Ti, !1))
    return !1;
  let e = [];
  for (let t of Zp(r)) {
    let i = Ts(r.state, t.from, t.to);
    i && e.push(fn.of(i), Rp(r, i, !1));
  }
  return e.length && r.dispatch({ effects: e }), e.length > 0;
};
function Rp(r, e, t = !0) {
  let i = r.state.doc.lineAt(e.from).number, n = r.state.doc.lineAt(e.to).number;
  return D.announce.of(`${r.state.phrase(t ? "Folded lines" : "Unfolded lines")} ${i} ${r.state.phrase("to")} ${n}.`);
}
const cy = (r) => {
  let { state: e } = r, t = [];
  for (let i = 0; i < e.doc.length; ) {
    let n = r.lineBlockAt(i), s = Cs(e, n.from, n.to);
    s && t.push(so.of(s)), i = (s ? r.lineBlockAt(s.to) : n).to + 1;
  }
  return t.length && r.dispatch({ effects: Xp(r.state, t) }), !!t.length;
}, fy = (r) => {
  let e = r.state.field(Ti, !1);
  if (!e || !e.size)
    return !1;
  let t = [];
  return e.between(0, r.state.doc.length, (i, n) => {
    t.push(fn.of({ from: i, to: n }));
  }), r.dispatch({ effects: t }), !0;
}, uy = [
  { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: ay },
  { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: hy },
  { key: "Ctrl-Alt-[", run: cy },
  { key: "Ctrl-Alt-]", run: fy }
], dy = {
  placeholderDOM: null,
  placeholderText: "…"
}, py = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, dy);
  }
});
function Lp(r) {
  return [Ti, by];
}
const Oy = /* @__PURE__ */ B.replace({ widget: /* @__PURE__ */ new class extends di {
  toDOM(r) {
    let { state: e } = r, t = e.facet(py), i = (s) => {
      let o = r.lineBlockAt(r.posAtDOM(s.target)), l = Ts(r.state, o.from, o.to);
      l && r.dispatch({ effects: fn.of(l) }), s.preventDefault();
    };
    if (t.placeholderDOM)
      return t.placeholderDOM(r, i);
    let n = document.createElement("span");
    return n.textContent = t.placeholderText, n.setAttribute("aria-label", e.phrase("folded code")), n.title = e.phrase("unfold"), n.className = "cm-foldPlaceholder", n.onclick = i, n;
  }
}() }), my = {
  openText: "⌄",
  closedText: "›",
  markerDOM: null,
  domEventHandlers: {}
};
class zo extends It {
  constructor(e, t) {
    super(), this.config = e, this.open = t;
  }
  eq(e) {
    return this.config == e.config && this.open == e.open;
  }
  toDOM(e) {
    if (this.config.markerDOM)
      return this.config.markerDOM(this.open);
    let t = document.createElement("span");
    return t.textContent = this.open ? this.config.openText : this.config.closedText, t.title = e.state.phrase(this.open ? "Fold line" : "Unfold line"), t;
  }
}
function gy(r = {}) {
  let e = Object.assign(Object.assign({}, my), r), t = new zo(e, !0), i = new zo(e, !1), n = ue.fromClass(class {
    constructor(o) {
      this.from = o.viewport.from, this.markers = this.buildMarkers(o);
    }
    update(o) {
      (o.docChanged || o.viewportChanged || o.startState.facet(hi) != o.state.facet(hi) || o.startState.field(Ti, !1) != o.state.field(Ti, !1) || Ue(o.startState) != Ue(o.state)) && (this.markers = this.buildMarkers(o.view));
    }
    buildMarkers(o) {
      let l = new _t();
      for (let a of o.viewportLineBlocks) {
        let h = Ts(o.state, a.from, a.to) ? i : Cs(o.state, a.from, a.to) ? t : null;
        h && l.add(a.from, a.from, h);
      }
      return l.finish();
    }
  }), { domEventHandlers: s } = e;
  return [
    n,
    ub({
      class: "cm-foldGutter",
      markers(o) {
        var l;
        return ((l = o.plugin(n)) === null || l === void 0 ? void 0 : l.markers) || H.empty;
      },
      initialSpacer() {
        return new zo(e, !1);
      },
      domEventHandlers: Object.assign(Object.assign({}, s), { click: (o, l, a) => {
        if (s.click && s.click(o, l, a))
          return !0;
        let h = Ts(o.state, l.from, l.to);
        if (h)
          return o.dispatch({ effects: fn.of(h) }), !0;
        let c = Cs(o.state, l.from, l.to);
        return c ? (o.dispatch({ effects: so.of(c) }), !0) : !1;
      } })
    }),
    Lp()
  ];
}
const by = /* @__PURE__ */ D.baseTheme({
  ".cm-foldPlaceholder": {
    backgroundColor: "#eee",
    border: "1px solid #ddd",
    color: "#888",
    borderRadius: ".2em",
    margin: "0 1px",
    padding: "0 1px",
    cursor: "pointer"
  },
  ".cm-foldGutter span": {
    padding: "0 1px",
    cursor: "pointer"
  }
});
let Ep = class zp {
  constructor(e, t) {
    let i;
    function n(l) {
      let a = Pt.newName();
      return (i || (i = /* @__PURE__ */ Object.create(null)))["." + a] = l, a;
    }
    const s = typeof t.all == "string" ? t.all : t.all ? n(t.all) : void 0, o = t.scope;
    this.scope = o instanceof xt ? (l) => l.prop(Ps) == o.data : o ? (l) => l == o : void 0, this.style = vp(e.map((l) => ({
      tag: l.tag,
      class: l.class || n(Object.assign({}, l, { tag: null }))
    })), {
      all: s
    }).style, this.module = i ? new Pt(i) : null, this.themeType = t.themeType;
  }
  /**
  Create a highlighter style that associates the given styles to
  the given tags. The specs must be objects that hold a style tag
  or array of tags in their `tag` property, and either a single
  `class` property providing a static CSS class (for highlighter
  that rely on external styling), or a
  [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
  set of CSS properties (which define the styling for those tags).
  
  The CSS rules created for a highlighter will be emitted in the
  order of the spec's properties. That means that for elements that
  have multiple tags associated with them, styles defined further
  down in the list will have a higher CSS precedence than styles
  defined earlier.
  */
  static define(e, t) {
    return new zp(e, t || {});
  }
};
const la = /* @__PURE__ */ R.define(), Dp = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? [r[0]] : null;
  }
});
function Do(r) {
  let e = r.facet(la);
  return e.length ? e : r.facet(Dp);
}
function yy(r, e) {
  let t = [wy], i;
  return r instanceof Ep && (r.module && t.push(D.styleModule.of(r.module)), i = r.themeType), e?.fallback ? t.push(Dp.of(r)) : i ? t.push(la.computeN([D.darkTheme], (n) => n.facet(D.darkTheme) == (i == "dark") ? [r] : [])) : t.push(la.of(r)), t;
}
let Sy = class {
  constructor(e) {
    this.markCache = /* @__PURE__ */ Object.create(null), this.tree = Ue(e.state), this.decorations = this.buildDeco(e, Do(e.state));
  }
  update(e) {
    let t = Ue(e.state), i = Do(e.state), n = i != Do(e.startState);
    t.length < e.view.viewport.to && !n && t.type == this.tree.type ? this.decorations = this.decorations.map(e.changes) : (t != this.tree || e.viewportChanged || n) && (this.tree = t, this.decorations = this.buildDeco(e.view, i));
  }
  buildDeco(e, t) {
    if (!t || !this.tree.length)
      return B.none;
    let i = new _t();
    for (let { from: n, to: s } of e.visibleRanges)
      zb(this.tree, t, (o, l, a) => {
        i.add(o, l, this.markCache[a] || (this.markCache[a] = B.mark({ class: a })));
      }, n, s);
    return i.finish();
  }
};
const wy = /* @__PURE__ */ Vt.high(/* @__PURE__ */ ue.fromClass(Sy, {
  decorations: (r) => r.decorations
})), xy = /* @__PURE__ */ Ep.define([
  {
    tag: z.meta,
    color: "#7a757a"
  },
  {
    tag: z.link,
    textDecoration: "underline"
  },
  {
    tag: z.heading,
    textDecoration: "underline",
    fontWeight: "bold"
  },
  {
    tag: z.emphasis,
    fontStyle: "italic"
  },
  {
    tag: z.strong,
    fontWeight: "bold"
  },
  {
    tag: z.strikethrough,
    textDecoration: "line-through"
  },
  {
    tag: z.keyword,
    color: "#708"
  },
  {
    tag: [z.atom, z.bool, z.url, z.contentSeparator, z.labelName],
    color: "#219"
  },
  {
    tag: [z.literal, z.inserted],
    color: "#164"
  },
  {
    tag: [z.string, z.deleted],
    color: "#a11"
  },
  {
    tag: [z.regexp, z.escape, /* @__PURE__ */ z.special(z.string)],
    color: "#e40"
  },
  {
    tag: /* @__PURE__ */ z.definition(z.variableName),
    color: "#00f"
  },
  {
    tag: /* @__PURE__ */ z.local(z.variableName),
    color: "#30a"
  },
  {
    tag: [z.typeName, z.namespace],
    color: "#085"
  },
  {
    tag: z.className,
    color: "#167"
  },
  {
    tag: [/* @__PURE__ */ z.special(z.variableName), z.macroName],
    color: "#256"
  },
  {
    tag: /* @__PURE__ */ z.definition(z.propertyName),
    color: "#00c"
  },
  {
    tag: z.comment,
    color: "#940"
  },
  {
    tag: z.invalid,
    color: "#f00"
  }
]), ky = /* @__PURE__ */ D.baseTheme({
  "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
  "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
}), _p = 1e4, Bp = "()[]{}", Ip = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, {
      afterCursor: !0,
      brackets: Bp,
      maxScanDistance: _p,
      renderMatch: $y
    });
  }
}), Qy = /* @__PURE__ */ B.mark({ class: "cm-matchingBracket" }), vy = /* @__PURE__ */ B.mark({ class: "cm-nonmatchingBracket" });
function $y(r) {
  let e = [], t = r.matched ? Qy : vy;
  return e.push(t.range(r.start.from, r.start.to)), r.end && e.push(t.range(r.end.from, r.end.to)), e;
}
const Py = /* @__PURE__ */ ge.define({
  create() {
    return B.none;
  },
  update(r, e) {
    if (!e.docChanged && !e.selection)
      return r;
    let t = [], i = e.state.facet(Ip);
    for (let n of e.state.selection.ranges) {
      if (!n.empty)
        continue;
      let s = En(e.state, n.head, -1, i) || n.head > 0 && En(e.state, n.head - 1, 1, i) || i.afterCursor && (En(e.state, n.head, 1, i) || n.head < e.state.doc.length && En(e.state, n.head + 1, -1, i));
      s && (t = t.concat(i.renderMatch(s, e.state)));
    }
    return B.set(t, !0);
  },
  provide: (r) => D.decorations.from(r)
}), Cy = [
  Py,
  ky
];
function Ty(r = {}) {
  return [Ip.of(r), Cy];
}
function aa(r, e, t) {
  let i = r.prop(e < 0 ? ie.openedBy : ie.closedBy);
  if (i)
    return i;
  if (r.name.length == 1) {
    let n = t.indexOf(r.name);
    if (n > -1 && n % 2 == (e < 0 ? 1 : 0))
      return [t[n + e]];
  }
  return null;
}
function En(r, e, t, i = {}) {
  let n = i.maxScanDistance || _p, s = i.brackets || Bp, o = Ue(r), l = o.resolveInner(e, t);
  for (let a = l; a; a = a.parent) {
    let h = aa(a.type, t, s);
    if (h && a.from < a.to)
      return Ay(r, e, t, a, h, s);
  }
  return My(r, e, t, o, l.type, n, s);
}
function Ay(r, e, t, i, n, s) {
  let o = i.parent, l = { from: i.from, to: i.to }, a = 0, h = o?.cursor();
  if (h && (t < 0 ? h.childBefore(i.from) : h.childAfter(i.to)))
    do
      if (t < 0 ? h.to <= i.from : h.from >= i.to) {
        if (a == 0 && n.indexOf(h.type.name) > -1 && h.from < h.to)
          return { start: l, end: { from: h.from, to: h.to }, matched: !0 };
        if (aa(h.type, t, s))
          a++;
        else if (aa(h.type, -t, s) && (a--, a == 0))
          return {
            start: l,
            end: h.from == h.to ? void 0 : { from: h.from, to: h.to },
            matched: !1
          };
      }
    while (t < 0 ? h.prevSibling() : h.nextSibling());
  return { start: l, matched: !1 };
}
function My(r, e, t, i, n, s, o) {
  let l = t < 0 ? r.sliceDoc(e - 1, e) : r.sliceDoc(e, e + 1), a = o.indexOf(l);
  if (a < 0 || a % 2 == 0 != t > 0)
    return null;
  let h = { from: t < 0 ? e - 1 : e, to: t > 0 ? e + 1 : e }, c = r.doc.iterRange(e, t > 0 ? r.doc.length : 0), f = 0;
  for (let u = 0; !c.next().done && u <= s; ) {
    let d = c.value;
    t < 0 && (u += d.length);
    let p = e + u * t;
    for (let O = t > 0 ? 0 : d.length - 1, g = t > 0 ? d.length : -1; O != g; O += t) {
      let b = o.indexOf(d[O]);
      if (!(b < 0 || i.resolve(p + O, 1).type != n))
        if (b % 2 == 0 == t > 0)
          f++;
        else {
          if (f == 1)
            return { start: h, end: { from: p + O, to: p + O + 1 }, matched: b >> 1 == a >> 1 };
          f--;
        }
    }
    t > 0 && (u += d.length);
  }
  return c.done ? { start: h, matched: !1 } : null;
}
const Zy = /* @__PURE__ */ Object.create(null), Uc = [Tt.none], Fc = [], Xy = /* @__PURE__ */ Object.create(null);
for (let [r, e] of [
  ["variable", "variableName"],
  ["variable-2", "variableName.special"],
  ["string-2", "string.special"],
  ["def", "variableName.definition"],
  ["tag", "typeName"],
  ["attribute", "propertyName"],
  ["type", "typeName"],
  ["builtin", "variableName.standard"],
  ["qualifier", "modifier"],
  ["error", "invalid"],
  ["header", "heading"],
  ["property", "propertyName"]
])
  Xy[r] = /* @__PURE__ */ Ry(Zy, e);
function _o(r, e) {
  Fc.indexOf(r) > -1 || (Fc.push(r), console.warn(e));
}
function Ry(r, e) {
  let t = null;
  for (let s of e.split(".")) {
    let o = r[s] || z[s];
    o ? typeof o == "function" ? t ? t = o(t) : _o(s, `Modifier ${s} used at start of tag`) : t ? _o(s, `Tag ${s} used as modifier`) : t = o : _o(s, `Unknown highlighting tag ${s}`);
  }
  if (!t)
    return 0;
  let i = e.replace(/ /g, "_"), n = Tt.define({
    id: Uc.length,
    name: i,
    props: [Rb({ [i]: t })]
  });
  return Uc.push(n), n.id;
}
const Ly = 1024;
let Ey = 0, Bo = class {
  constructor(e, t) {
    this.from = e, this.to = t;
  }
}, ee = class {
  /// Create a new node prop type.
  constructor(e = {}) {
    this.id = Ey++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
      throw new Error("This node type doesn't define a deserialize function");
    });
  }
  /// This is meant to be used with
  /// [`NodeSet.extend`](#common.NodeSet.extend) or
  /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
  /// prop values for each node type in the set. Takes a [match
  /// object](#common.NodeType^match) or function that returns undefined
  /// if the node type doesn't get this prop, and the prop's value if
  /// it does.
  add(e) {
    if (this.perNode)
      throw new RangeError("Can't add per-node props to node types");
    return typeof e != "function" && (e = At.match(e)), (t) => {
      let i = e(t);
      return i === void 0 ? null : [this, i];
    };
  }
};
ee.closedBy = new ee({ deserialize: (r) => r.split(" ") });
ee.openedBy = new ee({ deserialize: (r) => r.split(" ") });
ee.group = new ee({ deserialize: (r) => r.split(" ") });
ee.contextHash = new ee({ perNode: !0 });
ee.lookAhead = new ee({ perNode: !0 });
ee.mounted = new ee({ perNode: !0 });
const zy = /* @__PURE__ */ Object.create(null);
let At = class Vp {
  /// @internal
  constructor(e, t, i, n = 0) {
    this.name = e, this.props = t, this.id = i, this.flags = n;
  }
  static define(e) {
    let t = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : zy, i = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new Vp(e.name || "", t, e.id, i);
    if (e.props) {
      for (let s of e.props)
        if (Array.isArray(s) || (s = s(n)), s) {
          if (s[0].perNode)
            throw new RangeError("Can't store a per-node prop on a node type");
          t[s[0].id] = s[1];
        }
    }
    return n;
  }
  /// Retrieves a node prop for this type. Will return `undefined` if
  /// the prop isn't present on this node.
  prop(e) {
    return this.props[e.id];
  }
  /// True when this is the top node of a grammar.
  get isTop() {
    return (this.flags & 1) > 0;
  }
  /// True when this node is produced by a skip rule.
  get isSkipped() {
    return (this.flags & 2) > 0;
  }
  /// Indicates whether this is an error node.
  get isError() {
    return (this.flags & 4) > 0;
  }
  /// When true, this node type doesn't correspond to a user-declared
  /// named node, for example because it is used to cache repetition.
  get isAnonymous() {
    return (this.flags & 8) > 0;
  }
  /// Returns true when this node's name or one of its
  /// [groups](#common.NodeProp^group) matches the given string.
  is(e) {
    if (typeof e == "string") {
      if (this.name == e)
        return !0;
      let t = this.prop(ee.group);
      return t ? t.indexOf(e) > -1 : !1;
    }
    return this.id == e;
  }
  /// Create a function from node types to arbitrary values by
  /// specifying an object whose property names are node or
  /// [group](#common.NodeProp^group) names. Often useful with
  /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
  /// names, separated by spaces, in a single property name to map
  /// multiple node names to a single value.
  static match(e) {
    let t = /* @__PURE__ */ Object.create(null);
    for (let i in e)
      for (let n of i.split(" "))
        t[n] = e[i];
    return (i) => {
      for (let n = i.prop(ee.group), s = -1; s < (n ? n.length : 0); s++) {
        let o = t[s < 0 ? i.name : n[s]];
        if (o)
          return o;
      }
    };
  }
};
At.none = new At(
  "",
  /* @__PURE__ */ Object.create(null),
  0,
  8
  /* Anonymous */
);
const zn = /* @__PURE__ */ new WeakMap(), Hc = /* @__PURE__ */ new WeakMap();
var Ce;
(function(r) {
  r[r.ExcludeBuffers = 1] = "ExcludeBuffers", r[r.IncludeAnonymous = 2] = "IncludeAnonymous", r[r.IgnoreMounts = 4] = "IgnoreMounts", r[r.IgnoreOverlays = 8] = "IgnoreOverlays";
})(Ce || (Ce = {}));
let je = class ha {
  /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
  constructor(e, t, i, n, s) {
    if (this.type = e, this.children = t, this.positions = i, this.length = n, this.props = null, s && s.length) {
      this.props = /* @__PURE__ */ Object.create(null);
      for (let [o, l] of s)
        this.props[typeof o == "number" ? o : o.id] = l;
    }
  }
  /// @internal
  toString() {
    let e = this.prop(ee.mounted);
    if (e && !e.overlay)
      return e.tree.toString();
    let t = "";
    for (let i of this.children) {
      let n = i.toString();
      n && (t && (t += ","), t += n);
    }
    return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (t.length ? "(" + t + ")" : "") : t;
  }
  /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
  /// the tree. Mode can be used to [control](#common.IterMode) which
  /// nodes the cursor visits.
  cursor(e = 0) {
    return new Zs(this.topNode, e);
  }
  /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
  /// at the given position and side (see
  /// [`moveTo`](#common.TreeCursor.moveTo).
  cursorAt(e, t = 0, i = 0) {
    let n = zn.get(this) || this.topNode, s = new Zs(n);
    return s.moveTo(e, t), zn.set(this, s._tree), s;
  }
  /// Get a [syntax node](#common.SyntaxNode) object for the top of the
  /// tree.
  get topNode() {
    return new jr(this, 0, 0, null);
  }
  /// Get the [syntax node](#common.SyntaxNode) at the given position.
  /// If `side` is -1, this will move into nodes that end at the
  /// position. If 1, it'll move into nodes that start at the
  /// position. With 0, it'll only enter nodes that cover the position
  /// from both sides.
  resolve(e, t = 0) {
    let i = ji(zn.get(this) || this.topNode, e, t, !1);
    return zn.set(this, i), i;
  }
  /// Like [`resolve`](#common.Tree.resolve), but will enter
  /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
  /// pointing into the innermost overlaid tree at the given position
  /// (with parent links going through all parent structure, including
  /// the host trees).
  resolveInner(e, t = 0) {
    let i = ji(Hc.get(this) || this.topNode, e, t, !0);
    return Hc.set(this, i), i;
  }
  /// Iterate over the tree and its children, calling `enter` for any
  /// node that touches the `from`/`to` region (if given) before
  /// running over such a node's children, and `leave` (if given) when
  /// leaving the node. When `enter` returns `false`, that node will
  /// not have its children iterated over (or `leave` called).
  iterate(e) {
    let { enter: t, leave: i, from: n = 0, to: s = this.length } = e;
    for (let o = this.cursor((e.mode || 0) | Ce.IncludeAnonymous); ; ) {
      let l = !1;
      if (o.from <= s && o.to >= n && (o.type.isAnonymous || t(o) !== !1)) {
        if (o.firstChild())
          continue;
        l = !0;
      }
      for (; l && i && !o.type.isAnonymous && i(o), !o.nextSibling(); ) {
        if (!o.parent())
          return;
        l = !0;
      }
    }
  }
  /// Get the value of the given [node prop](#common.NodeProp) for this
  /// node. Works with both per-node and per-type props.
  prop(e) {
    return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
  }
  /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
  /// format that can be passed to the [`Tree`](#common.Tree)
  /// constructor.
  get propValues() {
    let e = [];
    if (this.props)
      for (let t in this.props)
        e.push([+t, this.props[t]]);
    return e;
  }
  /// Balance the direct children of this tree, producing a copy of
  /// which may have children grouped into subtrees with type
  /// [`NodeType.none`](#common.NodeType^none).
  balance(e = {}) {
    return this.children.length <= 8 ? this : ih(At.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, i, n) => new ha(this.type, t, i, n, this.propValues), e.makeTree || ((t, i, n) => new ha(At.none, t, i, n)));
  }
  /// Build a tree from a postfix-ordered buffer of node information,
  /// or a cursor over such a buffer.
  static build(e) {
    return By(e);
  }
};
je.empty = new je(At.none, [], [], 0);
let Dy = class qp {
  constructor(e, t) {
    this.buffer = e, this.index = t;
  }
  get id() {
    return this.buffer[this.index - 4];
  }
  get start() {
    return this.buffer[this.index - 3];
  }
  get end() {
    return this.buffer[this.index - 2];
  }
  get size() {
    return this.buffer[this.index - 1];
  }
  get pos() {
    return this.index;
  }
  next() {
    this.index -= 4;
  }
  fork() {
    return new qp(this.buffer, this.index);
  }
}, un = class Yp {
  /// Create a tree buffer.
  constructor(e, t, i) {
    this.buffer = e, this.length = t, this.set = i;
  }
  /// @internal
  get type() {
    return At.none;
  }
  /// @internal
  toString() {
    let e = [];
    for (let t = 0; t < this.buffer.length; )
      e.push(this.childString(t)), t = this.buffer[t + 3];
    return e.join(",");
  }
  /// @internal
  childString(e) {
    let t = this.buffer[e], i = this.buffer[e + 3], n = this.set.types[t], s = n.name;
    if (/\W/.test(s) && !n.isError && (s = JSON.stringify(s)), e += 4, i == e)
      return s;
    let o = [];
    for (; e < i; )
      o.push(this.childString(e)), e = this.buffer[e + 3];
    return s + "(" + o.join(",") + ")";
  }
  /// @internal
  findChild(e, t, i, n, s) {
    let { buffer: o } = this, l = -1;
    for (let a = e; a != t && !(Np(s, n, o[a + 1], o[a + 2]) && (l = a, i > 0)); a = o[a + 3])
      ;
    return l;
  }
  /// @internal
  slice(e, t, i, n) {
    let s = this.buffer, o = new Uint16Array(t - e);
    for (let l = e, a = 0; l < t; )
      o[a++] = s[l++], o[a++] = s[l++] - i, o[a++] = s[l++] - i, o[a++] = s[l++] - e;
    return new Yp(o, n - i, this.set);
  }
};
function Np(r, e, t, i) {
  switch (r) {
    case -2:
      return t < e;
    case -1:
      return i >= e && t < e;
    case 0:
      return t < e && i > e;
    case 1:
      return t <= e && i > e;
    case 2:
      return i > e;
    case 4:
      return !0;
  }
}
function Wp(r, e) {
  let t = r.childBefore(e);
  for (; t; ) {
    let i = t.lastChild;
    if (!i || i.to != t.to)
      break;
    i.type.isError && i.from == i.to ? (r = t, t = i.prevSibling) : t = i;
  }
  return r;
}
function ji(r, e, t, i) {
  for (var n; r.from == r.to || (t < 1 ? r.from >= e : r.from > e) || (t > -1 ? r.to <= e : r.to < e); ) {
    let o = !i && r instanceof jr && r.index < 0 ? null : r.parent;
    if (!o)
      return r;
    r = o;
  }
  let s = i ? 0 : Ce.IgnoreOverlays;
  if (i)
    for (let o = r, l = o.parent; l; o = l, l = o.parent)
      o instanceof jr && o.index < 0 && ((n = l.enter(e, t, s)) === null || n === void 0 ? void 0 : n.from) != o.from && (r = l);
  for (; ; ) {
    let o = r.enter(e, t, s);
    if (!o)
      return r;
    r = o;
  }
}
let jr = class ls {
  constructor(e, t, i, n) {
    this._tree = e, this.from = t, this.index = i, this._parent = n;
  }
  get type() {
    return this._tree.type;
  }
  get name() {
    return this._tree.type.name;
  }
  get to() {
    return this.from + this._tree.length;
  }
  nextChild(e, t, i, n, s = 0) {
    for (let o = this; ; ) {
      for (let { children: l, positions: a } = o._tree, h = t > 0 ? l.length : -1; e != h; e += t) {
        let c = l[e], f = a[e] + o.from;
        if (Np(n, i, f, f + c.length)) {
          if (c instanceof un) {
            if (s & Ce.ExcludeBuffers)
              continue;
            let u = c.findChild(0, c.buffer.length, t, i - f, n);
            if (u > -1)
              return new ca(new _y(o, c, e, f), null, u);
          } else if (s & Ce.IncludeAnonymous || !c.type.isAnonymous || th(c)) {
            let u;
            if (!(s & Ce.IgnoreMounts) && c.props && (u = c.prop(ee.mounted)) && !u.overlay)
              return new ls(u.tree, f, e, o);
            let d = new ls(c, f, e, o);
            return s & Ce.IncludeAnonymous || !d.type.isAnonymous ? d : d.nextChild(t < 0 ? c.children.length - 1 : 0, t, i, n);
          }
        }
      }
      if (s & Ce.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? e = o.index + t : e = t < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
        return null;
    }
  }
  get firstChild() {
    return this.nextChild(
      0,
      1,
      0,
      4
      /* DontCare */
    );
  }
  get lastChild() {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      0,
      4
      /* DontCare */
    );
  }
  childAfter(e) {
    return this.nextChild(
      0,
      1,
      e,
      2
      /* After */
    );
  }
  childBefore(e) {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      e,
      -2
      /* Before */
    );
  }
  enter(e, t, i = 0) {
    let n;
    if (!(i & Ce.IgnoreOverlays) && (n = this._tree.prop(ee.mounted)) && n.overlay) {
      let s = e - this.from;
      for (let { from: o, to: l } of n.overlay)
        if ((t > 0 ? o <= s : o < s) && (t < 0 ? l >= s : l > s))
          return new ls(n.tree, n.overlay[0].from + this.from, -1, this);
    }
    return this.nextChild(0, 1, e, t, i);
  }
  nextSignificantParent() {
    let e = this;
    for (; e.type.isAnonymous && e._parent; )
      e = e._parent;
    return e;
  }
  get parent() {
    return this._parent ? this._parent.nextSignificantParent() : null;
  }
  get nextSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index + 1,
      1,
      0,
      4
      /* DontCare */
    ) : null;
  }
  get prevSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index - 1,
      -1,
      0,
      4
      /* DontCare */
    ) : null;
  }
  cursor(e = 0) {
    return new Zs(this, e);
  }
  get tree() {
    return this._tree;
  }
  toTree() {
    return this._tree;
  }
  resolve(e, t = 0) {
    return ji(this, e, t, !1);
  }
  resolveInner(e, t = 0) {
    return ji(this, e, t, !0);
  }
  enterUnfinishedNodesBefore(e) {
    return Wp(this, e);
  }
  getChild(e, t = null, i = null) {
    let n = As(this, e, t, i);
    return n.length ? n[0] : null;
  }
  getChildren(e, t = null, i = null) {
    return As(this, e, t, i);
  }
  /// @internal
  toString() {
    return this._tree.toString();
  }
  get node() {
    return this;
  }
  matchContext(e) {
    return Ms(this, e);
  }
};
function As(r, e, t, i) {
  let n = r.cursor(), s = [];
  if (!n.firstChild())
    return s;
  if (t != null) {
    for (; !n.type.is(t); )
      if (!n.nextSibling())
        return s;
  }
  for (; ; ) {
    if (i != null && n.type.is(i))
      return s;
    if (n.type.is(e) && s.push(n.node), !n.nextSibling())
      return i == null ? s : [];
  }
}
function Ms(r, e, t = e.length - 1) {
  for (let i = r.parent; t >= 0; i = i.parent) {
    if (!i)
      return !1;
    if (!i.type.isAnonymous) {
      if (e[t] && e[t] != i.name)
        return !1;
      t--;
    }
  }
  return !0;
}
let _y = class {
  constructor(e, t, i, n) {
    this.parent = e, this.buffer = t, this.index = i, this.start = n;
  }
}, ca = class vr {
  constructor(e, t, i) {
    this.context = e, this._parent = t, this.index = i, this.type = e.buffer.set.types[e.buffer.buffer[i]];
  }
  get name() {
    return this.type.name;
  }
  get from() {
    return this.context.start + this.context.buffer.buffer[this.index + 1];
  }
  get to() {
    return this.context.start + this.context.buffer.buffer[this.index + 2];
  }
  child(e, t, i) {
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.context.start, i);
    return s < 0 ? null : new vr(this.context, this, s);
  }
  get firstChild() {
    return this.child(
      1,
      0,
      4
      /* DontCare */
    );
  }
  get lastChild() {
    return this.child(
      -1,
      0,
      4
      /* DontCare */
    );
  }
  childAfter(e) {
    return this.child(
      1,
      e,
      2
      /* After */
    );
  }
  childBefore(e) {
    return this.child(
      -1,
      e,
      -2
      /* Before */
    );
  }
  enter(e, t, i = 0) {
    if (i & Ce.ExcludeBuffers)
      return null;
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], t > 0 ? 1 : -1, e - this.context.start, t);
    return s < 0 ? null : new vr(this.context, this, s);
  }
  get parent() {
    return this._parent || this.context.parent.nextSignificantParent();
  }
  externalSibling(e) {
    return this._parent ? null : this.context.parent.nextChild(
      this.context.index + e,
      e,
      0,
      4
      /* DontCare */
    );
  }
  get nextSibling() {
    let { buffer: e } = this.context, t = e.buffer[this.index + 3];
    return t < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new vr(this.context, this._parent, t) : this.externalSibling(1);
  }
  get prevSibling() {
    let { buffer: e } = this.context, t = this._parent ? this._parent.index + 4 : 0;
    return this.index == t ? this.externalSibling(-1) : new vr(this.context, this._parent, e.findChild(
      t,
      this.index,
      -1,
      0,
      4
      /* DontCare */
    ));
  }
  cursor(e = 0) {
    return new Zs(this, e);
  }
  get tree() {
    return null;
  }
  toTree() {
    let e = [], t = [], { buffer: i } = this.context, n = this.index + 4, s = i.buffer[this.index + 3];
    if (s > n) {
      let o = i.buffer[this.index + 1], l = i.buffer[this.index + 2];
      e.push(i.slice(n, s, o, l)), t.push(0);
    }
    return new je(this.type, e, t, this.to - this.from);
  }
  resolve(e, t = 0) {
    return ji(this, e, t, !1);
  }
  resolveInner(e, t = 0) {
    return ji(this, e, t, !0);
  }
  enterUnfinishedNodesBefore(e) {
    return Wp(this, e);
  }
  /// @internal
  toString() {
    return this.context.buffer.childString(this.index);
  }
  getChild(e, t = null, i = null) {
    let n = As(this, e, t, i);
    return n.length ? n[0] : null;
  }
  getChildren(e, t = null, i = null) {
    return As(this, e, t, i);
  }
  get node() {
    return this;
  }
  matchContext(e) {
    return Ms(this, e);
  }
}, Zs = class {
  /// @internal
  constructor(e, t = 0) {
    if (this.mode = t, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, e instanceof jr)
      this.yieldNode(e);
    else {
      this._tree = e.context.parent, this.buffer = e.context;
      for (let i = e._parent; i; i = i._parent)
        this.stack.unshift(i.index);
      this.bufferNode = e, this.yieldBuf(e.index);
    }
  }
  /// Shorthand for `.type.name`.
  get name() {
    return this.type.name;
  }
  yieldNode(e) {
    return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, !0) : !1;
  }
  yieldBuf(e, t) {
    this.index = e;
    let { start: i, buffer: n } = this.buffer;
    return this.type = t || n.set.types[n.buffer[e]], this.from = i + n.buffer[e + 1], this.to = i + n.buffer[e + 2], !0;
  }
  yield(e) {
    return e ? e instanceof jr ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : !1;
  }
  /// @internal
  toString() {
    return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
  }
  /// @internal
  enterChild(e, t, i) {
    if (!this.buffer)
      return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, i, this.mode));
    let { buffer: n } = this.buffer, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.buffer.start, i);
    return s < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(s));
  }
  /// Move the cursor to this node's first child. When this returns
  /// false, the node has no child, and the cursor has not been moved.
  firstChild() {
    return this.enterChild(
      1,
      0,
      4
      /* DontCare */
    );
  }
  /// Move the cursor to this node's last child.
  lastChild() {
    return this.enterChild(
      -1,
      0,
      4
      /* DontCare */
    );
  }
  /// Move the cursor to the first child that ends after `pos`.
  childAfter(e) {
    return this.enterChild(
      1,
      e,
      2
      /* After */
    );
  }
  /// Move to the last child that starts before `pos`.
  childBefore(e) {
    return this.enterChild(
      -1,
      e,
      -2
      /* Before */
    );
  }
  /// Move the cursor to the child around `pos`. If side is -1 the
  /// child may end at that position, when 1 it may start there. This
  /// will also enter [overlaid](#common.MountedTree.overlay)
  /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
  /// set to false.
  enter(e, t, i = this.mode) {
    return this.buffer ? i & Ce.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, i));
  }
  /// Move to the node's parent node, if this isn't the top node.
  parent() {
    if (!this.buffer)
      return this.yieldNode(this.mode & Ce.IncludeAnonymous ? this._tree._parent : this._tree.parent);
    if (this.stack.length)
      return this.yieldBuf(this.stack.pop());
    let e = this.mode & Ce.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
    return this.buffer = null, this.yieldNode(e);
  }
  /// @internal
  sibling(e) {
    if (!this.buffer)
      return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : !1;
    let { buffer: t } = this.buffer, i = this.stack.length - 1;
    if (e < 0) {
      let n = i < 0 ? 0 : this.stack[i] + 4;
      if (this.index != n)
        return this.yieldBuf(t.findChild(
          n,
          this.index,
          -1,
          0,
          4
          /* DontCare */
        ));
    } else {
      let n = t.buffer[this.index + 3];
      if (n < (i < 0 ? t.buffer.length : t.buffer[this.stack[i] + 3]))
        return this.yieldBuf(n);
    }
    return i < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : !1;
  }
  /// Move to this node's next sibling, if any.
  nextSibling() {
    return this.sibling(1);
  }
  /// Move to this node's previous sibling, if any.
  prevSibling() {
    return this.sibling(-1);
  }
  atLastNode(e) {
    let t, i, { buffer: n } = this;
    if (n) {
      if (e > 0) {
        if (this.index < n.buffer.buffer.length)
          return !1;
      } else
        for (let s = 0; s < this.index; s++)
          if (n.buffer.buffer[s + 3] < this.index)
            return !1;
      ({ index: t, parent: i } = n);
    } else
      ({ index: t, _parent: i } = this._tree);
    for (; i; { index: t, _parent: i } = i)
      if (t > -1)
        for (let s = t + e, o = e < 0 ? -1 : i._tree.children.length; s != o; s += e) {
          let l = i._tree.children[s];
          if (this.mode & Ce.IncludeAnonymous || l instanceof un || !l.type.isAnonymous || th(l))
            return !1;
        }
    return !0;
  }
  move(e, t) {
    if (t && this.enterChild(
      e,
      0,
      4
      /* DontCare */
    ))
      return !0;
    for (; ; ) {
      if (this.sibling(e))
        return !0;
      if (this.atLastNode(e) || !this.parent())
        return !1;
    }
  }
  /// Move to the next node in a
  /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
  /// traversal, going from a node to its first child or, if the
  /// current node is empty or `enter` is false, its next sibling or
  /// the next sibling of the first parent node that has one.
  next(e = !0) {
    return this.move(1, e);
  }
  /// Move to the next node in a last-to-first pre-order traveral. A
  /// node is followed by its last child or, if it has none, its
  /// previous sibling or the previous sibling of the first parent
  /// node that has one.
  prev(e = !0) {
    return this.move(-1, e);
  }
  /// Move the cursor to the innermost node that covers `pos`. If
  /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
  /// it will enter nodes that start at `pos`.
  moveTo(e, t = 0) {
    for (; (this.from == this.to || (t < 1 ? this.from >= e : this.from > e) || (t > -1 ? this.to <= e : this.to < e)) && this.parent(); )
      ;
    for (; this.enterChild(1, e, t); )
      ;
    return this;
  }
  /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
  /// position.
  get node() {
    if (!this.buffer)
      return this._tree;
    let e = this.bufferNode, t = null, i = 0;
    if (e && e.context == this.buffer)
      e: for (let n = this.index, s = this.stack.length; s >= 0; ) {
        for (let o = e; o; o = o._parent)
          if (o.index == n) {
            if (n == this.index)
              return o;
            t = o, i = s + 1;
            break e;
          }
        n = this.stack[--s];
      }
    for (let n = i; n < this.stack.length; n++)
      t = new ca(this.buffer, t, this.stack[n]);
    return this.bufferNode = new ca(this.buffer, t, this.index);
  }
  /// Get the [tree](#common.Tree) that represents the current node, if
  /// any. Will return null when the node is in a [tree
  /// buffer](#common.TreeBuffer).
  get tree() {
    return this.buffer ? null : this._tree._tree;
  }
  /// Iterate over the current node and all its descendants, calling
  /// `enter` when entering a node and `leave`, if given, when leaving
  /// one. When `enter` returns `false`, any children of that node are
  /// skipped, and `leave` isn't called for it.
  iterate(e, t) {
    for (let i = 0; ; ) {
      let n = !1;
      if (this.type.isAnonymous || e(this) !== !1) {
        if (this.firstChild()) {
          i++;
          continue;
        }
        this.type.isAnonymous || (n = !0);
      }
      for (; n && t && t(this), n = this.type.isAnonymous, !this.nextSibling(); ) {
        if (!i)
          return;
        this.parent(), i--, n = !0;
      }
    }
  }
  /// Test whether the current node matches a given context—a sequence
  /// of direct parent node names. Empty strings in the context array
  /// are treated as wildcards.
  matchContext(e) {
    if (!this.buffer)
      return Ms(this.node, e);
    let { buffer: t } = this.buffer, { types: i } = t.set;
    for (let n = e.length - 1, s = this.stack.length - 1; n >= 0; s--) {
      if (s < 0)
        return Ms(this.node, e, n);
      let o = i[t.buffer[this.stack[s]]];
      if (!o.isAnonymous) {
        if (e[n] && e[n] != o.name)
          return !1;
        n--;
      }
    }
    return !0;
  }
};
function th(r) {
  return r.children.some((e) => e instanceof un || !e.type.isAnonymous || th(e));
}
function By(r) {
  var e;
  let { buffer: t, nodeSet: i, maxBufferLength: n = Ly, reused: s = [], minRepeatType: o = i.types.length } = r, l = Array.isArray(t) ? new Dy(t, t.length) : t, a = i.types, h = 0, c = 0;
  function f(x, S, y, Q, L) {
    let { id: $, start: P, end: T, size: A } = l, I = c;
    for (; A < 0; )
      if (l.next(), A == -1) {
        let re = s[$];
        y.push(re), Q.push(P - x);
        return;
      } else if (A == -3) {
        h = $;
        return;
      } else if (A == -4) {
        c = $;
        return;
      } else
        throw new RangeError(`Unrecognized record size: ${A}`);
    let q = a[$], Y, U, be = P - x;
    if (T - P <= n && (U = O(l.pos - S, L))) {
      let re = new Uint16Array(U.size - U.skip), N = l.pos - U.size, J = re.length;
      for (; l.pos > N; )
        J = g(U.start, re, J);
      Y = new un(re, T - U.start, i), be = U.start - x;
    } else {
      let re = l.pos - A;
      l.next();
      let N = [], J = [], ae = $ >= o ? $ : -1, oe = 0, pe = T;
      for (; l.pos > re; )
        ae >= 0 && l.id == ae && l.size >= 0 ? (l.end <= pe - n && (d(N, J, P, oe, l.end, pe, ae, I), oe = N.length, pe = l.end), l.next()) : f(P, re, N, J, ae);
      if (ae >= 0 && oe > 0 && oe < N.length && d(N, J, P, oe, P, pe, ae, I), N.reverse(), J.reverse(), ae > -1 && oe > 0) {
        let Be = u(q);
        Y = ih(q, N, J, 0, N.length, 0, T - P, Be, Be);
      } else
        Y = p(q, N, J, T - P, I - T);
    }
    y.push(Y), Q.push(be);
  }
  function u(x) {
    return (S, y, Q) => {
      let L = 0, $ = S.length - 1, P, T;
      if ($ >= 0 && (P = S[$]) instanceof je) {
        if (!$ && P.type == x && P.length == Q)
          return P;
        (T = P.prop(ee.lookAhead)) && (L = y[$] + P.length + T);
      }
      return p(x, S, y, Q, L);
    };
  }
  function d(x, S, y, Q, L, $, P, T) {
    let A = [], I = [];
    for (; x.length > Q; )
      A.push(x.pop()), I.push(S.pop() + y - L);
    x.push(p(i.types[P], A, I, $ - L, T - $)), S.push(L - y);
  }
  function p(x, S, y, Q, L = 0, $) {
    if (h) {
      let P = [ee.contextHash, h];
      $ = $ ? [P].concat($) : [P];
    }
    if (L > 25) {
      let P = [ee.lookAhead, L];
      $ = $ ? [P].concat($) : [P];
    }
    return new je(x, S, y, Q, $);
  }
  function O(x, S) {
    let y = l.fork(), Q = 0, L = 0, $ = 0, P = y.end - n, T = { size: 0, start: 0, skip: 0 };
    e: for (let A = y.pos - x; y.pos > A; ) {
      let I = y.size;
      if (y.id == S && I >= 0) {
        T.size = Q, T.start = L, T.skip = $, $ += 4, Q += 4, y.next();
        continue;
      }
      let q = y.pos - I;
      if (I < 0 || q < A || y.start < P)
        break;
      let Y = y.id >= o ? 4 : 0, U = y.start;
      for (y.next(); y.pos > q; ) {
        if (y.size < 0)
          if (y.size == -3)
            Y += 4;
          else
            break e;
        else y.id >= o && (Y += 4);
        y.next();
      }
      L = U, Q += I, $ += Y;
    }
    return (S < 0 || Q == x) && (T.size = Q, T.start = L, T.skip = $), T.size > 4 ? T : void 0;
  }
  function g(x, S, y) {
    let { id: Q, start: L, end: $, size: P } = l;
    if (l.next(), P >= 0 && Q < o) {
      let T = y;
      if (P > 4) {
        let A = l.pos - (P - 4);
        for (; l.pos > A; )
          y = g(x, S, y);
      }
      S[--y] = T, S[--y] = $ - x, S[--y] = L - x, S[--y] = Q;
    } else P == -3 ? h = Q : P == -4 && (c = Q);
    return y;
  }
  let b = [], w = [];
  for (; l.pos > 0; )
    f(r.start || 0, r.bufferStart || 0, b, w, -1);
  let k = (e = r.length) !== null && e !== void 0 ? e : b.length ? w[0] + b[0].length : 0;
  return new je(a[r.topID], b.reverse(), w.reverse(), k);
}
const Kc = /* @__PURE__ */ new WeakMap();
function as(r, e) {
  if (!r.isAnonymous || e instanceof un || e.type != r)
    return 1;
  let t = Kc.get(e);
  if (t == null) {
    t = 1;
    for (let i of e.children) {
      if (i.type != r || !(i instanceof je)) {
        t = 1;
        break;
      }
      t += as(r, i);
    }
    Kc.set(e, t);
  }
  return t;
}
function ih(r, e, t, i, n, s, o, l, a) {
  let h = 0;
  for (let p = i; p < n; p++)
    h += as(r, e[p]);
  let c = Math.ceil(
    h * 1.5 / 8
    /* BranchFactor */
  ), f = [], u = [];
  function d(p, O, g, b, w) {
    for (let k = g; k < b; ) {
      let x = k, S = O[k], y = as(r, p[k]);
      for (k++; k < b; k++) {
        let Q = as(r, p[k]);
        if (y + Q >= c)
          break;
        y += Q;
      }
      if (k == x + 1) {
        if (y > c) {
          let Q = p[x];
          d(Q.children, Q.positions, 0, Q.children.length, O[x] + w);
          continue;
        }
        f.push(p[x]);
      } else {
        let Q = O[k - 1] + p[k - 1].length - S;
        f.push(ih(r, p, O, x, k, S, Q, null, a));
      }
      u.push(S + w - s);
    }
  }
  return d(e, t, i, n, 0), (l || a)(f, u, o);
}
let hs = class fa {
  /// Construct a tree fragment.
  constructor(e, t, i, n, s = !1, o = !1) {
    this.from = e, this.to = t, this.tree = i, this.offset = n, this.open = (s ? 1 : 0) | (o ? 2 : 0);
  }
  /// Whether the start of the fragment represents the start of a
  /// parse, or the end of a change. (In the second case, it may not
  /// be safe to reuse some nodes at the start, depending on the
  /// parsing algorithm.)
  get openStart() {
    return (this.open & 1) > 0;
  }
  /// Whether the end of the fragment represents the end of a
  /// full-document parse, or the start of a change.
  get openEnd() {
    return (this.open & 2) > 0;
  }
  /// Create a set of fragments from a freshly parsed tree, or update
  /// an existing set of fragments by replacing the ones that overlap
  /// with a tree with content from the new tree. When `partial` is
  /// true, the parse is treated as incomplete, and the resulting
  /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
  /// true.
  static addTree(e, t = [], i = !1) {
    let n = [new fa(0, e.length, e, 0, !1, i)];
    for (let s of t)
      s.to > e.length && n.push(s);
    return n;
  }
  /// Apply a set of edits to an array of fragments, removing or
  /// splitting fragments as necessary to remove edited ranges, and
  /// adjusting offsets for fragments that moved.
  static applyChanges(e, t, i = 128) {
    if (!t.length)
      return e;
    let n = [], s = 1, o = e.length ? e[0] : null;
    for (let l = 0, a = 0, h = 0; ; l++) {
      let c = l < t.length ? t[l] : null, f = c ? c.fromA : 1e9;
      if (f - a >= i)
        for (; o && o.from < f; ) {
          let u = o;
          if (a >= u.from || f <= u.to || h) {
            let d = Math.max(u.from, a) - h, p = Math.min(u.to, f) - h;
            u = d >= p ? null : new fa(d, p, u.tree, u.offset + h, l > 0, !!c);
          }
          if (u && n.push(u), o.to > f)
            break;
          o = s < e.length ? e[s++] : null;
        }
      if (!c)
        break;
      a = c.toA, h = c.toA - c.toB;
    }
    return n;
  }
}, Iy = class {
  /// Start a parse, returning a [partial parse](#common.PartialParse)
  /// object. [`fragments`](#common.TreeFragment) can be passed in to
  /// make the parse incremental.
  ///
  /// By default, the entire input is parsed. You can pass `ranges`,
  /// which should be a sorted array of non-empty, non-overlapping
  /// ranges, to parse only those ranges. The tree returned in that
  /// case will start at `ranges[0].from`.
  startParse(e, t, i) {
    return typeof e == "string" && (e = new Vy(e)), i = i ? i.length ? i.map((n) => new Bo(n.from, n.to)) : [new Bo(0, 0)] : [new Bo(0, e.length)], this.createParse(e, t || [], i);
  }
  /// Run a full parse, returning the resulting tree.
  parse(e, t, i) {
    let n = this.startParse(e, t, i);
    for (; ; ) {
      let s = n.advance();
      if (s)
        return s;
    }
  }
}, Vy = class {
  constructor(e) {
    this.string = e;
  }
  get length() {
    return this.string.length;
  }
  chunk(e) {
    return this.string.slice(e);
  }
  get lineChunks() {
    return !1;
  }
  read(e, t) {
    return this.string.slice(e, t);
  }
};
new ee({ perNode: !0 });
let qy = 0, Ut = class jp {
  /// @internal
  constructor(e, t, i) {
    this.set = e, this.base = t, this.modified = i, this.id = qy++;
  }
  /// Define a new tag. If `parent` is given, the tag is treated as a
  /// sub-tag of that parent, and
  /// [highlighters](#highlight.tagHighlighter) that don't mention
  /// this tag will try to fall back to the parent tag (or grandparent
  /// tag, etc).
  static define(e) {
    if (e?.base)
      throw new Error("Can not derive from a modified tag");
    let t = new jp([], null, []);
    if (t.set.push(t), e)
      for (let i of e.set)
        t.set.push(i);
    return t;
  }
  /// Define a tag _modifier_, which is a function that, given a tag,
  /// will return a tag that is a subtag of the original. Applying the
  /// same modifier to a twice tag will return the same value (`m1(t1)
  /// == m1(t1)`) and applying multiple modifiers will, regardless or
  /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
  ///
  /// When multiple modifiers are applied to a given base tag, each
  /// smaller set of modifiers is registered as a parent, so that for
  /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
  /// `m1(m3(t1)`, and so on.
  static defineModifier() {
    let e = new Jc();
    return (t) => t.modified.indexOf(e) > -1 ? t : Jc.get(t.base || t, t.modified.concat(e).sort((i, n) => i.id - n.id));
  }
}, Yy = 0, Jc = class Gp {
  constructor() {
    this.instances = [], this.id = Yy++;
  }
  static get(e, t) {
    if (!t.length)
      return e;
    let i = t[0].instances.find((l) => l.base == e && Ny(t, l.modified));
    if (i)
      return i;
    let n = [], s = new Ut(n, e, t);
    for (let l of t)
      l.instances.push(s);
    let o = Up(t);
    for (let l of e.set)
      for (let a of o)
        n.push(Gp.get(l, a));
    return s;
  }
};
function Ny(r, e) {
  return r.length == e.length && r.every((t, i) => t == e[i]);
}
function Up(r) {
  let e = [r];
  for (let t = 0; t < r.length; t++)
    for (let i of Up(r.slice(0, t).concat(r.slice(t + 1))))
      e.push(i);
  return e;
}
function Wy(r) {
  let e = /* @__PURE__ */ Object.create(null);
  for (let t in r) {
    let i = r[t];
    Array.isArray(i) || (i = [i]);
    for (let n of t.split(" "))
      if (n) {
        let s = [], o = 2, l = n;
        for (let f = 0; ; ) {
          if (l == "..." && f > 0 && f + 3 == n.length) {
            o = 1;
            break;
          }
          let u = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);
          if (!u)
            throw new RangeError("Invalid path: " + n);
          if (s.push(u[0] == "*" ? "" : u[0][0] == '"' ? JSON.parse(u[0]) : u[0]), f += u[0].length, f == n.length)
            break;
          let d = n[f++];
          if (f == n.length && d == "!") {
            o = 0;
            break;
          }
          if (d != "/")
            throw new RangeError("Invalid path: " + n);
          l = n.slice(f);
        }
        let a = s.length - 1, h = s[a];
        if (!h)
          throw new RangeError("Invalid path: " + n);
        let c = new Gy(i, o, a > 0 ? s.slice(0, a) : null);
        e[h] = c.sort(e[h]);
      }
  }
  return jy.add(e);
}
const jy = new ee();
let Gy = class {
  constructor(e, t, i, n) {
    this.tags = e, this.mode = t, this.context = i, this.next = n;
  }
  sort(e) {
    return !e || e.depth < this.depth ? (this.next = e, this) : (e.next = this.sort(e.next), e);
  }
  get depth() {
    return this.context ? this.context.length : 0;
  }
};
function Uy(r, e) {
  let t = /* @__PURE__ */ Object.create(null);
  for (let s of r)
    if (!Array.isArray(s.tag))
      t[s.tag.id] = s.class;
    else
      for (let o of s.tag)
        t[o.id] = s.class;
  let { scope: i, all: n = null } = {};
  return {
    style: (s) => {
      let o = n;
      for (let l of s)
        for (let a of l.set) {
          let h = t[a.id];
          if (h) {
            o = o ? o + " " + h : h;
            break;
          }
        }
      return o;
    },
    scope: i
  };
}
const Z = Ut.define, Dn = Z(), Ft = Z(), ef = Z(Ft), tf = Z(Ft), Ht = Z(), _n = Z(Ht), Io = Z(Ht), bt = Z(), Oi = Z(bt), dt = Z(), pt = Z(), ua = Z(), ur = Z(ua), Bn = Z(), G = {
  /// A comment.
  comment: Dn,
  /// A line [comment](#highlight.tags.comment).
  lineComment: Z(Dn),
  /// A block [comment](#highlight.tags.comment).
  blockComment: Z(Dn),
  /// A documentation [comment](#highlight.tags.comment).
  docComment: Z(Dn),
  /// Any kind of identifier.
  name: Ft,
  /// The [name](#highlight.tags.name) of a variable.
  variableName: Z(Ft),
  /// A type [name](#highlight.tags.name).
  typeName: ef,
  /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
  tagName: Z(ef),
  /// A property or field [name](#highlight.tags.name).
  propertyName: tf,
  /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
  attributeName: Z(tf),
  /// The [name](#highlight.tags.name) of a class.
  className: Z(Ft),
  /// A label [name](#highlight.tags.name).
  labelName: Z(Ft),
  /// A namespace [name](#highlight.tags.name).
  namespace: Z(Ft),
  /// The [name](#highlight.tags.name) of a macro.
  macroName: Z(Ft),
  /// A literal value.
  literal: Ht,
  /// A string [literal](#highlight.tags.literal).
  string: _n,
  /// A documentation [string](#highlight.tags.string).
  docString: Z(_n),
  /// A character literal (subtag of [string](#highlight.tags.string)).
  character: Z(_n),
  /// An attribute value (subtag of [string](#highlight.tags.string)).
  attributeValue: Z(_n),
  /// A number [literal](#highlight.tags.literal).
  number: Io,
  /// An integer [number](#highlight.tags.number) literal.
  integer: Z(Io),
  /// A floating-point [number](#highlight.tags.number) literal.
  float: Z(Io),
  /// A boolean [literal](#highlight.tags.literal).
  bool: Z(Ht),
  /// Regular expression [literal](#highlight.tags.literal).
  regexp: Z(Ht),
  /// An escape [literal](#highlight.tags.literal), for example a
  /// backslash escape in a string.
  escape: Z(Ht),
  /// A color [literal](#highlight.tags.literal).
  color: Z(Ht),
  /// A URL [literal](#highlight.tags.literal).
  url: Z(Ht),
  /// A language keyword.
  keyword: dt,
  /// The [keyword](#highlight.tags.keyword) for the self or this
  /// object.
  self: Z(dt),
  /// The [keyword](#highlight.tags.keyword) for null.
  null: Z(dt),
  /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
  atom: Z(dt),
  /// A [keyword](#highlight.tags.keyword) that represents a unit.
  unit: Z(dt),
  /// A modifier [keyword](#highlight.tags.keyword).
  modifier: Z(dt),
  /// A [keyword](#highlight.tags.keyword) that acts as an operator.
  operatorKeyword: Z(dt),
  /// A control-flow related [keyword](#highlight.tags.keyword).
  controlKeyword: Z(dt),
  /// A [keyword](#highlight.tags.keyword) that defines something.
  definitionKeyword: Z(dt),
  /// A [keyword](#highlight.tags.keyword) related to defining or
  /// interfacing with modules.
  moduleKeyword: Z(dt),
  /// An operator.
  operator: pt,
  /// An [operator](#highlight.tags.operator) that defines something.
  derefOperator: Z(pt),
  /// Arithmetic-related [operator](#highlight.tags.operator).
  arithmeticOperator: Z(pt),
  /// Logical [operator](#highlight.tags.operator).
  logicOperator: Z(pt),
  /// Bit [operator](#highlight.tags.operator).
  bitwiseOperator: Z(pt),
  /// Comparison [operator](#highlight.tags.operator).
  compareOperator: Z(pt),
  /// [Operator](#highlight.tags.operator) that updates its operand.
  updateOperator: Z(pt),
  /// [Operator](#highlight.tags.operator) that defines something.
  definitionOperator: Z(pt),
  /// Type-related [operator](#highlight.tags.operator).
  typeOperator: Z(pt),
  /// Control-flow [operator](#highlight.tags.operator).
  controlOperator: Z(pt),
  /// Program or markup punctuation.
  punctuation: ua,
  /// [Punctuation](#highlight.tags.punctuation) that separates
  /// things.
  separator: Z(ua),
  /// Bracket-style [punctuation](#highlight.tags.punctuation).
  bracket: ur,
  /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
  /// tokens).
  angleBracket: Z(ur),
  /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
  /// tokens).
  squareBracket: Z(ur),
  /// Parentheses (usually `(` and `)` tokens). Subtag of
  /// [bracket](#highlight.tags.bracket).
  paren: Z(ur),
  /// Braces (usually `{` and `}` tokens). Subtag of
  /// [bracket](#highlight.tags.bracket).
  brace: Z(ur),
  /// Content, for example plain text in XML or markup documents.
  content: bt,
  /// [Content](#highlight.tags.content) that represents a heading.
  heading: Oi,
  /// A level 1 [heading](#highlight.tags.heading).
  heading1: Z(Oi),
  /// A level 2 [heading](#highlight.tags.heading).
  heading2: Z(Oi),
  /// A level 3 [heading](#highlight.tags.heading).
  heading3: Z(Oi),
  /// A level 4 [heading](#highlight.tags.heading).
  heading4: Z(Oi),
  /// A level 5 [heading](#highlight.tags.heading).
  heading5: Z(Oi),
  /// A level 6 [heading](#highlight.tags.heading).
  heading6: Z(Oi),
  /// A prose separator (such as a horizontal rule).
  contentSeparator: Z(bt),
  /// [Content](#highlight.tags.content) that represents a list.
  list: Z(bt),
  /// [Content](#highlight.tags.content) that represents a quote.
  quote: Z(bt),
  /// [Content](#highlight.tags.content) that is emphasized.
  emphasis: Z(bt),
  /// [Content](#highlight.tags.content) that is styled strong.
  strong: Z(bt),
  /// [Content](#highlight.tags.content) that is part of a link.
  link: Z(bt),
  /// [Content](#highlight.tags.content) that is styled as code or
  /// monospace.
  monospace: Z(bt),
  /// [Content](#highlight.tags.content) that has a strike-through
  /// style.
  strikethrough: Z(bt),
  /// Inserted text in a change-tracking format.
  inserted: Z(),
  /// Deleted text.
  deleted: Z(),
  /// Changed text.
  changed: Z(),
  /// An invalid or unsyntactic element.
  invalid: Z(),
  /// Metadata or meta-instruction.
  meta: Bn,
  /// [Metadata](#highlight.tags.meta) that applies to the entire
  /// document.
  documentMeta: Z(Bn),
  /// [Metadata](#highlight.tags.meta) that annotates or adds
  /// attributes to a given syntactic element.
  annotation: Z(Bn),
  /// Processing instruction or preprocessor directive. Subtag of
  /// [meta](#highlight.tags.meta).
  processingInstruction: Z(Bn),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
  /// given element is being defined. Expected to be used with the
  /// various [name](#highlight.tags.name) tags.
  definition: Ut.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates that
  /// something is constant. Mostly expected to be used with
  /// [variable names](#highlight.tags.variableName).
  constant: Ut.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
  /// a [variable](#highlight.tags.variableName) or [property
  /// name](#highlight.tags.propertyName) is being called or defined
  /// as a function.
  function: Ut.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
  /// [names](#highlight.tags.name) to indicate that they belong to
  /// the language's standard environment.
  standard: Ut.defineModifier(),
  /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
  /// [names](#highlight.tags.name) is local to some scope.
  local: Ut.defineModifier(),
  /// A generic variant [modifier](#highlight.Tag^defineModifier) that
  /// can be used to tag language-specific alternative variants of
  /// some common tag. It is recommended for themes to define special
  /// forms of at least the [string](#highlight.tags.string) and
  /// [variable name](#highlight.tags.variableName) tags, since those
  /// come up a lot.
  special: Ut.defineModifier()
};
Uy([
  { tag: G.link, class: "tok-link" },
  { tag: G.heading, class: "tok-heading" },
  { tag: G.emphasis, class: "tok-emphasis" },
  { tag: G.strong, class: "tok-strong" },
  { tag: G.keyword, class: "tok-keyword" },
  { tag: G.atom, class: "tok-atom" },
  { tag: G.bool, class: "tok-bool" },
  { tag: G.url, class: "tok-url" },
  { tag: G.labelName, class: "tok-labelName" },
  { tag: G.inserted, class: "tok-inserted" },
  { tag: G.deleted, class: "tok-deleted" },
  { tag: G.literal, class: "tok-literal" },
  { tag: G.string, class: "tok-string" },
  { tag: G.number, class: "tok-number" },
  { tag: [G.regexp, G.escape, G.special(G.string)], class: "tok-string2" },
  { tag: G.variableName, class: "tok-variableName" },
  { tag: G.local(G.variableName), class: "tok-variableName tok-local" },
  { tag: G.definition(G.variableName), class: "tok-variableName tok-definition" },
  { tag: G.special(G.variableName), class: "tok-variableName2" },
  { tag: G.definition(G.propertyName), class: "tok-propertyName tok-definition" },
  { tag: G.typeName, class: "tok-typeName" },
  { tag: G.namespace, class: "tok-namespace" },
  { tag: G.className, class: "tok-className" },
  { tag: G.macroName, class: "tok-macroName" },
  { tag: G.propertyName, class: "tok-propertyName" },
  { tag: G.operator, class: "tok-operator" },
  { tag: G.comment, class: "tok-comment" },
  { tag: G.meta, class: "tok-meta" },
  { tag: G.invalid, class: "tok-invalid" },
  { tag: G.punctuation, class: "tok-punctuation" }
]);
var Vo;
const da = /* @__PURE__ */ new ee();
let Et = class {
  /**
  Construct a language object. If you need to invoke this
  directly, first define a data facet with
  [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
  configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
  to the language's outer syntax node.
  */
  constructor(e, t, i = []) {
    this.data = e, W.prototype.hasOwnProperty("tree") || Object.defineProperty(W.prototype, "tree", { get() {
      return ci(this);
    } }), this.parser = t, this.extension = [
      Gi.of(this),
      W.languageData.of((n, s, o) => n.facet(rf(n, s, o)))
    ].concat(i);
  }
  /**
  Query whether this language is active at the given position.
  */
  isActiveAt(e, t, i = -1) {
    return rf(e, t, i) == this.data;
  }
  /**
  Find the document regions that were parsed using this language.
  The returned regions will _include_ any nested languages rooted
  in this language, when those exist.
  */
  findRegions(e) {
    let t = e.facet(Gi);
    if (t?.data == this.data)
      return [{ from: 0, to: e.doc.length }];
    if (!t || !t.allowsNesting)
      return [];
    let i = [], n = (s, o) => {
      if (s.prop(da) == this.data) {
        i.push({ from: o, to: o + s.length });
        return;
      }
      let l = s.prop(ee.mounted);
      if (l) {
        if (l.tree.prop(da) == this.data) {
          if (l.overlay)
            for (let a of l.overlay)
              i.push({ from: a.from + o, to: a.to + o });
          else
            i.push({ from: o, to: o + s.length });
          return;
        } else if (l.overlay) {
          let a = i.length;
          if (n(l.tree, l.overlay[0].from + o), i.length > a)
            return;
        }
      }
      for (let a = 0; a < s.children.length; a++) {
        let h = s.children[a];
        h instanceof je && n(h, s.positions[a] + o);
      }
    };
    return n(ci(e), 0), i;
  }
  /**
  Indicates whether this language allows nested languages. The
  default implementation returns true.
  */
  get allowsNesting() {
    return !0;
  }
};
Et.setState = /* @__PURE__ */ V.define();
function rf(r, e, t) {
  let i = r.facet(Gi);
  if (!i)
    return null;
  let n = i.data;
  if (i.allowsNesting)
    for (let s = ci(r).topNode; s; s = s.enter(e, t, Ce.ExcludeBuffers))
      n = s.type.prop(da) || n;
  return n;
}
function ci(r) {
  let e = r.field(Et.state, !1);
  return e ? e.tree : je.empty;
}
let Fy = class {
  constructor(e, t = e.length) {
    this.doc = e, this.length = t, this.cursorPos = 0, this.string = "", this.cursor = e.iter();
  }
  syncTo(e) {
    return this.string = this.cursor.next(e - this.cursorPos).value, this.cursorPos = e + this.string.length, this.cursorPos - this.string.length;
  }
  chunk(e) {
    return this.syncTo(e), this.string;
  }
  get lineChunks() {
    return !0;
  }
  read(e, t) {
    let i = this.cursorPos - this.string.length;
    return e < i || t >= this.cursorPos ? this.doc.sliceString(e, t) : this.string.slice(e - i, t - i);
  }
}, dr = null, Hy = class pa {
  constructor(e, t, i = [], n, s, o, l, a) {
    this.parser = e, this.state = t, this.fragments = i, this.tree = n, this.treeLen = s, this.viewport = o, this.skipped = l, this.scheduleOn = a, this.parse = null, this.tempSkipped = [];
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new pa(e, t, [], je.empty, 0, i, [], null);
  }
  startParse() {
    return this.parser.startParse(new Fy(this.state.doc), this.fragments);
  }
  /**
  @internal
  */
  work(e, t) {
    return t != null && t >= this.state.doc.length && (t = void 0), this.tree != je.empty && this.isDone(t ?? this.state.doc.length) ? (this.takeTree(), !0) : this.withContext(() => {
      var i;
      if (typeof e == "number") {
        let n = Date.now() + e;
        e = () => Date.now() > n;
      }
      for (this.parse || (this.parse = this.startParse()), t != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > t) && t < this.state.doc.length && this.parse.stopAt(t); ; ) {
        let n = this.parse.advance();
        if (n)
          if (this.fragments = this.withoutTempSkipped(hs.addTree(n, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (i = this.parse.stoppedAt) !== null && i !== void 0 ? i : this.state.doc.length, this.tree = n, this.parse = null, this.treeLen < (t ?? this.state.doc.length))
            this.parse = this.startParse();
          else
            return !0;
        if (e())
          return !1;
      }
    });
  }
  /**
  @internal
  */
  takeTree() {
    let e, t;
    this.parse && (e = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > e) && this.parse.stopAt(e), this.withContext(() => {
      for (; !(t = this.parse.advance()); )
        ;
    }), this.treeLen = e, this.tree = t, this.fragments = this.withoutTempSkipped(hs.addTree(this.tree, this.fragments, !0)), this.parse = null);
  }
  withContext(e) {
    let t = dr;
    dr = this;
    try {
      return e();
    } finally {
      dr = t;
    }
  }
  withoutTempSkipped(e) {
    for (let t; t = this.tempSkipped.pop(); )
      e = nf(e, t.from, t.to);
    return e;
  }
  /**
  @internal
  */
  changes(e, t) {
    let { fragments: i, tree: n, treeLen: s, viewport: o, skipped: l } = this;
    if (this.takeTree(), !e.empty) {
      let a = [];
      if (e.iterChangedRanges((h, c, f, u) => a.push({ fromA: h, toA: c, fromB: f, toB: u })), i = hs.applyChanges(i, a), n = je.empty, s = 0, o = { from: e.mapPos(o.from, -1), to: e.mapPos(o.to, 1) }, this.skipped.length) {
        l = [];
        for (let h of this.skipped) {
          let c = e.mapPos(h.from, 1), f = e.mapPos(h.to, -1);
          c < f && l.push({ from: c, to: f });
        }
      }
    }
    return new pa(this.parser, t, i, n, s, o, l, this.scheduleOn);
  }
  /**
  @internal
  */
  updateViewport(e) {
    if (this.viewport.from == e.from && this.viewport.to == e.to)
      return !1;
    this.viewport = e;
    let t = this.skipped.length;
    for (let i = 0; i < this.skipped.length; i++) {
      let { from: n, to: s } = this.skipped[i];
      n < e.to && s > e.from && (this.fragments = nf(this.fragments, n, s), this.skipped.splice(i--, 1));
    }
    return this.skipped.length >= t ? !1 : (this.reset(), !0);
  }
  /**
  @internal
  */
  reset() {
    this.parse && (this.takeTree(), this.parse = null);
  }
  /**
  Notify the parse scheduler that the given region was skipped
  because it wasn't in view, and the parse should be restarted
  when it comes into view.
  */
  skipUntilInView(e, t) {
    this.skipped.push({ from: e, to: t });
  }
  /**
  Returns a parser intended to be used as placeholder when
  asynchronously loading a nested parser. It'll skip its input and
  mark it as not-really-parsed, so that the next update will parse
  it again.
  
  When `until` is given, a reparse will be scheduled when that
  promise resolves.
  */
  static getSkippingParser(e) {
    return new class extends Iy {
      createParse(t, i, n) {
        let s = n[0].from, o = n[n.length - 1].to;
        return {
          parsedPos: s,
          advance() {
            let a = dr;
            if (a) {
              for (let h of n)
                a.tempSkipped.push(h);
              e && (a.scheduleOn = a.scheduleOn ? Promise.all([a.scheduleOn, e]) : e);
            }
            return this.parsedPos = o, new je(At.none, [], [], o - s);
          },
          stoppedAt: null,
          stopAt() {
          }
        };
      }
    }();
  }
  /**
  @internal
  */
  isDone(e) {
    e = Math.min(e, this.state.doc.length);
    let t = this.fragments;
    return this.treeLen >= e && t.length && t[0].from == 0 && t[0].to >= e;
  }
  /**
  Get the context for the current parse, or `null` if no editor
  parse is in progress.
  */
  static get() {
    return dr;
  }
};
function nf(r, e, t) {
  return hs.applyChanges(r, [{ fromA: e, toA: t, fromB: e, toB: t }]);
}
let Oa = class ma {
  constructor(e) {
    this.context = e, this.tree = e.tree;
  }
  apply(e) {
    if (!e.docChanged && this.tree == this.context.tree)
      return this;
    let t = this.context.changes(e.changes, e.state), i = this.context.treeLen == e.startState.doc.length ? void 0 : Math.max(e.changes.mapPos(this.context.treeLen), t.viewport.to);
    return t.work(20, i) || t.takeTree(), new ma(t);
  }
  static init(e) {
    let t = Math.min(3e3, e.doc.length), i = Hy.create(e.facet(Gi).parser, e, { from: 0, to: t });
    return i.work(20, t) || i.takeTree(), new ma(i);
  }
};
Et.state = /* @__PURE__ */ ge.define({
  create: Oa.init,
  update(r, e) {
    for (let t of e.effects)
      if (t.is(Et.setState))
        return t.value;
    return e.startState.facet(Gi) != e.state.facet(Gi) ? Oa.init(e.state) : r.apply(e);
  }
});
let Fp = (r) => {
  let e = setTimeout(
    () => r(),
    500
    /* MaxPause */
  );
  return () => clearTimeout(e);
};
typeof requestIdleCallback < "u" && (Fp = (r) => {
  let e = -1, t = setTimeout(
    () => {
      e = requestIdleCallback(r, {
        timeout: 400
        /* MinPause */
      });
    },
    100
    /* MinPause */
  );
  return () => e < 0 ? clearTimeout(t) : cancelIdleCallback(e);
});
const qo = typeof navigator < "u" && (!((Vo = navigator.scheduling) === null || Vo === void 0) && Vo.isInputPending) ? () => navigator.scheduling.isInputPending() : null, Ky = /* @__PURE__ */ ue.fromClass(class {
  constructor(e) {
    this.view = e, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
  }
  update(e) {
    let t = this.view.state.field(Et.state).context;
    (t.updateViewport(e.view.viewport) || this.view.viewport.to > t.treeLen) && this.scheduleWork(), e.docChanged && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(t);
  }
  scheduleWork() {
    if (this.working)
      return;
    let { state: e } = this.view, t = e.field(Et.state);
    (t.tree != t.context.tree || !t.context.isDone(e.doc.length)) && (this.working = Fp(this.work));
  }
  work(e) {
    this.working = null;
    let t = Date.now();
    if (this.chunkEnd < t && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = t + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
      return;
    let { state: i, viewport: { to: n } } = this.view, s = i.field(Et.state);
    if (s.tree == s.context.tree && s.context.isDone(
      n + 1e5
      /* MaxParseAhead */
    ))
      return;
    let o = Date.now() + Math.min(this.chunkBudget, 100, e && !qo ? Math.max(25, e.timeRemaining() - 5) : 1e9), l = s.context.treeLen < n && i.doc.length > n + 1e3, a = s.context.work(() => qo && qo() || Date.now() > o, n + (l ? 0 : 1e5));
    this.chunkBudget -= Date.now() - t, (a || this.chunkBudget <= 0) && (s.context.takeTree(), this.view.dispatch({ effects: Et.setState.of(new Oa(s.context)) })), this.chunkBudget > 0 && !(a && !l) && this.scheduleWork(), this.checkAsyncSchedule(s.context);
  }
  checkAsyncSchedule(e) {
    e.scheduleOn && (this.workScheduled++, e.scheduleOn.then(() => this.scheduleWork()).catch((t) => Qe(this.view.state, t)).then(() => this.workScheduled--), e.scheduleOn = null);
  }
  destroy() {
    this.working && this.working();
  }
  isWorking() {
    return !!(this.working || this.workScheduled > 0);
  }
}, {
  eventHandlers: { focus() {
    this.scheduleWork();
  } }
}), Gi = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? r[0] : null;
  },
  enables: [Et.state, Ky]
}), Jy = /* @__PURE__ */ R.define(), rh = /* @__PURE__ */ R.define({
  combine: (r) => {
    if (!r.length)
      return "  ";
    if (!/^(?: +|\t+)$/.test(r[0]))
      throw new Error("Invalid indent unit: " + JSON.stringify(r[0]));
    return r[0];
  }
});
function Xs(r) {
  let e = r.facet(rh);
  return e.charCodeAt(0) == 9 ? r.tabSize * e.length : e.length;
}
function Rs(r, e) {
  let t = "", i = r.tabSize;
  if (r.facet(rh).charCodeAt(0) == 9)
    for (; e >= i; )
      t += "	", e -= i;
  for (let n = 0; n < e; n++)
    t += " ";
  return t;
}
function Hp(r, e) {
  r instanceof W && (r = new oo(r));
  for (let i of r.state.facet(Jy)) {
    let n = i(r, e);
    if (n != null)
      return n;
  }
  let t = ci(r.state);
  return t ? tS(r, t, e) : null;
}
class oo {
  /**
  Create an indent context.
  */
  constructor(e, t = {}) {
    this.state = e, this.options = t, this.unit = Xs(e);
  }
  /**
  Get a description of the line at the given position, taking
  [simulated line
  breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
  into account. If there is such a break at `pos`, the `bias`
  argument determines whether the part of the line line before or
  after the break is used.
  */
  lineAt(e, t = 1) {
    let i = this.state.doc.lineAt(e), { simulateBreak: n, simulateDoubleBreak: s } = this.options;
    return n != null && n >= i.from && n <= i.to ? s && n == e ? { text: "", from: e } : (t < 0 ? n < e : n <= e) ? { text: i.text.slice(n - i.from), from: n } : { text: i.text.slice(0, n - i.from), from: i.from } : i;
  }
  /**
  Get the text directly after `pos`, either the entire line
  or the next 100 characters, whichever is shorter.
  */
  textAfterPos(e, t = 1) {
    if (this.options.simulateDoubleBreak && e == this.options.simulateBreak)
      return "";
    let { text: i, from: n } = this.lineAt(e, t);
    return i.slice(e - n, Math.min(i.length, e + 100 - n));
  }
  /**
  Find the column for the given position.
  */
  column(e, t = 1) {
    let { text: i, from: n } = this.lineAt(e, t), s = this.countColumn(i, e - n), o = this.options.overrideIndentation ? this.options.overrideIndentation(n) : -1;
    return o > -1 && (s += o - this.countColumn(i, i.search(/\S|$/))), s;
  }
  /**
  Find the column position (taking tabs into account) of the given
  position in the given string.
  */
  countColumn(e, t = e.length) {
    return lt(e, this.state.tabSize, t);
  }
  /**
  Find the indentation column of the line at the given point.
  */
  lineIndent(e, t = 1) {
    let { text: i, from: n } = this.lineAt(e, t), s = this.options.overrideIndentation;
    if (s) {
      let o = s(n);
      if (o > -1)
        return o;
    }
    return this.countColumn(i, i.search(/\S|$/));
  }
  /**
  Returns the [simulated line
  break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
  for this context, if any.
  */
  get simulatedBreak() {
    return this.options.simulateBreak || null;
  }
}
const eS = /* @__PURE__ */ new ee();
function tS(r, e, t) {
  return Kp(e.resolveInner(t).enterUnfinishedNodesBefore(t), t, r);
}
function iS(r) {
  return r.pos == r.options.simulateBreak && r.options.simulateDoubleBreak;
}
function rS(r) {
  let e = r.type.prop(eS);
  if (e)
    return e;
  let t = r.firstChild, i;
  if (t && (i = t.type.prop(ee.closedBy))) {
    let n = r.lastChild, s = n && i.indexOf(n.name) > -1;
    return (o) => lS(o, !0, 1, void 0, s && !iS(o) ? n.from : void 0);
  }
  return r.parent == null ? nS : null;
}
function Kp(r, e, t) {
  for (; r; r = r.parent) {
    let i = rS(r);
    if (i)
      return i(nh.create(t, e, r));
  }
  return null;
}
function nS() {
  return 0;
}
class nh extends oo {
  constructor(e, t, i) {
    super(e.state, e.options), this.base = e, this.pos = t, this.node = i;
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new nh(e, t, i);
  }
  /**
  Get the text directly after `this.pos`, either the entire line
  or the next 100 characters, whichever is shorter.
  */
  get textAfter() {
    return this.textAfterPos(this.pos);
  }
  /**
  Get the indentation at the reference line for `this.node`, which
  is the line on which it starts, unless there is a node that is
  _not_ a parent of this node covering the start of that line. If
  so, the line at the start of that node is tried, again skipping
  on if it is covered by another such node.
  */
  get baseIndent() {
    let e = this.state.doc.lineAt(this.node.from);
    for (; ; ) {
      let t = this.node.resolve(e.from);
      for (; t.parent && t.parent.from == t.from; )
        t = t.parent;
      if (sS(t, this.node))
        break;
      e = this.state.doc.lineAt(t.from);
    }
    return this.lineIndent(e.from);
  }
  /**
  Continue looking for indentations in the node's parent nodes,
  and return the result of that.
  */
  continue() {
    let e = this.node.parent;
    return e ? Kp(e, this.pos, this.base) : 0;
  }
}
function sS(r, e) {
  for (let t = e; t; t = t.parent)
    if (r == t)
      return !0;
  return !1;
}
function oS(r) {
  let e = r.node, t = e.childAfter(e.from), i = e.lastChild;
  if (!t)
    return null;
  let n = r.options.simulateBreak, s = r.state.doc.lineAt(t.from), o = n == null || n <= s.from ? s.to : Math.min(s.to, n);
  for (let l = t.to; ; ) {
    let a = e.childAfter(l);
    if (!a || a == i)
      return null;
    if (!a.type.isSkipped)
      return a.from < o ? t : null;
    l = a.to;
  }
}
function lS(r, e, t, i, n) {
  let s = r.textAfter, o = s.match(/^\s*/)[0].length, l = i && s.slice(o, o + i.length) == i || n == r.pos + o, a = oS(r);
  return a ? l ? r.column(a.from) : r.column(a.to) : r.baseIndent + (l ? 0 : r.unit * t);
}
const aS = 1e4, hS = "()[]{}";
function ga(r, e, t) {
  let i = r.prop(e < 0 ? ee.openedBy : ee.closedBy);
  if (i)
    return i;
  if (r.name.length == 1) {
    let n = t.indexOf(r.name);
    if (n > -1 && n % 2 == (e < 0 ? 1 : 0))
      return [t[n + e]];
  }
  return null;
}
function Li(r, e, t, i = {}) {
  let n = i.maxScanDistance || aS, s = i.brackets || hS, o = ci(r), l = o.resolveInner(e, t);
  for (let a = l; a; a = a.parent) {
    let h = ga(a.type, t, s);
    if (h && a.from < a.to)
      return cS(r, e, t, a, h, s);
  }
  return fS(r, e, t, o, l.type, n, s);
}
function cS(r, e, t, i, n, s) {
  let o = i.parent, l = { from: i.from, to: i.to }, a = 0, h = o?.cursor();
  if (h && (t < 0 ? h.childBefore(i.from) : h.childAfter(i.to)))
    do
      if (t < 0 ? h.to <= i.from : h.from >= i.to) {
        if (a == 0 && n.indexOf(h.type.name) > -1 && h.from < h.to)
          return { start: l, end: { from: h.from, to: h.to }, matched: !0 };
        if (ga(h.type, t, s))
          a++;
        else if (ga(h.type, -t, s) && (a--, a == 0))
          return {
            start: l,
            end: h.from == h.to ? void 0 : { from: h.from, to: h.to },
            matched: !1
          };
      }
    while (t < 0 ? h.prevSibling() : h.nextSibling());
  return { start: l, matched: !1 };
}
function fS(r, e, t, i, n, s, o) {
  let l = t < 0 ? r.sliceDoc(e - 1, e) : r.sliceDoc(e, e + 1), a = o.indexOf(l);
  if (a < 0 || a % 2 == 0 != t > 0)
    return null;
  let h = { from: t < 0 ? e - 1 : e, to: t > 0 ? e + 1 : e }, c = r.doc.iterRange(e, t > 0 ? r.doc.length : 0), f = 0;
  for (let u = 0; !c.next().done && u <= s; ) {
    let d = c.value;
    t < 0 && (u += d.length);
    let p = e + u * t;
    for (let O = t > 0 ? 0 : d.length - 1, g = t > 0 ? d.length : -1; O != g; O += t) {
      let b = o.indexOf(d[O]);
      if (!(b < 0 || i.resolve(p + O, 1).type != n))
        if (b % 2 == 0 == t > 0)
          f++;
        else {
          if (f == 1)
            return { start: h, end: { from: p + O, to: p + O + 1 }, matched: b >> 1 == a >> 1 };
          f--;
        }
    }
    t > 0 && (u += d.length);
  }
  return c.done ? { start: h, matched: !1 } : null;
}
const uS = /* @__PURE__ */ Object.create(null), sf = [At.none], of = [], dS = /* @__PURE__ */ Object.create(null);
for (let [r, e] of [
  ["variable", "variableName"],
  ["variable-2", "variableName.special"],
  ["string-2", "string.special"],
  ["def", "variableName.definition"],
  ["tag", "typeName"],
  ["attribute", "propertyName"],
  ["type", "typeName"],
  ["builtin", "variableName.standard"],
  ["qualifier", "modifier"],
  ["error", "invalid"],
  ["header", "heading"],
  ["property", "propertyName"]
])
  dS[r] = /* @__PURE__ */ pS(uS, e);
function Yo(r, e) {
  of.indexOf(r) > -1 || (of.push(r), console.warn(e));
}
function pS(r, e) {
  let t = null;
  for (let s of e.split(".")) {
    let o = r[s] || G[s];
    o ? typeof o == "function" ? t ? t = o(t) : Yo(s, `Modifier ${s} used at start of tag`) : t ? Yo(s, `Tag ${s} used as modifier`) : t = o : Yo(s, `Unknown highlighting tag ${s}`);
  }
  if (!t)
    return 0;
  let i = e.replace(/ /g, "_"), n = At.define({
    id: sf.length,
    name: i,
    props: [Wy({ [i]: t })]
  });
  return sf.push(n), n.id;
}
const OS = (r) => {
  let e = oh(r.state);
  return e.line ? mS(r) : e.block ? bS(r) : !1;
};
function sh(r, e) {
  return ({ state: t, dispatch: i }) => {
    if (t.readOnly)
      return !1;
    let n = r(e, t);
    return n ? (i(t.update(n)), !0) : !1;
  };
}
const mS = /* @__PURE__ */ sh(
  wS,
  0
  /* Toggle */
), gS = /* @__PURE__ */ sh(
  Jp,
  0
  /* Toggle */
), bS = /* @__PURE__ */ sh(
  (r, e) => Jp(r, e, SS(e)),
  0
  /* Toggle */
);
function oh(r, e = r.selection.main.head) {
  let t = r.languageDataAt("commentTokens", e);
  return t.length ? t[0] : {};
}
const pr = 50;
function yS(r, { open: e, close: t }, i, n) {
  let s = r.sliceDoc(i - pr, i), o = r.sliceDoc(n, n + pr), l = /\s*$/.exec(s)[0].length, a = /^\s*/.exec(o)[0].length, h = s.length - l;
  if (s.slice(h - e.length, h) == e && o.slice(a, a + t.length) == t)
    return {
      open: { pos: i - l, margin: l && 1 },
      close: { pos: n + a, margin: a && 1 }
    };
  let c, f;
  n - i <= 2 * pr ? c = f = r.sliceDoc(i, n) : (c = r.sliceDoc(i, i + pr), f = r.sliceDoc(n - pr, n));
  let u = /^\s*/.exec(c)[0].length, d = /\s*$/.exec(f)[0].length, p = f.length - d - t.length;
  return c.slice(u, u + e.length) == e && f.slice(p, p + t.length) == t ? {
    open: {
      pos: i + u + e.length,
      margin: /\s/.test(c.charAt(u + e.length)) ? 1 : 0
    },
    close: {
      pos: n - d - t.length,
      margin: /\s/.test(f.charAt(p - 1)) ? 1 : 0
    }
  } : null;
}
function SS(r) {
  let e = [];
  for (let t of r.selection.ranges) {
    let i = r.doc.lineAt(t.from), n = t.to <= i.to ? i : r.doc.lineAt(t.to), s = e.length - 1;
    s >= 0 && e[s].to > i.from ? e[s].to = n.to : e.push({ from: i.from, to: n.to });
  }
  return e;
}
function Jp(r, e, t = e.selection.ranges) {
  let i = t.map((s) => oh(e, s.from).block);
  if (!i.every((s) => s))
    return null;
  let n = t.map((s, o) => yS(e, i[o], s.from, s.to));
  if (r != 2 && !n.every((s) => s))
    return { changes: e.changes(t.map((s, o) => n[o] ? [] : [{ from: s.from, insert: i[o].open + " " }, { from: s.to, insert: " " + i[o].close }])) };
  if (r != 1 && n.some((s) => s)) {
    let s = [];
    for (let o = 0, l; o < n.length; o++)
      if (l = n[o]) {
        let a = i[o], { open: h, close: c } = l;
        s.push({ from: h.pos - a.open.length, to: h.pos + h.margin }, { from: c.pos - c.margin, to: c.pos + a.close.length });
      }
    return { changes: s };
  }
  return null;
}
function wS(r, e, t = e.selection.ranges) {
  let i = [], n = -1;
  for (let { from: s, to: o } of t) {
    let l = i.length, a = 1e9;
    for (let h = s; h <= o; ) {
      let c = e.doc.lineAt(h);
      if (c.from > n && (s == o || o > c.from)) {
        n = c.from;
        let f = oh(e, h).line;
        if (!f)
          continue;
        let u = /^\s*/.exec(c.text)[0].length, d = u == c.length, p = c.text.slice(u, u + f.length) == f ? u : -1;
        u < c.text.length && u < a && (a = u), i.push({ line: c, comment: p, token: f, indent: u, empty: d, single: !1 });
      }
      h = c.to + 1;
    }
    if (a < 1e9)
      for (let h = l; h < i.length; h++)
        i[h].indent < i[h].line.text.length && (i[h].indent = a);
    i.length == l + 1 && (i[l].single = !0);
  }
  if (r != 2 && i.some((s) => s.comment < 0 && (!s.empty || s.single))) {
    let s = [];
    for (let { line: l, token: a, indent: h, empty: c, single: f } of i)
      (f || !c) && s.push({ from: l.from + h, insert: a + " " });
    let o = e.changes(s);
    return { changes: o, selection: e.selection.map(o, 1) };
  } else if (r != 1 && i.some((s) => s.comment >= 0)) {
    let s = [];
    for (let { line: o, comment: l, token: a } of i)
      if (l >= 0) {
        let h = o.from + l, c = h + a.length;
        o.text[c - o.from] == " " && c++, s.push({ from: h, to: c });
      }
    return { changes: s };
  }
  return null;
}
const ba = /* @__PURE__ */ qt.define(), xS = /* @__PURE__ */ qt.define(), kS = /* @__PURE__ */ R.define(), eO = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, {
      minDepth: 100,
      newGroupDelay: 500
    }, { minDepth: Math.max, newGroupDelay: Math.min });
  }
});
function QS(r) {
  let e = 0;
  return r.iterChangedRanges((t, i) => e = i), e;
}
const tO = /* @__PURE__ */ ge.define({
  create() {
    return kt.empty;
  },
  update(r, e) {
    let t = e.state.facet(eO), i = e.annotation(ba);
    if (i) {
      let a = e.docChanged ? v.single(QS(e.changes)) : void 0, h = _e.fromTransaction(e, a), c = i.side, f = c == 0 ? r.undone : r.done;
      return h ? f = Ls(f, f.length, t.minDepth, h) : f = sO(f, e.startState.selection), new kt(c == 0 ? i.rest : f, c == 0 ? f : i.rest);
    }
    let n = e.annotation(xS);
    if ((n == "full" || n == "before") && (r = r.isolate()), e.annotation(me.addToHistory) === !1)
      return e.changes.empty ? r : r.addMapping(e.changes.desc);
    let s = _e.fromTransaction(e), o = e.annotation(me.time), l = e.annotation(me.userEvent);
    return s ? r = r.addChanges(s, o, l, t.newGroupDelay, t.minDepth) : e.selection && (r = r.addSelection(e.startState.selection, o, l, t.newGroupDelay)), (n == "full" || n == "after") && (r = r.isolate()), r;
  },
  toJSON(r) {
    return { done: r.done.map((e) => e.toJSON()), undone: r.undone.map((e) => e.toJSON()) };
  },
  fromJSON(r) {
    return new kt(r.done.map(_e.fromJSON), r.undone.map(_e.fromJSON));
  }
});
function vS(r = {}) {
  return [
    tO,
    eO.of(r),
    D.domEventHandlers({
      beforeinput(e, t) {
        let i = e.inputType == "historyUndo" ? iO : e.inputType == "historyRedo" ? rO : null;
        return i ? (e.preventDefault(), i(t)) : !1;
      }
    })
  ];
}
function lo(r, e) {
  return function({ state: t, dispatch: i }) {
    if (!e && t.readOnly)
      return !1;
    let n = t.field(tO, !1);
    if (!n)
      return !1;
    let s = n.pop(r, t, e);
    return s ? (i(s), !0) : !1;
  };
}
const iO = /* @__PURE__ */ lo(0, !1), rO = /* @__PURE__ */ lo(1, !1), $S = /* @__PURE__ */ lo(0, !0), PS = /* @__PURE__ */ lo(1, !0);
class _e {
  constructor(e, t, i, n, s) {
    this.changes = e, this.effects = t, this.mapped = i, this.startSelection = n, this.selectionsAfter = s;
  }
  setSelAfter(e) {
    return new _e(this.changes, this.effects, this.mapped, this.startSelection, e);
  }
  toJSON() {
    var e, t, i;
    return {
      changes: (e = this.changes) === null || e === void 0 ? void 0 : e.toJSON(),
      mapped: (t = this.mapped) === null || t === void 0 ? void 0 : t.toJSON(),
      startSelection: (i = this.startSelection) === null || i === void 0 ? void 0 : i.toJSON(),
      selectionsAfter: this.selectionsAfter.map((n) => n.toJSON())
    };
  }
  static fromJSON(e) {
    return new _e(e.changes && ye.fromJSON(e.changes), [], e.mapped && vt.fromJSON(e.mapped), e.startSelection && v.fromJSON(e.startSelection), e.selectionsAfter.map(v.fromJSON));
  }
  // This does not check `addToHistory` and such, it assumes the
  // transaction needs to be converted to an item. Returns null when
  // there are no changes or effects in the transaction.
  static fromTransaction(e, t) {
    let i = Je;
    for (let n of e.startState.facet(kS)) {
      let s = n(e);
      s.length && (i = i.concat(s));
    }
    return !i.length && e.changes.empty ? null : new _e(e.changes.invert(e.startState.doc), i, void 0, t || e.startState.selection, Je);
  }
  static selection(e) {
    return new _e(void 0, Je, void 0, void 0, e);
  }
}
function Ls(r, e, t, i) {
  let n = e + 1 > t + 20 ? e - t - 1 : 0, s = r.slice(n, e);
  return s.push(i), s;
}
function CS(r, e) {
  let t = [], i = !1;
  return r.iterChangedRanges((n, s) => t.push(n, s)), e.iterChangedRanges((n, s, o, l) => {
    for (let a = 0; a < t.length; ) {
      let h = t[a++], c = t[a++];
      l >= h && o <= c && (i = !0);
    }
  }), i;
}
function TS(r, e) {
  return r.ranges.length == e.ranges.length && r.ranges.filter((t, i) => t.empty != e.ranges[i].empty).length === 0;
}
function nO(r, e) {
  return r.length ? e.length ? r.concat(e) : r : e;
}
const Je = [], AS = 200;
function sO(r, e) {
  if (r.length) {
    let t = r[r.length - 1], i = t.selectionsAfter.slice(Math.max(0, t.selectionsAfter.length - AS));
    return i.length && i[i.length - 1].eq(e) ? r : (i.push(e), Ls(r, r.length - 1, 1e9, t.setSelAfter(i)));
  } else
    return [_e.selection([e])];
}
function MS(r) {
  let e = r[r.length - 1], t = r.slice();
  return t[r.length - 1] = e.setSelAfter(e.selectionsAfter.slice(0, e.selectionsAfter.length - 1)), t;
}
function No(r, e) {
  if (!r.length)
    return r;
  let t = r.length, i = Je;
  for (; t; ) {
    let n = ZS(r[t - 1], e, i);
    if (n.changes && !n.changes.empty || n.effects.length) {
      let s = r.slice(0, t);
      return s[t - 1] = n, s;
    } else
      e = n.mapped, t--, i = n.selectionsAfter;
  }
  return i.length ? [_e.selection(i)] : Je;
}
function ZS(r, e, t) {
  let i = nO(r.selectionsAfter.length ? r.selectionsAfter.map((l) => l.map(e)) : Je, t);
  if (!r.changes)
    return _e.selection(i);
  let n = r.changes.map(e), s = e.mapDesc(r.changes, !0), o = r.mapped ? r.mapped.composeDesc(s) : s;
  return new _e(n, V.mapEffects(r.effects, e), o, r.startSelection.map(s), i);
}
const XS = /^(input\.type|delete)($|\.)/;
class kt {
  constructor(e, t, i = 0, n = void 0) {
    this.done = e, this.undone = t, this.prevTime = i, this.prevUserEvent = n;
  }
  isolate() {
    return this.prevTime ? new kt(this.done, this.undone) : this;
  }
  addChanges(e, t, i, n, s) {
    let o = this.done, l = o[o.length - 1];
    return l && l.changes && !l.changes.empty && e.changes && (!i || XS.test(i)) && (!l.selectionsAfter.length && t - this.prevTime < n && CS(l.changes, e.changes) || // For compose (but not compose.start) events, always join with previous event
    i == "input.type.compose") ? o = Ls(o, o.length - 1, s, new _e(e.changes.compose(l.changes), nO(e.effects, l.effects), l.mapped, l.startSelection, Je)) : o = Ls(o, o.length, s, e), new kt(o, Je, t, i);
  }
  addSelection(e, t, i, n) {
    let s = this.done.length ? this.done[this.done.length - 1].selectionsAfter : Je;
    return s.length > 0 && t - this.prevTime < n && i == this.prevUserEvent && i && /^select($|\.)/.test(i) && TS(s[s.length - 1], e) ? this : new kt(sO(this.done, e), this.undone, t, i);
  }
  addMapping(e) {
    return new kt(No(this.done, e), No(this.undone, e), this.prevTime, this.prevUserEvent);
  }
  pop(e, t, i) {
    let n = e == 0 ? this.done : this.undone;
    if (n.length == 0)
      return null;
    let s = n[n.length - 1];
    if (i && s.selectionsAfter.length)
      return t.update({
        selection: s.selectionsAfter[s.selectionsAfter.length - 1],
        annotations: ba.of({ side: e, rest: MS(n) }),
        userEvent: e == 0 ? "select.undo" : "select.redo",
        scrollIntoView: !0
      });
    if (s.changes) {
      let o = n.length == 1 ? Je : n.slice(0, n.length - 1);
      return s.mapped && (o = No(o, s.mapped)), t.update({
        changes: s.changes,
        selection: s.startSelection,
        effects: s.effects,
        annotations: ba.of({ side: e, rest: o }),
        filter: !1,
        userEvent: e == 0 ? "undo" : "redo",
        scrollIntoView: !0
      });
    } else
      return null;
  }
}
kt.empty = /* @__PURE__ */ new kt(Je, Je);
const RS = [
  { key: "Mod-z", run: iO, preventDefault: !0 },
  { key: "Mod-y", mac: "Mod-Shift-z", run: rO, preventDefault: !0 },
  { key: "Mod-u", run: $S, preventDefault: !0 },
  { key: "Alt-u", mac: "Mod-Shift-u", run: PS, preventDefault: !0 }
];
function nr(r, e) {
  return v.create(r.ranges.map(e), r.mainIndex);
}
function Mt(r, e) {
  return r.update({ selection: e, scrollIntoView: !0, userEvent: "select" });
}
function Nt({ state: r, dispatch: e }, t) {
  let i = nr(r.selection, t);
  return i.eq(r.selection) ? !1 : (e(Mt(r, i)), !0);
}
function ao(r, e) {
  return v.cursor(e ? r.to : r.from);
}
function oO(r, e) {
  return Nt(r, (t) => t.empty ? r.moveByChar(t, e) : ao(t, e));
}
function nt(r) {
  return r.textDirectionAt(r.state.selection.main.head) == ce.LTR;
}
const lO = (r) => oO(r, !nt(r)), aO = (r) => oO(r, nt(r));
function hO(r, e) {
  return Nt(r, (t) => t.empty ? r.moveByGroup(t, e) : ao(t, e));
}
const LS = (r) => hO(r, !nt(r)), ES = (r) => hO(r, nt(r));
function zS(r, e, t) {
  if (e.type.prop(t))
    return !0;
  let i = e.to - e.from;
  return i && (i > 2 || /[^\s,.;:]/.test(r.sliceDoc(e.from, e.to))) || e.firstChild;
}
function ho(r, e, t) {
  let i = ci(r).resolveInner(e.head), n = t ? ee.closedBy : ee.openedBy;
  for (let a = e.head; ; ) {
    let h = t ? i.childAfter(a) : i.childBefore(a);
    if (!h)
      break;
    zS(r, h, n) ? i = h : a = t ? h.to : h.from;
  }
  let s = i.type.prop(n), o, l;
  return s && (o = t ? Li(r, i.from, 1) : Li(r, i.to, -1)) && o.matched ? l = t ? o.end.to : o.end.from : l = t ? i.to : i.from, v.cursor(l, t ? -1 : 1);
}
const DS = (r) => Nt(r, (e) => ho(r.state, e, !nt(r))), _S = (r) => Nt(r, (e) => ho(r.state, e, nt(r)));
function cO(r, e) {
  return Nt(r, (t) => {
    if (!t.empty)
      return ao(t, e);
    let i = r.moveVertically(t, e);
    return i.head != t.head ? i : r.moveToLineBoundary(t, e);
  });
}
const fO = (r) => cO(r, !1), uO = (r) => cO(r, !0);
function dO(r, e) {
  let { state: t } = r, i = nr(t.selection, (l) => l.empty ? r.moveVertically(l, e, Math.min(r.dom.clientHeight, innerHeight)) : ao(l, e));
  if (i.eq(t.selection))
    return !1;
  let n = r.coordsAtPos(t.selection.main.head), s = r.scrollDOM.getBoundingClientRect(), o;
  return n && n.top > s.top && n.bottom < s.bottom && n.top - s.top <= r.scrollDOM.scrollHeight - r.scrollDOM.scrollTop - r.scrollDOM.clientHeight && (o = D.scrollIntoView(i.main.head, { y: "start", yMargin: n.top - s.top })), r.dispatch(Mt(t, i), { effects: o }), !0;
}
const lf = (r) => dO(r, !1), ya = (r) => dO(r, !0);
function co(r, e, t) {
  let i = r.lineBlockAt(e.head), n = r.moveToLineBoundary(e, t);
  if (n.head == e.head && n.head != (t ? i.to : i.from) && (n = r.moveToLineBoundary(e, t, !1)), !t && n.head == i.from && i.length) {
    let s = /^\s*/.exec(r.state.sliceDoc(i.from, Math.min(i.from + 100, i.to)))[0].length;
    s && e.head != i.from + s && (n = v.cursor(i.from + s));
  }
  return n;
}
const af = (r) => Nt(r, (e) => co(r, e, !0)), hf = (r) => Nt(r, (e) => co(r, e, !1)), BS = (r) => Nt(r, (e) => v.cursor(r.lineBlockAt(e.head).from, 1)), IS = (r) => Nt(r, (e) => v.cursor(r.lineBlockAt(e.head).to, -1));
function VS(r, e, t) {
  let i = !1, n = nr(r.selection, (s) => {
    let o = Li(r, s.head, -1) || Li(r, s.head, 1) || s.head > 0 && Li(r, s.head - 1, 1) || s.head < r.doc.length && Li(r, s.head + 1, -1);
    if (!o || !o.end)
      return s;
    i = !0;
    let l = o.start.from == s.head ? o.end.to : o.end.from;
    return v.cursor(l);
  });
  return i ? (e(Mt(r, n)), !0) : !1;
}
const qS = ({ state: r, dispatch: e }) => VS(r, e);
function Zt(r, e) {
  let t = nr(r.state.selection, (i) => {
    let n = e(i);
    return v.range(i.anchor, n.head, n.goalColumn);
  });
  return t.eq(r.state.selection) ? !1 : (r.dispatch(Mt(r.state, t)), !0);
}
function pO(r, e) {
  return Zt(r, (t) => r.moveByChar(t, e));
}
const OO = (r) => pO(r, !nt(r)), mO = (r) => pO(r, nt(r));
function gO(r, e) {
  return Zt(r, (t) => r.moveByGroup(t, e));
}
const YS = (r) => gO(r, !nt(r)), NS = (r) => gO(r, nt(r)), WS = (r) => Zt(r, (e) => ho(r.state, e, !nt(r))), jS = (r) => Zt(r, (e) => ho(r.state, e, nt(r)));
function bO(r, e) {
  return Zt(r, (t) => r.moveVertically(t, e));
}
const yO = (r) => bO(r, !1), SO = (r) => bO(r, !0);
function wO(r, e) {
  return Zt(r, (t) => r.moveVertically(t, e, Math.min(r.dom.clientHeight, innerHeight)));
}
const cf = (r) => wO(r, !1), ff = (r) => wO(r, !0), uf = (r) => Zt(r, (e) => co(r, e, !0)), df = (r) => Zt(r, (e) => co(r, e, !1)), GS = (r) => Zt(r, (e) => v.cursor(r.lineBlockAt(e.head).from)), US = (r) => Zt(r, (e) => v.cursor(r.lineBlockAt(e.head).to)), pf = ({ state: r, dispatch: e }) => (e(Mt(r, { anchor: 0 })), !0), Of = ({ state: r, dispatch: e }) => (e(Mt(r, { anchor: r.doc.length })), !0), mf = ({ state: r, dispatch: e }) => (e(Mt(r, { anchor: r.selection.main.anchor, head: 0 })), !0), gf = ({ state: r, dispatch: e }) => (e(Mt(r, { anchor: r.selection.main.anchor, head: r.doc.length })), !0), FS = ({ state: r, dispatch: e }) => (e(r.update({ selection: { anchor: 0, head: r.doc.length }, userEvent: "select" })), !0), HS = ({ state: r, dispatch: e }) => {
  let t = po(r).map(({ from: i, to: n }) => v.range(i, Math.min(n + 1, r.doc.length)));
  return e(r.update({ selection: v.create(t), userEvent: "select" })), !0;
}, KS = ({ state: r, dispatch: e }) => {
  let t = nr(r.selection, (i) => {
    var n;
    let s = ci(r).resolveInner(i.head, 1);
    for (; !(s.from < i.from && s.to >= i.to || s.to > i.to && s.from <= i.from || !(!((n = s.parent) === null || n === void 0) && n.parent)); )
      s = s.parent;
    return v.range(s.to, s.from);
  });
  return e(Mt(r, t)), !0;
}, JS = ({ state: r, dispatch: e }) => {
  let t = r.selection, i = null;
  return t.ranges.length > 1 ? i = v.create([t.main]) : t.main.empty || (i = v.create([v.cursor(t.main.head)])), i ? (e(Mt(r, i)), !0) : !1;
};
function fo({ state: r, dispatch: e }, t) {
  if (r.readOnly)
    return !1;
  let i = "delete.selection", n = r.changeByRange((s) => {
    let { from: o, to: l } = s;
    if (o == l) {
      let a = t(o);
      a < o ? i = "delete.backward" : a > o && (i = "delete.forward"), o = Math.min(o, a), l = Math.max(l, a);
    }
    return o == l ? { range: s } : { changes: { from: o, to: l }, range: v.cursor(o) };
  });
  return n.changes.empty ? !1 : (e(r.update(n, { scrollIntoView: !0, userEvent: i })), !0);
}
function uo(r, e, t) {
  if (r instanceof D)
    for (let i of r.state.facet(D.atomicRanges).map((n) => n(r)))
      i.between(e, e, (n, s) => {
        n < e && s > e && (e = t ? s : n);
      });
  return e;
}
const xO = (r, e) => fo(r, (t) => {
  let { state: i } = r, n = i.doc.lineAt(t), s, o;
  if (!e && t > n.from && t < n.from + 200 && !/[^ \t]/.test(s = n.text.slice(0, t - n.from))) {
    if (s[s.length - 1] == "	")
      return t - 1;
    let l = lt(s, i.tabSize), a = l % Xs(i) || Xs(i);
    for (let h = 0; h < a && s[s.length - 1 - h] == " "; h++)
      t--;
    o = t;
  } else
    o = De(n.text, t - n.from, e, e) + n.from, o == t && n.number != (e ? i.doc.lines : 1) && (o += e ? 1 : -1);
  return uo(r, o, e);
}), Sa = (r) => xO(r, !1), kO = (r) => xO(r, !0), QO = (r, e) => fo(r, (t) => {
  let i = t, { state: n } = r, s = n.doc.lineAt(i), o = n.charCategorizer(i);
  for (let l = null; ; ) {
    if (i == (e ? s.to : s.from)) {
      i == t && s.number != (e ? n.doc.lines : 1) && (i += e ? 1 : -1);
      break;
    }
    let a = De(s.text, i - s.from, e) + s.from, h = s.text.slice(Math.min(i, a) - s.from, Math.max(i, a) - s.from), c = o(h);
    if (l != null && c != l)
      break;
    (h != " " || i != t) && (l = c), i = a;
  }
  return uo(r, i, e);
}), vO = (r) => QO(r, !1), ew = (r) => QO(r, !0), $O = (r) => fo(r, (e) => {
  let t = r.lineBlockAt(e).to;
  return uo(r, e < t ? t : Math.min(r.state.doc.length, e + 1), !0);
}), tw = (r) => fo(r, (e) => {
  let t = r.lineBlockAt(e).from;
  return uo(r, e > t ? t : Math.max(0, e - 1), !1);
}), iw = ({ state: r, dispatch: e }) => {
  if (r.readOnly)
    return !1;
  let t = r.changeByRange((i) => ({
    changes: { from: i.from, to: i.to, insert: K.of(["", ""]) },
    range: v.cursor(i.from)
  }));
  return e(r.update(t, { scrollIntoView: !0, userEvent: "input" })), !0;
}, rw = ({ state: r, dispatch: e }) => {
  if (r.readOnly)
    return !1;
  let t = r.changeByRange((i) => {
    if (!i.empty || i.from == 0 || i.from == r.doc.length)
      return { range: i };
    let n = i.from, s = r.doc.lineAt(n), o = n == s.from ? n - 1 : De(s.text, n - s.from, !1) + s.from, l = n == s.to ? n + 1 : De(s.text, n - s.from, !0) + s.from;
    return {
      changes: { from: o, to: l, insert: r.doc.slice(n, l).append(r.doc.slice(o, n)) },
      range: v.cursor(l)
    };
  });
  return t.changes.empty ? !1 : (e(r.update(t, { scrollIntoView: !0, userEvent: "move.character" })), !0);
};
function po(r) {
  let e = [], t = -1;
  for (let i of r.selection.ranges) {
    let n = r.doc.lineAt(i.from), s = r.doc.lineAt(i.to);
    if (!i.empty && i.to == s.from && (s = r.doc.lineAt(i.to - 1)), t >= n.number) {
      let o = e[e.length - 1];
      o.to = s.to, o.ranges.push(i);
    } else
      e.push({ from: n.from, to: s.to, ranges: [i] });
    t = s.number + 1;
  }
  return e;
}
function PO(r, e, t) {
  if (r.readOnly)
    return !1;
  let i = [], n = [];
  for (let s of po(r)) {
    if (t ? s.to == r.doc.length : s.from == 0)
      continue;
    let o = r.doc.lineAt(t ? s.to + 1 : s.from - 1), l = o.length + 1;
    if (t) {
      i.push({ from: s.to, to: o.to }, { from: s.from, insert: o.text + r.lineBreak });
      for (let a of s.ranges)
        n.push(v.range(Math.min(r.doc.length, a.anchor + l), Math.min(r.doc.length, a.head + l)));
    } else {
      i.push({ from: o.from, to: s.from }, { from: s.to, insert: r.lineBreak + o.text });
      for (let a of s.ranges)
        n.push(v.range(a.anchor - l, a.head - l));
    }
  }
  return i.length ? (e(r.update({
    changes: i,
    scrollIntoView: !0,
    selection: v.create(n, r.selection.mainIndex),
    userEvent: "move.line"
  })), !0) : !1;
}
const nw = ({ state: r, dispatch: e }) => PO(r, e, !1), sw = ({ state: r, dispatch: e }) => PO(r, e, !0);
function CO(r, e, t) {
  if (r.readOnly)
    return !1;
  let i = [];
  for (let n of po(r))
    t ? i.push({ from: n.from, insert: r.doc.slice(n.from, n.to) + r.lineBreak }) : i.push({ from: n.to, insert: r.lineBreak + r.doc.slice(n.from, n.to) });
  return e(r.update({ changes: i, scrollIntoView: !0, userEvent: "input.copyline" })), !0;
}
const ow = ({ state: r, dispatch: e }) => CO(r, e, !1), lw = ({ state: r, dispatch: e }) => CO(r, e, !0), aw = (r) => {
  if (r.state.readOnly)
    return !1;
  let { state: e } = r, t = e.changes(po(e).map(({ from: n, to: s }) => (n > 0 ? n-- : s < e.doc.length && s++, { from: n, to: s }))), i = nr(e.selection, (n) => r.moveVertically(n, !0)).map(t);
  return r.dispatch({ changes: t, selection: i, scrollIntoView: !0, userEvent: "delete.line" }), !0;
};
function hw(r, e) {
  if (/\(\)|\[\]|\{\}/.test(r.sliceDoc(e - 1, e + 1)))
    return { from: e, to: e };
  let t = ci(r).resolveInner(e), i = t.childBefore(e), n = t.childAfter(e), s;
  return i && n && i.to <= e && n.from >= e && (s = i.type.prop(ee.closedBy)) && s.indexOf(n.name) > -1 && r.doc.lineAt(i.to).from == r.doc.lineAt(n.from).from ? { from: i.to, to: n.from } : null;
}
const cw = /* @__PURE__ */ TO(!1), fw = /* @__PURE__ */ TO(!0);
function TO(r) {
  return ({ state: e, dispatch: t }) => {
    if (e.readOnly)
      return !1;
    let i = e.changeByRange((n) => {
      let { from: s, to: o } = n, l = e.doc.lineAt(s), a = !r && s == o && hw(e, s);
      r && (s = o = (o <= l.to ? l : e.doc.lineAt(o)).to);
      let h = new oo(e, { simulateBreak: s, simulateDoubleBreak: !!a }), c = Hp(h, s);
      for (c == null && (c = /^\s*/.exec(e.doc.lineAt(s).text)[0].length); o < l.to && /\s/.test(l.text[o - l.from]); )
        o++;
      a ? { from: s, to: o } = a : s > l.from && s < l.from + 100 && !/\S/.test(l.text.slice(0, s)) && (s = l.from);
      let f = ["", Rs(e, c)];
      return a && f.push(Rs(e, h.lineIndent(l.from, -1))), {
        changes: { from: s, to: o, insert: K.of(f) },
        range: v.cursor(s + 1 + f[1].length)
      };
    });
    return t(e.update(i, { scrollIntoView: !0, userEvent: "input" })), !0;
  };
}
function lh(r, e) {
  let t = -1;
  return r.changeByRange((i) => {
    let n = [];
    for (let o = i.from; o <= i.to; ) {
      let l = r.doc.lineAt(o);
      l.number > t && (i.empty || i.to > l.from) && (e(l, n, i), t = l.number), o = l.to + 1;
    }
    let s = r.changes(n);
    return {
      changes: n,
      range: v.range(s.mapPos(i.anchor, 1), s.mapPos(i.head, 1))
    };
  });
}
const uw = ({ state: r, dispatch: e }) => {
  if (r.readOnly)
    return !1;
  let t = /* @__PURE__ */ Object.create(null), i = new oo(r, { overrideIndentation: (s) => {
    let o = t[s];
    return o ?? -1;
  } }), n = lh(r, (s, o, l) => {
    let a = Hp(i, s.from);
    if (a == null)
      return;
    /\S/.test(s.text) || (a = 0);
    let h = /^\s*/.exec(s.text)[0], c = Rs(r, a);
    (h != c || l.from < s.from + h.length) && (t[s.from] = a, o.push({ from: s.from, to: s.from + h.length, insert: c }));
  });
  return n.changes.empty || e(r.update(n, { userEvent: "indent" })), !0;
}, AO = ({ state: r, dispatch: e }) => r.readOnly ? !1 : (e(r.update(lh(r, (t, i) => {
  i.push({ from: t.from, insert: r.facet(rh) });
}), { userEvent: "input.indent" })), !0), MO = ({ state: r, dispatch: e }) => r.readOnly ? !1 : (e(r.update(lh(r, (t, i) => {
  let n = /^\s*/.exec(t.text)[0];
  if (!n)
    return;
  let s = lt(n, r.tabSize), o = 0, l = Rs(r, Math.max(0, s - Xs(r)));
  for (; o < n.length && o < l.length && n.charCodeAt(o) == l.charCodeAt(o); )
    o++;
  i.push({ from: t.from + o, to: t.from + n.length, insert: l.slice(o) });
}), { userEvent: "delete.dedent" })), !0), dw = [
  { key: "Ctrl-b", run: lO, shift: OO, preventDefault: !0 },
  { key: "Ctrl-f", run: aO, shift: mO },
  { key: "Ctrl-p", run: fO, shift: yO },
  { key: "Ctrl-n", run: uO, shift: SO },
  { key: "Ctrl-a", run: BS, shift: GS },
  { key: "Ctrl-e", run: IS, shift: US },
  { key: "Ctrl-d", run: kO },
  { key: "Ctrl-h", run: Sa },
  { key: "Ctrl-k", run: $O },
  { key: "Ctrl-Alt-h", run: vO },
  { key: "Ctrl-o", run: iw },
  { key: "Ctrl-t", run: rw },
  { key: "Ctrl-v", run: ya }
], pw = /* @__PURE__ */ [
  { key: "ArrowLeft", run: lO, shift: OO, preventDefault: !0 },
  { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: LS, shift: YS },
  { mac: "Cmd-ArrowLeft", run: hf, shift: df },
  { key: "ArrowRight", run: aO, shift: mO, preventDefault: !0 },
  { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: ES, shift: NS },
  { mac: "Cmd-ArrowRight", run: af, shift: uf },
  { key: "ArrowUp", run: fO, shift: yO, preventDefault: !0 },
  { mac: "Cmd-ArrowUp", run: pf, shift: mf },
  { mac: "Ctrl-ArrowUp", run: lf, shift: cf },
  { key: "ArrowDown", run: uO, shift: SO, preventDefault: !0 },
  { mac: "Cmd-ArrowDown", run: Of, shift: gf },
  { mac: "Ctrl-ArrowDown", run: ya, shift: ff },
  { key: "PageUp", run: lf, shift: cf },
  { key: "PageDown", run: ya, shift: ff },
  { key: "Home", run: hf, shift: df, preventDefault: !0 },
  { key: "Mod-Home", run: pf, shift: mf },
  { key: "End", run: af, shift: uf, preventDefault: !0 },
  { key: "Mod-End", run: Of, shift: gf },
  { key: "Enter", run: cw },
  { key: "Mod-a", run: FS },
  { key: "Backspace", run: Sa, shift: Sa },
  { key: "Delete", run: kO },
  { key: "Mod-Backspace", mac: "Alt-Backspace", run: vO },
  { key: "Mod-Delete", mac: "Alt-Delete", run: ew },
  { mac: "Mod-Backspace", run: tw },
  { mac: "Mod-Delete", run: $O }
].concat(/* @__PURE__ */ dw.map((r) => ({ mac: r.key, run: r.run, shift: r.shift }))), Ow = /* @__PURE__ */ [
  { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: DS, shift: WS },
  { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: _S, shift: jS },
  { key: "Alt-ArrowUp", run: nw },
  { key: "Shift-Alt-ArrowUp", run: ow },
  { key: "Alt-ArrowDown", run: sw },
  { key: "Shift-Alt-ArrowDown", run: lw },
  { key: "Escape", run: JS },
  { key: "Mod-Enter", run: fw },
  { key: "Alt-l", mac: "Ctrl-l", run: HS },
  { key: "Mod-i", run: KS, preventDefault: !0 },
  { key: "Mod-[", run: MO },
  { key: "Mod-]", run: AO },
  { key: "Mod-Alt-\\", run: uw },
  { key: "Shift-Mod-k", run: aw },
  { key: "Shift-Mod-\\", run: qS },
  { key: "Mod-/", run: OS },
  { key: "Alt-A", run: gS }
].concat(pw), mw = { key: "Tab", run: AO, shift: MO }, bf = typeof String.prototype.normalize == "function" ? (r) => r.normalize("NFKD") : (r) => r;
class Ui {
  /**
  Create a text cursor. The query is the search string, `from` to
  `to` provides the region to search.
  
  When `normalize` is given, it will be called, on both the query
  string and the content it is matched against, before comparing.
  You can, for example, create a case-insensitive search by
  passing `s => s.toLowerCase()`.
  
  Text is always normalized with
  [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
  (when supported).
  */
  constructor(e, t, i = 0, n = e.length, s) {
    this.value = { from: 0, to: 0 }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(i, n), this.bufferStart = i, this.normalize = s ? (o) => s(bf(o)) : bf, this.query = this.normalize(t);
  }
  peek() {
    if (this.bufferPos == this.buffer.length) {
      if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done)
        return -1;
      this.bufferPos = 0, this.buffer = this.iter.value;
    }
    return Ee(this.buffer, this.bufferPos);
  }
  /**
  Look for the next match. Updates the iterator's
  [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
  [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
  at least once before using the cursor.
  */
  next() {
    for (; this.matches.length; )
      this.matches.pop();
    return this.nextOverlapping();
  }
  /**
  The `next` method will ignore matches that partially overlap a
  previous match. This method behaves like `next`, but includes
  such matches.
  */
  nextOverlapping() {
    for (; ; ) {
      let e = this.peek();
      if (e < 0)
        return this.done = !0, this;
      let t = Da(e), i = this.bufferStart + this.bufferPos;
      this.bufferPos += ot(e);
      let n = this.normalize(t);
      for (let s = 0, o = i; ; s++) {
        let l = n.charCodeAt(s), a = this.match(l, o);
        if (a)
          return this.value = a, this;
        if (s == n.length - 1)
          break;
        o == i && s < t.length && t.charCodeAt(s) == l && o++;
      }
    }
  }
  match(e, t) {
    let i = null;
    for (let n = 0; n < this.matches.length; n += 2) {
      let s = this.matches[n], o = !1;
      this.query.charCodeAt(s) == e && (s == this.query.length - 1 ? i = { from: this.matches[n + 1], to: t + 1 } : (this.matches[n]++, o = !0)), o || (this.matches.splice(n, 2), n -= 2);
    }
    return this.query.charCodeAt(0) == e && (this.query.length == 1 ? i = { from: t, to: t + 1 } : this.matches.push(1, t)), i;
  }
}
typeof Symbol < "u" && (Ui.prototype[Symbol.iterator] = function() {
  return this;
});
const ZO = { from: -1, to: -1, match: /* @__PURE__ */ /.*/.exec("") }, ah = "gm" + (/x/.unicode == null ? "" : "u");
class XO {
  /**
  Create a cursor that will search the given range in the given
  document. `query` should be the raw pattern (as you'd pass it to
  `new RegExp`).
  */
  constructor(e, t, i, n = 0, s = e.length) {
    if (this.to = s, this.curLine = "", this.done = !1, this.value = ZO, /\\[sWDnr]|\n|\r|\[\^/.test(t))
      return new RO(e, t, i, n, s);
    this.re = new RegExp(t, ah + (i?.ignoreCase ? "i" : "")), this.iter = e.iter();
    let o = e.lineAt(n);
    this.curLineStart = o.from, this.matchPos = n, this.getLine(this.curLineStart);
  }
  getLine(e) {
    this.iter.next(e), this.iter.lineBreak ? this.curLine = "" : (this.curLine = this.iter.value, this.curLineStart + this.curLine.length > this.to && (this.curLine = this.curLine.slice(0, this.to - this.curLineStart)), this.iter.next());
  }
  nextLine() {
    this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
  }
  /**
  Move to the next match, if there is one.
  */
  next() {
    for (let e = this.matchPos - this.curLineStart; ; ) {
      this.re.lastIndex = e;
      let t = this.matchPos <= this.to && this.re.exec(this.curLine);
      if (t) {
        let i = this.curLineStart + t.index, n = i + t[0].length;
        if (this.matchPos = n + (i == n ? 1 : 0), i == this.curLine.length && this.nextLine(), i < n || i > this.value.to)
          return this.value = { from: i, to: n, match: t }, this;
        e = this.matchPos - this.curLineStart;
      } else if (this.curLineStart + this.curLine.length < this.to)
        this.nextLine(), e = 0;
      else
        return this.done = !0, this;
    }
  }
}
const Wo = /* @__PURE__ */ new WeakMap();
class Bi {
  constructor(e, t) {
    this.from = e, this.text = t;
  }
  get to() {
    return this.from + this.text.length;
  }
  static get(e, t, i) {
    let n = Wo.get(e);
    if (!n || n.from >= i || n.to <= t) {
      let l = new Bi(t, e.sliceString(t, i));
      return Wo.set(e, l), l;
    }
    if (n.from == t && n.to == i)
      return n;
    let { text: s, from: o } = n;
    return o > t && (s = e.sliceString(t, o) + s, o = t), n.to < i && (s += e.sliceString(n.to, i)), Wo.set(e, new Bi(o, s)), new Bi(t, s.slice(t - o, i - o));
  }
}
class RO {
  constructor(e, t, i, n, s) {
    this.text = e, this.to = s, this.done = !1, this.value = ZO, this.matchPos = n, this.re = new RegExp(t, ah + (i?.ignoreCase ? "i" : "")), this.flat = Bi.get(e, n, this.chunkEnd(
      n + 5e3
      /* Base */
    ));
  }
  chunkEnd(e) {
    return e >= this.to ? this.to : this.text.lineAt(e).to;
  }
  next() {
    for (; ; ) {
      let e = this.re.lastIndex = this.matchPos - this.flat.from, t = this.re.exec(this.flat.text);
      if (t && !t[0] && t.index == e && (this.re.lastIndex = e + 1, t = this.re.exec(this.flat.text)), t && this.flat.to < this.to && t.index + t[0].length > this.flat.text.length - 10 && (t = null), t) {
        let i = this.flat.from + t.index, n = i + t[0].length;
        return this.value = { from: i, to: n, match: t }, this.matchPos = n + (i == n ? 1 : 0), this;
      } else {
        if (this.flat.to == this.to)
          return this.done = !0, this;
        this.flat = Bi.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
      }
    }
  }
}
typeof Symbol < "u" && (XO.prototype[Symbol.iterator] = RO.prototype[Symbol.iterator] = function() {
  return this;
});
function gw(r) {
  try {
    return new RegExp(r, ah), !0;
  } catch {
    return !1;
  }
}
function wa(r) {
  let e = fe("input", { class: "cm-textfield", name: "line" }), t = fe("form", {
    class: "cm-gotoLine",
    onkeydown: (n) => {
      n.keyCode == 27 ? (n.preventDefault(), r.dispatch({ effects: Es.of(!1) }), r.focus()) : n.keyCode == 13 && (n.preventDefault(), i());
    },
    onsubmit: (n) => {
      n.preventDefault(), i();
    }
  }, fe("label", r.state.phrase("Go to line"), ": ", e), " ", fe("button", { class: "cm-button", type: "submit" }, r.state.phrase("go")));
  function i() {
    let n = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);
    if (!n)
      return;
    let { state: s } = r, o = s.doc.lineAt(s.selection.main.head), [, l, a, h, c] = n, f = h ? +h.slice(1) : 0, u = a ? +a : o.number;
    if (a && c) {
      let p = u / 100;
      l && (p = p * (l == "-" ? -1 : 1) + o.number / s.doc.lines), u = Math.round(s.doc.lines * p);
    } else a && l && (u = u * (l == "-" ? -1 : 1) + o.number);
    let d = s.doc.line(Math.max(1, Math.min(s.doc.lines, u)));
    r.dispatch({
      effects: Es.of(!1),
      selection: v.cursor(d.from + Math.max(0, Math.min(f, d.length))),
      scrollIntoView: !0
    }), r.focus();
  }
  return { dom: t };
}
const Es = /* @__PURE__ */ V.define(), yf = /* @__PURE__ */ ge.define({
  create() {
    return !0;
  },
  update(r, e) {
    for (let t of e.effects)
      t.is(Es) && (r = t.value);
    return r;
  },
  provide: (r) => Nr.from(r, (e) => e ? wa : null)
}), bw = (r) => {
  let e = Yr(r, wa);
  if (!e) {
    let t = [Es.of(!0)];
    r.state.field(yf, !1) == null && t.push(V.appendConfig.of([yf, yw])), r.dispatch({ effects: t }), e = Yr(r, wa);
  }
  return e && e.dom.querySelector("input").focus(), !0;
}, yw = /* @__PURE__ */ D.baseTheme({
  ".cm-panel.cm-gotoLine": {
    padding: "2px 6px 4px",
    "& label": { fontSize: "80%" }
  }
}), Sw = {
  highlightWordAroundCursor: !1,
  minSelectionLength: 1,
  maxMatches: 100,
  wholeWords: !1
}, ww = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, Sw, {
      highlightWordAroundCursor: (e, t) => e || t,
      minSelectionLength: Math.min,
      maxMatches: Math.min
    });
  }
});
function xw(r) {
  return [Pw, $w];
}
const kw = /* @__PURE__ */ B.mark({ class: "cm-selectionMatch" }), Qw = /* @__PURE__ */ B.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
function Sf(r, e, t, i) {
  return (t == 0 || r(e.sliceDoc(t - 1, t)) != Ze.Word) && (i == e.doc.length || r(e.sliceDoc(i, i + 1)) != Ze.Word);
}
function vw(r, e, t, i) {
  return r(e.sliceDoc(t, t + 1)) == Ze.Word && r(e.sliceDoc(i - 1, i)) == Ze.Word;
}
const $w = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.decorations = this.getDeco(r);
  }
  update(r) {
    (r.selectionSet || r.docChanged || r.viewportChanged) && (this.decorations = this.getDeco(r.view));
  }
  getDeco(r) {
    let e = r.state.facet(ww), { state: t } = r, i = t.selection;
    if (i.ranges.length > 1)
      return B.none;
    let n = i.main, s, o = null;
    if (n.empty) {
      if (!e.highlightWordAroundCursor)
        return B.none;
      let a = t.wordAt(n.head);
      if (!a)
        return B.none;
      o = t.charCategorizer(n.head), s = t.sliceDoc(a.from, a.to);
    } else {
      let a = n.to - n.from;
      if (a < e.minSelectionLength || a > 200)
        return B.none;
      if (e.wholeWords) {
        if (s = t.sliceDoc(n.from, n.to), o = t.charCategorizer(n.head), !(Sf(o, t, n.from, n.to) && vw(o, t, n.from, n.to)))
          return B.none;
      } else if (s = t.sliceDoc(n.from, n.to).trim(), !s)
        return B.none;
    }
    let l = [];
    for (let a of r.visibleRanges) {
      let h = new Ui(t.doc, s, a.from, a.to);
      for (; !h.next().done; ) {
        let { from: c, to: f } = h.value;
        if ((!o || Sf(o, t, c, f)) && (n.empty && c <= n.from && f >= n.to ? l.push(Qw.range(c, f)) : (c >= n.to || f <= n.from) && l.push(kw.range(c, f)), l.length > e.maxMatches))
          return B.none;
      }
    }
    return B.set(l);
  }
}, {
  decorations: (r) => r.decorations
}), Pw = /* @__PURE__ */ D.baseTheme({
  ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
  ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
}), Cw = ({ state: r, dispatch: e }) => {
  let { selection: t } = r, i = v.create(t.ranges.map((n) => r.wordAt(n.head) || v.cursor(n.head)), t.mainIndex);
  return i.eq(t) ? !1 : (e(r.update({ selection: i })), !0);
};
function Tw(r, e) {
  let { main: t, ranges: i } = r.selection, n = r.wordAt(t.head), s = n && n.from == t.from && n.to == t.to;
  for (let o = !1, l = new Ui(r.doc, e, i[i.length - 1].to); ; )
    if (l.next(), l.done) {
      if (o)
        return null;
      l = new Ui(r.doc, e, 0, Math.max(0, i[i.length - 1].from - 1)), o = !0;
    } else {
      if (o && i.some((a) => a.from == l.value.from))
        continue;
      if (s) {
        let a = r.wordAt(l.value.from);
        if (!a || a.from != l.value.from || a.to != l.value.to)
          continue;
      }
      return l.value;
    }
}
const Aw = ({ state: r, dispatch: e }) => {
  let { ranges: t } = r.selection;
  if (t.some((s) => s.from === s.to))
    return Cw({ state: r, dispatch: e });
  let i = r.sliceDoc(t[0].from, t[0].to);
  if (r.selection.ranges.some((s) => r.sliceDoc(s.from, s.to) != i))
    return !1;
  let n = Tw(r, i);
  return n ? (e(r.update({
    selection: r.selection.addRange(v.range(n.from, n.to), !1),
    effects: D.scrollIntoView(n.to)
  })), !0) : !1;
}, hh = /* @__PURE__ */ R.define({
  combine(r) {
    var e;
    return {
      top: r.reduce((t, i) => t ?? i.top, void 0) || !1,
      caseSensitive: r.reduce((t, i) => t ?? i.caseSensitive, void 0) || !1,
      createPanel: ((e = r.find((t) => t.createPanel)) === null || e === void 0 ? void 0 : e.createPanel) || ((t) => new Bw(t))
    };
  }
});
class LO {
  /**
  Create a query object.
  */
  constructor(e) {
    this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || gw(this.search)), this.unquoted = e.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (t, i) => i == "n" ? `
` : i == "r" ? "\r" : i == "t" ? "	" : "\\");
  }
  /**
  Compare this query to another query.
  */
  eq(e) {
    return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp;
  }
  /**
  @internal
  */
  create() {
    return this.regexp ? new Zw(this) : new Mw(this);
  }
  /**
  Get a search cursor for this query, searching through the given
  range in the given document.
  */
  getCursor(e, t = 0, i = e.length) {
    return this.regexp ? Zi(this, e, t, i) : Mi(this, e, t, i);
  }
}
class EO {
  constructor(e) {
    this.spec = e;
  }
}
function Mi(r, e, t, i) {
  return new Ui(e, r.unquoted, t, i, r.caseSensitive ? void 0 : (n) => n.toLowerCase());
}
class Mw extends EO {
  constructor(e) {
    super(e);
  }
  nextMatch(e, t, i) {
    let n = Mi(this.spec, e, i, e.length).nextOverlapping();
    return n.done && (n = Mi(this.spec, e, 0, t).nextOverlapping()), n.done ? null : n.value;
  }
  // Searching in reverse is, rather than implementing inverted search
  // cursor, done by scanning chunk after chunk forward.
  prevMatchInRange(e, t, i) {
    for (let n = i; ; ) {
      let s = Math.max(t, n - 1e4 - this.spec.unquoted.length), o = Mi(this.spec, e, s, n), l = null;
      for (; !o.nextOverlapping().done; )
        l = o.value;
      if (l)
        return l;
      if (s == t)
        return null;
      n -= 1e4;
    }
  }
  prevMatch(e, t, i) {
    return this.prevMatchInRange(e, 0, t) || this.prevMatchInRange(e, i, e.length);
  }
  getReplacement(e) {
    return this.spec.replace;
  }
  matchAll(e, t) {
    let i = Mi(this.spec, e, 0, e.length), n = [];
    for (; !i.next().done; ) {
      if (n.length >= t)
        return null;
      n.push(i.value);
    }
    return n;
  }
  highlight(e, t, i, n) {
    let s = Mi(this.spec, e, Math.max(0, t - this.spec.unquoted.length), Math.min(i + this.spec.unquoted.length, e.length));
    for (; !s.next().done; )
      n(s.value.from, s.value.to);
  }
}
function Zi(r, e, t, i) {
  return new XO(e, r.search, r.caseSensitive ? void 0 : { ignoreCase: !0 }, t, i);
}
class Zw extends EO {
  nextMatch(e, t, i) {
    let n = Zi(this.spec, e, i, e.length).next();
    return n.done && (n = Zi(this.spec, e, 0, t).next()), n.done ? null : n.value;
  }
  prevMatchInRange(e, t, i) {
    for (let n = 1; ; n++) {
      let s = Math.max(
        t,
        i - n * 1e4
        /* ChunkSize */
      ), o = Zi(this.spec, e, s, i), l = null;
      for (; !o.next().done; )
        l = o.value;
      if (l && (s == t || l.from > s + 10))
        return l;
      if (s == t)
        return null;
    }
  }
  prevMatch(e, t, i) {
    return this.prevMatchInRange(e, 0, t) || this.prevMatchInRange(e, i, e.length);
  }
  getReplacement(e) {
    return this.spec.replace.replace(/\$([$&\d+])/g, (t, i) => i == "$" ? "$" : i == "&" ? e.match[0] : i != "0" && +i < e.match.length ? e.match[i] : t);
  }
  matchAll(e, t) {
    let i = Zi(this.spec, e, 0, e.length), n = [];
    for (; !i.next().done; ) {
      if (n.length >= t)
        return null;
      n.push(i.value);
    }
    return n;
  }
  highlight(e, t, i, n) {
    let s = Zi(this.spec, e, Math.max(
      0,
      t - 250
      /* HighlightMargin */
    ), Math.min(i + 250, e.length));
    for (; !s.next().done; )
      n(s.value.from, s.value.to);
  }
}
const Gr = /* @__PURE__ */ V.define(), ch = /* @__PURE__ */ V.define(), ni = /* @__PURE__ */ ge.define({
  create(r) {
    return new jo(xa(r).create(), null);
  },
  update(r, e) {
    for (let t of e.effects)
      t.is(Gr) ? r = new jo(t.value.create(), r.panel) : t.is(ch) && (r = new jo(r.query, t.value ? fh : null));
    return r;
  },
  provide: (r) => Nr.from(r, (e) => e.panel)
});
class jo {
  constructor(e, t) {
    this.query = e, this.panel = t;
  }
}
const Xw = /* @__PURE__ */ B.mark({ class: "cm-searchMatch" }), Rw = /* @__PURE__ */ B.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), Lw = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.decorations = this.highlight(r.state.field(ni));
  }
  update(r) {
    let e = r.state.field(ni);
    (e != r.startState.field(ni) || r.docChanged || r.selectionSet || r.viewportChanged) && (this.decorations = this.highlight(e));
  }
  highlight({ query: r, panel: e }) {
    if (!e || !r.spec.valid)
      return B.none;
    let { view: t } = this, i = new _t();
    for (let n = 0, s = t.visibleRanges, o = s.length; n < o; n++) {
      let { from: l, to: a } = s[n];
      for (; n < o - 1 && a > s[n + 1].from - 500; )
        a = s[++n].to;
      r.highlight(t.state.doc, l, a, (h, c) => {
        let f = t.state.selection.ranges.some((u) => u.from == h && u.to == c);
        i.add(h, c, f ? Rw : Xw);
      });
    }
    return i.finish();
  }
}, {
  decorations: (r) => r.decorations
});
function dn(r) {
  return (e) => {
    let t = e.state.field(ni, !1);
    return t && t.query.spec.valid ? r(e, t) : zO(e);
  };
}
const zs = /* @__PURE__ */ dn((r, { query: e }) => {
  let { from: t, to: i } = r.state.selection.main, n = e.nextMatch(r.state.doc, t, i);
  return !n || n.from == t && n.to == i ? !1 : (r.dispatch({
    selection: { anchor: n.from, head: n.to },
    scrollIntoView: !0,
    effects: uh(r, n),
    userEvent: "select.search"
  }), !0);
}), Ds = /* @__PURE__ */ dn((r, { query: e }) => {
  let { state: t } = r, { from: i, to: n } = t.selection.main, s = e.prevMatch(t.doc, i, n);
  return s ? (r.dispatch({
    selection: { anchor: s.from, head: s.to },
    scrollIntoView: !0,
    effects: uh(r, s),
    userEvent: "select.search"
  }), !0) : !1;
}), Ew = /* @__PURE__ */ dn((r, { query: e }) => {
  let t = e.matchAll(r.state.doc, 1e3);
  return !t || !t.length ? !1 : (r.dispatch({
    selection: v.create(t.map((i) => v.range(i.from, i.to))),
    userEvent: "select.search.matches"
  }), !0);
}), zw = ({ state: r, dispatch: e }) => {
  let t = r.selection;
  if (t.ranges.length > 1 || t.main.empty)
    return !1;
  let { from: i, to: n } = t.main, s = [], o = 0;
  for (let l = new Ui(r.doc, r.sliceDoc(i, n)); !l.next().done; ) {
    if (s.length > 1e3)
      return !1;
    l.value.from == i && (o = s.length), s.push(v.range(l.value.from, l.value.to));
  }
  return e(r.update({
    selection: v.create(s, o),
    userEvent: "select.search.matches"
  })), !0;
}, wf = /* @__PURE__ */ dn((r, { query: e }) => {
  let { state: t } = r, { from: i, to: n } = t.selection.main;
  if (t.readOnly)
    return !1;
  let s = e.nextMatch(t.doc, i, i);
  if (!s)
    return !1;
  let o = [], l, a;
  if (s.from == i && s.to == n && (a = t.toText(e.getReplacement(s)), o.push({ from: s.from, to: s.to, insert: a }), s = e.nextMatch(t.doc, s.from, s.to)), s) {
    let h = o.length == 0 || o[0].from >= s.to ? 0 : s.to - s.from - a.length;
    l = { anchor: s.from - h, head: s.to - h };
  }
  return r.dispatch({
    changes: o,
    selection: l,
    scrollIntoView: !!l,
    effects: s ? uh(r, s) : void 0,
    userEvent: "input.replace"
  }), !0;
}), Dw = /* @__PURE__ */ dn((r, { query: e }) => {
  if (r.state.readOnly)
    return !1;
  let t = e.matchAll(r.state.doc, 1e9).map((i) => {
    let { from: n, to: s } = i;
    return { from: n, to: s, insert: e.getReplacement(i) };
  });
  return t.length ? (r.dispatch({
    changes: t,
    userEvent: "input.replace.all"
  }), !0) : !1;
});
function fh(r) {
  return r.state.facet(hh).createPanel(r);
}
function xa(r, e) {
  var t;
  let i = r.selection.main, n = i.empty || i.to > i.from + 100 ? "" : r.sliceDoc(i.from, i.to), s = (t = e?.caseSensitive) !== null && t !== void 0 ? t : r.facet(hh).caseSensitive;
  return e && !n ? e : new LO({ search: n.replace(/\n/g, "\\n"), caseSensitive: s });
}
const zO = (r) => {
  let e = r.state.field(ni, !1);
  if (e && e.panel) {
    let t = Yr(r, fh);
    if (!t)
      return !1;
    let i = t.dom.querySelector("[name=search]");
    if (i != r.root.activeElement) {
      let n = xa(r.state, e.query.spec);
      n.valid && r.dispatch({ effects: Gr.of(n) }), i.focus(), i.select();
    }
  } else
    r.dispatch({ effects: [
      ch.of(!0),
      e ? Gr.of(xa(r.state, e.query.spec)) : V.appendConfig.of(Vw)
    ] });
  return !0;
}, DO = (r) => {
  let e = r.state.field(ni, !1);
  if (!e || !e.panel)
    return !1;
  let t = Yr(r, fh);
  return t && t.dom.contains(r.root.activeElement) && r.focus(), r.dispatch({ effects: ch.of(!1) }), !0;
}, _w = [
  { key: "Mod-f", run: zO, scope: "editor search-panel" },
  { key: "F3", run: zs, shift: Ds, scope: "editor search-panel", preventDefault: !0 },
  { key: "Mod-g", run: zs, shift: Ds, scope: "editor search-panel", preventDefault: !0 },
  { key: "Escape", run: DO, scope: "editor search-panel" },
  { key: "Mod-Shift-l", run: zw },
  { key: "Alt-g", run: bw },
  { key: "Mod-d", run: Aw, preventDefault: !0 }
];
class Bw {
  constructor(e) {
    this.view = e;
    let t = this.query = e.state.field(ni).query.spec;
    this.commit = this.commit.bind(this), this.searchField = fe("input", {
      value: t.search,
      placeholder: He(e, "Find"),
      "aria-label": He(e, "Find"),
      class: "cm-textfield",
      name: "search",
      onchange: this.commit,
      onkeyup: this.commit
    }), this.replaceField = fe("input", {
      value: t.replace,
      placeholder: He(e, "Replace"),
      "aria-label": He(e, "Replace"),
      class: "cm-textfield",
      name: "replace",
      onchange: this.commit,
      onkeyup: this.commit
    }), this.caseField = fe("input", {
      type: "checkbox",
      name: "case",
      checked: t.caseSensitive,
      onchange: this.commit
    }), this.reField = fe("input", {
      type: "checkbox",
      name: "re",
      checked: t.regexp,
      onchange: this.commit
    });
    function i(n, s, o) {
      return fe("button", { class: "cm-button", name: n, onclick: s, type: "button" }, o);
    }
    this.dom = fe("div", { onkeydown: (n) => this.keydown(n), class: "cm-search" }, [
      this.searchField,
      i("next", () => zs(e), [He(e, "next")]),
      i("prev", () => Ds(e), [He(e, "previous")]),
      i("select", () => Ew(e), [He(e, "all")]),
      fe("label", null, [this.caseField, He(e, "match case")]),
      fe("label", null, [this.reField, He(e, "regexp")]),
      ...e.state.readOnly ? [] : [
        fe("br"),
        this.replaceField,
        i("replace", () => wf(e), [He(e, "replace")]),
        i("replaceAll", () => Dw(e), [He(e, "replace all")]),
        fe("button", {
          name: "close",
          onclick: () => DO(e),
          "aria-label": He(e, "close"),
          type: "button"
        }, ["×"])
      ]
    ]);
  }
  commit() {
    let e = new LO({
      search: this.searchField.value,
      caseSensitive: this.caseField.checked,
      regexp: this.reField.checked,
      replace: this.replaceField.value
    });
    e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: Gr.of(e) }));
  }
  keydown(e) {
    w1(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? Ds : zs)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), wf(this.view));
  }
  update(e) {
    for (let t of e.transactions)
      for (let i of t.effects)
        i.is(Gr) && !i.value.eq(this.query) && this.setQuery(i.value);
  }
  setQuery(e) {
    this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp;
  }
  mount() {
    this.searchField.select();
  }
  get pos() {
    return 80;
  }
  get top() {
    return this.view.state.facet(hh).top;
  }
}
function He(r, e) {
  return r.state.phrase(e);
}
const In = 30, Vn = /[\s\.,:;?!]/;
function uh(r, { from: e, to: t }) {
  let i = r.state.doc.lineAt(e).from, n = r.state.doc.lineAt(t).to, s = Math.max(i, e - In), o = Math.min(n, t + In), l = r.state.sliceDoc(s, o);
  if (s != i) {
    for (let a = 0; a < In; a++)
      if (!Vn.test(l[a + 1]) && Vn.test(l[a])) {
        l = l.slice(a);
        break;
      }
  }
  if (o != n) {
    for (let a = l.length - 1; a > l.length - In; a--)
      if (!Vn.test(l[a - 1]) && Vn.test(l[a])) {
        l = l.slice(0, a);
        break;
      }
  }
  return D.announce.of(`${r.state.phrase("current match")}. ${l} ${r.state.phrase("on line")} ${r.state.doc.lineAt(e).number}`);
}
const Iw = /* @__PURE__ */ D.baseTheme({
  ".cm-panel.cm-search": {
    padding: "2px 6px 4px",
    position: "relative",
    "& [name=close]": {
      position: "absolute",
      top: "0",
      right: "4px",
      backgroundColor: "inherit",
      border: "none",
      font: "inherit",
      padding: 0,
      margin: 0
    },
    "& input, & button, & label": {
      margin: ".2em .6em .2em 0"
    },
    "& input[type=checkbox]": {
      marginRight: ".2em"
    },
    "& label": {
      fontSize: "80%",
      whiteSpace: "pre"
    }
  },
  "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
  "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
  "&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
  "&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
}), Vw = [
  ni,
  /* @__PURE__ */ Vt.lowest(Lw),
  Iw
];
let _O = class {
  /**
  Create a new completion context. (Mostly useful for testing
  completion sources—in the editor, the extension will create
  these for you.)
  */
  constructor(e, t, i) {
    this.state = e, this.pos = t, this.explicit = i, this.abortListeners = [];
  }
  /**
  Get the extent, content, and (if there is a token) type of the
  token before `this.pos`.
  */
  tokenBefore(e) {
    let t = Ue(this.state).resolveInner(this.pos, -1);
    for (; t && e.indexOf(t.name) < 0; )
      t = t.parent;
    return t ? {
      from: t.from,
      to: this.pos,
      text: this.state.sliceDoc(t.from, this.pos),
      type: t.type
    } : null;
  }
  /**
  Get the match of the given expression directly before the
  cursor.
  */
  matchBefore(e) {
    let t = this.state.doc.lineAt(this.pos), i = Math.max(t.from, this.pos - 250), n = t.text.slice(i - t.from, this.pos - t.from), s = n.search(BO(e, !1));
    return s < 0 ? null : { from: i + s, to: this.pos, text: n.slice(s) };
  }
  /**
  Yields true when the query has been aborted. Can be useful in
  asynchronous queries to avoid doing work that will be ignored.
  */
  get aborted() {
    return this.abortListeners == null;
  }
  /**
  Allows you to register abort handlers, which will be called when
  the query is
  [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
  */
  addEventListener(e, t) {
    e == "abort" && this.abortListeners && this.abortListeners.push(t);
  }
};
function xf(r) {
  let e = Object.keys(r).join(""), t = /\w/.test(e);
  return t && (e = e.replace(/\w/g, "")), `[${t ? "\\w" : ""}${e.replace(/[^\w\s]/g, "\\$&")}]`;
}
function qw(r) {
  let e = /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null);
  for (let { label: n } of r) {
    e[n[0]] = !0;
    for (let s = 1; s < n.length; s++)
      t[n[s]] = !0;
  }
  let i = xf(e) + xf(t) + "*$";
  return [new RegExp("^" + i), new RegExp(i)];
}
function Yw(r) {
  let e = r.map((n) => typeof n == "string" ? { label: n } : n), [t, i] = e.every((n) => /^\w+$/.test(n.label)) ? [/\w*$/, /\w+$/] : qw(e);
  return (n) => {
    let s = n.matchBefore(i);
    return s || n.explicit ? { from: s ? s.from : n.pos, options: e, validFor: t } : null;
  };
}
class kf {
  constructor(e, t, i) {
    this.completion = e, this.source = t, this.match = i;
  }
}
function si(r) {
  return r.selection.main.head;
}
function BO(r, e) {
  var t;
  let { source: i } = r, n = e && i[0] != "^", s = i[i.length - 1] != "$";
  return !n && !s ? r : new RegExp(`${n ? "^" : ""}(?:${i})${s ? "$" : ""}`, (t = r.flags) !== null && t !== void 0 ? t : r.ignoreCase ? "i" : "");
}
function Nw(r, e, t, i) {
  return Object.assign(Object.assign({}, r.changeByRange((n) => {
    if (n == r.selection.main)
      return {
        changes: { from: t, to: i, insert: e },
        range: v.cursor(t + e.length)
      };
    let s = i - t;
    return !n.empty || s && r.sliceDoc(n.from - s, n.from) != r.sliceDoc(t, i) ? { range: n } : {
      changes: { from: n.from - s, to: n.from, insert: e },
      range: v.cursor(n.from - s + e.length)
    };
  })), { userEvent: "input.complete" });
}
function IO(r, e) {
  const t = e.completion.apply || e.completion.label;
  let i = e.source;
  typeof t == "string" ? r.dispatch(Nw(r.state, t, i.from, i.to)) : t(r, e.completion, i.from, i.to);
}
const Qf = /* @__PURE__ */ new WeakMap();
function Ww(r) {
  if (!Array.isArray(r))
    return r;
  let e = Qf.get(r);
  return e || Qf.set(r, e = Yw(r)), e;
}
class jw {
  constructor(e) {
    this.pattern = e, this.chars = [], this.folded = [], this.any = [], this.precise = [], this.byWord = [];
    for (let t = 0; t < e.length; ) {
      let i = Ee(e, t), n = ot(i);
      this.chars.push(i);
      let s = e.slice(t, t + n), o = s.toUpperCase();
      this.folded.push(Ee(o == s ? s.toLowerCase() : o, 0)), t += n;
    }
    this.astral = e.length != this.chars.length;
  }
  // Matches a given word (completion) against the pattern (input).
  // Will return null for no match, and otherwise an array that starts
  // with the match score, followed by any number of `from, to` pairs
  // indicating the matched parts of `word`.
  //
  // The score is a number that is more negative the worse the match
  // is. See `Penalty` above.
  match(e) {
    if (this.pattern.length == 0)
      return [0];
    if (e.length < this.pattern.length)
      return null;
    let { chars: t, folded: i, any: n, precise: s, byWord: o } = this;
    if (t.length == 1) {
      let w = Ee(e, 0);
      return w == t[0] ? [0, 0, ot(w)] : w == i[0] ? [-200, 0, ot(w)] : null;
    }
    let l = e.indexOf(this.pattern);
    if (l == 0)
      return [0, 0, this.pattern.length];
    let a = t.length, h = 0;
    if (l < 0) {
      for (let w = 0, k = Math.min(e.length, 200); w < k && h < a; ) {
        let x = Ee(e, w);
        (x == t[h] || x == i[h]) && (n[h++] = w), w += ot(x);
      }
      if (h < a)
        return null;
    }
    let c = 0, f = 0, u = !1, d = 0, p = -1, O = -1, g = /[a-z]/.test(e), b = !0;
    for (let w = 0, k = Math.min(e.length, 200), x = 0; w < k && f < a; ) {
      let S = Ee(e, w);
      l < 0 && (c < a && S == t[c] && (s[c++] = w), d < a && (S == t[d] || S == i[d] ? (d == 0 && (p = w), O = w + 1, d++) : d = 0));
      let y, Q = S < 255 ? S >= 48 && S <= 57 || S >= 97 && S <= 122 ? 2 : S >= 65 && S <= 90 ? 1 : 0 : (y = Da(S)) != y.toLowerCase() ? 1 : y != y.toUpperCase() ? 2 : 0;
      (!w || Q == 1 && g || x == 0 && Q != 0) && (t[f] == S || i[f] == S && (u = !0) ? o[f++] = w : o.length && (b = !1)), x = Q, w += ot(S);
    }
    return f == a && o[0] == 0 && b ? this.result(-100 + (u ? -200 : 0), o, e) : d == a && p == 0 ? [-200 - e.length, 0, O] : l > -1 ? [-700 - e.length, l, l + this.pattern.length] : d == a ? [-900 - e.length, p, O] : f == a ? this.result(-100 + (u ? -200 : 0) + -700 + (b ? 0 : -1100), o, e) : t.length == 2 ? null : this.result((n[0] ? -700 : 0) + -200 + -1100, n, e);
  }
  result(e, t, i) {
    let n = [e - i.length], s = 1;
    for (let o of t) {
      let l = o + (this.astral ? ot(Ee(i, o)) : 1);
      s > 1 && n[s - 1] == o ? n[s - 1] = l : (n[s++] = o, n[s++] = l);
    }
    return n;
  }
}
const fi = /* @__PURE__ */ R.define({
  combine(r) {
    return Yt(r, {
      activateOnTyping: !0,
      override: null,
      closeOnBlur: !0,
      maxRenderedOptions: 100,
      defaultKeymap: !0,
      optionClass: () => "",
      aboveCursor: !1,
      icons: !0,
      addToOptions: []
    }, {
      defaultKeymap: (e, t) => e && t,
      closeOnBlur: (e, t) => e && t,
      icons: (e, t) => e && t,
      optionClass: (e, t) => (i) => Gw(e(i), t(i)),
      addToOptions: (e, t) => e.concat(t)
    });
  }
});
function Gw(r, e) {
  return r ? e ? r + " " + e : r : e;
}
function Uw(r) {
  let e = r.addToOptions.slice();
  return r.icons && e.push({
    render(t) {
      let i = document.createElement("div");
      return i.classList.add("cm-completionIcon"), t.type && i.classList.add(...t.type.split(/\s+/g).map((n) => "cm-completionIcon-" + n)), i.setAttribute("aria-hidden", "true"), i;
    },
    position: 20
  }), e.push({
    render(t, i, n) {
      let s = document.createElement("span");
      s.className = "cm-completionLabel";
      let { label: o } = t, l = 0;
      for (let a = 1; a < n.length; ) {
        let h = n[a++], c = n[a++];
        h > l && s.appendChild(document.createTextNode(o.slice(l, h)));
        let f = s.appendChild(document.createElement("span"));
        f.appendChild(document.createTextNode(o.slice(h, c))), f.className = "cm-completionMatchedText", l = c;
      }
      return l < o.length && s.appendChild(document.createTextNode(o.slice(l))), s;
    },
    position: 50
  }, {
    render(t) {
      if (!t.detail)
        return null;
      let i = document.createElement("span");
      return i.className = "cm-completionDetail", i.textContent = t.detail, i;
    },
    position: 80
  }), e.sort((t, i) => t.position - i.position).map((t) => t.render);
}
function vf(r, e, t) {
  if (r <= t)
    return { from: 0, to: r };
  if (e <= r >> 1) {
    let n = Math.floor(e / t);
    return { from: n * t, to: (n + 1) * t };
  }
  let i = Math.floor((r - e) / t);
  return { from: r - (i + 1) * t, to: r - i * t };
}
class Fw {
  constructor(e, t) {
    this.view = e, this.stateField = t, this.info = null, this.placeInfo = {
      read: () => this.measureInfo(),
      write: (l) => this.positionInfo(l),
      key: this
    };
    let i = e.state.field(t), { options: n, selected: s } = i.open, o = e.state.facet(fi);
    this.optionContent = Uw(o), this.optionClass = o.optionClass, this.range = vf(n.length, s, o.maxRenderedOptions), this.dom = document.createElement("div"), this.dom.className = "cm-tooltip-autocomplete", this.dom.addEventListener("mousedown", (l) => {
      for (let a = l.target, h; a && a != this.dom; a = a.parentNode)
        if (a.nodeName == "LI" && (h = /-(\d+)$/.exec(a.id)) && +h[1] < n.length) {
          IO(e, n[+h[1]]), l.preventDefault();
          return;
        }
    }), this.list = this.dom.appendChild(this.createListBox(n, i.id, this.range)), this.list.addEventListener("scroll", () => {
      this.info && this.view.requestMeasure(this.placeInfo);
    });
  }
  mount() {
    this.updateSel();
  }
  update(e) {
    e.state.field(this.stateField) != e.startState.field(this.stateField) && this.updateSel();
  }
  positioned() {
    this.info && this.view.requestMeasure(this.placeInfo);
  }
  updateSel() {
    let e = this.view.state.field(this.stateField), t = e.open;
    if ((t.selected < this.range.from || t.selected >= this.range.to) && (this.range = vf(t.options.length, t.selected, this.view.state.facet(fi).maxRenderedOptions), this.list.remove(), this.list = this.dom.appendChild(this.createListBox(t.options, e.id, this.range)), this.list.addEventListener("scroll", () => {
      this.info && this.view.requestMeasure(this.placeInfo);
    })), this.updateSelectedOption(t.selected)) {
      this.info && (this.info.remove(), this.info = null);
      let { completion: i } = t.options[t.selected], { info: n } = i;
      if (!n)
        return;
      let s = typeof n == "string" ? document.createTextNode(n) : n(i);
      if (!s)
        return;
      "then" in s ? s.then((o) => {
        o && this.view.state.field(this.stateField, !1) == e && this.addInfoPane(o);
      }).catch((o) => Qe(this.view.state, o, "completion info")) : this.addInfoPane(s);
    }
  }
  addInfoPane(e) {
    let t = this.info = document.createElement("div");
    t.className = "cm-tooltip cm-completionInfo", t.appendChild(e), this.dom.appendChild(t), this.view.requestMeasure(this.placeInfo);
  }
  updateSelectedOption(e) {
    let t = null;
    for (let i = this.list.firstChild, n = this.range.from; i; i = i.nextSibling, n++)
      n == e ? i.hasAttribute("aria-selected") || (i.setAttribute("aria-selected", "true"), t = i) : i.hasAttribute("aria-selected") && i.removeAttribute("aria-selected");
    return t && Kw(this.list, t), t;
  }
  measureInfo() {
    let e = this.dom.querySelector("[aria-selected]");
    if (!e || !this.info)
      return null;
    let t = this.dom.getBoundingClientRect(), i = this.info.getBoundingClientRect(), n = e.getBoundingClientRect();
    if (n.top > Math.min(innerHeight, t.bottom) - 10 || n.bottom < Math.max(0, t.top) + 10)
      return null;
    let s = Math.max(0, Math.min(n.top, innerHeight - i.height)) - t.top, o = this.view.textDirection == ce.RTL, l = t.left, a = innerWidth - t.right;
    return o && l < Math.min(i.width, a) ? o = !1 : !o && a < Math.min(i.width, l) && (o = !0), { top: s, left: o };
  }
  positionInfo(e) {
    this.info && (this.info.style.top = (e ? e.top : -1e6) + "px", e && (this.info.classList.toggle("cm-completionInfo-left", e.left), this.info.classList.toggle("cm-completionInfo-right", !e.left)));
  }
  createListBox(e, t, i) {
    const n = document.createElement("ul");
    n.id = t, n.setAttribute("role", "listbox"), n.setAttribute("aria-expanded", "true"), n.setAttribute("aria-label", this.view.state.phrase("Completions"));
    for (let s = i.from; s < i.to; s++) {
      let { completion: o, match: l } = e[s];
      const a = n.appendChild(document.createElement("li"));
      a.id = t + "-" + s, a.setAttribute("role", "option");
      let h = this.optionClass(o);
      h && (a.className = h);
      for (let c of this.optionContent) {
        let f = c(o, this.view.state, l);
        f && a.appendChild(f);
      }
    }
    return i.from && n.classList.add("cm-completionListIncompleteTop"), i.to < e.length && n.classList.add("cm-completionListIncompleteBottom"), n;
  }
}
function Hw(r) {
  return (e) => new Fw(e, r);
}
function Kw(r, e) {
  let t = r.getBoundingClientRect(), i = e.getBoundingClientRect();
  i.top < t.top ? r.scrollTop -= t.top - i.top : i.bottom > t.bottom && (r.scrollTop += i.bottom - t.bottom);
}
function $f(r) {
  return (r.boost || 0) * 100 + (r.apply ? 10 : 0) + (r.info ? 5 : 0) + (r.type ? 1 : 0);
}
function Jw(r, e) {
  let t = [], i = 0;
  for (let o of r)
    if (o.hasResult())
      if (o.result.filter === !1) {
        let l = o.result.getMatch;
        for (let a of o.result.options) {
          let h = [1e9 - i++];
          if (l)
            for (let c of l(a))
              h.push(c);
          t.push(new kf(a, o, h));
        }
      } else {
        let l = new jw(e.sliceDoc(o.from, o.to)), a;
        for (let h of o.result.options)
          (a = l.match(h.label)) && (h.boost != null && (a[0] += h.boost), t.push(new kf(h, o, a)));
      }
  let n = [], s = null;
  for (let o of t.sort(rx))
    !s || s.label != o.completion.label || s.detail != o.completion.detail || s.type != null && o.completion.type != null && s.type != o.completion.type || s.apply != o.completion.apply ? n.push(o) : $f(o.completion) > $f(s) && (n[n.length - 1] = o), s = o.completion;
  return n;
}
class Xr {
  constructor(e, t, i, n, s) {
    this.options = e, this.attrs = t, this.tooltip = i, this.timestamp = n, this.selected = s;
  }
  setSelected(e, t) {
    return e == this.selected || e >= this.options.length ? this : new Xr(this.options, Pf(t, e), this.tooltip, this.timestamp, e);
  }
  static build(e, t, i, n, s) {
    let o = Jw(e, t);
    if (!o.length)
      return null;
    let l = 0;
    if (n && n.selected) {
      let a = n.options[n.selected].completion;
      for (let h = 0; h < o.length; h++)
        if (o[h].completion == a) {
          l = h;
          break;
        }
    }
    return new Xr(o, Pf(i, l), {
      pos: e.reduce((a, h) => h.hasResult() ? Math.min(a, h.from) : a, 1e8),
      create: Hw(Ke),
      above: s.aboveCursor
    }, n ? n.timestamp : Date.now(), l);
  }
  map(e) {
    return new Xr(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: e.mapPos(this.tooltip.pos) }), this.timestamp, this.selected);
  }
}
class _s {
  constructor(e, t, i) {
    this.active = e, this.id = t, this.open = i;
  }
  static start() {
    return new _s(ix, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
  }
  update(e) {
    let { state: t } = e, i = t.facet(fi), s = (i.override || t.languageDataAt("autocomplete", si(t)).map(Ww)).map((l) => (this.active.find((h) => h.source == l) || new ze(
      l,
      this.active.some(
        (h) => h.state != 0
        /* Inactive */
      ) ? 1 : 0
      /* Inactive */
    )).update(e, i));
    s.length == this.active.length && s.every((l, a) => l == this.active[a]) && (s = this.active);
    let o = e.selection || s.some((l) => l.hasResult() && e.changes.touchesRange(l.from, l.to)) || !ex(s, this.active) ? Xr.build(s, t, this.id, this.open, i) : this.open && e.docChanged ? this.open.map(e.changes) : this.open;
    !o && s.every(
      (l) => l.state != 1
      /* Pending */
    ) && s.some((l) => l.hasResult()) && (s = s.map((l) => l.hasResult() ? new ze(
      l.source,
      0
      /* Inactive */
    ) : l));
    for (let l of e.effects)
      l.is(qO) && (o = o && o.setSelected(l.value, this.id));
    return s == this.active && o == this.open ? this : new _s(s, this.id, o);
  }
  get tooltip() {
    return this.open ? this.open.tooltip : null;
  }
  get attrs() {
    return this.open ? this.open.attrs : tx;
  }
}
function ex(r, e) {
  if (r == e)
    return !0;
  for (let t = 0, i = 0; ; ) {
    for (; t < r.length && !r[t].hasResult; )
      t++;
    for (; i < e.length && !e[i].hasResult; )
      i++;
    let n = t == r.length, s = i == e.length;
    if (n || s)
      return n == s;
    if (r[t++].result != e[i++].result)
      return !1;
  }
}
const tx = {
  "aria-autocomplete": "list"
};
function Pf(r, e) {
  return {
    "aria-autocomplete": "list",
    "aria-haspopup": "listbox",
    "aria-activedescendant": r + "-" + e,
    "aria-controls": r
  };
}
const ix = [];
function rx(r, e) {
  let t = e.match[0] - r.match[0];
  return t || r.completion.label.localeCompare(e.completion.label);
}
function ka(r) {
  return r.isUserEvent("input.type") ? "input" : r.isUserEvent("delete.backward") ? "delete" : null;
}
class ze {
  constructor(e, t, i = -1) {
    this.source = e, this.state = t, this.explicitPos = i;
  }
  hasResult() {
    return !1;
  }
  update(e, t) {
    let i = ka(e), n = this;
    i ? n = n.handleUserEvent(e, i, t) : e.docChanged ? n = n.handleChange(e) : e.selection && n.state != 0 && (n = new ze(
      n.source,
      0
      /* Inactive */
    ));
    for (let s of e.effects)
      if (s.is(dh))
        n = new ze(n.source, 1, s.value ? si(e.state) : -1);
      else if (s.is(Bs))
        n = new ze(
          n.source,
          0
          /* Inactive */
        );
      else if (s.is(VO))
        for (let o of s.value)
          o.source == n.source && (n = o);
    return n;
  }
  handleUserEvent(e, t, i) {
    return t == "delete" || !i.activateOnTyping ? this.map(e.changes) : new ze(
      this.source,
      1
      /* Pending */
    );
  }
  handleChange(e) {
    return e.changes.touchesRange(si(e.startState)) ? new ze(
      this.source,
      0
      /* Inactive */
    ) : this.map(e.changes);
  }
  map(e) {
    return e.empty || this.explicitPos < 0 ? this : new ze(this.source, this.state, e.mapPos(this.explicitPos));
  }
}
class Rr extends ze {
  constructor(e, t, i, n, s) {
    super(e, 2, t), this.result = i, this.from = n, this.to = s;
  }
  hasResult() {
    return !0;
  }
  handleUserEvent(e, t, i) {
    var n;
    let s = e.changes.mapPos(this.from), o = e.changes.mapPos(this.to, 1), l = si(e.state);
    if ((this.explicitPos < 0 ? l <= s : l < this.from) || l > o || t == "delete" && si(e.startState) == this.from)
      return new ze(
        this.source,
        t == "input" && i.activateOnTyping ? 1 : 0
        /* Inactive */
      );
    let a = this.explicitPos < 0 ? -1 : e.changes.mapPos(this.explicitPos), h;
    return nx(this.result.validFor, e.state, s, o) ? new Rr(this.source, a, this.result, s, o) : this.result.update && (h = this.result.update(this.result, s, o, new _O(e.state, l, a >= 0))) ? new Rr(this.source, a, h, h.from, (n = h.to) !== null && n !== void 0 ? n : si(e.state)) : new ze(this.source, 1, a);
  }
  handleChange(e) {
    return e.changes.touchesRange(this.from, this.to) ? new ze(
      this.source,
      0
      /* Inactive */
    ) : this.map(e.changes);
  }
  map(e) {
    return e.empty ? this : new Rr(this.source, this.explicitPos < 0 ? -1 : e.mapPos(this.explicitPos), this.result, e.mapPos(this.from), e.mapPos(this.to, 1));
  }
}
function nx(r, e, t, i) {
  if (!r)
    return !1;
  let n = e.sliceDoc(t, i);
  return typeof r == "function" ? r(n, t, i, e) : BO(r, !0).test(n);
}
const dh = /* @__PURE__ */ V.define(), Bs = /* @__PURE__ */ V.define(), VO = /* @__PURE__ */ V.define({
  map(r, e) {
    return r.map((t) => t.map(e));
  }
}), qO = /* @__PURE__ */ V.define(), Ke = /* @__PURE__ */ ge.define({
  create() {
    return _s.start();
  },
  update(r, e) {
    return r.update(e);
  },
  provide: (r) => [
    Ka.from(r, (e) => e.tooltip),
    D.contentAttributes.from(r, (e) => e.attrs)
  ]
}), YO = 75;
function qn(r, e = "option") {
  return (t) => {
    let i = t.state.field(Ke, !1);
    if (!i || !i.open || Date.now() - i.open.timestamp < YO)
      return !1;
    let n = 1, s;
    e == "page" && (s = ab(t, i.open.tooltip)) && (n = Math.max(2, Math.floor(s.dom.offsetHeight / s.dom.querySelector("li").offsetHeight) - 1));
    let o = i.open.selected + n * (r ? 1 : -1), { length: l } = i.open.options;
    return o < 0 ? o = e == "page" ? 0 : l - 1 : o >= l && (o = e == "page" ? l - 1 : 0), t.dispatch({ effects: qO.of(o) }), !0;
  };
}
const sx = (r) => {
  let e = r.state.field(Ke, !1);
  return r.state.readOnly || !e || !e.open || Date.now() - e.open.timestamp < YO ? !1 : (IO(r, e.open.options[e.open.selected]), !0);
}, ox = (r) => r.state.field(Ke, !1) ? (r.dispatch({ effects: dh.of(!0) }), !0) : !1, lx = (r) => {
  let e = r.state.field(Ke, !1);
  return !e || !e.active.some(
    (t) => t.state != 0
    /* Inactive */
  ) ? !1 : (r.dispatch({ effects: Bs.of(null) }), !0);
};
class ax {
  constructor(e, t) {
    this.active = e, this.context = t, this.time = Date.now(), this.updates = [], this.done = void 0;
  }
}
const Cf = 50, hx = 50, cx = 1e3, fx = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.debounceUpdate = -1, this.running = [], this.debounceAccept = -1, this.composing = 0;
    for (let e of r.state.field(Ke).active)
      e.state == 1 && this.startQuery(e);
  }
  update(r) {
    let e = r.state.field(Ke);
    if (!r.selectionSet && !r.docChanged && r.startState.field(Ke) == e)
      return;
    let t = r.transactions.some((i) => (i.selection || i.docChanged) && !ka(i));
    for (let i = 0; i < this.running.length; i++) {
      let n = this.running[i];
      if (t || n.updates.length + r.transactions.length > hx && Date.now() - n.time > cx) {
        for (let s of n.context.abortListeners)
          try {
            s();
          } catch (o) {
            Qe(this.view.state, o);
          }
        n.context.abortListeners = null, this.running.splice(i--, 1);
      } else
        n.updates.push(...r.transactions);
    }
    if (this.debounceUpdate > -1 && clearTimeout(this.debounceUpdate), this.debounceUpdate = e.active.some((i) => i.state == 1 && !this.running.some((n) => n.active.source == i.source)) ? setTimeout(() => this.startUpdate(), Cf) : -1, this.composing != 0)
      for (let i of r.transactions)
        ka(i) == "input" ? this.composing = 2 : this.composing == 2 && i.selection && (this.composing = 3);
  }
  startUpdate() {
    this.debounceUpdate = -1;
    let { state: r } = this.view, e = r.field(Ke);
    for (let t of e.active)
      t.state == 1 && !this.running.some((i) => i.active.source == t.source) && this.startQuery(t);
  }
  startQuery(r) {
    let { state: e } = this.view, t = si(e), i = new _O(e, t, r.explicitPos == t), n = new ax(r, i);
    this.running.push(n), Promise.resolve(r.source(i)).then((s) => {
      n.context.aborted || (n.done = s || null, this.scheduleAccept());
    }, (s) => {
      this.view.dispatch({ effects: Bs.of(null) }), Qe(this.view.state, s);
    });
  }
  scheduleAccept() {
    this.running.every((r) => r.done !== void 0) ? this.accept() : this.debounceAccept < 0 && (this.debounceAccept = setTimeout(() => this.accept(), Cf));
  }
  // For each finished query in this.running, try to create a result
  // or, if appropriate, restart the query.
  accept() {
    var r;
    this.debounceAccept > -1 && clearTimeout(this.debounceAccept), this.debounceAccept = -1;
    let e = [], t = this.view.state.facet(fi);
    for (let i = 0; i < this.running.length; i++) {
      let n = this.running[i];
      if (n.done === void 0)
        continue;
      if (this.running.splice(i--, 1), n.done) {
        let o = new Rr(n.active.source, n.active.explicitPos, n.done, n.done.from, (r = n.done.to) !== null && r !== void 0 ? r : si(n.updates.length ? n.updates[0].startState : this.view.state));
        for (let l of n.updates)
          o = o.update(l, t);
        if (o.hasResult()) {
          e.push(o);
          continue;
        }
      }
      let s = this.view.state.field(Ke).active.find((o) => o.source == n.active.source);
      if (s && s.state == 1)
        if (n.done == null) {
          let o = new ze(
            n.active.source,
            0
            /* Inactive */
          );
          for (let l of n.updates)
            o = o.update(l, t);
          o.state != 1 && e.push(o);
        } else
          this.startQuery(s);
    }
    e.length && this.view.dispatch({ effects: VO.of(e) });
  }
}, {
  eventHandlers: {
    blur() {
      let r = this.view.state.field(Ke, !1);
      r && r.tooltip && this.view.state.facet(fi).closeOnBlur && this.view.dispatch({ effects: Bs.of(null) });
    },
    compositionstart() {
      this.composing = 1;
    },
    compositionend() {
      this.composing == 3 && setTimeout(() => this.view.dispatch({ effects: dh.of(!1) }), 20), this.composing = 0;
    }
  }
}), ux = /* @__PURE__ */ D.baseTheme({
  ".cm-tooltip.cm-tooltip-autocomplete": {
    "& > ul": {
      fontFamily: "monospace",
      whiteSpace: "nowrap",
      overflow: "hidden auto",
      maxWidth_fallback: "700px",
      maxWidth: "min(700px, 95vw)",
      minWidth: "250px",
      maxHeight: "10em",
      listStyle: "none",
      margin: 0,
      padding: 0,
      "& > li": {
        overflowX: "hidden",
        textOverflow: "ellipsis",
        cursor: "pointer",
        padding: "1px 3px",
        lineHeight: 1.2
      }
    }
  },
  "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
    background: "#17c",
    color: "white"
  },
  "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
    background: "#347",
    color: "white"
  },
  ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
    content: '"···"',
    opacity: 0.5,
    display: "block",
    textAlign: "center"
  },
  ".cm-tooltip.cm-completionInfo": {
    position: "absolute",
    padding: "3px 9px",
    width: "max-content",
    maxWidth: "300px"
  },
  ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
  ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
  "&light .cm-snippetField": { backgroundColor: "#00000022" },
  "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
  ".cm-snippetFieldPosition": {
    verticalAlign: "text-top",
    width: 0,
    height: "1.15em",
    margin: "0 -0.7px -.7em",
    borderLeft: "1.4px dotted #888"
  },
  ".cm-completionMatchedText": {
    textDecoration: "underline"
  },
  ".cm-completionDetail": {
    marginLeft: "0.5em",
    fontStyle: "italic"
  },
  ".cm-completionIcon": {
    fontSize: "90%",
    width: ".8em",
    display: "inline-block",
    textAlign: "center",
    paddingRight: ".6em",
    opacity: "0.6"
  },
  ".cm-completionIcon-function, .cm-completionIcon-method": {
    "&:after": { content: "'ƒ'" }
  },
  ".cm-completionIcon-class": {
    "&:after": { content: "'○'" }
  },
  ".cm-completionIcon-interface": {
    "&:after": { content: "'◌'" }
  },
  ".cm-completionIcon-variable": {
    "&:after": { content: "'𝑥'" }
  },
  ".cm-completionIcon-constant": {
    "&:after": { content: "'𝐶'" }
  },
  ".cm-completionIcon-type": {
    "&:after": { content: "'𝑡'" }
  },
  ".cm-completionIcon-enum": {
    "&:after": { content: "'∪'" }
  },
  ".cm-completionIcon-property": {
    "&:after": { content: "'□'" }
  },
  ".cm-completionIcon-keyword": {
    "&:after": { content: "'🔑︎'" }
    // Disable emoji rendering
  },
  ".cm-completionIcon-namespace": {
    "&:after": { content: "'▢'" }
  },
  ".cm-completionIcon-text": {
    "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
  }
}), Is = {
  brackets: ["(", "[", "{", "'", '"'],
  before: ")]}:;>"
}, ki = /* @__PURE__ */ V.define({
  map(r, e) {
    let t = e.mapPos(r, -1, ke.TrackAfter);
    return t ?? void 0;
  }
}), ph = /* @__PURE__ */ V.define({
  map(r, e) {
    return e.mapPos(r);
  }
}), Oh = /* @__PURE__ */ new class extends oi {
}();
Oh.startSide = 1;
Oh.endSide = -1;
const NO = /* @__PURE__ */ ge.define({
  create() {
    return H.empty;
  },
  update(r, e) {
    if (e.selection) {
      let t = e.state.doc.lineAt(e.selection.main.head).from, i = e.startState.doc.lineAt(e.startState.selection.main.head).from;
      t != e.changes.mapPos(i, -1) && (r = H.empty);
    }
    r = r.map(e.changes);
    for (let t of e.effects)
      t.is(ki) ? r = r.update({ add: [Oh.range(t.value, t.value + 1)] }) : t.is(ph) && (r = r.update({ filter: (i) => i != t.value }));
    return r;
  }
});
function dx() {
  return [Ox, NO];
}
const Go = "()[]{}<>";
function WO(r) {
  for (let e = 0; e < Go.length; e += 2)
    if (Go.charCodeAt(e) == r)
      return Go.charAt(e + 1);
  return Da(r < 128 ? r : r + 1);
}
function jO(r, e) {
  return r.languageDataAt("closeBrackets", e)[0] || Is;
}
const px = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent), Ox = /* @__PURE__ */ D.inputHandler.of((r, e, t, i) => {
  if ((px ? r.composing : r.compositionStarted) || r.state.readOnly)
    return !1;
  let n = r.state.selection.main;
  if (i.length > 2 || i.length == 2 && ot(Ee(i, 0)) == 1 || e != n.from || t != n.to)
    return !1;
  let s = bx(r.state, i);
  return s ? (r.dispatch(s), !0) : !1;
}), mx = ({ state: r, dispatch: e }) => {
  if (r.readOnly)
    return !1;
  let i = jO(r, r.selection.main.head).brackets || Is.brackets, n = null, s = r.changeByRange((o) => {
    if (o.empty) {
      let l = yx(r.doc, o.head);
      for (let a of i)
        if (a == l && Oo(r.doc, o.head) == WO(Ee(a, 0)))
          return {
            changes: { from: o.head - a.length, to: o.head + a.length },
            range: v.cursor(o.head - a.length),
            userEvent: "delete.backward"
          };
    }
    return { range: n = o };
  });
  return n || e(r.update(s, { scrollIntoView: !0 })), !n;
}, gx = [
  { key: "Backspace", run: mx }
];
function bx(r, e) {
  let t = jO(r, r.selection.main.head), i = t.brackets || Is.brackets;
  for (let n of i) {
    let s = WO(Ee(n, 0));
    if (e == n)
      return s == n ? xx(r, n, i.indexOf(n + n + n) > -1) : Sx(r, n, s, t.before || Is.before);
    if (e == s && GO(r, r.selection.main.from))
      return wx(r, n, s);
  }
  return null;
}
function GO(r, e) {
  let t = !1;
  return r.field(NO).between(0, r.doc.length, (i) => {
    i == e && (t = !0);
  }), t;
}
function Oo(r, e) {
  let t = r.sliceString(e, e + 2);
  return t.slice(0, ot(Ee(t, 0)));
}
function yx(r, e) {
  let t = r.sliceString(e - 2, e);
  return ot(Ee(t, 0)) == t.length ? t : t.slice(1);
}
function Sx(r, e, t, i) {
  let n = null, s = r.changeByRange((o) => {
    if (!o.empty)
      return {
        changes: [{ insert: e, from: o.from }, { insert: t, from: o.to }],
        effects: ki.of(o.to + e.length),
        range: v.range(o.anchor + e.length, o.head + e.length)
      };
    let l = Oo(r.doc, o.head);
    return !l || /\s/.test(l) || i.indexOf(l) > -1 ? {
      changes: { insert: e + t, from: o.head },
      effects: ki.of(o.head + e.length),
      range: v.cursor(o.head + e.length)
    } : { range: n = o };
  });
  return n ? null : r.update(s, {
    scrollIntoView: !0,
    userEvent: "input.type"
  });
}
function wx(r, e, t) {
  let i = null, n = r.selection.ranges.map((s) => s.empty && Oo(r.doc, s.head) == t ? v.cursor(s.head + t.length) : i = s);
  return i ? null : r.update({
    selection: v.create(n, r.selection.mainIndex),
    scrollIntoView: !0,
    effects: r.selection.ranges.map(({ from: s }) => ph.of(s))
  });
}
function xx(r, e, t) {
  let i = null, n = r.changeByRange((s) => {
    if (!s.empty)
      return {
        changes: [{ insert: e, from: s.from }, { insert: e, from: s.to }],
        effects: ki.of(s.to + e.length),
        range: v.range(s.anchor + e.length, s.head + e.length)
      };
    let o = s.head, l = Oo(r.doc, o);
    if (l == e) {
      if (Tf(r, o))
        return {
          changes: { insert: e + e, from: o },
          effects: ki.of(o + e.length),
          range: v.cursor(o + e.length)
        };
      if (GO(r, o)) {
        let a = t && r.sliceDoc(o, o + e.length * 3) == e + e + e;
        return {
          range: v.cursor(o + e.length * (a ? 3 : 1)),
          effects: ph.of(o)
        };
      }
    } else {
      if (t && r.sliceDoc(o - 2 * e.length, o) == e + e && Tf(r, o - 2 * e.length))
        return {
          changes: { insert: e + e + e + e, from: o },
          effects: ki.of(o + e.length),
          range: v.cursor(o + e.length)
        };
      if (r.charCategorizer(o)(l) != Ze.Word) {
        let a = r.sliceDoc(o - 1, o);
        if (a != e && r.charCategorizer(o)(a) != Ze.Word && !kx(r, o, e))
          return {
            changes: { insert: e + e, from: o },
            effects: ki.of(o + e.length),
            range: v.cursor(o + e.length)
          };
      }
    }
    return { range: i = s };
  });
  return i ? null : r.update(n, {
    scrollIntoView: !0,
    userEvent: "input.type"
  });
}
function Tf(r, e) {
  let t = Ue(r).resolveInner(e + 1);
  return t.parent && t.from == e;
}
function kx(r, e, t) {
  let i = Ue(r).resolveInner(e, -1);
  for (let n = 0; n < 5; n++) {
    if (r.sliceDoc(i.from, i.from + t.length) == t)
      return !0;
    let s = i.to == e && i.parent;
    if (!s)
      break;
    i = s;
  }
  return !1;
}
function Qx(r = {}) {
  return [
    Ke,
    fi.of(r),
    fx,
    vx,
    ux
  ];
}
const UO = [
  { key: "Ctrl-Space", run: ox },
  { key: "Escape", run: lx },
  { key: "ArrowDown", run: /* @__PURE__ */ qn(!0) },
  { key: "ArrowUp", run: /* @__PURE__ */ qn(!1) },
  { key: "PageDown", run: /* @__PURE__ */ qn(!0, "page") },
  { key: "PageUp", run: /* @__PURE__ */ qn(!1, "page") },
  { key: "Enter", run: sx }
], vx = /* @__PURE__ */ Vt.highest(/* @__PURE__ */ Ci.computeN([fi], (r) => r.facet(fi).defaultKeymap ? [UO] : []));
class $x {
  constructor(e, t, i) {
    this.from = e, this.to = t, this.diagnostic = i;
  }
}
class Si {
  constructor(e, t, i) {
    this.diagnostics = e, this.panel = t, this.selected = i;
  }
  static init(e, t, i) {
    let n = e, s = i.facet(Ei).markerFilter;
    s && (n = s(n));
    let o = B.set(n.map((l) => l.from == l.to || l.from == l.to - 1 && i.doc.lineAt(l.from).to == l.from ? B.widget({
      widget: new Ex(l),
      diagnostic: l
    }).range(l.from) : B.mark({
      attributes: { class: "cm-lintRange cm-lintRange-" + l.severity },
      diagnostic: l
    }).range(l.from, l.to)), !0);
    return new Si(o, t, Fi(o));
  }
}
function Fi(r, e = null, t = 0) {
  let i = null;
  return r.between(t, 1e9, (n, s, { spec: o }) => {
    if (!(e && o.diagnostic != e))
      return i = new $x(n, s, o.diagnostic), !1;
  }), i;
}
function Px(r, e) {
  return !!(r.effects.some((t) => t.is(mh)) || r.changes.touchesRange(e.pos));
}
function FO(r, e) {
  return r.field(Ge, !1) ? e : e.concat(V.appendConfig.of([
    Ge,
    D.decorations.compute([Ge], (t) => {
      let { selected: i, panel: n } = t.field(Ge);
      return !i || !n || i.from == i.to ? B.none : B.set([
        Tx.range(i.from, i.to)
      ]);
    }),
    lb(Ax, { hideOn: Px }),
    Dx
  ]));
}
function Cx(r, e) {
  return {
    effects: FO(r, [mh.of(e)])
  };
}
const mh = /* @__PURE__ */ V.define(), gh = /* @__PURE__ */ V.define(), HO = /* @__PURE__ */ V.define(), Ge = /* @__PURE__ */ ge.define({
  create() {
    return new Si(B.none, null, null);
  },
  update(r, e) {
    if (e.docChanged) {
      let t = r.diagnostics.map(e.changes), i = null;
      if (r.selected) {
        let n = e.changes.mapPos(r.selected.from, 1);
        i = Fi(t, r.selected.diagnostic, n) || Fi(t, null, n);
      }
      r = new Si(t, r.panel, i);
    }
    for (let t of e.effects)
      t.is(mh) ? r = Si.init(t.value, r.panel, e.state) : t.is(gh) ? r = new Si(r.diagnostics, t.value ? mo.open : null, r.selected) : t.is(HO) && (r = new Si(r.diagnostics, r.panel, t.value));
    return r;
  },
  provide: (r) => [
    Nr.from(r, (e) => e.panel),
    D.decorations.from(r, (e) => e.diagnostics)
  ]
}), Tx = /* @__PURE__ */ B.mark({ class: "cm-lintRange cm-lintRange-active" });
function Ax(r, e, t) {
  let { diagnostics: i } = r.state.field(Ge), n = [], s = 2e8, o = 0;
  i.between(e - (t < 0 ? 1 : 0), e + (t > 0 ? 1 : 0), (a, h, { spec: c }) => {
    e >= a && e <= h && (a == h || (e > a || t > 0) && (e < h || t < 0)) && (n.push(c.diagnostic), s = Math.min(a, s), o = Math.max(h, o));
  });
  let l = r.state.facet(Ei).tooltipFilter;
  return l && (n = l(n)), n.length ? {
    pos: s,
    end: o,
    above: r.state.doc.lineAt(s).to < o,
    create() {
      return { dom: Mx(r, n) };
    }
  } : null;
}
function Mx(r, e) {
  return fe("ul", { class: "cm-tooltip-lint" }, e.map((t) => JO(r, t, !1)));
}
const Zx = (r) => {
  let e = r.state.field(Ge, !1);
  (!e || !e.panel) && r.dispatch({ effects: FO(r.state, [gh.of(!0)]) });
  let t = Yr(r, mo.open);
  return t && t.dom.querySelector(".cm-panel-lint ul").focus(), !0;
}, Af = (r) => {
  let e = r.state.field(Ge, !1);
  return !e || !e.panel ? !1 : (r.dispatch({ effects: gh.of(!1) }), !0);
}, Xx = (r) => {
  let e = r.state.field(Ge, !1);
  if (!e)
    return !1;
  let t = r.state.selection.main, i = e.diagnostics.iter(t.to + 1);
  return !i.value && (i = e.diagnostics.iter(0), !i.value || i.from == t.from && i.to == t.to) ? !1 : (r.dispatch({ selection: { anchor: i.from, head: i.to }, scrollIntoView: !0 }), !0);
}, Rx = [
  { key: "Mod-Shift-m", run: Zx },
  { key: "F8", run: Xx }
], Lx = /* @__PURE__ */ ue.fromClass(class {
  constructor(r) {
    this.view = r, this.timeout = -1, this.set = !0;
    let { delay: e } = r.state.facet(Ei);
    this.lintTime = Date.now() + e, this.run = this.run.bind(this), this.timeout = setTimeout(this.run, e);
  }
  run() {
    let r = Date.now();
    if (r < this.lintTime - 10)
      setTimeout(this.run, this.lintTime - r);
    else {
      this.set = !1;
      let { state: e } = this.view, { sources: t } = e.facet(Ei);
      Promise.all(t.map((i) => Promise.resolve(i(this.view)))).then((i) => {
        let n = i.reduce((s, o) => s.concat(o));
        this.view.state.doc == e.doc && this.view.dispatch(Cx(this.view.state, n));
      }, (i) => {
        Qe(this.view.state, i);
      });
    }
  }
  update(r) {
    let e = r.state.facet(Ei);
    (r.docChanged || e != r.startState.facet(Ei)) && (this.lintTime = Date.now() + e.delay, this.set || (this.set = !0, this.timeout = setTimeout(this.run, e.delay)));
  }
  force() {
    this.set && (this.lintTime = Date.now(), this.run());
  }
  destroy() {
    clearTimeout(this.timeout);
  }
}), Ei = /* @__PURE__ */ R.define({
  combine(r) {
    return Object.assign({ sources: r.map((e) => e.source) }, Yt(r.map((e) => e.config), {
      delay: 750,
      markerFilter: null,
      tooltipFilter: null
    }));
  },
  enables: Lx
});
function KO(r) {
  let e = [];
  if (r)
    e: for (let { name: t } of r) {
      for (let i = 0; i < t.length; i++) {
        let n = t[i];
        if (/[a-zA-Z]/.test(n) && !e.some((s) => s.toLowerCase() == n.toLowerCase())) {
          e.push(n);
          continue e;
        }
      }
      e.push("");
    }
  return e;
}
function JO(r, e, t) {
  var i;
  let n = t ? KO(e.actions) : [];
  return fe("li", { class: "cm-diagnostic cm-diagnostic-" + e.severity }, fe("span", { class: "cm-diagnosticText" }, e.renderMessage ? e.renderMessage() : e.message), (i = e.actions) === null || i === void 0 ? void 0 : i.map((s, o) => {
    let l = (f) => {
      f.preventDefault();
      let u = Fi(r.state.field(Ge).diagnostics, e);
      u && s.apply(r, u.from, u.to);
    }, { name: a } = s, h = n[o] ? a.indexOf(n[o]) : -1, c = h < 0 ? a : [
      a.slice(0, h),
      fe("u", a.slice(h, h + 1)),
      a.slice(h + 1)
    ];
    return fe("button", {
      type: "button",
      class: "cm-diagnosticAction",
      onclick: l,
      onmousedown: l,
      "aria-label": ` Action: ${a}${h < 0 ? "" : ` (access key "${n[o]})"`}.`
    }, c);
  }), e.source && fe("div", { class: "cm-diagnosticSource" }, e.source));
}
class Ex extends di {
  constructor(e) {
    super(), this.diagnostic = e;
  }
  eq(e) {
    return e.diagnostic == this.diagnostic;
  }
  toDOM() {
    return fe("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
  }
}
class Mf {
  constructor(e, t) {
    this.diagnostic = t, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = JO(e, t, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
  }
}
class mo {
  constructor(e) {
    this.view = e, this.items = [];
    let t = (n) => {
      if (n.keyCode == 27)
        Af(this.view), this.view.focus();
      else if (n.keyCode == 38 || n.keyCode == 33)
        this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
      else if (n.keyCode == 40 || n.keyCode == 34)
        this.moveSelection((this.selectedIndex + 1) % this.items.length);
      else if (n.keyCode == 36)
        this.moveSelection(0);
      else if (n.keyCode == 35)
        this.moveSelection(this.items.length - 1);
      else if (n.keyCode == 13)
        this.view.focus();
      else if (n.keyCode >= 65 && n.keyCode <= 90 && this.selectedIndex >= 0) {
        let { diagnostic: s } = this.items[this.selectedIndex], o = KO(s.actions);
        for (let l = 0; l < o.length; l++)
          if (o[l].toUpperCase().charCodeAt(0) == n.keyCode) {
            let a = Fi(this.view.state.field(Ge).diagnostics, s);
            a && s.actions[l].apply(e, a.from, a.to);
          }
      } else
        return;
      n.preventDefault();
    }, i = (n) => {
      for (let s = 0; s < this.items.length; s++)
        this.items[s].dom.contains(n.target) && this.moveSelection(s);
    };
    this.list = fe("ul", {
      tabIndex: 0,
      role: "listbox",
      "aria-label": this.view.state.phrase("Diagnostics"),
      onkeydown: t,
      onclick: i
    }), this.dom = fe("div", { class: "cm-panel-lint" }, this.list, fe("button", {
      type: "button",
      name: "close",
      "aria-label": this.view.state.phrase("close"),
      onclick: () => Af(this.view)
    }, "×")), this.update();
  }
  get selectedIndex() {
    let e = this.view.state.field(Ge).selected;
    if (!e)
      return -1;
    for (let t = 0; t < this.items.length; t++)
      if (this.items[t].diagnostic == e.diagnostic)
        return t;
    return -1;
  }
  update() {
    let { diagnostics: e, selected: t } = this.view.state.field(Ge), i = 0, n = !1, s = null;
    for (e.between(0, this.view.state.doc.length, (o, l, { spec: a }) => {
      let h = -1, c;
      for (let f = i; f < this.items.length; f++)
        if (this.items[f].diagnostic == a.diagnostic) {
          h = f;
          break;
        }
      h < 0 ? (c = new Mf(this.view, a.diagnostic), this.items.splice(i, 0, c), n = !0) : (c = this.items[h], h > i && (this.items.splice(i, h - i), n = !0)), t && c.diagnostic == t.diagnostic ? c.dom.hasAttribute("aria-selected") || (c.dom.setAttribute("aria-selected", "true"), s = c) : c.dom.hasAttribute("aria-selected") && c.dom.removeAttribute("aria-selected"), i++;
    }); i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
      n = !0, this.items.pop();
    this.items.length == 0 && (this.items.push(new Mf(this.view, {
      from: -1,
      to: -1,
      severity: "info",
      message: this.view.state.phrase("No diagnostics")
    })), n = !0), s ? (this.list.setAttribute("aria-activedescendant", s.id), this.view.requestMeasure({
      key: this,
      read: () => ({ sel: s.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
      write: ({ sel: o, panel: l }) => {
        o.top < l.top ? this.list.scrollTop -= l.top - o.top : o.bottom > l.bottom && (this.list.scrollTop += o.bottom - l.bottom);
      }
    })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), n && this.sync();
  }
  sync() {
    let e = this.list.firstChild;
    function t() {
      let i = e;
      e = i.nextSibling, i.remove();
    }
    for (let i of this.items)
      if (i.dom.parentNode == this.list) {
        for (; e != i.dom; )
          t();
        e = i.dom.nextSibling;
      } else
        this.list.insertBefore(i.dom, e);
    for (; e; )
      t();
  }
  moveSelection(e) {
    if (this.selectedIndex < 0)
      return;
    let t = this.view.state.field(Ge), i = Fi(t.diagnostics, this.items[e].diagnostic);
    i && this.view.dispatch({
      selection: { anchor: i.from, head: i.to },
      scrollIntoView: !0,
      effects: HO.of(i)
    });
  }
  static open(e) {
    return new mo(e);
  }
}
function zx(r, e = 'viewBox="0 0 40 40"') {
  return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(r)}</svg>')`;
}
function Uo(r) {
  return zx(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${r}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
}
const Dx = /* @__PURE__ */ D.baseTheme({
  ".cm-diagnostic": {
    padding: "3px 6px 3px 8px",
    marginLeft: "-1px",
    display: "block",
    whiteSpace: "pre-wrap"
  },
  ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
  ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
  ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
  ".cm-diagnosticAction": {
    font: "inherit",
    border: "none",
    padding: "2px 4px",
    backgroundColor: "#444",
    color: "white",
    borderRadius: "3px",
    marginLeft: "8px"
  },
  ".cm-diagnosticSource": {
    fontSize: "70%",
    opacity: 0.7
  },
  ".cm-lintRange": {
    backgroundPosition: "left bottom",
    backgroundRepeat: "repeat-x",
    paddingBottom: "0.7px"
  },
  ".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ Uo("#d11") },
  ".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ Uo("orange") },
  ".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ Uo("#999") },
  ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
  ".cm-tooltip-lint": {
    padding: 0,
    margin: 0
  },
  ".cm-lintPoint": {
    position: "relative",
    "&:after": {
      content: '""',
      position: "absolute",
      bottom: 0,
      left: "-2px",
      borderLeft: "3px solid transparent",
      borderRight: "3px solid transparent",
      borderBottom: "4px solid #d11"
    }
  },
  ".cm-lintPoint-warning": {
    "&:after": { borderBottomColor: "orange" }
  },
  ".cm-lintPoint-info": {
    "&:after": { borderBottomColor: "#999" }
  },
  ".cm-panel.cm-panel-lint": {
    position: "relative",
    "& ul": {
      maxHeight: "100px",
      overflowY: "auto",
      "& [aria-selected]": {
        backgroundColor: "#ddd",
        "& u": { textDecoration: "underline" }
      },
      "&:focus [aria-selected]": {
        background_fallback: "#bdf",
        backgroundColor: "Highlight",
        color_fallback: "white",
        color: "HighlightText"
      },
      "& u": { textDecoration: "none" },
      padding: 0,
      margin: 0
    },
    "& [name=close]": {
      position: "absolute",
      top: "0",
      right: "2px",
      background: "inherit",
      border: "none",
      font: "inherit",
      padding: 0,
      margin: 0
    }
  }
}), _x = [
  /* @__PURE__ */ yb(),
  /* @__PURE__ */ xb(),
  /* @__PURE__ */ D1(),
  /* @__PURE__ */ vS(),
  /* @__PURE__ */ gy(),
  /* @__PURE__ */ P1(),
  /* @__PURE__ */ Z1(),
  /* @__PURE__ */ W.allowMultipleSelections.of(!0),
  /* @__PURE__ */ iy(),
  /* @__PURE__ */ yy(xy, { fallback: !0 }),
  /* @__PURE__ */ Ty(),
  /* @__PURE__ */ dx(),
  /* @__PURE__ */ Qx(),
  /* @__PURE__ */ F1(),
  /* @__PURE__ */ J1(),
  /* @__PURE__ */ Y1(),
  /* @__PURE__ */ xw(),
  /* @__PURE__ */ Ci.of([
    ...gx,
    ...Ow,
    ..._w,
    ...RS,
    ...uy,
    ...UO,
    ...Rx
  ])
], em = 1024;
let Bx = 0;
class et {
  constructor(e, t) {
    this.from = e, this.to = t;
  }
}
class j {
  /**
  Create a new node prop type.
  */
  constructor(e = {}) {
    this.id = Bx++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
      throw new Error("This node type doesn't define a deserialize function");
    }), this.combine = e.combine || null;
  }
  /**
  This is meant to be used with
  [`NodeSet.extend`](#common.NodeSet.extend) or
  [`LRParser.configure`](#lr.ParserConfig.props) to compute
  prop values for each node type in the set. Takes a [match
  object](#common.NodeType^match) or function that returns undefined
  if the node type doesn't get this prop, and the prop's value if
  it does.
  */
  add(e) {
    if (this.perNode)
      throw new RangeError("Can't add per-node props to node types");
    return typeof e != "function" && (e = Se.match(e)), (t) => {
      let i = e(t);
      return i === void 0 ? null : [this, i];
    };
  }
}
j.closedBy = new j({ deserialize: (r) => r.split(" ") });
j.openedBy = new j({ deserialize: (r) => r.split(" ") });
j.group = new j({ deserialize: (r) => r.split(" ") });
j.isolate = new j({ deserialize: (r) => {
  if (r && r != "rtl" && r != "ltr" && r != "auto")
    throw new RangeError("Invalid value for isolate: " + r);
  return r || "auto";
} });
j.contextHash = new j({ perNode: !0 });
j.lookAhead = new j({ perNode: !0 });
j.mounted = new j({ perNode: !0 });
class Ur {
  constructor(e, t, i) {
    this.tree = e, this.overlay = t, this.parser = i;
  }
  /**
  @internal
  */
  static get(e) {
    return e && e.props && e.props[j.mounted.id];
  }
}
const Ix = /* @__PURE__ */ Object.create(null);
class Se {
  /**
  @internal
  */
  constructor(e, t, i, n = 0) {
    this.name = e, this.props = t, this.id = i, this.flags = n;
  }
  /**
  Define a node type.
  */
  static define(e) {
    let t = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : Ix, i = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new Se(e.name || "", t, e.id, i);
    if (e.props) {
      for (let s of e.props)
        if (Array.isArray(s) || (s = s(n)), s) {
          if (s[0].perNode)
            throw new RangeError("Can't store a per-node prop on a node type");
          t[s[0].id] = s[1];
        }
    }
    return n;
  }
  /**
  Retrieves a node prop for this type. Will return `undefined` if
  the prop isn't present on this node.
  */
  prop(e) {
    return this.props[e.id];
  }
  /**
  True when this is the top node of a grammar.
  */
  get isTop() {
    return (this.flags & 1) > 0;
  }
  /**
  True when this node is produced by a skip rule.
  */
  get isSkipped() {
    return (this.flags & 2) > 0;
  }
  /**
  Indicates whether this is an error node.
  */
  get isError() {
    return (this.flags & 4) > 0;
  }
  /**
  When true, this node type doesn't correspond to a user-declared
  named node, for example because it is used to cache repetition.
  */
  get isAnonymous() {
    return (this.flags & 8) > 0;
  }
  /**
  Returns true when this node's name or one of its
  [groups](#common.NodeProp^group) matches the given string.
  */
  is(e) {
    if (typeof e == "string") {
      if (this.name == e)
        return !0;
      let t = this.prop(j.group);
      return t ? t.indexOf(e) > -1 : !1;
    }
    return this.id == e;
  }
  /**
  Create a function from node types to arbitrary values by
  specifying an object whose property names are node or
  [group](#common.NodeProp^group) names. Often useful with
  [`NodeProp.add`](#common.NodeProp.add). You can put multiple
  names, separated by spaces, in a single property name to map
  multiple node names to a single value.
  */
  static match(e) {
    let t = /* @__PURE__ */ Object.create(null);
    for (let i in e)
      for (let n of i.split(" "))
        t[n] = e[i];
    return (i) => {
      for (let n = i.prop(j.group), s = -1; s < (n ? n.length : 0); s++) {
        let o = t[s < 0 ? i.name : n[s]];
        if (o)
          return o;
      }
    };
  }
}
Se.none = new Se(
  "",
  /* @__PURE__ */ Object.create(null),
  0,
  8
  /* NodeFlag.Anonymous */
);
class pn {
  /**
  Create a set with the given types. The `id` property of each
  type should correspond to its position within the array.
  */
  constructor(e) {
    this.types = e;
    for (let t = 0; t < e.length; t++)
      if (e[t].id != t)
        throw new RangeError("Node type ids should correspond to array positions when creating a node set");
  }
  /**
  Create a copy of this set with some node properties added. The
  arguments to this method can be created with
  [`NodeProp.add`](#common.NodeProp.add).
  */
  extend(...e) {
    let t = [];
    for (let i of this.types) {
      let n = null;
      for (let s of e) {
        let o = s(i);
        if (o) {
          n || (n = Object.assign({}, i.props));
          let l = o[1], a = o[0];
          a.combine && a.id in n && (l = a.combine(n[a.id], l)), n[a.id] = l;
        }
      }
      t.push(n ? new Se(i.name, n, i.id, i.flags) : i);
    }
    return new pn(t);
  }
}
const Yn = /* @__PURE__ */ new WeakMap(), Zf = /* @__PURE__ */ new WeakMap();
var le;
(function(r) {
  r[r.ExcludeBuffers = 1] = "ExcludeBuffers", r[r.IncludeAnonymous = 2] = "IncludeAnonymous", r[r.IgnoreMounts = 4] = "IgnoreMounts", r[r.IgnoreOverlays = 8] = "IgnoreOverlays";
})(le || (le = {}));
class te {
  /**
  Construct a new tree. See also [`Tree.build`](#common.Tree^build).
  */
  constructor(e, t, i, n, s) {
    if (this.type = e, this.children = t, this.positions = i, this.length = n, this.props = null, s && s.length) {
      this.props = /* @__PURE__ */ Object.create(null);
      for (let [o, l] of s)
        this.props[typeof o == "number" ? o : o.id] = l;
    }
  }
  /**
  @internal
  */
  toString() {
    let e = Ur.get(this);
    if (e && !e.overlay)
      return e.tree.toString();
    let t = "";
    for (let i of this.children) {
      let n = i.toString();
      n && (t && (t += ","), t += n);
    }
    return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (t.length ? "(" + t + ")" : "") : t;
  }
  /**
  Get a [tree cursor](#common.TreeCursor) positioned at the top of
  the tree. Mode can be used to [control](#common.IterMode) which
  nodes the cursor visits.
  */
  cursor(e = 0) {
    return new Vs(this.topNode, e);
  }
  /**
  Get a [tree cursor](#common.TreeCursor) pointing into this tree
  at the given position and side (see
  [`moveTo`](#common.TreeCursor.moveTo).
  */
  cursorAt(e, t = 0, i = 0) {
    let n = Yn.get(this) || this.topNode, s = new Vs(n);
    return s.moveTo(e, t), Yn.set(this, s._tree), s;
  }
  /**
  Get a [syntax node](#common.SyntaxNode) object for the top of the
  tree.
  */
  get topNode() {
    return new Ae(this, 0, 0, null);
  }
  /**
  Get the [syntax node](#common.SyntaxNode) at the given position.
  If `side` is -1, this will move into nodes that end at the
  position. If 1, it'll move into nodes that start at the
  position. With 0, it'll only enter nodes that cover the position
  from both sides.
  
  Note that this will not enter
  [overlays](#common.MountedTree.overlay), and you often want
  [`resolveInner`](#common.Tree.resolveInner) instead.
  */
  resolve(e, t = 0) {
    let i = Fr(Yn.get(this) || this.topNode, e, t, !1);
    return Yn.set(this, i), i;
  }
  /**
  Like [`resolve`](#common.Tree.resolve), but will enter
  [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
  pointing into the innermost overlaid tree at the given position
  (with parent links going through all parent structure, including
  the host trees).
  */
  resolveInner(e, t = 0) {
    let i = Fr(Zf.get(this) || this.topNode, e, t, !0);
    return Zf.set(this, i), i;
  }
  /**
  In some situations, it can be useful to iterate through all
  nodes around a position, including those in overlays that don't
  directly cover the position. This method gives you an iterator
  that will produce all nodes, from small to big, around the given
  position.
  */
  resolveStack(e, t = 0) {
    return Yx(this, e, t);
  }
  /**
  Iterate over the tree and its children, calling `enter` for any
  node that touches the `from`/`to` region (if given) before
  running over such a node's children, and `leave` (if given) when
  leaving the node. When `enter` returns `false`, that node will
  not have its children iterated over (or `leave` called).
  */
  iterate(e) {
    let { enter: t, leave: i, from: n = 0, to: s = this.length } = e, o = e.mode || 0, l = (o & le.IncludeAnonymous) > 0;
    for (let a = this.cursor(o | le.IncludeAnonymous); ; ) {
      let h = !1;
      if (a.from <= s && a.to >= n && (!l && a.type.isAnonymous || t(a) !== !1)) {
        if (a.firstChild())
          continue;
        h = !0;
      }
      for (; h && i && (l || !a.type.isAnonymous) && i(a), !a.nextSibling(); ) {
        if (!a.parent())
          return;
        h = !0;
      }
    }
  }
  /**
  Get the value of the given [node prop](#common.NodeProp) for this
  node. Works with both per-node and per-type props.
  */
  prop(e) {
    return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
  }
  /**
  Returns the node's [per-node props](#common.NodeProp.perNode) in a
  format that can be passed to the [`Tree`](#common.Tree)
  constructor.
  */
  get propValues() {
    let e = [];
    if (this.props)
      for (let t in this.props)
        e.push([+t, this.props[t]]);
    return e;
  }
  /**
  Balance the direct children of this tree, producing a copy of
  which may have children grouped into subtrees with type
  [`NodeType.none`](#common.NodeType^none).
  */
  balance(e = {}) {
    return this.children.length <= 8 ? this : Sh(Se.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, i, n) => new te(this.type, t, i, n, this.propValues), e.makeTree || ((t, i, n) => new te(Se.none, t, i, n)));
  }
  /**
  Build a tree from a postfix-ordered buffer of node information,
  or a cursor over such a buffer.
  */
  static build(e) {
    return Nx(e);
  }
}
te.empty = new te(Se.none, [], [], 0);
class bh {
  constructor(e, t) {
    this.buffer = e, this.index = t;
  }
  get id() {
    return this.buffer[this.index - 4];
  }
  get start() {
    return this.buffer[this.index - 3];
  }
  get end() {
    return this.buffer[this.index - 2];
  }
  get size() {
    return this.buffer[this.index - 1];
  }
  get pos() {
    return this.index;
  }
  next() {
    this.index -= 4;
  }
  fork() {
    return new bh(this.buffer, this.index);
  }
}
class ui {
  /**
  Create a tree buffer.
  */
  constructor(e, t, i) {
    this.buffer = e, this.length = t, this.set = i;
  }
  /**
  @internal
  */
  get type() {
    return Se.none;
  }
  /**
  @internal
  */
  toString() {
    let e = [];
    for (let t = 0; t < this.buffer.length; )
      e.push(this.childString(t)), t = this.buffer[t + 3];
    return e.join(",");
  }
  /**
  @internal
  */
  childString(e) {
    let t = this.buffer[e], i = this.buffer[e + 3], n = this.set.types[t], s = n.name;
    if (/\W/.test(s) && !n.isError && (s = JSON.stringify(s)), e += 4, i == e)
      return s;
    let o = [];
    for (; e < i; )
      o.push(this.childString(e)), e = this.buffer[e + 3];
    return s + "(" + o.join(",") + ")";
  }
  /**
  @internal
  */
  findChild(e, t, i, n, s) {
    let { buffer: o } = this, l = -1;
    for (let a = e; a != t && !(tm(s, n, o[a + 1], o[a + 2]) && (l = a, i > 0)); a = o[a + 3])
      ;
    return l;
  }
  /**
  @internal
  */
  slice(e, t, i) {
    let n = this.buffer, s = new Uint16Array(t - e), o = 0;
    for (let l = e, a = 0; l < t; ) {
      s[a++] = n[l++], s[a++] = n[l++] - i;
      let h = s[a++] = n[l++] - i;
      s[a++] = n[l++] - e, o = Math.max(o, h);
    }
    return new ui(s, o, this.set);
  }
}
function tm(r, e, t, i) {
  switch (r) {
    case -2:
      return t < e;
    case -1:
      return i >= e && t < e;
    case 0:
      return t < e && i > e;
    case 1:
      return t <= e && i > e;
    case 2:
      return i > e;
    case 4:
      return !0;
  }
}
function Fr(r, e, t, i) {
  for (var n; r.from == r.to || (t < 1 ? r.from >= e : r.from > e) || (t > -1 ? r.to <= e : r.to < e); ) {
    let o = !i && r instanceof Ae && r.index < 0 ? null : r.parent;
    if (!o)
      return r;
    r = o;
  }
  let s = i ? 0 : le.IgnoreOverlays;
  if (i)
    for (let o = r, l = o.parent; l; o = l, l = o.parent)
      o instanceof Ae && o.index < 0 && ((n = l.enter(e, t, s)) === null || n === void 0 ? void 0 : n.from) != o.from && (r = l);
  for (; ; ) {
    let o = r.enter(e, t, s);
    if (!o)
      return r;
    r = o;
  }
}
class im {
  cursor(e = 0) {
    return new Vs(this, e);
  }
  getChild(e, t = null, i = null) {
    let n = Xf(this, e, t, i);
    return n.length ? n[0] : null;
  }
  getChildren(e, t = null, i = null) {
    return Xf(this, e, t, i);
  }
  resolve(e, t = 0) {
    return Fr(this, e, t, !1);
  }
  resolveInner(e, t = 0) {
    return Fr(this, e, t, !0);
  }
  matchContext(e) {
    return Qa(this.parent, e);
  }
  enterUnfinishedNodesBefore(e) {
    let t = this.childBefore(e), i = this;
    for (; t; ) {
      let n = t.lastChild;
      if (!n || n.to != t.to)
        break;
      n.type.isError && n.from == n.to ? (i = t, t = n.prevSibling) : t = n;
    }
    return i;
  }
  get node() {
    return this;
  }
  get next() {
    return this.parent;
  }
}
class Ae extends im {
  constructor(e, t, i, n) {
    super(), this._tree = e, this.from = t, this.index = i, this._parent = n;
  }
  get type() {
    return this._tree.type;
  }
  get name() {
    return this._tree.type.name;
  }
  get to() {
    return this.from + this._tree.length;
  }
  nextChild(e, t, i, n, s = 0) {
    for (let o = this; ; ) {
      for (let { children: l, positions: a } = o._tree, h = t > 0 ? l.length : -1; e != h; e += t) {
        let c = l[e], f = a[e] + o.from;
        if (tm(n, i, f, f + c.length)) {
          if (c instanceof ui) {
            if (s & le.ExcludeBuffers)
              continue;
            let u = c.findChild(0, c.buffer.length, t, i - f, n);
            if (u > -1)
              return new Qt(new Vx(o, c, e, f), null, u);
          } else if (s & le.IncludeAnonymous || !c.type.isAnonymous || yh(c)) {
            let u;
            if (!(s & le.IgnoreMounts) && (u = Ur.get(c)) && !u.overlay)
              return new Ae(u.tree, f, e, o);
            let d = new Ae(c, f, e, o);
            return s & le.IncludeAnonymous || !d.type.isAnonymous ? d : d.nextChild(t < 0 ? c.children.length - 1 : 0, t, i, n);
          }
        }
      }
      if (s & le.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? e = o.index + t : e = t < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
        return null;
    }
  }
  get firstChild() {
    return this.nextChild(
      0,
      1,
      0,
      4
      /* Side.DontCare */
    );
  }
  get lastChild() {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      0,
      4
      /* Side.DontCare */
    );
  }
  childAfter(e) {
    return this.nextChild(
      0,
      1,
      e,
      2
      /* Side.After */
    );
  }
  childBefore(e) {
    return this.nextChild(
      this._tree.children.length - 1,
      -1,
      e,
      -2
      /* Side.Before */
    );
  }
  enter(e, t, i = 0) {
    let n;
    if (!(i & le.IgnoreOverlays) && (n = Ur.get(this._tree)) && n.overlay) {
      let s = e - this.from;
      for (let { from: o, to: l } of n.overlay)
        if ((t > 0 ? o <= s : o < s) && (t < 0 ? l >= s : l > s))
          return new Ae(n.tree, n.overlay[0].from + this.from, -1, this);
    }
    return this.nextChild(0, 1, e, t, i);
  }
  nextSignificantParent() {
    let e = this;
    for (; e.type.isAnonymous && e._parent; )
      e = e._parent;
    return e;
  }
  get parent() {
    return this._parent ? this._parent.nextSignificantParent() : null;
  }
  get nextSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index + 1,
      1,
      0,
      4
      /* Side.DontCare */
    ) : null;
  }
  get prevSibling() {
    return this._parent && this.index >= 0 ? this._parent.nextChild(
      this.index - 1,
      -1,
      0,
      4
      /* Side.DontCare */
    ) : null;
  }
  get tree() {
    return this._tree;
  }
  toTree() {
    return this._tree;
  }
  /**
  @internal
  */
  toString() {
    return this._tree.toString();
  }
}
function Xf(r, e, t, i) {
  let n = r.cursor(), s = [];
  if (!n.firstChild())
    return s;
  if (t != null) {
    for (let o = !1; !o; )
      if (o = n.type.is(t), !n.nextSibling())
        return s;
  }
  for (; ; ) {
    if (i != null && n.type.is(i))
      return s;
    if (n.type.is(e) && s.push(n.node), !n.nextSibling())
      return i == null ? s : [];
  }
}
function Qa(r, e, t = e.length - 1) {
  for (let i = r; t >= 0; i = i.parent) {
    if (!i)
      return !1;
    if (!i.type.isAnonymous) {
      if (e[t] && e[t] != i.name)
        return !1;
      t--;
    }
  }
  return !0;
}
class Vx {
  constructor(e, t, i, n) {
    this.parent = e, this.buffer = t, this.index = i, this.start = n;
  }
}
class Qt extends im {
  get name() {
    return this.type.name;
  }
  get from() {
    return this.context.start + this.context.buffer.buffer[this.index + 1];
  }
  get to() {
    return this.context.start + this.context.buffer.buffer[this.index + 2];
  }
  constructor(e, t, i) {
    super(), this.context = e, this._parent = t, this.index = i, this.type = e.buffer.set.types[e.buffer.buffer[i]];
  }
  child(e, t, i) {
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.context.start, i);
    return s < 0 ? null : new Qt(this.context, this, s);
  }
  get firstChild() {
    return this.child(
      1,
      0,
      4
      /* Side.DontCare */
    );
  }
  get lastChild() {
    return this.child(
      -1,
      0,
      4
      /* Side.DontCare */
    );
  }
  childAfter(e) {
    return this.child(
      1,
      e,
      2
      /* Side.After */
    );
  }
  childBefore(e) {
    return this.child(
      -1,
      e,
      -2
      /* Side.Before */
    );
  }
  enter(e, t, i = 0) {
    if (i & le.ExcludeBuffers)
      return null;
    let { buffer: n } = this.context, s = n.findChild(this.index + 4, n.buffer[this.index + 3], t > 0 ? 1 : -1, e - this.context.start, t);
    return s < 0 ? null : new Qt(this.context, this, s);
  }
  get parent() {
    return this._parent || this.context.parent.nextSignificantParent();
  }
  externalSibling(e) {
    return this._parent ? null : this.context.parent.nextChild(
      this.context.index + e,
      e,
      0,
      4
      /* Side.DontCare */
    );
  }
  get nextSibling() {
    let { buffer: e } = this.context, t = e.buffer[this.index + 3];
    return t < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new Qt(this.context, this._parent, t) : this.externalSibling(1);
  }
  get prevSibling() {
    let { buffer: e } = this.context, t = this._parent ? this._parent.index + 4 : 0;
    return this.index == t ? this.externalSibling(-1) : new Qt(this.context, this._parent, e.findChild(
      t,
      this.index,
      -1,
      0,
      4
      /* Side.DontCare */
    ));
  }
  get tree() {
    return null;
  }
  toTree() {
    let e = [], t = [], { buffer: i } = this.context, n = this.index + 4, s = i.buffer[this.index + 3];
    if (s > n) {
      let o = i.buffer[this.index + 1];
      e.push(i.slice(n, s, o)), t.push(0);
    }
    return new te(this.type, e, t, this.to - this.from);
  }
  /**
  @internal
  */
  toString() {
    return this.context.buffer.childString(this.index);
  }
}
function rm(r) {
  if (!r.length)
    return null;
  let e = 0, t = r[0];
  for (let s = 1; s < r.length; s++) {
    let o = r[s];
    (o.from > t.from || o.to < t.to) && (t = o, e = s);
  }
  let i = t instanceof Ae && t.index < 0 ? null : t.parent, n = r.slice();
  return i ? n[e] = i : n.splice(e, 1), new qx(n, t);
}
class qx {
  constructor(e, t) {
    this.heads = e, this.node = t;
  }
  get next() {
    return rm(this.heads);
  }
}
function Yx(r, e, t) {
  let i = r.resolveInner(e, t), n = null;
  for (let s = i instanceof Ae ? i : i.context.parent; s; s = s.parent)
    if (s.index < 0) {
      let o = s.parent;
      (n || (n = [i])).push(o.resolve(e, t)), s = o;
    } else {
      let o = Ur.get(s.tree);
      if (o && o.overlay && o.overlay[0].from <= e && o.overlay[o.overlay.length - 1].to >= e) {
        let l = new Ae(o.tree, o.overlay[0].from + s.from, -1, s);
        (n || (n = [i])).push(Fr(l, e, t, !1));
      }
    }
  return n ? rm(n) : i;
}
class Vs {
  /**
  Shorthand for `.type.name`.
  */
  get name() {
    return this.type.name;
  }
  /**
  @internal
  */
  constructor(e, t = 0) {
    if (this.mode = t, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, e instanceof Ae)
      this.yieldNode(e);
    else {
      this._tree = e.context.parent, this.buffer = e.context;
      for (let i = e._parent; i; i = i._parent)
        this.stack.unshift(i.index);
      this.bufferNode = e, this.yieldBuf(e.index);
    }
  }
  yieldNode(e) {
    return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, !0) : !1;
  }
  yieldBuf(e, t) {
    this.index = e;
    let { start: i, buffer: n } = this.buffer;
    return this.type = t || n.set.types[n.buffer[e]], this.from = i + n.buffer[e + 1], this.to = i + n.buffer[e + 2], !0;
  }
  /**
  @internal
  */
  yield(e) {
    return e ? e instanceof Ae ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : !1;
  }
  /**
  @internal
  */
  toString() {
    return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
  }
  /**
  @internal
  */
  enterChild(e, t, i) {
    if (!this.buffer)
      return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, i, this.mode));
    let { buffer: n } = this.buffer, s = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.buffer.start, i);
    return s < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(s));
  }
  /**
  Move the cursor to this node's first child. When this returns
  false, the node has no child, and the cursor has not been moved.
  */
  firstChild() {
    return this.enterChild(
      1,
      0,
      4
      /* Side.DontCare */
    );
  }
  /**
  Move the cursor to this node's last child.
  */
  lastChild() {
    return this.enterChild(
      -1,
      0,
      4
      /* Side.DontCare */
    );
  }
  /**
  Move the cursor to the first child that ends after `pos`.
  */
  childAfter(e) {
    return this.enterChild(
      1,
      e,
      2
      /* Side.After */
    );
  }
  /**
  Move to the last child that starts before `pos`.
  */
  childBefore(e) {
    return this.enterChild(
      -1,
      e,
      -2
      /* Side.Before */
    );
  }
  /**
  Move the cursor to the child around `pos`. If side is -1 the
  child may end at that position, when 1 it may start there. This
  will also enter [overlaid](#common.MountedTree.overlay)
  [mounted](#common.NodeProp^mounted) trees unless `overlays` is
  set to false.
  */
  enter(e, t, i = this.mode) {
    return this.buffer ? i & le.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, i));
  }
  /**
  Move to the node's parent node, if this isn't the top node.
  */
  parent() {
    if (!this.buffer)
      return this.yieldNode(this.mode & le.IncludeAnonymous ? this._tree._parent : this._tree.parent);
    if (this.stack.length)
      return this.yieldBuf(this.stack.pop());
    let e = this.mode & le.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
    return this.buffer = null, this.yieldNode(e);
  }
  /**
  @internal
  */
  sibling(e) {
    if (!this.buffer)
      return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : !1;
    let { buffer: t } = this.buffer, i = this.stack.length - 1;
    if (e < 0) {
      let n = i < 0 ? 0 : this.stack[i] + 4;
      if (this.index != n)
        return this.yieldBuf(t.findChild(
          n,
          this.index,
          -1,
          0,
          4
          /* Side.DontCare */
        ));
    } else {
      let n = t.buffer[this.index + 3];
      if (n < (i < 0 ? t.buffer.length : t.buffer[this.stack[i] + 3]))
        return this.yieldBuf(n);
    }
    return i < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : !1;
  }
  /**
  Move to this node's next sibling, if any.
  */
  nextSibling() {
    return this.sibling(1);
  }
  /**
  Move to this node's previous sibling, if any.
  */
  prevSibling() {
    return this.sibling(-1);
  }
  atLastNode(e) {
    let t, i, { buffer: n } = this;
    if (n) {
      if (e > 0) {
        if (this.index < n.buffer.buffer.length)
          return !1;
      } else
        for (let s = 0; s < this.index; s++)
          if (n.buffer.buffer[s + 3] < this.index)
            return !1;
      ({ index: t, parent: i } = n);
    } else
      ({ index: t, _parent: i } = this._tree);
    for (; i; { index: t, _parent: i } = i)
      if (t > -1)
        for (let s = t + e, o = e < 0 ? -1 : i._tree.children.length; s != o; s += e) {
          let l = i._tree.children[s];
          if (this.mode & le.IncludeAnonymous || l instanceof ui || !l.type.isAnonymous || yh(l))
            return !1;
        }
    return !0;
  }
  move(e, t) {
    if (t && this.enterChild(
      e,
      0,
      4
      /* Side.DontCare */
    ))
      return !0;
    for (; ; ) {
      if (this.sibling(e))
        return !0;
      if (this.atLastNode(e) || !this.parent())
        return !1;
    }
  }
  /**
  Move to the next node in a
  [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
  traversal, going from a node to its first child or, if the
  current node is empty or `enter` is false, its next sibling or
  the next sibling of the first parent node that has one.
  */
  next(e = !0) {
    return this.move(1, e);
  }
  /**
  Move to the next node in a last-to-first pre-order traversal. A
  node is followed by its last child or, if it has none, its
  previous sibling or the previous sibling of the first parent
  node that has one.
  */
  prev(e = !0) {
    return this.move(-1, e);
  }
  /**
  Move the cursor to the innermost node that covers `pos`. If
  `side` is -1, it will enter nodes that end at `pos`. If it is 1,
  it will enter nodes that start at `pos`.
  */
  moveTo(e, t = 0) {
    for (; (this.from == this.to || (t < 1 ? this.from >= e : this.from > e) || (t > -1 ? this.to <= e : this.to < e)) && this.parent(); )
      ;
    for (; this.enterChild(1, e, t); )
      ;
    return this;
  }
  /**
  Get a [syntax node](#common.SyntaxNode) at the cursor's current
  position.
  */
  get node() {
    if (!this.buffer)
      return this._tree;
    let e = this.bufferNode, t = null, i = 0;
    if (e && e.context == this.buffer)
      e: for (let n = this.index, s = this.stack.length; s >= 0; ) {
        for (let o = e; o; o = o._parent)
          if (o.index == n) {
            if (n == this.index)
              return o;
            t = o, i = s + 1;
            break e;
          }
        n = this.stack[--s];
      }
    for (let n = i; n < this.stack.length; n++)
      t = new Qt(this.buffer, t, this.stack[n]);
    return this.bufferNode = new Qt(this.buffer, t, this.index);
  }
  /**
  Get the [tree](#common.Tree) that represents the current node, if
  any. Will return null when the node is in a [tree
  buffer](#common.TreeBuffer).
  */
  get tree() {
    return this.buffer ? null : this._tree._tree;
  }
  /**
  Iterate over the current node and all its descendants, calling
  `enter` when entering a node and `leave`, if given, when leaving
  one. When `enter` returns `false`, any children of that node are
  skipped, and `leave` isn't called for it.
  */
  iterate(e, t) {
    for (let i = 0; ; ) {
      let n = !1;
      if (this.type.isAnonymous || e(this) !== !1) {
        if (this.firstChild()) {
          i++;
          continue;
        }
        this.type.isAnonymous || (n = !0);
      }
      for (; ; ) {
        if (n && t && t(this), n = this.type.isAnonymous, !i)
          return;
        if (this.nextSibling())
          break;
        this.parent(), i--, n = !0;
      }
    }
  }
  /**
  Test whether the current node matches a given context—a sequence
  of direct parent node names. Empty strings in the context array
  are treated as wildcards.
  */
  matchContext(e) {
    if (!this.buffer)
      return Qa(this.node.parent, e);
    let { buffer: t } = this.buffer, { types: i } = t.set;
    for (let n = e.length - 1, s = this.stack.length - 1; n >= 0; s--) {
      if (s < 0)
        return Qa(this._tree, e, n);
      let o = i[t.buffer[this.stack[s]]];
      if (!o.isAnonymous) {
        if (e[n] && e[n] != o.name)
          return !1;
        n--;
      }
    }
    return !0;
  }
}
function yh(r) {
  return r.children.some((e) => e instanceof ui || !e.type.isAnonymous || yh(e));
}
function Nx(r) {
  var e;
  let { buffer: t, nodeSet: i, maxBufferLength: n = em, reused: s = [], minRepeatType: o = i.types.length } = r, l = Array.isArray(t) ? new bh(t, t.length) : t, a = i.types, h = 0, c = 0;
  function f(S, y, Q, L, $, P) {
    let { id: T, start: A, end: I, size: q } = l, Y = c, U = h;
    if (q < 0)
      if (l.next(), q == -1) {
        let ae = s[T];
        Q.push(ae), L.push(A - S);
        return;
      } else if (q == -3) {
        h = T;
        return;
      } else if (q == -4) {
        c = T;
        return;
      } else
        throw new RangeError(`Unrecognized record size: ${q}`);
    let be = a[T], re, N, J = A - S;
    if (I - A <= n && (N = g(l.pos - y, $))) {
      let ae = new Uint16Array(N.size - N.skip), oe = l.pos - N.size, pe = ae.length;
      for (; l.pos > oe; )
        pe = b(N.start, ae, pe);
      re = new ui(ae, I - N.start, i), J = N.start - S;
    } else {
      let ae = l.pos - q;
      l.next();
      let oe = [], pe = [], Be = T >= o ? T : -1, Ai = 0, gn = I;
      for (; l.pos > ae; )
        Be >= 0 && l.id == Be && l.size >= 0 ? (l.end <= gn - n && (p(oe, pe, A, Ai, l.end, gn, Be, Y, U), Ai = oe.length, gn = l.end), l.next()) : P > 2500 ? u(A, ae, oe, pe) : f(A, ae, oe, pe, Be, P + 1);
      if (Be >= 0 && Ai > 0 && Ai < oe.length && p(oe, pe, A, Ai, A, gn, Be, Y, U), oe.reverse(), pe.reverse(), Be > -1 && Ai > 0) {
        let Dh = d(be, U);
        re = Sh(be, oe, pe, 0, oe.length, 0, I - A, Dh, Dh);
      } else
        re = O(be, oe, pe, I - A, Y - I, U);
    }
    Q.push(re), L.push(J);
  }
  function u(S, y, Q, L) {
    let $ = [], P = 0, T = -1;
    for (; l.pos > y; ) {
      let { id: A, start: I, end: q, size: Y } = l;
      if (Y > 4)
        l.next();
      else {
        if (T > -1 && I < T)
          break;
        T < 0 && (T = q - n), $.push(A, I, q), P++, l.next();
      }
    }
    if (P) {
      let A = new Uint16Array(P * 4), I = $[$.length - 2];
      for (let q = $.length - 3, Y = 0; q >= 0; q -= 3)
        A[Y++] = $[q], A[Y++] = $[q + 1] - I, A[Y++] = $[q + 2] - I, A[Y++] = Y;
      Q.push(new ui(A, $[2] - I, i)), L.push(I - S);
    }
  }
  function d(S, y) {
    return (Q, L, $) => {
      let P = 0, T = Q.length - 1, A, I;
      if (T >= 0 && (A = Q[T]) instanceof te) {
        if (!T && A.type == S && A.length == $)
          return A;
        (I = A.prop(j.lookAhead)) && (P = L[T] + A.length + I);
      }
      return O(S, Q, L, $, P, y);
    };
  }
  function p(S, y, Q, L, $, P, T, A, I) {
    let q = [], Y = [];
    for (; S.length > L; )
      q.push(S.pop()), Y.push(y.pop() + Q - $);
    S.push(O(i.types[T], q, Y, P - $, A - P, I)), y.push($ - Q);
  }
  function O(S, y, Q, L, $, P, T) {
    if (P) {
      let A = [j.contextHash, P];
      T = T ? [A].concat(T) : [A];
    }
    if ($ > 25) {
      let A = [j.lookAhead, $];
      T = T ? [A].concat(T) : [A];
    }
    return new te(S, y, Q, L, T);
  }
  function g(S, y) {
    let Q = l.fork(), L = 0, $ = 0, P = 0, T = Q.end - n, A = { size: 0, start: 0, skip: 0 };
    e: for (let I = Q.pos - S; Q.pos > I; ) {
      let q = Q.size;
      if (Q.id == y && q >= 0) {
        A.size = L, A.start = $, A.skip = P, P += 4, L += 4, Q.next();
        continue;
      }
      let Y = Q.pos - q;
      if (q < 0 || Y < I || Q.start < T)
        break;
      let U = Q.id >= o ? 4 : 0, be = Q.start;
      for (Q.next(); Q.pos > Y; ) {
        if (Q.size < 0)
          if (Q.size == -3)
            U += 4;
          else
            break e;
        else Q.id >= o && (U += 4);
        Q.next();
      }
      $ = be, L += q, P += U;
    }
    return (y < 0 || L == S) && (A.size = L, A.start = $, A.skip = P), A.size > 4 ? A : void 0;
  }
  function b(S, y, Q) {
    let { id: L, start: $, end: P, size: T } = l;
    if (l.next(), T >= 0 && L < o) {
      let A = Q;
      if (T > 4) {
        let I = l.pos - (T - 4);
        for (; l.pos > I; )
          Q = b(S, y, Q);
      }
      y[--Q] = A, y[--Q] = P - S, y[--Q] = $ - S, y[--Q] = L;
    } else T == -3 ? h = L : T == -4 && (c = L);
    return Q;
  }
  let w = [], k = [];
  for (; l.pos > 0; )
    f(r.start || 0, r.bufferStart || 0, w, k, -1, 0);
  let x = (e = r.length) !== null && e !== void 0 ? e : w.length ? k[0] + w[0].length : 0;
  return new te(a[r.topID], w.reverse(), k.reverse(), x);
}
const Rf = /* @__PURE__ */ new WeakMap();
function cs(r, e) {
  if (!r.isAnonymous || e instanceof ui || e.type != r)
    return 1;
  let t = Rf.get(e);
  if (t == null) {
    t = 1;
    for (let i of e.children) {
      if (i.type != r || !(i instanceof te)) {
        t = 1;
        break;
      }
      t += cs(r, i);
    }
    Rf.set(e, t);
  }
  return t;
}
function Sh(r, e, t, i, n, s, o, l, a) {
  let h = 0;
  for (let p = i; p < n; p++)
    h += cs(r, e[p]);
  let c = Math.ceil(
    h * 1.5 / 8
    /* Balance.BranchFactor */
  ), f = [], u = [];
  function d(p, O, g, b, w) {
    for (let k = g; k < b; ) {
      let x = k, S = O[k], y = cs(r, p[k]);
      for (k++; k < b; k++) {
        let Q = cs(r, p[k]);
        if (y + Q >= c)
          break;
        y += Q;
      }
      if (k == x + 1) {
        if (y > c) {
          let Q = p[x];
          d(Q.children, Q.positions, 0, Q.children.length, O[x] + w);
          continue;
        }
        f.push(p[x]);
      } else {
        let Q = O[k - 1] + p[k - 1].length - S;
        f.push(Sh(r, p, O, x, k, S, Q, null, a));
      }
      u.push(S + w - s);
    }
  }
  return d(e, t, i, n, 0), (l || a)(f, u, o);
}
class nm {
  constructor() {
    this.map = /* @__PURE__ */ new WeakMap();
  }
  setBuffer(e, t, i) {
    let n = this.map.get(e);
    n || this.map.set(e, n = /* @__PURE__ */ new Map()), n.set(t, i);
  }
  getBuffer(e, t) {
    let i = this.map.get(e);
    return i && i.get(t);
  }
  /**
  Set the value for this syntax node.
  */
  set(e, t) {
    e instanceof Qt ? this.setBuffer(e.context.buffer, e.index, t) : e instanceof Ae && this.map.set(e.tree, t);
  }
  /**
  Retrieve value for this syntax node, if it exists in the map.
  */
  get(e) {
    return e instanceof Qt ? this.getBuffer(e.context.buffer, e.index) : e instanceof Ae ? this.map.get(e.tree) : void 0;
  }
  /**
  Set the value for the node that a cursor currently points to.
  */
  cursorSet(e, t) {
    e.buffer ? this.setBuffer(e.buffer.buffer, e.index, t) : this.map.set(e.tree, t);
  }
  /**
  Retrieve the value for the node that a cursor currently points
  to.
  */
  cursorGet(e) {
    return e.buffer ? this.getBuffer(e.buffer.buffer, e.index) : this.map.get(e.tree);
  }
}
class Dt {
  /**
  Construct a tree fragment. You'll usually want to use
  [`addTree`](#common.TreeFragment^addTree) and
  [`applyChanges`](#common.TreeFragment^applyChanges) instead of
  calling this directly.
  */
  constructor(e, t, i, n, s = !1, o = !1) {
    this.from = e, this.to = t, this.tree = i, this.offset = n, this.open = (s ? 1 : 0) | (o ? 2 : 0);
  }
  /**
  Whether the start of the fragment represents the start of a
  parse, or the end of a change. (In the second case, it may not
  be safe to reuse some nodes at the start, depending on the
  parsing algorithm.)
  */
  get openStart() {
    return (this.open & 1) > 0;
  }
  /**
  Whether the end of the fragment represents the end of a
  full-document parse, or the start of a change.
  */
  get openEnd() {
    return (this.open & 2) > 0;
  }
  /**
  Create a set of fragments from a freshly parsed tree, or update
  an existing set of fragments by replacing the ones that overlap
  with a tree with content from the new tree. When `partial` is
  true, the parse is treated as incomplete, and the resulting
  fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
  true.
  */
  static addTree(e, t = [], i = !1) {
    let n = [new Dt(0, e.length, e, 0, !1, i)];
    for (let s of t)
      s.to > e.length && n.push(s);
    return n;
  }
  /**
  Apply a set of edits to an array of fragments, removing or
  splitting fragments as necessary to remove edited ranges, and
  adjusting offsets for fragments that moved.
  */
  static applyChanges(e, t, i = 128) {
    if (!t.length)
      return e;
    let n = [], s = 1, o = e.length ? e[0] : null;
    for (let l = 0, a = 0, h = 0; ; l++) {
      let c = l < t.length ? t[l] : null, f = c ? c.fromA : 1e9;
      if (f - a >= i)
        for (; o && o.from < f; ) {
          let u = o;
          if (a >= u.from || f <= u.to || h) {
            let d = Math.max(u.from, a) - h, p = Math.min(u.to, f) - h;
            u = d >= p ? null : new Dt(d, p, u.tree, u.offset + h, l > 0, !!c);
          }
          if (u && n.push(u), o.to > f)
            break;
          o = s < e.length ? e[s++] : null;
        }
      if (!c)
        break;
      a = c.toA, h = c.toA - c.toB;
    }
    return n;
  }
}
class wh {
  /**
  Start a parse, returning a [partial parse](#common.PartialParse)
  object. [`fragments`](#common.TreeFragment) can be passed in to
  make the parse incremental.
  
  By default, the entire input is parsed. You can pass `ranges`,
  which should be a sorted array of non-empty, non-overlapping
  ranges, to parse only those ranges. The tree returned in that
  case will start at `ranges[0].from`.
  */
  startParse(e, t, i) {
    return typeof e == "string" && (e = new Wx(e)), i = i ? i.length ? i.map((n) => new et(n.from, n.to)) : [new et(0, 0)] : [new et(0, e.length)], this.createParse(e, t || [], i);
  }
  /**
  Run a full parse, returning the resulting tree.
  */
  parse(e, t, i) {
    let n = this.startParse(e, t, i);
    for (; ; ) {
      let s = n.advance();
      if (s)
        return s;
    }
  }
}
class Wx {
  constructor(e) {
    this.string = e;
  }
  get length() {
    return this.string.length;
  }
  chunk(e) {
    return this.string.slice(e);
  }
  get lineChunks() {
    return !1;
  }
  read(e, t) {
    return this.string.slice(e, t);
  }
}
function sm(r) {
  return (e, t, i, n) => new Gx(e, r, t, i, n);
}
class Lf {
  constructor(e, t, i, n, s) {
    this.parser = e, this.parse = t, this.overlay = i, this.target = n, this.from = s;
  }
}
function Ef(r) {
  if (!r.length || r.some((e) => e.from >= e.to))
    throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(r));
}
class jx {
  constructor(e, t, i, n, s, o, l) {
    this.parser = e, this.predicate = t, this.mounts = i, this.index = n, this.start = s, this.target = o, this.prev = l, this.depth = 0, this.ranges = [];
  }
}
const va = new j({ perNode: !0 });
class Gx {
  constructor(e, t, i, n, s) {
    this.nest = t, this.input = i, this.fragments = n, this.ranges = s, this.inner = [], this.innerDone = 0, this.baseTree = null, this.stoppedAt = null, this.baseParse = e;
  }
  advance() {
    if (this.baseParse) {
      let i = this.baseParse.advance();
      if (!i)
        return null;
      if (this.baseParse = null, this.baseTree = i, this.startInner(), this.stoppedAt != null)
        for (let n of this.inner)
          n.parse.stopAt(this.stoppedAt);
    }
    if (this.innerDone == this.inner.length) {
      let i = this.baseTree;
      return this.stoppedAt != null && (i = new te(i.type, i.children, i.positions, i.length, i.propValues.concat([[va, this.stoppedAt]]))), i;
    }
    let e = this.inner[this.innerDone], t = e.parse.advance();
    if (t) {
      this.innerDone++;
      let i = Object.assign(/* @__PURE__ */ Object.create(null), e.target.props);
      i[j.mounted.id] = new Ur(t, e.overlay, e.parser), e.target.props = i;
    }
    return null;
  }
  get parsedPos() {
    if (this.baseParse)
      return 0;
    let e = this.input.length;
    for (let t = this.innerDone; t < this.inner.length; t++)
      this.inner[t].from < e && (e = Math.min(e, this.inner[t].parse.parsedPos));
    return e;
  }
  stopAt(e) {
    if (this.stoppedAt = e, this.baseParse)
      this.baseParse.stopAt(e);
    else
      for (let t = this.innerDone; t < this.inner.length; t++)
        this.inner[t].parse.stopAt(e);
  }
  startInner() {
    let e = new Hx(this.fragments), t = null, i = null, n = new Vs(new Ae(this.baseTree, this.ranges[0].from, 0, null), le.IncludeAnonymous | le.IgnoreMounts);
    e: for (let s, o; ; ) {
      let l = !0, a;
      if (this.stoppedAt != null && n.from >= this.stoppedAt)
        l = !1;
      else if (e.hasNode(n)) {
        if (t) {
          let h = t.mounts.find((c) => c.frag.from <= n.from && c.frag.to >= n.to && c.mount.overlay);
          if (h)
            for (let c of h.mount.overlay) {
              let f = c.from + h.pos, u = c.to + h.pos;
              f >= n.from && u <= n.to && !t.ranges.some((d) => d.from < u && d.to > f) && t.ranges.push({ from: f, to: u });
            }
        }
        l = !1;
      } else if (i && (o = Ux(i.ranges, n.from, n.to)))
        l = o != 2;
      else if (!n.type.isAnonymous && (s = this.nest(n, this.input)) && (n.from < n.to || !s.overlay)) {
        n.tree || (Fx(n), t && t.depth++, i && i.depth++);
        let h = e.findMounts(n.from, s.parser);
        if (typeof s.overlay == "function")
          t = new jx(s.parser, s.overlay, h, this.inner.length, n.from, n.tree, t);
        else {
          let c = _f(this.ranges, s.overlay || (n.from < n.to ? [new et(n.from, n.to)] : []));
          c.length && Ef(c), (c.length || !s.overlay) && this.inner.push(new Lf(s.parser, c.length ? s.parser.startParse(this.input, Bf(h, c), c) : s.parser.startParse(""), s.overlay ? s.overlay.map((f) => new et(f.from - n.from, f.to - n.from)) : null, n.tree, c.length ? c[0].from : n.from)), s.overlay ? c.length && (i = { ranges: c, depth: 0, prev: i }) : l = !1;
        }
      } else if (t && (a = t.predicate(n)) && (a === !0 && (a = new et(n.from, n.to)), a.from < a.to)) {
        let h = t.ranges.length - 1;
        h >= 0 && t.ranges[h].to == a.from ? t.ranges[h] = { from: t.ranges[h].from, to: a.to } : t.ranges.push(a);
      }
      if (l && n.firstChild())
        t && t.depth++, i && i.depth++;
      else
        for (; !n.nextSibling(); ) {
          if (!n.parent())
            break e;
          if (t && !--t.depth) {
            let h = _f(this.ranges, t.ranges);
            h.length && (Ef(h), this.inner.splice(t.index, 0, new Lf(t.parser, t.parser.startParse(this.input, Bf(t.mounts, h), h), t.ranges.map((c) => new et(c.from - t.start, c.to - t.start)), t.target, h[0].from))), t = t.prev;
          }
          i && !--i.depth && (i = i.prev);
        }
    }
  }
}
function Ux(r, e, t) {
  for (let i of r) {
    if (i.from >= t)
      break;
    if (i.to > e)
      return i.from <= e && i.to >= t ? 2 : 1;
  }
  return 0;
}
function zf(r, e, t, i, n, s) {
  if (e < t) {
    let o = r.buffer[e + 1];
    i.push(r.slice(e, t, o)), n.push(o - s);
  }
}
function Fx(r) {
  let { node: e } = r, t = [], i = e.context.buffer;
  do
    t.push(r.index), r.parent();
  while (!r.tree);
  let n = r.tree, s = n.children.indexOf(i), o = n.children[s], l = o.buffer, a = [s];
  function h(c, f, u, d, p, O) {
    let g = t[O], b = [], w = [];
    zf(o, c, g, b, w, d);
    let k = l[g + 1], x = l[g + 2];
    a.push(b.length);
    let S = O ? h(g + 4, l[g + 3], o.set.types[l[g]], k, x - k, O - 1) : e.toTree();
    return b.push(S), w.push(k - d), zf(o, l[g + 3], f, b, w, d), new te(u, b, w, p);
  }
  n.children[s] = h(0, l.length, Se.none, 0, o.length, t.length - 1);
  for (let c of a) {
    let f = r.tree.children[c], u = r.tree.positions[c];
    r.yield(new Ae(f, u + r.from, c, r._tree));
  }
}
class Df {
  constructor(e, t) {
    this.offset = t, this.done = !1, this.cursor = e.cursor(le.IncludeAnonymous | le.IgnoreMounts);
  }
  // Move to the first node (in pre-order) that starts at or after `pos`.
  moveTo(e) {
    let { cursor: t } = this, i = e - this.offset;
    for (; !this.done && t.from < i; )
      t.to >= e && t.enter(i, 1, le.IgnoreOverlays | le.ExcludeBuffers) || t.next(!1) || (this.done = !0);
  }
  hasNode(e) {
    if (this.moveTo(e.from), !this.done && this.cursor.from + this.offset == e.from && this.cursor.tree)
      for (let t = this.cursor.tree; ; ) {
        if (t == e.tree)
          return !0;
        if (t.children.length && t.positions[0] == 0 && t.children[0] instanceof te)
          t = t.children[0];
        else
          break;
      }
    return !1;
  }
}
let Hx = class {
  constructor(e) {
    var t;
    if (this.fragments = e, this.curTo = 0, this.fragI = 0, e.length) {
      let i = this.curFrag = e[0];
      this.curTo = (t = i.tree.prop(va)) !== null && t !== void 0 ? t : i.to, this.inner = new Df(i.tree, -i.offset);
    } else
      this.curFrag = this.inner = null;
  }
  hasNode(e) {
    for (; this.curFrag && e.from >= this.curTo; )
      this.nextFrag();
    return this.curFrag && this.curFrag.from <= e.from && this.curTo >= e.to && this.inner.hasNode(e);
  }
  nextFrag() {
    var e;
    if (this.fragI++, this.fragI == this.fragments.length)
      this.curFrag = this.inner = null;
    else {
      let t = this.curFrag = this.fragments[this.fragI];
      this.curTo = (e = t.tree.prop(va)) !== null && e !== void 0 ? e : t.to, this.inner = new Df(t.tree, -t.offset);
    }
  }
  findMounts(e, t) {
    var i;
    let n = [];
    if (this.inner) {
      this.inner.cursor.moveTo(e, 1);
      for (let s = this.inner.cursor.node; s; s = s.parent) {
        let o = (i = s.tree) === null || i === void 0 ? void 0 : i.prop(j.mounted);
        if (o && o.parser == t)
          for (let l = this.fragI; l < this.fragments.length; l++) {
            let a = this.fragments[l];
            if (a.from >= s.to)
              break;
            a.tree == this.curFrag.tree && n.push({
              frag: a,
              pos: s.from - a.offset,
              mount: o
            });
          }
      }
    }
    return n;
  }
};
function _f(r, e) {
  let t = null, i = e;
  for (let n = 1, s = 0; n < r.length; n++) {
    let o = r[n - 1].to, l = r[n].from;
    for (; s < i.length; s++) {
      let a = i[s];
      if (a.from >= l)
        break;
      a.to <= o || (t || (i = t = e.slice()), a.from < o ? (t[s] = new et(a.from, o), a.to > l && t.splice(s + 1, 0, new et(l, a.to))) : a.to > l ? t[s--] = new et(l, a.to) : t.splice(s--, 1));
    }
  }
  return i;
}
function Kx(r, e, t, i) {
  let n = 0, s = 0, o = !1, l = !1, a = -1e9, h = [];
  for (; ; ) {
    let c = n == r.length ? 1e9 : o ? r[n].to : r[n].from, f = s == e.length ? 1e9 : l ? e[s].to : e[s].from;
    if (o != l) {
      let u = Math.max(a, t), d = Math.min(c, f, i);
      u < d && h.push(new et(u, d));
    }
    if (a = Math.min(c, f), a == 1e9)
      break;
    c == a && (o ? (o = !1, n++) : o = !0), f == a && (l ? (l = !1, s++) : l = !0);
  }
  return h;
}
function Bf(r, e) {
  let t = [];
  for (let { pos: i, mount: n, frag: s } of r) {
    let o = i + (n.overlay ? n.overlay[0].from : 0), l = o + n.tree.length, a = Math.max(s.from, o), h = Math.min(s.to, l);
    if (n.overlay) {
      let c = n.overlay.map((u) => new et(u.from + i, u.to + i)), f = Kx(e, c, a, h);
      for (let u = 0, d = a; ; u++) {
        let p = u == f.length, O = p ? h : f[u].from;
        if (O > d && t.push(new Dt(d, O, n.tree, -o, s.from >= d || s.openStart, s.to <= O || s.openEnd)), p)
          break;
        d = f[u].to;
      }
    } else
      t.push(new Dt(a, h, n.tree, -o, s.from >= o || s.openStart, s.to <= l || s.openEnd));
  }
  return t;
}
let Jx = 0;
class Ne {
  /**
  @internal
  */
  constructor(e, t, i, n) {
    this.name = e, this.set = t, this.base = i, this.modified = n, this.id = Jx++;
  }
  toString() {
    let { name: e } = this;
    for (let t of this.modified)
      t.name && (e = `${t.name}(${e})`);
    return e;
  }
  static define(e, t) {
    let i = typeof e == "string" ? e : "?";
    if (e instanceof Ne && (t = e), t?.base)
      throw new Error("Can not derive from a modified tag");
    let n = new Ne(i, [], null, []);
    if (n.set.push(n), t)
      for (let s of t.set)
        n.set.push(s);
    return n;
  }
  /**
  Define a tag _modifier_, which is a function that, given a tag,
  will return a tag that is a subtag of the original. Applying the
  same modifier to a twice tag will return the same value (`m1(t1)
  == m1(t1)`) and applying multiple modifiers will, regardless or
  order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
  
  When multiple modifiers are applied to a given base tag, each
  smaller set of modifiers is registered as a parent, so that for
  example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
  `m1(m3(t1)`, and so on.
  */
  static defineModifier(e) {
    let t = new qs(e);
    return (i) => i.modified.indexOf(t) > -1 ? i : qs.get(i.base || i, i.modified.concat(t).sort((n, s) => n.id - s.id));
  }
}
let ek = 0;
class qs {
  constructor(e) {
    this.name = e, this.instances = [], this.id = ek++;
  }
  static get(e, t) {
    if (!t.length)
      return e;
    let i = t[0].instances.find((l) => l.base == e && tk(t, l.modified));
    if (i)
      return i;
    let n = [], s = new Ne(e.name, n, e, t);
    for (let l of t)
      l.instances.push(s);
    let o = ik(t);
    for (let l of e.set)
      if (!l.modified.length)
        for (let a of o)
          n.push(qs.get(l, a));
    return s;
  }
}
function tk(r, e) {
  return r.length == e.length && r.every((t, i) => t == e[i]);
}
function ik(r) {
  let e = [[]];
  for (let t = 0; t < r.length; t++)
    for (let i = 0, n = e.length; i < n; i++)
      e.push(e[i].concat(r[t]));
  return e.sort((t, i) => i.length - t.length);
}
function sr(r) {
  let e = /* @__PURE__ */ Object.create(null);
  for (let t in r) {
    let i = r[t];
    Array.isArray(i) || (i = [i]);
    for (let n of t.split(" "))
      if (n) {
        let s = [], o = 2, l = n;
        for (let f = 0; ; ) {
          if (l == "..." && f > 0 && f + 3 == n.length) {
            o = 1;
            break;
          }
          let u = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);
          if (!u)
            throw new RangeError("Invalid path: " + n);
          if (s.push(u[0] == "*" ? "" : u[0][0] == '"' ? JSON.parse(u[0]) : u[0]), f += u[0].length, f == n.length)
            break;
          let d = n[f++];
          if (f == n.length && d == "!") {
            o = 0;
            break;
          }
          if (d != "/")
            throw new RangeError("Invalid path: " + n);
          l = n.slice(f);
        }
        let a = s.length - 1, h = s[a];
        if (!h)
          throw new RangeError("Invalid path: " + n);
        let c = new Hr(i, o, a > 0 ? s.slice(0, a) : null);
        e[h] = c.sort(e[h]);
      }
  }
  return om.add(e);
}
const om = new j({
  combine(r, e) {
    let t, i, n;
    for (; r || e; ) {
      if (!r || e && r.depth >= e.depth ? (n = e, e = e.next) : (n = r, r = r.next), t && t.mode == n.mode && !n.context && !t.context)
        continue;
      let s = new Hr(n.tags, n.mode, n.context);
      t ? t.next = s : i = s, t = s;
    }
    return i;
  }
});
class Hr {
  constructor(e, t, i, n) {
    this.tags = e, this.mode = t, this.context = i, this.next = n;
  }
  get opaque() {
    return this.mode == 0;
  }
  get inherit() {
    return this.mode == 1;
  }
  sort(e) {
    return !e || e.depth < this.depth ? (this.next = e, this) : (e.next = this.sort(e.next), e);
  }
  get depth() {
    return this.context ? this.context.length : 0;
  }
}
Hr.empty = new Hr([], 2, null);
function lm(r, e) {
  let t = /* @__PURE__ */ Object.create(null);
  for (let s of r)
    if (!Array.isArray(s.tag))
      t[s.tag.id] = s.class;
    else
      for (let o of s.tag)
        t[o.id] = s.class;
  let { scope: i, all: n = null } = e || {};
  return {
    style: (s) => {
      let o = n;
      for (let l of s)
        for (let a of l.set) {
          let h = t[a.id];
          if (h) {
            o = o ? o + " " + h : h;
            break;
          }
        }
      return o;
    },
    scope: i
  };
}
function rk(r, e) {
  let t = null;
  for (let i of r) {
    let n = i.style(e);
    n && (t = t ? t + " " + n : n);
  }
  return t;
}
function nk(r, e, t, i = 0, n = r.length) {
  let s = new sk(i, Array.isArray(e) ? e : [e], t);
  s.highlightRange(r.cursor(), i, n, "", s.highlighters), s.flush(n);
}
class sk {
  constructor(e, t, i) {
    this.at = e, this.highlighters = t, this.span = i, this.class = "";
  }
  startSpan(e, t) {
    t != this.class && (this.flush(e), e > this.at && (this.at = e), this.class = t);
  }
  flush(e) {
    e > this.at && this.class && this.span(this.at, e, this.class);
  }
  highlightRange(e, t, i, n, s) {
    let { type: o, from: l, to: a } = e;
    if (l >= i || a <= t)
      return;
    o.isTop && (s = this.highlighters.filter((d) => !d.scope || d.scope(o)));
    let h = n, c = ok(e) || Hr.empty, f = rk(s, c.tags);
    if (f && (h && (h += " "), h += f, c.mode == 1 && (n += (n ? " " : "") + f)), this.startSpan(Math.max(t, l), h), c.opaque)
      return;
    let u = e.tree && e.tree.prop(j.mounted);
    if (u && u.overlay) {
      let d = e.node.enter(u.overlay[0].from + l, 1), p = this.highlighters.filter((g) => !g.scope || g.scope(u.tree.type)), O = e.firstChild();
      for (let g = 0, b = l; ; g++) {
        let w = g < u.overlay.length ? u.overlay[g] : null, k = w ? w.from + l : a, x = Math.max(t, b), S = Math.min(i, k);
        if (x < S && O)
          for (; e.from < S && (this.highlightRange(e, x, S, n, s), this.startSpan(Math.min(S, e.to), h), !(e.to >= k || !e.nextSibling())); )
            ;
        if (!w || k > i)
          break;
        b = w.to + l, b > t && (this.highlightRange(d.cursor(), Math.max(t, w.from + l), Math.min(i, b), "", p), this.startSpan(Math.min(i, b), h));
      }
      O && e.parent();
    } else if (e.firstChild()) {
      u && (n = "");
      do
        if (!(e.to <= t)) {
          if (e.from >= i)
            break;
          this.highlightRange(e, t, i, n, s), this.startSpan(Math.min(i, e.to), h);
        }
      while (e.nextSibling());
      e.parent();
    }
  }
}
function ok(r) {
  let e = r.type.prop(om);
  for (; e && e.context && !r.matchContext(e.context); )
    e = e.next;
  return e || null;
}
const X = Ne.define, Nn = X(), Kt = X(), If = X(Kt), Vf = X(Kt), Jt = X(), Wn = X(Jt), Fo = X(Jt), yt = X(), mi = X(yt), Ot = X(), mt = X(), $a = X(), Or = X($a), jn = X(), m = {
  /**
  A comment.
  */
  comment: Nn,
  /**
  A line [comment](#highlight.tags.comment).
  */
  lineComment: X(Nn),
  /**
  A block [comment](#highlight.tags.comment).
  */
  blockComment: X(Nn),
  /**
  A documentation [comment](#highlight.tags.comment).
  */
  docComment: X(Nn),
  /**
  Any kind of identifier.
  */
  name: Kt,
  /**
  The [name](#highlight.tags.name) of a variable.
  */
  variableName: X(Kt),
  /**
  A type [name](#highlight.tags.name).
  */
  typeName: If,
  /**
  A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
  */
  tagName: X(If),
  /**
  A property or field [name](#highlight.tags.name).
  */
  propertyName: Vf,
  /**
  An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
  */
  attributeName: X(Vf),
  /**
  The [name](#highlight.tags.name) of a class.
  */
  className: X(Kt),
  /**
  A label [name](#highlight.tags.name).
  */
  labelName: X(Kt),
  /**
  A namespace [name](#highlight.tags.name).
  */
  namespace: X(Kt),
  /**
  The [name](#highlight.tags.name) of a macro.
  */
  macroName: X(Kt),
  /**
  A literal value.
  */
  literal: Jt,
  /**
  A string [literal](#highlight.tags.literal).
  */
  string: Wn,
  /**
  A documentation [string](#highlight.tags.string).
  */
  docString: X(Wn),
  /**
  A character literal (subtag of [string](#highlight.tags.string)).
  */
  character: X(Wn),
  /**
  An attribute value (subtag of [string](#highlight.tags.string)).
  */
  attributeValue: X(Wn),
  /**
  A number [literal](#highlight.tags.literal).
  */
  number: Fo,
  /**
  An integer [number](#highlight.tags.number) literal.
  */
  integer: X(Fo),
  /**
  A floating-point [number](#highlight.tags.number) literal.
  */
  float: X(Fo),
  /**
  A boolean [literal](#highlight.tags.literal).
  */
  bool: X(Jt),
  /**
  Regular expression [literal](#highlight.tags.literal).
  */
  regexp: X(Jt),
  /**
  An escape [literal](#highlight.tags.literal), for example a
  backslash escape in a string.
  */
  escape: X(Jt),
  /**
  A color [literal](#highlight.tags.literal).
  */
  color: X(Jt),
  /**
  A URL [literal](#highlight.tags.literal).
  */
  url: X(Jt),
  /**
  A language keyword.
  */
  keyword: Ot,
  /**
  The [keyword](#highlight.tags.keyword) for the self or this
  object.
  */
  self: X(Ot),
  /**
  The [keyword](#highlight.tags.keyword) for null.
  */
  null: X(Ot),
  /**
  A [keyword](#highlight.tags.keyword) denoting some atomic value.
  */
  atom: X(Ot),
  /**
  A [keyword](#highlight.tags.keyword) that represents a unit.
  */
  unit: X(Ot),
  /**
  A modifier [keyword](#highlight.tags.keyword).
  */
  modifier: X(Ot),
  /**
  A [keyword](#highlight.tags.keyword) that acts as an operator.
  */
  operatorKeyword: X(Ot),
  /**
  A control-flow related [keyword](#highlight.tags.keyword).
  */
  controlKeyword: X(Ot),
  /**
  A [keyword](#highlight.tags.keyword) that defines something.
  */
  definitionKeyword: X(Ot),
  /**
  A [keyword](#highlight.tags.keyword) related to defining or
  interfacing with modules.
  */
  moduleKeyword: X(Ot),
  /**
  An operator.
  */
  operator: mt,
  /**
  An [operator](#highlight.tags.operator) that dereferences something.
  */
  derefOperator: X(mt),
  /**
  Arithmetic-related [operator](#highlight.tags.operator).
  */
  arithmeticOperator: X(mt),
  /**
  Logical [operator](#highlight.tags.operator).
  */
  logicOperator: X(mt),
  /**
  Bit [operator](#highlight.tags.operator).
  */
  bitwiseOperator: X(mt),
  /**
  Comparison [operator](#highlight.tags.operator).
  */
  compareOperator: X(mt),
  /**
  [Operator](#highlight.tags.operator) that updates its operand.
  */
  updateOperator: X(mt),
  /**
  [Operator](#highlight.tags.operator) that defines something.
  */
  definitionOperator: X(mt),
  /**
  Type-related [operator](#highlight.tags.operator).
  */
  typeOperator: X(mt),
  /**
  Control-flow [operator](#highlight.tags.operator).
  */
  controlOperator: X(mt),
  /**
  Program or markup punctuation.
  */
  punctuation: $a,
  /**
  [Punctuation](#highlight.tags.punctuation) that separates
  things.
  */
  separator: X($a),
  /**
  Bracket-style [punctuation](#highlight.tags.punctuation).
  */
  bracket: Or,
  /**
  Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
  tokens).
  */
  angleBracket: X(Or),
  /**
  Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
  tokens).
  */
  squareBracket: X(Or),
  /**
  Parentheses (usually `(` and `)` tokens). Subtag of
  [bracket](#highlight.tags.bracket).
  */
  paren: X(Or),
  /**
  Braces (usually `{` and `}` tokens). Subtag of
  [bracket](#highlight.tags.bracket).
  */
  brace: X(Or),
  /**
  Content, for example plain text in XML or markup documents.
  */
  content: yt,
  /**
  [Content](#highlight.tags.content) that represents a heading.
  */
  heading: mi,
  /**
  A level 1 [heading](#highlight.tags.heading).
  */
  heading1: X(mi),
  /**
  A level 2 [heading](#highlight.tags.heading).
  */
  heading2: X(mi),
  /**
  A level 3 [heading](#highlight.tags.heading).
  */
  heading3: X(mi),
  /**
  A level 4 [heading](#highlight.tags.heading).
  */
  heading4: X(mi),
  /**
  A level 5 [heading](#highlight.tags.heading).
  */
  heading5: X(mi),
  /**
  A level 6 [heading](#highlight.tags.heading).
  */
  heading6: X(mi),
  /**
  A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
  */
  contentSeparator: X(yt),
  /**
  [Content](#highlight.tags.content) that represents a list.
  */
  list: X(yt),
  /**
  [Content](#highlight.tags.content) that represents a quote.
  */
  quote: X(yt),
  /**
  [Content](#highlight.tags.content) that is emphasized.
  */
  emphasis: X(yt),
  /**
  [Content](#highlight.tags.content) that is styled strong.
  */
  strong: X(yt),
  /**
  [Content](#highlight.tags.content) that is part of a link.
  */
  link: X(yt),
  /**
  [Content](#highlight.tags.content) that is styled as code or
  monospace.
  */
  monospace: X(yt),
  /**
  [Content](#highlight.tags.content) that has a strike-through
  style.
  */
  strikethrough: X(yt),
  /**
  Inserted text in a change-tracking format.
  */
  inserted: X(),
  /**
  Deleted text.
  */
  deleted: X(),
  /**
  Changed text.
  */
  changed: X(),
  /**
  An invalid or unsyntactic element.
  */
  invalid: X(),
  /**
  Metadata or meta-instruction.
  */
  meta: jn,
  /**
  [Metadata](#highlight.tags.meta) that applies to the entire
  document.
  */
  documentMeta: X(jn),
  /**
  [Metadata](#highlight.tags.meta) that annotates or adds
  attributes to a given syntactic element.
  */
  annotation: X(jn),
  /**
  Processing instruction or preprocessor directive. Subtag of
  [meta](#highlight.tags.meta).
  */
  processingInstruction: X(jn),
  /**
  [Modifier](#highlight.Tag^defineModifier) that indicates that a
  given element is being defined. Expected to be used with the
  various [name](#highlight.tags.name) tags.
  */
  definition: Ne.defineModifier("definition"),
  /**
  [Modifier](#highlight.Tag^defineModifier) that indicates that
  something is constant. Mostly expected to be used with
  [variable names](#highlight.tags.variableName).
  */
  constant: Ne.defineModifier("constant"),
  /**
  [Modifier](#highlight.Tag^defineModifier) used to indicate that
  a [variable](#highlight.tags.variableName) or [property
  name](#highlight.tags.propertyName) is being called or defined
  as a function.
  */
  function: Ne.defineModifier("function"),
  /**
  [Modifier](#highlight.Tag^defineModifier) that can be applied to
  [names](#highlight.tags.name) to indicate that they belong to
  the language's standard environment.
  */
  standard: Ne.defineModifier("standard"),
  /**
  [Modifier](#highlight.Tag^defineModifier) that indicates a given
  [names](#highlight.tags.name) is local to some scope.
  */
  local: Ne.defineModifier("local"),
  /**
  A generic variant [modifier](#highlight.Tag^defineModifier) that
  can be used to tag language-specific alternative variants of
  some common tag. It is recommended for themes to define special
  forms of at least the [string](#highlight.tags.string) and
  [variable name](#highlight.tags.variableName) tags, since those
  come up a lot.
  */
  special: Ne.defineModifier("special")
};
for (let r in m) {
  let e = m[r];
  e instanceof Ne && (e.name = r);
}
lm([
  { tag: m.link, class: "tok-link" },
  { tag: m.heading, class: "tok-heading" },
  { tag: m.emphasis, class: "tok-emphasis" },
  { tag: m.strong, class: "tok-strong" },
  { tag: m.keyword, class: "tok-keyword" },
  { tag: m.atom, class: "tok-atom" },
  { tag: m.bool, class: "tok-bool" },
  { tag: m.url, class: "tok-url" },
  { tag: m.labelName, class: "tok-labelName" },
  { tag: m.inserted, class: "tok-inserted" },
  { tag: m.deleted, class: "tok-deleted" },
  { tag: m.literal, class: "tok-literal" },
  { tag: m.string, class: "tok-string" },
  { tag: m.number, class: "tok-number" },
  { tag: [m.regexp, m.escape, m.special(m.string)], class: "tok-string2" },
  { tag: m.variableName, class: "tok-variableName" },
  { tag: m.local(m.variableName), class: "tok-variableName tok-local" },
  { tag: m.definition(m.variableName), class: "tok-variableName tok-definition" },
  { tag: m.special(m.variableName), class: "tok-variableName2" },
  { tag: m.definition(m.propertyName), class: "tok-propertyName tok-definition" },
  { tag: m.typeName, class: "tok-typeName" },
  { tag: m.namespace, class: "tok-namespace" },
  { tag: m.className, class: "tok-className" },
  { tag: m.macroName, class: "tok-macroName" },
  { tag: m.propertyName, class: "tok-propertyName" },
  { tag: m.operator, class: "tok-operator" },
  { tag: m.comment, class: "tok-comment" },
  { tag: m.meta, class: "tok-meta" },
  { tag: m.invalid, class: "tok-invalid" },
  { tag: m.punctuation, class: "tok-punctuation" }
]);
var Ho;
const Qi = /* @__PURE__ */ new j();
function xh(r) {
  return R.define({
    combine: r ? (e) => e.concat(r) : void 0
  });
}
const kh = /* @__PURE__ */ new j();
class tt {
  /**
  Construct a language object. If you need to invoke this
  directly, first define a data facet with
  [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
  configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
  to the language's outer syntax node.
  */
  constructor(e, t, i = [], n = "") {
    this.data = e, this.name = n, W.prototype.hasOwnProperty("tree") || Object.defineProperty(W.prototype, "tree", { get() {
      return ve(this);
    } }), this.parser = t, this.extension = [
      Ji.of(this),
      W.languageData.of((s, o, l) => {
        let a = qf(s, o, l), h = a.type.prop(Qi);
        if (!h)
          return [];
        let c = s.facet(h), f = a.type.prop(kh);
        if (f) {
          let u = a.resolve(o - a.from, l);
          for (let d of f)
            if (d.test(u, s)) {
              let p = s.facet(d.facet);
              return d.type == "replace" ? p : p.concat(c);
            }
        }
        return c;
      })
    ].concat(i);
  }
  /**
  Query whether this language is active at the given position.
  */
  isActiveAt(e, t, i = -1) {
    return qf(e, t, i).type.prop(Qi) == this.data;
  }
  /**
  Find the document regions that were parsed using this language.
  The returned regions will _include_ any nested languages rooted
  in this language, when those exist.
  */
  findRegions(e) {
    let t = e.facet(Ji);
    if (t?.data == this.data)
      return [{ from: 0, to: e.doc.length }];
    if (!t || !t.allowsNesting)
      return [];
    let i = [], n = (s, o) => {
      if (s.prop(Qi) == this.data) {
        i.push({ from: o, to: o + s.length });
        return;
      }
      let l = s.prop(j.mounted);
      if (l) {
        if (l.tree.prop(Qi) == this.data) {
          if (l.overlay)
            for (let a of l.overlay)
              i.push({ from: a.from + o, to: a.to + o });
          else
            i.push({ from: o, to: o + s.length });
          return;
        } else if (l.overlay) {
          let a = i.length;
          if (n(l.tree, l.overlay[0].from + o), i.length > a)
            return;
        }
      }
      for (let a = 0; a < s.children.length; a++) {
        let h = s.children[a];
        h instanceof te && n(h, s.positions[a] + o);
      }
    };
    return n(ve(e), 0), i;
  }
  /**
  Indicates whether this language allows nested languages. The
  default implementation returns true.
  */
  get allowsNesting() {
    return !0;
  }
}
tt.setState = /* @__PURE__ */ V.define();
function qf(r, e, t) {
  let i = r.facet(Ji), n = ve(r).topNode;
  if (!i || i.allowsNesting)
    for (let s = n; s; s = s.enter(e, t, le.ExcludeBuffers))
      s.type.isTop && (n = s);
  return n;
}
class Hi extends tt {
  constructor(e, t, i) {
    super(e, t, [], i), this.parser = t;
  }
  /**
  Define a language from a parser.
  */
  static define(e) {
    let t = xh(e.languageData);
    return new Hi(t, e.parser.configure({
      props: [Qi.add((i) => i.isTop ? t : void 0)]
    }), e.name);
  }
  /**
  Create a new instance of this language with a reconfigured
  version of its parser and optionally a new name.
  */
  configure(e, t) {
    return new Hi(this.data, this.parser.configure(e), t || this.name);
  }
  get allowsNesting() {
    return this.parser.hasWrappers();
  }
}
function ve(r) {
  let e = r.field(tt.state, !1);
  return e ? e.tree : te.empty;
}
class lk {
  /**
  Create an input object for the given document.
  */
  constructor(e) {
    this.doc = e, this.cursorPos = 0, this.string = "", this.cursor = e.iter();
  }
  get length() {
    return this.doc.length;
  }
  syncTo(e) {
    return this.string = this.cursor.next(e - this.cursorPos).value, this.cursorPos = e + this.string.length, this.cursorPos - this.string.length;
  }
  chunk(e) {
    return this.syncTo(e), this.string;
  }
  get lineChunks() {
    return !0;
  }
  read(e, t) {
    let i = this.cursorPos - this.string.length;
    return e < i || t >= this.cursorPos ? this.doc.sliceString(e, t) : this.string.slice(e - i, t - i);
  }
}
let mr = null;
class Kr {
  constructor(e, t, i = [], n, s, o, l, a) {
    this.parser = e, this.state = t, this.fragments = i, this.tree = n, this.treeLen = s, this.viewport = o, this.skipped = l, this.scheduleOn = a, this.parse = null, this.tempSkipped = [];
  }
  /**
  @internal
  */
  static create(e, t, i) {
    return new Kr(e, t, [], te.empty, 0, i, [], null);
  }
  startParse() {
    return this.parser.startParse(new lk(this.state.doc), this.fragments);
  }
  /**
  @internal
  */
  work(e, t) {
    return t != null && t >= this.state.doc.length && (t = void 0), this.tree != te.empty && this.isDone(t ?? this.state.doc.length) ? (this.takeTree(), !0) : this.withContext(() => {
      var i;
      if (typeof e == "number") {
        let n = Date.now() + e;
        e = () => Date.now() > n;
      }
      for (this.parse || (this.parse = this.startParse()), t != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > t) && t < this.state.doc.length && this.parse.stopAt(t); ; ) {
        let n = this.parse.advance();
        if (n)
          if (this.fragments = this.withoutTempSkipped(Dt.addTree(n, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (i = this.parse.stoppedAt) !== null && i !== void 0 ? i : this.state.doc.length, this.tree = n, this.parse = null, this.treeLen < (t ?? this.state.doc.length))
            this.parse = this.startParse();
          else
            return !0;
        if (e())
          return !1;
      }
    });
  }
  /**
  @internal
  */
  takeTree() {
    let e, t;
    this.parse && (e = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > e) && this.parse.stopAt(e), this.withContext(() => {
      for (; !(t = this.parse.advance()); )
        ;
    }), this.treeLen = e, this.tree = t, this.fragments = this.withoutTempSkipped(Dt.addTree(this.tree, this.fragments, !0)), this.parse = null);
  }
  withContext(e) {
    let t = mr;
    mr = this;
    try {
      return e();
    } finally {
      mr = t;
    }
  }
  withoutTempSkipped(e) {
    for (let t; t = this.tempSkipped.pop(); )
      e = Yf(e, t.from, t.to);
    return e;
  }
  /**
  @internal
  */
  changes(e, t) {
    let { fragments: i, tree: n, treeLen: s, viewport: o, skipped: l } = this;
    if (this.takeTree(), !e.empty) {
      let a = [];
      if (e.iterChangedRanges((h, c, f, u) => a.push({ fromA: h, toA: c, fromB: f, toB: u })), i = Dt.applyChanges(i, a), n = te.empty, s = 0, o = { from: e.mapPos(o.from, -1), to: e.mapPos(o.to, 1) }, this.skipped.length) {
        l = [];
        for (let h of this.skipped) {
          let c = e.mapPos(h.from, 1), f = e.mapPos(h.to, -1);
          c < f && l.push({ from: c, to: f });
        }
      }
    }
    return new Kr(this.parser, t, i, n, s, o, l, this.scheduleOn);
  }
  /**
  @internal
  */
  updateViewport(e) {
    if (this.viewport.from == e.from && this.viewport.to == e.to)
      return !1;
    this.viewport = e;
    let t = this.skipped.length;
    for (let i = 0; i < this.skipped.length; i++) {
      let { from: n, to: s } = this.skipped[i];
      n < e.to && s > e.from && (this.fragments = Yf(this.fragments, n, s), this.skipped.splice(i--, 1));
    }
    return this.skipped.length >= t ? !1 : (this.reset(), !0);
  }
  /**
  @internal
  */
  reset() {
    this.parse && (this.takeTree(), this.parse = null);
  }
  /**
  Notify the parse scheduler that the given region was skipped
  because it wasn't in view, and the parse should be restarted
  when it comes into view.
  */
  skipUntilInView(e, t) {
    this.skipped.push({ from: e, to: t });
  }
  /**
  Returns a parser intended to be used as placeholder when
  asynchronously loading a nested parser. It'll skip its input and
  mark it as not-really-parsed, so that the next update will parse
  it again.
  
  When `until` is given, a reparse will be scheduled when that
  promise resolves.
  */
  static getSkippingParser(e) {
    return new class extends wh {
      createParse(t, i, n) {
        let s = n[0].from, o = n[n.length - 1].to;
        return {
          parsedPos: s,
          advance() {
            let a = mr;
            if (a) {
              for (let h of n)
                a.tempSkipped.push(h);
              e && (a.scheduleOn = a.scheduleOn ? Promise.all([a.scheduleOn, e]) : e);
            }
            return this.parsedPos = o, new te(Se.none, [], [], o - s);
          },
          stoppedAt: null,
          stopAt() {
          }
        };
      }
    }();
  }
  /**
  @internal
  */
  isDone(e) {
    e = Math.min(e, this.state.doc.length);
    let t = this.fragments;
    return this.treeLen >= e && t.length && t[0].from == 0 && t[0].to >= e;
  }
  /**
  Get the context for the current parse, or `null` if no editor
  parse is in progress.
  */
  static get() {
    return mr;
  }
}
function Yf(r, e, t) {
  return Dt.applyChanges(r, [{ fromA: e, toA: t, fromB: e, toB: t }]);
}
class Ki {
  constructor(e) {
    this.context = e, this.tree = e.tree;
  }
  apply(e) {
    if (!e.docChanged && this.tree == this.context.tree)
      return this;
    let t = this.context.changes(e.changes, e.state), i = this.context.treeLen == e.startState.doc.length ? void 0 : Math.max(e.changes.mapPos(this.context.treeLen), t.viewport.to);
    return t.work(20, i) || t.takeTree(), new Ki(t);
  }
  static init(e) {
    let t = Math.min(3e3, e.doc.length), i = Kr.create(e.facet(Ji).parser, e, { from: 0, to: t });
    return i.work(20, t) || i.takeTree(), new Ki(i);
  }
}
tt.state = /* @__PURE__ */ ge.define({
  create: Ki.init,
  update(r, e) {
    for (let t of e.effects)
      if (t.is(tt.setState))
        return t.value;
    return e.startState.facet(Ji) != e.state.facet(Ji) ? Ki.init(e.state) : r.apply(e);
  }
});
let am = (r) => {
  let e = setTimeout(
    () => r(),
    500
    /* Work.MaxPause */
  );
  return () => clearTimeout(e);
};
typeof requestIdleCallback < "u" && (am = (r) => {
  let e = -1, t = setTimeout(
    () => {
      e = requestIdleCallback(r, {
        timeout: 400
        /* Work.MinPause */
      });
    },
    100
    /* Work.MinPause */
  );
  return () => e < 0 ? clearTimeout(t) : cancelIdleCallback(e);
});
const Ko = typeof navigator < "u" && (!((Ho = navigator.scheduling) === null || Ho === void 0) && Ho.isInputPending) ? () => navigator.scheduling.isInputPending() : null, ak = /* @__PURE__ */ ue.fromClass(class {
  constructor(e) {
    this.view = e, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
  }
  update(e) {
    let t = this.view.state.field(tt.state).context;
    (t.updateViewport(e.view.viewport) || this.view.viewport.to > t.treeLen) && this.scheduleWork(), (e.docChanged || e.selectionSet) && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(t);
  }
  scheduleWork() {
    if (this.working)
      return;
    let { state: e } = this.view, t = e.field(tt.state);
    (t.tree != t.context.tree || !t.context.isDone(e.doc.length)) && (this.working = am(this.work));
  }
  work(e) {
    this.working = null;
    let t = Date.now();
    if (this.chunkEnd < t && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = t + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
      return;
    let { state: i, viewport: { to: n } } = this.view, s = i.field(tt.state);
    if (s.tree == s.context.tree && s.context.isDone(
      n + 1e5
      /* Work.MaxParseAhead */
    ))
      return;
    let o = Date.now() + Math.min(this.chunkBudget, 100, e && !Ko ? Math.max(25, e.timeRemaining() - 5) : 1e9), l = s.context.treeLen < n && i.doc.length > n + 1e3, a = s.context.work(() => Ko && Ko() || Date.now() > o, n + (l ? 0 : 1e5));
    this.chunkBudget -= Date.now() - t, (a || this.chunkBudget <= 0) && (s.context.takeTree(), this.view.dispatch({ effects: tt.setState.of(new Ki(s.context)) })), this.chunkBudget > 0 && !(a && !l) && this.scheduleWork(), this.checkAsyncSchedule(s.context);
  }
  checkAsyncSchedule(e) {
    e.scheduleOn && (this.workScheduled++, e.scheduleOn.then(() => this.scheduleWork()).catch((t) => Qe(this.view.state, t)).then(() => this.workScheduled--), e.scheduleOn = null);
  }
  destroy() {
    this.working && this.working();
  }
  isWorking() {
    return !!(this.working || this.workScheduled > 0);
  }
}, {
  eventHandlers: { focus() {
    this.scheduleWork();
  } }
}), Ji = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? r[0] : null;
  },
  enables: (r) => [
    tt.state,
    ak,
    D.contentAttributes.compute([r], (e) => {
      let t = e.facet(r);
      return t && t.name ? { "data-language": t.name } : {};
    })
  ]
});
class Jr {
  /**
  Create a language support object.
  */
  constructor(e, t = []) {
    this.language = e, this.support = t, this.extension = [e, t];
  }
}
class Ys {
  constructor(e, t, i, n, s, o = void 0) {
    this.name = e, this.alias = t, this.extensions = i, this.filename = n, this.loadFunc = s, this.support = o, this.loading = null;
  }
  /**
  Start loading the the language. Will return a promise that
  resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
  object when the language successfully loads.
  */
  load() {
    return this.loading || (this.loading = this.loadFunc().then((e) => this.support = e, (e) => {
      throw this.loading = null, e;
    }));
  }
  /**
  Create a language description.
  */
  static of(e) {
    let { load: t, support: i } = e;
    if (!t) {
      if (!i)
        throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
      t = () => Promise.resolve(i);
    }
    return new Ys(e.name, (e.alias || []).concat(e.name).map((n) => n.toLowerCase()), e.extensions || [], e.filename, t, i);
  }
  /**
  Look for a language in the given array of descriptions that
  matches the filename. Will first match
  [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
  and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
  and return the first language that matches.
  */
  static matchFilename(e, t) {
    for (let n of e)
      if (n.filename && n.filename.test(t))
        return n;
    let i = /\.([^.]+)$/.exec(t);
    if (i) {
      for (let n of e)
        if (n.extensions.indexOf(i[1]) > -1)
          return n;
    }
    return null;
  }
  /**
  Look for a language whose name or alias matches the the given
  name (case-insensitively). If `fuzzy` is true, and no direct
  matchs is found, this'll also search for a language whose name
  or alias occurs in the string (for names shorter than three
  characters, only when surrounded by non-word characters).
  */
  static matchLanguageName(e, t, i = !0) {
    t = t.toLowerCase();
    for (let n of e)
      if (n.alias.some((s) => s == t))
        return n;
    if (i)
      for (let n of e)
        for (let s of n.alias) {
          let o = t.indexOf(s);
          if (o > -1 && (s.length > 2 || !/\w/.test(t[o - 1]) && !/\w/.test(t[o + s.length])))
            return n;
        }
    return null;
  }
}
const hm = /* @__PURE__ */ R.define({
  combine: (r) => {
    if (!r.length)
      return "  ";
    let e = r[0];
    if (!e || /\S/.test(e) || Array.from(e).some((t) => t != e[0]))
      throw new Error("Invalid indent unit: " + JSON.stringify(r[0]));
    return e;
  }
}), go = /* @__PURE__ */ new j();
function hk(r) {
  let e = r.node, t = e.childAfter(e.from), i = e.lastChild;
  if (!t)
    return null;
  let n = r.options.simulateBreak, s = r.state.doc.lineAt(t.from), o = n == null || n <= s.from ? s.to : Math.min(s.to, n);
  for (let l = t.to; ; ) {
    let a = e.childAfter(l);
    if (!a || a == i)
      return null;
    if (!a.type.isSkipped) {
      if (a.from >= o)
        return null;
      let h = /^ */.exec(s.text.slice(t.to - s.from))[0].length;
      return { from: t.from, to: t.to + h };
    }
    l = a.to;
  }
}
function ck({ closing: r, align: e = !0, units: t = 1 }) {
  return (i) => fk(i, e, t, r);
}
function fk(r, e, t, i, n) {
  let s = r.textAfter, o = s.match(/^\s*/)[0].length, l = i && s.slice(o, o + i.length) == i || n == r.pos + o, a = e ? hk(r) : null;
  return a ? l ? r.column(a.from) : r.column(a.to) : r.baseIndent + (l ? 0 : r.unit * t);
}
const uk = (r) => r.baseIndent;
function fs({ except: r, units: e = 1 } = {}) {
  return (t) => {
    let i = r && r.test(t.textAfter);
    return t.baseIndent + (i ? 0 : e * t.unit);
  };
}
const dk = /* @__PURE__ */ R.define(), On = /* @__PURE__ */ new j();
function cm(r) {
  let e = r.firstChild, t = r.lastChild;
  return e && e.to < t.from ? { from: e.to, to: t.type.isError ? r.to : t.from } : null;
}
class bo {
  constructor(e, t) {
    this.specs = e;
    let i;
    function n(l) {
      let a = Pt.newName();
      return (i || (i = /* @__PURE__ */ Object.create(null)))["." + a] = l, a;
    }
    const s = typeof t.all == "string" ? t.all : t.all ? n(t.all) : void 0, o = t.scope;
    this.scope = o instanceof tt ? (l) => l.prop(Qi) == o.data : o ? (l) => l == o : void 0, this.style = lm(e.map((l) => ({
      tag: l.tag,
      class: l.class || n(Object.assign({}, l, { tag: null }))
    })), {
      all: s
    }).style, this.module = i ? new Pt(i) : null, this.themeType = t.themeType;
  }
  /**
  Create a highlighter style that associates the given styles to
  the given tags. The specs must be objects that hold a style tag
  or array of tags in their `tag` property, and either a single
  `class` property providing a static CSS class (for highlighter
  that rely on external styling), or a
  [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
  set of CSS properties (which define the styling for those tags).
  
  The CSS rules created for a highlighter will be emitted in the
  order of the spec's properties. That means that for elements that
  have multiple tags associated with them, styles defined further
  down in the list will have a higher CSS precedence than styles
  defined earlier.
  */
  static define(e, t) {
    return new bo(e, t || {});
  }
}
const Pa = /* @__PURE__ */ R.define(), pk = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? [r[0]] : null;
  }
});
function Jo(r) {
  let e = r.facet(Pa);
  return e.length ? e : r.facet(pk);
}
function Ok(r, e) {
  let t = [gk], i;
  return r instanceof bo && (r.module && t.push(D.styleModule.of(r.module)), i = r.themeType), i ? t.push(Pa.computeN([D.darkTheme], (n) => n.facet(D.darkTheme) == (i == "dark") ? [r] : [])) : t.push(Pa.of(r)), t;
}
class mk {
  constructor(e) {
    this.markCache = /* @__PURE__ */ Object.create(null), this.tree = ve(e.state), this.decorations = this.buildDeco(e, Jo(e.state)), this.decoratedTo = e.viewport.to;
  }
  update(e) {
    let t = ve(e.state), i = Jo(e.state), n = i != Jo(e.startState), { viewport: s } = e.view, o = e.changes.mapPos(this.decoratedTo, 1);
    t.length < s.to && !n && t.type == this.tree.type && o >= s.to ? (this.decorations = this.decorations.map(e.changes), this.decoratedTo = o) : (t != this.tree || e.viewportChanged || n) && (this.tree = t, this.decorations = this.buildDeco(e.view, i), this.decoratedTo = s.to);
  }
  buildDeco(e, t) {
    if (!t || !this.tree.length)
      return B.none;
    let i = new _t();
    for (let { from: n, to: s } of e.visibleRanges)
      nk(this.tree, t, (o, l, a) => {
        i.add(o, l, this.markCache[a] || (this.markCache[a] = B.mark({ class: a })));
      }, n, s);
    return i.finish();
  }
}
const gk = /* @__PURE__ */ Vt.high(/* @__PURE__ */ ue.fromClass(mk, {
  decorations: (r) => r.decorations
})), bk = /* @__PURE__ */ new j(), yk = /* @__PURE__ */ Object.create(null), Nf = [Se.none], Wf = [], jf = /* @__PURE__ */ Object.create(null), Sk = /* @__PURE__ */ Object.create(null);
for (let [r, e] of [
  ["variable", "variableName"],
  ["variable-2", "variableName.special"],
  ["string-2", "string.special"],
  ["def", "variableName.definition"],
  ["tag", "tagName"],
  ["attribute", "attributeName"],
  ["type", "typeName"],
  ["builtin", "variableName.standard"],
  ["qualifier", "modifier"],
  ["error", "invalid"],
  ["header", "heading"],
  ["property", "propertyName"]
])
  Sk[r] = /* @__PURE__ */ wk(yk, e);
function el(r, e) {
  Wf.indexOf(r) > -1 || (Wf.push(r), console.warn(e));
}
function wk(r, e) {
  let t = [];
  for (let l of e.split(" ")) {
    let a = [];
    for (let h of l.split(".")) {
      let c = r[h] || m[h];
      c ? typeof c == "function" ? a.length ? a = a.map(c) : el(h, `Modifier ${h} used at start of tag`) : a.length ? el(h, `Tag ${h} used as modifier`) : a = Array.isArray(c) ? c : [c] : el(h, `Unknown highlighting tag ${h}`);
    }
    for (let h of a)
      t.push(h);
  }
  if (!t.length)
    return 0;
  let i = e.replace(/ /g, "_"), n = i + " " + t.map((l) => l.id), s = jf[n];
  if (s)
    return s.id;
  let o = jf[n] = Se.define({
    id: Nf.length,
    name: i,
    props: [sr({ [i]: t })]
  });
  return Nf.push(o), o.id;
}
ce.RTL, ce.LTR;
class xk {
  /**
  Create a new completion context. (Mostly useful for testing
  completion sources—in the editor, the extension will create
  these for you.)
  */
  constructor(e, t, i, n) {
    this.state = e, this.pos = t, this.explicit = i, this.view = n, this.abortListeners = [], this.abortOnDocChange = !1;
  }
  /**
  Get the extent, content, and (if there is a token) type of the
  token before `this.pos`.
  */
  tokenBefore(e) {
    let t = ve(this.state).resolveInner(this.pos, -1);
    for (; t && e.indexOf(t.name) < 0; )
      t = t.parent;
    return t ? {
      from: t.from,
      to: this.pos,
      text: this.state.sliceDoc(t.from, this.pos),
      type: t.type
    } : null;
  }
  /**
  Get the match of the given expression directly before the
  cursor.
  */
  matchBefore(e) {
    let t = this.state.doc.lineAt(this.pos), i = Math.max(t.from, this.pos - 250), n = t.text.slice(i - t.from, this.pos - t.from), s = n.search($k(e));
    return s < 0 ? null : { from: i + s, to: this.pos, text: n.slice(s) };
  }
  /**
  Yields true when the query has been aborted. Can be useful in
  asynchronous queries to avoid doing work that will be ignored.
  */
  get aborted() {
    return this.abortListeners == null;
  }
  /**
  Allows you to register abort handlers, which will be called when
  the query is
  [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
  
  By default, running queries will not be aborted for regular
  typing or backspacing, on the assumption that they are likely to
  return a result with a
  [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
  allows the result to be used after all. Passing `onDocChange:
  true` will cause this query to be aborted for any document
  change.
  */
  addEventListener(e, t, i) {
    e == "abort" && this.abortListeners && (this.abortListeners.push(t), i && i.onDocChange && (this.abortOnDocChange = !0));
  }
}
function Gf(r) {
  let e = Object.keys(r).join(""), t = /\w/.test(e);
  return t && (e = e.replace(/\w/g, "")), `[${t ? "\\w" : ""}${e.replace(/[^\w\s]/g, "\\$&")}]`;
}
function kk(r) {
  let e = /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null);
  for (let { label: n } of r) {
    e[n[0]] = !0;
    for (let s = 1; s < n.length; s++)
      t[n[s]] = !0;
  }
  let i = Gf(e) + Gf(t) + "*$";
  return [new RegExp("^" + i), new RegExp(i)];
}
function Qk(r) {
  let e = r.map((n) => typeof n == "string" ? { label: n } : n), [t, i] = e.every((n) => /^\w+$/.test(n.label)) ? [/\w*$/, /\w+$/] : kk(e);
  return (n) => {
    let s = n.matchBefore(i);
    return s || n.explicit ? { from: s ? s.from : n.pos, options: e, validFor: t } : null;
  };
}
function vk(r, e) {
  return (t) => {
    for (let i = ve(t.state).resolveInner(t.pos, -1); i; i = i.parent) {
      if (r.indexOf(i.name) > -1)
        return null;
      if (i.type.isTop)
        break;
    }
    return e(t);
  };
}
function $k(r, e) {
  var t;
  let { source: i } = r, n = i[i.length - 1] != "$";
  return n ? new RegExp(`(?:${i})${n ? "$" : ""}`, (t = r.flags) !== null && t !== void 0 ? t : r.ignoreCase ? "i" : "") : r;
}
const Pk = /* @__PURE__ */ qt.define(), Ck = /* @__PURE__ */ D.baseTheme({
  ".cm-tooltip.cm-tooltip-autocomplete": {
    "& > ul": {
      fontFamily: "monospace",
      whiteSpace: "nowrap",
      overflow: "hidden auto",
      maxWidth_fallback: "700px",
      maxWidth: "min(700px, 95vw)",
      minWidth: "250px",
      maxHeight: "10em",
      height: "100%",
      listStyle: "none",
      margin: 0,
      padding: 0,
      "& > li, & > completion-section": {
        padding: "1px 3px",
        lineHeight: 1.2
      },
      "& > li": {
        overflowX: "hidden",
        textOverflow: "ellipsis",
        cursor: "pointer"
      },
      "& > completion-section": {
        display: "list-item",
        borderBottom: "1px solid silver",
        paddingLeft: "0.5em",
        opacity: 0.7
      }
    }
  },
  "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
    background: "#17c",
    color: "white"
  },
  "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
    background: "#777"
  },
  "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
    background: "#347",
    color: "white"
  },
  "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
    background: "#444"
  },
  ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
    content: '"···"',
    opacity: 0.5,
    display: "block",
    textAlign: "center"
  },
  ".cm-tooltip.cm-completionInfo": {
    position: "absolute",
    padding: "3px 9px",
    width: "max-content",
    maxWidth: "400px",
    boxSizing: "border-box",
    whiteSpace: "pre-line"
  },
  ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
  ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
  ".cm-completionInfo.cm-completionInfo-left-narrow": { right: "30px" },
  ".cm-completionInfo.cm-completionInfo-right-narrow": { left: "30px" },
  "&light .cm-snippetField": { backgroundColor: "#00000022" },
  "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
  ".cm-snippetFieldPosition": {
    verticalAlign: "text-top",
    width: 0,
    height: "1.15em",
    display: "inline-block",
    margin: "0 -0.7px -.7em",
    borderLeft: "1.4px dotted #888"
  },
  ".cm-completionMatchedText": {
    textDecoration: "underline"
  },
  ".cm-completionDetail": {
    marginLeft: "0.5em",
    fontStyle: "italic"
  },
  ".cm-completionIcon": {
    fontSize: "90%",
    width: ".8em",
    display: "inline-block",
    textAlign: "center",
    paddingRight: ".6em",
    opacity: "0.6",
    boxSizing: "content-box"
  },
  ".cm-completionIcon-function, .cm-completionIcon-method": {
    "&:after": { content: "'ƒ'" }
  },
  ".cm-completionIcon-class": {
    "&:after": { content: "'○'" }
  },
  ".cm-completionIcon-interface": {
    "&:after": { content: "'◌'" }
  },
  ".cm-completionIcon-variable": {
    "&:after": { content: "'𝑥'" }
  },
  ".cm-completionIcon-constant": {
    "&:after": { content: "'𝐶'" }
  },
  ".cm-completionIcon-type": {
    "&:after": { content: "'𝑡'" }
  },
  ".cm-completionIcon-enum": {
    "&:after": { content: "'∪'" }
  },
  ".cm-completionIcon-property": {
    "&:after": { content: "'□'" }
  },
  ".cm-completionIcon-keyword": {
    "&:after": { content: "'🔑︎'" }
    // Disable emoji rendering
  },
  ".cm-completionIcon-namespace": {
    "&:after": { content: "'▢'" }
  },
  ".cm-completionIcon-text": {
    "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
  }
});
class Tk {
  constructor(e, t, i, n) {
    this.field = e, this.line = t, this.from = i, this.to = n;
  }
}
class Qh {
  constructor(e, t, i) {
    this.field = e, this.from = t, this.to = i;
  }
  map(e) {
    let t = e.mapPos(this.from, -1, ke.TrackDel), i = e.mapPos(this.to, 1, ke.TrackDel);
    return t == null || i == null ? null : new Qh(this.field, t, i);
  }
}
class vh {
  constructor(e, t) {
    this.lines = e, this.fieldPositions = t;
  }
  instantiate(e, t) {
    let i = [], n = [t], s = e.doc.lineAt(t), o = /^\s*/.exec(s.text)[0];
    for (let a of this.lines) {
      if (i.length) {
        let h = o, c = /^\t*/.exec(a)[0].length;
        for (let f = 0; f < c; f++)
          h += e.facet(hm);
        n.push(t + h.length - c), a = h + a.slice(c);
      }
      i.push(a), t += a.length + 1;
    }
    let l = this.fieldPositions.map((a) => new Qh(a.field, n[a.line] + a.from, n[a.line] + a.to));
    return { text: i, ranges: l };
  }
  static parse(e) {
    let t = [], i = [], n = [], s;
    for (let o of e.split(/\r\n?|\n/)) {
      for (; s = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o); ) {
        let l = s[1] ? +s[1] : null, a = s[2] || s[3] || "", h = -1, c = a.replace(/\\[{}]/g, (f) => f[1]);
        for (let f = 0; f < t.length; f++)
          (l != null ? t[f].seq == l : c && t[f].name == c) && (h = f);
        if (h < 0) {
          let f = 0;
          for (; f < t.length && (l == null || t[f].seq != null && t[f].seq < l); )
            f++;
          t.splice(f, 0, { seq: l, name: c }), h = f;
          for (let u of n)
            u.field >= h && u.field++;
        }
        for (let f of n)
          if (f.line == i.length && f.from > s.index) {
            let u = s[2] ? 3 + (s[1] || "").length : 2;
            f.from -= u, f.to -= u;
          }
        n.push(new Tk(h, i.length, s.index, s.index + c.length)), o = o.slice(0, s.index) + a + o.slice(s.index + s[0].length);
      }
      o = o.replace(/\\([{}])/g, (l, a, h) => {
        for (let c of n)
          c.line == i.length && c.from > h && (c.from--, c.to--);
        return a;
      }), i.push(o);
    }
    return new vh(i, n);
  }
}
let Ak = /* @__PURE__ */ B.widget({ widget: /* @__PURE__ */ new class extends di {
  toDOM() {
    let r = document.createElement("span");
    return r.className = "cm-snippetFieldPosition", r;
  }
  ignoreEvent() {
    return !1;
  }
}() }), Mk = /* @__PURE__ */ B.mark({ class: "cm-snippetField" });
class or {
  constructor(e, t) {
    this.ranges = e, this.active = t, this.deco = B.set(e.map((i) => (i.from == i.to ? Ak : Mk).range(i.from, i.to)), !0);
  }
  map(e) {
    let t = [];
    for (let i of this.ranges) {
      let n = i.map(e);
      if (!n)
        return null;
      t.push(n);
    }
    return new or(t, this.active);
  }
  selectionInsideField(e) {
    return e.ranges.every((t) => this.ranges.some((i) => i.field == this.active && i.from <= t.from && i.to >= t.to));
  }
}
const mn = /* @__PURE__ */ V.define({
  map(r, e) {
    return r && r.map(e);
  }
}), Zk = /* @__PURE__ */ V.define(), en = /* @__PURE__ */ ge.define({
  create() {
    return null;
  },
  update(r, e) {
    for (let t of e.effects) {
      if (t.is(mn))
        return t.value;
      if (t.is(Zk) && r)
        return new or(r.ranges, t.value);
    }
    return r && e.docChanged && (r = r.map(e.changes)), r && e.selection && !r.selectionInsideField(e.selection) && (r = null), r;
  },
  provide: (r) => D.decorations.from(r, (e) => e ? e.deco : B.none)
});
function $h(r, e) {
  return v.create(r.filter((t) => t.field == e).map((t) => v.range(t.from, t.to)));
}
function Xk(r) {
  let e = vh.parse(r);
  return (t, i, n, s) => {
    let { text: o, ranges: l } = e.instantiate(t.state, n), { main: a } = t.state.selection, h = {
      changes: { from: n, to: s == a.from ? a.to : s, insert: K.of(o) },
      scrollIntoView: !0,
      annotations: i ? [Pk.of(i), me.userEvent.of("input.complete")] : void 0
    };
    if (l.length && (h.selection = $h(l, 0)), l.some((c) => c.field > 0)) {
      let c = new or(l, 0), f = h.effects = [mn.of(c)];
      t.state.field(en, !1) === void 0 && f.push(V.appendConfig.of([en, Dk, _k, Ck]));
    }
    t.dispatch(t.state.update(h));
  };
}
function fm(r) {
  return ({ state: e, dispatch: t }) => {
    let i = e.field(en, !1);
    if (!i || r < 0 && i.active == 0)
      return !1;
    let n = i.active + r, s = r > 0 && !i.ranges.some((o) => o.field == n + r);
    return t(e.update({
      selection: $h(i.ranges, n),
      effects: mn.of(s ? null : new or(i.ranges, n)),
      scrollIntoView: !0
    })), !0;
  };
}
const Rk = ({ state: r, dispatch: e }) => r.field(en, !1) ? (e(r.update({ effects: mn.of(null) })), !0) : !1, Lk = /* @__PURE__ */ fm(1), Ek = /* @__PURE__ */ fm(-1), zk = [
  { key: "Tab", run: Lk, shift: Ek },
  { key: "Escape", run: Rk }
], Uf = /* @__PURE__ */ R.define({
  combine(r) {
    return r.length ? r[0] : zk;
  }
}), Dk = /* @__PURE__ */ Vt.highest(/* @__PURE__ */ Ci.compute([Uf], (r) => r.facet(Uf)));
function Le(r, e) {
  return { ...e, apply: Xk(r) };
}
const _k = /* @__PURE__ */ D.domEventHandlers({
  mousedown(r, e) {
    let t = e.state.field(en, !1), i;
    if (!t || (i = e.posAtCoords({ x: r.clientX, y: r.clientY })) == null)
      return !1;
    let n = t.ranges.find((s) => s.from <= i && s.to >= i);
    return !n || n.field == t.active ? !1 : (e.dispatch({
      selection: $h(t.ranges, n.field),
      effects: mn.of(t.ranges.some((s) => s.field > n.field) ? new or(t.ranges, n.field) : null),
      scrollIntoView: !0
    }), !0);
  }
}), um = /* @__PURE__ */ new class extends oi {
}();
um.startSide = 1;
um.endSide = -1;
class Ns {
  static create(e, t, i, n, s) {
    let o = n + (n << 8) + e + (t << 4) | 0;
    return new Ns(e, t, i, o, s, [], []);
  }
  constructor(e, t, i, n, s, o, l) {
    this.type = e, this.value = t, this.from = i, this.hash = n, this.end = s, this.children = o, this.positions = l, this.hashProp = [[j.contextHash, n]];
  }
  addChild(e, t) {
    e.prop(j.contextHash) != this.hash && (e = new te(e.type, e.children, e.positions, e.length, this.hashProp)), this.children.push(e), this.positions.push(t);
  }
  toTree(e, t = this.end) {
    let i = this.children.length - 1;
    return i >= 0 && (t = Math.max(t, this.positions[i] + this.children[i].length + this.from)), new te(e.types[this.type], this.children, this.positions, t - this.from).balance({
      makeTree: (n, s, o) => new te(Se.none, n, s, o, this.hashProp)
    });
  }
}
var C;
(function(r) {
  r[r.Document = 1] = "Document", r[r.CodeBlock = 2] = "CodeBlock", r[r.FencedCode = 3] = "FencedCode", r[r.Blockquote = 4] = "Blockquote", r[r.HorizontalRule = 5] = "HorizontalRule", r[r.BulletList = 6] = "BulletList", r[r.OrderedList = 7] = "OrderedList", r[r.ListItem = 8] = "ListItem", r[r.ATXHeading1 = 9] = "ATXHeading1", r[r.ATXHeading2 = 10] = "ATXHeading2", r[r.ATXHeading3 = 11] = "ATXHeading3", r[r.ATXHeading4 = 12] = "ATXHeading4", r[r.ATXHeading5 = 13] = "ATXHeading5", r[r.ATXHeading6 = 14] = "ATXHeading6", r[r.SetextHeading1 = 15] = "SetextHeading1", r[r.SetextHeading2 = 16] = "SetextHeading2", r[r.HTMLBlock = 17] = "HTMLBlock", r[r.LinkReference = 18] = "LinkReference", r[r.Paragraph = 19] = "Paragraph", r[r.CommentBlock = 20] = "CommentBlock", r[r.ProcessingInstructionBlock = 21] = "ProcessingInstructionBlock", r[r.Escape = 22] = "Escape", r[r.Entity = 23] = "Entity", r[r.HardBreak = 24] = "HardBreak", r[r.Emphasis = 25] = "Emphasis", r[r.StrongEmphasis = 26] = "StrongEmphasis", r[r.Link = 27] = "Link", r[r.Image = 28] = "Image", r[r.InlineCode = 29] = "InlineCode", r[r.HTMLTag = 30] = "HTMLTag", r[r.Comment = 31] = "Comment", r[r.ProcessingInstruction = 32] = "ProcessingInstruction", r[r.Autolink = 33] = "Autolink", r[r.HeaderMark = 34] = "HeaderMark", r[r.QuoteMark = 35] = "QuoteMark", r[r.ListMark = 36] = "ListMark", r[r.LinkMark = 37] = "LinkMark", r[r.EmphasisMark = 38] = "EmphasisMark", r[r.CodeMark = 39] = "CodeMark", r[r.CodeText = 40] = "CodeText", r[r.CodeInfo = 41] = "CodeInfo", r[r.LinkTitle = 42] = "LinkTitle", r[r.LinkLabel = 43] = "LinkLabel", r[r.URL = 44] = "URL";
})(C || (C = {}));
class Bk {
  /**
  @internal
  */
  constructor(e, t) {
    this.start = e, this.content = t, this.marks = [], this.parsers = [];
  }
}
class Ik {
  constructor() {
    this.text = "", this.baseIndent = 0, this.basePos = 0, this.depth = 0, this.markers = [], this.pos = 0, this.indent = 0, this.next = -1;
  }
  /**
  @internal
  */
  forward() {
    this.basePos > this.pos && this.forwardInner();
  }
  /**
  @internal
  */
  forwardInner() {
    let e = this.skipSpace(this.basePos);
    this.indent = this.countIndent(e, this.pos, this.indent), this.pos = e, this.next = e == this.text.length ? -1 : this.text.charCodeAt(e);
  }
  /**
  Skip whitespace after the given position, return the position of
  the next non-space character or the end of the line if there's
  only space after `from`.
  */
  skipSpace(e) {
    return Lr(this.text, e);
  }
  /**
  @internal
  */
  reset(e) {
    for (this.text = e, this.baseIndent = this.basePos = this.pos = this.indent = 0, this.forwardInner(), this.depth = 1; this.markers.length; )
      this.markers.pop();
  }
  /**
  Move the line's base position forward to the given position.
  This should only be called by composite [block
  parsers](#BlockParser.parse) or [markup skipping
  functions](#NodeSpec.composite).
  */
  moveBase(e) {
    this.basePos = e, this.baseIndent = this.countIndent(e, this.pos, this.indent);
  }
  /**
  Move the line's base position forward to the given _column_.
  */
  moveBaseColumn(e) {
    this.baseIndent = e, this.basePos = this.findColumn(e);
  }
  /**
  Store a composite-block-level marker. Should be called from
  [markup skipping functions](#NodeSpec.composite) when they
  consume any non-whitespace characters.
  */
  addMarker(e) {
    this.markers.push(e);
  }
  /**
  Find the column position at `to`, optionally starting at a given
  position and column.
  */
  countIndent(e, t = 0, i = 0) {
    for (let n = t; n < e; n++)
      i += this.text.charCodeAt(n) == 9 ? 4 - i % 4 : 1;
    return i;
  }
  /**
  Find the position corresponding to the given column.
  */
  findColumn(e) {
    let t = 0;
    for (let i = 0; t < this.text.length && i < e; t++)
      i += this.text.charCodeAt(t) == 9 ? 4 - i % 4 : 1;
    return t;
  }
  /**
  @internal
  */
  scrub() {
    if (!this.baseIndent)
      return this.text;
    let e = "";
    for (let t = 0; t < this.basePos; t++)
      e += " ";
    return e + this.text.slice(this.basePos);
  }
}
function Ff(r, e, t) {
  if (t.pos == t.text.length || r != e.block && t.indent >= e.stack[t.depth + 1].value + t.baseIndent)
    return !0;
  if (t.indent >= t.baseIndent + 4)
    return !1;
  let i = (r.type == C.OrderedList ? Th : Ch)(t, e, !1);
  return i > 0 && (r.type != C.BulletList || Ph(t, e, !1) < 0) && t.text.charCodeAt(t.pos + i - 1) == r.value;
}
const dm = {
  [C.Blockquote](r, e, t) {
    return t.next != 62 ? !1 : (t.markers.push(F(C.QuoteMark, e.lineStart + t.pos, e.lineStart + t.pos + 1)), t.moveBase(t.pos + (st(t.text.charCodeAt(t.pos + 1)) ? 2 : 1)), r.end = e.lineStart + t.text.length, !0);
  },
  [C.ListItem](r, e, t) {
    return t.indent < t.baseIndent + r.value && t.next > -1 ? !1 : (t.moveBaseColumn(t.baseIndent + r.value), !0);
  },
  [C.OrderedList]: Ff,
  [C.BulletList]: Ff,
  [C.Document]() {
    return !0;
  }
};
function st(r) {
  return r == 32 || r == 9 || r == 10 || r == 13;
}
function Lr(r, e = 0) {
  for (; e < r.length && st(r.charCodeAt(e)); )
    e++;
  return e;
}
function Hf(r, e, t) {
  for (; e > t && st(r.charCodeAt(e - 1)); )
    e--;
  return e;
}
function pm(r) {
  if (r.next != 96 && r.next != 126)
    return -1;
  let e = r.pos + 1;
  for (; e < r.text.length && r.text.charCodeAt(e) == r.next; )
    e++;
  if (e < r.pos + 3)
    return -1;
  if (r.next == 96) {
    for (let t = e; t < r.text.length; t++)
      if (r.text.charCodeAt(t) == 96)
        return -1;
  }
  return e;
}
function Om(r) {
  return r.next != 62 ? -1 : r.text.charCodeAt(r.pos + 1) == 32 ? 2 : 1;
}
function Ph(r, e, t) {
  if (r.next != 42 && r.next != 45 && r.next != 95)
    return -1;
  let i = 1;
  for (let n = r.pos + 1; n < r.text.length; n++) {
    let s = r.text.charCodeAt(n);
    if (s == r.next)
      i++;
    else if (!st(s))
      return -1;
  }
  return t && r.next == 45 && bm(r) > -1 && r.depth == e.stack.length && e.parser.leafBlockParsers.indexOf(xm.SetextHeading) > -1 || i < 3 ? -1 : 1;
}
function mm(r, e) {
  for (let t = r.stack.length - 1; t >= 0; t--)
    if (r.stack[t].type == e)
      return !0;
  return !1;
}
function Ch(r, e, t) {
  return (r.next == 45 || r.next == 43 || r.next == 42) && (r.pos == r.text.length - 1 || st(r.text.charCodeAt(r.pos + 1))) && (!t || mm(e, C.BulletList) || r.skipSpace(r.pos + 2) < r.text.length) ? 1 : -1;
}
function Th(r, e, t) {
  let i = r.pos, n = r.next;
  for (; n >= 48 && n <= 57; ) {
    i++;
    if (i == r.text.length)
      return -1;
    n = r.text.charCodeAt(i);
  }
  return i == r.pos || i > r.pos + 9 || n != 46 && n != 41 || i < r.text.length - 1 && !st(r.text.charCodeAt(i + 1)) || t && !mm(e, C.OrderedList) && (r.skipSpace(i + 1) == r.text.length || i > r.pos + 1 || r.next != 49) ? -1 : i + 1 - r.pos;
}
function gm(r) {
  if (r.next != 35)
    return -1;
  let e = r.pos + 1;
  for (; e < r.text.length && r.text.charCodeAt(e) == 35; )
    e++;
  if (e < r.text.length && r.text.charCodeAt(e) != 32)
    return -1;
  let t = e - r.pos;
  return t > 6 ? -1 : t;
}
function bm(r) {
  if (r.next != 45 && r.next != 61 || r.indent >= r.baseIndent + 4)
    return -1;
  let e = r.pos + 1;
  for (; e < r.text.length && r.text.charCodeAt(e) == r.next; )
    e++;
  let t = e;
  for (; e < r.text.length && st(r.text.charCodeAt(e)); )
    e++;
  return e == r.text.length ? t : -1;
}
const Ca = /^[ \t]*$/, ym = /-->/, Sm = /\?>/, Ta = [
  [/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
  [/^\s*<!--/, ym],
  [/^\s*<\?/, Sm],
  [/^\s*<![A-Z]/, />/],
  [/^\s*<!\[CDATA\[/, /\]\]>/],
  [/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i, Ca],
  [/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, Ca]
];
function wm(r, e, t) {
  if (r.next != 60)
    return -1;
  let i = r.text.slice(r.pos);
  for (let n = 0, s = Ta.length - (t ? 1 : 0); n < s; n++)
    if (Ta[n][0].test(i))
      return n;
  return -1;
}
function Kf(r, e) {
  let t = r.countIndent(e, r.pos, r.indent), i = r.countIndent(r.skipSpace(e), e, t);
  return i >= t + 5 ? t + 1 : i;
}
function gi(r, e, t) {
  let i = r.length - 1;
  i >= 0 && r[i].to == e && r[i].type == C.CodeText ? r[i].to = t : r.push(F(C.CodeText, e, t));
}
const Gn = {
  LinkReference: void 0,
  IndentedCode(r, e) {
    let t = e.baseIndent + 4;
    if (e.indent < t)
      return !1;
    let i = e.findColumn(t), n = r.lineStart + i, s = r.lineStart + e.text.length, o = [], l = [];
    for (gi(o, n, s); r.nextLine() && e.depth >= r.stack.length; )
      if (e.pos == e.text.length) {
        gi(l, r.lineStart - 1, r.lineStart);
        for (let a of e.markers)
          l.push(a);
      } else {
        if (e.indent < t)
          break;
        {
          if (l.length) {
            for (let h of l)
              h.type == C.CodeText ? gi(o, h.from, h.to) : o.push(h);
            l = [];
          }
          gi(o, r.lineStart - 1, r.lineStart);
          for (let h of e.markers)
            o.push(h);
          s = r.lineStart + e.text.length;
          let a = r.lineStart + e.findColumn(e.baseIndent + 4);
          a < s && gi(o, a, s);
        }
      }
    return l.length && (l = l.filter((a) => a.type != C.CodeText), l.length && (e.markers = l.concat(e.markers))), r.addNode(r.buffer.writeElements(o, -n).finish(C.CodeBlock, s - n), n), !0;
  },
  FencedCode(r, e) {
    let t = pm(e);
    if (t < 0)
      return !1;
    let i = r.lineStart + e.pos, n = e.next, s = t - e.pos, o = e.skipSpace(t), l = Hf(e.text, e.text.length, o), a = [F(C.CodeMark, i, i + s)];
    o < l && a.push(F(C.CodeInfo, r.lineStart + o, r.lineStart + l));
    for (let h = !0; r.nextLine() && e.depth >= r.stack.length; h = !1) {
      let c = e.pos;
      if (e.indent - e.baseIndent < 4)
        for (; c < e.text.length && e.text.charCodeAt(c) == n; )
          c++;
      if (c - e.pos >= s && e.skipSpace(c) == e.text.length) {
        for (let f of e.markers)
          a.push(f);
        a.push(F(C.CodeMark, r.lineStart + e.pos, r.lineStart + c)), r.nextLine();
        break;
      } else {
        h || gi(a, r.lineStart - 1, r.lineStart);
        for (let d of e.markers)
          a.push(d);
        let f = r.lineStart + e.basePos, u = r.lineStart + e.text.length;
        f < u && gi(a, f, u);
      }
    }
    return r.addNode(r.buffer.writeElements(a, -i).finish(C.FencedCode, r.prevLineEnd() - i), i), !0;
  },
  Blockquote(r, e) {
    let t = Om(e);
    return t < 0 ? !1 : (r.startContext(C.Blockquote, e.pos), r.addNode(C.QuoteMark, r.lineStart + e.pos, r.lineStart + e.pos + 1), e.moveBase(e.pos + t), null);
  },
  HorizontalRule(r, e) {
    if (Ph(e, r, !1) < 0)
      return !1;
    let t = r.lineStart + e.pos;
    return r.nextLine(), r.addNode(C.HorizontalRule, t), !0;
  },
  BulletList(r, e) {
    let t = Ch(e, r, !1);
    if (t < 0)
      return !1;
    r.block.type != C.BulletList && r.startContext(C.BulletList, e.basePos, e.next);
    let i = Kf(e, e.pos + 1);
    return r.startContext(C.ListItem, e.basePos, i - e.baseIndent), r.addNode(C.ListMark, r.lineStart + e.pos, r.lineStart + e.pos + t), e.moveBaseColumn(i), null;
  },
  OrderedList(r, e) {
    let t = Th(e, r, !1);
    if (t < 0)
      return !1;
    r.block.type != C.OrderedList && r.startContext(C.OrderedList, e.basePos, e.text.charCodeAt(e.pos + t - 1));
    let i = Kf(e, e.pos + t);
    return r.startContext(C.ListItem, e.basePos, i - e.baseIndent), r.addNode(C.ListMark, r.lineStart + e.pos, r.lineStart + e.pos + t), e.moveBaseColumn(i), null;
  },
  ATXHeading(r, e) {
    let t = gm(e);
    if (t < 0)
      return !1;
    let i = e.pos, n = r.lineStart + i, s = Hf(e.text, e.text.length, i), o = s;
    for (; o > i && e.text.charCodeAt(o - 1) == e.next; )
      o--;
    (o == s || o == i || !st(e.text.charCodeAt(o - 1))) && (o = e.text.length);
    let l = r.buffer.write(C.HeaderMark, 0, t).writeElements(r.parser.parseInline(e.text.slice(i + t + 1, o), n + t + 1), -n);
    o < e.text.length && l.write(C.HeaderMark, o - i, s - i);
    let a = l.finish(C.ATXHeading1 - 1 + t, e.text.length - i);
    return r.nextLine(), r.addNode(a, n), !0;
  },
  HTMLBlock(r, e) {
    let t = wm(e, r, !1);
    if (t < 0)
      return !1;
    let i = r.lineStart + e.pos, n = Ta[t][1], s = [], o = n != Ca;
    for (; !n.test(e.text) && r.nextLine(); ) {
      if (e.depth < r.stack.length) {
        o = !1;
        break;
      }
      for (let h of e.markers)
        s.push(h);
    }
    o && r.nextLine();
    let l = n == ym ? C.CommentBlock : n == Sm ? C.ProcessingInstructionBlock : C.HTMLBlock, a = r.prevLineEnd();
    return r.addNode(r.buffer.writeElements(s, -i).finish(l, a - i), i), !0;
  },
  SetextHeading: void 0
  // Specifies relative precedence for block-continue function
};
class Vk {
  constructor(e) {
    this.stage = 0, this.elts = [], this.pos = 0, this.start = e.start, this.advance(e.content);
  }
  nextLine(e, t, i) {
    if (this.stage == -1)
      return !1;
    let n = i.content + `
` + t.scrub(), s = this.advance(n);
    return s > -1 && s < n.length ? this.complete(e, i, s) : !1;
  }
  finish(e, t) {
    return (this.stage == 2 || this.stage == 3) && Lr(t.content, this.pos) == t.content.length ? this.complete(e, t, t.content.length) : !1;
  }
  complete(e, t, i) {
    return e.addLeafElement(t, F(C.LinkReference, this.start, this.start + i, this.elts)), !0;
  }
  nextStage(e) {
    return e ? (this.pos = e.to - this.start, this.elts.push(e), this.stage++, !0) : (e === !1 && (this.stage = -1), !1);
  }
  advance(e) {
    for (; ; ) {
      if (this.stage == -1)
        return -1;
      if (this.stage == 0) {
        if (!this.nextStage(Mm(e, this.pos, this.start, !0)))
          return -1;
        if (e.charCodeAt(this.pos) != 58)
          return this.stage = -1;
        this.elts.push(F(C.LinkMark, this.pos + this.start, this.pos + this.start + 1)), this.pos++;
      } else if (this.stage == 1) {
        if (!this.nextStage(Tm(e, Lr(e, this.pos), this.start)))
          return -1;
      } else if (this.stage == 2) {
        let t = Lr(e, this.pos), i = 0;
        if (t > this.pos) {
          let n = Am(e, t, this.start);
          if (n) {
            let s = tl(e, n.to - this.start);
            s > 0 && (this.nextStage(n), i = s);
          }
        }
        return i || (i = tl(e, this.pos)), i > 0 && i < e.length ? i : -1;
      } else
        return tl(e, this.pos);
    }
  }
}
function tl(r, e) {
  for (; e < r.length; e++) {
    let t = r.charCodeAt(e);
    if (t == 10)
      break;
    if (!st(t))
      return -1;
  }
  return e;
}
class qk {
  nextLine(e, t, i) {
    let n = t.depth < e.stack.length ? -1 : bm(t), s = t.next;
    if (n < 0)
      return !1;
    let o = F(C.HeaderMark, e.lineStart + t.pos, e.lineStart + n);
    return e.nextLine(), e.addLeafElement(i, F(s == 61 ? C.SetextHeading1 : C.SetextHeading2, i.start, e.prevLineEnd(), [
      ...e.parser.parseInline(i.content, i.start),
      o
    ])), !0;
  }
  finish() {
    return !1;
  }
}
const xm = {
  LinkReference(r, e) {
    return e.content.charCodeAt(0) == 91 ? new Vk(e) : null;
  },
  SetextHeading() {
    return new qk();
  }
}, Yk = [
  (r, e) => gm(e) >= 0,
  (r, e) => pm(e) >= 0,
  (r, e) => Om(e) >= 0,
  (r, e) => Ch(e, r, !0) >= 0,
  (r, e) => Th(e, r, !0) >= 0,
  (r, e) => Ph(e, r, !0) >= 0,
  (r, e) => wm(e, r, !0) >= 0
], Nk = { text: "", end: 0 };
class Wk {
  /**
  @internal
  */
  constructor(e, t, i, n) {
    this.parser = e, this.input = t, this.ranges = n, this.line = new Ik(), this.atEnd = !1, this.reusePlaceholders = /* @__PURE__ */ new Map(), this.stoppedAt = null, this.rangeI = 0, this.to = n[n.length - 1].to, this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = n[0].from, this.block = Ns.create(C.Document, 0, this.lineStart, 0, 0), this.stack = [this.block], this.fragments = i.length ? new Uk(i, t) : null, this.readLine();
  }
  get parsedPos() {
    return this.absoluteLineStart;
  }
  advance() {
    if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt)
      return this.finish();
    let { line: e } = this;
    for (; ; ) {
      for (let i = 0; ; ) {
        let n = e.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
        for (; i < e.markers.length && (!n || e.markers[i].from < n.end); ) {
          let s = e.markers[i++];
          this.addNode(s.type, s.from, s.to);
        }
        if (!n)
          break;
        this.finishContext();
      }
      if (e.pos < e.text.length)
        break;
      if (!this.nextLine())
        return this.finish();
    }
    if (this.fragments && this.reuseFragment(e.basePos))
      return null;
    e: for (; ; ) {
      for (let i of this.parser.blockParsers)
        if (i) {
          let n = i(this, e);
          if (n != !1) {
            if (n == !0)
              return null;
            e.forward();
            continue e;
          }
        }
      break;
    }
    let t = new Bk(this.lineStart + e.pos, e.text.slice(e.pos));
    for (let i of this.parser.leafBlockParsers)
      if (i) {
        let n = i(this, t);
        n && t.parsers.push(n);
      }
    e: for (; this.nextLine() && e.pos != e.text.length; ) {
      if (e.indent < e.baseIndent + 4) {
        for (let i of this.parser.endLeafBlock)
          if (i(this, e, t))
            break e;
      }
      for (let i of t.parsers)
        if (i.nextLine(this, e, t))
          return null;
      t.content += `
` + e.scrub();
      for (let i of e.markers)
        t.marks.push(i);
    }
    return this.finishLeaf(t), null;
  }
  stopAt(e) {
    if (this.stoppedAt != null && this.stoppedAt < e)
      throw new RangeError("Can't move stoppedAt forward");
    this.stoppedAt = e;
  }
  reuseFragment(e) {
    if (!this.fragments.moveTo(this.absoluteLineStart + e, this.absoluteLineStart) || !this.fragments.matches(this.block.hash))
      return !1;
    let t = this.fragments.takeNodes(this);
    return t ? (this.absoluteLineStart += t, this.lineStart = Zm(this.absoluteLineStart, this.ranges), this.moveRangeI(), this.absoluteLineStart < this.to ? (this.lineStart++, this.absoluteLineStart++, this.readLine()) : (this.atEnd = !0, this.readLine()), !0) : !1;
  }
  /**
  The number of parent blocks surrounding the current block.
  */
  get depth() {
    return this.stack.length;
  }
  /**
  Get the type of the parent block at the given depth. When no
  depth is passed, return the type of the innermost parent.
  */
  parentType(e = this.depth - 1) {
    return this.parser.nodeSet.types[this.stack[e].type];
  }
  /**
  Move to the next input line. This should only be called by
  (non-composite) [block parsers](#BlockParser.parse) that consume
  the line directly, or leaf block parser
  [`nextLine`](#LeafBlockParser.nextLine) methods when they
  consume the current line (and return true).
  */
  nextLine() {
    return this.lineStart += this.line.text.length, this.absoluteLineEnd >= this.to ? (this.absoluteLineStart = this.absoluteLineEnd, this.atEnd = !0, this.readLine(), !1) : (this.lineStart++, this.absoluteLineStart = this.absoluteLineEnd + 1, this.moveRangeI(), this.readLine(), !0);
  }
  /**
  Retrieve the text of the line after the current one, without
  actually moving the context's current line forward.
  */
  peekLine() {
    return this.scanLine(this.absoluteLineEnd + 1).text;
  }
  moveRangeI() {
    for (; this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to; )
      this.rangeI++, this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
  }
  /**
  @internal
  Collect the text for the next line.
  */
  scanLine(e) {
    let t = Nk;
    if (t.end = e, e >= this.to)
      t.text = "";
    else if (t.text = this.lineChunkAt(e), t.end += t.text.length, this.ranges.length > 1) {
      let i = this.absoluteLineStart, n = this.rangeI;
      for (; this.ranges[n].to < t.end; ) {
        n++;
        let s = this.ranges[n].from, o = this.lineChunkAt(s);
        t.end = s + o.length, t.text = t.text.slice(0, this.ranges[n - 1].to - i) + o, i = t.end - t.text.length;
      }
    }
    return t;
  }
  /**
  @internal
  Populate this.line with the content of the next line. Skip
  leading characters covered by composite blocks.
  */
  readLine() {
    let { line: e } = this, { text: t, end: i } = this.scanLine(this.absoluteLineStart);
    for (this.absoluteLineEnd = i, e.reset(t); e.depth < this.stack.length; e.depth++) {
      let n = this.stack[e.depth], s = this.parser.skipContextMarkup[n.type];
      if (!s)
        throw new Error("Unhandled block context " + C[n.type]);
      let o = this.line.markers.length;
      if (!s(n, this, e)) {
        this.line.markers.length > o && (n.end = this.line.markers[this.line.markers.length - 1].to);
        break;
      }
      e.forward();
    }
  }
  lineChunkAt(e) {
    let t = this.input.chunk(e), i;
    if (this.input.lineChunks)
      i = t == `
` ? "" : t;
    else {
      let n = t.indexOf(`
`);
      i = n < 0 ? t : t.slice(0, n);
    }
    return e + i.length > this.to ? i.slice(0, this.to - e) : i;
  }
  /**
  The end position of the previous line.
  */
  prevLineEnd() {
    return this.atEnd ? this.lineStart : this.lineStart - 1;
  }
  /**
  @internal
  */
  startContext(e, t, i = 0) {
    this.block = Ns.create(e, i, this.lineStart + t, this.block.hash, this.lineStart + this.line.text.length), this.stack.push(this.block);
  }
  /**
  Start a composite block. Should only be called from [block
  parser functions](#BlockParser.parse) that return null.
  */
  startComposite(e, t, i = 0) {
    this.startContext(this.parser.getNodeType(e), t, i);
  }
  /**
  @internal
  */
  addNode(e, t, i) {
    typeof e == "number" && (e = new te(this.parser.nodeSet.types[e], er, er, (i ?? this.prevLineEnd()) - t)), this.block.addChild(e, t - this.block.from);
  }
  /**
  Add a block element. Can be called by [block
  parsers](#BlockParser.parse).
  */
  addElement(e) {
    this.block.addChild(e.toTree(this.parser.nodeSet), e.from - this.block.from);
  }
  /**
  Add a block element from a [leaf parser](#LeafBlockParser). This
  makes sure any extra composite block markup (such as blockquote
  markers) inside the block are also added to the syntax tree.
  */
  addLeafElement(e, t) {
    this.addNode(this.buffer.writeElements(Ma(t.children, e.marks), -t.from).finish(t.type, t.to - t.from), t.from);
  }
  /**
  @internal
  */
  finishContext() {
    let e = this.stack.pop(), t = this.stack[this.stack.length - 1];
    t.addChild(e.toTree(this.parser.nodeSet), e.from - t.from), this.block = t;
  }
  finish() {
    for (; this.stack.length > 1; )
      this.finishContext();
    return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
  }
  addGaps(e) {
    return this.ranges.length > 1 ? km(this.ranges, 0, e.topNode, this.ranges[0].from, this.reusePlaceholders) : e;
  }
  /**
  @internal
  */
  finishLeaf(e) {
    for (let i of e.parsers)
      if (i.finish(this, e))
        return;
    let t = Ma(this.parser.parseInline(e.content, e.start), e.marks);
    this.addNode(this.buffer.writeElements(t, -e.start).finish(C.Paragraph, e.content.length), e.start);
  }
  elt(e, t, i, n) {
    return typeof e == "string" ? F(this.parser.getNodeType(e), t, i, n) : new $m(e, t);
  }
  /**
  @internal
  */
  get buffer() {
    return new vm(this.parser.nodeSet);
  }
}
function km(r, e, t, i, n) {
  let s = r[e].to, o = [], l = [], a = t.from + i;
  function h(c, f) {
    for (; f ? c >= s : c > s; ) {
      let u = r[e + 1].from - s;
      i += u, c += u, e++, s = r[e].to;
    }
  }
  for (let c = t.firstChild; c; c = c.nextSibling) {
    h(c.from + i, !0);
    let f = c.from + i, u, d = n.get(c.tree);
    d ? u = d : c.to + i > s ? (u = km(r, e, c, i, n), h(c.to + i, !1)) : u = c.toTree(), o.push(u), l.push(f - a);
  }
  return h(t.to + i, !1), new te(t.type, o, l, t.to + i - a, t.tree ? t.tree.propValues : void 0);
}
class yo extends wh {
  /**
  @internal
  */
  constructor(e, t, i, n, s, o, l, a, h) {
    super(), this.nodeSet = e, this.blockParsers = t, this.leafBlockParsers = i, this.blockNames = n, this.endLeafBlock = s, this.skipContextMarkup = o, this.inlineParsers = l, this.inlineNames = a, this.wrappers = h, this.nodeTypes = /* @__PURE__ */ Object.create(null);
    for (let c of e.types)
      this.nodeTypes[c.name] = c.id;
  }
  createParse(e, t, i) {
    let n = new Wk(this, e, t, i);
    for (let s of this.wrappers)
      n = s(n, e, t, i);
    return n;
  }
  /**
  Reconfigure the parser.
  */
  configure(e) {
    let t = Aa(e);
    if (!t)
      return this;
    let { nodeSet: i, skipContextMarkup: n } = this, s = this.blockParsers.slice(), o = this.leafBlockParsers.slice(), l = this.blockNames.slice(), a = this.inlineParsers.slice(), h = this.inlineNames.slice(), c = this.endLeafBlock.slice(), f = this.wrappers;
    if (gr(t.defineNodes)) {
      n = Object.assign({}, n);
      let u = i.types.slice(), d;
      for (let p of t.defineNodes) {
        let { name: O, block: g, composite: b, style: w } = typeof p == "string" ? { name: p } : p;
        if (u.some((S) => S.name == O))
          continue;
        b && (n[u.length] = (S, y, Q) => b(y, Q, S.value));
        let k = u.length, x = b ? ["Block", "BlockContext"] : g ? k >= C.ATXHeading1 && k <= C.SetextHeading2 ? ["Block", "LeafBlock", "Heading"] : ["Block", "LeafBlock"] : void 0;
        u.push(Se.define({
          id: k,
          name: O,
          props: x && [[j.group, x]]
        })), w && (d || (d = {}), Array.isArray(w) || w instanceof Ne ? d[O] = w : Object.assign(d, w));
      }
      i = new pn(u), d && (i = i.extend(sr(d)));
    }
    if (gr(t.props) && (i = i.extend(...t.props)), gr(t.remove))
      for (let u of t.remove) {
        let d = this.blockNames.indexOf(u), p = this.inlineNames.indexOf(u);
        d > -1 && (s[d] = o[d] = void 0), p > -1 && (a[p] = void 0);
      }
    if (gr(t.parseBlock))
      for (let u of t.parseBlock) {
        let d = l.indexOf(u.name);
        if (d > -1)
          s[d] = u.parse, o[d] = u.leaf;
        else {
          let p = u.before ? Un(l, u.before) : u.after ? Un(l, u.after) + 1 : l.length - 1;
          s.splice(p, 0, u.parse), o.splice(p, 0, u.leaf), l.splice(p, 0, u.name);
        }
        u.endLeaf && c.push(u.endLeaf);
      }
    if (gr(t.parseInline))
      for (let u of t.parseInline) {
        let d = h.indexOf(u.name);
        if (d > -1)
          a[d] = u.parse;
        else {
          let p = u.before ? Un(h, u.before) : u.after ? Un(h, u.after) + 1 : h.length - 1;
          a.splice(p, 0, u.parse), h.splice(p, 0, u.name);
        }
      }
    return t.wrap && (f = f.concat(t.wrap)), new yo(i, s, o, l, c, n, a, h, f);
  }
  /**
  @internal
  */
  getNodeType(e) {
    let t = this.nodeTypes[e];
    if (t == null)
      throw new RangeError(`Unknown node type '${e}'`);
    return t;
  }
  /**
  Parse the given piece of inline text at the given offset,
  returning an array of [`Element`](#Element) objects representing
  the inline content.
  */
  parseInline(e, t) {
    let i = new Ah(this, e, t);
    e: for (let n = t; n < i.end; ) {
      let s = i.char(n);
      for (let o of this.inlineParsers)
        if (o) {
          let l = o(i, s, n);
          if (l >= 0) {
            n = l;
            continue e;
          }
        }
      n++;
    }
    return i.resolveMarkers(0);
  }
}
function gr(r) {
  return r != null && r.length > 0;
}
function Aa(r) {
  if (!Array.isArray(r))
    return r;
  if (r.length == 0)
    return null;
  let e = Aa(r[0]);
  if (r.length == 1)
    return e;
  let t = Aa(r.slice(1));
  if (!t || !e)
    return e || t;
  let i = (o, l) => (o || er).concat(l || er), n = e.wrap, s = t.wrap;
  return {
    props: i(e.props, t.props),
    defineNodes: i(e.defineNodes, t.defineNodes),
    parseBlock: i(e.parseBlock, t.parseBlock),
    parseInline: i(e.parseInline, t.parseInline),
    remove: i(e.remove, t.remove),
    wrap: n ? s ? (o, l, a, h) => n(s(o, l, a, h), l, a, h) : n : s
  };
}
function Un(r, e) {
  let t = r.indexOf(e);
  if (t < 0)
    throw new RangeError(`Position specified relative to unknown parser ${e}`);
  return t;
}
let Qm = [Se.none];
for (let r = 1, e; e = C[r]; r++)
  Qm[r] = Se.define({
    id: r,
    name: e,
    props: r >= C.Escape ? [] : [[j.group, r in dm ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
    top: e == "Document"
  });
const er = [];
class vm {
  constructor(e) {
    this.nodeSet = e, this.content = [], this.nodes = [];
  }
  write(e, t, i, n = 0) {
    return this.content.push(e, t, i, 4 + n * 4), this;
  }
  writeElements(e, t = 0) {
    for (let i of e)
      i.writeTo(this, t);
    return this;
  }
  finish(e, t) {
    return te.build({
      buffer: this.content,
      nodeSet: this.nodeSet,
      reused: this.nodes,
      topID: e,
      length: t
    });
  }
}
let tn = class {
  /**
  @internal
  */
  constructor(e, t, i, n = er) {
    this.type = e, this.from = t, this.to = i, this.children = n;
  }
  /**
  @internal
  */
  writeTo(e, t) {
    let i = e.content.length;
    e.writeElements(this.children, t), e.content.push(this.type, this.from + t, this.to + t, e.content.length + 4 - i);
  }
  /**
  @internal
  */
  toTree(e) {
    return new vm(e).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
  }
};
class $m {
  constructor(e, t) {
    this.tree = e, this.from = t;
  }
  get to() {
    return this.from + this.tree.length;
  }
  get type() {
    return this.tree.type.id;
  }
  get children() {
    return er;
  }
  writeTo(e, t) {
    e.nodes.push(this.tree), e.content.push(e.nodes.length - 1, this.from + t, this.to + t, -1);
  }
  toTree() {
    return this.tree;
  }
}
function F(r, e, t, i) {
  return new tn(r, e, t, i);
}
const Pm = { resolve: "Emphasis", mark: "EmphasisMark" }, Cm = { resolve: "Emphasis", mark: "EmphasisMark" }, wi = {}, Ws = {};
class Ye {
  constructor(e, t, i, n) {
    this.type = e, this.from = t, this.to = i, this.side = n;
  }
}
const Jf = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
let rn = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
try {
  rn = new RegExp("[\\p{S}|\\p{P}]", "u");
} catch {
}
const il = {
  Escape(r, e, t) {
    if (e != 92 || t == r.end - 1)
      return -1;
    let i = r.char(t + 1);
    for (let n = 0; n < Jf.length; n++)
      if (Jf.charCodeAt(n) == i)
        return r.append(F(C.Escape, t, t + 2));
    return -1;
  },
  Entity(r, e, t) {
    if (e != 38)
      return -1;
    let i = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(r.slice(t + 1, t + 31));
    return i ? r.append(F(C.Entity, t, t + 1 + i[0].length)) : -1;
  },
  InlineCode(r, e, t) {
    if (e != 96 || t && r.char(t - 1) == 96)
      return -1;
    let i = t + 1;
    for (; i < r.end && r.char(i) == 96; )
      i++;
    let n = i - t, s = 0;
    for (; i < r.end; i++)
      if (r.char(i) == 96) {
        if (s++, s == n && r.char(i + 1) != 96)
          return r.append(F(C.InlineCode, t, i + 1, [
            F(C.CodeMark, t, t + n),
            F(C.CodeMark, i + 1 - n, i + 1)
          ]));
      } else
        s = 0;
    return -1;
  },
  HTMLTag(r, e, t) {
    if (e != 60 || t == r.end - 1)
      return -1;
    let i = r.slice(t + 1, r.end), n = /^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);
    if (n)
      return r.append(F(C.Autolink, t, t + 1 + n[0].length, [
        F(C.LinkMark, t, t + 1),
        // url[0] includes the closing bracket, so exclude it from this slice
        F(C.URL, t + 1, t + n[0].length),
        F(C.LinkMark, t + n[0].length, t + 1 + n[0].length)
      ]));
    let s = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);
    if (s)
      return r.append(F(C.Comment, t, t + 1 + s[0].length));
    let o = /^\?[^]*?\?>/.exec(i);
    if (o)
      return r.append(F(C.ProcessingInstruction, t, t + 1 + o[0].length));
    let l = /^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);
    return l ? r.append(F(C.HTMLTag, t, t + 1 + l[0].length)) : -1;
  },
  Emphasis(r, e, t) {
    if (e != 95 && e != 42)
      return -1;
    let i = t + 1;
    for (; r.char(i) == e; )
      i++;
    let n = r.slice(t - 1, t), s = r.slice(i, i + 1), o = rn.test(n), l = rn.test(s), a = /\s|^$/.test(n), h = /\s|^$/.test(s), c = !h && (!l || a || o), f = !a && (!o || h || l), u = c && (e == 42 || !f || o), d = f && (e == 42 || !c || l);
    return r.append(new Ye(e == 95 ? Pm : Cm, t, i, (u ? 1 : 0) | (d ? 2 : 0)));
  },
  HardBreak(r, e, t) {
    if (e == 92 && r.char(t + 1) == 10)
      return r.append(F(C.HardBreak, t, t + 2));
    if (e == 32) {
      let i = t + 1;
      for (; r.char(i) == 32; )
        i++;
      if (r.char(i) == 10 && i >= t + 2)
        return r.append(F(C.HardBreak, t, i + 1));
    }
    return -1;
  },
  Link(r, e, t) {
    return e == 91 ? r.append(new Ye(
      wi,
      t,
      t + 1,
      1
      /* Mark.Open */
    )) : -1;
  },
  Image(r, e, t) {
    return e == 33 && r.char(t + 1) == 91 ? r.append(new Ye(
      Ws,
      t,
      t + 2,
      1
      /* Mark.Open */
    )) : -1;
  },
  LinkEnd(r, e, t) {
    if (e != 93)
      return -1;
    for (let i = r.parts.length - 1; i >= 0; i--) {
      let n = r.parts[i];
      if (n instanceof Ye && (n.type == wi || n.type == Ws)) {
        if (!n.side || r.skipSpace(n.to) == t && !/[(\[]/.test(r.slice(t + 1, t + 2)))
          return r.parts[i] = null, -1;
        let s = r.takeContent(i), o = r.parts[i] = jk(r, s, n.type == wi ? C.Link : C.Image, n.from, t + 1);
        if (n.type == wi)
          for (let l = 0; l < i; l++) {
            let a = r.parts[l];
            a instanceof Ye && a.type == wi && (a.side = 0);
          }
        return o.to;
      }
    }
    return -1;
  }
};
function jk(r, e, t, i, n) {
  let { text: s } = r, o = r.char(n), l = n;
  if (e.unshift(F(C.LinkMark, i, i + (t == C.Image ? 2 : 1))), e.push(F(C.LinkMark, n - 1, n)), o == 40) {
    let a = r.skipSpace(n + 1), h = Tm(s, a - r.offset, r.offset), c;
    h && (a = r.skipSpace(h.to), a != h.to && (c = Am(s, a - r.offset, r.offset), c && (a = r.skipSpace(c.to)))), r.char(a) == 41 && (e.push(F(C.LinkMark, n, n + 1)), l = a + 1, h && e.push(h), c && e.push(c), e.push(F(C.LinkMark, a, l)));
  } else if (o == 91) {
    let a = Mm(s, n - r.offset, r.offset, !1);
    a && (e.push(a), l = a.to);
  }
  return F(t, i, l, e);
}
function Tm(r, e, t) {
  if (r.charCodeAt(e) == 60) {
    for (let n = e + 1; n < r.length; n++) {
      let s = r.charCodeAt(n);
      if (s == 62)
        return F(C.URL, e + t, n + 1 + t);
      if (s == 60 || s == 10)
        return !1;
    }
    return null;
  } else {
    let n = 0, s = e;
    for (let o = !1; s < r.length; s++) {
      let l = r.charCodeAt(s);
      if (st(l))
        break;
      if (o)
        o = !1;
      else if (l == 40)
        n++;
      else if (l == 41) {
        if (!n)
          break;
        n--;
      } else l == 92 && (o = !0);
    }
    return s > e ? F(C.URL, e + t, s + t) : s == r.length ? null : !1;
  }
}
function Am(r, e, t) {
  let i = r.charCodeAt(e);
  if (i != 39 && i != 34 && i != 40)
    return !1;
  let n = i == 40 ? 41 : i;
  for (let s = e + 1, o = !1; s < r.length; s++) {
    let l = r.charCodeAt(s);
    if (o)
      o = !1;
    else {
      if (l == n)
        return F(C.LinkTitle, e + t, s + 1 + t);
      l == 92 && (o = !0);
    }
  }
  return null;
}
function Mm(r, e, t, i) {
  for (let n = !1, s = e + 1, o = Math.min(r.length, s + 999); s < o; s++) {
    let l = r.charCodeAt(s);
    if (n)
      n = !1;
    else {
      if (l == 93)
        return i ? !1 : F(C.LinkLabel, e + t, s + 1 + t);
      if (i && !st(l) && (i = !1), l == 91)
        return !1;
      l == 92 && (n = !0);
    }
  }
  return null;
}
class Ah {
  /**
  @internal
  */
  constructor(e, t, i) {
    this.parser = e, this.text = t, this.offset = i, this.parts = [];
  }
  /**
  Get the character code at the given (document-relative)
  position.
  */
  char(e) {
    return e >= this.end ? -1 : this.text.charCodeAt(e - this.offset);
  }
  /**
  The position of the end of this inline section.
  */
  get end() {
    return this.offset + this.text.length;
  }
  /**
  Get a substring of this inline section. Again uses
  document-relative positions.
  */
  slice(e, t) {
    return this.text.slice(e - this.offset, t - this.offset);
  }
  /**
  @internal
  */
  append(e) {
    return this.parts.push(e), e.to;
  }
  /**
  Add a [delimiter](#DelimiterType) at this given position. `open`
  and `close` indicate whether this delimiter is opening, closing,
  or both. Returns the end of the delimiter, for convenient
  returning from [parse functions](#InlineParser.parse).
  */
  addDelimiter(e, t, i, n, s) {
    return this.append(new Ye(e, t, i, (n ? 1 : 0) | (s ? 2 : 0)));
  }
  /**
  Returns true when there is an unmatched link or image opening
  token before the current position.
  */
  get hasOpenLink() {
    for (let e = this.parts.length - 1; e >= 0; e--) {
      let t = this.parts[e];
      if (t instanceof Ye && (t.type == wi || t.type == Ws))
        return !0;
    }
    return !1;
  }
  /**
  Add an inline element. Returns the end of the element.
  */
  addElement(e) {
    return this.append(e);
  }
  /**
  Resolve markers between this.parts.length and from, wrapping matched markers in the
  appropriate node and updating the content of this.parts. @internal
  */
  resolveMarkers(e) {
    for (let i = e; i < this.parts.length; i++) {
      let n = this.parts[i];
      if (!(n instanceof Ye && n.type.resolve && n.side & 2))
        continue;
      let s = n.type == Pm || n.type == Cm, o = n.to - n.from, l, a = i - 1;
      for (; a >= e; a--) {
        let O = this.parts[a];
        if (O instanceof Ye && O.side & 1 && O.type == n.type && // Ignore emphasis delimiters where the character count doesn't match
        !(s && (n.side & 1 || O.side & 2) && (O.to - O.from + o) % 3 == 0 && ((O.to - O.from) % 3 || o % 3))) {
          l = O;
          break;
        }
      }
      if (!l)
        continue;
      let h = n.type.resolve, c = [], f = l.from, u = n.to;
      if (s) {
        let O = Math.min(2, l.to - l.from, o);
        f = l.to - O, u = n.from + O, h = O == 1 ? "Emphasis" : "StrongEmphasis";
      }
      l.type.mark && c.push(this.elt(l.type.mark, f, l.to));
      for (let O = a + 1; O < i; O++)
        this.parts[O] instanceof tn && c.push(this.parts[O]), this.parts[O] = null;
      n.type.mark && c.push(this.elt(n.type.mark, n.from, u));
      let d = this.elt(h, f, u, c);
      this.parts[a] = s && l.from != f ? new Ye(l.type, l.from, f, l.side) : null, (this.parts[i] = s && n.to != u ? new Ye(n.type, u, n.to, n.side) : null) ? this.parts.splice(i, 0, d) : this.parts[i] = d;
    }
    let t = [];
    for (let i = e; i < this.parts.length; i++) {
      let n = this.parts[i];
      n instanceof tn && t.push(n);
    }
    return t;
  }
  /**
  Find an opening delimiter of the given type. Returns `null` if
  no delimiter is found, or an index that can be passed to
  [`takeContent`](#InlineContext.takeContent) otherwise.
  */
  findOpeningDelimiter(e) {
    for (let t = this.parts.length - 1; t >= 0; t--) {
      let i = this.parts[t];
      if (i instanceof Ye && i.type == e && i.side & 1)
        return t;
    }
    return null;
  }
  /**
  Remove all inline elements and delimiters starting from the
  given index (which you should get from
  [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
  resolve delimiters inside of them, and return them as an array
  of elements.
  */
  takeContent(e) {
    let t = this.resolveMarkers(e);
    return this.parts.length = e, t;
  }
  /**
  Return the delimiter at the given index. Mostly useful to get
  additional info out of a delimiter index returned by
  [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
  Returns null if there is no delimiter at this index.
  */
  getDelimiterAt(e) {
    let t = this.parts[e];
    return t instanceof Ye ? t : null;
  }
  /**
  Skip space after the given (document) position, returning either
  the position of the next non-space character or the end of the
  section.
  */
  skipSpace(e) {
    return Lr(this.text, e - this.offset) + this.offset;
  }
  elt(e, t, i, n) {
    return typeof e == "string" ? F(this.parser.getNodeType(e), t, i, n) : new $m(e, t);
  }
}
Ah.linkStart = wi;
Ah.imageStart = Ws;
function Ma(r, e) {
  if (!e.length)
    return r;
  if (!r.length)
    return e;
  let t = r.slice(), i = 0;
  for (let n of e) {
    for (; i < t.length && t[i].to < n.to; )
      i++;
    if (i < t.length && t[i].from < n.from) {
      let s = t[i];
      s instanceof tn && (t[i] = new tn(s.type, s.from, s.to, Ma(s.children, [n])));
    } else
      t.splice(i++, 0, n);
  }
  return t;
}
const Gk = [C.CodeBlock, C.ListItem, C.OrderedList, C.BulletList];
let Uk = class {
  constructor(e, t) {
    this.fragments = e, this.input = t, this.i = 0, this.fragment = null, this.fragmentEnd = -1, this.cursor = null, e.length && (this.fragment = e[this.i++]);
  }
  nextFragment() {
    this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null, this.cursor = null, this.fragmentEnd = -1;
  }
  moveTo(e, t) {
    for (; this.fragment && this.fragment.to <= e; )
      this.nextFragment();
    if (!this.fragment || this.fragment.from > (e ? e - 1 : 0))
      return !1;
    if (this.fragmentEnd < 0) {
      let s = this.fragment.to;
      for (; s > 0 && this.input.read(s - 1, s) != `
`; )
        s--;
      this.fragmentEnd = s ? s - 1 : 0;
    }
    let i = this.cursor;
    i || (i = this.cursor = this.fragment.tree.cursor(), i.firstChild());
    let n = e + this.fragment.offset;
    for (; i.to <= n; )
      if (!i.parent())
        return !1;
    for (; ; ) {
      if (i.from >= n)
        return this.fragment.from <= t;
      if (!i.childAfter(n))
        return !1;
    }
  }
  matches(e) {
    let t = this.cursor.tree;
    return t && t.prop(j.contextHash) == e;
  }
  takeNodes(e) {
    let t = this.cursor, i = this.fragment.offset, n = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0), s = e.absoluteLineStart, o = s, l = e.block.children.length, a = o, h = l;
    for (; ; ) {
      if (t.to - i > n) {
        if (t.type.isAnonymous && t.firstChild())
          continue;
        break;
      }
      let c = Zm(t.from - i, e.ranges);
      if (t.to - i <= e.ranges[e.rangeI].to)
        e.addNode(t.tree, c);
      else {
        let f = new te(e.parser.nodeSet.types[C.Paragraph], [], [], 0, e.block.hashProp);
        e.reusePlaceholders.set(f, t.tree), e.addNode(f, c);
      }
      if (t.type.is("Block") && (Gk.indexOf(t.type.id) < 0 ? (o = t.to - i, l = e.block.children.length) : (o = a, l = h, a = t.to - i, h = e.block.children.length)), !t.nextSibling())
        break;
    }
    for (; e.block.children.length > l; )
      e.block.children.pop(), e.block.positions.pop();
    return o - s;
  }
};
function Zm(r, e) {
  let t = r;
  for (let i = 1; i < e.length; i++) {
    let n = e[i - 1].to, s = e[i].from;
    n < r && (t -= s - n);
  }
  return t;
}
const Fk = sr({
  "Blockquote/...": m.quote,
  HorizontalRule: m.contentSeparator,
  "ATXHeading1/... SetextHeading1/...": m.heading1,
  "ATXHeading2/... SetextHeading2/...": m.heading2,
  "ATXHeading3/...": m.heading3,
  "ATXHeading4/...": m.heading4,
  "ATXHeading5/...": m.heading5,
  "ATXHeading6/...": m.heading6,
  "Comment CommentBlock": m.comment,
  Escape: m.escape,
  Entity: m.character,
  "Emphasis/...": m.emphasis,
  "StrongEmphasis/...": m.strong,
  "Link/... Image/...": m.link,
  "OrderedList/... BulletList/...": m.list,
  "BlockQuote/...": m.quote,
  "InlineCode CodeText": m.monospace,
  "URL Autolink": m.url,
  "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": m.processingInstruction,
  "CodeInfo LinkLabel": m.labelName,
  LinkTitle: m.string,
  Paragraph: m.content
}), Hk = new yo(new pn(Qm).extend(Fk), Object.keys(Gn).map((r) => Gn[r]), Object.keys(Gn).map((r) => xm[r]), Object.keys(Gn), Yk, dm, Object.keys(il).map((r) => il[r]), Object.keys(il), []);
function Kk(r, e, t) {
  let i = [];
  for (let n = r.firstChild, s = e; ; n = n.nextSibling) {
    let o = n ? n.from : t;
    if (o > s && i.push({ from: s, to: o }), !n)
      break;
    s = n.to;
  }
  return i;
}
function Jk(r) {
  let { codeParser: e, htmlParser: t } = r;
  return { wrap: sm((n, s) => {
    let o = n.type.id;
    if (e && (o == C.CodeBlock || o == C.FencedCode)) {
      let l = "";
      if (o == C.FencedCode) {
        let h = n.node.getChild(C.CodeInfo);
        h && (l = s.read(h.from, h.to));
      }
      let a = e(l);
      if (a)
        return { parser: a, overlay: (h) => h.type.id == C.CodeText };
    } else if (t && (o == C.HTMLBlock || o == C.HTMLTag || o == C.CommentBlock))
      return { parser: t, overlay: Kk(n.node, n.from, n.to) };
    return null;
  }) };
}
const eQ = { resolve: "Strikethrough", mark: "StrikethroughMark" }, tQ = {
  defineNodes: [{
    name: "Strikethrough",
    style: { "Strikethrough/...": m.strikethrough }
  }, {
    name: "StrikethroughMark",
    style: m.processingInstruction
  }],
  parseInline: [{
    name: "Strikethrough",
    parse(r, e, t) {
      if (e != 126 || r.char(t + 1) != 126 || r.char(t + 2) == 126)
        return -1;
      let i = r.slice(t - 1, t), n = r.slice(t + 2, t + 3), s = /\s|^$/.test(i), o = /\s|^$/.test(n), l = rn.test(i), a = rn.test(n);
      return r.addDelimiter(eQ, t, t + 2, !o && (!a || s || l), !s && (!l || o || a));
    },
    after: "Emphasis"
  }]
};
function Er(r, e, t = 0, i, n = 0) {
  let s = 0, o = !0, l = -1, a = -1, h = !1, c = () => {
    i.push(r.elt("TableCell", n + l, n + a, r.parser.parseInline(e.slice(l, a), n + l)));
  };
  for (let f = t; f < e.length; f++) {
    let u = e.charCodeAt(f);
    u == 124 && !h ? ((!o || l > -1) && s++, o = !1, i && (l > -1 && c(), i.push(r.elt("TableDelimiter", f + n, f + n + 1))), l = a = -1) : (h || u != 32 && u != 9) && (l < 0 && (l = f), a = f + 1), h = !h && u == 92;
  }
  return l > -1 && (s++, i && c()), s;
}
function eu(r, e) {
  for (let t = e; t < r.length; t++) {
    let i = r.charCodeAt(t);
    if (i == 124)
      return !0;
    i == 92 && t++;
  }
  return !1;
}
const Xm = /^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
class tu {
  constructor() {
    this.rows = null;
  }
  nextLine(e, t, i) {
    if (this.rows == null) {
      this.rows = !1;
      let n;
      if ((t.next == 45 || t.next == 58 || t.next == 124) && Xm.test(n = t.text.slice(t.pos))) {
        let s = [];
        Er(e, i.content, 0, s, i.start) == Er(e, n, t.pos) && (this.rows = [
          e.elt("TableHeader", i.start, i.start + i.content.length, s),
          e.elt("TableDelimiter", e.lineStart + t.pos, e.lineStart + t.text.length)
        ]);
      }
    } else if (this.rows) {
      let n = [];
      Er(e, t.text, t.pos, n, e.lineStart), this.rows.push(e.elt("TableRow", e.lineStart + t.pos, e.lineStart + t.text.length, n));
    }
    return !1;
  }
  finish(e, t) {
    return this.rows ? (e.addLeafElement(t, e.elt("Table", t.start, t.start + t.content.length, this.rows)), !0) : !1;
  }
}
const iQ = {
  defineNodes: [
    { name: "Table", block: !0 },
    { name: "TableHeader", style: { "TableHeader/...": m.heading } },
    "TableRow",
    { name: "TableCell", style: m.content },
    { name: "TableDelimiter", style: m.processingInstruction }
  ],
  parseBlock: [{
    name: "Table",
    leaf(r, e) {
      return eu(e.content, 0) ? new tu() : null;
    },
    endLeaf(r, e, t) {
      if (t.parsers.some((n) => n instanceof tu) || !eu(e.text, e.basePos))
        return !1;
      let i = r.peekLine();
      return Xm.test(i) && Er(r, e.text, e.basePos) == Er(r, i, e.basePos);
    },
    before: "SetextHeading"
  }]
};
class rQ {
  nextLine() {
    return !1;
  }
  finish(e, t) {
    return e.addLeafElement(t, e.elt("Task", t.start, t.start + t.content.length, [
      e.elt("TaskMarker", t.start, t.start + 3),
      ...e.parser.parseInline(t.content.slice(3), t.start + 3)
    ])), !0;
  }
}
const nQ = {
  defineNodes: [
    { name: "Task", block: !0, style: m.list },
    { name: "TaskMarker", style: m.atom }
  ],
  parseBlock: [{
    name: "TaskList",
    leaf(r, e) {
      return /^\[[ xX]\][ \t]/.test(e.content) && r.parentType().name == "ListItem" ? new rQ() : null;
    },
    after: "SetextHeading"
  }]
}, iu = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy, ru = /[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy, sQ = /[\w-]+\.[\w-]+($|\/)/, nu = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy, su = /\/[a-zA-Z\d@.]+/gy;
function ou(r, e, t, i) {
  let n = 0;
  for (let s = e; s < t; s++)
    r[s] == i && n++;
  return n;
}
function oQ(r, e) {
  ru.lastIndex = e;
  let t = ru.exec(r);
  if (!t || sQ.exec(t[0])[0].indexOf("_") > -1)
    return -1;
  let i = e + t[0].length;
  for (; ; ) {
    let n = r[i - 1], s;
    if (/[?!.,:*_~]/.test(n) || n == ")" && ou(r, e, i, ")") > ou(r, e, i, "("))
      i--;
    else if (n == ";" && (s = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(r.slice(e, i))))
      i = e + s.index;
    else
      break;
  }
  return i;
}
function lu(r, e) {
  nu.lastIndex = e;
  let t = nu.exec(r);
  if (!t)
    return -1;
  let i = t[0][t[0].length - 1];
  return i == "_" || i == "-" ? -1 : e + t[0].length - (i == "." ? 1 : 0);
}
const lQ = {
  parseInline: [{
    name: "Autolink",
    parse(r, e, t) {
      let i = t - r.offset;
      if (i && /\w/.test(r.text[i - 1]))
        return -1;
      iu.lastIndex = i;
      let n = iu.exec(r.text), s = -1;
      if (!n)
        return -1;
      if (n[1] || n[2]) {
        if (s = oQ(r.text, i + n[0].length), s > -1 && r.hasOpenLink) {
          let o = /([^\[\]]|\[[^\]]*\])*/.exec(r.text.slice(i, s));
          s = i + o[0].length;
        }
      } else n[3] ? s = lu(r.text, i) : (s = lu(r.text, i + n[0].length), s > -1 && n[0] == "xmpp:" && (su.lastIndex = s, n = su.exec(r.text), n && (s = n.index + n[0].length)));
      return s < 0 ? -1 : (r.addElement(r.elt("URL", t, s + r.offset)), s + r.offset);
    }
  }]
}, aQ = [iQ, nQ, tQ, lQ];
function Rm(r, e, t) {
  return (i, n, s) => {
    if (n != r || i.char(s + 1) == r)
      return -1;
    let o = [i.elt(t, s, s + 1)];
    for (let l = s + 1; l < i.end; l++) {
      let a = i.char(l);
      if (a == r)
        return i.addElement(i.elt(e, s, l + 1, o.concat(i.elt(t, l, l + 1))));
      if (a == 92 && o.push(i.elt("Escape", l, l++ + 2)), st(a))
        break;
    }
    return -1;
  };
}
const hQ = {
  defineNodes: [
    { name: "Superscript", style: m.special(m.content) },
    { name: "SuperscriptMark", style: m.processingInstruction }
  ],
  parseInline: [{
    name: "Superscript",
    parse: Rm(94, "Superscript", "SuperscriptMark")
  }]
}, cQ = {
  defineNodes: [
    { name: "Subscript", style: m.special(m.content) },
    { name: "SubscriptMark", style: m.processingInstruction }
  ],
  parseInline: [{
    name: "Subscript",
    parse: Rm(126, "Subscript", "SubscriptMark")
  }]
}, fQ = {
  defineNodes: [{ name: "Emoji", style: m.character }],
  parseInline: [{
    name: "Emoji",
    parse(r, e, t) {
      let i;
      return e != 58 || !(i = /^[a-zA-Z_0-9]+:/.exec(r.slice(t + 1, r.end))) ? -1 : r.addElement(r.elt("Emoji", t, t + 1 + i[0].length));
    }
  }]
};
class js {
  /**
  @internal
  */
  constructor(e, t, i, n, s, o, l, a, h, c = 0, f) {
    this.p = e, this.stack = t, this.state = i, this.reducePos = n, this.pos = s, this.score = o, this.buffer = l, this.bufferBase = a, this.curContext = h, this.lookAhead = c, this.parent = f;
  }
  /**
  @internal
  */
  toString() {
    return `[${this.stack.filter((e, t) => t % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
  }
  // Start an empty stack
  /**
  @internal
  */
  static start(e, t, i = 0) {
    let n = e.parser.context;
    return new js(e, [], t, i, i, 0, [], 0, n ? new au(n, n.start) : null, 0, null);
  }
  /**
  The stack's current [context](#lr.ContextTracker) value, if
  any. Its type will depend on the context tracker's type
  parameter, or it will be `null` if there is no context
  tracker.
  */
  get context() {
    return this.curContext ? this.curContext.context : null;
  }
  // Push a state onto the stack, tracking its start position as well
  // as the buffer base at that point.
  /**
  @internal
  */
  pushState(e, t) {
    this.stack.push(this.state, t, this.bufferBase + this.buffer.length), this.state = e;
  }
  // Apply a reduce action
  /**
  @internal
  */
  reduce(e) {
    var t;
    let i = e >> 19, n = e & 65535, { parser: s } = this.p, o = this.reducePos < this.pos - 25;
    o && this.setLookAhead(this.pos);
    let l = s.dynamicPrecedence(n);
    if (l && (this.score += l), i == 0) {
      this.pushState(s.getGoto(this.state, n, !0), this.reducePos), n < s.minRepeatTerm && this.storeNode(n, this.reducePos, this.reducePos, o ? 8 : 4, !0), this.reduceContext(n, this.reducePos);
      return;
    }
    let a = this.stack.length - (i - 1) * 3 - (e & 262144 ? 6 : 0), h = a ? this.stack[a - 2] : this.p.ranges[0].from, c = this.reducePos - h;
    c >= 2e3 && !(!((t = this.p.parser.nodeSet.types[n]) === null || t === void 0) && t.isAnonymous) && (h == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = c) : this.p.lastBigReductionSize < c && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = h, this.p.lastBigReductionSize = c));
    let f = a ? this.stack[a - 1] : 0, u = this.bufferBase + this.buffer.length - f;
    if (n < s.minRepeatTerm || e & 131072) {
      let d = s.stateFlag(
        this.state,
        1
        /* StateFlag.Skipped */
      ) ? this.pos : this.reducePos;
      this.storeNode(n, h, d, u + 4, !0);
    }
    if (e & 262144)
      this.state = this.stack[a];
    else {
      let d = this.stack[a - 3];
      this.state = s.getGoto(d, n, !0);
    }
    for (; this.stack.length > a; )
      this.stack.pop();
    this.reduceContext(n, h);
  }
  // Shift a value into the buffer
  /**
  @internal
  */
  storeNode(e, t, i, n = 4, s = !1) {
    if (e == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
      let o = this, l = this.buffer.length;
      if (l == 0 && o.parent && (l = o.bufferBase - o.parent.bufferBase, o = o.parent), l > 0 && o.buffer[l - 4] == 0 && o.buffer[l - 1] > -1) {
        if (t == i)
          return;
        if (o.buffer[l - 2] >= t) {
          o.buffer[l - 2] = i;
          return;
        }
      }
    }
    if (!s || this.pos == i)
      this.buffer.push(e, t, i, n);
    else {
      let o = this.buffer.length;
      if (o > 0 && (this.buffer[o - 4] != 0 || this.buffer[o - 1] < 0)) {
        let l = !1;
        for (let a = o; a > 0 && this.buffer[a - 2] > i; a -= 4)
          if (this.buffer[a - 1] >= 0) {
            l = !0;
            break;
          }
        if (l)
          for (; o > 0 && this.buffer[o - 2] > i; )
            this.buffer[o] = this.buffer[o - 4], this.buffer[o + 1] = this.buffer[o - 3], this.buffer[o + 2] = this.buffer[o - 2], this.buffer[o + 3] = this.buffer[o - 1], o -= 4, n > 4 && (n -= 4);
      }
      this.buffer[o] = e, this.buffer[o + 1] = t, this.buffer[o + 2] = i, this.buffer[o + 3] = n;
    }
  }
  // Apply a shift action
  /**
  @internal
  */
  shift(e, t, i, n) {
    if (e & 131072)
      this.pushState(e & 65535, this.pos);
    else if ((e & 262144) == 0) {
      let s = e, { parser: o } = this.p;
      (n > this.pos || t <= o.maxNode) && (this.pos = n, o.stateFlag(
        s,
        1
        /* StateFlag.Skipped */
      ) || (this.reducePos = n)), this.pushState(s, i), this.shiftContext(t, i), t <= o.maxNode && this.buffer.push(t, i, n, 4);
    } else
      this.pos = n, this.shiftContext(t, i), t <= this.p.parser.maxNode && this.buffer.push(t, i, n, 4);
  }
  // Apply an action
  /**
  @internal
  */
  apply(e, t, i, n) {
    e & 65536 ? this.reduce(e) : this.shift(e, t, i, n);
  }
  // Add a prebuilt (reused) node into the buffer.
  /**
  @internal
  */
  useNode(e, t) {
    let i = this.p.reused.length - 1;
    (i < 0 || this.p.reused[i] != e) && (this.p.reused.push(e), i++);
    let n = this.pos;
    this.reducePos = this.pos = n + e.length, this.pushState(t, n), this.buffer.push(
      i,
      n,
      this.reducePos,
      -1
      /* size == -1 means this is a reused value */
    ), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, e, this, this.p.stream.reset(this.pos - e.length)));
  }
  // Split the stack. Due to the buffer sharing and the fact
  // that `this.stack` tends to stay quite shallow, this isn't very
  // expensive.
  /**
  @internal
  */
  split() {
    let e = this, t = e.buffer.length;
    for (; t > 0 && e.buffer[t - 2] > e.reducePos; )
      t -= 4;
    let i = e.buffer.slice(t), n = e.bufferBase + t;
    for (; e && n == e.bufferBase; )
      e = e.parent;
    return new js(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, i, n, this.curContext, this.lookAhead, e);
  }
  // Try to recover from an error by 'deleting' (ignoring) one token.
  /**
  @internal
  */
  recoverByDelete(e, t) {
    let i = e <= this.p.parser.maxNode;
    i && this.storeNode(e, this.pos, t, 4), this.storeNode(0, this.pos, t, i ? 8 : 4), this.pos = this.reducePos = t, this.score -= 190;
  }
  /**
  Check if the given term would be able to be shifted (optionally
  after some reductions) on this stack. This can be useful for
  external tokenizers that want to make sure they only provide a
  given token when it applies.
  */
  canShift(e) {
    for (let t = new uQ(this); ; ) {
      let i = this.p.parser.stateSlot(
        t.state,
        4
        /* ParseState.DefaultReduce */
      ) || this.p.parser.hasAction(t.state, e);
      if (i == 0)
        return !1;
      if ((i & 65536) == 0)
        return !0;
      t.reduce(i);
    }
  }
  // Apply up to Recover.MaxNext recovery actions that conceptually
  // inserts some missing token or rule.
  /**
  @internal
  */
  recoverByInsert(e) {
    if (this.stack.length >= 300)
      return [];
    let t = this.p.parser.nextStates(this.state);
    if (t.length > 8 || this.stack.length >= 120) {
      let n = [];
      for (let s = 0, o; s < t.length; s += 2)
        (o = t[s + 1]) != this.state && this.p.parser.hasAction(o, e) && n.push(t[s], o);
      if (this.stack.length < 120)
        for (let s = 0; n.length < 8 && s < t.length; s += 2) {
          let o = t[s + 1];
          n.some((l, a) => a & 1 && l == o) || n.push(t[s], o);
        }
      t = n;
    }
    let i = [];
    for (let n = 0; n < t.length && i.length < 4; n += 2) {
      let s = t[n + 1];
      if (s == this.state)
        continue;
      let o = this.split();
      o.pushState(s, this.pos), o.storeNode(0, o.pos, o.pos, 4, !0), o.shiftContext(t[n], this.pos), o.reducePos = this.pos, o.score -= 200, i.push(o);
    }
    return i;
  }
  // Force a reduce, if possible. Return false if that can't
  // be done.
  /**
  @internal
  */
  forceReduce() {
    let { parser: e } = this.p, t = e.stateSlot(
      this.state,
      5
      /* ParseState.ForcedReduce */
    );
    if ((t & 65536) == 0)
      return !1;
    if (!e.validAction(this.state, t)) {
      let i = t >> 19, n = t & 65535, s = this.stack.length - i * 3;
      if (s < 0 || e.getGoto(this.stack[s], n, !1) < 0) {
        let o = this.findForcedReduction();
        if (o == null)
          return !1;
        t = o;
      }
      this.storeNode(0, this.pos, this.pos, 4, !0), this.score -= 100;
    }
    return this.reducePos = this.pos, this.reduce(t), !0;
  }
  /**
  Try to scan through the automaton to find some kind of reduction
  that can be applied. Used when the regular ForcedReduce field
  isn't a valid action. @internal
  */
  findForcedReduction() {
    let { parser: e } = this.p, t = [], i = (n, s) => {
      if (!t.includes(n))
        return t.push(n), e.allActions(n, (o) => {
          if (!(o & 393216)) if (o & 65536) {
            let l = (o >> 19) - s;
            if (l > 1) {
              let a = o & 65535, h = this.stack.length - l * 3;
              if (h >= 0 && e.getGoto(this.stack[h], a, !1) >= 0)
                return l << 19 | 65536 | a;
            }
          } else {
            let l = i(o, s + 1);
            if (l != null)
              return l;
          }
        });
    };
    return i(this.state, 0);
  }
  /**
  @internal
  */
  forceAll() {
    for (; !this.p.parser.stateFlag(
      this.state,
      2
      /* StateFlag.Accepting */
    ); )
      if (!this.forceReduce()) {
        this.storeNode(0, this.pos, this.pos, 4, !0);
        break;
      }
    return this;
  }
  /**
  Check whether this state has no further actions (assumed to be a direct descendant of the
  top state, since any other states must be able to continue
  somehow). @internal
  */
  get deadEnd() {
    if (this.stack.length != 3)
      return !1;
    let { parser: e } = this.p;
    return e.data[e.stateSlot(
      this.state,
      1
      /* ParseState.Actions */
    )] == 65535 && !e.stateSlot(
      this.state,
      4
      /* ParseState.DefaultReduce */
    );
  }
  /**
  Restart the stack (put it back in its start state). Only safe
  when this.stack.length == 3 (state is directly below the top
  state). @internal
  */
  restart() {
    this.storeNode(0, this.pos, this.pos, 4, !0), this.state = this.stack[0], this.stack.length = 0;
  }
  /**
  @internal
  */
  sameState(e) {
    if (this.state != e.state || this.stack.length != e.stack.length)
      return !1;
    for (let t = 0; t < this.stack.length; t += 3)
      if (this.stack[t] != e.stack[t])
        return !1;
    return !0;
  }
  /**
  Get the parser used by this stack.
  */
  get parser() {
    return this.p.parser;
  }
  /**
  Test whether a given dialect (by numeric ID, as exported from
  the terms file) is enabled.
  */
  dialectEnabled(e) {
    return this.p.parser.dialect.flags[e];
  }
  shiftContext(e, t) {
    this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, e, this, this.p.stream.reset(t)));
  }
  reduceContext(e, t) {
    this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, e, this, this.p.stream.reset(t)));
  }
  /**
  @internal
  */
  emitContext() {
    let e = this.buffer.length - 1;
    (e < 0 || this.buffer[e] != -3) && this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
  }
  /**
  @internal
  */
  emitLookAhead() {
    let e = this.buffer.length - 1;
    (e < 0 || this.buffer[e] != -4) && this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
  }
  updateContext(e) {
    if (e != this.curContext.context) {
      let t = new au(this.curContext.tracker, e);
      t.hash != this.curContext.hash && this.emitContext(), this.curContext = t;
    }
  }
  /**
  @internal
  */
  setLookAhead(e) {
    e > this.lookAhead && (this.emitLookAhead(), this.lookAhead = e);
  }
  /**
  @internal
  */
  close() {
    this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
  }
}
class au {
  constructor(e, t) {
    this.tracker = e, this.context = t, this.hash = e.strict ? e.hash(t) : 0;
  }
}
class uQ {
  constructor(e) {
    this.start = e, this.state = e.state, this.stack = e.stack, this.base = this.stack.length;
  }
  reduce(e) {
    let t = e & 65535, i = e >> 19;
    i == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (i - 1) * 3;
    let n = this.start.p.parser.getGoto(this.stack[this.base - 3], t, !0);
    this.state = n;
  }
}
class Gs {
  constructor(e, t, i) {
    this.stack = e, this.pos = t, this.index = i, this.buffer = e.buffer, this.index == 0 && this.maybeNext();
  }
  static create(e, t = e.bufferBase + e.buffer.length) {
    return new Gs(e, t, t - e.bufferBase);
  }
  maybeNext() {
    let e = this.stack.parent;
    e != null && (this.index = this.stack.bufferBase - e.bufferBase, this.stack = e, this.buffer = e.buffer);
  }
  get id() {
    return this.buffer[this.index - 4];
  }
  get start() {
    return this.buffer[this.index - 3];
  }
  get end() {
    return this.buffer[this.index - 2];
  }
  get size() {
    return this.buffer[this.index - 1];
  }
  next() {
    this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
  }
  fork() {
    return new Gs(this.stack, this.pos, this.index);
  }
}
function $r(r, e = Uint16Array) {
  if (typeof r != "string")
    return r;
  let t = null;
  for (let i = 0, n = 0; i < r.length; ) {
    let s = 0;
    for (; ; ) {
      let o = r.charCodeAt(i++), l = !1;
      if (o == 126) {
        s = 65535;
        break;
      }
      o >= 92 && o--, o >= 34 && o--;
      let a = o - 32;
      if (a >= 46 && (a -= 46, l = !0), s += a, l)
        break;
      s *= 46;
    }
    t ? t[n++] = s : t = new e(s);
  }
  return t;
}
class us {
  constructor() {
    this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
  }
}
const hu = new us();
class dQ {
  /**
  @internal
  */
  constructor(e, t) {
    this.input = e, this.ranges = t, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = hu, this.rangeIndex = 0, this.pos = this.chunkPos = t[0].from, this.range = t[0], this.end = t[t.length - 1].to, this.readNext();
  }
  /**
  @internal
  */
  resolveOffset(e, t) {
    let i = this.range, n = this.rangeIndex, s = this.pos + e;
    for (; s < i.from; ) {
      if (!n)
        return null;
      let o = this.ranges[--n];
      s -= i.from - o.to, i = o;
    }
    for (; t < 0 ? s > i.to : s >= i.to; ) {
      if (n == this.ranges.length - 1)
        return null;
      let o = this.ranges[++n];
      s += o.from - i.to, i = o;
    }
    return s;
  }
  /**
  @internal
  */
  clipPos(e) {
    if (e >= this.range.from && e < this.range.to)
      return e;
    for (let t of this.ranges)
      if (t.to > e)
        return Math.max(e, t.from);
    return this.end;
  }
  /**
  Look at a code unit near the stream position. `.peek(0)` equals
  `.next`, `.peek(-1)` gives you the previous character, and so
  on.
  
  Note that looking around during tokenizing creates dependencies
  on potentially far-away content, which may reduce the
  effectiveness incremental parsing—when looking forward—or even
  cause invalid reparses when looking backward more than 25 code
  units, since the library does not track lookbehind.
  */
  peek(e) {
    let t = this.chunkOff + e, i, n;
    if (t >= 0 && t < this.chunk.length)
      i = this.pos + e, n = this.chunk.charCodeAt(t);
    else {
      let s = this.resolveOffset(e, 1);
      if (s == null)
        return -1;
      if (i = s, i >= this.chunk2Pos && i < this.chunk2Pos + this.chunk2.length)
        n = this.chunk2.charCodeAt(i - this.chunk2Pos);
      else {
        let o = this.rangeIndex, l = this.range;
        for (; l.to <= i; )
          l = this.ranges[++o];
        this.chunk2 = this.input.chunk(this.chunk2Pos = i), i + this.chunk2.length > l.to && (this.chunk2 = this.chunk2.slice(0, l.to - i)), n = this.chunk2.charCodeAt(0);
      }
    }
    return i >= this.token.lookAhead && (this.token.lookAhead = i + 1), n;
  }
  /**
  Accept a token. By default, the end of the token is set to the
  current stream position, but you can pass an offset (relative to
  the stream position) to change that.
  */
  acceptToken(e, t = 0) {
    let i = t ? this.resolveOffset(t, -1) : this.pos;
    if (i == null || i < this.token.start)
      throw new RangeError("Token end out of bounds");
    this.token.value = e, this.token.end = i;
  }
  /**
  Accept a token ending at a specific given position.
  */
  acceptTokenTo(e, t) {
    this.token.value = e, this.token.end = t;
  }
  getChunk() {
    if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
      let { chunk: e, chunkPos: t } = this;
      this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = e, this.chunk2Pos = t, this.chunkOff = this.pos - this.chunkPos;
    } else {
      this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
      let e = this.input.chunk(this.pos), t = this.pos + e.length;
      this.chunk = t > this.range.to ? e.slice(0, this.range.to - this.pos) : e, this.chunkPos = this.pos, this.chunkOff = 0;
    }
  }
  readNext() {
    return this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? this.next = -1 : this.next = this.chunk.charCodeAt(this.chunkOff);
  }
  /**
  Move the stream forward N (defaults to 1) code units. Returns
  the new value of [`next`](#lr.InputStream.next).
  */
  advance(e = 1) {
    for (this.chunkOff += e; this.pos + e >= this.range.to; ) {
      if (this.rangeIndex == this.ranges.length - 1)
        return this.setDone();
      e -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
    }
    return this.pos += e, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
  }
  setDone() {
    return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
  }
  /**
  @internal
  */
  reset(e, t) {
    if (t ? (this.token = t, t.start = e, t.lookAhead = e + 1, t.value = t.extended = -1) : this.token = hu, this.pos != e) {
      if (this.pos = e, e == this.end)
        return this.setDone(), this;
      for (; e < this.range.from; )
        this.range = this.ranges[--this.rangeIndex];
      for (; e >= this.range.to; )
        this.range = this.ranges[++this.rangeIndex];
      e >= this.chunkPos && e < this.chunkPos + this.chunk.length ? this.chunkOff = e - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
    }
    return this;
  }
  /**
  @internal
  */
  read(e, t) {
    if (e >= this.chunkPos && t <= this.chunkPos + this.chunk.length)
      return this.chunk.slice(e - this.chunkPos, t - this.chunkPos);
    if (e >= this.chunk2Pos && t <= this.chunk2Pos + this.chunk2.length)
      return this.chunk2.slice(e - this.chunk2Pos, t - this.chunk2Pos);
    if (e >= this.range.from && t <= this.range.to)
      return this.input.read(e, t);
    let i = "";
    for (let n of this.ranges) {
      if (n.from >= t)
        break;
      n.to > e && (i += this.input.read(Math.max(n.from, e), Math.min(n.to, t)));
    }
    return i;
  }
}
class Ii {
  constructor(e, t) {
    this.data = e, this.id = t;
  }
  token(e, t) {
    let { parser: i } = t.p;
    Lm(this.data, e, t, this.id, i.data, i.tokenPrecTable);
  }
}
Ii.prototype.contextual = Ii.prototype.fallback = Ii.prototype.extend = !1;
class Us {
  constructor(e, t, i) {
    this.precTable = t, this.elseToken = i, this.data = typeof e == "string" ? $r(e) : e;
  }
  token(e, t) {
    let i = e.pos, n = 0;
    for (; ; ) {
      let s = e.next < 0, o = e.resolveOffset(1, 1);
      if (Lm(this.data, e, t, 0, this.data, this.precTable), e.token.value > -1)
        break;
      if (this.elseToken == null)
        return;
      if (s || n++, o == null)
        break;
      e.reset(o, e.token);
    }
    n && (e.reset(i, e.token), e.acceptToken(this.elseToken, n));
  }
}
Us.prototype.contextual = Ii.prototype.fallback = Ii.prototype.extend = !1;
class Fe {
  /**
  Create a tokenizer. The first argument is the function that,
  given an input stream, scans for the types of tokens it
  recognizes at the stream's position, and calls
  [`acceptToken`](#lr.InputStream.acceptToken) when it finds
  one.
  */
  constructor(e, t = {}) {
    this.token = e, this.contextual = !!t.contextual, this.fallback = !!t.fallback, this.extend = !!t.extend;
  }
}
function Lm(r, e, t, i, n, s) {
  let o = 0, l = 1 << i, { dialect: a } = t.p.parser;
  e: for (; (l & r[o]) != 0; ) {
    let h = r[o + 1];
    for (let d = o + 3; d < h; d += 2)
      if ((r[d + 1] & l) > 0) {
        let p = r[d];
        if (a.allows(p) && (e.token.value == -1 || e.token.value == p || pQ(p, e.token.value, n, s))) {
          e.acceptToken(p);
          break;
        }
      }
    let c = e.next, f = 0, u = r[o + 2];
    if (e.next < 0 && u > f && r[h + u * 3 - 3] == 65535) {
      o = r[h + u * 3 - 1];
      continue e;
    }
    for (; f < u; ) {
      let d = f + u >> 1, p = h + d + (d << 1), O = r[p], g = r[p + 1] || 65536;
      if (c < O)
        u = d;
      else if (c >= g)
        f = d + 1;
      else {
        o = r[p + 2], e.advance();
        continue e;
      }
    }
    break;
  }
}
function cu(r, e, t) {
  for (let i = e, n; (n = r[i]) != 65535; i++)
    if (n == t)
      return i - e;
  return -1;
}
function pQ(r, e, t, i) {
  let n = cu(t, i, e);
  return n < 0 || cu(t, i, r) < n;
}
const Ie = typeof process < "u" && process.env && /\bparse\b/.test(process.env.LOG);
let rl = null;
function fu(r, e, t) {
  let i = r.cursor(le.IncludeAnonymous);
  for (i.moveTo(e); ; )
    if (!(t < 0 ? i.childBefore(e) : i.childAfter(e)))
      for (; ; ) {
        if ((t < 0 ? i.to < e : i.from > e) && !i.type.isError)
          return t < 0 ? Math.max(0, Math.min(
            i.to - 1,
            e - 25
            /* Lookahead.Margin */
          )) : Math.min(r.length, Math.max(
            i.from + 1,
            e + 25
            /* Lookahead.Margin */
          ));
        if (t < 0 ? i.prevSibling() : i.nextSibling())
          break;
        if (!i.parent())
          return t < 0 ? 0 : r.length;
      }
}
class OQ {
  constructor(e, t) {
    this.fragments = e, this.nodeSet = t, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
  }
  nextFragment() {
    let e = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
    if (e) {
      for (this.safeFrom = e.openStart ? fu(e.tree, e.from + e.offset, 1) - e.offset : e.from, this.safeTo = e.openEnd ? fu(e.tree, e.to + e.offset, -1) - e.offset : e.to; this.trees.length; )
        this.trees.pop(), this.start.pop(), this.index.pop();
      this.trees.push(e.tree), this.start.push(-e.offset), this.index.push(0), this.nextStart = this.safeFrom;
    } else
      this.nextStart = 1e9;
  }
  // `pos` must be >= any previously given `pos` for this cursor
  nodeAt(e) {
    if (e < this.nextStart)
      return null;
    for (; this.fragment && this.safeTo <= e; )
      this.nextFragment();
    if (!this.fragment)
      return null;
    for (; ; ) {
      let t = this.trees.length - 1;
      if (t < 0)
        return this.nextFragment(), null;
      let i = this.trees[t], n = this.index[t];
      if (n == i.children.length) {
        this.trees.pop(), this.start.pop(), this.index.pop();
        continue;
      }
      let s = i.children[n], o = this.start[t] + i.positions[n];
      if (o > e)
        return this.nextStart = o, null;
      if (s instanceof te) {
        if (o == e) {
          if (o < this.safeFrom)
            return null;
          let l = o + s.length;
          if (l <= this.safeTo) {
            let a = s.prop(j.lookAhead);
            if (!a || l + a < this.fragment.to)
              return s;
          }
        }
        this.index[t]++, o + s.length >= Math.max(this.safeFrom, e) && (this.trees.push(s), this.start.push(o), this.index.push(0));
      } else
        this.index[t]++, this.nextStart = o + s.length;
    }
  }
}
class mQ {
  constructor(e, t) {
    this.stream = t, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = e.tokenizers.map((i) => new us());
  }
  getActions(e) {
    let t = 0, i = null, { parser: n } = e.p, { tokenizers: s } = n, o = n.stateSlot(
      e.state,
      3
      /* ParseState.TokenizerMask */
    ), l = e.curContext ? e.curContext.hash : 0, a = 0;
    for (let h = 0; h < s.length; h++) {
      if ((1 << h & o) == 0)
        continue;
      let c = s[h], f = this.tokens[h];
      if (!(i && !c.fallback) && ((c.contextual || f.start != e.pos || f.mask != o || f.context != l) && (this.updateCachedToken(f, c, e), f.mask = o, f.context = l), f.lookAhead > f.end + 25 && (a = Math.max(f.lookAhead, a)), f.value != 0)) {
        let u = t;
        if (f.extended > -1 && (t = this.addActions(e, f.extended, f.end, t)), t = this.addActions(e, f.value, f.end, t), !c.extend && (i = f, t > u))
          break;
      }
    }
    for (; this.actions.length > t; )
      this.actions.pop();
    return a && e.setLookAhead(a), !i && e.pos == this.stream.end && (i = new us(), i.value = e.p.parser.eofTerm, i.start = i.end = e.pos, t = this.addActions(e, i.value, i.end, t)), this.mainToken = i, this.actions;
  }
  getMainToken(e) {
    if (this.mainToken)
      return this.mainToken;
    let t = new us(), { pos: i, p: n } = e;
    return t.start = i, t.end = Math.min(i + 1, n.stream.end), t.value = i == n.stream.end ? n.parser.eofTerm : 0, t;
  }
  updateCachedToken(e, t, i) {
    let n = this.stream.clipPos(i.pos);
    if (t.token(this.stream.reset(n, e), i), e.value > -1) {
      let { parser: s } = i.p;
      for (let o = 0; o < s.specialized.length; o++)
        if (s.specialized[o] == e.value) {
          let l = s.specializers[o](this.stream.read(e.start, e.end), i);
          if (l >= 0 && i.p.parser.dialect.allows(l >> 1)) {
            (l & 1) == 0 ? e.value = l >> 1 : e.extended = l >> 1;
            break;
          }
        }
    } else
      e.value = 0, e.end = this.stream.clipPos(n + 1);
  }
  putAction(e, t, i, n) {
    for (let s = 0; s < n; s += 3)
      if (this.actions[s] == e)
        return n;
    return this.actions[n++] = e, this.actions[n++] = t, this.actions[n++] = i, n;
  }
  addActions(e, t, i, n) {
    let { state: s } = e, { parser: o } = e.p, { data: l } = o;
    for (let a = 0; a < 2; a++)
      for (let h = o.stateSlot(
        s,
        a ? 2 : 1
        /* ParseState.Actions */
      ); ; h += 3) {
        if (l[h] == 65535)
          if (l[h + 1] == 1)
            h = Rt(l, h + 2);
          else {
            n == 0 && l[h + 1] == 2 && (n = this.putAction(Rt(l, h + 2), t, i, n));
            break;
          }
        l[h] == t && (n = this.putAction(Rt(l, h + 1), t, i, n));
      }
    return n;
  }
}
class gQ {
  constructor(e, t, i, n) {
    this.parser = e, this.input = t, this.ranges = n, this.recovering = 0, this.nextStackID = 9812, this.minStackPos = 0, this.reused = [], this.stoppedAt = null, this.lastBigReductionStart = -1, this.lastBigReductionSize = 0, this.bigReductionCount = 0, this.stream = new dQ(t, n), this.tokens = new mQ(e, this.stream), this.topTerm = e.top[1];
    let { from: s } = n[0];
    this.stacks = [js.start(this, e.top[0], s)], this.fragments = i.length && this.stream.end - s > e.bufferLength * 4 ? new OQ(i, e.nodeSet) : null;
  }
  get parsedPos() {
    return this.minStackPos;
  }
  // Move the parser forward. This will process all parse stacks at
  // `this.pos` and try to advance them to a further position. If no
  // stack for such a position is found, it'll start error-recovery.
  //
  // When the parse is finished, this will return a syntax tree. When
  // not, it returns `null`.
  advance() {
    let e = this.stacks, t = this.minStackPos, i = this.stacks = [], n, s;
    if (this.bigReductionCount > 300 && e.length == 1) {
      let [o] = e;
      for (; o.forceReduce() && o.stack.length && o.stack[o.stack.length - 2] >= this.lastBigReductionStart; )
        ;
      this.bigReductionCount = this.lastBigReductionSize = 0;
    }
    for (let o = 0; o < e.length; o++) {
      let l = e[o];
      for (; ; ) {
        if (this.tokens.mainToken = null, l.pos > t)
          i.push(l);
        else {
          if (this.advanceStack(l, i, e))
            continue;
          {
            n || (n = [], s = []), n.push(l);
            let a = this.tokens.getMainToken(l);
            s.push(a.value, a.end);
          }
        }
        break;
      }
    }
    if (!i.length) {
      let o = n && yQ(n);
      if (o)
        return Ie && console.log("Finish with " + this.stackID(o)), this.stackToTree(o);
      if (this.parser.strict)
        throw Ie && n && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), new SyntaxError("No parse at " + t);
      this.recovering || (this.recovering = 5);
    }
    if (this.recovering && n) {
      let o = this.stoppedAt != null && n[0].pos > this.stoppedAt ? n[0] : this.runRecovery(n, s, i);
      if (o)
        return Ie && console.log("Force-finish " + this.stackID(o)), this.stackToTree(o.forceAll());
    }
    if (this.recovering) {
      let o = this.recovering == 1 ? 1 : this.recovering * 3;
      if (i.length > o)
        for (i.sort((l, a) => a.score - l.score); i.length > o; )
          i.pop();
      i.some((l) => l.reducePos > t) && this.recovering--;
    } else if (i.length > 1) {
      e: for (let o = 0; o < i.length - 1; o++) {
        let l = i[o];
        for (let a = o + 1; a < i.length; a++) {
          let h = i[a];
          if (l.sameState(h) || l.buffer.length > 500 && h.buffer.length > 500)
            if ((l.score - h.score || l.buffer.length - h.buffer.length) > 0)
              i.splice(a--, 1);
            else {
              i.splice(o--, 1);
              continue e;
            }
        }
      }
      i.length > 12 && i.splice(
        12,
        i.length - 12
        /* Rec.MaxStackCount */
      );
    }
    this.minStackPos = i[0].pos;
    for (let o = 1; o < i.length; o++)
      i[o].pos < this.minStackPos && (this.minStackPos = i[o].pos);
    return null;
  }
  stopAt(e) {
    if (this.stoppedAt != null && this.stoppedAt < e)
      throw new RangeError("Can't move stoppedAt forward");
    this.stoppedAt = e;
  }
  // Returns an updated version of the given stack, or null if the
  // stack can't advance normally. When `split` and `stacks` are
  // given, stacks split off by ambiguous operations will be pushed to
  // `split`, or added to `stacks` if they move `pos` forward.
  advanceStack(e, t, i) {
    let n = e.pos, { parser: s } = this, o = Ie ? this.stackID(e) + " -> " : "";
    if (this.stoppedAt != null && n > this.stoppedAt)
      return e.forceReduce() ? e : null;
    if (this.fragments) {
      let h = e.curContext && e.curContext.tracker.strict, c = h ? e.curContext.hash : 0;
      for (let f = this.fragments.nodeAt(n); f; ) {
        let u = this.parser.nodeSet.types[f.type.id] == f.type ? s.getGoto(e.state, f.type.id) : -1;
        if (u > -1 && f.length && (!h || (f.prop(j.contextHash) || 0) == c))
          return e.useNode(f, u), Ie && console.log(o + this.stackID(e) + ` (via reuse of ${s.getName(f.type.id)})`), !0;
        if (!(f instanceof te) || f.children.length == 0 || f.positions[0] > 0)
          break;
        let d = f.children[0];
        if (d instanceof te && f.positions[0] == 0)
          f = d;
        else
          break;
      }
    }
    let l = s.stateSlot(
      e.state,
      4
      /* ParseState.DefaultReduce */
    );
    if (l > 0)
      return e.reduce(l), Ie && console.log(o + this.stackID(e) + ` (via always-reduce ${s.getName(
        l & 65535
        /* Action.ValueMask */
      )})`), !0;
    if (e.stack.length >= 8400)
      for (; e.stack.length > 6e3 && e.forceReduce(); )
        ;
    let a = this.tokens.getActions(e);
    for (let h = 0; h < a.length; ) {
      let c = a[h++], f = a[h++], u = a[h++], d = h == a.length || !i, p = d ? e : e.split(), O = this.tokens.mainToken;
      if (p.apply(c, f, O ? O.start : p.pos, u), Ie && console.log(o + this.stackID(p) + ` (via ${(c & 65536) == 0 ? "shift" : `reduce of ${s.getName(
        c & 65535
        /* Action.ValueMask */
      )}`} for ${s.getName(f)} @ ${n}${p == e ? "" : ", split"})`), d)
        return !0;
      p.pos > n ? t.push(p) : i.push(p);
    }
    return !1;
  }
  // Advance a given stack forward as far as it will go. Returns the
  // (possibly updated) stack if it got stuck, or null if it moved
  // forward and was given to `pushStackDedup`.
  advanceFully(e, t) {
    let i = e.pos;
    for (; ; ) {
      if (!this.advanceStack(e, null, null))
        return !1;
      if (e.pos > i)
        return uu(e, t), !0;
    }
  }
  runRecovery(e, t, i) {
    let n = null, s = !1;
    for (let o = 0; o < e.length; o++) {
      let l = e[o], a = t[o << 1], h = t[(o << 1) + 1], c = Ie ? this.stackID(l) + " -> " : "";
      if (l.deadEnd && (s || (s = !0, l.restart(), Ie && console.log(c + this.stackID(l) + " (restarted)"), this.advanceFully(l, i))))
        continue;
      let f = l.split(), u = c;
      for (let d = 0; d < 10 && f.forceReduce() && (Ie && console.log(u + this.stackID(f) + " (via force-reduce)"), !this.advanceFully(f, i)); d++)
        Ie && (u = this.stackID(f) + " -> ");
      for (let d of l.recoverByInsert(a))
        Ie && console.log(c + this.stackID(d) + " (via recover-insert)"), this.advanceFully(d, i);
      this.stream.end > l.pos ? (h == l.pos && (h++, a = 0), l.recoverByDelete(a, h), Ie && console.log(c + this.stackID(l) + ` (via recover-delete ${this.parser.getName(a)})`), uu(l, i)) : (!n || n.score < l.score) && (n = l);
    }
    return n;
  }
  // Convert the stack's buffer to a syntax tree.
  stackToTree(e) {
    return e.close(), te.build({
      buffer: Gs.create(e),
      nodeSet: this.parser.nodeSet,
      topID: this.topTerm,
      maxBufferLength: this.parser.bufferLength,
      reused: this.reused,
      start: this.ranges[0].from,
      length: e.pos - this.ranges[0].from,
      minRepeatType: this.parser.minRepeatTerm
    });
  }
  stackID(e) {
    let t = (rl || (rl = /* @__PURE__ */ new WeakMap())).get(e);
    return t || rl.set(e, t = String.fromCodePoint(this.nextStackID++)), t + e;
  }
}
function uu(r, e) {
  for (let t = 0; t < e.length; t++) {
    let i = e[t];
    if (i.pos == r.pos && i.sameState(r)) {
      e[t].score < r.score && (e[t] = r);
      return;
    }
  }
  e.push(r);
}
class bQ {
  constructor(e, t, i) {
    this.source = e, this.flags = t, this.disabled = i;
  }
  allows(e) {
    return !this.disabled || this.disabled[e] == 0;
  }
}
const nl = (r) => r;
class Em {
  /**
  Define a context tracker.
  */
  constructor(e) {
    this.start = e.start, this.shift = e.shift || nl, this.reduce = e.reduce || nl, this.reuse = e.reuse || nl, this.hash = e.hash || (() => 0), this.strict = e.strict !== !1;
  }
}
class tr extends wh {
  /**
  @internal
  */
  constructor(e) {
    if (super(), this.wrappers = [], e.version != 14)
      throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);
    let t = e.nodeNames.split(" ");
    this.minRepeatTerm = t.length;
    for (let l = 0; l < e.repeatNodeCount; l++)
      t.push("");
    let i = Object.keys(e.topRules).map((l) => e.topRules[l][1]), n = [];
    for (let l = 0; l < t.length; l++)
      n.push([]);
    function s(l, a, h) {
      n[l].push([a, a.deserialize(String(h))]);
    }
    if (e.nodeProps)
      for (let l of e.nodeProps) {
        let a = l[0];
        typeof a == "string" && (a = j[a]);
        for (let h = 1; h < l.length; ) {
          let c = l[h++];
          if (c >= 0)
            s(c, a, l[h++]);
          else {
            let f = l[h + -c];
            for (let u = -c; u > 0; u--)
              s(l[h++], a, f);
            h++;
          }
        }
      }
    this.nodeSet = new pn(t.map((l, a) => Se.define({
      name: a >= this.minRepeatTerm ? void 0 : l,
      id: a,
      props: n[a],
      top: i.indexOf(a) > -1,
      error: a == 0,
      skipped: e.skippedNodes && e.skippedNodes.indexOf(a) > -1
    }))), e.propSources && (this.nodeSet = this.nodeSet.extend(...e.propSources)), this.strict = !1, this.bufferLength = em;
    let o = $r(e.tokenData);
    this.context = e.context, this.specializerSpecs = e.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
    for (let l = 0; l < this.specializerSpecs.length; l++)
      this.specialized[l] = this.specializerSpecs[l].term;
    this.specializers = this.specializerSpecs.map(du), this.states = $r(e.states, Uint32Array), this.data = $r(e.stateData), this.goto = $r(e.goto), this.maxTerm = e.maxTerm, this.tokenizers = e.tokenizers.map((l) => typeof l == "number" ? new Ii(o, l) : l), this.topRules = e.topRules, this.dialects = e.dialects || {}, this.dynamicPrecedences = e.dynamicPrecedences || null, this.tokenPrecTable = e.tokenPrec, this.termNames = e.termNames || null, this.maxNode = this.nodeSet.types.length - 1, this.dialect = this.parseDialect(), this.top = this.topRules[Object.keys(this.topRules)[0]];
  }
  createParse(e, t, i) {
    let n = new gQ(this, e, t, i);
    for (let s of this.wrappers)
      n = s(n, e, t, i);
    return n;
  }
  /**
  Get a goto table entry @internal
  */
  getGoto(e, t, i = !1) {
    let n = this.goto;
    if (t >= n[0])
      return -1;
    for (let s = n[t + 1]; ; ) {
      let o = n[s++], l = o & 1, a = n[s++];
      if (l && i)
        return a;
      for (let h = s + (o >> 1); s < h; s++)
        if (n[s] == e)
          return a;
      if (l)
        return -1;
    }
  }
  /**
  Check if this state has an action for a given terminal @internal
  */
  hasAction(e, t) {
    let i = this.data;
    for (let n = 0; n < 2; n++)
      for (let s = this.stateSlot(
        e,
        n ? 2 : 1
        /* ParseState.Actions */
      ), o; ; s += 3) {
        if ((o = i[s]) == 65535)
          if (i[s + 1] == 1)
            o = i[s = Rt(i, s + 2)];
          else {
            if (i[s + 1] == 2)
              return Rt(i, s + 2);
            break;
          }
        if (o == t || o == 0)
          return Rt(i, s + 1);
      }
    return 0;
  }
  /**
  @internal
  */
  stateSlot(e, t) {
    return this.states[e * 6 + t];
  }
  /**
  @internal
  */
  stateFlag(e, t) {
    return (this.stateSlot(
      e,
      0
      /* ParseState.Flags */
    ) & t) > 0;
  }
  /**
  @internal
  */
  validAction(e, t) {
    return !!this.allActions(e, (i) => i == t ? !0 : null);
  }
  /**
  @internal
  */
  allActions(e, t) {
    let i = this.stateSlot(
      e,
      4
      /* ParseState.DefaultReduce */
    ), n = i ? t(i) : void 0;
    for (let s = this.stateSlot(
      e,
      1
      /* ParseState.Actions */
    ); n == null; s += 3) {
      if (this.data[s] == 65535)
        if (this.data[s + 1] == 1)
          s = Rt(this.data, s + 2);
        else
          break;
      n = t(Rt(this.data, s + 1));
    }
    return n;
  }
  /**
  Get the states that can follow this one through shift actions or
  goto jumps. @internal
  */
  nextStates(e) {
    let t = [];
    for (let i = this.stateSlot(
      e,
      1
      /* ParseState.Actions */
    ); ; i += 3) {
      if (this.data[i] == 65535)
        if (this.data[i + 1] == 1)
          i = Rt(this.data, i + 2);
        else
          break;
      if ((this.data[i + 2] & 1) == 0) {
        let n = this.data[i + 1];
        t.some((s, o) => o & 1 && s == n) || t.push(this.data[i], n);
      }
    }
    return t;
  }
  /**
  Configure the parser. Returns a new parser instance that has the
  given settings modified. Settings not provided in `config` are
  kept from the original parser.
  */
  configure(e) {
    let t = Object.assign(Object.create(tr.prototype), this);
    if (e.props && (t.nodeSet = this.nodeSet.extend(...e.props)), e.top) {
      let i = this.topRules[e.top];
      if (!i)
        throw new RangeError(`Invalid top rule name ${e.top}`);
      t.top = i;
    }
    return e.tokenizers && (t.tokenizers = this.tokenizers.map((i) => {
      let n = e.tokenizers.find((s) => s.from == i);
      return n ? n.to : i;
    })), e.specializers && (t.specializers = this.specializers.slice(), t.specializerSpecs = this.specializerSpecs.map((i, n) => {
      let s = e.specializers.find((l) => l.from == i.external);
      if (!s)
        return i;
      let o = Object.assign(Object.assign({}, i), { external: s.to });
      return t.specializers[n] = du(o), o;
    })), e.contextTracker && (t.context = e.contextTracker), e.dialect && (t.dialect = this.parseDialect(e.dialect)), e.strict != null && (t.strict = e.strict), e.wrap && (t.wrappers = t.wrappers.concat(e.wrap)), e.bufferLength != null && (t.bufferLength = e.bufferLength), t;
  }
  /**
  Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
  are registered for this parser.
  */
  hasWrappers() {
    return this.wrappers.length > 0;
  }
  /**
  Returns the name associated with a given term. This will only
  work for all terms when the parser was generated with the
  `--names` option. By default, only the names of tagged terms are
  stored.
  */
  getName(e) {
    return this.termNames ? this.termNames[e] : String(e <= this.maxNode && this.nodeSet.types[e].name || e);
  }
  /**
  The eof term id is always allocated directly after the node
  types. @internal
  */
  get eofTerm() {
    return this.maxNode + 1;
  }
  /**
  The type of top node produced by the parser.
  */
  get topNode() {
    return this.nodeSet.types[this.top[1]];
  }
  /**
  @internal
  */
  dynamicPrecedence(e) {
    let t = this.dynamicPrecedences;
    return t == null ? 0 : t[e] || 0;
  }
  /**
  @internal
  */
  parseDialect(e) {
    let t = Object.keys(this.dialects), i = t.map(() => !1);
    if (e)
      for (let s of e.split(" ")) {
        let o = t.indexOf(s);
        o >= 0 && (i[o] = !0);
      }
    let n = null;
    for (let s = 0; s < t.length; s++)
      if (!i[s])
        for (let o = this.dialects[t[s]], l; (l = this.data[o++]) != 65535; )
          (n || (n = new Uint8Array(this.maxTerm + 1)))[l] = 1;
    return new bQ(e, i, n);
  }
  /**
  Used by the output of the parser generator. Not available to
  user code. @hide
  */
  static deserialize(e) {
    return new tr(e);
  }
}
function Rt(r, e) {
  return r[e] | r[e + 1] << 16;
}
function yQ(r) {
  let e = null;
  for (let t of r) {
    let i = t.p.stoppedAt;
    (t.pos == t.p.stream.end || i != null && t.pos > i) && t.p.parser.stateFlag(
      t.state,
      2
      /* StateFlag.Accepting */
    ) && (!e || e.score < t.score) && (e = t);
  }
  return e;
}
function du(r) {
  if (r.external) {
    let e = r.extend ? 1 : 0;
    return (t, i) => r.external(t, i) << 1 | e;
  }
  return r.get;
}
const SQ = 55, wQ = 1, xQ = 56, kQ = 2, QQ = 57, vQ = 3, pu = 4, $Q = 5, Mh = 6, zm = 7, Dm = 8, _m = 9, Bm = 10, PQ = 11, CQ = 12, TQ = 13, sl = 58, AQ = 14, MQ = 15, Ou = 59, Im = 21, ZQ = 23, Vm = 24, XQ = 25, Za = 27, qm = 28, RQ = 29, LQ = 32, EQ = 35, zQ = 37, DQ = 38, _Q = 0, BQ = 1, IQ = {
  area: !0,
  base: !0,
  br: !0,
  col: !0,
  command: !0,
  embed: !0,
  frame: !0,
  hr: !0,
  img: !0,
  input: !0,
  keygen: !0,
  link: !0,
  meta: !0,
  param: !0,
  source: !0,
  track: !0,
  wbr: !0,
  menuitem: !0
}, VQ = {
  dd: !0,
  li: !0,
  optgroup: !0,
  option: !0,
  p: !0,
  rp: !0,
  rt: !0,
  tbody: !0,
  td: !0,
  tfoot: !0,
  th: !0,
  tr: !0
}, mu = {
  dd: { dd: !0, dt: !0 },
  dt: { dd: !0, dt: !0 },
  li: { li: !0 },
  option: { option: !0, optgroup: !0 },
  optgroup: { optgroup: !0 },
  p: {
    address: !0,
    article: !0,
    aside: !0,
    blockquote: !0,
    dir: !0,
    div: !0,
    dl: !0,
    fieldset: !0,
    footer: !0,
    form: !0,
    h1: !0,
    h2: !0,
    h3: !0,
    h4: !0,
    h5: !0,
    h6: !0,
    header: !0,
    hgroup: !0,
    hr: !0,
    menu: !0,
    nav: !0,
    ol: !0,
    p: !0,
    pre: !0,
    section: !0,
    table: !0,
    ul: !0
  },
  rp: { rp: !0, rt: !0 },
  rt: { rp: !0, rt: !0 },
  tbody: { tbody: !0, tfoot: !0 },
  td: { td: !0, th: !0 },
  tfoot: { tbody: !0 },
  th: { td: !0, th: !0 },
  thead: { tbody: !0, tfoot: !0 },
  tr: { tr: !0 }
};
function qQ(r) {
  return r == 45 || r == 46 || r == 58 || r >= 65 && r <= 90 || r == 95 || r >= 97 && r <= 122 || r >= 161;
}
let gu = null, bu = null, yu = 0;
function Xa(r, e) {
  let t = r.pos + e;
  if (yu == t && bu == r) return gu;
  let i = r.peek(e), n = "";
  for (; qQ(i); )
    n += String.fromCharCode(i), i = r.peek(++e);
  return bu = r, yu = t, gu = n ? n.toLowerCase() : i == YQ || i == NQ ? void 0 : null;
}
const Ym = 60, Fs = 62, Zh = 47, YQ = 63, NQ = 33, WQ = 45;
function Su(r, e) {
  this.name = r, this.parent = e;
}
const jQ = [Mh, Bm, zm, Dm, _m], GQ = new Em({
  start: null,
  shift(r, e, t, i) {
    return jQ.indexOf(e) > -1 ? new Su(Xa(i, 1) || "", r) : r;
  },
  reduce(r, e) {
    return e == Im && r ? r.parent : r;
  },
  reuse(r, e, t, i) {
    let n = e.type.id;
    return n == Mh || n == zQ ? new Su(Xa(i, 1) || "", r) : r;
  },
  strict: !1
}), UQ = new Fe((r, e) => {
  if (r.next != Ym) {
    r.next < 0 && e.context && r.acceptToken(sl);
    return;
  }
  r.advance();
  let t = r.next == Zh;
  t && r.advance();
  let i = Xa(r, 0);
  if (i === void 0) return;
  if (!i) return r.acceptToken(t ? MQ : AQ);
  let n = e.context ? e.context.name : null;
  if (t) {
    if (i == n) return r.acceptToken(PQ);
    if (n && VQ[n]) return r.acceptToken(sl, -2);
    if (e.dialectEnabled(_Q)) return r.acceptToken(CQ);
    for (let s = e.context; s; s = s.parent) if (s.name == i) return;
    r.acceptToken(TQ);
  } else {
    if (i == "script") return r.acceptToken(zm);
    if (i == "style") return r.acceptToken(Dm);
    if (i == "textarea") return r.acceptToken(_m);
    if (IQ.hasOwnProperty(i)) return r.acceptToken(Bm);
    n && mu[n] && mu[n][i] ? r.acceptToken(sl, -1) : r.acceptToken(Mh);
  }
}, { contextual: !0 }), FQ = new Fe((r) => {
  for (let e = 0, t = 0; ; t++) {
    if (r.next < 0) {
      t && r.acceptToken(Ou);
      break;
    }
    if (r.next == WQ)
      e++;
    else if (r.next == Fs && e >= 2) {
      t >= 3 && r.acceptToken(Ou, -2);
      break;
    } else
      e = 0;
    r.advance();
  }
});
function HQ(r) {
  for (; r; r = r.parent)
    if (r.name == "svg" || r.name == "math") return !0;
  return !1;
}
const KQ = new Fe((r, e) => {
  if (r.next == Zh && r.peek(1) == Fs) {
    let t = e.dialectEnabled(BQ) || HQ(e.context);
    r.acceptToken(t ? $Q : pu, 2);
  } else r.next == Fs && r.acceptToken(pu, 1);
});
function Xh(r, e, t) {
  let i = 2 + r.length;
  return new Fe((n) => {
    for (let s = 0, o = 0, l = 0; ; l++) {
      if (n.next < 0) {
        l && n.acceptToken(e);
        break;
      }
      if (s == 0 && n.next == Ym || s == 1 && n.next == Zh || s >= 2 && s < i && n.next == r.charCodeAt(s - 2))
        s++, o++;
      else if (s == i && n.next == Fs) {
        l > o ? n.acceptToken(e, -o) : n.acceptToken(t, -(o - 2));
        break;
      } else if ((n.next == 10 || n.next == 13) && l) {
        n.acceptToken(e, 1);
        break;
      } else
        s = o = 0;
      n.advance();
    }
  });
}
const JQ = Xh("script", SQ, wQ), ev = Xh("style", xQ, kQ), tv = Xh("textarea", QQ, vQ), iv = sr({
  "Text RawText IncompleteTag IncompleteCloseTag": m.content,
  "StartTag StartCloseTag SelfClosingEndTag EndTag": m.angleBracket,
  TagName: m.tagName,
  "MismatchedCloseTag/TagName": [m.tagName, m.invalid],
  AttributeName: m.attributeName,
  "AttributeValue UnquotedAttributeValue": m.attributeValue,
  Is: m.definitionOperator,
  "EntityReference CharacterReference": m.character,
  Comment: m.blockComment,
  ProcessingInst: m.processingInstruction,
  DoctypeDecl: m.documentMeta
}), rv = tr.deserialize({
  version: 14,
  states: ",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&r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yO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",
  goto: "%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",
  nodeNames: "⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",
  maxTerm: 68,
  context: GQ,
  nodeProps: [
    ["closedBy", -10, 1, 2, 3, 7, 8, 9, 10, 11, 12, 13, "EndTag", 6, "EndTag SelfClosingEndTag", -4, 22, 31, 34, 37, "CloseTag"],
    ["openedBy", 4, "StartTag StartCloseTag", 5, "StartTag", -4, 30, 33, 36, 38, "OpenTag"],
    ["group", -10, 14, 15, 18, 19, 20, 21, 40, 41, 42, 43, "Entity", 17, "Entity TextContent", -3, 29, 32, 35, "TextContent Entity"],
    ["isolate", -11, 22, 30, 31, 33, 34, 36,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;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!<TXjSaP!b`!dpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",
  tokenizers: [JQ, ev, tv, KQ, UQ, FQ, 0, 1, 2, 3, 4, 5],
  topRules: { Document: [0, 16] },
  dialects: { noMatch: 0, selfClosing: 515 },
  tokenPrec: 517
});
function Nm(r, e) {
  let t = /* @__PURE__ */ Object.create(null);
  for (let i of r.getChildren(Vm)) {
    let n = i.getChild(XQ), s = i.getChild(Za) || i.getChild(qm);
    n && (t[e.read(n.from, n.to)] = s ? s.type.id == Za ? e.read(s.from + 1, s.to - 1) : e.read(s.from, s.to) : "");
  }
  return t;
}
function wu(r, e) {
  let t = r.getChild(ZQ);
  return t ? e.read(t.from, t.to) : " ";
}
function ol(r, e, t) {
  let i;
  for (let n of t)
    if (!n.attrs || n.attrs(i || (i = Nm(r.node.parent.firstChild, e))))
      return { parser: n.parser };
  return null;
}
function Wm(r = [], e = []) {
  let t = [], i = [], n = [], s = [];
  for (let l of r)
    (l.tag == "script" ? t : l.tag == "style" ? i : l.tag == "textarea" ? n : s).push(l);
  let o = e.length ? /* @__PURE__ */ Object.create(null) : null;
  for (let l of e) (o[l.name] || (o[l.name] = [])).push(l);
  return sm((l, a) => {
    let h = l.type.id;
    if (h == RQ) return ol(l, a, t);
    if (h == LQ) return ol(l, a, i);
    if (h == EQ) return ol(l, a, n);
    if (h == Im && s.length) {
      let c = l.node, f = c.firstChild, u = f && wu(f, a), d;
      if (u) {
        for (let p of s)
          if (p.tag == u && (!p.attrs || p.attrs(d || (d = Nm(f, a))))) {
            let O = c.lastChild, g = O.type.id == DQ ? O.from : c.to;
            if (g > f.to)
              return { parser: p.parser, overlay: [{ from: f.to, to: g }] };
          }
      }
    }
    if (o && h == Vm) {
      let c = l.node, f;
      if (f = c.firstChild) {
        let u = o[a.read(f.from, f.to)];
        if (u) for (let d of u) {
          if (d.tagName && d.tagName != wu(c.parent, a)) continue;
          let p = c.lastChild;
          if (p.type.id == Za) {
            let O = p.from + 1, g = p.lastChild, b = p.to - (g && g.isError ? 0 : 1);
            if (b > O) return { parser: d.parser, overlay: [{ from: O, to: b }] };
          } else if (p.type.id == qm)
            return { parser: d.parser, overlay: [{ from: p.from, to: p.to }] };
        }
      }
    }
    return null;
  });
}
const nv = 122, xu = 1, sv = 123, ov = 124, jm = 2, lv = 125, av = 3, hv = 4, Gm = [
  9,
  10,
  11,
  12,
  13,
  32,
  133,
  160,
  5760,
  8192,
  8193,
  8194,
  8195,
  8196,
  8197,
  8198,
  8199,
  8200,
  8201,
  8202,
  8232,
  8233,
  8239,
  8287,
  12288
], cv = 58, fv = 40, Um = 95, uv = 91, ds = 45, dv = 46, pv = 35, Ov = 37, mv = 38, gv = 92, bv = 10, yv = 42;
function nn(r) {
  return r >= 65 && r <= 90 || r >= 97 && r <= 122 || r >= 161;
}
function Rh(r) {
  return r >= 48 && r <= 57;
}
function ku(r) {
  return Rh(r) || r >= 97 && r <= 102 || r >= 65 && r <= 70;
}
const Fm = (r, e, t) => (i, n) => {
  for (let s = !1, o = 0, l = 0; ; l++) {
    let { next: a } = i;
    if (nn(a) || a == ds || a == Um || s && Rh(a))
      !s && (a != ds || l > 0) && (s = !0), o === l && a == ds && o++, i.advance();
    else if (a == gv && i.peek(1) != bv) {
      if (i.advance(), ku(i.next)) {
        do
          i.advance();
        while (ku(i.next));
        i.next == 32 && i.advance();
      } else i.next > -1 && i.advance();
      s = !0;
    } else {
      s && i.acceptToken(
        o == 2 && n.canShift(jm) ? e : a == fv ? t : r
      );
      break;
    }
  }
}, Sv = new Fe(
  Fm(sv, jm, ov)
), wv = new Fe(
  Fm(lv, av, hv)
), xv = new Fe((r) => {
  if (Gm.includes(r.peek(-1))) {
    let { next: e } = r;
    (nn(e) || e == Um || e == pv || e == dv || e == yv || e == uv || e == cv && nn(r.peek(1)) || e == ds || e == mv) && r.acceptToken(nv);
  }
}), kv = new Fe((r) => {
  if (!Gm.includes(r.peek(-1))) {
    let { next: e } = r;
    if (e == Ov && (r.advance(), r.acceptToken(xu)), nn(e)) {
      do
        r.advance();
      while (nn(r.next) || Rh(r.next));
      r.acceptToken(xu);
    }
  }
}), Qv = sr({
  "AtKeyword import charset namespace keyframes media supports": m.definitionKeyword,
  "from to selector": m.keyword,
  NamespaceName: m.namespace,
  KeyframeName: m.labelName,
  KeyframeRangeName: m.operatorKeyword,
  TagName: m.tagName,
  ClassName: m.className,
  PseudoClassName: m.constant(m.className),
  IdName: m.labelName,
  "FeatureName PropertyName": m.propertyName,
  AttributeName: m.attributeName,
  NumberLiteral: m.number,
  KeywordQuery: m.keyword,
  UnaryQueryOp: m.operatorKeyword,
  "CallTag ValueName": m.atom,
  VariableName: m.variableName,
  Callee: m.operatorKeyword,
  Unit: m.unit,
  "UniversalSelector NestingSelector": m.definitionOperator,
  "MatchOp CompareOp": m.compareOperator,
  "ChildOp SiblingOp, LogicOp": m.logicOperator,
  BinOp: m.arithmeticOperator,
  Important: m.modifier,
  Comment: m.blockComment,
  ColorLiteral: m.color,
  "ParenthesizedContent StringLiteral": m.string,
  ":": m.punctuation,
  "PseudoOp #": m.derefOperator,
  "; ,": m.separator,
  "( )": m.paren,
  "[ ]": m.squareBracket,
  "{ }": m.brace
}), vv = { __proto__: null, lang: 38, "nth-child": 38, "nth-last-child": 38, "nth-of-type": 38, "nth-last-of-type": 38, dir: 38, "host-context": 38, if: 84, url: 124, "url-prefix": 124, domain: 124, regexp: 124 }, $v = { __proto__: null, or: 98, and: 98, not: 106, only: 106, layer: 170 }, Pv = { __proto__: null, selector: 112, layer: 166 }, Cv = { __proto__: null, "@import": 162, "@media": 174, "@charset": 178, "@namespace": 182, "@keyframes": 188, "@supports": 200, "@scope": 204 }, Tv = { __proto__: null, to: 207 }, Av = tr.deserialize({
  version: 14,
  states: "EbQYQdOOO#qQdOOP#xO`OOOOQP'#Cf'#CfOOQP'#Ce'#CeO#}QdO'#ChO$nQaO'#CcO$xQdO'#CkO%TQdO'#DpO%YQdO'#DrO%_QdO'#DuO%_QdO'#DxOOQP'#FV'#FVO&eQhO'#EhOOQS'#FU'#FUOOQS'#Ek'#EkQYQdOOO&lQdO'#EOO&PQhO'#EUO&lQdO'#EWO'aQdO'#EYO'lQdO'#E]O'tQhO'#EcO(VQdO'#EeO(bQaO'#CfO)VQ`O'#D{O)[Q`O'#F`O)gQdO'#F`QOQ`OOP)qO&jO'#CaPOOO)C@t)C@tOOQP'#Cj'#CjOOQP,59S,59SO#}QdO,59SO)|QdO,59VO%TQdO,5:[O%YQdO,5:^O%_QdO,5:aO%_QdO,5:cO%_QdO,5:dO%_QdO'#ErO*XQ`O,58}O*aQdO'#DzOOQS,58},58}OOQP'#Cn'#CnOOQO'#Dn'#DnOOQP,59V,59VO*hQ`O,59VO*mQ`O,59VOOQP'#Dq'#DqOOQP,5:[,5:[OOQO'#Ds'#DsO*rQpO,5:^O+]QaO,5:aO+sQaO,5:dOOQW'#DZ'#DZO,ZQhO'#DdO,xQhO'#FaO'tQhO'#DbO-WQ`O'#DhOOQW'#F['#F[O-]Q`O,5;SO-eQ`O'#DeOOQS-E8i-E8iOOQ['#Cs'#CsO-jQdO'#CtO.QQdO'#CzO.hQdO'#C}O/OQ!pO'#DPO1RQ!jO,5:jOOQO'#DU'#DUO*mQ`O'#DTO1cQ!nO'#FXO3`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YvQ#ZwQ#[xQ$]!vQ$m#`R&b%mR$q#aQ!gaQ!oc[#q!c!d!e#t#v#xQ$a!zd$o#a$p$s%q%u%z&d&l&x'QQ$r#cQ%R#{S%g$a%iQ%l$kQ&^%hR&p&P]#s!c!d!e#t#v#xW!Z]b!g$PQ!ufQ#f!YQ#l![Q$v#iQ$w#jQ$z#mS%V$R%XR&i%xQ#h!YQ%w$tR&w&hR$|#mR$n#`QlPR#_zQ!_]Q!nbQ$O!gR%U$P",
  nodeNames: "⚠ Unit VariableName VariableName QueryCallee Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector . ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue AtKeyword # ; ] [ BracketedValue } { BracedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee IfExpression if ArgList IfBranch KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp ComparisonQuery CompareOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector ParenthesizedSelector CallQuery ArgList , CallLiteral CallTag ParenthesizedContent PseudoClassName ArgList IdSelector IdName AttributeSelector AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp Block Declaration PropertyName Important ImportStatement import Layer layer LayerName layer MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports ScopeStatement scope to AtRule Styles",
  maxTerm: 143,
  nodeProps: [
    ["isolate", -2, 5, 36, ""],
    ["openedBy", 20, "(", 28, "[", 31, "{"],
    ["closedBy", 21, ")", 29, "]", 32, "}"]
  ],
  propSources: [Qv],
  skippedNodes: [0, 5, 106],
  repeatNodeCount: 15,
  tokenData: "JQ~R!YOX$qX^%i^p$qpq%iqr({rs-ust/itu6Wuv$qvw7Qwx7cxy9Qyz9cz{9h{|:R|}>t}!O?V!O!P?t!P!Q@]!Q![AU![!]BP!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%Qz![%Q![!]Bh!];'S%Q;'S;=`%c<%lO%QbBoSaQ!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QjCQSkYOy%Qz;'S%Q;'S;=`%c<%lO%QhCcU!TWOy%Qz!_%Q!_!`Cu!`;'S%Q;'S;=`%c<%lO%QhC|S!TW!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QlDaS!TW!hSOy%Qz;'S%Q;'S;=`%c<%lO%QjDtV!jQ!TWOy%Qz!_%Q!_!`Cu!`!aEZ!a;'S%Q;'S;=`%c<%lO%QbEbS!jQ!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QjEqYOy%Qz}%Q}!OFa!O!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjFfW!a`Oy%Qz!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjGV[iY!a`Oy%Qz}%Q}!OGO!O!Q%Q!Q![GO![!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjHQSmYOy%Qz;'S%Q;'S;=`%c<%lO%QnHcSl^Oy%Qz;'S%Q;'S;=`%c<%lO%QjHtSpYOy%Qz;'S%Q;'S;=`%c<%lO%QjIVSoYOy%Qz;'S%Q;'S;=`%c<%lO%QfIhU!mQOy%Qz!_%Q!_!`6m!`;'S%Q;'S;=`%c<%lO%Q`I}P;=`<%l$q",
  tokenizers: [xv, kv, Sv, wv, 1, 2, 3, 4, new Us("m~RRYZ[z{a~~g~aO#v~~dP!P!Qg~lO#w~~", 28, 129)],
  topRules: { StyleSheet: [0, 6], Styles: [1, 105] },
  specialized: [{ term: 124, get: (r) => vv[r] || -1 }, { term: 125, get: (r) => $v[r] || -1 }, { term: 4, get: (r) => Pv[r] || -1 }, { term: 25, get: (r) => Cv[r] || -1 }, { term: 123, get: (r) => Tv[r] || -1 }],
  tokenPrec: 1963
});
let ll = null;
function al() {
  if (!ll && typeof document == "object" && document.body) {
    let { style: r } = document.body, e = [], t = /* @__PURE__ */ new Set();
    for (let i in r)
      i != "cssText" && i != "cssFloat" && typeof r[i] == "string" && (/[A-Z]/.test(i) && (i = i.replace(/[A-Z]/g, (n) => "-" + n.toLowerCase())), t.has(i) || (e.push(i), t.add(i)));
    ll = e.sort().map((i) => ({ type: "property", label: i, apply: i + ": " }));
  }
  return ll || [];
}
const Qu = /* @__PURE__ */ [
  "active",
  "after",
  "any-link",
  "autofill",
  "backdrop",
  "before",
  "checked",
  "cue",
  "default",
  "defined",
  "disabled",
  "empty",
  "enabled",
  "file-selector-button",
  "first",
  "first-child",
  "first-letter",
  "first-line",
  "first-of-type",
  "focus",
  "focus-visible",
  "focus-within",
  "fullscreen",
  "has",
  "host",
  "host-context",
  "hover",
  "in-range",
  "indeterminate",
  "invalid",
  "is",
  "lang",
  "last-child",
  "last-of-type",
  "left",
  "link",
  "marker",
  "modal",
  "not",
  "nth-child",
  "nth-last-child",
  "nth-last-of-type",
  "nth-of-type",
  "only-child",
  "only-of-type",
  "optional",
  "out-of-range",
  "part",
  "placeholder",
  "placeholder-shown",
  "read-only",
  "read-write",
  "required",
  "right",
  "root",
  "scope",
  "selection",
  "slotted",
  "target",
  "target-text",
  "valid",
  "visited",
  "where"
].map((r) => ({ type: "class", label: r })), vu = /* @__PURE__ */ [
  "above",
  "absolute",
  "activeborder",
  "additive",
  "activecaption",
  "after-white-space",
  "ahead",
  "alias",
  "all",
  "all-scroll",
  "alphabetic",
  "alternate",
  "always",
  "antialiased",
  "appworkspace",
  "asterisks",
  "attr",
  "auto",
  "auto-flow",
  "avoid",
  "avoid-column",
  "avoid-page",
  "avoid-region",
  "axis-pan",
  "background",
  "backwards",
  "baseline",
  "below",
  "bidi-override",
  "blink",
  "block",
  "block-axis",
  "bold",
  "bolder",
  "border",
  "border-box",
  "both",
  "bottom",
  "break",
  "break-all",
  "break-word",
  "bullets",
  "button",
  "button-bevel",
  "buttonface",
  "buttonhighlight",
  "buttonshadow",
  "buttontext",
  "calc",
  "capitalize",
  "caps-lock-indicator",
  "caption",
  "captiontext",
  "caret",
  "cell",
  "center",
  "checkbox",
  "circle",
  "cjk-decimal",
  "clear",
  "clip",
  "close-quote",
  "col-resize",
  "collapse",
  "color",
  "color-burn",
  "color-dodge",
  "column",
  "column-reverse",
  "compact",
  "condensed",
  "contain",
  "content",
  "contents",
  "content-box",
  "context-menu",
  "continuous",
  "copy",
  "counter",
  "counters",
  "cover",
  "crop",
  "cross",
  "crosshair",
  "currentcolor",
  "cursive",
  "cyclic",
  "darken",
  "dashed",
  "decimal",
  "decimal-leading-zero",
  "default",
  "default-button",
  "dense",
  "destination-atop",
  "destination-in",
  "destination-out",
  "destination-over",
  "difference",
  "disc",
  "discard",
  "disclosure-closed",
  "disclosure-open",
  "document",
  "dot-dash",
  "dot-dot-dash",
  "dotted",
  "double",
  "down",
  "e-resize",
  "ease",
  "ease-in",
  "ease-in-out",
  "ease-out",
  "element",
  "ellipse",
  "ellipsis",
  "embed",
  "end",
  "ethiopic-abegede-gez",
  "ethiopic-halehame-aa-er",
  "ethiopic-halehame-gez",
  "ew-resize",
  "exclusion",
  "expanded",
  "extends",
  "extra-condensed",
  "extra-expanded",
  "fantasy",
  "fast",
  "fill",
  "fill-box",
  "fixed",
  "flat",
  "flex",
  "flex-end",
  "flex-start",
  "footnotes",
  "forwards",
  "from",
  "geometricPrecision",
  "graytext",
  "grid",
  "groove",
  "hand",
  "hard-light",
  "help",
  "hidden",
  "hide",
  "higher",
  "highlight",
  "highlighttext",
  "horizontal",
  "hsl",
  "hsla",
  "hue",
  "icon",
  "ignore",
  "inactiveborder",
  "inactivecaption",
  "inactivecaptiontext",
  "infinite",
  "infobackground",
  "infotext",
  "inherit",
  "initial",
  "inline",
  "inline-axis",
  "inline-block",
  "inline-flex",
  "inline-grid",
  "inline-table",
  "inset",
  "inside",
  "intrinsic",
  "invert",
  "italic",
  "justify",
  "keep-all",
  "landscape",
  "large",
  "larger",
  "left",
  "level",
  "lighter",
  "lighten",
  "line-through",
  "linear",
  "linear-gradient",
  "lines",
  "list-item",
  "listbox",
  "listitem",
  "local",
  "logical",
  "loud",
  "lower",
  "lower-hexadecimal",
  "lower-latin",
  "lower-norwegian",
  "lowercase",
  "ltr",
  "luminosity",
  "manipulation",
  "match",
  "matrix",
  "matrix3d",
  "medium",
  "menu",
  "menutext",
  "message-box",
  "middle",
  "min-intrinsic",
  "mix",
  "monospace",
  "move",
  "multiple",
  "multiple_mask_images",
  "multiply",
  "n-resize",
  "narrower",
  "ne-resize",
  "nesw-resize",
  "no-close-quote",
  "no-drop",
  "no-open-quote",
  "no-repeat",
  "none",
  "normal",
  "not-allowed",
  "nowrap",
  "ns-resize",
  "numbers",
  "numeric",
  "nw-resize",
  "nwse-resize",
  "oblique",
  "opacity",
  "open-quote",
  "optimizeLegibility",
  "optimizeSpeed",
  "outset",
  "outside",
  "outside-shape",
  "overlay",
  "overline",
  "padding",
  "padding-box",
  "painted",
  "page",
  "paused",
  "perspective",
  "pinch-zoom",
  "plus-darker",
  "plus-lighter",
  "pointer",
  "polygon",
  "portrait",
  "pre",
  "pre-line",
  "pre-wrap",
  "preserve-3d",
  "progress",
  "push-button",
  "radial-gradient",
  "radio",
  "read-only",
  "read-write",
  "read-write-plaintext-only",
  "rectangle",
  "region",
  "relative",
  "repeat",
  "repeating-linear-gradient",
  "repeating-radial-gradient",
  "repeat-x",
  "repeat-y",
  "reset",
  "reverse",
  "rgb",
  "rgba",
  "ridge",
  "right",
  "rotate",
  "rotate3d",
  "rotateX",
  "rotateY",
  "rotateZ",
  "round",
  "row",
  "row-resize",
  "row-reverse",
  "rtl",
  "run-in",
  "running",
  "s-resize",
  "sans-serif",
  "saturation",
  "scale",
  "scale3d",
  "scaleX",
  "scaleY",
  "scaleZ",
  "screen",
  "scroll",
  "scrollbar",
  "scroll-position",
  "se-resize",
  "self-start",
  "self-end",
  "semi-condensed",
  "semi-expanded",
  "separate",
  "serif",
  "show",
  "single",
  "skew",
  "skewX",
  "skewY",
  "skip-white-space",
  "slide",
  "slider-horizontal",
  "slider-vertical",
  "sliderthumb-horizontal",
  "sliderthumb-vertical",
  "slow",
  "small",
  "small-caps",
  "small-caption",
  "smaller",
  "soft-light",
  "solid",
  "source-atop",
  "source-in",
  "source-out",
  "source-over",
  "space",
  "space-around",
  "space-between",
  "space-evenly",
  "spell-out",
  "square",
  "start",
  "static",
  "status-bar",
  "stretch",
  "stroke",
  "stroke-box",
  "sub",
  "subpixel-antialiased",
  "svg_masks",
  "super",
  "sw-resize",
  "symbolic",
  "symbols",
  "system-ui",
  "table",
  "table-caption",
  "table-cell",
  "table-column",
  "table-column-group",
  "table-footer-group",
  "table-header-group",
  "table-row",
  "table-row-group",
  "text",
  "text-bottom",
  "text-top",
  "textarea",
  "textfield",
  "thick",
  "thin",
  "threeddarkshadow",
  "threedface",
  "threedhighlight",
  "threedlightshadow",
  "threedshadow",
  "to",
  "top",
  "transform",
  "translate",
  "translate3d",
  "translateX",
  "translateY",
  "translateZ",
  "transparent",
  "ultra-condensed",
  "ultra-expanded",
  "underline",
  "unidirectional-pan",
  "unset",
  "up",
  "upper-latin",
  "uppercase",
  "url",
  "var",
  "vertical",
  "vertical-text",
  "view-box",
  "visible",
  "visibleFill",
  "visiblePainted",
  "visibleStroke",
  "visual",
  "w-resize",
  "wait",
  "wave",
  "wider",
  "window",
  "windowframe",
  "windowtext",
  "words",
  "wrap",
  "wrap-reverse",
  "x-large",
  "x-small",
  "xor",
  "xx-large",
  "xx-small"
].map((r) => ({ type: "keyword", label: r })).concat(/* @__PURE__ */ [
  "aliceblue",
  "antiquewhite",
  "aqua",
  "aquamarine",
  "azure",
  "beige",
  "bisque",
  "black",
  "blanchedalmond",
  "blue",
  "blueviolet",
  "brown",
  "burlywood",
  "cadetblue",
  "chartreuse",
  "chocolate",
  "coral",
  "cornflowerblue",
  "cornsilk",
  "crimson",
  "cyan",
  "darkblue",
  "darkcyan",
  "darkgoldenrod",
  "darkgray",
  "darkgreen",
  "darkkhaki",
  "darkmagenta",
  "darkolivegreen",
  "darkorange",
  "darkorchid",
  "darkred",
  "darksalmon",
  "darkseagreen",
  "darkslateblue",
  "darkslategray",
  "darkturquoise",
  "darkviolet",
  "deeppink",
  "deepskyblue",
  "dimgray",
  "dodgerblue",
  "firebrick",
  "floralwhite",
  "forestgreen",
  "fuchsia",
  "gainsboro",
  "ghostwhite",
  "gold",
  "goldenrod",
  "gray",
  "grey",
  "green",
  "greenyellow",
  "honeydew",
  "hotpink",
  "indianred",
  "indigo",
  "ivory",
  "khaki",
  "lavender",
  "lavenderblush",
  "lawngreen",
  "lemonchiffon",
  "lightblue",
  "lightcoral",
  "lightcyan",
  "lightgoldenrodyellow",
  "lightgray",
  "lightgreen",
  "lightpink",
  "lightsalmon",
  "lightseagreen",
  "lightskyblue",
  "lightslategray",
  "lightsteelblue",
  "lightyellow",
  "lime",
  "limegreen",
  "linen",
  "magenta",
  "maroon",
  "mediumaquamarine",
  "mediumblue",
  "mediumorchid",
  "mediumpurple",
  "mediumseagreen",
  "mediumslateblue",
  "mediumspringgreen",
  "mediumturquoise",
  "mediumvioletred",
  "midnightblue",
  "mintcream",
  "mistyrose",
  "moccasin",
  "navajowhite",
  "navy",
  "oldlace",
  "olive",
  "olivedrab",
  "orange",
  "orangered",
  "orchid",
  "palegoldenrod",
  "palegreen",
  "paleturquoise",
  "palevioletred",
  "papayawhip",
  "peachpuff",
  "peru",
  "pink",
  "plum",
  "powderblue",
  "purple",
  "rebeccapurple",
  "red",
  "rosybrown",
  "royalblue",
  "saddlebrown",
  "salmon",
  "sandybrown",
  "seagreen",
  "seashell",
  "sienna",
  "silver",
  "skyblue",
  "slateblue",
  "slategray",
  "snow",
  "springgreen",
  "steelblue",
  "tan",
  "teal",
  "thistle",
  "tomato",
  "turquoise",
  "violet",
  "wheat",
  "white",
  "whitesmoke",
  "yellow",
  "yellowgreen"
].map((r) => ({ type: "constant", label: r }))), Mv = /* @__PURE__ */ [
  "a",
  "abbr",
  "address",
  "article",
  "aside",
  "b",
  "bdi",
  "bdo",
  "blockquote",
  "body",
  "br",
  "button",
  "canvas",
  "caption",
  "cite",
  "code",
  "col",
  "colgroup",
  "dd",
  "del",
  "details",
  "dfn",
  "dialog",
  "div",
  "dl",
  "dt",
  "em",
  "figcaption",
  "figure",
  "footer",
  "form",
  "header",
  "hgroup",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "hr",
  "html",
  "i",
  "iframe",
  "img",
  "input",
  "ins",
  "kbd",
  "label",
  "legend",
  "li",
  "main",
  "meter",
  "nav",
  "ol",
  "output",
  "p",
  "pre",
  "ruby",
  "section",
  "select",
  "small",
  "source",
  "span",
  "strong",
  "sub",
  "summary",
  "sup",
  "table",
  "tbody",
  "td",
  "template",
  "textarea",
  "tfoot",
  "th",
  "thead",
  "tr",
  "u",
  "ul"
].map((r) => ({ type: "type", label: r })), Zv = /* @__PURE__ */ [
  "@charset",
  "@color-profile",
  "@container",
  "@counter-style",
  "@font-face",
  "@font-feature-values",
  "@font-palette-values",
  "@import",
  "@keyframes",
  "@layer",
  "@media",
  "@namespace",
  "@page",
  "@position-try",
  "@property",
  "@scope",
  "@starting-style",
  "@supports",
  "@view-transition"
].map((r) => ({ type: "keyword", label: r })), Xt = /^(\w[\w-]*|-\w[\w-]*|)$/, Xv = /^-(-[\w-]*)?$/;
function Rv(r, e) {
  var t;
  if ((r.name == "(" || r.type.isError) && (r = r.parent || r), r.name != "ArgList")
    return !1;
  let i = (t = r.parent) === null || t === void 0 ? void 0 : t.firstChild;
  return i?.name != "Callee" ? !1 : e.sliceString(i.from, i.to) == "var";
}
const $u = /* @__PURE__ */ new nm(), Lv = ["Declaration"];
function Ev(r) {
  for (let e = r; ; ) {
    if (e.type.isTop)
      return e;
    if (!(e = e.parent))
      return r;
  }
}
function Hm(r, e, t) {
  if (e.to - e.from > 4096) {
    let i = $u.get(e);
    if (i)
      return i;
    let n = [], s = /* @__PURE__ */ new Set(), o = e.cursor(le.IncludeAnonymous);
    if (o.firstChild())
      do
        for (let l of Hm(r, o.node, t))
          s.has(l.label) || (s.add(l.label), n.push(l));
      while (o.nextSibling());
    return $u.set(e, n), n;
  } else {
    let i = [], n = /* @__PURE__ */ new Set();
    return e.cursor().iterate((s) => {
      var o;
      if (t(s) && s.matchContext(Lv) && ((o = s.node.nextSibling) === null || o === void 0 ? void 0 : o.name) == ":") {
        let l = r.sliceString(s.from, s.to);
        n.has(l) || (n.add(l), i.push({ label: l, type: "variable" }));
      }
    }), i;
  }
}
const zv = (r) => (e) => {
  let { state: t, pos: i } = e, n = ve(t).resolveInner(i, -1), s = n.type.isError && n.from == n.to - 1 && t.doc.sliceString(n.from, n.to) == "-";
  if (n.name == "PropertyName" || (s || n.name == "TagName") && /^(Block|Styles)$/.test(n.resolve(n.to).name))
    return { from: n.from, options: al(), validFor: Xt };
  if (n.name == "ValueName")
    return { from: n.from, options: vu, validFor: Xt };
  if (n.name == "PseudoClassName")
    return { from: n.from, options: Qu, validFor: Xt };
  if (r(n) || (e.explicit || s) && Rv(n, t.doc))
    return {
      from: r(n) || s ? n.from : i,
      options: Hm(t.doc, Ev(n), r),
      validFor: Xv
    };
  if (n.name == "TagName") {
    for (let { parent: a } = n; a; a = a.parent)
      if (a.name == "Block")
        return { from: n.from, options: al(), validFor: Xt };
    return { from: n.from, options: Mv, validFor: Xt };
  }
  if (n.name == "AtKeyword")
    return { from: n.from, options: Zv, validFor: Xt };
  if (!e.explicit)
    return null;
  let o = n.resolve(i), l = o.childBefore(i);
  return l && l.name == ":" && o.name == "PseudoClassSelector" ? { from: i, options: Qu, validFor: Xt } : l && l.name == ":" && o.name == "Declaration" || o.name == "ArgList" ? { from: i, options: vu, validFor: Xt } : o.name == "Block" || o.name == "Styles" ? { from: i, options: al(), validFor: Xt } : null;
}, Dv = /* @__PURE__ */ zv((r) => r.name == "VariableName"), Hs = /* @__PURE__ */ Hi.define({
  name: "css",
  parser: /* @__PURE__ */ Av.configure({
    props: [
      /* @__PURE__ */ go.add({
        Declaration: /* @__PURE__ */ fs()
      }),
      /* @__PURE__ */ On.add({
        "Block KeyframeList": cm
      })
    ]
  }),
  languageData: {
    commentTokens: { block: { open: "/*", close: "*/" } },
    indentOnInput: /^\s*\}$/,
    wordChars: "-"
  }
});
function _v() {
  return new Jr(Hs, Hs.data.of({ autocomplete: Dv }));
}
const Bv = 316, Iv = 317, Pu = 1, Vv = 2, qv = 3, Yv = 4, Nv = 318, Wv = 320, jv = 321, Gv = 5, Uv = 6, Fv = 0, Ra = [
  9,
  10,
  11,
  12,
  13,
  32,
  133,
  160,
  5760,
  8192,
  8193,
  8194,
  8195,
  8196,
  8197,
  8198,
  8199,
  8200,
  8201,
  8202,
  8232,
  8233,
  8239,
  8287,
  12288
], Km = 125, Hv = 59, La = 47, Kv = 42, Jv = 43, e$ = 45, t$ = 60, i$ = 44, r$ = 63, n$ = 46, s$ = 91, o$ = new Em({
  start: !1,
  shift(r, e) {
    return e == Gv || e == Uv || e == Wv ? r : e == jv;
  },
  strict: !1
}), l$ = new Fe((r, e) => {
  let { next: t } = r;
  (t == Km || t == -1 || e.context) && r.acceptToken(Nv);
}, { contextual: !0, fallback: !0 }), a$ = new Fe((r, e) => {
  let { next: t } = r, i;
  Ra.indexOf(t) > -1 || t == La && ((i = r.peek(1)) == La || i == Kv) || t != Km && t != Hv && t != -1 && !e.context && r.acceptToken(Bv);
}, { contextual: !0 }), h$ = new Fe((r, e) => {
  r.next == s$ && !e.context && r.acceptToken(Iv);
}, { contextual: !0 }), c$ = new Fe((r, e) => {
  let { next: t } = r;
  if (t == Jv || t == e$) {
    if (r.advance(), t == r.next) {
      r.advance();
      let i = !e.context && e.canShift(Pu);
      r.acceptToken(i ? Pu : Vv);
    }
  } else t == r$ && r.peek(1) == n$ && (r.advance(), r.advance(), (r.next < 48 || r.next > 57) && r.acceptToken(qv));
}, { contextual: !0 });
function hl(r, e) {
  return r >= 65 && r <= 90 || r >= 97 && r <= 122 || r == 95 || r >= 192 || !e && r >= 48 && r <= 57;
}
const f$ = new Fe((r, e) => {
  if (r.next != t$ || !e.dialectEnabled(Fv) || (r.advance(), r.next == La)) return;
  let t = 0;
  for (; Ra.indexOf(r.next) > -1; )
    r.advance(), t++;
  if (hl(r.next, !0)) {
    for (r.advance(), t++; hl(r.next, !1); )
      r.advance(), t++;
    for (; Ra.indexOf(r.next) > -1; )
      r.advance(), t++;
    if (r.next == i$) return;
    for (let i = 0; ; i++) {
      if (i == 7) {
        if (!hl(r.next, !0)) return;
        break;
      }
      if (r.next != "extends".charCodeAt(i)) break;
      r.advance(), t++;
    }
  }
  r.acceptToken(Yv, -t);
}), u$ = sr({
  "get set async static": m.modifier,
  "for while do if else switch try catch finally return throw break continue default case defer": m.controlKeyword,
  "in of await yield void typeof delete instanceof as satisfies": m.operatorKeyword,
  "let var const using function class extends": m.definitionKeyword,
  "import export from": m.moduleKeyword,
  "with debugger new": m.keyword,
  TemplateString: m.special(m.string),
  super: m.atom,
  BooleanLiteral: m.bool,
  this: m.self,
  null: m.null,
  Star: m.modifier,
  VariableName: m.variableName,
  "CallExpression/VariableName TaggedTemplateExpression/VariableName": m.function(m.variableName),
  VariableDefinition: m.definition(m.variableName),
  Label: m.labelName,
  PropertyName: m.propertyName,
  PrivatePropertyName: m.special(m.propertyName),
  "CallExpression/MemberExpression/PropertyName": m.function(m.propertyName),
  "FunctionDeclaration/VariableDefinition": m.function(m.definition(m.variableName)),
  "ClassDeclaration/VariableDefinition": m.definition(m.className),
  "NewExpression/VariableName": m.className,
  PropertyDefinition: m.definition(m.propertyName),
  PrivatePropertyDefinition: m.definition(m.special(m.propertyName)),
  UpdateOp: m.updateOperator,
  "LineComment Hashbang": m.lineComment,
  BlockComment: m.blockComment,
  Number: m.number,
  String: m.string,
  Escape: m.escape,
  ArithOp: m.arithmeticOperator,
  LogicOp: m.logicOperator,
  BitOp: m.bitwiseOperator,
  CompareOp: m.compareOperator,
  RegExp: m.regexp,
  Equals: m.definitionOperator,
  Arrow: m.function(m.punctuation),
  ": Spread": m.punctuation,
  "( )": m.paren,
  "[ ]": m.squareBracket,
  "{ }": m.brace,
  "InterpolationStart InterpolationEnd": m.special(m.brace),
  ".": m.derefOperator,
  ", ;": m.separator,
  "@": m.meta,
  TypeName: m.typeName,
  TypeDefinition: m.definition(m.typeName),
  "type enum interface implements namespace module declare": m.definitionKeyword,
  "abstract global Privacy readonly override": m.modifier,
  "is keyof unique infer asserts": m.operatorKeyword,
  JSXAttributeValue: m.attributeValue,
  JSXText: m.content,
  "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": m.angleBracket,
  "JSXIdentifier JSXNameSpacedName": m.tagName,
  "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": m.attributeName,
  "JSXBuiltin/JSXIdentifier": m.standard(m.tagName)
}), d$ = { __proto__: null, export: 20, as: 25, from: 33, default: 36, async: 41, function: 42, in: 52, out: 55, const: 56, extends: 60, this: 64, true: 72, false: 72, null: 84, void: 88, typeof: 92, super: 108, new: 142, delete: 154, yield: 163, await: 167, class: 172, public: 235, private: 235, protected: 235, readonly: 237, instanceof: 256, satisfies: 259, import: 292, keyof: 349, unique: 353, infer: 359, asserts: 395, is: 397, abstract: 417, implements: 419, type: 421, let: 424, var: 426, using: 429, interface: 435, enum: 439, namespace: 445, module: 447, declare: 451, global: 455, defer: 471, for: 476, of: 485, while: 488, with: 492, do: 496, if: 500, else: 502, switch: 506, case: 512, try: 518, catch: 522, finally: 526, return: 530, throw: 534, break: 538, continue: 542, debugger: 546 }, p$ = { __proto__: null, async: 129, get: 131, set: 133, declare: 195, public: 197, private: 197, protected: 197, static: 199, abstract: 201, override: 203, readonly: 209, accessor: 211, new: 401 }, O$ = { __proto__: null, "<": 193 }, m$ = tr.deserialize({
  version: 14,
  states: "$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0L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lfR)x$qT)m$l)nR4V/UT*_$x*bT*h${*YQ0w+fQ1g,VQ3_.fQ5t1iQ6P1qQ7X3cQ8r6SQ9c7WQ:^8qQ:p9bQ;Z:`Q;c:rQ;n;[R;q;dnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&l!VR,h&itmOXst!U!V!Z#d%m&i&r&t&u&w,s,x2[2_R,o&oT%lm,oR1k,XR,g&gQ&U|S+}&V&WR1^,OR+s&PT&p!W&sT&q!W&sT2^,x2_",
  nodeNames: "⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",
  maxTerm: 380,
  context: o$,
  nodeProps: [
    ["isolate", -8, 5, 6, 14, 37, 39, 51, 53, 55, ""],
    ["group", -26, 9, 17, 19, 68, 207, 211, 215, 216, 218, 221, 224, 234, 237, 243, 245, 247, 249, 252, 258, 264, 266, 268, 270, 272, 274, 275, "Statement", -34, 13, 14, 32, 35, 36, 42, 51, 54, 55, 57, 62, 70, 72, 76, 80, 82, 84, 85, 110, 111, 120, 121, 136, 139, 141, 142, 143, 144, 145, 147, 148, 167, 169, 171, "Expression", -23, 31, 33, 37, 41, 43, 45, 173, 175, 177, 178, 180, 181, 182, 184, 185, 186, 188, 189, 190, 201, 203, 205, 206, "Type", -3, 88, 103, 109, "ClassItem"],
    ["openedBy", 23, "<", 38, "InterpolationStart", 56, "[", 60, "{", 73, "(", 160, "JSXStartCloseTag"],
    ["closedBy", -2, 24, 168, ">", 40, "InterpolationEnd", 50, "]", 61, "}", 74, ")", 165, "JSXEnd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r!P~#yP;=`<%l!P~$RO(c~~", 141, 340), new Us("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~", 25, 323)],
  topRules: { Script: [0, 7], SingleExpression: [1, 276], SingleClassItem: [2, 277] },
  dialects: { jsx: 0, ts: 15175 },
  dynamicPrecedences: { 80: 1, 82: 1, 94: 1, 169: 1, 199: 1 },
  specialized: [{ term: 327, get: (r) => d$[r] || -1 }, { term: 343, get: (r) => p$[r] || -1 }, { term: 95, get: (r) => O$[r] || -1 }],
  tokenPrec: 15201
}), Jm = [
  /* @__PURE__ */ Le("function ${name}(${params}) {\n	${}\n}", {
    label: "function",
    detail: "definition",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n	${}\n}", {
    label: "for",
    detail: "loop",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("for (let ${name} of ${collection}) {\n	${}\n}", {
    label: "for",
    detail: "of loop",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("do {\n	${}\n} while (${})", {
    label: "do",
    detail: "loop",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("while (${}) {\n	${}\n}", {
    label: "while",
    detail: "loop",
    type: "keyword"
  }),
  /* @__PURE__ */ Le(`try {
	\${}
} catch (\${error}) {
	\${}
}`, {
    label: "try",
    detail: "/ catch block",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("if (${}) {\n	${}\n}", {
    label: "if",
    detail: "block",
    type: "keyword"
  }),
  /* @__PURE__ */ Le(`if (\${}) {
	\${}
} else {
	\${}
}`, {
    label: "if",
    detail: "/ else block",
    type: "keyword"
  }),
  /* @__PURE__ */ Le(`class \${name} {
	constructor(\${params}) {
		\${}
	}
}`, {
    label: "class",
    detail: "definition",
    type: "keyword"
  }),
  /* @__PURE__ */ Le('import {${names}} from "${module}"\n${}', {
    label: "import",
    detail: "named",
    type: "keyword"
  }),
  /* @__PURE__ */ Le('import ${name} from "${module}"\n${}', {
    label: "import",
    detail: "default",
    type: "keyword"
  })
], g$ = /* @__PURE__ */ Jm.concat([
  /* @__PURE__ */ Le("interface ${name} {\n	${}\n}", {
    label: "interface",
    detail: "definition",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("type ${name} = ${type}", {
    label: "type",
    detail: "definition",
    type: "keyword"
  }),
  /* @__PURE__ */ Le("enum ${name} {\n	${}\n}", {
    label: "enum",
    detail: "definition",
    type: "keyword"
  })
]), Cu = /* @__PURE__ */ new nm(), eg = /* @__PURE__ */ new Set([
  "Script",
  "Block",
  "FunctionExpression",
  "FunctionDeclaration",
  "ArrowFunction",
  "MethodDeclaration",
  "ForStatement"
]);
function br(r) {
  return (e, t) => {
    let i = e.node.getChild("VariableDefinition");
    return i && t(i, r), !0;
  };
}
const b$ = ["FunctionDeclaration"], y$ = {
  FunctionDeclaration: /* @__PURE__ */ br("function"),
  ClassDeclaration: /* @__PURE__ */ br("class"),
  ClassExpression: () => !0,
  EnumDeclaration: /* @__PURE__ */ br("constant"),
  TypeAliasDeclaration: /* @__PURE__ */ br("type"),
  NamespaceDeclaration: /* @__PURE__ */ br("namespace"),
  VariableDefinition(r, e) {
    r.matchContext(b$) || e(r, "variable");
  },
  TypeDefinition(r, e) {
    e(r, "type");
  },
  __proto__: null
};
function tg(r, e) {
  let t = Cu.get(e);
  if (t)
    return t;
  let i = [], n = !0;
  function s(o, l) {
    let a = r.sliceString(o.from, o.to);
    i.push({ label: a, type: l });
  }
  return e.cursor(le.IncludeAnonymous).iterate((o) => {
    if (n)
      n = !1;
    else if (o.name) {
      let l = y$[o.name];
      if (l && l(o, s) || eg.has(o.name))
        return !1;
    } else if (o.to - o.from > 8192) {
      for (let l of tg(r, o.node))
        i.push(l);
      return !1;
    }
  }), Cu.set(e, i), i;
}
const Tu = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/, ig = [
  "TemplateString",
  "String",
  "RegExp",
  "LineComment",
  "BlockComment",
  "VariableDefinition",
  "TypeDefinition",
  "Label",
  "PropertyDefinition",
  "PropertyName",
  "PrivatePropertyDefinition",
  "PrivatePropertyName",
  "JSXText",
  "JSXAttributeValue",
  "JSXOpenTag",
  "JSXCloseTag",
  "JSXSelfClosingTag",
  ".",
  "?."
];
function S$(r) {
  let e = ve(r.state).resolveInner(r.pos, -1);
  if (ig.indexOf(e.name) > -1)
    return null;
  let t = e.name == "VariableName" || e.to - e.from < 20 && Tu.test(r.state.sliceDoc(e.from, e.to));
  if (!t && !r.explicit)
    return null;
  let i = [];
  for (let n = e; n; n = n.parent)
    eg.has(n.name) && (i = i.concat(tg(r.state.doc, n)));
  return {
    options: i,
    from: t ? e.from : r.pos,
    validFor: Tu
  };
}
const $t = /* @__PURE__ */ Hi.define({
  name: "javascript",
  parser: /* @__PURE__ */ m$.configure({
    props: [
      /* @__PURE__ */ go.add({
        IfStatement: /* @__PURE__ */ fs({ except: /^\s*({|else\b)/ }),
        TryStatement: /* @__PURE__ */ fs({ except: /^\s*({|catch\b|finally\b)/ }),
        LabeledStatement: uk,
        SwitchBody: (r) => {
          let e = r.textAfter, t = /^\s*\}/.test(e), i = /^\s*(case|default)\b/.test(e);
          return r.baseIndent + (t ? 0 : i ? 1 : 2) * r.unit;
        },
        Block: /* @__PURE__ */ ck({ closing: "}" }),
        ArrowFunction: (r) => r.baseIndent + r.unit,
        "TemplateString BlockComment": () => null,
        "Statement Property": /* @__PURE__ */ fs({ except: /^\s*{/ }),
        JSXElement(r) {
          let e = /^\s*<\//.test(r.textAfter);
          return r.lineIndent(r.node.from) + (e ? 0 : r.unit);
        },
        JSXEscape(r) {
          let e = /\s*\}/.test(r.textAfter);
          return r.lineIndent(r.node.from) + (e ? 0 : r.unit);
        },
        "JSXOpenTag JSXSelfClosingTag"(r) {
          return r.column(r.node.from) + r.unit;
        }
      }),
      /* @__PURE__ */ On.add({
        "Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": cm,
        BlockComment(r) {
          return { from: r.from + 2, to: r.to - 2 };
        }
      })
    ]
  }),
  languageData: {
    closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
    commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
    indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
    wordChars: "$"
  }
}), rg = {
  test: (r) => /^JSX/.test(r.name),
  facet: /* @__PURE__ */ xh({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
}, ng = /* @__PURE__ */ $t.configure({ dialect: "ts" }, "typescript"), sg = /* @__PURE__ */ $t.configure({
  dialect: "jsx",
  props: [/* @__PURE__ */ kh.add((r) => r.isTop ? [rg] : void 0)]
}), og = /* @__PURE__ */ $t.configure({
  dialect: "jsx ts",
  props: [/* @__PURE__ */ kh.add((r) => r.isTop ? [rg] : void 0)]
}, "typescript");
let lg = (r) => ({ label: r, type: "keyword" });
const ag = /* @__PURE__ */ "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(lg), w$ = /* @__PURE__ */ ag.concat(/* @__PURE__ */ ["declare", "implements", "private", "protected", "public"].map(lg));
function x$(r = {}) {
  let e = r.jsx ? r.typescript ? og : sg : r.typescript ? ng : $t, t = r.typescript ? g$.concat(w$) : Jm.concat(ag);
  return new Jr(e, [
    $t.data.of({
      autocomplete: vk(ig, Qk(t))
    }),
    $t.data.of({
      autocomplete: S$
    }),
    r.jsx ? v$ : []
  ]);
}
function k$(r) {
  for (; ; ) {
    if (r.name == "JSXOpenTag" || r.name == "JSXSelfClosingTag" || r.name == "JSXFragmentTag")
      return r;
    if (r.name == "JSXEscape" || !r.parent)
      return null;
    r = r.parent;
  }
}
function Au(r, e, t = r.length) {
  for (let i = e?.firstChild; i; i = i.nextSibling)
    if (i.name == "JSXIdentifier" || i.name == "JSXBuiltin" || i.name == "JSXNamespacedName" || i.name == "JSXMemberExpression")
      return r.sliceString(i.from, Math.min(i.to, t));
  return "";
}
const Q$ = typeof navigator == "object" && /* @__PURE__ */ /Android\b/.test(navigator.userAgent), v$ = /* @__PURE__ */ D.inputHandler.of((r, e, t, i, n) => {
  if ((Q$ ? r.composing : r.compositionStarted) || r.state.readOnly || e != t || i != ">" && i != "/" || !$t.isActiveAt(r.state, e, -1))
    return !1;
  let s = n(), { state: o } = s, l = o.changeByRange((a) => {
    var h;
    let { head: c } = a, f = ve(o).resolveInner(c - 1, -1), u;
    if (f.name == "JSXStartTag" && (f = f.parent), !(o.doc.sliceString(c - 1, c) != i || f.name == "JSXAttributeValue" && f.to > c)) {
      if (i == ">" && f.name == "JSXFragmentTag")
        return { range: a, changes: { from: c, insert: "</>" } };
      if (i == "/" && f.name == "JSXStartCloseTag") {
        let d = f.parent, p = d.parent;
        if (p && d.from == c - 2 && ((u = Au(o.doc, p.firstChild, c)) || ((h = p.firstChild) === null || h === void 0 ? void 0 : h.name) == "JSXFragmentTag")) {
          let O = `${u}>`;
          return { range: v.cursor(c + O.length, -1), changes: { from: c, insert: O } };
        }
      } else if (i == ">") {
        let d = k$(f);
        if (d && d.name == "JSXOpenTag" && !/^\/?>|^<\//.test(o.doc.sliceString(c, c + 2)) && (u = Au(o.doc, d, c)))
          return { range: a, changes: { from: c, insert: `</${u}>` } };
      }
    }
    return { range: a };
  });
  return l.changes.empty ? !1 : (r.dispatch([
    s,
    o.update(l, { userEvent: "input.complete", scrollIntoView: !0 })
  ]), !0);
}), yr = ["_blank", "_self", "_top", "_parent"], cl = ["ascii", "utf-8", "utf-16", "latin1", "latin1"], fl = ["get", "post", "put", "delete"], ul = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Ve = ["true", "false"], _ = {}, $$ = {
  a: {
    attrs: {
      href: null,
      ping: null,
      type: null,
      media: null,
      target: yr,
      hreflang: null
    }
  },
  abbr: _,
  address: _,
  area: {
    attrs: {
      alt: null,
      coords: null,
      href: null,
      target: null,
      ping: null,
      media: null,
      hreflang: null,
      type: null,
      shape: ["default", "rect", "circle", "poly"]
    }
  },
  article: _,
  aside: _,
  audio: {
    attrs: {
      src: null,
      mediagroup: null,
      crossorigin: ["anonymous", "use-credentials"],
      preload: ["none", "metadata", "auto"],
      autoplay: ["autoplay"],
      loop: ["loop"],
      controls: ["controls"]
    }
  },
  b: _,
  base: { attrs: { href: null, target: yr } },
  bdi: _,
  bdo: _,
  blockquote: { attrs: { cite: null } },
  body: _,
  br: _,
  button: {
    attrs: {
      form: null,
      formaction: null,
      name: null,
      value: null,
      autofocus: ["autofocus"],
      disabled: ["autofocus"],
      formenctype: ul,
      formmethod: fl,
      formnovalidate: ["novalidate"],
      formtarget: yr,
      type: ["submit", "reset", "button"]
    }
  },
  canvas: { attrs: { width: null, height: null } },
  caption: _,
  center: _,
  cite: _,
  code: _,
  col: { attrs: { span: null } },
  colgroup: { attrs: { span: null } },
  command: {
    attrs: {
      type: ["command", "checkbox", "radio"],
      label: null,
      icon: null,
      radiogroup: null,
      command: null,
      title: null,
      disabled: ["disabled"],
      checked: ["checked"]
    }
  },
  data: { attrs: { value: null } },
  datagrid: { attrs: { disabled: ["disabled"], multiple: ["multiple"] } },
  datalist: { attrs: { data: null } },
  dd: _,
  del: { attrs: { cite: null, datetime: null } },
  details: { attrs: { open: ["open"] } },
  dfn: _,
  div: _,
  dl: _,
  dt: _,
  em: _,
  embed: { attrs: { src: null, type: null, width: null, height: null } },
  eventsource: { attrs: { src: null } },
  fieldset: { attrs: { disabled: ["disabled"], form: null, name: null } },
  figcaption: _,
  figure: _,
  footer: _,
  form: {
    attrs: {
      action: null,
      name: null,
      "accept-charset": cl,
      autocomplete: ["on", "off"],
      enctype: ul,
      method: fl,
      novalidate: ["novalidate"],
      target: yr
    }
  },
  h1: _,
  h2: _,
  h3: _,
  h4: _,
  h5: _,
  h6: _,
  head: {
    children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
  },
  header: _,
  hgroup: _,
  hr: _,
  html: {
    attrs: { manifest: null }
  },
  i: _,
  iframe: {
    attrs: {
      src: null,
      srcdoc: null,
      name: null,
      width: null,
      height: null,
      sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
      seamless: ["seamless"]
    }
  },
  img: {
    attrs: {
      alt: null,
      src: null,
      ismap: null,
      usemap: null,
      width: null,
      height: null,
      crossorigin: ["anonymous", "use-credentials"]
    }
  },
  input: {
    attrs: {
      alt: null,
      dirname: null,
      form: null,
      formaction: null,
      height: null,
      list: null,
      max: null,
      maxlength: null,
      min: null,
      name: null,
      pattern: null,
      placeholder: null,
      size: null,
      src: null,
      step: null,
      value: null,
      width: null,
      accept: ["audio/*", "video/*", "image/*"],
      autocomplete: ["on", "off"],
      autofocus: ["autofocus"],
      checked: ["checked"],
      disabled: ["disabled"],
      formenctype: ul,
      formmethod: fl,
      formnovalidate: ["novalidate"],
      formtarget: yr,
      multiple: ["multiple"],
      readonly: ["readonly"],
      required: ["required"],
      type: [
        "hidden",
        "text",
        "search",
        "tel",
        "url",
        "email",
        "password",
        "datetime",
        "date",
        "month",
        "week",
        "time",
        "datetime-local",
        "number",
        "range",
        "color",
        "checkbox",
        "radio",
        "file",
        "submit",
        "image",
        "reset",
        "button"
      ]
    }
  },
  ins: { attrs: { cite: null, datetime: null } },
  kbd: _,
  keygen: {
    attrs: {
      challenge: null,
      form: null,
      name: null,
      autofocus: ["autofocus"],
      disabled: ["disabled"],
      keytype: ["RSA"]
    }
  },
  label: { attrs: { for: null, form: null } },
  legend: _,
  li: { attrs: { value: null } },
  link: {
    attrs: {
      href: null,
      type: null,
      hreflang: null,
      media: null,
      sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
    }
  },
  map: { attrs: { name: null } },
  mark: _,
  menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
  meta: {
    attrs: {
      content: null,
      charset: cl,
      name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
      "http-equiv": ["content-language", "content-type", "default-style", "refresh"]
    }
  },
  meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
  nav: _,
  noscript: _,
  object: {
    attrs: {
      data: null,
      type: null,
      name: null,
      usemap: null,
      form: null,
      width: null,
      height: null,
      typemustmatch: ["typemustmatch"]
    }
  },
  ol: {
    attrs: { reversed: ["reversed"], start: null, type: ["1", "a", "A", "i", "I"] },
    children: ["li", "script", "template", "ul", "ol"]
  },
  optgroup: { attrs: { disabled: ["disabled"], label: null } },
  option: { attrs: { disabled: ["disabled"], label: null, selected: ["selected"], value: null } },
  output: { attrs: { for: null, form: null, name: null } },
  p: _,
  param: { attrs: { name: null, value: null } },
  pre: _,
  progress: { attrs: { value: null, max: null } },
  q: { attrs: { cite: null } },
  rp: _,
  rt: _,
  ruby: _,
  samp: _,
  script: {
    attrs: {
      type: ["text/javascript"],
      src: null,
      async: ["async"],
      defer: ["defer"],
      charset: cl
    }
  },
  section: _,
  select: {
    attrs: {
      form: null,
      name: null,
      size: null,
      autofocus: ["autofocus"],
      disabled: ["disabled"],
      multiple: ["multiple"]
    }
  },
  slot: { attrs: { name: null } },
  small: _,
  source: { attrs: { src: null, type: null, media: null } },
  span: _,
  strong: _,
  style: {
    attrs: {
      type: ["text/css"],
      media: null,
      scoped: null
    }
  },
  sub: _,
  summary: _,
  sup: _,
  table: _,
  tbody: _,
  td: { attrs: { colspan: null, rowspan: null, headers: null } },
  template: _,
  textarea: {
    attrs: {
      dirname: null,
      form: null,
      maxlength: null,
      name: null,
      placeholder: null,
      rows: null,
      cols: null,
      autofocus: ["autofocus"],
      disabled: ["disabled"],
      readonly: ["readonly"],
      required: ["required"],
      wrap: ["soft", "hard"]
    }
  },
  tfoot: _,
  th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
  thead: _,
  time: { attrs: { datetime: null } },
  title: _,
  tr: _,
  track: {
    attrs: {
      src: null,
      label: null,
      default: null,
      kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
      srclang: null
    }
  },
  ul: { children: ["li", "script", "template", "ul", "ol"] },
  var: _,
  video: {
    attrs: {
      src: null,
      poster: null,
      width: null,
      height: null,
      crossorigin: ["anonymous", "use-credentials"],
      preload: ["auto", "metadata", "none"],
      autoplay: ["autoplay"],
      mediagroup: ["movie"],
      muted: ["muted"],
      controls: ["controls"]
    }
  },
  wbr: _
}, hg = {
  accesskey: null,
  class: null,
  contenteditable: Ve,
  contextmenu: null,
  dir: ["ltr", "rtl", "auto"],
  draggable: ["true", "false", "auto"],
  dropzone: ["copy", "move", "link", "string:", "file:"],
  hidden: ["hidden"],
  id: null,
  inert: ["inert"],
  itemid: null,
  itemprop: null,
  itemref: null,
  itemscope: ["itemscope"],
  itemtype: null,
  lang: ["ar", "bn", "de", "en-GB", "en-US", "es", "fr", "hi", "id", "ja", "pa", "pt", "ru", "tr", "zh"],
  spellcheck: Ve,
  autocorrect: Ve,
  autocapitalize: Ve,
  style: null,
  tabindex: null,
  title: null,
  translate: ["yes", "no"],
  rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"],
  role: /* @__PURE__ */ "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),
  "aria-activedescendant": null,
  "aria-atomic": Ve,
  "aria-autocomplete": ["inline", "list", "both", "none"],
  "aria-busy": Ve,
  "aria-checked": ["true", "false", "mixed", "undefined"],
  "aria-controls": null,
  "aria-describedby": null,
  "aria-disabled": Ve,
  "aria-dropeffect": null,
  "aria-expanded": ["true", "false", "undefined"],
  "aria-flowto": null,
  "aria-grabbed": ["true", "false", "undefined"],
  "aria-haspopup": Ve,
  "aria-hidden": Ve,
  "aria-invalid": ["true", "false", "grammar", "spelling"],
  "aria-label": null,
  "aria-labelledby": null,
  "aria-level": null,
  "aria-live": ["off", "polite", "assertive"],
  "aria-multiline": Ve,
  "aria-multiselectable": Ve,
  "aria-owns": null,
  "aria-posinset": null,
  "aria-pressed": ["true", "false", "mixed", "undefined"],
  "aria-readonly": Ve,
  "aria-relevant": null,
  "aria-required": Ve,
  "aria-selected": ["true", "false", "undefined"],
  "aria-setsize": null,
  "aria-sort": ["ascending", "descending", "none", "other"],
  "aria-valuemax": null,
  "aria-valuemin": null,
  "aria-valuenow": null,
  "aria-valuetext": null
}, cg = /* @__PURE__ */ "beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map((r) => "on" + r);
for (let r of cg)
  hg[r] = null;
class sn {
  constructor(e, t) {
    this.tags = { ...$$, ...e }, this.globalAttrs = { ...hg, ...t }, this.allTags = Object.keys(this.tags), this.globalAttrNames = Object.keys(this.globalAttrs);
  }
}
sn.default = /* @__PURE__ */ new sn();
function ir(r, e, t = r.length) {
  if (!e)
    return "";
  let i = e.firstChild, n = i && i.getChild("TagName");
  return n ? r.sliceString(n.from, Math.min(n.to, t)) : "";
}
function rr(r, e = !1) {
  for (; r; r = r.parent)
    if (r.name == "Element")
      if (e)
        e = !1;
      else
        return r;
  return null;
}
function fg(r, e, t) {
  let i = t.tags[ir(r, rr(e))];
  return i?.children || t.allTags;
}
function Lh(r, e) {
  let t = [];
  for (let i = rr(e); i && !i.type.isTop; i = rr(i.parent)) {
    let n = ir(r, i);
    if (n && i.lastChild.name == "CloseTag")
      break;
    n && t.indexOf(n) < 0 && (e.name == "EndTag" || e.from >= i.firstChild.to) && t.push(n);
  }
  return t;
}
const ug = /^[:\-\.\w\u00b7-\uffff]*$/;
function Mu(r, e, t, i, n) {
  let s = /\s*>/.test(r.sliceDoc(n, n + 5)) ? "" : ">", o = rr(t, t.name == "StartTag" || t.name == "TagName");
  return {
    from: i,
    to: n,
    options: fg(r.doc, o, e).map((l) => ({ label: l, type: "type" })).concat(Lh(r.doc, t).map((l, a) => ({
      label: "/" + l,
      apply: "/" + l + s,
      type: "type",
      boost: 99 - a
    }))),
    validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/
  };
}
function Zu(r, e, t, i) {
  let n = /\s*>/.test(r.sliceDoc(i, i + 5)) ? "" : ">";
  return {
    from: t,
    to: i,
    options: Lh(r.doc, e).map((s, o) => ({ label: s, apply: s + n, type: "type", boost: 99 - o })),
    validFor: ug
  };
}
function P$(r, e, t, i) {
  let n = [], s = 0;
  for (let o of fg(r.doc, t, e))
    n.push({ label: "<" + o, type: "type" });
  for (let o of Lh(r.doc, t))
    n.push({ label: "</" + o + ">", type: "type", boost: 99 - s++ });
  return { from: i, to: i, options: n, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ };
}
function C$(r, e, t, i, n) {
  let s = rr(t), o = s ? e.tags[ir(r.doc, s)] : null, l = o && o.attrs ? Object.keys(o.attrs) : [], a = o && o.globalAttrs === !1 ? l : l.length ? l.concat(e.globalAttrNames) : e.globalAttrNames;
  return {
    from: i,
    to: n,
    options: a.map((h) => ({ label: h, type: "property" })),
    validFor: ug
  };
}
function T$(r, e, t, i, n) {
  var s;
  let o = (s = t.parent) === null || s === void 0 ? void 0 : s.getChild("AttributeName"), l = [], a;
  if (o) {
    let h = r.sliceDoc(o.from, o.to), c = e.globalAttrs[h];
    if (!c) {
      let f = rr(t), u = f ? e.tags[ir(r.doc, f)] : null;
      c = u?.attrs && u.attrs[h];
    }
    if (c) {
      let f = r.sliceDoc(i, n).toLowerCase(), u = '"', d = '"';
      /^['"]/.test(f) ? (a = f[0] == '"' ? /^[^"]*$/ : /^[^']*$/, u = "", d = r.sliceDoc(n, n + 1) == f[0] ? "" : f[0], f = f.slice(1), i++) : a = /^[^\s<>='"]*$/;
      for (let p of c)
        l.push({ label: p, apply: u + p + d, type: "constant" });
    }
  }
  return { from: i, to: n, options: l, validFor: a };
}
function dg(r, e) {
  let { state: t, pos: i } = e, n = ve(t).resolveInner(i, -1), s = n.resolve(i);
  for (let o = i, l; s == n && (l = n.childBefore(o)); ) {
    let a = l.lastChild;
    if (!a || !a.type.isError || a.from < a.to)
      break;
    s = n = l, o = a.from;
  }
  return n.name == "TagName" ? n.parent && /CloseTag$/.test(n.parent.name) ? Zu(t, n, n.from, i) : Mu(t, r, n, n.from, i) : n.name == "StartTag" || n.name == "IncompleteTag" ? Mu(t, r, n, i, i) : n.name == "StartCloseTag" || n.name == "IncompleteCloseTag" ? Zu(t, n, i, i) : n.name == "OpenTag" || n.name == "SelfClosingTag" || n.name == "AttributeName" ? C$(t, r, n, n.name == "AttributeName" ? n.from : i, i) : n.name == "Is" || n.name == "AttributeValue" || n.name == "UnquotedAttributeValue" ? T$(t, r, n, n.name == "Is" ? i : n.from, i) : e.explicit && (s.name == "Element" || s.name == "Text" || s.name == "Document") ? P$(t, r, n, i) : null;
}
function A$(r) {
  return dg(sn.default, r);
}
function M$(r) {
  let { extraTags: e, extraGlobalAttributes: t } = r, i = t || e ? new sn(e, t) : sn.default;
  return (n) => dg(i, n);
}
const Z$ = /* @__PURE__ */ $t.parser.configure({ top: "SingleExpression" }), pg = [
  {
    tag: "script",
    attrs: (r) => r.type == "text/typescript" || r.lang == "ts",
    parser: ng.parser
  },
  {
    tag: "script",
    attrs: (r) => r.type == "text/babel" || r.type == "text/jsx",
    parser: sg.parser
  },
  {
    tag: "script",
    attrs: (r) => r.type == "text/typescript-jsx",
    parser: og.parser
  },
  {
    tag: "script",
    attrs(r) {
      return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(r.type);
    },
    parser: Z$
  },
  {
    tag: "script",
    attrs(r) {
      return !r.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(r.type);
    },
    parser: $t.parser
  },
  {
    tag: "style",
    attrs(r) {
      return (!r.lang || r.lang == "css") && (!r.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(r.type));
    },
    parser: Hs.parser
  }
], Og = /* @__PURE__ */ [
  {
    name: "style",
    parser: /* @__PURE__ */ Hs.parser.configure({ top: "Styles" })
  }
].concat(/* @__PURE__ */ cg.map((r) => ({ name: r, parser: $t.parser }))), mg = /* @__PURE__ */ Hi.define({
  name: "html",
  parser: /* @__PURE__ */ rv.configure({
    props: [
      /* @__PURE__ */ go.add({
        Element(r) {
          let e = /^(\s*)(<\/)?/.exec(r.textAfter);
          return r.node.to <= r.pos + e[0].length ? r.continue() : r.lineIndent(r.node.from) + (e[2] ? 0 : r.unit);
        },
        "OpenTag CloseTag SelfClosingTag"(r) {
          return r.column(r.node.from) + r.unit;
        },
        Document(r) {
          if (r.pos + /\s*/.exec(r.textAfter)[0].length < r.node.to)
            return r.continue();
          let e = null, t;
          for (let i = r.node; ; ) {
            let n = i.lastChild;
            if (!n || n.name != "Element" || n.to != i.to)
              break;
            e = i = n;
          }
          return e && !((t = e.lastChild) && (t.name == "CloseTag" || t.name == "SelfClosingTag")) ? r.lineIndent(e.from) + r.unit : null;
        }
      }),
      /* @__PURE__ */ On.add({
        Element(r) {
          let e = r.firstChild, t = r.lastChild;
          return !e || e.name != "OpenTag" ? null : { from: e.to, to: t.name == "CloseTag" ? t.from : r.to };
        }
      }),
      /* @__PURE__ */ bk.add({
        "OpenTag CloseTag": (r) => r.getChild("TagName")
      })
    ]
  }),
  languageData: {
    commentTokens: { block: { open: "<!--", close: "-->" } },
    indentOnInput: /^\s*<\/\w+\W$/,
    wordChars: "-_"
  }
}), ps = /* @__PURE__ */ mg.configure({
  wrap: /* @__PURE__ */ Wm(pg, Og)
});
function X$(r = {}) {
  let e = "", t;
  r.matchClosingTags === !1 && (e = "noMatch"), r.selfClosingTags === !0 && (e = (e ? e + " " : "") + "selfClosing"), (r.nestedLanguages && r.nestedLanguages.length || r.nestedAttributes && r.nestedAttributes.length) && (t = Wm((r.nestedLanguages || []).concat(pg), (r.nestedAttributes || []).concat(Og)));
  let i = t ? mg.configure({ wrap: t, dialect: e }) : e ? ps.configure({ dialect: e }) : ps;
  return new Jr(i, [
    ps.data.of({ autocomplete: M$(r) }),
    r.autoCloseTags !== !1 ? R$ : [],
    x$().support,
    _v().support
  ]);
}
const Xu = /* @__PURE__ */ new Set(/* @__PURE__ */ "area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")), R$ = /* @__PURE__ */ D.inputHandler.of((r, e, t, i, n) => {
  if (r.composing || r.state.readOnly || e != t || i != ">" && i != "/" || !ps.isActiveAt(r.state, e, -1))
    return !1;
  let s = n(), { state: o } = s, l = o.changeByRange((a) => {
    var h, c, f;
    let u = o.doc.sliceString(a.from - 1, a.to) == i, { head: d } = a, p = ve(o).resolveInner(d, -1), O;
    if (u && i == ">" && p.name == "EndTag") {
      let g = p.parent;
      if (((c = (h = g.parent) === null || h === void 0 ? void 0 : h.lastChild) === null || c === void 0 ? void 0 : c.name) != "CloseTag" && (O = ir(o.doc, g.parent, d)) && !Xu.has(O)) {
        let b = d + (o.doc.sliceString(d, d + 1) === ">" ? 1 : 0), w = `</${O}>`;
        return { range: a, changes: { from: d, to: b, insert: w } };
      }
    } else if (u && i == "/" && p.name == "IncompleteCloseTag") {
      let g = p.parent;
      if (p.from == d - 2 && ((f = g.lastChild) === null || f === void 0 ? void 0 : f.name) != "CloseTag" && (O = ir(o.doc, g, d)) && !Xu.has(O)) {
        let b = d + (o.doc.sliceString(d, d + 1) === ">" ? 1 : 0), w = `${O}>`;
        return {
          range: v.cursor(d + w.length, -1),
          changes: { from: d, to: b, insert: w }
        };
      }
    }
    return { range: a };
  });
  return l.changes.empty ? !1 : (r.dispatch([
    s,
    o.update(l, {
      userEvent: "input.complete",
      scrollIntoView: !0
    })
  ]), !0);
}), gg = /* @__PURE__ */ xh({ commentTokens: { block: { open: "<!--", close: "-->" } } }), bg = /* @__PURE__ */ new j(), yg = /* @__PURE__ */ Hk.configure({
  props: [
    /* @__PURE__ */ On.add((r) => !r.is("Block") || r.is("Document") || Ea(r) != null || L$(r) ? void 0 : (e, t) => ({ from: t.doc.lineAt(e.from).to, to: e.to })),
    /* @__PURE__ */ bg.add(Ea),
    /* @__PURE__ */ go.add({
      Document: () => null
    }),
    /* @__PURE__ */ Qi.add({
      Document: gg
    })
  ]
});
function Ea(r) {
  let e = /^(?:ATX|Setext)Heading(\d)$/.exec(r.name);
  return e ? +e[1] : void 0;
}
function L$(r) {
  return r.name == "OrderedList" || r.name == "BulletList";
}
function E$(r, e) {
  let t = r;
  for (; ; ) {
    let i = t.nextSibling, n;
    if (!i || (n = Ea(i.type)) != null && n <= e)
      break;
    t = i;
  }
  return t.to;
}
const z$ = /* @__PURE__ */ dk.of((r, e, t) => {
  for (let i = ve(r).resolveInner(t, -1); i && !(i.from < e); i = i.parent) {
    let n = i.type.prop(bg);
    if (n == null)
      continue;
    let s = E$(i, n);
    if (s > t)
      return { from: t, to: s };
  }
  return null;
});
function Eh(r) {
  return new tt(gg, r, [], "markdown");
}
const D$ = /* @__PURE__ */ Eh(yg), _$ = /* @__PURE__ */ yg.configure([aQ, cQ, hQ, fQ, {
  props: [
    /* @__PURE__ */ On.add({
      Table: (r, e) => ({ from: e.doc.lineAt(r.from).to, to: r.to })
    })
  ]
}]), Ks = /* @__PURE__ */ Eh(_$);
function B$(r, e) {
  return (t) => {
    if (t && r) {
      let i = null;
      if (t = /\S*/.exec(t)[0], typeof r == "function" ? i = r(t) : i = Ys.matchLanguageName(r, t, !0), i instanceof Ys)
        return i.support ? i.support.language.parser : Kr.getSkippingParser(i.load());
      if (i)
        return i.parser;
    }
    return e ? e.parser : null;
  };
}
class dl {
  constructor(e, t, i, n, s, o, l) {
    this.node = e, this.from = t, this.to = i, this.spaceBefore = n, this.spaceAfter = s, this.type = o, this.item = l;
  }
  blank(e, t = !0) {
    let i = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
    if (e != null) {
      for (; i.length < e; )
        i += " ";
      return i;
    } else {
      for (let n = this.to - this.from - i.length - this.spaceAfter.length; n > 0; n--)
        i += " ";
      return i + (t ? this.spaceAfter : "");
    }
  }
  marker(e, t) {
    let i = this.node.name == "OrderedList" ? String(+wg(this.item, e)[2] + t) : "";
    return this.spaceBefore + i + this.type + this.spaceAfter;
  }
}
function Sg(r, e) {
  let t = [], i = [];
  for (let n = r; n; n = n.parent) {
    if (n.name == "FencedCode")
      return i;
    (n.name == "ListItem" || n.name == "Blockquote") && t.push(n);
  }
  for (let n = t.length - 1; n >= 0; n--) {
    let s = t[n], o, l = e.lineAt(s.from), a = s.from - l.from;
    if (s.name == "Blockquote" && (o = /^ *>( ?)/.exec(l.text.slice(a))))
      i.push(new dl(s, a, a + o[0].length, "", o[1], ">", null));
    else if (s.name == "ListItem" && s.parent.name == "OrderedList" && (o = /^( *)\d+([.)])( *)/.exec(l.text.slice(a)))) {
      let h = o[3], c = o[0].length;
      h.length >= 4 && (h = h.slice(0, h.length - 4), c -= 4), i.push(new dl(s.parent, a, a + c, o[1], h, o[2], s));
    } else if (s.name == "ListItem" && s.parent.name == "BulletList" && (o = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(a)))) {
      let h = o[4], c = o[0].length;
      h.length > 4 && (h = h.slice(0, h.length - 4), c -= 4);
      let f = o[2];
      o[3] && (f += o[3].replace(/[xX]/, " ")), i.push(new dl(s.parent, a, a + c, o[1], h, f, s));
    }
  }
  return i;
}
function wg(r, e) {
  return /^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(r.from, r.from + 10));
}
function pl(r, e, t, i = 0) {
  for (let n = -1, s = r; ; ) {
    if (s.name == "ListItem") {
      let l = wg(s, e), a = +l[2];
      if (n >= 0) {
        if (a != n + 1)
          return;
        t.push({ from: s.from + l[1].length, to: s.from + l[0].length, insert: String(n + 2 + i) });
      }
      n = a;
    }
    let o = s.nextSibling;
    if (!o)
      break;
    s = o;
  }
}
function zh(r, e) {
  let t = /^[ \t]*/.exec(r)[0].length;
  if (!t || e.facet(hm) != "	")
    return r;
  let i = lt(r, 4, t), n = "";
  for (let s = i; s > 0; )
    s >= 4 ? (n += "	", s -= 4) : (n += " ", s--);
  return n + r.slice(t);
}
const I$ = (r = {}) => ({ state: e, dispatch: t }) => {
  let i = ve(e), { doc: n } = e, s = null, o = e.changeByRange((l) => {
    if (!l.empty || !Ks.isActiveAt(e, l.from, -1) && !Ks.isActiveAt(e, l.from, 1))
      return s = { range: l };
    let a = l.from, h = n.lineAt(a), c = Sg(i.resolveInner(a, -1), n);
    for (; c.length && c[c.length - 1].from > a - h.from; )
      c.pop();
    if (!c.length)
      return s = { range: l };
    let f = c[c.length - 1];
    if (f.to - f.spaceAfter.length > a - h.from)
      return s = { range: l };
    let u = a >= f.to - f.spaceAfter.length && !/\S/.test(h.text.slice(f.to));
    if (f.item && u) {
      let b = f.node.firstChild, w = f.node.getChild("ListItem", "ListItem");
      if (b.to >= a || w && w.to < a || h.from > 0 && !/[^\s>]/.test(n.lineAt(h.from - 1).text) || r.nonTightLists === !1) {
        let k = c.length > 1 ? c[c.length - 2] : null, x, S = "";
        k && k.item ? (x = h.from + k.from, S = k.marker(n, 1)) : x = h.from + (k ? k.to : 0);
        let y = [{ from: x, to: a, insert: S }];
        return f.node.name == "OrderedList" && pl(f.item, n, y, -2), k && k.node.name == "OrderedList" && pl(k.item, n, y), { range: v.cursor(x + S.length), changes: y };
      } else {
        let k = Lu(c, e, h);
        return {
          range: v.cursor(a + k.length + 1),
          changes: { from: h.from, insert: k + e.lineBreak }
        };
      }
    }
    if (f.node.name == "Blockquote" && u && h.from) {
      let b = n.lineAt(h.from - 1), w = />\s*$/.exec(b.text);
      if (w && w.index == f.from) {
        let k = e.changes([
          { from: b.from + w.index, to: b.to },
          { from: h.from + f.from, to: h.to }
        ]);
        return { range: l.map(k), changes: k };
      }
    }
    let d = [];
    f.node.name == "OrderedList" && pl(f.item, n, d);
    let p = f.item && f.item.from < h.from, O = "";
    if (!p || /^[\s\d.)\-+*>]*/.exec(h.text)[0].length >= f.to)
      for (let b = 0, w = c.length - 1; b <= w; b++)
        O += b == w && !p ? c[b].marker(n, 1) : c[b].blank(b < w ? lt(h.text, 4, c[b + 1].from) - O.length : null);
    let g = a;
    for (; g > h.from && /\s/.test(h.text.charAt(g - h.from - 1)); )
      g--;
    return O = zh(O, e), q$(f.node, e.doc) && (O = Lu(c, e, h) + e.lineBreak + O), d.push({ from: g, to: a, insert: e.lineBreak + O }), { range: v.cursor(g + O.length + 1), changes: d };
  });
  return s ? !1 : (t(e.update(o, { scrollIntoView: !0, userEvent: "input" })), !0);
}, V$ = /* @__PURE__ */ I$();
function Ru(r) {
  return r.name == "QuoteMark" || r.name == "ListMark";
}
function q$(r, e) {
  if (r.name != "OrderedList" && r.name != "BulletList")
    return !1;
  let t = r.firstChild, i = r.getChild("ListItem", "ListItem");
  if (!i)
    return !1;
  let n = e.lineAt(t.to), s = e.lineAt(i.from), o = /^[\s>]*$/.test(n.text);
  return n.number + (o ? 0 : 1) < s.number;
}
function Lu(r, e, t) {
  let i = "";
  for (let n = 0, s = r.length - 2; n <= s; n++)
    i += r[n].blank(n < s ? lt(t.text, 4, r[n + 1].from) - i.length : null, n < s);
  return zh(i, e);
}
function Y$(r, e) {
  let t = r.resolveInner(e, -1), i = e;
  Ru(t) && (i = t.from, t = t.parent);
  for (let n; n = t.childBefore(i); )
    if (Ru(n))
      i = n.from;
    else if (n.name == "OrderedList" || n.name == "BulletList")
      t = n.lastChild, i = t.to;
    else
      break;
  return t;
}
const N$ = ({ state: r, dispatch: e }) => {
  let t = ve(r), i = null, n = r.changeByRange((s) => {
    let o = s.from, { doc: l } = r;
    if (s.empty && Ks.isActiveAt(r, s.from)) {
      let a = l.lineAt(o), h = Sg(Y$(t, o), l);
      if (h.length) {
        let c = h[h.length - 1], f = c.to - c.spaceAfter.length + (c.spaceAfter ? 1 : 0);
        if (o - a.from > f && !/\S/.test(a.text.slice(f, o - a.from)))
          return {
            range: v.cursor(a.from + f),
            changes: { from: a.from + f, to: o }
          };
        if (o - a.from == f && // Only apply this if we're on the line that has the
        // construct's syntax, or there's only indentation in the
        // target range
        (!c.item || a.from <= c.item.from || !/\S/.test(a.text.slice(0, c.to)))) {
          let u = a.from + c.from;
          if (c.item && c.node.from < c.item.from && /\S/.test(a.text.slice(c.from, c.to))) {
            let d = c.blank(lt(a.text, 4, c.to) - lt(a.text, 4, c.from));
            return u == a.from && (d = zh(d, r)), {
              range: v.cursor(u + d.length),
              changes: { from: u, to: a.from + c.to, insert: d }
            };
          }
          if (u < o)
            return { range: v.cursor(u), changes: { from: u, to: o } };
        }
      }
    }
    return i = { range: s };
  });
  return i ? !1 : (e(r.update(n, { scrollIntoView: !0, userEvent: "delete" })), !0);
}, W$ = [
  { key: "Enter", run: V$ },
  { key: "Backspace", run: N$ }
], xg = /* @__PURE__ */ X$({ matchClosingTags: !1 });
function j$(r = {}) {
  let { codeLanguages: e, defaultCodeLanguage: t, addKeymap: i = !0, base: { parser: n } = D$, completeHTMLTags: s = !0, pasteURLAsLink: o = !0, htmlTagLanguage: l = xg } = r;
  if (!(n instanceof yo))
    throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");
  let a = r.extensions ? [r.extensions] : [], h = [l.support, z$], c;
  o && h.push(H$), t instanceof Jr ? (h.push(t.support), c = t.language) : t && (c = t);
  let f = e || c ? B$(e, c) : void 0;
  a.push(Jk({ codeParser: f, htmlParser: l.language.parser })), i && h.push(Vt.high(Ci.of(W$)));
  let u = Eh(n.configure(a));
  return s && h.push(u.data.of({ autocomplete: G$ })), new Jr(u, h);
}
function G$(r) {
  let { state: e, pos: t } = r, i = /<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t - 25, t));
  if (!i)
    return null;
  let n = ve(e).resolveInner(t, -1);
  for (; n && !n.type.isTop; ) {
    if (n.name == "CodeBlock" || n.name == "FencedCode" || n.name == "ProcessingInstructionBlock" || n.name == "CommentBlock" || n.name == "Link" || n.name == "Image")
      return null;
    n = n.parent;
  }
  return {
    from: t - i[0].length,
    to: t,
    options: U$(),
    validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
  };
}
let Ol = null;
function U$() {
  if (Ol)
    return Ol;
  let r = A$(new xk(W.create({ extensions: xg }), 0, !0));
  return Ol = r ? r.options : [];
}
const F$ = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i, H$ = /* @__PURE__ */ D.domEventHandlers({
  paste: (r, e) => {
    var t;
    let { main: i } = e.state.selection;
    if (i.empty)
      return !1;
    let n = (t = r.clipboardData) === null || t === void 0 ? void 0 : t.getData("text/plain");
    if (!n || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(n) || (/^www\./.test(n) && (n = "https://" + n), !Ks.isActiveAt(e.state, i.from, 1)))
      return !1;
    let s = ve(e.state), o = !1;
    return s.iterate({
      from: i.from,
      to: i.to,
      enter: (l) => {
        (l.from > i.from || F$.test(l.name)) && (o = !0);
      },
      leave: (l) => {
        l.to < i.to && (o = !0);
      }
    }), o ? !1 : (e.dispatch({
      changes: [{ from: i.from, insert: "[" }, { from: i.to, insert: `](${n})` }],
      userEvent: "input.paste",
      scrollIntoView: !0
    }), !0);
  }
}), K$ = "#e5c07b", Eu = "#e06c75", J$ = "#56b6c2", eP = "#ffffff", Os = "#abb2bf", za = "#7d8799", tP = "#61afef", iP = "#98c379", zu = "#d19a66", rP = "#c678dd", nP = "#21252b", Du = "#2c313a", _u = "#282c34", ml = "#353a42", sP = "#3E4451", Bu = "#528bff", oP = /* @__PURE__ */ D.theme({
  "&": {
    color: Os,
    backgroundColor: _u
  },
  ".cm-content": {
    caretColor: Bu
  },
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: Bu },
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: sP },
  ".cm-panels": { backgroundColor: nP, color: Os },
  ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
  ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
  ".cm-searchMatch": {
    backgroundColor: "#72a1ff59",
    outline: "1px solid #457dff"
  },
  ".cm-searchMatch.cm-searchMatch-selected": {
    backgroundColor: "#6199ff2f"
  },
  ".cm-activeLine": { backgroundColor: "#6699ff0b" },
  ".cm-selectionMatch": { backgroundColor: "#aafe661a" },
  "&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
    backgroundColor: "#bad0f847"
  },
  ".cm-gutters": {
    backgroundColor: _u,
    color: za,
    border: "none"
  },
  ".cm-activeLineGutter": {
    backgroundColor: Du
  },
  ".cm-foldPlaceholder": {
    backgroundColor: "transparent",
    border: "none",
    color: "#ddd"
  },
  ".cm-tooltip": {
    border: "none",
    backgroundColor: ml
  },
  ".cm-tooltip .cm-tooltip-arrow:before": {
    borderTopColor: "transparent",
    borderBottomColor: "transparent"
  },
  ".cm-tooltip .cm-tooltip-arrow:after": {
    borderTopColor: ml,
    borderBottomColor: ml
  },
  ".cm-tooltip-autocomplete": {
    "& > ul > li[aria-selected]": {
      backgroundColor: Du,
      color: Os
    }
  }
}, { dark: !0 }), lP = /* @__PURE__ */ bo.define([
  {
    tag: m.keyword,
    color: rP
  },
  {
    tag: [m.name, m.deleted, m.character, m.propertyName, m.macroName],
    color: Eu
  },
  {
    tag: [/* @__PURE__ */ m.function(m.variableName), m.labelName],
    color: tP
  },
  {
    tag: [m.color, /* @__PURE__ */ m.constant(m.name), /* @__PURE__ */ m.standard(m.name)],
    color: zu
  },
  {
    tag: [/* @__PURE__ */ m.definition(m.name), m.separator],
    color: Os
  },
  {
    tag: [m.typeName, m.className, m.number, m.changed, m.annotation, m.modifier, m.self, m.namespace],
    color: K$
  },
  {
    tag: [m.operator, m.operatorKeyword, m.url, m.escape, m.regexp, m.link, /* @__PURE__ */ m.special(m.string)],
    color: J$
  },
  {
    tag: [m.meta, m.comment],
    color: za
  },
  {
    tag: m.strong,
    fontWeight: "bold"
  },
  {
    tag: m.emphasis,
    fontStyle: "italic"
  },
  {
    tag: m.strikethrough,
    textDecoration: "line-through"
  },
  {
    tag: m.link,
    color: za,
    textDecoration: "underline"
  },
  {
    tag: m.heading,
    fontWeight: "bold",
    color: Eu
  },
  {
    tag: [m.atom, m.bool, /* @__PURE__ */ m.special(m.variableName)],
    color: zu
  },
  {
    tag: [m.processingInstruction, m.string, m.inserted],
    color: iP
  },
  {
    tag: m.invalid,
    color: eP
  }
]), aP = [oP, /* @__PURE__ */ Ok(lP)];
class hP {
  constructor(e, t) {
    if (this.textarea = e, this.preview = t, this._updateTimeout = null, this.editorView = null, this._isSyncing = !1, this._autoSaveTimeout = null, !this.textarea || !this.preview) {
      console.error("MarkdownEditor: textarea or preview element not found");
      return;
    }
    this.init();
  }
  init() {
    typeof marked < "u" && marked.setOptions({
      gfm: !0,
      breaks: !0,
      highlight: (i, n) => {
        if (typeof hljs < "u")
          try {
            return n && hljs.getLanguage(n) ? hljs.highlight(i, { language: n }).value : hljs.highlightAuto(i).value;
          } catch (s) {
            console.warn("Highlight.js error:", s);
          }
        return i;
      }
    });
    const e = W.create({
      doc: this.textarea.value,
      extensions: [
        _x,
        j$(),
        aP,
        Ci.of([mw]),
        D.updateListener.of((i) => {
          i.docChanged && (this._updateTimeout && clearTimeout(this._updateTimeout), this._updateTimeout = setTimeout(() => {
            this.updatePreview();
          }, 150), this._autoSaveTimeout && clearTimeout(this._autoSaveTimeout), this._autoSaveTimeout = setTimeout(() => {
            const n = this.textarea.closest("form");
            if (n) {
              const s = document.getElementById("auto-save-status");
              s && (s.textContent = "Sauvegarde..."), n.requestSubmit();
            }
          }, 2e3));
        }),
        // Keymap for Ctrl/Cmd+S
        Ci.of([{
          key: "Mod-s",
          run: () => {
            const i = this.textarea.closest("form");
            return i && i.requestSubmit(), !0;
          }
        }])
      ]
    });
    this.editorView = new D({
      state: e,
      parent: this.textarea.parentElement
    }), this.textarea.style.display = "none";
    const t = () => {
      const i = this.editorView.dom;
      if (!i) return;
      const n = window.innerHeight - 180;
      i.style.height = `${n}px`, i.style.maxHeight = `${n}px`, i.style.overflowY = "auto";
    };
    t(), window.addEventListener("resize", t), this.editorView.dom.addEventListener("scroll", () => {
      if (this._isSyncing) return;
      this._isSyncing = !0;
      const i = this.editorView.scrollDOM.scrollTop, n = this.editorView.scrollDOM.scrollHeight - this.editorView.scrollDOM.clientHeight;
      if (n > 0 && this.preview) {
        const s = i / n, o = this.preview.scrollHeight - this.preview.clientHeight;
        o > 0 && (this.preview.scrollTop = s * o);
      }
      setTimeout(() => {
        this._isSyncing = !1;
      }, 50);
    }), this.preview.addEventListener("scroll", () => {
      if (this._isSyncing) return;
      this._isSyncing = !0;
      const i = this.preview.scrollTop, n = this.preview.scrollHeight - this.preview.clientHeight;
      if (n > 0 && this.editorView) {
        const s = i / n, o = this.editorView.scrollDOM.scrollHeight - this.editorView.scrollDOM.clientHeight;
        o > 0 && (this.editorView.scrollDOM.scrollTop = s * o);
      }
      setTimeout(() => {
        this._isSyncing = !1;
      }, 50);
    }), this.updatePreview();
  }
  stripFrontMatter(e) {
    const t = e.split(`
`);
    if (t.length > 0 && t[0].trim() === "---") {
      let i = -1, n = -1;
      for (let s = 0; s < t.length; s++)
        if (t[s].trim() === "---")
          if (i === -1)
            i = s;
          else {
            n = s;
            break;
          }
      if (i !== -1 && n !== -1)
        return t.slice(n + 1).join(`
`);
    }
    return e;
  }
  updatePreview() {
    const e = this.editorView ? this.editorView.state.doc.toString() : this.textarea.value, t = this.stripFrontMatter(e);
    if (typeof marked < "u" && typeof DOMPurify < "u") {
      const i = marked.parse(t), n = DOMPurify.sanitize(i, {
        ADD_ATTR: ["hx-get", "hx-target", "hx-swap", "onclick"]
      });
      this.preview.innerHTML = n, typeof htmx < "u" && htmx.process(this.preview), typeof hljs < "u" && this.preview.querySelectorAll("pre code").forEach((s) => {
        hljs.highlightElement(s);
      });
    } else
      this.preview.textContent = t;
  }
  destroy() {
    this._updateTimeout && (clearTimeout(this._updateTimeout), this._updateTimeout = null), this._autoSaveTimeout && (clearTimeout(this._autoSaveTimeout), this._autoSaveTimeout = null), this.editorView && (this.editorView.destroy(), this.editorView = null), this.textarea && (this.textarea.style.display = ""), this.textarea = null, this.preview = null;
  }
}
class cP {
  constructor({ editorView: e }) {
    if (this.editorView = e, !this.editorView) {
      console.error("SlashCommands: EditorView instance required");
      return;
    }
    this.active = !1, this.query = "", this.selectedIndex = 0, this.palette = null, this.slashPos = null, this._updateListener = null, this._keydownHandler = null, this.commands = [
      { name: "h1", snippet: "# " },
      { name: "h2", snippet: "## " },
      { name: "h3", snippet: "### " },
      { name: "list", snippet: "- " },
      { name: "date", snippet: () => (/* @__PURE__ */ new Date()).toLocaleDateString("fr-FR") },
      { name: "link", snippet: "[texte](url)" },
      { name: "bold", snippet: "**texte**" },
      { name: "italic", snippet: "*texte*" },
      { name: "code", snippet: "`code`" },
      { name: "codeblock", snippet: "```\ncode\n```" },
      { name: "quote", snippet: "> " },
      { name: "hr", snippet: "---" },
      { name: "table", snippet: `| Colonne 1 | Colonne 2 | Colonne 3 |
|-----------|-----------|-----------|
| Ligne 1   | Données   | Données   |
| Ligne 2   | Données   | Données   |` }
    ], this.init();
  }
  init() {
    this.createPalette(), this._inputHandler = () => {
      Promise.resolve().then(() => {
        this.checkForSlashCommand();
      });
    }, this._selectionHandler = () => {
      Promise.resolve().then(() => {
        this.checkForSlashCommand();
      });
    }, this.editorView.dom.addEventListener("input", this._inputHandler), this.editorView.dom.addEventListener("selectionchange", this._selectionHandler), this._keydownHandler = (e) => {
      if (!this.active) return;
      const t = this.getFilteredCommands();
      if (t.length === 0) {
        this.hidePalette();
        return;
      }
      let i = !1;
      switch (e.key) {
        case "ArrowDown":
          this.selectedIndex = (this.selectedIndex + 1) % t.length, this.updatePalette(), i = !0;
          break;
        case "ArrowUp":
          this.selectedIndex = (this.selectedIndex - 1 + t.length) % t.length, this.updatePalette(), i = !0;
          break;
        case "Enter":
        case "Tab":
          this.executeCommand(t[this.selectedIndex]), i = !0;
          break;
        case "Escape":
          this.hidePalette(), i = !0;
          break;
      }
      i && (e.preventDefault(), e.stopPropagation());
    }, this.editorView.dom.addEventListener("keydown", this._keydownHandler, !0);
  }
  createPalette() {
    this.palette = document.createElement("ul"), this.palette.id = "slash-commands-palette", this.palette.style.cssText = `
            position: fixed;
            background: #161b22;
            background-color: #161b22 !important;
            border: 1px solid #58a6ff;
            list-style: none;
            padding: 0.5rem;
            margin: 0;
            border-radius: 8px;
            z-index: 10000;
            display: none;
            min-width: 220px;
            max-height: 320px;
            overflow-y: auto;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(88, 166, 255, 0.2);
            opacity: 1 !important;
        `, document.body.appendChild(this.palette);
  }
  checkForSlashCommand() {
    if (!this.editorView) return;
    const { state: e } = this.editorView, { from: t, to: i } = e.selection.main;
    if (t !== i) {
      this.hidePalette();
      return;
    }
    const n = e.doc.lineAt(t), s = e.doc.sliceString(n.from, t), o = s.lastIndexOf("/");
    if (o === -1) {
      this.hidePalette();
      return;
    }
    const l = o > 0 ? s[o - 1] : "";
    if (!(o === 0 || /\s/.test(l))) {
      this.hidePalette();
      return;
    }
    const h = s.substring(o + 1);
    if (h.includes(" ") || h.includes(`
`)) {
      this.hidePalette();
      return;
    }
    this.query = h, this.slashPos = { lineNumber: n.number, offset: o, absolutePos: n.from + o }, this.active || (this.selectedIndex = 0), this.showPalette();
  }
  getFilteredCommands() {
    return this.query ? this.commands.filter(
      (e) => e.name.toLowerCase().includes(this.query.toLowerCase())
    ) : this.commands;
  }
  showPalette() {
    if (this.getFilteredCommands().length === 0) {
      this.hidePalette();
      return;
    }
    this.active = !0, this.updatePalette(), this.positionPalette(), this.palette && (this.palette.style.display = "block");
  }
  hidePalette() {
    this.active = !1, this.query = "", this.selectedIndex = 0, this.slashPos = null, this.palette && (this.palette.style.display = "none");
  }
  updatePalette() {
    if (!this.palette) return;
    const e = this.getFilteredCommands();
    this.palette.innerHTML = "", e.forEach((t, i) => {
      const n = document.createElement("li");
      n.innerHTML = `<span style="color: #7d8590; margin-right: 0.5rem;">⌘</span>/${t.name}`;
      const s = i === this.selectedIndex;
      n.style.cssText = `
                padding: 0.5rem 0.75rem;
                cursor: pointer;
                color: ${s ? "white" : "#e6edf3"};
                background: ${s ? "linear-gradient(135deg, #58a6ff, #8b5cf6)" : "transparent"};
                border-radius: 4px;
                margin: 4px 0;
                transition: all 150ms ease;
                font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
                font-size: 0.9rem;
                font-weight: ${s ? "500" : "400"};
                display: flex;
                align-items: center;
            `, n.addEventListener("mouseenter", () => {
        this.selectedIndex = i, this.updatePalette();
      }), n.addEventListener("click", (o) => {
        o.preventDefault(), o.stopPropagation(), this.executeCommand(t);
      }), this.palette.appendChild(n), s && n.scrollIntoView({
        block: "nearest",
        behavior: "auto"
      });
    });
  }
  positionPalette() {
    !this.palette || !this.editorView || !this.slashPos || requestAnimationFrame(() => {
      const { state: e } = this.editorView, { from: t } = e.selection.main, i = this.editorView.coordsAtPos(t);
      if (i) {
        const { left: n, bottom: s } = i, o = 320, h = window.innerHeight - s < o && s > o;
        this.palette.style.left = `${n}px`, h ? (this.palette.style.top = `${i.top - o - 5}px`, this.palette.style.bottom = "auto") : (this.palette.style.top = `${s + 5}px`, this.palette.style.bottom = "auto");
      }
    });
  }
  executeCommand(e) {
    if (!e || !this.slashPos) {
      this.hidePalette();
      return;
    }
    let t = e.snippet;
    typeof t == "function" && (t = t());
    const { state: i, dispatch: n } = this.editorView, { from: s } = i.selection.main, o = this.slashPos.absolutePos;
    n(i.update({
      changes: { from: o, to: s, insert: t },
      selection: { anchor: o + t.length }
    })), this.editorView.focus(), this.hidePalette();
  }
  destroy() {
    this.editorView && (this._keydownHandler && (this.editorView.dom.removeEventListener("keydown", this._keydownHandler, !0), this._keydownHandler = null), this._inputHandler && (this.editorView.dom.removeEventListener("input", this._inputHandler), this._inputHandler = null), this._selectionHandler && (this.editorView.dom.removeEventListener("selectionchange", this._selectionHandler), this._selectionHandler = null)), this.hidePalette(), this.palette && this.palette.parentNode && this.palette.parentNode.removeChild(this.palette), this.palette = null, this.editorView = null;
  }
}
window.currentMarkdownEditor = null;
window.currentSlashCommands = null;
function Iu(r) {
  const e = r && typeof r.querySelector == "function" ? r : document, t = e.querySelector("#editor") || document.getElementById("editor"), i = e.querySelector("#preview") || document.getElementById("preview");
  if (!t || !i) {
    console.error("initializeMarkdownEditor: Missing textarea or preview elements");
    return;
  }
  window.currentMarkdownEditor && (window.currentMarkdownEditor.destroy(), window.currentMarkdownEditor = null), window.currentSlashCommands && (window.currentSlashCommands.destroy(), window.currentSlashCommands = null);
  const n = new hP(t, i);
  if (window.currentMarkdownEditor = n, n.editorView) {
    const s = new cP({
      editorView: n.editorView
    });
    window.currentSlashCommands = s;
  }
}
window.togglePreview = function() {
  const r = document.getElementById("editor-grid"), e = document.querySelector(".editor-panel"), t = document.getElementById("preview"), i = document.getElementById("toggle-preview-btn");
  if (!r || !e || !t || !i) {
    console.error("togglePreview: Missing elements", { grid: r, editorPanel: e, preview: t, btn: i });
    return;
  }
  const n = window.innerWidth <= 768;
  let s = localStorage.getItem("viewMode") || "split", o;
  n ? s === "editor-only" ? o = "preview-only" : o = "editor-only" : s === "split" ? o = "editor-only" : s === "editor-only" ? o = "preview-only" : o = "split", window.applyViewMode(o, document);
};
window.applyViewMode = function(r, e) {
  const t = e && typeof e.querySelector == "function" ? e : document, i = t.querySelector("#editor-grid"), n = t.querySelector(".editor-panel"), s = t.querySelector("#preview"), o = t.querySelector("#toggle-preview-btn");
  if (!i || !n || !s) {
    console.error("applyViewMode: Missing essential elements", { grid: i, editorPanel: n, preview: s });
    return;
  }
  const l = window.innerWidth <= 768;
  switch (i.classList.remove("preview-hidden", "editor-hidden", "split-view"), n.classList.remove("hidden"), s.classList.remove("hidden"), r) {
    case "editor-only":
      i.classList.add("preview-hidden"), s.classList.add("hidden"), o && (o.textContent = "◧ Éditeur", o.title = l ? "Mode: Éditeur → Cliquer pour Preview" : "Mode: Éditeur seul → Cliquer pour Preview seule");
      break;
    case "preview-only":
      i.classList.add("editor-hidden"), n.classList.add("hidden"), o && (o.textContent = "◨ Preview", o.title = l ? "Mode: Preview → Cliquer pour Éditeur" : "Mode: Preview seule → Cliquer pour Split");
      break;
    case "split":
    default:
      i.classList.add("split-view"), o && (o.textContent = "◫ Split", o.title = "Mode: Split → Cliquer pour Éditeur seul");
      break;
  }
  localStorage.setItem("viewMode", r);
};
window.restorePreviewState = function(r) {
  const e = localStorage.getItem("viewMode") || "split";
  window.applyViewMode(e, r);
};
document.addEventListener("DOMContentLoaded", () => {
  const r = document.querySelector("#editor"), e = document.querySelector("#preview");
  r && e && (Iu(), window.restorePreviewState(document)), document.body.addEventListener("htmx:beforeSwap", (t) => {
    const i = t.detail?.target;
    if (i && i.id === "editor-container") {
      const n = t.detail.serverResponse;
      if (n) {
        const s = document.createElement("div");
        s.innerHTML = n;
        const o = s.querySelector("#editor-grid"), l = s.querySelector(".editor-panel"), a = s.querySelector("#preview"), h = s.querySelector("#toggle-preview-btn");
        if (o && l && a) {
          if (!h)
            return;
          const f = localStorage.getItem("viewMode") || "split", d = window.innerWidth <= 768 && f === "split" ? "preview-only" : f;
          switch (o.classList.remove("preview-hidden", "editor-hidden", "split-view"), l.classList.remove("hidden"), a.classList.remove("hidden"), d) {
            case "editor-only":
              o.classList.add("preview-hidden"), a.classList.add("hidden");
              break;
            case "preview-only":
              o.classList.add("editor-hidden"), l.classList.add("hidden");
              break;
            case "split":
            default:
              o.classList.add("split-view");
              break;
          }
          t.detail.serverResponse = s.innerHTML;
        }
      }
    }
  }), document.body.addEventListener("htmx:afterSwap", (t) => {
    const i = t.detail?.target;
    if (i && i.id === "editor-container") {
      i.removeAttribute("hx-trigger"), i.removeAttribute("hx-get");
      const n = i.querySelector("#editor"), s = i.querySelector("#preview"), l = !i.querySelector("#toggle-preview-btn");
      n && s ? (Iu(i), l || window.restorePreviewState(i)) : (window.currentMarkdownEditor && (window.currentMarkdownEditor.destroy(), window.currentMarkdownEditor = null), window.currentSlashCommands && (window.currentSlashCommands.destroy(), window.currentSlashCommands = null));
    }
  });
});
class fP {
  constructor() {
    this.init();
  }
  init() {
    document.body.addEventListener("htmx:afterSwap", (e) => {
      (e.detail.target.id === "file-tree" || e.detail.target.closest("#file-tree")) && (this.setupFolderToggles(), this.setupDragAndDrop());
    }), document.getElementById("file-tree") && (this.setupFolderToggles(), this.setupDragAndDrop());
  }
  setupFolderToggles() {
    document.querySelectorAll(".folder-header").forEach((t) => {
      t.dataset.toggleInitialized !== "true" && (t.dataset.toggleInitialized = "true", t.addEventListener("click", (i) => {
        i.stopPropagation(), this.toggleFolder(t);
      }));
    });
  }
  toggleFolder(e) {
    const i = e.parentElement.querySelector(".folder-children"), n = e.querySelector(".folder-toggle"), s = e.querySelector(".folder-icon");
    i.style.display === "none" ? (i.style.display = "block", n.classList.add("expanded"), s.textContent = "📂") : (i.style.display = "none", n.classList.remove("expanded"), s.textContent = "📁");
  }
  setupDragAndDrop() {
    const e = document.querySelectorAll('.file-item[draggable="true"]'), t = document.querySelectorAll(".folder-item");
    console.log("Setup drag & drop:", {
      filesCount: e.length,
      foldersCount: t.length
    }), e.forEach((i) => {
      i.addEventListener("dragstart", (n) => this.handleDragStart(n)), i.addEventListener("dragend", (n) => this.handleDragEnd(n)), i.addEventListener("click", (n) => {
        n.dataTransfer && n.preventDefault();
      }, !0);
    }), t.forEach((i) => {
      const n = i.querySelector(".folder-header");
      n.addEventListener("dragover", (s) => this.handleDragOver(s)), n.addEventListener("dragleave", (s) => this.handleDragLeave(s)), n.addEventListener("drop", (s) => this.handleDrop(s));
    });
  }
  handleDragStart(e) {
    const t = e.target;
    t.classList.add("dragging");
    const i = t.dataset.path;
    e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", i), e.dataTransfer.setData("application/note-path", i);
  }
  handleDragEnd(e) {
    e.target.classList.remove("dragging"), document.querySelectorAll(".folder-item.drag-over").forEach((i) => {
      i.classList.remove("drag-over");
    });
  }
  handleDragOver(e) {
    e.preventDefault(), e.stopPropagation(), e.dataTransfer.dropEffect = "move";
    const i = e.currentTarget.closest(".folder-item");
    i && !i.classList.contains("drag-over") && i.classList.add("drag-over");
  }
  handleDragLeave(e) {
    e.stopPropagation();
    const t = e.currentTarget, i = t.closest(".folder-item"), n = t.getBoundingClientRect();
    (e.clientX < n.left || e.clientX >= n.right || e.clientY < n.top || e.clientY >= n.bottom) && i && i.classList.remove("drag-over");
  }
  handleDrop(e) {
    e.preventDefault(), e.stopPropagation();
    const i = e.currentTarget.closest(".folder-item");
    i.classList.remove("drag-over");
    const n = e.dataTransfer.getData("application/note-path") || e.dataTransfer.getData("text/plain"), s = i.dataset.path;
    if (console.log("Drop event:", {
      sourcePath: n,
      targetFolderPath: s,
      dataTransfer: e.dataTransfer.types,
      folderItem: i
    }), !n || !s) {
      console.error("Chemins invalides pour le drag & drop", {
        sourcePath: n,
        targetFolderPath: s,
        folderItemDataset: i.dataset
      }), alert(`Erreur: source='${n}', destination='${s}'`);
      return;
    }
    if ((n.includes("/") ? n.substring(0, n.lastIndexOf("/")) : "") === s)
      return;
    const l = n.includes("/") ? n.substring(n.lastIndexOf("/") + 1) : n, a = s + "/" + l;
    this.moveFile(n, a);
  }
  async moveFile(e, t) {
    console.log("moveFile called:", { sourcePath: e, destinationPath: t });
    try {
      const i = new URLSearchParams({
        source: e,
        destination: t
      });
      console.log("FormData contents:", {
        source: i.get("source"),
        destination: i.get("destination")
      });
      const n = await fetch("/api/files/move", {
        method: "POST",
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        body: i
      });
      if (!n.ok) {
        const a = await n.text();
        throw new Error(a || "Erreur lors du déplacement du fichier");
      }
      const s = await n.text(), o = document.createElement("div");
      o.innerHTML = s;
      const l = o.querySelector("[hx-swap-oob]");
      if (l) {
        const a = l.id, h = document.getElementById(a);
        h && (h.innerHTML = l.innerHTML, this.setupFolderToggles(), this.setupDragAndDrop());
      }
      console.log(`Fichier déplacé: ${e} -> ${t}`);
    } catch (i) {
      console.error("Erreur lors du déplacement:", i), alert("Erreur lors du déplacement du fichier: " + i.message);
    }
  }
}
window.showNewNoteModal = function() {
  const r = document.getElementById("new-note-modal");
  r.style.display = "flex", setTimeout(() => {
    document.getElementById("note-name").focus();
  }, 100);
};
window.hideNewNoteModal = function() {
  const r = document.getElementById("new-note-modal");
  r.style.display = "none", document.getElementById("note-name").value = "";
};
window.handleNewNote = function(r) {
  r.preventDefault();
  let e = document.getElementById("note-name").value.trim();
  if (!e) {
    alert("Veuillez entrer un nom de note");
    return;
  }
  if (e.endsWith(".md") || (e += ".md"), e.includes("..") || e.includes("\\")) {
    alert("Nom de note invalide. Évitez les caractères \\ et ..");
    return;
  }
  window.hideNewNoteModal(), document.getElementById("editor-container").removeAttribute("hx-trigger"), typeof htmx < "u" && htmx.ajax("GET", `/api/notes/${encodeURIComponent(e)}`, {
    target: "#editor-container",
    swap: "innerHTML"
  });
};
window.showNewFolderModal = function() {
  const r = document.getElementById("new-folder-modal");
  r.style.display = "flex", setTimeout(() => {
    document.getElementById("folder-name").focus();
  }, 100);
};
window.hideNewFolderModal = function() {
  const r = document.getElementById("new-folder-modal");
  r.style.display = "none", document.getElementById("folder-name").value = "";
};
window.handleNewFolder = async function(r) {
  r.preventDefault();
  let e = document.getElementById("folder-name").value.trim();
  if (!e) {
    alert("Veuillez entrer un nom de dossier");
    return;
  }
  if (e.includes("..") || e.includes("\\")) {
    alert("Nom de dossier invalide. Évitez les caractères  et ..");
    return;
  }
  try {
    const t = new URLSearchParams({
      path: e
    }), i = await fetch("/api/folders/create", {
      method: "POST",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      body: t
    });
    if (!i.ok) {
      const l = await i.text();
      throw new Error(l || "Erreur lors de la création du dossier");
    }
    const n = await i.text(), s = document.createElement("div");
    s.innerHTML = n;
    const o = s.querySelector("[hx-swap-oob]");
    if (o) {
      const l = o.id, a = document.getElementById(l);
      a && (a.innerHTML = o.innerHTML, window.fileTree.setupFolderToggles(), window.fileTree.setupDragAndDrop());
    }
    window.hideNewFolderModal();
  } catch (t) {
    console.error("Erreur lors de la création du dossier:", t), alert("Erreur lors de la création du dossier: " + t.message);
  }
};
document.addEventListener("keydown", (r) => {
  if (r.key === "Escape") {
    const e = document.getElementById("new-folder-modal"), t = document.getElementById("new-note-modal");
    e && e.style.display === "flex" && window.hideNewFolderModal(), t && t.style.display === "flex" && window.hideNewNoteModal();
  }
});
document.addEventListener("DOMContentLoaded", () => {
  window.fileTree = new fP();
});
function Js() {
  return window.innerWidth <= 768;
}
window.toggleSidebar = function() {
  const r = document.querySelector("aside"), e = document.querySelector(".sidebar-overlay");
  if (!r) {
    console.error("Aside element not found");
    return;
  }
  if (Js())
    r.classList.contains("sidebar-visible") ? (r.classList.remove("sidebar-visible"), e && e.classList.remove("active")) : (r.classList.add("sidebar-visible"), e && e.classList.add("active"));
  else {
    const i = document.querySelector(".main-layout");
    if (i) {
      i.classList.toggle("sidebar-hidden");
      const n = i.classList.contains("sidebar-hidden");
      localStorage.setItem("sidebarVisible", !n);
    }
  }
};
function Vu() {
  if (Js()) {
    const e = localStorage.getItem("viewMode");
    (!e || e === "split") && localStorage.setItem("viewMode", "preview-only");
    const t = document.querySelector("aside");
    t && t.classList.remove("sidebar-visible");
    const i = document.querySelector(".sidebar-overlay");
    i && i.classList.remove("active");
  }
}
document.addEventListener("DOMContentLoaded", () => {
  const r = document.getElementById("toggle-sidebar-btn"), e = document.querySelector(".main-layout");
  Vu(), r && e && (Js() || localStorage.getItem("sidebarVisible") === "false" && e.classList.add("sidebar-hidden"), r.addEventListener("click", toggleSidebar));
  let t;
  window.addEventListener("resize", () => {
    clearTimeout(t), t = setTimeout(() => {
      Vu();
    }, 250);
  }), document.body.addEventListener("htmx:afterSwap", (i) => {
    if ((i.detail.target.id === "editor-container" || i.detail.target.id === "main-content") && Js()) {
      const s = document.querySelector("aside"), o = document.querySelector(".sidebar-overlay");
      s && s.classList.contains("sidebar-visible") && (s.classList.remove("sidebar-visible"), o && o.classList.remove("active"));
    }
  });
});
class uP {
  constructor() {
    this.modal = null, this.input = null, this.resultsContainer = null, this.isOpen = !1, this.searchTimeout = null, this.selectedIndex = 0, this.results = [], this._keydownHandler = null, this.init();
  }
  init() {
    this.createModal(), this.attachKeyboardShortcuts();
  }
  createModal() {
    this.modal = document.createElement("div"), this.modal.id = "search-modal", this.modal.className = "search-modal", this.modal.style.display = "none", this.modal.innerHTML = `
            <div class="search-modal-overlay"></div>
            <div class="search-modal-container">
                <div class="search-modal-header">
                    <div class="search-modal-input-wrapper">
                        <svg class="search-modal-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <circle cx="11" cy="11" r="8"></circle>
                            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                        </svg>
                        <input
                            type="text"
                            class="search-modal-input"
                            placeholder="Rechercher dans les notes... (tag:projet, title:réunion, path:docs)"
                            autocomplete="off"
                            spellcheck="false"
                        />
                        <kbd class="search-modal-kbd">ESC</kbd>
                    </div>
                </div>
                <div class="search-modal-body">
                    <div class="search-modal-results">
                        <div class="search-modal-help">
                            <div class="search-modal-help-title">💡 Recherche avancée</div>
                            <div class="search-modal-help-items">
                                <div class="search-modal-help-item">
                                    <code>tag:projet</code>
                                    <span>Filtrer par tag</span>
                                </div>
                                <div class="search-modal-help-item">
                                    <code>title:réunion</code>
                                    <span>Rechercher dans les titres</span>
                                </div>
                                <div class="search-modal-help-item">
                                    <code>path:docs</code>
                                    <span>Rechercher dans les chemins</span>
                                </div>
                                <div class="search-modal-help-item">
                                    <code>"phrase exacte"</code>
                                    <span>Recherche de phrase</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="search-modal-footer">
                    <div class="search-modal-footer-hint">
                        <kbd>↑</kbd><kbd>↓</kbd> Navigation
                        <kbd>↵</kbd> Ouvrir
                        <kbd>ESC</kbd> Fermer
                    </div>
                </div>
            </div>
        `, document.body.appendChild(this.modal), this.input = this.modal.querySelector(".search-modal-input"), this.resultsContainer = this.modal.querySelector(".search-modal-results"), this.modal.querySelector(".search-modal-overlay").addEventListener("click", () => {
      this.close();
    }), this.input.addEventListener("input", (e) => {
      this.handleSearch(e.target.value);
    }), this.input.addEventListener("keydown", (e) => {
      this.handleKeyNavigation(e);
    });
  }
  attachKeyboardShortcuts() {
    this._keydownHandler = (e) => {
      (e.ctrlKey || e.metaKey) && e.key === "k" && (e.preventDefault(), this.toggle()), e.key === "Escape" && this.isOpen && (e.preventDefault(), this.close());
    }, document.addEventListener("keydown", this._keydownHandler);
  }
  handleSearch(e) {
    if (clearTimeout(this.searchTimeout), !e.trim()) {
      this.showHelp();
      return;
    }
    this.showLoading(), this.searchTimeout = setTimeout(async () => {
      try {
        const i = await (await fetch(`/api/search?query=${encodeURIComponent(e)}`)).text(), o = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".search-result-link");
        this.results = Array.from(o).map((l, a) => ({
          index: a,
          element: l.cloneNode(!0)
        })), this.results.length > 0 ? this.renderResults(e) : this.showNoResults(e);
      } catch (t) {
        console.error("[SearchModal] Erreur de recherche:", t), this.showError();
      }
    }, 300);
  }
  handleKeyNavigation(e) {
    if (this.results.length !== 0)
      switch (e.key) {
        case "ArrowDown":
          e.preventDefault(), this.selectedIndex = Math.min(this.selectedIndex + 1, this.results.length - 1), this.updateSelection();
          break;
        case "ArrowUp":
          e.preventDefault(), this.selectedIndex = Math.max(this.selectedIndex - 1, 0), this.updateSelection();
          break;
        case "Enter":
          e.preventDefault(), this.selectResult();
          break;
      }
  }
  updateSelection() {
    this.resultsContainer.querySelectorAll(".search-modal-result-item").forEach((t, i) => {
      i === this.selectedIndex ? (t.classList.add("selected"), t.scrollIntoView({ block: "nearest", behavior: "smooth" })) : t.classList.remove("selected");
    });
  }
  selectResult() {
    if (this.results.length === 0) return;
    const e = this.results[this.selectedIndex];
    if (e && e.element) {
      const t = e.element.getAttribute("hx-get");
      t && (htmx.ajax("GET", t, {
        target: "#editor-container",
        swap: "innerHTML"
      }), this.close());
    }
  }
  renderResults(e) {
    this.resultsContainer.innerHTML = "", this.selectedIndex = 0;
    const t = document.createElement("div");
    t.className = "search-modal-results-header", t.innerHTML = `
            <span class="search-modal-results-count">${this.results.length} résultat${this.results.length > 1 ? "s" : ""}</span>
        `, this.resultsContainer.appendChild(t), this.results.forEach((i, n) => {
      const s = document.createElement("div");
      s.className = "search-modal-result-item", n === 0 && s.classList.add("selected");
      const o = i.element, l = o.querySelector(".search-result-icon")?.textContent || "📄", a = o.querySelector(".search-result-title")?.textContent || "Sans titre", h = o.querySelector(".search-result-path")?.textContent || "", c = o.querySelector(".search-result-snippet")?.textContent || "", f = Array.from(o.querySelectorAll(".tag-pill")).map((d) => d.textContent), u = o.querySelector(".search-result-date")?.textContent || "";
      s.innerHTML = `
                <div class="search-modal-result-icon">${l}</div>
                <div class="search-modal-result-content">
                    <div class="search-modal-result-title">${this.highlightQuery(a, e)}</div>
                    <div class="search-modal-result-path">${h}</div>
                    ${c ? `<div class="search-modal-result-snippet">${this.highlightQuery(c, e)}</div>` : ""}
                    <div class="search-modal-result-footer">
                        ${f.length > 0 ? `
                            <div class="search-modal-result-tags">
                                ${f.map((d) => `<span class="tag-pill">${d}</span>`).join("")}
                            </div>
                        ` : ""}
                        ${u ? `<span class="search-modal-result-date">${u}</span>` : ""}
                    </div>
                </div>
            `, s.addEventListener("click", () => {
        this.selectedIndex = n, this.selectResult();
      }), s.addEventListener("mouseenter", () => {
        this.selectedIndex = n, this.updateSelection();
      }), this.resultsContainer.appendChild(s);
    });
  }
  highlightQuery(e, t) {
    if (!t || !e) return e;
    const i = t.split(/\s+/).filter((s) => !s.includes(":")).map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
    if (i.length === 0) return e;
    const n = new RegExp(`(${i.join("|")})`, "gi");
    return e.replace(n, "<mark>$1</mark>");
  }
  showHelp() {
    this.results = [], this.resultsContainer.innerHTML = `
            <div class="search-modal-help">
                <div class="search-modal-help-title">💡 Recherche avancée</div>
                <div class="search-modal-help-items">
                    <div class="search-modal-help-item">
                        <code>tag:projet</code>
                        <span>Filtrer par tag</span>
                    </div>
                    <div class="search-modal-help-item">
                        <code>title:réunion</code>
                        <span>Rechercher dans les titres</span>
                    </div>
                    <div class="search-modal-help-item">
                        <code>path:docs</code>
                        <span>Rechercher dans les chemins</span>
                    </div>
                    <div class="search-modal-help-item">
                        <code>"phrase exacte"</code>
                        <span>Recherche de phrase</span>
                    </div>
                </div>
            </div>
        `;
  }
  showLoading() {
    this.resultsContainer.innerHTML = `
            <div class="search-modal-loading">
                <div class="search-modal-spinner"></div>
                <p>Recherche en cours...</p>
            </div>
        `;
  }
  showNoResults(e) {
    this.results = [], this.resultsContainer.innerHTML = `
            <div class="search-modal-no-results">
                <div class="search-modal-no-results-icon">🔍</div>
                <p class="search-modal-no-results-text">Aucun résultat pour « <strong>${this.escapeHtml(e)}</strong> »</p>
                <p class="search-modal-no-results-hint">Essayez d'autres mots-clés ou utilisez les filtres</p>
            </div>
        `;
  }
  showError() {
    this.resultsContainer.innerHTML = `
            <div class="search-modal-error">
                <div class="search-modal-error-icon">⚠️</div>
                <p>Une erreur s'est produite lors de la recherche</p>
            </div>
        `;
  }
  escapeHtml(e) {
    const t = document.createElement("div");
    return t.textContent = e, t.innerHTML;
  }
  open() {
    this.isOpen || (this.isOpen = !0, this.modal.style.display = "flex", requestAnimationFrame(() => {
      this.modal.classList.add("active");
    }), setTimeout(() => {
      this.input.focus(), this.input.select();
    }, 100), this.selectedIndex = 0, this.showHelp());
  }
  close() {
    this.isOpen && (this.isOpen = !1, this.modal.classList.remove("active"), setTimeout(() => {
      this.modal.style.display = "none", this.input.value = "", this.results = [];
    }, 200));
  }
  toggle() {
    this.isOpen ? this.close() : this.open();
  }
  destroy() {
    this._keydownHandler && (document.removeEventListener("keydown", this._keydownHandler), this._keydownHandler = null), this.modal && this.modal.parentNode && this.modal.parentNode.removeChild(this.modal), this.modal = null, this.input = null, this.resultsContainer = null;
  }
}
window.searchModal = null;
document.addEventListener("DOMContentLoaded", () => {
  window.searchModal = new uP();
});
