ai-client-kit
Version:
一款 AI 集成套件,适配任意前端框架,兼容多种大模型、聊天面板、Function Calling、Agent、工作流等。
1,577 lines • 1.91 MB
JavaScript
function VD(t) {
if (t)
throw t;
}
function Mp(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var Xh, HD;
function jk() {
if (HD) return Xh;
HD = 1;
var t = Object.prototype.hasOwnProperty, e = Object.prototype.toString, r = Object.defineProperty, n = Object.getOwnPropertyDescriptor, i = function(l) {
return typeof Array.isArray == "function" ? Array.isArray(l) : e.call(l) === "[object Array]";
}, s = function(l) {
if (!l || e.call(l) !== "[object Object]")
return !1;
var c = t.call(l, "constructor"), p = l.constructor && l.constructor.prototype && t.call(l.constructor.prototype, "isPrototypeOf");
if (l.constructor && !c && !p)
return !1;
var f;
for (f in l)
;
return typeof f > "u" || t.call(l, f);
}, a = function(l, c) {
r && c.name === "__proto__" ? r(l, c.name, {
enumerable: !0,
configurable: !0,
value: c.newValue,
writable: !0
}) : l[c.name] = c.newValue;
}, o = function(l, c) {
if (c === "__proto__")
if (t.call(l, c)) {
if (n)
return n(l, c).value;
} else return;
return l[c];
};
return Xh = function u() {
var l, c, p, f, h, m, g = arguments[0], y = 1, D = arguments.length, d = !1;
for (typeof g == "boolean" && (d = g, g = arguments[1] || {}, y = 2), (g == null || typeof g != "object" && typeof g != "function") && (g = {}); y < D; ++y)
if (l = arguments[y], l != null)
for (c in l)
p = o(g, c), f = o(l, c), g !== f && (d && f && (s(f) || (h = i(f))) ? (h ? (h = !1, m = p && i(p) ? p : []) : m = p && s(p) ? p : {}, a(g, { name: c, newValue: u(d, m, f) })) : typeof f < "u" && a(g, { name: c, newValue: f }));
return g;
}, Xh;
}
var qk = jk();
const Qh = /* @__PURE__ */ Mp(qk);
function _d(t) {
if (typeof t != "object" || t === null)
return !1;
const e = Object.getPrototypeOf(t);
return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in t) && !(Symbol.iterator in t);
}
function Uk() {
const t = [], e = { run: r, use: n };
return e;
function r(...i) {
let s = -1;
const a = i.pop();
if (typeof a != "function")
throw new TypeError("Expected function as last argument, not " + a);
o(null, ...i);
function o(u, ...l) {
const c = t[++s];
let p = -1;
if (u) {
a(u);
return;
}
for (; ++p < i.length; )
(l[p] === null || l[p] === void 0) && (l[p] = i[p]);
i = l, c ? zk(c, o)(...l) : a(null, ...l);
}
}
function n(i) {
if (typeof i != "function")
throw new TypeError(
"Expected `middelware` to be a function, not " + i
);
return t.push(i), e;
}
}
function zk(t, e) {
let r;
return n;
function n(...a) {
const o = t.length > a.length;
let u;
o && a.push(i);
try {
u = t.apply(this, a);
} catch (l) {
const c = (
/** @type {Error} */
l
);
if (o && r)
throw c;
return i(c);
}
o || (u && u.then && typeof u.then == "function" ? u.then(s, i) : u instanceof Error ? i(u) : s(u));
}
function i(a, ...o) {
r || (r = !0, e(a, ...o));
}
function s(a) {
i(null, a);
}
}
function Yo(t) {
return !t || typeof t != "object" ? "" : "position" in t || "type" in t ? WD(t.position) : "start" in t || "end" in t ? WD(t) : "line" in t || "column" in t ? Bd(t) : "";
}
function Bd(t) {
return GD(t && t.line) + ":" + GD(t && t.column);
}
function WD(t) {
return Bd(t && t.start) + "-" + Bd(t && t.end);
}
function GD(t) {
return t && typeof t == "number" ? t : 1;
}
class wr extends Error {
/**
* Create a message for `reason`.
*
* > 🪦 **Note**: also has obsolete signatures.
*
* @overload
* @param {string} reason
* @param {Options | null | undefined} [options]
* @returns
*
* @overload
* @param {string} reason
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns
*
* @overload
* @param {string} reason
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns
*
* @overload
* @param {string} reason
* @param {string | null | undefined} [origin]
* @returns
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns
*
* @overload
* @param {Error | VFileMessage} cause
* @param {string | null | undefined} [origin]
* @returns
*
* @param {Error | VFileMessage | string} causeOrReason
* Reason for message, should use markdown.
* @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
* Configuration (optional).
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns
* Instance of `VFileMessage`.
*/
// eslint-disable-next-line complexity
constructor(e, r, n) {
super(), typeof r == "string" && (n = r, r = void 0);
let i = "", s = {}, a = !1;
if (r && ("line" in r && "column" in r ? s = { place: r } : "start" in r && "end" in r ? s = { place: r } : "type" in r ? s = {
ancestors: [r],
place: r.position
} : s = { ...r }), typeof e == "string" ? i = e : !s.cause && e && (a = !0, i = e.message, s.cause = e), !s.ruleId && !s.source && typeof n == "string") {
const u = n.indexOf(":");
u === -1 ? s.ruleId = n : (s.source = n.slice(0, u), s.ruleId = n.slice(u + 1));
}
if (!s.place && s.ancestors && s.ancestors) {
const u = s.ancestors[s.ancestors.length - 1];
u && (s.place = u.position);
}
const o = s.place && "start" in s.place ? s.place.start : s.place;
this.ancestors = s.ancestors || void 0, this.cause = s.cause || void 0, this.column = o ? o.column : void 0, this.fatal = void 0, this.file = "", this.message = i, this.line = o ? o.line : void 0, this.name = Yo(s.place) || "1:1", this.place = s.place || void 0, this.reason = this.message, this.ruleId = s.ruleId || void 0, this.source = s.source || void 0, this.stack = a && s.cause && typeof s.cause.stack == "string" ? s.cause.stack : "", this.actual = void 0, this.expected = void 0, this.note = void 0, this.url = void 0;
}
}
wr.prototype.file = "";
wr.prototype.name = "";
wr.prototype.reason = "";
wr.prototype.message = "";
wr.prototype.stack = "";
wr.prototype.column = void 0;
wr.prototype.line = void 0;
wr.prototype.ancestors = void 0;
wr.prototype.cause = void 0;
wr.prototype.fatal = void 0;
wr.prototype.place = void 0;
wr.prototype.ruleId = void 0;
wr.prototype.source = void 0;
const Fn = { basename: Vk, dirname: Hk, extname: Wk, join: Gk, sep: "/" };
function Vk(t, e) {
if (e !== void 0 && typeof e != "string")
throw new TypeError('"ext" argument must be a string');
Nu(t);
let r = 0, n = -1, i = t.length, s;
if (e === void 0 || e.length === 0 || e.length > t.length) {
for (; i--; )
if (t.codePointAt(i) === 47) {
if (s) {
r = i + 1;
break;
}
} else n < 0 && (s = !0, n = i + 1);
return n < 0 ? "" : t.slice(r, n);
}
if (e === t)
return "";
let a = -1, o = e.length - 1;
for (; i--; )
if (t.codePointAt(i) === 47) {
if (s) {
r = i + 1;
break;
}
} else
a < 0 && (s = !0, a = i + 1), o > -1 && (t.codePointAt(i) === e.codePointAt(o--) ? o < 0 && (n = i) : (o = -1, n = a));
return r === n ? n = a : n < 0 && (n = t.length), t.slice(r, n);
}
function Hk(t) {
if (Nu(t), t.length === 0)
return ".";
let e = -1, r = t.length, n;
for (; --r; )
if (t.codePointAt(r) === 47) {
if (n) {
e = r;
break;
}
} else n || (n = !0);
return e < 0 ? t.codePointAt(0) === 47 ? "/" : "." : e === 1 && t.codePointAt(0) === 47 ? "//" : t.slice(0, e);
}
function Wk(t) {
Nu(t);
let e = t.length, r = -1, n = 0, i = -1, s = 0, a;
for (; e--; ) {
const o = t.codePointAt(e);
if (o === 47) {
if (a) {
n = e + 1;
break;
}
continue;
}
r < 0 && (a = !0, r = e + 1), o === 46 ? i < 0 ? i = e : s !== 1 && (s = 1) : i > -1 && (s = -1);
}
return i < 0 || r < 0 || // We saw a non-dot character immediately before the dot.
s === 0 || // The (right-most) trimmed path component is exactly `..`.
s === 1 && i === r - 1 && i === n + 1 ? "" : t.slice(i, r);
}
function Gk(...t) {
let e = -1, r;
for (; ++e < t.length; )
Nu(t[e]), t[e] && (r = r === void 0 ? t[e] : r + "/" + t[e]);
return r === void 0 ? "." : Jk(r);
}
function Jk(t) {
Nu(t);
const e = t.codePointAt(0) === 47;
let r = Kk(t, !e);
return r.length === 0 && !e && (r = "."), r.length > 0 && t.codePointAt(t.length - 1) === 47 && (r += "/"), e ? "/" + r : r;
}
function Kk(t, e) {
let r = "", n = 0, i = -1, s = 0, a = -1, o, u;
for (; ++a <= t.length; ) {
if (a < t.length)
o = t.codePointAt(a);
else {
if (o === 47)
break;
o = 47;
}
if (o === 47) {
if (!(i === a - 1 || s === 1)) if (i !== a - 1 && s === 2) {
if (r.length < 2 || n !== 2 || r.codePointAt(r.length - 1) !== 46 || r.codePointAt(r.length - 2) !== 46) {
if (r.length > 2) {
if (u = r.lastIndexOf("/"), u !== r.length - 1) {
u < 0 ? (r = "", n = 0) : (r = r.slice(0, u), n = r.length - 1 - r.lastIndexOf("/")), i = a, s = 0;
continue;
}
} else if (r.length > 0) {
r = "", n = 0, i = a, s = 0;
continue;
}
}
e && (r = r.length > 0 ? r + "/.." : "..", n = 2);
} else
r.length > 0 ? r += "/" + t.slice(i + 1, a) : r = t.slice(i + 1, a), n = a - i - 1;
i = a, s = 0;
} else o === 46 && s > -1 ? s++ : s = -1;
}
return r;
}
function Nu(t) {
if (typeof t != "string")
throw new TypeError(
"Path must be a string. Received " + JSON.stringify(t)
);
}
const Yk = { cwd: Xk };
function Xk() {
return "/";
}
function Nd(t) {
return !!(t !== null && typeof t == "object" && "href" in t && t.href && "protocol" in t && t.protocol && // @ts-expect-error: indexing is fine.
t.auth === void 0);
}
function Qk(t) {
if (typeof t == "string")
t = new URL(t);
else if (!Nd(t)) {
const e = new TypeError(
'The "path" argument must be of type string or an instance of URL. Received `' + t + "`"
);
throw e.code = "ERR_INVALID_ARG_TYPE", e;
}
if (t.protocol !== "file:") {
const e = new TypeError("The URL must be of scheme file");
throw e.code = "ERR_INVALID_URL_SCHEME", e;
}
return Zk(t);
}
function Zk(t) {
if (t.hostname !== "") {
const n = new TypeError(
'File URL host must be "localhost" or empty on darwin'
);
throw n.code = "ERR_INVALID_FILE_URL_HOST", n;
}
const e = t.pathname;
let r = -1;
for (; ++r < e.length; )
if (e.codePointAt(r) === 37 && e.codePointAt(r + 1) === 50) {
const n = e.codePointAt(r + 2);
if (n === 70 || n === 102) {
const i = new TypeError(
"File URL path must not include encoded / characters"
);
throw i.code = "ERR_INVALID_FILE_URL_PATH", i;
}
}
return decodeURIComponent(e);
}
const Zh = (
/** @type {const} */
[
"history",
"path",
"basename",
"stem",
"extname",
"dirname"
]
);
class e3 {
/**
* Create a new virtual file.
*
* `options` is treated as:
*
* * `string` or `Uint8Array` — `{value: options}`
* * `URL` — `{path: options}`
* * `VFile` — shallow copies its data over to the new file
* * `object` — all fields are shallow copied over to the new file
*
* Path related fields are set in the following order (least specific to
* most specific): `history`, `path`, `basename`, `stem`, `extname`,
* `dirname`.
*
* You cannot set `dirname` or `extname` without setting either `history`,
* `path`, `basename`, or `stem` too.
*
* @param {Compatible | null | undefined} [value]
* File value.
* @returns
* New instance.
*/
constructor(e) {
let r;
e ? Nd(e) ? r = { path: e } : typeof e == "string" || t3(e) ? r = { value: e } : r = e : r = {}, this.cwd = "cwd" in r ? "" : Yk.cwd(), this.data = {}, this.history = [], this.messages = [], this.value, this.map, this.result, this.stored;
let n = -1;
for (; ++n < Zh.length; ) {
const s = Zh[n];
s in r && r[s] !== void 0 && r[s] !== null && (this[s] = s === "history" ? [...r[s]] : r[s]);
}
let i;
for (i in r)
Zh.includes(i) || (this[i] = r[i]);
}
/**
* Get the basename (including extname) (example: `'index.min.js'`).
*
* @returns {string | undefined}
* Basename.
*/
get basename() {
return typeof this.path == "string" ? Fn.basename(this.path) : void 0;
}
/**
* Set basename (including extname) (`'index.min.js'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be nullified (use `file.path = file.dirname` instead).
*
* @param {string} basename
* Basename.
* @returns {undefined}
* Nothing.
*/
set basename(e) {
tf(e, "basename"), ef(e, "basename"), this.path = Fn.join(this.dirname || "", e);
}
/**
* Get the parent path (example: `'~'`).
*
* @returns {string | undefined}
* Dirname.
*/
get dirname() {
return typeof this.path == "string" ? Fn.dirname(this.path) : void 0;
}
/**
* Set the parent path (example: `'~'`).
*
* Cannot be set if there’s no `path` yet.
*
* @param {string | undefined} dirname
* Dirname.
* @returns {undefined}
* Nothing.
*/
set dirname(e) {
JD(this.basename, "dirname"), this.path = Fn.join(e || "", this.basename);
}
/**
* Get the extname (including dot) (example: `'.js'`).
*
* @returns {string | undefined}
* Extname.
*/
get extname() {
return typeof this.path == "string" ? Fn.extname(this.path) : void 0;
}
/**
* Set the extname (including dot) (example: `'.js'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be set if there’s no `path` yet.
*
* @param {string | undefined} extname
* Extname.
* @returns {undefined}
* Nothing.
*/
set extname(e) {
if (ef(e, "extname"), JD(this.dirname, "extname"), e) {
if (e.codePointAt(0) !== 46)
throw new Error("`extname` must start with `.`");
if (e.includes(".", 1))
throw new Error("`extname` cannot contain multiple dots");
}
this.path = Fn.join(this.dirname, this.stem + (e || ""));
}
/**
* Get the full path (example: `'~/index.min.js'`).
*
* @returns {string}
* Path.
*/
get path() {
return this.history[this.history.length - 1];
}
/**
* Set the full path (example: `'~/index.min.js'`).
*
* Cannot be nullified.
* You can set a file URL (a `URL` object with a `file:` protocol) which will
* be turned into a path with `url.fileURLToPath`.
*
* @param {URL | string} path
* Path.
* @returns {undefined}
* Nothing.
*/
set path(e) {
Nd(e) && (e = Qk(e)), tf(e, "path"), this.path !== e && this.history.push(e);
}
/**
* Get the stem (basename w/o extname) (example: `'index.min'`).
*
* @returns {string | undefined}
* Stem.
*/
get stem() {
return typeof this.path == "string" ? Fn.basename(this.path, this.extname) : void 0;
}
/**
* Set the stem (basename w/o extname) (example: `'index.min'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be nullified (use `file.path = file.dirname` instead).
*
* @param {string} stem
* Stem.
* @returns {undefined}
* Nothing.
*/
set stem(e) {
tf(e, "stem"), ef(e, "stem"), this.path = Fn.join(this.dirname || "", e + (this.extname || ""));
}
// Normal prototypal methods.
/**
* Create a fatal message for `reason` associated with the file.
*
* The `fatal` field of the message is set to `true` (error; file not usable)
* and the `file` field is set to the current file path.
* The message is added to the `messages` field on `file`.
*
* > 🪦 **Note**: also has obsolete signatures.
*
* @overload
* @param {string} reason
* @param {MessageOptions | null | undefined} [options]
* @returns {never}
*
* @overload
* @param {string} reason
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @overload
* @param {string} reason
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @overload
* @param {string} reason
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {string | null | undefined} [origin]
* @returns {never}
*
* @param {Error | VFileMessage | string} causeOrReason
* Reason for message, should use markdown.
* @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
* Configuration (optional).
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {never}
* Never.
* @throws {VFileMessage}
* Message.
*/
fail(e, r, n) {
const i = this.message(e, r, n);
throw i.fatal = !0, i;
}
/**
* Create an info message for `reason` associated with the file.
*
* The `fatal` field of the message is set to `undefined` (info; change
* likely not needed) and the `file` field is set to the current file path.
* The message is added to the `messages` field on `file`.
*
* > 🪦 **Note**: also has obsolete signatures.
*
* @overload
* @param {string} reason
* @param {MessageOptions | null | undefined} [options]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @param {Error | VFileMessage | string} causeOrReason
* Reason for message, should use markdown.
* @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
* Configuration (optional).
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {VFileMessage}
* Message.
*/
info(e, r, n) {
const i = this.message(e, r, n);
return i.fatal = void 0, i;
}
/**
* Create a message for `reason` associated with the file.
*
* The `fatal` field of the message is set to `false` (warning; change may be
* needed) and the `file` field is set to the current file path.
* The message is added to the `messages` field on `file`.
*
* > 🪦 **Note**: also has obsolete signatures.
*
* @overload
* @param {string} reason
* @param {MessageOptions | null | undefined} [options]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {string} reason
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Node | NodeLike | null | undefined} parent
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {Point | Position | null | undefined} place
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @overload
* @param {Error | VFileMessage} cause
* @param {string | null | undefined} [origin]
* @returns {VFileMessage}
*
* @param {Error | VFileMessage | string} causeOrReason
* Reason for message, should use markdown.
* @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]
* Configuration (optional).
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {VFileMessage}
* Message.
*/
message(e, r, n) {
const i = new wr(
// @ts-expect-error: the overloads are fine.
e,
r,
n
);
return this.path && (i.name = this.path + ":" + i.name, i.file = this.path), i.fatal = !1, this.messages.push(i), i;
}
/**
* Serialize the file.
*
* > **Note**: which encodings are supported depends on the engine.
* > For info on Node.js, see:
* > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.
*
* @param {string | null | undefined} [encoding='utf8']
* Character encoding to understand `value` as when it’s a `Uint8Array`
* (default: `'utf-8'`).
* @returns {string}
* Serialized file.
*/
toString(e) {
return this.value === void 0 ? "" : typeof this.value == "string" ? this.value : new TextDecoder(e || void 0).decode(this.value);
}
}
function ef(t, e) {
if (t && t.includes(Fn.sep))
throw new Error(
"`" + e + "` cannot be a path: did not expect `" + Fn.sep + "`"
);
}
function tf(t, e) {
if (!t)
throw new Error("`" + e + "` cannot be empty");
}
function JD(t, e) {
if (!t)
throw new Error("Setting `" + e + "` requires `path` to be set too");
}
function t3(t) {
return !!(t && typeof t == "object" && "byteLength" in t && "byteOffset" in t);
}
const r3 = (
/**
* @type {new <Parameters extends Array<unknown>, Result>(property: string | symbol) => (...parameters: Parameters) => Result}
*/
/** @type {unknown} */
/**
* @this {Function}
* @param {string | symbol} property
* @returns {(...parameters: Array<unknown>) => unknown}
*/
(function(t) {
const n = (
/** @type {Record<string | symbol, Function>} */
// Prototypes do exist.
// type-coverage:ignore-next-line
this.constructor.prototype
), i = n[t], s = function() {
return i.apply(s, arguments);
};
return Object.setPrototypeOf(s, n), s;
})
), n3 = {}.hasOwnProperty;
class Ym extends r3 {
/**
* Create a processor.
*/
constructor() {
super("copy"), this.Compiler = void 0, this.Parser = void 0, this.attachers = [], this.compiler = void 0, this.freezeIndex = -1, this.frozen = void 0, this.namespace = {}, this.parser = void 0, this.transformers = Uk();
}
/**
* Copy a processor.
*
* @deprecated
* This is a private internal method and should not be used.
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
* New *unfrozen* processor ({@linkcode Processor}) that is
* configured to work the same as its ancestor.
* When the descendant processor is configured in the future it does not
* affect the ancestral processor.
*/
copy() {
const e = (
/** @type {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} */
new Ym()
);
let r = -1;
for (; ++r < this.attachers.length; ) {
const n = this.attachers[r];
e.use(...n);
}
return e.data(Qh(!0, {}, this.namespace)), e;
}
/**
* Configure the processor with info available to all plugins.
* Information is stored in an object.
*
* Typically, options can be given to a specific plugin, but sometimes it
* makes sense to have information shared with several plugins.
* For example, a list of HTML elements that are self-closing, which is
* needed during all phases.
*
* > **Note**: setting information cannot occur on *frozen* processors.
* > Call the processor first to create a new unfrozen processor.
*
* > **Note**: to register custom data in TypeScript, augment the
* > {@linkcode Data} interface.
*
* @example
* This example show how to get and set info:
*
* ```js
* import {unified} from 'unified'
*
* const processor = unified().data('alpha', 'bravo')
*
* processor.data('alpha') // => 'bravo'
*
* processor.data() // => {alpha: 'bravo'}
*
* processor.data({charlie: 'delta'})
*
* processor.data() // => {charlie: 'delta'}
* ```
*
* @template {keyof Data} Key
*
* @overload
* @returns {Data}
*
* @overload
* @param {Data} dataset
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
*
* @overload
* @param {Key} key
* @returns {Data[Key]}
*
* @overload
* @param {Key} key
* @param {Data[Key]} value
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
*
* @param {Data | Key} [key]
* Key to get or set, or entire dataset to set, or nothing to get the
* entire dataset (optional).
* @param {Data[Key]} [value]
* Value to set (optional).
* @returns {unknown}
* The current processor when setting, the value at `key` when getting, or
* the entire dataset when getting without key.
*/
data(e, r) {
return typeof e == "string" ? arguments.length === 2 ? (sf("data", this.frozen), this.namespace[e] = r, this) : n3.call(this.namespace, e) && this.namespace[e] || void 0 : e ? (sf("data", this.frozen), this.namespace = e, this) : this.namespace;
}
/**
* Freeze a processor.
*
* Frozen processors are meant to be extended and not to be configured
* directly.
*
* When a processor is frozen it cannot be unfrozen.
* New processors working the same way can be created by calling the
* processor.
*
* It’s possible to freeze processors explicitly by calling `.freeze()`.
* Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
* `.stringify()`, `.process()`, or `.processSync()` are called.
*
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
* The current processor.
*/
freeze() {
if (this.frozen)
return this;
const e = (
/** @type {Processor} */
/** @type {unknown} */
this
);
for (; ++this.freezeIndex < this.attachers.length; ) {
const [r, ...n] = this.attachers[this.freezeIndex];
if (n[0] === !1)
continue;
n[0] === !0 && (n[0] = void 0);
const i = r.call(e, ...n);
typeof i == "function" && this.transformers.use(i);
}
return this.frozen = !0, this.freezeIndex = Number.POSITIVE_INFINITY, this;
}
/**
* Parse text to a syntax tree.
*
* > **Note**: `parse` freezes the processor if not already *frozen*.
*
* > **Note**: `parse` performs the parse phase, not the run phase or other
* > phases.
*
* @param {Compatible | undefined} [file]
* file to parse (optional); typically `string` or `VFile`; any value
* accepted as `x` in `new VFile(x)`.
* @returns {ParseTree extends undefined ? Node : ParseTree}
* Syntax tree representing `file`.
*/
parse(e) {
this.freeze();
const r = ml(e), n = this.parser || this.Parser;
return rf("parse", n), n(String(r), r);
}
/**
* Process the given file as configured on the processor.
*
* > **Note**: `process` freezes the processor if not already *frozen*.
*
* > **Note**: `process` performs the parse, run, and stringify phases.
*
* @overload
* @param {Compatible | undefined} file
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
* @returns {undefined}
*
* @overload
* @param {Compatible | undefined} [file]
* @returns {Promise<VFileWithOutput<CompileResult>>}
*
* @param {Compatible | undefined} [file]
* File (optional); typically `string` or `VFile`]; any value accepted as
* `x` in `new VFile(x)`.
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
* Callback (optional).
* @returns {Promise<VFile> | undefined}
* Nothing if `done` is given.
* Otherwise a promise, rejected with a fatal error or resolved with the
* processed file.
*
* The parsed, transformed, and compiled value is available at
* `file.value` (see note).
*
* > **Note**: unified typically compiles by serializing: most
* > compilers return `string` (or `Uint8Array`).
* > Some compilers, such as the one configured with
* > [`rehype-react`][rehype-react], return other values (in this case, a
* > React tree).
* > If you’re using a compiler that doesn’t serialize, expect different
* > result values.
* >
* > To register custom results in TypeScript, add them to
* > {@linkcode CompileResultMap}.
*
* [rehype-react]: https://github.com/rehypejs/rehype-react
*/
process(e, r) {
const n = this;
return this.freeze(), rf("process", this.parser || this.Parser), nf("process", this.compiler || this.Compiler), r ? i(void 0, r) : new Promise(i);
function i(s, a) {
const o = ml(e), u = (
/** @type {HeadTree extends undefined ? Node : HeadTree} */
/** @type {unknown} */
n.parse(o)
);
n.run(u, o, function(c, p, f) {
if (c || !p || !f)
return l(c);
const h = (
/** @type {CompileTree extends undefined ? Node : CompileTree} */
/** @type {unknown} */
p
), m = n.stringify(h, f);
a3(m) ? f.value = m : f.result = m, l(
c,
/** @type {VFileWithOutput<CompileResult>} */
f
);
});
function l(c, p) {
c || !p ? a(c) : s ? s(p) : r(void 0, p);
}
}
}
/**
* Process the given file as configured on the processor.
*
* An error is thrown if asynchronous transforms are configured.
*
* > **Note**: `processSync` freezes the processor if not already *frozen*.
*
* > **Note**: `processSync` performs the parse, run, and stringify phases.
*
* @param {Compatible | undefined} [file]
* File (optional); typically `string` or `VFile`; any value accepted as
* `x` in `new VFile(x)`.
* @returns {VFileWithOutput<CompileResult>}
* The processed file.
*
* The parsed, transformed, and compiled value is available at
* `file.value` (see note).
*
* > **Note**: unified typically compiles by serializing: most
* > compilers return `string` (or `Uint8Array`).
* > Some compilers, such as the one configured with
* > [`rehype-react`][rehype-react], return other values (in this case, a
* > React tree).
* > If you’re using a compiler that doesn’t serialize, expect different
* > result values.
* >
* > To register custom results in TypeScript, add them to
* > {@linkcode CompileResultMap}.
*
* [rehype-react]: https://github.com/rehypejs/rehype-react
*/
processSync(e) {
let r = !1, n;
return this.freeze(), rf("processSync", this.parser || this.Parser), nf("processSync", this.compiler || this.Compiler), this.process(e, i), YD("processSync", "process", r), n;
function i(s, a) {
r = !0, VD(s), n = a;
}
}
/**
* Run *transformers* on a syntax tree.
*
* > **Note**: `run` freezes the processor if not already *frozen*.
*
* > **Note**: `run` performs the run phase, not other phases.
*
* @overload
* @param {HeadTree extends undefined ? Node : HeadTree} tree
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
* @returns {undefined}
*
* @overload
* @param {HeadTree extends undefined ? Node : HeadTree} tree
* @param {Compatible | undefined} file
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
* @returns {undefined}
*
* @overload
* @param {HeadTree extends undefined ? Node : HeadTree} tree
* @param {Compatible | undefined} [file]
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
*
* @param {HeadTree extends undefined ? Node : HeadTree} tree
* Tree to transform and inspect.
* @param {(
* RunCallback<TailTree extends undefined ? Node : TailTree> |
* Compatible
* )} [file]
* File associated with `node` (optional); any value accepted as `x` in
* `new VFile(x)`.
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
* Callback (optional).
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
* Nothing if `done` is given.
* Otherwise, a promise rejected with a fatal error or resolved with the
* transformed tree.
*/
run(e, r, n) {
KD(e), this.freeze();
const i = this.transformers;
return !n && typeof r == "function" && (n = r, r = void 0), n ? s(void 0, n) : new Promise(s);
function s(a, o) {
const u = ml(r);
i.run(e, u, l);
function l(c, p, f) {
const h = (
/** @type {TailTree extends undefined ? Node : TailTree} */
p || e
);
c ? o(c) : a ? a(h) : n(void 0, h, f);
}
}
}
/**
* Run *transformers* on a syntax tree.
*
* An error is thrown if asynchronous transforms are configured.
*
* > **Note**: `runSync` freezes the processor if not already *frozen*.
*
* > **Note**: `runSync` performs the run phase, not other phases.
*
* @param {HeadTree extends undefined ? Node : HeadTree} tree
* Tree to transform and inspect.
* @param {Compatible | undefined} [file]
* File associated with `node` (optional); any value accepted as `x` in
* `new VFile(x)`.
* @returns {TailTree extends undefined ? Node : TailTree}
* Transformed tree.
*/
runSync(e, r) {
let n = !1, i;
return this.run(e, r, s), YD("runSync", "run", n), i;
function s(a, o) {
VD(a), i = o, n = !0;
}
}
/**
* Compile a syntax tree.
*
* > **Note**: `stringify` freezes the processor if not already *frozen*.
*
* > **Note**: `stringify` performs the stringify phase, not the run phase
* > or other phases.
*
* @param {CompileTree extends undefined ? Node : CompileTree} tree
* Tree to compile.
* @param {Compatible | undefined} [file]
* File associated with `node` (optional); any value accepted as `x` in
* `new VFile(x)`.
* @returns {CompileResult extends undefined ? Value : CompileResult}
* Textual representation of the tree (see note).
*
* > **Note**: unified typically compiles by serializing: most compilers
* > return `string` (or `Uint8Array`).
* > Some compilers, such as the one configured with
* > [`rehype-react`][rehype-react], return other values (in this case, a
* > React tree).
* > If you’re using a compiler that doesn’t serialize, expect different
* > result values.
* >
* > To register custom results in TypeScript, add them to
* > {@linkcode CompileResultMap}.
*
* [rehype-react]: https://github.com/rehypejs/rehype-react
*/
stringify(e, r) {
this.freeze();
const n = ml(r), i = this.compiler || this.Compiler;
return nf("stringify", i), KD(e), i(e, n);
}
/**
* Configure the processor to use a plugin, a list of usable values, or a
* preset.
*
* If the processor is already using a plugin, the previous plugin
* configuration is changed based on the options that are passed in.
* In other words, the plugin is not added a second time.
*
* > **Note**: `use` cannot be called on *frozen* processors.
* > Call the processor first to create a new unfrozen processor.
*
* @example
* There are many ways to pass plugins to `.use()`.
* This example gives an overview:
*
* ```js
* import {unified} from 'unified'
*
* unified()
* // Plugin with options:
* .use(pluginA, {x: true, y: true})
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
* .use(pluginA, {y: false, z: true})
* // Plugins:
* .use([pluginB, pluginC])
* // Two plugins, the second with options:
* .use([pluginD, [pluginE, {}]])
* // Preset with plugins and settings:
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
* // Settings only:
* .use({settings: {position: false}})
* ```
*
* @template {Array<unknown>} [Parameters=[]]
* @template {Node | string | undefined} [Input=undefined]
* @template [Output=Input]
*
* @overload
* @param {Preset | null | undefined} [preset]
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
*
* @overload
* @param {PluggableList} list
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
*
* @overload
* @param {Plugin<Parameters, Input, Output>} plugin
* @param {...(Parameters | [boolean])} parameters
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
*
* @param {PluggableList | Plugin | Preset | null | undefined} value
* Usable value.
* @param {...unknown} parameters
* Parameters, when a plugin is given as a usable value.
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
* Current processor.
*/
use(e, ...r) {
const n = this.attachers, i = this.namespace;
if (sf("use", this.frozen), e != null) if (typeof e == "function")
u(e, r);
else if (typeof e == "object")
Array.isArray(e) ? o(e) : a(e);
else
throw new TypeError("Expected usable value, not `" + e + "`");
return this;
function s(l) {
if (typeof l == "function")
u(l, []);
else if (typeof l == "object")
if (Array.isArray(l)) {
const [c, ...p] = (
/** @type {PluginTuple<Array<unknown>>} */
l
);
u(c, p);
} else
a(l);
else
throw new TypeError("Expected usable value, not `" + l + "`");
}
function a(l) {
if (!("plugins" in l) && !("settings" in l))
throw new Error(
"Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither"
);
o(l.plugins), l.settings && (i.settings = Qh(!0, i.settings, l.settings));
}
function o(l) {
let c = -1;
if (l != null) if (Array.isArray(l))
for (; ++c < l.length; ) {
const p = l[c];
s(p);
}
else
throw new TypeError("Expected a list of plugins, not `" + l + "`");
}
function u(l, c) {
let p = -1, f = -1;
for (; ++p < n.length; )
if (n[p][0] === l) {
f = p;
break;
}
if (f === -1)
n.push([l, ...c]);
else if (c.length > 0) {
let [h, ...m] = c;
const g = n[f][1];
_d(g) && _d(h) && (h = Qh(!0, g, h)), n[f] = [l, h, ...m];
}
}
}
}
const i3 = new Ym().freeze();
function rf(t, e) {
if (typeof e != "function")
throw new TypeError("Cannot `" + t + "` without `parser`");
}
function nf(t, e) {
if (typeof e != "function")
throw new TypeError("Cannot `" + t + "` without `compiler`");
}
function sf(t, e) {
if (e)
throw new Error(
"Cannot call `" + t + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`."
);
}
function KD(t) {
if (!_d(t) || typeof t.type != "string")
throw new TypeError("Expected node, got `" + t + "`");
}
function YD(t, e, r) {
if (!r)
throw new Error(
"`" + t + "` finished async. Use `" + e + "` instead"
);
}
function ml(t) {
return s3(t) ? t : new e3(t);
}
function s3(t) {
return !!(t && typeof t == "object" && "message" in t && "messages" in t);
}
function a3(t) {
return typeof t == "string" || o3(t);
}
function o3(t) {
return !!(t && typeof t == "object" && "byteLength" in t && "byteOffset" in t);
}
const u3 = {};
function Xm(t, e) {
const r = u3, n = typeof r.includeImageAlt == "boolean" ? r.includeImageAlt : !0, i = typeof r.includeHtml == "boolean" ? r.includeHtml : !0;
return mA(t, n, i);
}
function mA(t, e, r) {
if (l3(t)) {
if ("value" in t)
return t.type === "html" && !r ? "" : t.value;
if (e && "alt" in t && t.alt)
return t.alt;
if ("children" in t)
return XD(t.children, e, r);
}
return Array.isArray(t) ? XD(t, e, r) : "";
}
function XD(t, e, r) {
const n = [];
let i = -1;
for (; ++i < t.length; )
n[i] = mA(t[i], e, r);
return n.join("");
}
function l3(t) {
return !!(t && typeof t == "object");
}
const QD = document.createElement("i");
function Qm(t) {
const e = "&" + t + ";";
QD.innerHTML = e;
const r = QD.textContent;
return (
// @ts-expect-error: TypeScript is wrong that `textContent` on elements can
// yield `null`.
r.charCodeAt(r.length - 1) === 59 && t !== "semi" || r === e ? !1 : r
);
}
function Lr(t, e, r, n) {
const i = t.length;
let s = 0, a;
if (e < 0 ? e = -e > i ? 0 : i + e : e = e > i ? i : e, r = r > 0 ? r : 0, n.length < 1e4)
a = Array.from(n), a.unshift(e, r), t.splice(...a);
else
for (r && t.splice(e, r); s < n.length; )
a = n.slice(s, s + 1e4), a.unshift(e, 0), t.splice(...a), s += 1e4, e += 1e4;
}
function Jr(t, e) {
return t.length > 0 ? (Lr(t, t.length, 0, e), t) : e;
}
const ZD = {}.hasOwnProperty;
function gA(t) {
const e = {};
let r = -1;
for (; ++r < t.length; )
c3(e, t[r]);
return e;
}
function c3(t, e) {
let r;
for (r in e) {
const i = (ZD.call(t, r) ? t[r] : void 0) || (t[r] = {}), s = e[r];
let a;
if (s)
for (a in s) {
ZD.call(i, a) || (i[a] = []);
const o = s[a];
p3(
// @ts-expect-error Looks like a list.
i[a],
Array.isArray(o) ? o : o ? [o] : []
);
}
}
}
function p3(t, e) {
let r = -1;
const n = [];
for (; ++r < e.length; )
(e[r].add === "after" ? t : n).push(e[r]);
Lr(t, 0, 0, n);
}
function yA(t, e) {
const r = Number.parseInt(t, e);
return (
// C0 except for HT, LF, FF, CR, space.
r < 9 || r === 11 || r > 13 && r < 32 || // Control character (DEL) of C0, and C1 controls.
r > 126 && r < 160 || // Lone high surrogates and low surrogates.
r > 55295 && r < 57344 || // Noncharacters.
r > 64975 && r < 65008 || /* eslint-disable no-bitwise */
(r & 65535) === 65535 || (r & 65535) === 65534 || /* eslint-enable no-bitwise */
// Out of range
r > 1114111 ? "�" : String.fromCodePoint(r)
);
}
function fn(t) {
return t.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
}
const ur = Hi(/[A-Za-z]/), Qt = Hi(/[\dA-Za-z]/), h3 = Hi(/[#-'*+\--9=?A-Z^-~]/);
function pp(t) {
return (
// Special whitespace codes (which have negative values), C0 and Control
// character DEL
t !== null && (t < 32 || t === 127)
);
}
const Id = Hi(/\d/), f3 = Hi(/[\dA-Fa-f]/), d3 = Hi(/[!-/:-@[-`{-~]/);
function Se(t) {
return t !== null && t < -2;
}
function at(t) {
return t !== null && (t < 0 || t === 32);
}
function He(t) {
return t === -2 || t === -1 || t === 32;
}
const Rp = Hi(new RegExp("\\p{P}|\\p{S}", "u")), Fs = Hi(/\s/);
function Hi(t) {
return e;
function e(r) {
return r !== null && r > -1 && t.test(String.fromCharCode(r));
}
}
function $a(t) {
const e = [];
let r = -1, n = 0, i = 0;
for (; ++r < t.length; ) {
const s = t.charCodeAt(r);
let a = "";
if (s === 37 && Qt(t.charCodeAt(r + 1)) && Qt(t.charCodeAt(r + 2)))
i = 2;
else if (s < 128)
/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s)) || (a = String.fromCharCode(s));
else if (s > 55295 && s < 57344) {
const o = t.charCodeAt(r + 1);
s < 56320 && o > 56319 && o < 57344 ? (a = String.fromCharCode(s, o), i = 1) : a = "�";
} else
a = String.fromCharCode(s);
a && (e.push(t.slice(n, r), encodeURIComponent(a)), n = r + i + 1, a = ""), i && (r += i, i = 0);
}
return e.join("") + t.slice(n);
}
function Xe(t, e, r, n) {
const i = n ? n - 1 : Number.POSITIVE_INFINITY;
let s = 0;
return a;
function a(u) {
return He(u) ? (t.enter(r), o(u)) : e(u);
}
function o(u) {
return He(u) && s++ < i ? (t.consume(u), o) : (t.exit(r), e(u));
}
}
const m3 = {
tokenize: g3
};
function g3(t) {
const e = t.attempt(this.parser.constructs.contentInitial, n, i);
let r;
return e;
function n(o) {
if (o === null) {
t.consume(o);
return;
}
return t.enter("lineEnding"), t.consume(o), t.exit("lineEnding"), Xe(t, e, "linePrefix");
}
function i(o) {
return t.enter("paragraph"), s(o);
}
function s(o) {
const u = t.enter("chunkText", {
contentType: "text",
previous: r
});
return r && (r.next = u), r = u, a(o);
}
function a(o) {
if (o === null) {
t.exit("chunkText"), t.exit("paragraph"), t.consume(o);
return;
}
return Se(o) ? (t.consume(o), t.exit("chunkText"), s) : (t.consume(o), a);
}
}
const y3 = {
tokenize: D3
}, e2 = {
tokenize: E3
};
function D3(t) {
const e = this, r = [];
let n = 0, i, s, a;
return o;
function o(x) {
if (n < r.length) {
const C = r[n];
return e.containerState = C[1], t.attempt(C[0].continuation, u, l)(x);
}
return l(x);
}
function u(x) {
if (n++, e.containerState._closeFlow) {
e.containerState._closeFlow = void 0, i && d();
const C = e.events.length;
let E = C, A;
for (; E--; )
if (e.events[E][0] === "exit" && e.events[E][1].type === "chunkFlow") {
A = e.events[E][1].end;
break;
}
D(n);
let b = C;
for (; b < e.events.length; )
e.events[b][1].end = {
...A
}, b++;
return Lr(e.events, E + 1, 0, e.events.slice(C)), e.events.length = b, l(x);
}
return o(x);
}
function l(x) {
if (n === r.length) {
if (!i)
return f(x);
if (i.currentConstruct && i.currentConstruct.concrete)
return m(x);
e.interrupt = !!(i.currentConstruct && !i._gfmTableDynamicInterruptHack);
}
return e.containerState = {}, t.check(e2, c, p)(x);
}
function c(x) {
return i && d(), D(n), f(x);
}
function p(x) {
return e.parser.lazy[e.now().line] = n !== r.length, a = e.now().offset, m(x);
}
function f(x) {
return e.containerState = {}, t.attempt(e2, h, m)(x);
}
function h(x) {
return n++, r.push([e.currentConstruct, e.containerState]), f(x);
}
function m(x) {
if (x === null) {
i && d(), D(0), t.consume(x);
return;
}
return i = i || e.parser.flow(e.now()), t.enter("chunkFlow", {
_tokenizer: i,
contentType: "flow",
previous: s
}), g(x);
}
function g(x) {
if (x === null) {
y(t.exit("chunkFlow"), !0), D(0), t.consume(x);
return;
}
return Se(x) ? (t.consume(x), y(t.exit("chunkFlow")), n = 0, e.interrupt = void 0, o) : (t.consume(x), g);
}
function y(x, C) {
const E = e.sliceStream(x);
if (C && E.push(null), x.previous = s, s && (s.next = x), s = x, i.defineSkip(x.start), i.write(E), e.parser.lazy[x.start.line]) {
let A = i.events.length;
for (; A--; )
if (
// The token starts before the line ending…
i.events[A][1].start.offset < a && // …and either is not ended yet…
(!i.events[A][1].end || // …or ends after it.
i.events[A][1].end.offset > a)
)
return;
const b = e.events.length;
let w = b, P, F;
for (; w--; )
if (e.events[w][0] === "exit" && e.events[w]