vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
1,674 lines (1,671 loc) • 48.7 kB
JavaScript
const Oe = 1024;
let ke = 0;
class T {
constructor(e, t) {
this.from = e, this.to = t;
}
}
class k {
/**
Create a new node prop type.
*/
constructor(e = {}) {
this.id = ke++, 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 = j.match(e)), (t) => {
let r = e(t);
return r === void 0 ? null : [this, r];
};
}
}
k.closedBy = new k({ deserialize: (l) => l.split(" ") });
k.openedBy = new k({ deserialize: (l) => l.split(" ") });
k.group = new k({ deserialize: (l) => l.split(" ") });
k.isolate = new k({ deserialize: (l) => {
if (l && l != "rtl" && l != "ltr" && l != "auto")
throw new RangeError("Invalid value for isolate: " + l);
return l || "auto";
} });
k.contextHash = new k({ perNode: !0 });
k.lookAhead = new k({ perNode: !0 });
k.mounted = new k({ perNode: !0 });
class q {
constructor(e, t, r) {
this.tree = e, this.overlay = t, this.parser = r;
}
/**
@internal
*/
static get(e) {
return e && e.props && e.props[k.mounted.id];
}
}
const Ce = /* @__PURE__ */ Object.create(null);
class j {
/**
@internal
*/
constructor(e, t, r, n = 0) {
this.name = e, this.props = t, this.id = r, this.flags = n;
}
/**
Define a node type.
*/
static define(e) {
let t = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : Ce, r = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), n = new j(e.name || "", t, e.id, r);
if (e.props) {
for (let i of e.props)
if (Array.isArray(i) || (i = i(n)), i) {
if (i[0].perNode)
throw new RangeError("Can't store a per-node prop on a node type");
t[i[0].id] = i[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(k.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 r in e)
for (let n of r.split(" "))
t[n] = e[r];
return (r) => {
for (let n = r.prop(k.group), i = -1; i < (n ? n.length : 0); i++) {
let s = t[i < 0 ? r.name : n[i]];
if (s)
return s;
}
};
}
}
j.none = new j(
"",
/* @__PURE__ */ Object.create(null),
0,
8
/* NodeFlag.Anonymous */
);
class ye {
/**
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 r of this.types) {
let n = null;
for (let i of e) {
let s = i(r);
s && (n || (n = Object.assign({}, r.props)), n[s[0].id] = s[1]);
}
t.push(n ? new j(r.name, n, r.id, r.flags) : r);
}
return new ye(t);
}
}
const Z = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new WeakMap();
var S;
(function(l) {
l[l.ExcludeBuffers = 1] = "ExcludeBuffers", l[l.IncludeAnonymous = 2] = "IncludeAnonymous", l[l.IgnoreMounts = 4] = "IgnoreMounts", l[l.IgnoreOverlays = 8] = "IgnoreOverlays";
})(S || (S = {}));
class z {
/**
Construct a new tree. See also [`Tree.build`](#common.Tree^build).
*/
constructor(e, t, r, n, i) {
if (this.type = e, this.children = t, this.positions = r, this.length = n, this.props = null, i && i.length) {
this.props = /* @__PURE__ */ Object.create(null);
for (let [s, f] of i)
this.props[typeof s == "number" ? s : s.id] = f;
}
}
/**
@internal
*/
toString() {
let e = q.get(this);
if (e && !e.overlay)
return e.tree.toString();
let t = "";
for (let r of this.children) {
let n = r.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 te(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, r = 0) {
let n = Z.get(this) || this.topNode, i = new te(n);
return i.moveTo(e, t), Z.set(this, i._tree), i;
}
/**
Get a [syntax node](#common.SyntaxNode) object for the top of the
tree.
*/
get topNode() {
return new B(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 r = K(Z.get(this) || this.topNode, e, t, !1);
return Z.set(this, r), r;
}
/**
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 r = K(oe.get(this) || this.topNode, e, t, !0);
return oe.set(this, r), r;
}
/**
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 _e(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: r, from: n = 0, to: i = this.length } = e, s = e.mode || 0, f = (s & S.IncludeAnonymous) > 0;
for (let h = this.cursor(s | S.IncludeAnonymous); ; ) {
let u = !1;
if (h.from <= i && h.to >= n && (!f && h.type.isAnonymous || t(h) !== !1)) {
if (h.firstChild())
continue;
u = !0;
}
for (; u && r && (f || !h.type.isAnonymous) && r(h), !h.nextSibling(); ) {
if (!h.parent())
return;
u = !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 : le(j.none, this.children, this.positions, 0, this.children.length, 0, this.length, (t, r, n) => new z(this.type, t, r, n, this.propValues), e.makeTree || ((t, r, n) => new z(j.none, t, r, n)));
}
/**
Build a tree from a postfix-ordered buffer of node information,
or a cursor over such a buffer.
*/
static build(e) {
return Ie(e);
}
}
z.empty = new z(j.none, [], [], 0);
class ie {
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 ie(this.buffer, this.index);
}
}
class H {
/**
Create a tree buffer.
*/
constructor(e, t, r) {
this.buffer = e, this.length = t, this.set = r;
}
/**
@internal
*/
get type() {
return j.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], r = this.buffer[e + 3], n = this.set.types[t], i = n.name;
if (/\W/.test(i) && !n.isError && (i = JSON.stringify(i)), e += 4, r == e)
return i;
let s = [];
for (; e < r; )
s.push(this.childString(e)), e = this.buffer[e + 3];
return i + "(" + s.join(",") + ")";
}
/**
@internal
*/
findChild(e, t, r, n, i) {
let { buffer: s } = this, f = -1;
for (let h = e; h != t && !(be(i, n, s[h + 1], s[h + 2]) && (f = h, r > 0)); h = s[h + 3])
;
return f;
}
/**
@internal
*/
slice(e, t, r) {
let n = this.buffer, i = new Uint16Array(t - e), s = 0;
for (let f = e, h = 0; f < t; ) {
i[h++] = n[f++], i[h++] = n[f++] - r;
let u = i[h++] = n[f++] - r;
i[h++] = n[f++] - e, s = Math.max(s, u);
}
return new H(i, s, this.set);
}
}
function be(l, e, t, r) {
switch (l) {
case -2:
return t < e;
case -1:
return r >= e && t < e;
case 0:
return t < e && r > e;
case 1:
return t <= e && r > e;
case 2:
return r > e;
case 4:
return !0;
}
}
function K(l, e, t, r) {
for (var n; l.from == l.to || (t < 1 ? l.from >= e : l.from > e) || (t > -1 ? l.to <= e : l.to < e); ) {
let s = !r && l instanceof B && l.index < 0 ? null : l.parent;
if (!s)
return l;
l = s;
}
let i = r ? 0 : S.IgnoreOverlays;
if (r)
for (let s = l, f = s.parent; f; s = f, f = s.parent)
s instanceof B && s.index < 0 && ((n = f.enter(e, t, i)) === null || n === void 0 ? void 0 : n.from) != s.from && (l = f);
for (; ; ) {
let s = l.enter(e, t, i);
if (!s)
return l;
l = s;
}
}
class we {
cursor(e = 0) {
return new te(this, e);
}
getChild(e, t = null, r = null) {
let n = ue(this, e, t, r);
return n.length ? n[0] : null;
}
getChildren(e, t = null, r = null) {
return ue(this, e, t, r);
}
resolve(e, t = 0) {
return K(this, e, t, !1);
}
resolveInner(e, t = 0) {
return K(this, e, t, !0);
}
matchContext(e) {
return re(this.parent, e);
}
enterUnfinishedNodesBefore(e) {
let t = this.childBefore(e), r = this;
for (; t; ) {
let n = t.lastChild;
if (!n || n.to != t.to)
break;
n.type.isError && n.from == n.to ? (r = t, t = n.prevSibling) : t = n;
}
return r;
}
get node() {
return this;
}
get next() {
return this.parent;
}
}
class B extends we {
constructor(e, t, r, n) {
super(), this._tree = e, this.from = t, this.index = r, 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, r, n, i = 0) {
for (let s = this; ; ) {
for (let { children: f, positions: h } = s._tree, u = t > 0 ? f.length : -1; e != u; e += t) {
let o = f[e], c = h[e] + s.from;
if (be(n, r, c, c + o.length)) {
if (o instanceof H) {
if (i & S.ExcludeBuffers)
continue;
let d = o.findChild(0, o.buffer.length, t, r - c, n);
if (d > -1)
return new D(new Ae(s, o, e, c), null, d);
} else if (i & S.IncludeAnonymous || !o.type.isAnonymous || se(o)) {
let d;
if (!(i & S.IgnoreMounts) && (d = q.get(o)) && !d.overlay)
return new B(d.tree, c, e, s);
let x = new B(o, c, e, s);
return i & S.IncludeAnonymous || !x.type.isAnonymous ? x : x.nextChild(t < 0 ? o.children.length - 1 : 0, t, r, n);
}
}
}
if (i & S.IncludeAnonymous || !s.type.isAnonymous || (s.index >= 0 ? e = s.index + t : e = t < 0 ? -1 : s._parent._tree.children.length, s = s._parent, !s))
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, r = 0) {
let n;
if (!(r & S.IgnoreOverlays) && (n = q.get(this._tree)) && n.overlay) {
let i = e - this.from;
for (let { from: s, to: f } of n.overlay)
if ((t > 0 ? s <= i : s < i) && (t < 0 ? f >= i : f > i))
return new B(n.tree, n.overlay[0].from + this.from, -1, this);
}
return this.nextChild(0, 1, e, t, r);
}
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 ue(l, e, t, r) {
let n = l.cursor(), i = [];
if (!n.firstChild())
return i;
if (t != null) {
for (let s = !1; !s; )
if (s = n.type.is(t), !n.nextSibling())
return i;
}
for (; ; ) {
if (r != null && n.type.is(r))
return i;
if (n.type.is(e) && i.push(n.node), !n.nextSibling())
return r == null ? i : [];
}
}
function re(l, e, t = e.length - 1) {
for (let r = l; t >= 0; r = r.parent) {
if (!r)
return !1;
if (!r.type.isAnonymous) {
if (e[t] && e[t] != r.name)
return !1;
t--;
}
}
return !0;
}
class Ae {
constructor(e, t, r, n) {
this.parent = e, this.buffer = t, this.index = r, this.start = n;
}
}
class D extends we {
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, r) {
super(), this.context = e, this._parent = t, this.index = r, this.type = e.buffer.set.types[e.buffer.buffer[r]];
}
child(e, t, r) {
let { buffer: n } = this.context, i = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.context.start, r);
return i < 0 ? null : new D(this.context, this, i);
}
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, r = 0) {
if (r & S.ExcludeBuffers)
return null;
let { buffer: n } = this.context, i = n.findChild(this.index + 4, n.buffer[this.index + 3], t > 0 ? 1 : -1, e - this.context.start, t);
return i < 0 ? null : new D(this.context, this, i);
}
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 D(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 D(this.context, this._parent, e.findChild(
t,
this.index,
-1,
0,
4
/* Side.DontCare */
));
}
get tree() {
return null;
}
toTree() {
let e = [], t = [], { buffer: r } = this.context, n = this.index + 4, i = r.buffer[this.index + 3];
if (i > n) {
let s = r.buffer[this.index + 1];
e.push(r.slice(n, i, s)), t.push(0);
}
return new z(this.type, e, t, this.to - this.from);
}
/**
@internal
*/
toString() {
return this.context.buffer.childString(this.index);
}
}
function ve(l) {
if (!l.length)
return null;
let e = 0, t = l[0];
for (let i = 1; i < l.length; i++) {
let s = l[i];
(s.from > t.from || s.to < t.to) && (t = s, e = i);
}
let r = t instanceof B && t.index < 0 ? null : t.parent, n = l.slice();
return r ? n[e] = r : n.splice(e, 1), new Se(n, t);
}
class Se {
constructor(e, t) {
this.heads = e, this.node = t;
}
get next() {
return ve(this.heads);
}
}
function _e(l, e, t) {
let r = l.resolveInner(e, t), n = null;
for (let i = r instanceof B ? r : r.context.parent; i; i = i.parent)
if (i.index < 0) {
let s = i.parent;
(n || (n = [r])).push(s.resolve(e, t)), i = s;
} else {
let s = q.get(i.tree);
if (s && s.overlay && s.overlay[0].from <= e && s.overlay[s.overlay.length - 1].to >= e) {
let f = new B(s.tree, s.overlay[0].from + i.from, -1, i);
(n || (n = [r])).push(K(f, e, t, !1));
}
}
return n ? ve(n) : r;
}
class te {
/**
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 B)
this.yieldNode(e);
else {
this._tree = e.context.parent, this.buffer = e.context;
for (let r = e._parent; r; r = r._parent)
this.stack.unshift(r.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: r, buffer: n } = this.buffer;
return this.type = t || n.set.types[n.buffer[e]], this.from = r + n.buffer[e + 1], this.to = r + n.buffer[e + 2], !0;
}
/**
@internal
*/
yield(e) {
return e ? e instanceof B ? (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, r) {
if (!this.buffer)
return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, t, r, this.mode));
let { buffer: n } = this.buffer, i = n.findChild(this.index + 4, n.buffer[this.index + 3], e, t - this.buffer.start, r);
return i < 0 ? !1 : (this.stack.push(this.index), this.yieldBuf(i));
}
/**
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, r = this.mode) {
return this.buffer ? r & S.ExcludeBuffers ? !1 : this.enterChild(1, e, t) : this.yield(this._tree.enter(e, t, r));
}
/**
Move to the node's parent node, if this isn't the top node.
*/
parent() {
if (!this.buffer)
return this.yieldNode(this.mode & S.IncludeAnonymous ? this._tree._parent : this._tree.parent);
if (this.stack.length)
return this.yieldBuf(this.stack.pop());
let e = this.mode & S.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, r = this.stack.length - 1;
if (e < 0) {
let n = r < 0 ? 0 : this.stack[r] + 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 < (r < 0 ? t.buffer.length : t.buffer[this.stack[r] + 3]))
return this.yieldBuf(n);
}
return r < 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, r, { buffer: n } = this;
if (n) {
if (e > 0) {
if (this.index < n.buffer.buffer.length)
return !1;
} else
for (let i = 0; i < this.index; i++)
if (n.buffer.buffer[i + 3] < this.index)
return !1;
({ index: t, parent: r } = n);
} else
({ index: t, _parent: r } = this._tree);
for (; r; { index: t, _parent: r } = r)
if (t > -1)
for (let i = t + e, s = e < 0 ? -1 : r._tree.children.length; i != s; i += e) {
let f = r._tree.children[i];
if (this.mode & S.IncludeAnonymous || f instanceof H || !f.type.isAnonymous || se(f))
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, r = 0;
if (e && e.context == this.buffer)
e: for (let n = this.index, i = this.stack.length; i >= 0; ) {
for (let s = e; s; s = s._parent)
if (s.index == n) {
if (n == this.index)
return s;
t = s, r = i + 1;
break e;
}
n = this.stack[--i];
}
for (let n = r; n < this.stack.length; n++)
t = new D(this.buffer, t, this.stack[n]);
return this.bufferNode = new D(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 r = 0; ; ) {
let n = !1;
if (this.type.isAnonymous || e(this) !== !1) {
if (this.firstChild()) {
r++;
continue;
}
this.type.isAnonymous || (n = !0);
}
for (; ; ) {
if (n && t && t(this), n = this.type.isAnonymous, !r)
return;
if (this.nextSibling())
break;
this.parent(), r--, 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 re(this.node.parent, e);
let { buffer: t } = this.buffer, { types: r } = t.set;
for (let n = e.length - 1, i = this.stack.length - 1; n >= 0; i--) {
if (i < 0)
return re(this._tree, e, n);
let s = r[t.buffer[this.stack[i]]];
if (!s.isAnonymous) {
if (e[n] && e[n] != s.name)
return !1;
n--;
}
}
return !0;
}
}
function se(l) {
return l.children.some((e) => e instanceof H || !e.type.isAnonymous || se(e));
}
function Ie(l) {
var e;
let { buffer: t, nodeSet: r, maxBufferLength: n = 1024, reused: i = [], minRepeatType: s = r.types.length } = l, f = Array.isArray(t) ? new ie(t, t.length) : t, h = r.types, u = 0, o = 0;
function c(m, w, a, C, y, A) {
let { id: g, start: p, end: b, size: v } = f, N = o, U = u;
for (; v < 0; )
if (f.next(), v == -1) {
let W = i[g];
a.push(W), C.push(p - m);
return;
} else if (v == -3) {
u = g;
return;
} else if (v == -4) {
o = g;
return;
} else
throw new RangeError(`Unrecognized record size: ${v}`);
let $ = h[g], X, J, fe = p - m;
if (b - p <= n && (J = O(f.pos - w, y))) {
let W = new Uint16Array(J.size - J.skip), M = f.pos - J.size, R = W.length;
for (; f.pos > M; )
R = F(J.start, W, R);
X = new H(W, b - J.start, r), fe = J.start - m;
} else {
let W = f.pos - v;
f.next();
let M = [], R = [], V = g >= s ? g : -1, G = 0, Y = b;
for (; f.pos > W; )
V >= 0 && f.id == V && f.size >= 0 ? (f.end <= Y - n && (_(M, R, p, G, f.end, Y, V, N, U), G = M.length, Y = f.end), f.next()) : A > 2500 ? d(p, W, M, R) : c(p, W, M, R, V, A + 1);
if (V >= 0 && G > 0 && G < M.length && _(M, R, p, G, p, Y, V, N, U), M.reverse(), R.reverse(), V > -1 && G > 0) {
let he = x($, U);
X = le($, M, R, 0, M.length, 0, b - p, he, he);
} else
X = P($, M, R, b - p, N - b, U);
}
a.push(X), C.push(fe);
}
function d(m, w, a, C) {
let y = [], A = 0, g = -1;
for (; f.pos > w; ) {
let { id: p, start: b, end: v, size: N } = f;
if (N > 4)
f.next();
else {
if (g > -1 && b < g)
break;
g < 0 && (g = v - n), y.push(p, b, v), A++, f.next();
}
}
if (A) {
let p = new Uint16Array(A * 4), b = y[y.length - 2];
for (let v = y.length - 3, N = 0; v >= 0; v -= 3)
p[N++] = y[v], p[N++] = y[v + 1] - b, p[N++] = y[v + 2] - b, p[N++] = N;
a.push(new H(p, y[2] - b, r)), C.push(b - m);
}
}
function x(m, w) {
return (a, C, y) => {
let A = 0, g = a.length - 1, p, b;
if (g >= 0 && (p = a[g]) instanceof z) {
if (!g && p.type == m && p.length == y)
return p;
(b = p.prop(k.lookAhead)) && (A = C[g] + p.length + b);
}
return P(m, a, C, y, A, w);
};
}
function _(m, w, a, C, y, A, g, p, b) {
let v = [], N = [];
for (; m.length > C; )
v.push(m.pop()), N.push(w.pop() + a - y);
m.push(P(r.types[g], v, N, A - y, p - A, b)), w.push(y - a);
}
function P(m, w, a, C, y, A, g) {
if (A) {
let p = [k.contextHash, A];
g = g ? [p].concat(g) : [p];
}
if (y > 25) {
let p = [k.lookAhead, y];
g = g ? [p].concat(g) : [p];
}
return new z(m, w, a, C, g);
}
function O(m, w) {
let a = f.fork(), C = 0, y = 0, A = 0, g = a.end - n, p = { size: 0, start: 0, skip: 0 };
e: for (let b = a.pos - m; a.pos > b; ) {
let v = a.size;
if (a.id == w && v >= 0) {
p.size = C, p.start = y, p.skip = A, A += 4, C += 4, a.next();
continue;
}
let N = a.pos - v;
if (v < 0 || N < b || a.start < g)
break;
let U = a.id >= s ? 4 : 0, $ = a.start;
for (a.next(); a.pos > N; ) {
if (a.size < 0)
if (a.size == -3)
U += 4;
else
break e;
else a.id >= s && (U += 4);
a.next();
}
y = $, C += v, A += U;
}
return (w < 0 || C == m) && (p.size = C, p.start = y, p.skip = A), p.size > 4 ? p : void 0;
}
function F(m, w, a) {
let { id: C, start: y, end: A, size: g } = f;
if (f.next(), g >= 0 && C < s) {
let p = a;
if (g > 4) {
let b = f.pos - (g - 4);
for (; f.pos > b; )
a = F(m, w, a);
}
w[--a] = p, w[--a] = A - m, w[--a] = y - m, w[--a] = C;
} else g == -3 ? u = C : g == -4 && (o = C);
return a;
}
let E = [], I = [];
for (; f.pos > 0; )
c(l.start || 0, l.bufferStart || 0, E, I, -1, 0);
let L = (e = l.length) !== null && e !== void 0 ? e : E.length ? I[0] + E[0].length : 0;
return new z(h[l.topID], E.reverse(), I.reverse(), L);
}
const ae = /* @__PURE__ */ new WeakMap();
function ee(l, e) {
if (!l.isAnonymous || e instanceof H || e.type != l)
return 1;
let t = ae.get(e);
if (t == null) {
t = 1;
for (let r of e.children) {
if (r.type != l || !(r instanceof z)) {
t = 1;
break;
}
t += ee(l, r);
}
ae.set(e, t);
}
return t;
}
function le(l, e, t, r, n, i, s, f, h) {
let u = 0;
for (let _ = r; _ < n; _++)
u += ee(l, e[_]);
let o = Math.ceil(
u * 1.5 / 8
/* Balance.BranchFactor */
), c = [], d = [];
function x(_, P, O, F, E) {
for (let I = O; I < F; ) {
let L = I, m = P[I], w = ee(l, _[I]);
for (I++; I < F; I++) {
let a = ee(l, _[I]);
if (w + a >= o)
break;
w += a;
}
if (I == L + 1) {
if (w > o) {
let a = _[L];
x(a.children, a.positions, 0, a.children.length, P[L] + E);
continue;
}
c.push(_[L]);
} else {
let a = P[I - 1] + _[I - 1].length - m;
c.push(le(l, _, P, L, I, m, a, null, h));
}
d.push(m + E - i);
}
}
return x(e, t, r, n, 0), (f || h)(c, d, s);
}
class Fe {
constructor() {
this.map = /* @__PURE__ */ new WeakMap();
}
setBuffer(e, t, r) {
let n = this.map.get(e);
n || this.map.set(e, n = /* @__PURE__ */ new Map()), n.set(t, r);
}
getBuffer(e, t) {
let r = this.map.get(e);
return r && r.get(t);
}
/**
Set the value for this syntax node.
*/
set(e, t) {
e instanceof D ? this.setBuffer(e.context.buffer, e.index, t) : e instanceof B && this.map.set(e.tree, t);
}
/**
Retrieve value for this syntax node, if it exists in the map.
*/
get(e) {
return e instanceof D ? this.getBuffer(e.context.buffer, e.index) : e instanceof B ? 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 Q {
/**
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, r, n, i = !1, s = !1) {
this.from = e, this.to = t, this.tree = r, this.offset = n, this.open = (i ? 1 : 0) | (s ? 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 = [], r = !1) {
let n = [new Q(0, e.length, e, 0, !1, r)];
for (let i of t)
i.to > e.length && n.push(i);
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, r = 128) {
if (!t.length)
return e;
let n = [], i = 1, s = e.length ? e[0] : null;
for (let f = 0, h = 0, u = 0; ; f++) {
let o = f < t.length ? t[f] : null, c = o ? o.fromA : 1e9;
if (c - h >= r)
for (; s && s.from < c; ) {
let d = s;
if (h >= d.from || c <= d.to || u) {
let x = Math.max(d.from, h) - u, _ = Math.min(d.to, c) - u;
d = x >= _ ? null : new Q(x, _, d.tree, d.offset + u, f > 0, !!o);
}
if (d && n.push(d), s.to > c)
break;
s = i < e.length ? e[i++] : null;
}
if (!o)
break;
h = o.toA, u = o.toA - o.toB;
}
return n;
}
}
class je {
/**
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, r) {
return typeof e == "string" && (e = new Ne(e)), r = r ? r.length ? r.map((n) => new T(n.from, n.to)) : [new T(0, 0)] : [new T(0, e.length)], this.createParse(e, t || [], r);
}
/**
Run a full parse, returning the resulting tree.
*/
parse(e, t, r) {
let n = this.startParse(e, t, r);
for (; ; ) {
let i = n.advance();
if (i)
return i;
}
}
}
class Ne {
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 Re(l) {
return (e, t, r, n) => new Be(e, l, t, r, n);
}
class pe {
constructor(e, t, r, n, i) {
this.parser = e, this.parse = t, this.overlay = r, this.target = n, this.from = i;
}
}
function de(l) {
if (!l.length || l.some((e) => e.from >= e.to))
throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(l));
}
class Pe {
constructor(e, t, r, n, i, s, f) {
this.parser = e, this.predicate = t, this.mounts = r, this.index = n, this.start = i, this.target = s, this.prev = f, this.depth = 0, this.ranges = [];
}
}
const ne = new k({ perNode: !0 });
class Be {
constructor(e, t, r, n, i) {
this.nest = t, this.input = r, this.fragments = n, this.ranges = i, this.inner = [], this.innerDone = 0, this.baseTree = null, this.stoppedAt = null, this.baseParse = e;
}
advance() {
if (this.baseParse) {
let r = this.baseParse.advance();
if (!r)
return null;
if (this.baseParse = null, this.baseTree = r, this.startInner(), this.stoppedAt != null)
for (let n of this.inner)
n.parse.stopAt(this.stoppedAt);
}
if (this.innerDone == this.inner.length) {
let r = this.baseTree;
return this.stoppedAt != null && (r = new z(r.type, r.children, r.positions, r.length, r.propValues.concat([[ne, this.stoppedAt]]))), r;
}
let e = this.inner[this.innerDone], t = e.parse.advance();
if (t) {
this.innerDone++;
let r = Object.assign(/* @__PURE__ */ Object.create(null), e.target.props);
r[k.mounted.id] = new q(t, e.overlay, e.parser), e.target.props = r;
}
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 Me(this.fragments), t = null, r = null, n = new te(new B(this.baseTree, this.ranges[0].from, 0, null), S.IncludeAnonymous | S.IgnoreMounts);
e: for (let i, s; ; ) {
let f = !0, h;
if (this.stoppedAt != null && n.from >= this.stoppedAt)
f = !1;
else if (e.hasNode(n)) {
if (t) {
let u = t.mounts.find((o) => o.frag.from <= n.from && o.frag.to >= n.to && o.mount.overlay);
if (u)
for (let o of u.mount.overlay) {
let c = o.from + u.pos, d = o.to + u.pos;
c >= n.from && d <= n.to && !t.ranges.some((x) => x.from < d && x.to > c) && t.ranges.push({ from: c, to: d });
}
}
f = !1;
} else if (r && (s = ze(r.ranges, n.from, n.to)))
f = s != 2;
else if (!n.type.isAnonymous && (i = this.nest(n, this.input)) && (n.from < n.to || !i.overlay)) {
n.tree || Ee(n);
let u = e.findMounts(n.from, i.parser);
if (typeof i.overlay == "function")
t = new Pe(i.parser, i.overlay, u, this.inner.length, n.from, n.tree, t);
else {
let o = me(this.ranges, i.overlay || (n.from < n.to ? [new T(n.from, n.to)] : []));
o.length && de(o), (o.length || !i.overlay) && this.inner.push(new pe(i.parser, o.length ? i.parser.startParse(this.input, xe(u, o), o) : i.parser.startParse(""), i.overlay ? i.overlay.map((c) => new T(c.from - n.from, c.to - n.from)) : null, n.tree, o.length ? o[0].from : n.from)), i.overlay ? o.length && (r = { ranges: o, depth: 0, prev: r }) : f = !1;
}
} else if (t && (h = t.predicate(n)) && (h === !0 && (h = new T(n.from, n.to)), h.from < h.to)) {
let u = t.ranges.length - 1;
u >= 0 && t.ranges[u].to == h.from ? t.ranges[u] = { from: t.ranges[u].from, to: h.to } : t.ranges.push(h);
}
if (f && n.firstChild())
t && t.depth++, r && r.depth++;
else
for (; !n.nextSibling(); ) {
if (!n.parent())
break e;
if (t && !--t.depth) {
let u = me(this.ranges, t.ranges);
u.length && (de(u), this.inner.splice(t.index, 0, new pe(t.parser, t.parser.startParse(this.input, xe(t.mounts, u), u), t.ranges.map((o) => new T(o.from - t.start, o.to - t.start)), t.target, u[0].from))), t = t.prev;
}
r && !--r.depth && (r = r.prev);
}
}
}
}
function ze(l, e, t) {
for (let r of l) {
if (r.from >= t)
break;
if (r.to > e)
return r.from <= e && r.to >= t ? 2 : 1;
}
return 0;
}
function ce(l, e, t, r, n, i) {
if (e < t) {
let s = l.buffer[e + 1];
r.push(l.slice(e, t, s)), n.push(s - i);
}
}
function Ee(l) {
let { node: e } = l, t = [], r = e.context.buffer;
do
t.push(l.index), l.parent();
while (!l.tree);
let n = l.tree, i = n.children.indexOf(r), s = n.children[i], f = s.buffer, h = [i];
function u(o, c, d, x, _, P) {
let O = t[P], F = [], E = [];
ce(s, o, O, F, E, x);
let I = f[O + 1], L = f[O + 2];
h.push(F.length);
let m = P ? u(O + 4, f[O + 3], s.set.types[f[O]], I, L - I, P - 1) : e.toTree();
return F.push(m), E.push(I - x), ce(s, f[O + 3], c, F, E, x), new z(d, F, E, _);
}
n.children[i] = u(0, f.length, j.none, 0, s.length, t.length - 1);
for (let o of h) {
let c = l.tree.children[o], d = l.tree.positions[o];
l.yield(new B(c, d + l.from, o, l._tree));
}
}
class ge {
constructor(e, t) {
this.offset = t, this.done = !1, this.cursor = e.cursor(S.IncludeAnonymous | S.IgnoreMounts);
}
// Move to the first node (in pre-order) that starts at or after `pos`.
moveTo(e) {
let { cursor: t } = this, r = e - this.offset;
for (; !this.done && t.from < r; )
t.to >= e && t.enter(r, 1, S.IgnoreOverlays | S.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 z)
t = t.children[0];
else
break;
}
return !1;
}
}
class Me {
constructor(e) {
var t;
if (this.fragments = e, this.curTo = 0, this.fragI = 0, e.length) {
let r = this.curFrag = e[0];
this.curTo = (t = r.tree.prop(ne)) !== null && t !== void 0 ? t : r.to, this.inner = new ge(r.tree, -r.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(ne)) !== null && e !== void 0 ? e : t.to, this.inner = new ge(t.tree, -t.offset);
}
}
findMounts(e, t) {
var r;
let n = [];
if (this.inner) {
this.inner.cursor.moveTo(e, 1);
for (let i = this.inner.cursor.node; i; i = i.parent) {
let s = (r = i.tree) === null || r === void 0 ? void 0 : r.prop(k.mounted);
if (s && s.parser == t)
for (let f = this.fragI; f < this.fragments.length; f++) {
let h = this.fragments[f];
if (h.from >= i.to)
break;
h.tree == this.curFrag.tree && n.push({
frag: h,
pos: i.from - h.offset,
mount: s
});
}
}
}
return n;
}
}
function me(l, e) {
let t = null, r = e;
for (let n = 1, i = 0; n < l.length; n++) {
let s = l[n - 1].to, f = l[n].from;
for (; i < r.length; i++) {
let h = r[i];
if (h.from >= f)
break;
h.to <= s || (t || (r = t = e.slice()), h.from < s ? (t[i] = new T(h.from, s), h.to > f && t.splice(i + 1, 0, new T(f, h.to))) : h.to > f ? t[i--] = new T(f, h.to) : t.splice(i--, 1));
}
}
return r;
}
function Te(l, e, t, r) {
let n = 0, i = 0, s = !1, f = !1, h = -1e9, u = [];
for (; ; ) {
let o = n == l.length ? 1e9 : s ? l[n].to : l[n].from, c = i == e.length ? 1e9 : f ? e[i].to : e[i].from;
if (s != f) {
let d = Math.max(h, t), x = Math.min(o, c, r);
d < x && u.push(new T(d, x));
}
if (h = Math.min(o, c), h == 1e9)
break;
o == h && (s ? (s = !1, n++) : s = !0), c == h && (f ? (f = !1, i++) : f = !0);
}
return u;
}
function xe(l, e) {
let t = [];
for (let { pos: r, mount: n, frag: i } of l) {
let s = r + (n.overlay ? n.overlay[0].from : 0), f = s + n.tree.length, h = Math.max(i.from, s), u = Math.min(i.to, f);
if (n.overlay) {
let o = n.overlay.map((d) => new T(d.from + r, d.to + r)), c = Te(e, o, h, u);
for (let d = 0, x = h; ; d++) {
let _ = d == c.length, P = _ ? u : c[d].from;
if (P > x && t.push(new Q(x, P, n.tree, -s, i.from >= x || i.openStart, i.to <= P || i.openEnd)), _)
break;
x = c[d].to;
}
} else
t.push(new Q(h, u, n.tree, -s, i.from >= s || i.openStart, i.to <= f || i.openEnd));
}
return t;
}
export {
Oe as DefaultBufferLength,
S as IterMode,
q as MountedTree,
k as NodeProp,
ye as NodeSet,
j as NodeType,
Fe as NodeWeakMap,
je as Parser,
z as Tree,
H as TreeBuffer,
te as TreeCursor,
Q as TreeFragment,
Re as parseMixed
};
//# sourceMappingURL=index.mjs.map