@tanstack/ai-mcp
Version:
Host-side Model Context Protocol client for TanStack AI: discover and run MCP server tools, resources, and prompts in any adapter's chat() loop, with generated end-to-end types.
4,835 lines • 198 kB
JavaScript
#!/usr/bin/env node
import {
__esm,
init_esm_shims
} from "./chunk-K3ER4CT6.js";
// ../../node_modules/.pnpm/prettier@3.9.9/node_modules/prettier/plugins/yaml.mjs
function _o(t7) {
return this[t7 < 0 ? this.length + t7 : t7];
}
function sn(t7, e, n) {
if (!t7.has(e)) {
let s = n(e);
t7.set(e, s);
}
return t7.get(e);
}
function Do(t7) {
if (typeof t7 == "string") return gt;
if (Array.isArray(t7)) return yt;
if (!t7) return;
let { type: e } = t7;
if (nn.has(e)) return e;
}
function Mo(t7) {
let e = t7 === null ? "null" : typeof t7;
if (e !== "string" && e !== "object") return `Unexpected doc '${e}',
Expected it to be 'string' or 'object'.`;
if (rn(t7)) throw new Error("doc is valid.");
let n = Object.prototype.toString.call(t7);
if (n !== "[object Object]") return `Unexpected doc '${n}'.`;
let s = xo([...nn].map((r) => `'${r}'`));
return `Unexpected doc.type '${t7.type}'.
Expected it to be ${s}.`;
}
function $o(t7, e) {
if (typeof t7 == "string") return e(t7);
let n = /* @__PURE__ */ new Map();
return s(t7);
function s(i) {
return sn(n, i, r);
}
function r(i) {
switch (rn(i)) {
case yt:
return e(i.map(s));
case Ve:
return e({ ...i, parts: i.parts.map(s) });
case Ge:
return e({ ...i, breakContents: s(i.breakContents), flatContents: s(i.flatContents) });
case je: {
let { expandedStates: o, contents: a } = i;
return o ? (o = o.map(s), a = o[0]) : a = s(a), e({ ...i, contents: a, expandedStates: o });
}
case Ue:
case Xt:
case Zt:
case tn:
case Qe:
return e({ ...i, contents: s(i.contents) });
case gt:
case Wt:
case zt:
case en:
case ke:
case He:
return e(i);
default:
throw new Zs(i);
}
}
}
function er(t7, e = wt) {
return $o(t7, (n) => typeof n == "string" ? R(e, n.split(`
`)) : n);
}
function bt(t7, e) {
return nr(t7), re(e), { type: Ue, contents: e, n: t7 };
}
function as(t7) {
return bt(Number.NEGATIVE_INFINITY, t7);
}
function sr(t7) {
return bt({ type: "root" }, t7);
}
function rr(t7) {
return bt(-1, t7);
}
function an(t7) {
return tr(t7), { type: Ve, parts: t7 };
}
function Je(t7, e = {}) {
return re(t7), on(e.expandedStates, true), { type: je, id: e.id, contents: t7, break: !!e.shouldBreak, expandedStates: e.expandedStates };
}
function ls(t7, e) {
return Je(t7[0], { ...e, expandedStates: t7 });
}
function St(t7, e = "", n = {}) {
return re(t7), e !== "" && re(e), { type: Ge, breakContents: t7, flatContents: e, groupId: n.groupId };
}
function R(t7, e) {
re(t7), on(e);
let n = [];
for (let s = 0; s < e.length; s++) s !== 0 && n.push(t7), n.push(e[s]);
return n;
}
function ir(t7) {
return re(t7), { type: Qe, contents: t7 };
}
function cn(t7) {
return (e, n, s) => {
if (n === false) return false;
let r = !!s?.backwards, { length: i } = e, o = n;
for (; o >= 0 && o < i; ) {
let a = e.charAt(o);
if (t7 instanceof RegExp) {
if (!t7.test(a)) return o;
} else if (!t7.includes(a)) return o;
r ? o-- : o++;
}
return o === -1 || o === i ? o : false;
};
}
function qo(t7, e, n) {
if (e === false) return false;
let s = !!n?.backwards, r = t7.charAt(e);
if (s) {
if (t7.charAt(e - 1) === "\r" && r === `
`) return e - 2;
if (or(r)) return e - 1;
} else {
if (r === "\r" && t7.charAt(e + 1) === `
`) return e + 2;
if (or(r)) return e + 1;
}
return e;
}
function Fo(t7, e) {
let n = e - 1;
n = cs(t7, n, { backwards: true }), n = fs(t7, n, { backwards: true }), n = cs(t7, n, { backwards: true });
let s = fs(t7, n, { backwards: true });
return n !== s;
}
function lr(t7, e) {
let { node: n } = t7;
if (n.type === "root" && e.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint|lintstaged)rc$/.test(e.filepath)) return async (s) => {
let r = await s(e.originalText, { parser: "json" });
return r ? [r, O] : void 0;
};
}
function Ct(t7) {
if (Et !== null && typeof Et.property) {
let e = Et;
return Et = Ct.prototype = null, e;
}
return Et = Ct.prototype = t7 ?? /* @__PURE__ */ Object.create(null), new Ct();
}
function ms(t7) {
return Ct(t7);
}
function Yo(t7, e = "type") {
ms(t7);
function n(s) {
let r = s[e], i = t7[r];
if (!Array.isArray(i)) throw Object.assign(new Error(`Missing visitor keys for '${r}'.`), { node: s });
return i;
}
return n;
}
function hs(t7, e) {
switch (t7.type) {
case "comment":
if (wr(t7.value)) return null;
break;
case "quoteDouble":
case "quoteSingle":
e.type = "quote";
break;
case "document":
e.directivesEndMarker || delete e.directivesEndMarker, e.documentEndMarker || delete e.documentEndMarker;
break;
case "blockLiteral":
case "blockFolded":
t7.chomping === "keep" ? e.value = t7.value.split(`
`).map((n) => n.replace(/[ \t]+$/, "")).join(`
`) : (t7.chomping === "clip" || t7.chomping === "strip") && (e.value = t7.value.trimEnd());
break;
}
}
function jo(t7) {
return Array.isArray(t7) && t7.length > 0;
}
function X(t7, e) {
return typeof t7?.type == "string" && e.includes(t7.type);
}
function ds(t7, e, n) {
return e("children" in t7 ? { ...t7, children: t7.children.map((s) => ds(s, e, t7)) } : t7, n);
}
function Xe(t7, e, n) {
Object.defineProperty(t7, e, { get: n, enumerable: false });
}
function Cr(t7, e) {
let n = 0, s = e.length;
for (let r = t7.position.end.offset - 1; r < s; r++) {
let i = e[r];
if (i === `
` && n++, n === 1 && /\S/.test(i)) return false;
if (n === 2) return true;
}
return false;
}
function fn(t7) {
let { node: e } = t7;
switch (e.type) {
case "tag":
case "anchor":
case "comment":
return false;
}
let n = t7.stack.length;
for (let s = 1; s < n; s++) {
let r = t7.stack[s], i = t7.stack[s - 1];
if (Array.isArray(i) && typeof r == "number" && r !== i.length - 1) return false;
}
return true;
}
function un(t7) {
return We(t7.children) ? un(V(0, t7.children, -1)) : t7;
}
function Er(t7) {
return t7.value.trim() === "prettier-ignore";
}
function Nr(t7) {
let { node: e } = t7;
if (e.type === "documentBody") {
let n = t7.parent.head;
return K(n) && Er(V(0, n.endComments, -1));
}
return pe(e) && Er(V(0, e.leadingComments, -1));
}
function ze(t7) {
return !We(t7.children) && !Vo(t7);
}
function Vo(t7) {
return pe(t7) || Pe(t7) || gs(t7) || z(t7) || K(t7);
}
function pe(t7) {
return We(t7?.leadingComments);
}
function Pe(t7) {
return We(t7?.middleComments);
}
function gs(t7) {
return t7?.indicatorComment;
}
function z(t7) {
return t7?.trailingComment;
}
function K(t7) {
return We(t7?.endComments);
}
function Ar(t7) {
return t7 ? t7.split(/(?<!^| ) (?! |$)/) : [];
}
function Tr(t7, e, n) {
let s = e.split(`
`).map((i, o, a) => o === 0 && o === a.length - 1 ? i : o !== 0 && o !== a.length - 1 ? i.trim() : o === 0 ? i.trimEnd() : i.trimStart());
if (n.proseWrap === "preserve") return s.map((i) => i ? [i] : []);
let r = [];
for (let [i, o] of s.entries()) {
let a = Ar(o);
i > 0 && s[i - 1].length > 0 && a.length > 0 && !(t7 === "quoteDouble" && V(0, V(0, r, -1), -1).endsWith("\\")) ? r[r.length - 1] = [...V(0, r, -1), ...a] : r.push(a);
}
return n.proseWrap === "never" ? r.map((i) => [i.join(" ")]) : r;
}
function Or(t7, { parentIndent: e, isLastDescendant: n, options: s }) {
let r = t7.position.start.line === t7.position.end.line ? "" : s.originalText.slice(t7.position.start.offset, t7.position.end.offset).match(/^[^\n]*\n(.*)$/s)[1];
if (r === "") return [];
let i;
if (t7.indent === null) {
let c = r.match(/^(?<leadingSpace> *)[^\n\r ]/m);
i = c ? c.groups.leadingSpace.length : Number.POSITIVE_INFINITY;
} else i = t7.indent - 1 + e;
let o = r.split(`
`).map((c) => c.slice(i));
if (s.proseWrap === "preserve" || t7.type === "blockLiteral") return l(o.map((c) => c ? [c] : []));
let a = [];
for (let [c, u] of o.entries()) {
let f = Ar(u);
c > 0 && f.length > 0 && o[c - 1].length > 0 && !/^\s/.test(f[0]) && !/^\s|\s$/.test(V(0, a, -1)) ? a[a.length - 1] = [...V(0, a, -1), ...f] : a.push(f);
}
return a = a.map((c) => {
let u = [];
for (let f of c) u.length > 0 && /\s$/.test(V(0, u, -1)) ? u[u.length - 1] += " " + f : u.push(f);
return u;
}), s.proseWrap === "never" && (a = a.map((c) => [c.join(" ")])), l(a);
function l(c) {
if (t7.chomping === "keep") return r.endsWith(`
`) && V(0, c, -1).length === 0 ? c.slice(0, -1) : c;
let u = 0;
for (let f = c.length - 1; f >= 0 && c[f].every((p) => p.replace(/[ \t]+$/, "") === ""); f--) u++;
return u === 0 ? c : u >= 2 && !n ? c.slice(0, -(u - 1)) : c.slice(0, -u);
}
}
function At(t7) {
if (!t7) return true;
switch (t7.type) {
case "plain":
case "quoteDouble":
case "quoteSingle":
case "alias":
case "flowMapping":
case "flowSequence":
return true;
default:
return false;
}
}
function pn(t7, e) {
let { node: n, root: s } = t7, r = sn(Go, s, () => /* @__PURE__ */ new Set());
return !r.has(n.position.end.offset) && (r.add(n.position.end.offset), Cr(n, e) && !ys(t7.parent)) ? ln : "";
}
function ys(t7) {
return K(t7) && !X(t7, ["documentHead", "documentBody", "flowMapping", "flowSequence"]);
}
function Y(t7, e) {
return bt(" ".repeat(t7), e);
}
function Qo(t7, e, n) {
let { node: s } = t7, r = t7.ancestors.filter((c) => c.type === "sequence" || c.type === "mapping").length, i = fn(t7), o = [s.type === "blockFolded" ? ">" : "|"];
s.indent !== null && o.push(s.indent.toString()), s.chomping !== "clip" && o.push(s.chomping === "keep" ? "+" : "-"), gs(s) && o.push(" ", n("indicatorComment"));
let a = Or(s, { parentIndent: r, isLastDescendant: i, options: e }), l = [];
for (let [c, u] of a.entries()) c === 0 && l.push(O), l.push(an(R(Se, u))), c !== a.length - 1 ? l.push(u.length === 0 ? O : sr(wt)) : s.chomping === "keep" && i && l.push(as(u.length === 0 ? O : wt));
return s.indent === null ? o.push(rr(Y(e.tabWidth, l))) : o.push(as(Y(s.indent - 1 + r, l))), o;
}
function mn(t7, e, n) {
let { node: s } = t7, r = s.type === "flowMapping", i = r ? "{" : "[", o = r ? "}" : "]", a = ln;
r && s.children.length > 0 && e.bracketSpacing && (a = Se);
let l = V(0, s.children, -1), c = l?.type === "flowMappingItem" && ze(l.key) && ze(l.value);
return [i, Y(e.tabWidth, [a, Ho(t7, e, n), e.trailingComma === "none" ? "" : St(","), K(s) ? [O, R(O, t7.map(n, "endComments"))] : ""]), c ? "" : a, o];
}
function Ho(t7, e, n) {
return t7.map(({ isLast: s, node: r, next: i }) => [n(), s ? "" : [",", Se, r.position.start.line !== i.position.start.line ? pn(t7, e.originalText) : ""]], "children");
}
function Jo(t7, e, n) {
let { node: s, parent: r } = t7, { key: i, value: o } = s, a = ze(i), l = ze(o);
if (a && l) return ": ";
let c = n("key"), u = Wo(s) ? " " : "";
if (l) return s.type === "flowMappingItem" && r.type === "flowMapping" ? c : s.type === "mappingItem" && hn(i.content, e) && !z(i.content) && r.tag?.value !== "tag:yaml.org,2002:set" ? [c, u, ":"] : ["? ", Y(2, c)];
let f = n("value");
if (a) return [": ", Y(2, f)];
if (pe(o) || !At(i.content)) return ["? ", Y(2, c), O, ...t7.map(() => [n(), O], "value", "leadingComments"), ": ", Y(2, f)];
if (Xo(i.content) && !pe(i.content) && !Pe(i.content) && !z(i.content) && !K(i) && !pe(o.content) && !Pe(o.content) && !K(o) && hn(o.content, e) && hn(i.content, e)) return [c, u, ": ", f];
let p = /* @__PURE__ */ Symbol("mappingKey"), h = Je([St("? "), Je(Y(2, c), { id: p })]), g = [O, ": ", Y(2, f)], m = [u, ":"];
K(o) && o.content && X(o.content, ["flowMapping", "flowSequence"]) && o.content.children.length === 0 ? m.push(" ") : pe(o.content) || K(o) && o.content && !X(o.content, ["mapping", "sequence"]) || r.type === "mapping" && z(i.content) && At(o.content) || X(o.content, ["mapping", "sequence"]) && o.content.tag === null && o.content.anchor === null ? m.push(O) : o.content ? m.push(Se) : z(o) && m.push(" "), m.push(f);
let d = Y(e.tabWidth, m);
return hn(i.content, e) && !pe(i.content) && !Pe(i.content) && !z(i.content) && !K(i) ? ls([[c, d]]) : ls([[h, St(g, d, { groupId: p })]]);
}
function hn(t7, e) {
if (!t7) return true;
switch (t7.type) {
case "plain":
case "quoteSingle":
case "quoteDouble":
break;
case "alias":
return true;
default:
return false;
}
if (e.proseWrap === "preserve") return t7.position.start.line === t7.position.end.line;
if (/\\$/m.test(e.originalText.slice(t7.position.start.offset, t7.position.end.offset))) return false;
switch (e.proseWrap) {
case "never":
return !t7.value.includes(`
`);
case "always":
return !/[\n ]/.test(t7.value);
default:
return false;
}
}
function Wo(t7) {
return t7.key.content?.type === "alias";
}
function Xo(t7) {
if (!t7) return true;
switch (t7.type) {
case "plain":
case "quoteDouble":
case "quoteSingle":
return t7.position.start.line === t7.position.end.line;
case "alias":
return true;
default:
return false;
}
}
function zo(t7) {
return ds(t7, Zo);
}
function Zo(t7) {
switch (t7.type) {
case "document":
Xe(t7, "head", () => t7.children[0]), Xe(t7, "body", () => t7.children[1]);
break;
case "documentBody":
case "sequenceItem":
case "flowSequenceItem":
case "mappingKey":
case "mappingValue":
Xe(t7, "content", () => t7.children[0]);
break;
case "mappingItem":
case "flowMappingItem":
Xe(t7, "key", () => t7.children[0]), Xe(t7, "value", () => t7.children[1]);
break;
}
return t7;
}
function ea(t7, e, n) {
let { node: s } = t7, r = [];
s.type !== "mappingValue" && pe(s) && r.push([R(O, t7.map(n, "leadingComments")), O]);
let { tag: i, anchor: o } = s;
i && r.push(n("tag")), i && o && r.push(" "), o && r.push(n("anchor"));
let a = "";
return X(s, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !fn(t7) && (a = pn(t7, e.originalText)), (i || o) && (X(s, ["sequence", "mapping"]) && !Pe(s) ? r.push(O) : r.push(" ")), Pe(s) && r.push([s.middleComments.length === 1 ? "" : O, R(O, t7.map(n, "middleComments")), O]), Nr(t7) ? r.push(er(e.originalText.slice(s.position.start.offset, s.position.end.offset).trimEnd())) : r.push(Je(ta(t7, e, n))), z(s) && !X(s, ["document", "documentHead"]) && r.push(ir([s.type === "mappingValue" && !s.content ? "" : " ", t7.parent.type === "mappingKey" && t7.getParentNode(2).type === "mapping" && At(s) ? "" : kt, n("trailingComment")])), ys(s) && r.push(Y(s.type === "sequenceItem" ? 2 : 0, [O, R(O, t7.map(({ node: l }) => [us(e.originalText, Nt(l)) ? O : "", n()], "endComments"))])), r.push(a), r;
}
function ta(t7, e, n) {
let { node: s } = t7;
switch (s.type) {
case "root": {
let r = un(s), i = !(X(r, ["blockLiteral", "blockFolded"]) && r.chomping === "keep"), o = [];
return t7.each(({ node: a, isFirst: l }) => {
l || o.push(O), o.push(n()), sa(t7) && (i && o.push(O), o.push("..."), z(a) && o.push(" ", n("trailingComment")));
}, "children"), i && o.push(O), o;
}
case "document": {
let r = [];
return ra(t7) && ((s.head.children.length > 0 || s.head.endComments.length > 0) && r.push(n("head")), z(s.head) ? r.push(["---", " ", n(["head", "trailingComment"])]) : r.push("---")), na(s) && r.push(n("body")), R(O, r);
}
case "documentHead":
return R(O, [...t7.map(n, "children"), ...t7.map(n, "endComments")]);
case "documentBody": {
let { children: r, endComments: i } = s, o = "";
if (r.length > 0 && i.length > 0) {
let a = un(s);
if (X(a, ["blockFolded", "blockLiteral"])) a.chomping !== "keep" && (o = [O, O]);
else {
let l = V(0, r, -1);
o = X(l, ["mapping"]) && us(e.originalText, Nt(i[0])) ? [O, O] : O;
}
}
return [R(O, t7.map(n, "children")), o, R(O, t7.map(n, "endComments"))];
}
case "directive":
return ["%", R(" ", [s.name, ...s.parameters])];
case "comment":
return ["#", s.value];
case "alias":
return ["*", s.value];
case "tag":
return e.originalText.slice(s.position.start.offset, s.position.end.offset);
case "anchor":
return ["&", s.value];
case "plain":
return Tt(s.type, e.originalText.slice(s.position.start.offset, s.position.end.offset), e);
case "quoteDouble":
case "quoteSingle": {
let o = e.originalText.slice(s.position.start.offset + 1, s.position.end.offset - 1);
if (s.type === "quoteSingle" && o.includes("\\") || s.type === "quoteDouble" && /\\[^"]/.test(o)) {
let l = s.type === "quoteDouble" ? '"' : "'";
return [l, Tt(s.type, o, e), l];
}
if (o.includes('"')) return ["'", Tt(s.type, s.type === "quoteDouble" ? Jt(0, Jt(0, o, '\\"', '"'), "'", "'".repeat(2)) : o, e), "'"];
if (o.includes("'")) return ['"', Tt(s.type, s.type === "quoteSingle" ? Jt(0, o, "''", "'") : o, e), '"'];
let a = e.singleQuote ? "'" : '"';
return [a, Tt(s.type, o, e), a];
}
case "blockFolded":
case "blockLiteral":
return _r(t7, e, n);
case "mapping":
case "sequence":
return R(O, t7.map(n, "children"));
case "sequenceItem":
return ["- ", Y(2, s.content ? n("content") : "")];
case "mappingKey":
case "mappingValue":
return s.content ? n("content") : "";
case "mappingItem":
case "flowMappingItem":
return Ir(t7, e, n);
case "flowMapping":
return mn(t7, e, n);
case "flowSequence":
return mn(t7, e, n);
case "flowSequenceItem":
return n("content");
default:
throw new ar(s, "YAML");
}
}
function na(t7) {
return t7.body.children.length > 0 || K(t7.body);
}
function sa(t7) {
let e = t7.node;
if (e.documentEndMarker || z(e)) return true;
if (t7.isLast) return false;
let n = t7.next;
return n.head.children.length > 0 || K(n.head);
}
function ra(t7) {
let e = t7.node;
return e.directivesEndMarker || e.head.children.length > 0 || K(e.head) || z(e.head);
}
function Tt(t7, e, n) {
let s = Tr(t7, e, n);
return R(O, s.map((r) => an(R(Se, r))));
}
function Q(t7, e = null) {
"children" in t7 && t7.children.forEach((n) => Q(n, t7)), "anchor" in t7 && t7.anchor && Q(t7.anchor, t7), "tag" in t7 && t7.tag && Q(t7.tag, t7);
"leadingComments" in t7 && t7.leadingComments.forEach((n) => Q(n, t7)), "middleComments" in t7 && t7.middleComments.forEach((n) => Q(n, t7)), "indicatorComment" in t7 && t7.indicatorComment && Q(t7.indicatorComment, t7), "trailingComment" in t7 && t7.trailingComment && Q(t7.trailingComment, t7), "endComments" in t7 && t7.endComments.forEach((n) => Q(n, t7)), Object.defineProperty(t7, "_parent", { value: e, enumerable: false });
}
function ve(t7) {
return `${t7.line}:${t7.column}`;
}
function xr(t7) {
Q(t7);
let e = aa(t7), n = t7.children.slice();
t7.comments.filter((s) => !s._parent).forEach((s) => {
for (; n.length > 1 && s.position.start.line > n[0].position.end.line; ) n.shift();
la(s, e, n[0]);
});
}
function aa(t7) {
let e = Array.from(new Array(t7.position.end.line), () => ({}));
for (let n of t7.comments) e[n.position.start.line - 1].comment = n;
return Mr(e, t7), e;
}
function Mr(t7, e) {
if (e.position.start.offset !== e.position.end.offset) {
if ("leadingComments" in e) {
let { start: n } = e.position, { leadingAttachableNode: s } = t7[n.line - 1];
(!s || n.column < s.position.start.column) && (t7[n.line - 1].leadingAttachableNode = e);
}
if ("trailingComment" in e && e.position.end.column > 1 && e.type !== "document" && e.type !== "documentHead") {
let { end: n } = e.position, { trailingAttachableNode: s } = t7[n.line - 1];
(!s || n.column >= s.position.end.column) && (t7[n.line - 1].trailingAttachableNode = e);
}
if (e.type !== "root" && e.type !== "document" && e.type !== "documentHead" && e.type !== "documentBody") {
let { start: n, end: s } = e.position, r = [s.line].concat(n.line === s.line ? [] : n.line);
for (let i of r) {
let o = t7[i - 1].trailingNode;
(!o || s.column >= o.position.end.column) && (t7[i - 1].trailingNode = e);
}
}
"children" in e && e.children.forEach((n) => {
Mr(t7, n);
});
}
}
function la(t7, e, n) {
let s = t7.position.start.line, { trailingAttachableNode: r } = e[s - 1];
if (r) {
if (r.trailingComment) throw new Error(`Unexpected multiple trailing comment at ${ve(t7.position.start)}`);
Q(t7, r), r.trailingComment = t7;
return;
}
for (let o = s; o >= n.position.start.line; o--) {
let { trailingNode: a } = e[o - 1], l;
if (a) l = a;
else if (o !== s && e[o - 1].comment) l = e[o - 1].comment._parent;
else continue;
if ((l.type === "sequence" || l.type === "mapping") && (l = l.children[0]), l.type === "mappingItem") {
let [c, u] = l.children;
l = $r(c) ? c : u;
}
for (; ; ) {
if (ca(l, t7)) {
Q(t7, l), l.endComments.push(t7);
return;
}
if (!l._parent) break;
l = l._parent;
}
break;
}
for (let o = s + 1; o <= n.position.end.line; o++) {
let { leadingAttachableNode: a } = e[o - 1];
if (a) {
Q(t7, a), a.leadingComments.push(t7);
return;
}
}
let i = n.children[1];
Q(t7, i), i.endComments.push(t7);
}
function ca(t7, e) {
if (t7.position.start.offset < e.position.start.offset && t7.position.end.offset > e.position.end.offset) switch (t7.type) {
case "flowMapping":
case "flowSequence":
return t7.children.length === 0 || e.position.start.line > t7.children[t7.children.length - 1].position.end.line;
}
if (e.position.end.offset < t7.position.end.offset) return false;
switch (t7.type) {
case "sequenceItem":
return e.position.start.column > t7.position.start.column;
case "mappingKey":
case "mappingValue":
return e.position.start.column > t7._parent.position.start.column && (t7.children.length === 0 || t7.children.length === 1 && t7.children[0].type !== "blockFolded" && t7.children[0].type !== "blockLiteral") && (t7.type === "mappingValue" || $r(t7));
default:
return false;
}
}
function $r(t7) {
return t7.position.start !== t7.position.end && (t7.children.length === 0 || t7.position.start.offset !== t7.children[0].position.start.offset);
}
function Br(t7, e, n) {
return { type: "root", position: t7, children: e, comments: n };
}
function Z(t7, e) {
return { start: t7, end: e };
}
function Rr(t7) {
return { start: t7, end: t7 };
}
function qr(t7, e) {
return { type: "comment", position: e.transformRange([t7.offset, t7.offset + t7.source.length]), value: t7.source.slice(1) };
}
function Fr(t7, e) {
return { type: "anchor", position: t7, value: e };
}
function Kr(t7, e, n) {
return { anchor: e, tag: t7, middleComments: n };
}
function Yr(t7, e) {
return { type: "tag", position: t7, value: e };
}
function Ur(t7, e, n) {
let s = [], r = null, i = null, o = null;
for (let a of e) {
let l = [a.offset, a.offset + a.source.length];
switch (a.type) {
case "tag":
{
r ?? (r = l);
let c = t7.tag ?? a.source.slice(a.source.startsWith("!!") ? 2 : 1);
c === "!" && (c = "tag:yaml.org,2002:str"), i = Yr(n.transformRange(l), c);
}
break;
case "anchor":
r ?? (r = l), o = Fr(n.transformRange(l), t7.anchor);
break;
case "comment": {
let c = n.transformComment(a);
r && r[0] <= l[0] && l[1] <= t7.range[0] && s.push(c);
break;
}
default:
throw new Error(`Unexpected content property token type: ${a.type}`);
}
}
return Kr(i, o, s);
}
function jr(t7, e, n) {
return { type: "alias", position: t7, leadingComments: [], trailingComment: null, ...e, value: n };
}
function* q(...t7) {
for (let e of t7) if (e) for (let n of e) fa(n) || (yield n);
}
function fa(t7) {
return t7.type === "space" || t7.type === "newline";
}
function Ee(t7) {
return t7.type === "comment" || t7.type === "tag" || t7.type === "anchor";
}
function D(t7, e) {
let n = [];
for (let s of q(t7)) s.type === "comment" ? e.transformComment(s) : n.push(s);
return n;
}
function Vr(t7, e, n) {
let s = t7.srcToken;
for (let r of D(s.end, e)) throw new Error(`Unexpected token type in alias end: ${r.type}`);
return jr(e.transformRange(t7.range), e.transformContentProperties(t7, n.tokens), t7.source);
}
function Gr(t7) {
return { ...t7, type: "blockFolded" };
}
function Qr(t7, e, n, s, r, i) {
return { type: "blockValue", position: t7, leadingComments: [], ...e, chomping: n, indent: s, value: r, indicatorComment: i };
}
function gn(t7, e, n, s) {
let r = null, i = null;
for (let a of q(e.props)) if (a.type === "comment") i = n.transformComment(a);
else if (a.type === "block-scalar-header") r = a;
else throw new Error(`Unexpected token type in block value end: ${a.type}`);
if (!r) throw new Error("Expected block scalar header token");
let o = ua(r.source);
return Qr(n.transformRange(t7.range), n.transformContentProperties(t7, s.tokens), o.chomping, o.indent, t7.source, i);
}
function ua(t7) {
let e = /([+-]?)(\d*)([+-]?)$/u.exec(t7), n = null, s = "clip";
if (e) {
n = e[2] ? Number(e[2]) : null;
let r = e[3] || e[1];
s = r === "+" ? "keep" : r === "-" ? "strip" : "clip";
}
return { chomping: s, indent: n };
}
function Hr(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "block-scalar") throw new Error("Expected block scalar srcToken");
return Gr(gn(t7, s, e, n));
}
function Jr(t7) {
return { ...t7, type: "blockLiteral" };
}
function Wr(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "block-scalar") throw new Error("Expected block scalar srcToken");
return Jr(gn(t7, s, e, n));
}
function yn(t7, e, n) {
return { type: "flowCollection", position: t7, leadingComments: [], trailingComment: null, endComments: [], ...e, children: n };
}
function Xr(t7, e, n) {
return { ...yn(t7, e, n), type: "flowMapping" };
}
function _t(t7, e, n) {
return { type: "flowMappingItem", position: t7, leadingComments: [], children: [e, n] };
}
function zr(t7, e) {
return { type: "mappingKey", position: t7, trailingComment: null, endComments: [], children: e ? [e] : [] };
}
function ws(t7, e) {
return { type: "mappingValue", position: t7, leadingComments: [], trailingComment: null, endComments: [], children: e ? [e] : [] };
}
function Ce(t7, e, n, s) {
var r;
let i = [], o = null;
for (let h of q(e.start)) {
if (Ee(h)) {
i.push(h);
continue;
}
if (h.type === "explicit-key-ind") {
o = h;
continue;
}
if (h.type === "comma") continue;
throw new Error(`Unexpected token type in collection item start: ${h.type}`);
}
let a = [], l = null;
for (let h of q(e.sep)) {
if (Ee(h)) {
a.push(h);
continue;
}
if (h.type === "map-value-ind") {
l = h;
continue;
}
throw new Error(`Unexpected token type in collection item sep: ${h.type}`);
}
let c = o?.offset ?? ((r = e.key) === null || r === void 0 ? void 0 : r.offset) ?? l?.offset ?? e.value.offset, u = [c, e.key ? t7.key.range[1] : o ? o.offset + o.source.length : c], f = null;
if (t7.value) {
var p;
let h = l?.offset ?? ((p = e.value) === null || p === void 0 ? void 0 : p.offset) ?? t7.value.range[0];
f = [h, e.value ? t7.value.range[1] : l ? l.offset + l.source.length : h];
}
return pa(t7, n, s, { range: u, props: { tokens: i } }, { range: f, props: { tokens: a } });
}
function pa(t7, e, n, s, r) {
let i = null;
It(t7.key, s.props) ? D(s.props.tokens, e) : i = e.transformNode(t7.key, s.props);
let o = null;
It(t7.value, r.props) ? D(r.props.tokens, e) : o = e.transformNode(t7.value, r.props);
let a = zr(e.transformRange([s.range ? s.range[0] : i.position.start.offset, i ? i.position.end.offset : s.range[1]]), i), l = o || r.range ? ws(e.transformRange([r.range ? r.range[0] : o.position.start.offset, o ? o.position.end.offset : r.range[0] + 1]), o) : null;
return n(Z(a.position.start, l ? l.position.end : a.position.end), a, l || ws(Rr(a.position.end), null));
}
function Zr(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "flow-collection") throw new Error("Expected flow-collection CST node for flow map");
let r = t7.items.map((o, a) => {
let l = s.items[a];
return Ce(o, l, e, _t);
});
if (t7.items.length < s.items.length) for (let o = t7.items.length; o < s.items.length; o++) {
let a = s.items[o];
for (let l of D(a.start, e)) {
if (l.type === "comma") continue;
throw new Error(`Unexpected token type in collection item start: ${l.type}`);
}
}
let i = null;
for (let o of D(s.end, e)) {
if (o.type === "flow-map-end") {
i = o;
continue;
}
throw new Error(`Unexpected token type in flow map end: ${o.type}`);
}
if (!i) throw new Error("Expected flow-map-end token");
return Xr(e.transformRange([s.start.offset, i.offset + i.source.length]), e.transformContentProperties(t7, n.tokens), r);
}
function ei(t7, e, n) {
return { ...yn(t7, e, n), type: "flowSequence" };
}
function ti(t7, e) {
return { type: "flowSequenceItem", position: t7, children: [e] };
}
function ie(t7) {
return t7[t7.length - 1];
}
function I(t7) {
if (t7 && typeof t7 == "object") switch (t7[G]) {
case oe:
case Ne:
return true;
}
return false;
}
function _(t7) {
if (t7 && typeof t7 == "object") switch (t7[G]) {
case wn:
case oe:
case ee:
case Ne:
return true;
}
return false;
}
function ae(t7, e) {
let n = si(e);
ne(t7) ? Ze(null, t7.contents, n, Object.freeze([t7])) === me && (t7.contents = null) : Ze(null, t7, n, Object.freeze([]));
}
function Ze(t7, e, n, s) {
let r = ri(t7, e, n, s);
if (_(r) || T(r)) return ii(t7, s, r), Ze(t7, r, n, s);
if (typeof r != "symbol") {
if (I(e)) {
s = Object.freeze(s.concat(e));
for (let i = 0; i < e.items.length; ++i) {
let o = Ze(i, e.items[i], n, s);
if (typeof o == "number") i = o - 1;
else {
if (o === W) return W;
o === me && (e.items.splice(i, 1), i -= 1);
}
}
} else if (T(e)) {
s = Object.freeze(s.concat(e));
let i = Ze("key", e.key, n, s);
if (i === W) return W;
i === me && (e.key = null);
let o = Ze("value", e.value, n, s);
if (o === W) return W;
o === me && (e.value = null);
}
}
return r;
}
async function Lt(t7, e) {
let n = si(e);
ne(t7) ? await et(null, t7.contents, n, Object.freeze([t7])) === me && (t7.contents = null) : await et(null, t7, n, Object.freeze([]));
}
async function et(t7, e, n, s) {
let r = await ri(t7, e, n, s);
if (_(r) || T(r)) return ii(t7, s, r), et(t7, r, n, s);
if (typeof r != "symbol") {
if (I(e)) {
s = Object.freeze(s.concat(e));
for (let i = 0; i < e.items.length; ++i) {
let o = await et(i, e.items[i], n, s);
if (typeof o == "number") i = o - 1;
else {
if (o === W) return W;
o === me && (e.items.splice(i, 1), i -= 1);
}
}
} else if (T(e)) {
s = Object.freeze(s.concat(e));
let i = await et("key", e.key, n, s);
if (i === W) return W;
i === me && (e.key = null);
let o = await et("value", e.value, n, s);
if (o === W) return W;
o === me && (e.value = null);
}
}
return r;
}
function si(t7) {
return typeof t7 == "object" && (t7.Collection || t7.Node || t7.Value) ? Object.assign({ Alias: t7.Node, Map: t7.Node, Scalar: t7.Node, Seq: t7.Node }, t7.Value && { Map: t7.Value, Scalar: t7.Value, Seq: t7.Value }, t7.Collection && { Map: t7.Collection, Seq: t7.Collection }, t7) : t7;
}
function ri(t7, e, n, s) {
if (typeof n == "function") return n(t7, e, s);
if (U(e)) return n.Map?.(t7, e, s);
if (J(e)) return n.Seq?.(t7, e, s);
if (T(e)) return n.Pair?.(t7, e, s);
if (C(e)) return n.Scalar?.(t7, e, s);
if (H(e)) return n.Alias?.(t7, e, s);
}
function ii(t7, e, n) {
let s = e[e.length - 1];
if (I(s)) s.items[t7] = n;
else if (T(s)) t7 === "key" ? s.key = n : s.value = n;
else if (ne(s)) s.contents = n;
else {
let r = H(s) ? "alias" : "scalar";
throw new Error(`Cannot replace node with ${r} parent`);
}
}
function Sn(t7) {
if (/[\x00-\x19\s,[\]{}]/.test(t7)) {
let n = `Anchor must not contain whitespace or control characters: ${JSON.stringify(t7)}`;
throw new Error(n);
}
return true;
}
function ks(t7) {
let e = /* @__PURE__ */ new Set();
return ae(t7, { Value(n, s) {
s.anchor && e.add(s.anchor);
} }), e;
}
function Ss(t7, e) {
for (let n = 1; ; ++n) {
let s = `${t7}${n}`;
if (!e.has(s)) return s;
}
}
function oi(t7, e) {
let n = [], s = /* @__PURE__ */ new Map(), r = null;
return { onAnchor: (i) => {
n.push(i), r ?? (r = ks(t7));
let o = Ss(e, r);
return r.add(o), o;
}, setAnchors: () => {
for (let i of n) {
let o = s.get(i);
if (typeof o == "object" && o.anchor && (C(o.node) || I(o.node))) o.node.anchor = o.anchor;
else {
let a = new Error("Failed to resolve repeated object (this should not happen)");
throw a.source = i, a;
}
}
}, sourceObjects: s };
}
function De(t7, e, n, s) {
if (s && typeof s == "object") if (Array.isArray(s)) for (let r = 0, i = s.length; r < i; ++r) {
let o = s[r], a = De(t7, s, String(r), o);
a === void 0 ? delete s[r] : a !== o && (s[r] = a);
}
else if (s instanceof Map) for (let r of Array.from(s.keys())) {
let i = s.get(r), o = De(t7, s, r, i);
o === void 0 ? s.delete(r) : o !== i && s.set(r, o);
}
else if (s instanceof Set) for (let r of Array.from(s)) {
let i = De(t7, s, r, r);
i === void 0 ? s.delete(r) : i !== r && (s.delete(r), s.add(i));
}
else for (let [r, i] of Object.entries(s)) {
let o = De(t7, s, r, i);
o === void 0 ? delete s[r] : o !== i && (s[r] = o);
}
return t7.call(e, n, s);
}
function B(t7, e, n) {
if (Array.isArray(t7)) return t7.map((s, r) => B(s, String(r), n));
if (t7 && typeof t7.toJSON == "function") {
if (!n || !kn(t7)) return t7.toJSON(e, n);
let s = { aliasCount: 0, count: 1, res: void 0 };
n.anchors.set(t7, s), n.onCreate = (i) => {
s.res = i, delete n.onCreate;
};
let r = t7.toJSON(e, n);
return n.onCreate && n.onCreate(r), r;
}
return typeof t7 == "bigint" && !n?.keep ? Number(t7) : t7;
}
function En(t7, e, n) {
if (H(e)) {
let s = e.resolve(t7), r = n && s && n.get(s);
return r ? r.count * r.aliasCount : 0;
} else if (I(e)) {
let s = 0;
for (let r of e.items) {
let i = En(t7, r, n);
i > s && (s = i);
}
return s;
} else if (T(e)) {
let s = En(t7, e.key, n), r = En(t7, e.value, n);
return Math.max(s, r);
}
return 1;
}
function ga(t7, e, n) {
if (e) {
let s = n.filter((i) => i.tag === e), r = s.find((i) => !i.format) ?? s[0];
if (!r) throw new Error(`Tag ${e} not found`);
return r;
}
return n.find((s) => s.identify?.(t7) && !s.format);
}
function Ae(t7, e, n) {
if (ne(t7) && (t7 = t7.contents), _(t7)) return t7;
if (T(t7)) {
let f = n.schema[oe].createNode?.(n.schema, null, n);
return f.items.push(t7), f;
}
(t7 instanceof String || t7 instanceof Number || t7 instanceof Boolean || typeof BigInt < "u" && t7 instanceof BigInt) && (t7 = t7.valueOf());
let { aliasDuplicateObjects: s, onAnchor: r, onTagObj: i, schema: o, sourceObjects: a } = n, l;
if (s && t7 && typeof t7 == "object") {
if (l = a.get(t7), l) return l.anchor ?? (l.anchor = r(t7)), new de(l.anchor);
l = { anchor: null, node: null }, a.set(t7, l);
}
e?.startsWith("!!") && (e = da + e.slice(2));
let c = ga(t7, e, o.tags);
if (!c) {
if (t7 && typeof t7.toJSON == "function" && (t7 = t7.toJSON()), !t7 || typeof t7 != "object") {
let f = new y(t7);
return l && (l.node = f), f;
}
c = t7 instanceof Map ? o[oe] : Symbol.iterator in Object(t7) ? o[Ne] : o[oe];
}
i && (i(c), delete n.onTagObj);
let u = c?.createNode ? c.createNode(n.schema, t7, n) : typeof c?.nodeClass?.from == "function" ? c.nodeClass.from(n.schema, t7, n) : new y(t7);
return e ? u.tag = e : c.default || (u.tag = c.tag), l && (l.node = u), u;
}
function Pt(t7, e, n) {
let s = n;
for (let r = e.length - 1; r >= 0; --r) {
let i = e[r];
if (typeof i == "number" && Number.isInteger(i) && i >= 0) {
let o = [];
o[i] = s, s = o;
} else s = /* @__PURE__ */ new Map([[i, s]]);
}
return Ae(s, void 0, { aliasDuplicateObjects: false, keepUndefined: false, onAnchor: () => {
throw new Error("This should not happen, please report a bug.");
}, schema: t7, sourceObjects: /* @__PURE__ */ new Map() });
}
function se(t7, e) {
return /^\n+$/.test(t7) ? t7.substring(1) : e ? t7.replace(/^(?! *$)/gm, e) : t7;
}
function Dt(t7, e, n = "flow", { indentAtStart: s, lineWidth: r = 80, minContentWidth: i = 20, onFold: o, onOverflow: a } = {}) {
if (!r || r < 0) return t7;
r < i && (i = 0);
let l = Math.max(1 + i, 1 + r - e.length);
if (t7.length <= l) return t7;
let c = [], u = {}, f = r - e.length;
typeof s == "number" && (s > r - Math.max(2, i) ? c.push(0) : f = r - s);
let p, h, g = false, m = -1, d = -1, b = -1;
n === Nn && (m = li(t7, m, e.length), m !== -1 && (f = m + l));
for (let S; S = t7[m += 1]; ) {
if (n === vt && S === "\\") {
switch (d = m, t7[m + 1]) {
case "x":
m += 3;
break;
case "u":
m += 5;
break;
case "U":
m += 9;
break;
default:
m += 1;
}
b = m;
}
if (S === `
`) n === Nn && (m = li(t7, m, e.length)), f = m + e.length + l, p = void 0;
else {
if (S === " " && h && h !== " " && h !== `
` && h !== " ") {
let E = t7[m + 1];
E && E !== " " && E !== `
` && E !== " " && (p = m);
}
if (m >= f) if (p) c.push(p), f = p + l, p = void 0;
else if (n === vt) {
for (; h === " " || h === " "; ) h = S, S = t7[m += 1], g = true;
let E = m > b + 1 ? m - 2 : d - 1;
if (u[E]) return t7;
c.push(E), u[E] = true, f = E + l, p = void 0;
} else g = true;
}
h = S;
}
if (g && a && a(), c.length === 0) return t7;
o && o();
let k = t7.slice(0, c[0]);
for (let S = 0; S < c.length; ++S) {
let E = c[S], N = c[S + 1] || t7.length;
E === 0 ? k = `
${e}${t7.slice(0, N)}` : (n === vt && u[E] && (k += `${t7[E]}\\`), k += `
${e}${t7.slice(E + 1, N)}`);
}
return k;
}
function li(t7, e, n) {
let s = e, r = e + 1, i = t7[r];
for (; i === " " || i === " "; ) if (e < r + n) i = t7[++e];
else {
do
i = t7[++e];
while (i && i !== `
`);
s = e, r = e + 1, i = t7[r];
}
return s;
}
function ya(t7, e, n) {
if (!e || e < 0) return false;
let s = e - n, r = t7.length;
if (r <= s) return false;
for (let i = 0, o = 0; i < r; ++i) if (t7[i] === `
`) {
if (i - o > s) return true;
if (o = i + 1, r - o <= s) return false;
}
return true;
}
function xt(t7, e) {
let n = JSON.stringify(t7);
if (e.options.doubleQuotedAsJSON) return n;
let { implicitKey: s } = e, r = e.options.doubleQuotedMinMultiLineLength, i = e.indent || (On(t7) ? " " : ""), o = "", a = 0;
for (let l = 0, c = n[l]; c; c = n[++l]) if (c === " " && n[l + 1] === "\\" && n[l + 2] === "n" && (o += n.slice(a, l) + "\\ ", l += 1, a = l, c = "\\"), c === "\\") switch (n[l + 1]) {
case "u":
{
o += n.slice(a, l);
let u = n.substr(l + 2, 4);
switch (u) {
case "0000":
o += "\\0";
break;
case "0007":
o += "\\a";
break;
case "000b":
o += "\\v";
break;
case "001b":
o += "\\e";
break;
case "0085":
o += "\\N";
break;
case "00a0":
o += "\\_";
break;
case "2028":
o += "\\L";
break;
case "2029":
o += "\\P";
break;
default:
u.substr(0, 2) === "00" ? o += "\\x" + u.substr(2) : o += n.substr(l, 6);
}
l += 5, a = l + 1;
}
break;
case "n":
if (s || n[l + 2] === '"' || n.length < r) l += 1;
else {
for (o += n.slice(a, l) + `
`; n[l + 2] === "\\" && n[l + 3] === "n" && n[l + 4] !== '"'; ) o += `
`, l += 2;
o += i, n[l + 2] === " " && (o += "\\"), l += 1, a = l + 1;
}
break;
default:
l += 1;
}
return o = a ? o + n.slice(a) : n, s ? o : Dt(o, i, vt, Tn(e, false));
}
function Cs(t7, e) {
if (e.options.singleQuote === false || e.implicitKey && t7.includes(`
`) || /[ \t]\n|\n[ \t]/.test(t7)) return xt(t7, e);
let n = e.indent || (On(t7) ? " " : ""), s = "'" + t7.replace(/'/g, "''").replace(/\n+/g, `$&
${n}`) + "'";
return e.implicitKey ? s : Dt(s, n, Es, Tn(e, false));
}
function st(t7, e) {
let { singleQuote: n } = e.options, s;
if (n === false) s = xt;
else {
let r = t7.includes('"'), i = t7.includes("'");
r && !i ? s = Cs : i && !r ? s = xt : s = n ? Cs : xt;
}
return s(t7, e);
}
function An({ comment: t7, type: e, value: n }, s, r, i) {
let { blockQuote: o, commentString: a, lineWidth: l } = s.options;
if (!o || /\n[\t ]+$/.test(n)) return st(n, s);
let c = s.indent || (s.forceBlockIndent || On(n) ? " " : ""), u = o === "literal" ? true : o === "folded" || e === y.BLOCK_FOLDED ? false : e === y.BLOCK_LITERAL ? true : !ya(n, l, c.length);
if (!n) return u ? `|
` : `>
`;
let f, p;
for (p = n.length; p > 0; --p) {
let N = n[p - 1];
if (N !== `
` && N !== " " && N !== " ") break;
}
let h = n.substring(p), g = h.indexOf(`
`);
g === -1 ? f = "-" : n === h || g !== h.length - 1 ? (f = "+", i && i()) : f = "", h && (n = n.slice(0, -h.length), h[h.length - 1] === `
` && (h = h.slice(0, -1)), h = h.replace(Ns, `$&${c}`));
let m = false, d, b = -1;
for (d = 0; d < n.length; ++d) {
let N = n[d];
if (N === " ") m = true;
else if (N === `
`) b = d;
else break;
}
let k = n.substring(0, b < d ? b + 1 : d);
k && (n = n.substring(k.length), k = k.replace(/\n+/g, `$&${c}`));
let E = (m ? c ? "2" : "1" : "") + f;
if (t7 && (E += " " + a(t7.replace(/ ?[\r\n]+/g, " ")), r && r()), !u) {
let N = n.replace(/\n+/g, `
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${c}`), A = false, L = Tn(s, true);
o !== "folded" && e !== y.BLOCK_FOLDED && (L.onOverflow = () => {
A = true;
});
let w = Dt(`${k}${N}${h}`, c, Nn, L);
if (!A) return `>${E}
${c}${w}`;
}
return n = n.replace(/\n+/g, `$&${c}`), `|${E}
${c}${k}${n}${h}`;
}
function wa(t7, e, n, s) {
let { type: r, value: i } = t7, { actualString: o, implicitKey: a, indent: l, indentStep: c, inFlow: u } = e;
if (a && i.includes(`
`) || u && /[[\]{},]/.test(i)) return st(i, e);
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i)) return a || u || !i.includes(`
`) ? st(i, e) : An(t7, e, n, s);
if (!a && !u && r !== y.PLAIN && i.includes(`
`)) return An(t7, e, n, s);
if (On(i)) {
if (l === "") return e.forceBlockIndent = true, An(t7, e, n, s);
if (a && l === c) return st(i, e);
}
let f = i.replace(/\n+/g, `$&
${l}`);
if (o) {
let p = (m) => m.default && m.tag !== "tag:yaml.org,2002:str" && m.test?.test(f), { compat: h, tags: g } = e.doc.schema;
if (g.some(p) || h?.some(p)) return st(i, e);
}
return a ? f : Dt(f, l, Es, Tn(e, false));
}
function Te(t7, e, n, s) {
let { implicitKey: r, inFlow: i } = e, o = typeof t7.value == "string" ? t7 : Object.assign({}, t7, { value: String(t7.value) }), { type: a } = t7;
a !== y.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (a = y.QUOTE_DOUBLE);
let l = (u) => {
switch (u) {
case y.BLOCK_FOLDED:
case y.BLOCK_LITERAL:
return r || i ? st(o.value, e) : An(o, e, n, s);
case y.QUOTE_DOUBLE:
return xt(o.value, e);
case y.QUOTE_SINGLE:
return Cs(o.value, e);
case y.PLAIN:
return wa(o, e, n, s);
default:
return null;
}
}, c = l(a);
if (c === null) {
let { defaultKeyType: u, defaultStringType: f } = e.options, p = r && u || f;
if (c = l(p), c === null) throw new Error(`Unsupported default string type ${p}`);
}
return c;
}
function _n(t7, e) {
let n = Object.assign({ blockQuote: true, commentString: ai, defaultKeyType: null, defaultStringType: "PLAIN", directives: null, doubleQuotedAsJSON: false, doubleQuotedMinMultiLineLength: 40, falseStr: "false", flowCollectionPadding: true, indentSeq: true, lineWidth: 80, minContentWidth: 20, nullStr: "null", simpleKeys: false, singleQuote: null, trailingComma: false, trueStr: "true", verifyAliasOrder: true }, t7.schema.toStringOptions, e), s;
switch (n.collectionStyle) {
case "block":
s = false;
break;
case "flow":
s = true;
break;
default:
s = null;
}
return { anchors: /* @__PURE__ */ new Set(), doc: t7, flowCollectionPadding: n.flowCollectionPadding ? " " : "", indent: "", indentStep: typeof n.indent == "number" ? " ".repeat(n.indent) : " ", inFlow: s, options: n };
}
function ba(t7, e) {
if (e.tag) {
let r = t7.filter((i) => i.tag === e.tag);
if (r.length > 0) return r.find((i) => i.format === e.format) ?? r[0];
}
let n, s;
if (C(e)) {
s = e.value;
let r = t7.filter((i) => i.identify?.(s));
if (r.length > 1) {
let i = r.filter((o) => o.test);
i.length > 0 && (r = i);
}
n = r.find((i) => i.format === e.format) ?? r.find((i) => !i.format);
} else s = e, n = t7.find((r) => r.nodeClass && s instanceof r.nodeClass);
if (!n) {
let r = s?.constructor?.name ?? (s === null ? "null" : typeof s);
throw new Error(`Tag not resolved for ${r} value`);
}
return n;
}
function ka(t7, e, { anchors: n, doc: s }) {
if (!s.directives) return "";
let r = [], i = (C(t7) || I(t7)) && t7.anchor;
i && Sn(i) && (n.add(i), r.push(`&${i}`));
let o = t7.tag ?? (e.default ? null : e.tag);
return o && r.push(s.directives.tagString(o)), r.join(" ");
}
function Oe(t7, e, n, s) {
if (T(t7)) return t7.toString(e, n, s);
if (H(t7)) {
if (e.doc.directives) return t7.toString(e);
if (e.resolvedAliases?.has(t7)) throw new TypeError("Cannot stringify circular structure without alias nodes");
e.resolvedAliases ? e.resolvedAliases.add(t7) : e.resolvedAliases = /* @__PURE__ */ new Set([t7]), t7 = t7.resolve(e.doc);
}
let r, i = _(t7) ? t7 : e.doc.createNode(t7, { onTagObj: (l) => r = l });
r ?? (r = ba(e.doc.schema.tags, i));
let o = ka(i, r, e);
o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
let a = typeof r.stringify == "function" ? r.stringify(i, e, n, s) : C(i) ? Te(i, e, n, s) : i.toString(e, n, s);
return o ? C(i) || a[0] === "{" || a[0] === "[" ? `${o} ${a}` : `${o}
${e.indent}${a}` : a;
}
function ci({ key: t7, value: e }, n, s, r) {
let { allNullValues: i, doc: o, indent: a, indentStep: l, options: { commentString: c, indentSeq: u, simpleKeys: f } } = n, p = _(t7) && t7.comment || null;
if (f) {
if (p) throw new Error("With simple keys, key nodes cannot have comments");
if (I(t7) || !_(t7) && typeof t7 == "object") {
let L = "With simple keys, collection cannot be used as a key value";
throw new Error(L);
}
}
let h = !f && (!t7 || p && e == null && !n.inFlow || I(t7) || (C(t7) ? t7.type === y.BLOCK_FOLDED || t7.type === y.BLOCK_LITERAL : typeof t7 == "object"));
n = Object.assign({}, n, { allNullValues: false, implicitKey: !h && (f || !i), indent: a + l });
let g = false, m = false, d = Oe(t7, n, () => g = true, () => m = true);
if (!h && !n.inFlow && d.length > 1024) {
if (f) throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
h = true;
}
if (n.inFlow) {
if (i || e == null) return g && s && s(), d === "" ? "?" : h ? `? ${d}` : d;
} else if (i && !f || e == null && h) return d = `? ${d}`, p && !g ? d += ge(d, n.indent, c(p)) : m && r && r(), d;
g && (p = null), h ? (p && (d += ge(d, n.indent, c(p))), d = `? ${d}
${a}:`) : (d = `${d}:`, p && (d += ge(d, n.indent, c(p))));
let b, k, S;
_(e) ? (b = !!e.spaceBefore, k = e.commentBefore, S = e.comment) : (b = false, k = null, S = null, e && typeof e == "object" && (e = o.createNode(e))), n.implicitKey = false, !h && !p && C(e) && (n.indentAtStart = d.length + 1), m = false, !u && l.length >= 2 && !n.inFlow && !h && J(e) && !e.flow && !e.tag && !e.anchor && (n.indent = n.indent.substring(2));
let E = false, N = Oe(e, n, () => E = true, () => m = true), A = " ";
if (p || b || k) {
if (A = b ? `
` : "", k) {
let L = c(k);
A += `
${se(L, n.indent)}`;
}
N === "" && !n.inFlow ? A === `
` && S && (A = `
`) : A += `
${n.indent}`;
} else if (!h && I(e)) {
let L = N[0], w = N.indexOf(`
`), M = w !== -1, Le = n.inFlow ?? e.flow ?? e.items.length === 0;
if (M || !Le) {
let Ye = false;
if (M && (L === "&" || L === "!")) {
let $ = N.indexOf(" ");
L === "&" && $ !== -1 && $ < w && N[$ + 1] === "!" && ($ = N.indexOf(" ", $ + 1)), ($ === -1 || w < $) && (Ye = true);
}
Ye || (A = `
${n.indent}`);
}
} else (N === "" || N[0] === `
`) && (A = "");
return d += A + N, n.inFlow ? E && s && s() : S && !E ? d += ge(d, n.indent, c(S)) : m && r && r(), d;
}
function In(t7, e) {
(t7 === "debug" || t7 === "warn") && console.warn(e);
}
function Ts(t7, e, n) {
let s = ui(t7, n);
if (J(s)) for (let r of s.items) As(t7, e, r);
else if (Array.isArray(s)) for (let r of s) As(t7, e, r);
else As(t7, e, s);
}
function As(t7, e, n) {
let s = ui(t7, n);
if (!U(s)) throw new Error("Merge sources must be maps or map aliases");
let r = s.toJSON(null, t7, Map);
for (let [i, o] of r) e instanceof Map ? e.has(i) || e.set(i, o) : e instanceof Set ? e.add(i) : Object.prototype.hasOwnProperty.call(e, i) || Object.defineProperty(e, i, { value: o, writable: true, enumerable: true, configurable: true });
return e;
}
function ui(t7, e) {
return t7 && H(e) ? e.resolve(t7.doc, t7) : e;
}
function Pn(t7, e, { key: n, value: s }) {
if (_(n) && n.addToJSMap) n.addToJSMap(t7, e, s);
else if (fi(t7, n)) Ts(t7, e, s);
else {
let r = B(n, "", t7);
if (e instanceof Map) e.set(r, B(s, r, t7));
else if (e instanceof Set) e.add(r);
else {
let i = Sa(n, r, t7), o = B(s, i, t7);
i in e ? Object.defineProperty(e, i, { value: o, writable: true, enumerable: true, configurable: true }) : e[i] = o;
}
}
return e;
}
function Sa(t7, e, n) {
if (e === null) return "";
if (typeof e != "object") return String(e);
if (_(t7) && n?.doc) {
let s = _n(n.doc, {});
s.anchors = /* @__PURE__ */ new Set();
for (let i of n.anchors.keys()) s.anchors.add(i.anchor);
s.inFlow = true, s.inStringifyKey = true;
let r = t7.toString(s);
if (!n.mapKeyWarned) {
let i = JSON.stringify(r);
i.length > 40 && (i = i.substring(0, 36) + '..."'), In(n.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`), n.mapKeyWarned = true;
}
return r;
}
return JSON.stringify(e);
}
function rt(t7, e, n) {
let s = Ae(t7, void 0, n), r = Ae(e, void 0, n);
return new v(s, r);
}
function Dn(t7, e, n) {
return (e.inFlow ?? t7.flow ? Ca : Ea)(t7, e, n);
}
function Ea({ comment: t7, items: e }, n, { blockItemPrefix: s, flowChars: r, itemIndent: i, onChompKeep: o, onComment: a }) {
let { indent: l, options: { commentString: c } } = n, u = Object.assign({}, n, { indent: i, type: null }), f = false, p = [];
for (let g = 0; g < e.length; ++g) {
let m = e[g], d = null;
if (_(m)) !f && m.spaceBefore && p.push(""), vn(n, p, m.commentBefore, f), m.comment && (d = m.comment);
else if (T(m)) {
let k = _(m.key) ? m.key : null;
k && (!f && k.spaceBefore && p.push(""), vn(n, p, k.commentBefore, f));
}
f = false;
let b = Oe(m, u, () => d = null, () => f = true);
d && (b += ge(b, i, c(d))), f && d && (f = false), p.push(s + b);
}
let h;
if (p.length === 0) h = r.start + r.end;
else {
h = p[0];
for (let g = 1; g < p.length; ++g) {
let m = p[g];
h += m ? `
${l}${m}` : `
`;
}
}
return t7 ? (h += `
` + se(c(t7), l), a && a()) : f && o && o(), h;
}
function Ca({ items: t7 }, e, { flowChars: n, itemIndent: s }) {
let { indent: r, indentStep: i, flowCollectionPadding: o, options: { commentString: a } } = e;
s += i;
let l = Object.assign({}, e, { indent: s, inFlow: true, type: null }), c = false, u = 0, f = [];
for (let g = 0; g < t7.length; ++g) {
let m = t7[g], d = null;
if (_(m)) m.spaceBefore && f.push(""), vn(e, f, m.commentBefore, false), m.comment && (d = m.comment);
else if (T(m)) {
let k = _(m.key) ? m.key : null;
k && (k.spaceBefore && f.push(""), vn(e, f, k.commentBefore, false), k.comment && (c = true));
let S = _(m.value) ? m.value : null;
S ? (S.comment && (d = S.comment), S.commentBefore && (c = true)) : m.value == null && k?.comment && (d = k.comment);
}
d && (c = true);
let b = Oe(m, l, () => d = null);
c || (c = f.length > u || b.includes(`
`)), g < t7.length - 1 ? b += "," : e.options.trailingComma && (e.options.lineWidth > 0 && (c || (c = f.reduce((k, S) => k + S.length + 2, 2) + (b.length + 2) > e.options.lineWidth)), c && (b += ",")), d && (b += ge(b, s, a(d))), f.push(b), u = f.length;
}
let { start: p, end: h } = n;
if (f.length === 0) return p + h;
if (!c) {
let g = f.reduce((m, d) => m + d.length + 2, 2);
c = e.options.lineWidth > 0 && g > e.options.lineWidth;
}
if (c) {
let g = p;
for (let m of f) g += m ? `
${i}${r}${m}` : `
`;
return `${g}
${r}${h}`;
} else return `${p}${o}${f.join(" ")}${o}${h}`;
}
function vn({ indent: t7, options: { commentString: e } }, n, s, r) {
if (s && r && (s = s.replace(/^\n+/, "")), s) {
let i = se(e(s), t7);
n.push(i.trimStart());
}
}
function Me(t7, e) {
let n = C(e) ? e.value : e;
for (let s of t7) if (T(s) && (s.key === e || s.key === n || C(s.key) && s.key.value === n)) return s;
}
function xn(t7) {
let e = C(t7) ? t7.value : t7;
return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
}
function j({ format: t7, minFractionDigits: e, tag: n, value: s }) {
if (typeof s == "bigint") return String(s);
let r = typeof s == "number" ? s : Number(s);
if (!isFinite(r)) return isNaN(r) ? ".nan" : r < 0 ? "-.inf" : ".inf";
let i = Object.is(s, -0) ? "-0" : JSON.stringify(s);
if (!t7 && e && (!n || n === "tag:yaml.org,2002:float") && /^-?\d/.test(i) && !i.includes("e")) {
let o = i.indexOf(".");
o < 0 && (o = i.length, i += ".");
let a = e - (i.length - o - 1);
for (; a-- > 0; ) i += "0";
}
return i;
}
function pi(t7, e, n) {
let { value: s } = t7;
return Rn(s) && s >= 0 ? n + s.toString(e) : j(t7);
}
function hi(t7) {
return typeof t7 == "bigint" || Number.isInteger(t7);
}
function _s(t7, e) {
if (J(t7)) for (let n = 0; n < t7.items.length; ++n) {
let s = t7.items[n];
if (!T(s)) {
if (U(s)) {
s.items.length > 1 && e("Each pair must have its own sequence indicator");
let r = s.items[0] || new v(new y(null));
if (s.commentBefore && (r.key.commentBefore = r.key.commentBefore ? `${s.commentBefore}
${r.key.commentBefore}` : s.commentBefore), s.comment) {
let i = r.value ?? r.key;
i.comment = i.comment ? `${s.comment}
${i.comment}` : s.comment;
}
s = r;
}
t7.items[n] = T(s) ? s : new v(s);
}
}
else e("Expected a sequence for this tag");
return t7;
}
function Is(t7, e, n) {
let { replacer: s } = n, r = new F(t7);
r.tag = "tag:yaml.org,2002:pairs";
let i = 0;
if (e && Symbol.iterator in Object(e)) for (let o of e) {
typeof s == "function" && (o = s.call(e, String(i++), o));
let a, l;
if (Array.isArray(o)) if (o.length === 2) a = o[0], l = o[1];
else throw new TypeError(`Expected [key, value] tuple: ${o}`);
else if (o && o instanceof Object) {
let c = Object.keys(o);
if (c.length === 1) a = c[0], l = o[a];
else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`);
} else a = o;
r.items.push(rt(a, l, n));
}
return r;
}
function gi({ value: t7, source: e }, n) {
return e && (t7 ? Ls : Ps).test.test(e) ? e : t7 ? n.options.trueStr : n.options.falseStr;
}
function Un(t7, e, n, { intAsBigInt: s }) {
let r = t7[0];
if ((r === "-" || r === "+") && (e += 1), t7 = t7.substring(e).replace(/_/g, ""), s) {
switch (n) {
case 2:
t7 = `0b${t7}`;
break;
case 8:
t7 = `0o${t7}`;
break;
case 16:
t7 = `0x${t7}`;
break;
}
let o = BigInt(t7);
return r === "-" ? BigInt(-1) * o : o;
}
let i = parseInt(t7, n);
return r === "-" ? -1 * i : i;
}
function vs(t7, e, n) {
let { value: s } = t7;
if (qt(s)) {
let r = s.toString(e);
return s < 0 ? "-" + n + r.substr(1) : n + r;
}
return j(t7);
}
function Ds(t7, e) {
let n = t7[0], s = n === "-" || n === "+" ? t7.substring(1) : t7, r = (o) => e ? BigInt(o) : Number(o), i = s.replace(/_/g, "").split(":").reduce((o, a) => o * r(60) + r(a), r(0));
return n === "-" ? r(-1) * i : i;
}
function Ni(t7) {
let { value: e } = t7, n = (o) => o;
if (typeof e == "bigint") n = (o) => BigInt(o);
else if (isNaN(e) || !isFinite(e)) return j(t7);
let s = "";
e < 0 && (s = "-", e *= n(-1));
let r = n(60), i = [e % r];
return e < 60 ? i.unshift(0) : (e = (e - i[0]) / r, i.unshift(e % r), e >= 60 && (e = (e - i[0]) / r, i.unshift(e))), s + i.map((o) => String(o).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
}
function Gn(t7, e, n) {
let s = Ai.get(e);
if (s && !t7) return n && !s.includes(le) ? s.concat(le) : s.slice();
let r = s;
if (!r) if (Array.isArray(t7)) r = [];
else {
let i = Array.from(Ai.keys()).filter((o) => o !== "yaml11").map((o) => JSON.stringify(o)).join(", ");
throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`);
}
if (Array.isArray(t7)) for (let i of t7) r = r.concat(i);
else typeof t7 == "function" && (r = t7(r.slice()));
return n && (r = r.concat(le)), r.reduce((i, o) => {
let a = typeof o == "string" ? Ti[o] : o;
if (!a) {
let l = JSON.stringify(o), c = Object.keys(Ti).map((u) => JSON.stringify(u)).join(", ");
throw new Error(`Unknown custom tag ${l}; use one of ${c}`);
}
return i.includes(a) || i.push(a), i;
}, []);
}
function _i(t7, e) {
let n = [], s = e.directives === true;
if (e.directives !== false && t7.directives) {
let l = t7.directives.toString(t7);
l ? (n.push(l), s = true) : t7.directives.docStart && (s = true);
}
s && n.push("---");
let r = _n(t7, e), { commentString: i } = r.options;
if (t7.commentBefore) {
n.length !== 1 && n.unshift("");
let l = i(t7.commentBefore);
n.unshift(se(l, ""));
}
let o = false, a = null;
if (t7.contents) {
if (_(t7.contents)) {
if (t7.contents.spaceBefore && s && n.push(""), t7.contents.commentBefore) {
let u = i(t7.contents.commentBefore);
n.push(se(u, ""));
}
r.forceBlockIndent = !!t7.comment, a = t7.contents.comment;
}
let l = a ? void 0 : () => o = true, c = Oe(t7.contents, r, () => a = null, l);
a && (c += ge(c, "", i(a))), (c[0] === "|" || c[0] === ">") && n[n.length - 1] === "---" ? n[n.length - 1] = `--- ${c}` : n.push(c);
} else n.push(Oe(t7.contents, r));
if (t7.directives?.docEnd) if (t7.comment) {
let l = i(t7.comment);
l.includes(`
`) ? (n.push("..."), n.push(se(l, ""))) : n.push(`... ${l}`);
} else n.push("...");
else {
let l = t7.comment;
l && o && (l = l.replace(/^\n+/, "")), l && ((!o || a) && n[n.length - 1] !== "" && n.push(""), n.push(se(i(l), "")));
}
return n.join(`
`) + `
`;
}
function ct(t7) {
if (I(t7)) return true;
throw new Error("Expected a YAML collection as document contents");
}
function we(t7, { flow: e, indicator: n, next: s, offset: r, onError: i, parentIndent: o, startOnNewline: a }) {
let l = false, c = a, u = a, f = "", p = "", h = false, g = false, m = null, d = null, b = null, k = null, S = null, E = null, N = null;
for (let w of t7) switch (g && (w.type !== "space" && w.type !== "newline" && w.type !== "comma" && i(w.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), g = false), m && (c && w.type !== "comment" && w.type !== "newline" && i(m, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), m = null), w.type) {
case "space":
!e && (n !== "doc-start" || s?.type !== "flow-collection") && w.source.includes(" ") && (m = w), u = true;
break;
case "comment": {
u || i(w, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
let M = w.source.substring(1) || " ";
f ? f += p + M : f = M, p = "", c = false;
break;
}
case "newline":
c ? f ? f += w.source : (!E || n !== "seq-item-ind") && (l = true) : p += w.source, c = true, h = true, (d || b) && (k = w), u = true;
break;
case "anchor":
d && i(w, "MULTIPLE_ANCHORS", "A node can have at most one anchor"), w.source.endsWith(":") && i(w.offset + w.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true), d = w, N ?? (N = w.offset), c = false, u = false, g = true;
break;
case "tag": {
b && i(w, "MULTIPLE_TAGS", "A node can have at most one tag"), b = w, N ?? (N = w.offset), c = false, u = false, g = true;
break;
}
case n:
(d || b) && i(w, "BAD_PROP_ORDER", `Anchors and tags must be after the ${w.source} indicator`), E && i(w, "UNEXPECTED_TOKEN", `Unexpected ${w.source} in ${e ?? "collection"}`), E = w, c = n === "seq-item-ind" || n === "explicit-key-ind", u = false;
break;
case "comma":
if (e) {
S && i(w, "UNEXPECTED_TOKEN", `Unexpected , in ${e}`), S = w, c = false, u = false;
break;
}
default:
i(w, "UNEXPECTED_TOKEN", `Unexpected ${w.type} token`), c = false, u = false;
}
let A = t7[t7.length - 1], L = A ? A.offset + A.source.length : r;
return g && s && s.type !== "space" && s.type !== "newline" && s.type !== "comma" && (s.type !== "scalar" || s.source !== "") && i(s.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), m && (c && m.indent <= o || s?.type === "block-map" || s?.type === "block-seq") && i(m, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), { comma: S, found: E, spaceBefore: l, comment: f, hasNewline: h, anchor: d, tag: b, newlineAfterProp: k, end: L, start: N ?? L };
}
function Be(t7) {
if (!t7) return null;
switch (t7.type) {
case "alias":
case "scalar":
case "double-quoted-scalar":
case "single-quoted-scalar":
if (t7.source.includes(`
`)) return true;
if (t7.end) {
for (let e of t7.end) if (e.type === "newline") return true;
}
return false;
case "flow-collection":
for (let e of t7.items) {
for (let n of e.start) if (n.type === "newline") return true;
if (e.sep) {
for (let n of e.sep) if (n.type === "newline") return true;
}
if (Be(e.key) || Be(e.value)) return true;
}
return false;
default:
return true;
}
}
function Yt(t7, e, n) {
if (e?.type === "flow-collection") {
let s = e.end[0];
s.indent === t7 && (s.source === "]" || s.source === "}") && Be(e) && n(s, "BAD_INDENT", "Flow end indicator should be more indented than parent", true);
}
}
function Qn(t7, e, n) {
let { uniqueKeys: s } = t7.options;
if (s === false) return false;
let r = typeof s == "function" ? s : (i, o) => i === o || C(i) && C(o) && i.value === o.value;
return e.some((i) => r(i.key, n));
}
function Li({ composeNode: t7, composeEmptyNode: e }, n, s, r, i) {
let o = i?.nodeClass ?? x, a = new o(n.schema);
n.atRoot && (n.atRoot = false);
let l = s.offset, c = null;
for (let u of s.items) {
let { start: f, key: p, sep: h, value: g } = u, m = we(f, { indicator: "explicit-key-ind", next: p ?? h?.[0], offset: l, onError: r, parentIndent: s.indent, startOnNewline: true }), d = !m.found;
if (d) {
if (p && (p.type === "block-seq" ? r(l, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key") : "indent" in p && p.indent !== s.indent && r(l, "BAD_INDENT", Ii)), !m.anchor && !m.tag && !h) {
c = m.end, m.comment && (a.comment ? a.comment += `
` + m.comment : a.comment = m.comment);
continue;
}
(m.newlineAfterProp || Be(p)) && r(p ?? f[f.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
} else m.found?.indent !== s.indent && r(l, "BAD_INDENT", Ii);
n.atKey = true;
let b = m.end, k = p ? t7(n, p, m, r) : e(n, b, f, null, m, r);
n.schema.compat && Yt(s.indent, p, r), n.atKey = false, Qn(n, a.items, k) && r(b, "DUPLICATE_KEY", "Map keys must be unique");
let S = we(h ?? [], { indicator: "map-value-ind", next: g, offset: k.range[2], onError: r, parentIndent: s.indent, startOnNewline: !p || p.type === "block-scalar" });
if (l = S.end, S.found) {
d && (g?.type === "block-map" && !S.hasNewline && r(l, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"), n.options.strict && m.start < S.found.offset - 1024 && r(k.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));
let E = g ? t7(n, g, S, r) : e(n, l, h, null, S, r);
n.schema.compat && Yt(s.indent, g, r), l = E.range[2];
let N = new v(k, E);
n.options.keepSourceTokens && (N.srcToken = u), a.items.push(N);
} else {
d && r(k.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), S.comment && (k.comment ? k.comment += `
` + S.comment : k.comment = S.comment);
let E = new v(k);
n.options.keepSourceTokens && (E.srcToken = u), a.items.push(E);
}
}
return c && c < l && r(c, "IMPOSSIBLE", "Map comment with trailing content"), a.range = [s.offset, l, c ?? l], a;
}
function Pi({ composeNode: t7, composeEmptyNode: e }, n, s, r, i) {
let o = i?.nodeClass ?? F, a = new o(n.schema);
n.atRoot && (n.atRoot = false), n.atKey && (n.atKey = false);
let l = s.offset, c = null;
for (let { start: u, value: f } of s.items) {
let p = we(u, { indicator: "seq-item-ind", next: f, offset: l, onError: r, parentIndent: s.indent, startOnNewline: true });
if (!p.found) if (p.anchor || p.tag || f) f?.type === "block-seq" ? r(p.end, "BAD_INDENT", "All sequence items must start at the same column") : r(l, "MISSING_CHAR", "Sequence item without - indicator");
else {
c = p.end, p.comment && (a.comment = p.comment);
continue;
}
let h = f ? t7(n, f, p, r) : e(n, p.end, u, null, p, r);
n.schema.compat && Yt(s.indent, f, r), l = h.range[2], a.items.push(h);
}
return a.range = [s.offset, l, c ?? l], a;
}
function be(t7, e, n, s) {
let r = "";
if (t7) {
let i = false, o = "";
for (let a of t7) {
let { source: l, type: c } = a;
switch (c) {
case "space":
i = true;
break;
case "comment": {
n && !i && s(a, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
let u = l.substring(1) || " ";
r ? r += o + u : r = u, o = "";
break;
}
case "newline":
r && (o += l), i = true;
break;
default:
s(a, "UNEXPECTED_TOKEN", `Unexpected ${c} at node end`);
}
e += l.length;
}
}
return { comment: r, offset: e };
}
function vi({ composeNode: t7, composeEmptyNode: e }, n, s, r, i) {
let o = s.start.source === "{", a = o ? "flow map" : "flow sequence", l = i?.nodeClass ?? (o ? x : F), c = new l(n.schema);
c.flow = true;
let u = n.atRoot;
u && (n.atRoot = false), n.atKey && (n.atKey = false);
let f = s.offset + s.start.source.length;
for (let d = 0; d < s.items.length; ++d) {
let b = s.items[d], { start: k, key: S, sep: E, value: N } = b, A = we(k, { flow: a, indicator: "explicit-key-ind", next: S ?? E?.[0], offset: f, onError: r, parentIndent: s.indent, startOnNewline: false });
if (!A.found) {
if (!A.anchor && !A.tag && !E && !N) {
d === 0 && A.comma ? r(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`) : d < s.items.length - 1 && r(A.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${a}`), A.comment && (c.comment ? c.comment += `
` + A.comment : c.comment = A.comment), f = A.end;
continue;
}
!o && n.options.strict && Be(S) && r(S, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
}
if (d === 0) A.comma && r(A.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${a}`);
else if (A.comma || r(A.start, "MISSING_CHAR", `Missing , between ${a} items`), A.comment) {
let L = "";
e: for (let w of k) switch (w.type) {
case "comma":
case "space":
break;
case "comment":
L = w.source.substring(1);
break e;
default:
break e;
}
if (L) {
let w = c.items[c.items.length - 1];
T(w) && (w = w.value ?? w.key), w.comment ? w.comment += `
` + L : w.comment = L, A.comment = A.comment.substring(L.length + 1);
}
}
if (!o && !E && !A.found) {
let L = N ? t7(n, N, A, r) : e(n, A.end, E, null, A, r);
c.items.push(L), f = L.range[2], $s(N) && r(L.range, "BLOCK_IN_FLOW", Ms);
} else {
n.atKey = true;
let L = A.end, w = S ? t7(n, S, A, r) : e(n, L, k, null, A, r);
$s(S) && r(w.range, "BLOCK_IN_FLOW", Ms), n.atKey = false;
let M = we(E ?? [], { flow: a, indicator: "map-value-ind", next: N, offset: w.range[2], onError: r, parentIndent: s.indent, startOnNewline: false });
if (M.found) {
if (!o && !A.found && n.options.strict) {
if (E) for (let $ of E) {
if ($ === M.found) break;
if ($.type === "newline") {
r($, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
break;
}
}
A.start < M.found.offset - 1024 && r(M.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
}
} else N && ("source" in N && N.source?.[0] === ":" ? r(N, "MISSING_CHAR", `Missing space after : in ${a}`) : r(M.start, "MISSING_CHAR", `Missing , or : between ${a} items`));
let Le = N ? t7(n, N, M, r) : M.found ? e(n, M.end, E, null, M, r) : null;
Le ? $s(N) && r(Le.range, "BLOCK_IN_FLOW", Ms) : M.comment && (w.comment ? w.comment += `
` + M.comment : w.comment = M.comment);
let Ye = new v(w, Le);
if (n.options.keepSourceTokens && (Ye.srcToken = b), o) {
let $ = c;
Qn(n, $.items, w) && r(L, "DUPLICATE_KEY", "Map keys must be unique"), $.items.push(Ye);
} else {
let $ = new x(n.schema);
$.flow = true, $.items.push(Ye);
let zs = (Le ?? w).range;
$.range = [w.range[0], zs[1], zs[2]], c.items.push($);
}
f = Le ? Le.range[2] : M.end;
}
}
let p = o ? "}" : "]", [h, ...g] = s.end, m = f;
if (h?.source === p) m = h.offset + h.source.length;
else {
let d = a[0].toUpperCase() + a.substring(1), b = u ? `${d} must end with a ${p}` : `${d} in block collection must be sufficiently indented and end with a ${p}`;
r(f, u ? "MISSING_CHAR" : "BAD_INDENT", b), h && h.source.length !== 1 && g.unshift(h);
}
if (g.length > 0) {
let d = be(g, m, n.options.strict, r);
d.comment && (c.comment ? c.comment += `
` + d.comment : c.comment = d.comment), c.range = [s.offset, m, d.offset];
} else c.range = [s.offset, m, m];
return c;
}
function Bs(t7, e, n, s, r, i) {
let o = n.type === "block-map" ? Li(t7, e, n, s, i) : n.type === "block-seq" ? Pi(t7, e, n, s, i) : vi(t7, e, n, s, i), a = o.constructor;
return r === "!" || r === a.tagName ? (o.tag = a.tagName, o) : (r && (o.tag = r), o);
}
function Di(t7, e, n, s, r) {
let i = s.tag, o = i ? e.directives.tagName(i.source, (p) => r(i, "TAG_RESOLVE_FAILED", p)) : null;
if (n.type === "block-seq") {
let { anchor: p, newlineAfterProp: h } = s, g = p && i ? p.offset > i.offset ? p : i : p ?? i;
g && (!h || h.offset < g.offset) && r(g, "MISSING_CHAR", "Missing newline after block sequence props");
}
let a = n.type === "block-map" ? "map" : n.type === "block-seq" ? "seq" : n.start.source === "{" ? "map" : "seq";
if (!i || !o || o === "!" || o === x.tagName && a === "map" || o === F.tagName && a === "seq") return Bs(t7, e, n, r, o);
let l = e.schema.tags.find((p) => p.tag === o && p.collection === a);
if (!l) {
let p = e.schema.knownTags[o];
if (p?.collection === a) e.schema.tags.push(Object.assign({}, p, { default: false })), l = p;
else return p ? r(i, "BAD_COLLECTION_TYPE", `${p.tag} used for ${a} collection, but expects ${p.collection ?? "scalar"}`, true) : r(i, "TAG_RESOLVE_FAILED", `Unresolved tag: ${o}`, true), Bs(t7, e, n, r, o);
}
let c = Bs(t7, e, n, r, o, l), u = l.resolve?.(c, (p) => r(i, "TAG_RESOLVE_FAILED", p), e.options) ?? c, f = _(u) ? u : new y(u);
return f.range = c.range, f.tag = o, l?.format && (f.format = l.format), f;
}
function Hn(t7, e, n) {
let s = e.offset, r = Oa(e, t7.options.strict, n);
if (!r) return { value: "", type: null, comment: "", range: [s, s, s] };
let i = r.mode === ">" ? y.BLOCK_FOLDED : y.BLOCK_LITERAL, o = e.source ? _a(e.source) : [], a = o.length;
for (let m = o.length - 1; m >= 0; --m) {
let d = o[m][1];
if (d === "" || d === "\r") a = m;
else break;
}
if (a === 0) {
let m = r.chomp === "+" && o.length > 0 ? `
`.repeat(Math.max(1, o.length - 1)) : "", d = s + r.length;
return e.source && (d += e.source.length), { value: m, type: i, comment: r.comment, range: [s, d, d] };
}
let l = e.indent + r.indent, c = e.offset + r.length, u = 0;
for (let m = 0; m < a; ++m) {
let [d, b] = o[m];
if (b === "" || b === "\r") r.indent === 0 && d.length > l && (l = d.length);
else {
d.length < l && n(c + d.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), r.indent === 0 && (l = d.length), u = m, l === 0 && !t7.atRoot && n(c, "BAD_INDENT", "Block scalar values in collections must be indented");
break;
}
c += d.length + b.length + 1;
}
for (let m = o.length - 1; m >= a; --m) o[m][0].length > l && (a = m + 1);
let f = "", p = "", h = false;
for (let m = 0; m < u; ++m) f += o[m][0].slice(l) + `
`;
for (let m = u; m < a; ++m) {
let [d, b] = o[m];
c += d.length + b.length + 1;
let k = b[b.length - 1] === "\r";
if (k && (b = b.slice(0, -1)), b && d.length < l) {
let E = `Block scalar lines must not be less indented than their ${r.indent ? "explicit indentation indicator" : "first line"}`;
n(c - b.length - (k ? 2 : 1), "BAD_INDENT", E), d = "";
}
i === y.BLOCK_LITERAL ? (f += p + d.slice(l) + b, p = `
`) : d.length > l || b[0] === " " ? (p === " " ? p = `
` : !h && p === `
` && (p = `
`), f += p + d.slice(l) + b, p = `
`, h = true) : b === "" ? p === `
` ? f += `
` : p = `
` : (f += p + b, p = " ", h = false);
}
switch (r.chomp) {
case "-":
break;
case "+":
for (let m = a; m < o.length; ++m) f += `
` + o[m][0].slice(l);
f[f.length - 1] !== `
` && (f += `
`);
break;
default:
f += `
`;
}
let g = s + r.length + e.source.length;
return { value: f, type: i, comment: r.comment, range: [s, g, g] };
}
function Oa({ offset: t7, props: e }, n, s) {
if (e[0].type !== "block-scalar-header") return s(e[0], "IMPOSSIBLE", "Block scalar header not found"), null;
let { source: r } = e[0], i = r[0], o = 0, a = "", l = -1;
for (let p = 1; p < r.length; ++p) {
let h = r[p];
if (!a && (h === "-" || h === "+")) a = h;
else {
let g = Number(h);
!o && g ? o = g : l === -1 && (l = t7 + p);
}
}
l !== -1 && s(l, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${r}`);
let c = false, u = "", f = r.length;
for (let p = 1; p < e.length; ++p) {
let h = e[p];
switch (h.type) {
case "space":
c = true;
case "newline":
f += h.source.length;
break;
case "comment":
n && !c && s(h, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), f += h.source.length, u = h.source.substring(1);
break;
case "error":
s(h, "UNEXPECTED_TOKEN", h.message), f += h.source.length;
break;
default: {
let g = `Unexpected token in block scalar header: ${h.type}`;
s(h, "UNEXPECTED_TOKEN", g);
let m = h.source;
m && typeof m == "string" && (f += m.length);
}
}
}
return { mode: i, indent: o, chomp: a, comment: u, length: f };
}
function _a(t7) {
let e = t7.split(/\n( *)/), n = e[0], s = n.match(/^( *)/), i = [s?.[1] ? [s[1], n.slice(s[1].length)] : ["", n]];
for (let o = 1; o < e.length; o += 2) i.push([e[o], e[o + 1]]);
return i;
}
function Jn(t7, e, n) {
let { offset: s, type: r, source: i, end: o } = t7, a, l, c = (p, h, g) => n(s + p, h, g);
switch (r) {
case "scalar":
a = y.PLAIN, l = Ia(i, c);
break;
case "single-quoted-scalar":
a = y.QUOTE_SINGLE, l = La(i, c);
break;
case "double-quoted-scalar":
a = y.QUOTE_DOUBLE, l = Pa(i, c);
break;
default:
return n(t7, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${r}`), { value: "", type: null, comment: "", range: [s, s + i.length, s + i.length] };
}
let u = s + i.length, f = be(o, u, e, n);
return { value: l, type: a, comment: f.comment, range: [s, u, f.offset] };
}
function Ia(t7, e) {
let n = "";
switch (t7[0]) {
case " ":
n = "a tab character";
break;
case ",":
n = "flow indicator character ,";
break;
case "%":
n = "directive indicator character %";
break;
case "|":
case ">": {
n = `block scalar indicator ${t7[0]}`;
break;
}
case "@":
case "`": {
n = `reserved character ${t7[0]}`;
break;
}
}
return n && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${n}`), xi(t7);
}
function La(t7, e) {
return (t7[t7.length - 1] !== "'" || t7.length === 1) && e(t7.length, "MISSING_CHAR", "Missing closing 'quote"), xi(t7.slice(1, -1)).replace(/''/g, "'");
}
function xi(t7) {
let e, n;
try {
e = new RegExp(`(.*?)(?<![ ])[ ]*\r?
`, "sy"), n = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
`, "sy");
} catch {
e = /(.*?)[ \t]*\r?\n/sy, n = /[ \t]*(.*?)[ \t]*\r?\n/sy;
}
let s = e.exec(t7);
if (!s) return t7;
let r = s[1], i = " ", o = e.lastIndex;
for (n.lastIndex = o; s = n.exec(t7); ) s[1] === "" ? i === `
` ? r += i : i = `
` : (r += i + s[1], i = " "), o = n.lastIndex;
let a = /[ \t]*(.*)/sy;
return a.lastIndex = o, s = a.exec(t7), r + i + (s?.[1] ?? "");
}
function Pa(t7, e) {
let n = "";
for (let s = 1; s < t7.length - 1; ++s) {
let r = t7[s];
if (!(r === "\r" && t7[s + 1] === `
`)) if (r === `
`) {
let { fold: i, offset: o } = va(t7, s);
n += i, s = o;
} else if (r === "\\") {
let i = t7[++s], o = Da[i];
if (o) n += o;
else if (i === `
`) for (i = t7[s + 1]; i === " " || i === " "; ) i = t7[++s + 1];
else if (i === "\r" && t7[s + 1] === `
`) for (i = t7[++s + 1]; i === " " || i === " "; ) i = t7[++s + 1];
else if (i === "x" || i === "u" || i === "U") {
let a = i === "x" ? 2 : i === "u" ? 4 : 8;
n += xa(t7, s + 1, a, e), s += a;
} else {
let a = t7.substr(s - 1, 2);
e(s - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${a}`), n += a;
}
} else if (r === " " || r === " ") {
let i = s, o = t7[s + 1];
for (; o === " " || o === " "; ) o = t7[++s + 1];
o !== `
` && !(o === "\r" && t7[s + 2] === `
`) && (n += s > i ? t7.slice(i, s + 1) : r);
} else n += r;
}
return (t7[t7.length - 1] !== '"' || t7.length === 1) && e(t7.length, "MISSING_CHAR", 'Missing closing "quote'), n;
}
function va(t7, e) {
let n = "", s = t7[e + 1];
for (; (s === " " || s === " " || s === `
` || s === "\r") && !(s === "\r" && t7[e + 2] !== `
`); ) s === `
` && (n += `
`), e += 1, s = t7[e + 1];
return n || (n = " "), { fold: n, offset: e };
}
function xa(t7, e, n, s) {
let r = t7.substr(e, n), o = r.length === n && /^[0-9a-fA-F]+$/.test(r) ? parseInt(r, 16) : NaN;
try {
return String.fromCodePoint(o);
} catch {
let a = t7.substr(e - 2, n + 2);
return s(e - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${a}`), a;
}
}
function Rs(t7, e, n, s) {
let { value: r, type: i, comment: o, range: a } = e.type === "block-scalar" ? Hn(t7, e, s) : Jn(e, t7.options.strict, s), l = n ? t7.directives.tagName(n.source, (f) => s(n, "TAG_RESOLVE_FAILED", f)) : null, c;
t7.options.stringKeys && t7.atKey ? c = t7.schema[ee] : l ? c = Ma(t7.schema, r, l, n, s) : e.type === "scalar" ? c = $a(t7, r, e, s) : c = t7.schema[ee];
let u;
try {
let f = c.resolve(r, (p) => s(n ?? e, "TAG_RESOLVE_FAILED", p), t7.options);
u = C(f) ? f : new y(f);
} catch (f) {
let p = f instanceof Error ? f.message : String(f);
s(n ?? e, "TAG_RESOLVE_FAILED", p), u = new y(r);
}
return u.range = a, u.source = r, i && (u.type = i), l && (u.tag = l), c.format && (u.format = c.format), o && (u.comment = o), u;
}
function Ma(t7, e, n, s, r) {
if (n === "!") return t7[ee];
let i = [];
for (let a of t7.tags) if (!a.collection && a.tag === n) if (a.default && a.test) i.push(a);
else return a;
for (let a of i) if (a.test?.test(e)) return a;
let o = t7.knownTags[n];
return o && !o.collection ? (t7.tags.push(Object.assign({}, o, { default: false, test: void 0 })), o) : (r(s, "TAG_RESOLVE_FAILED", `Unresolved tag: ${n}`, n !== "tag:yaml.org,2002:str"), t7[ee]);
}
function $a({ atKey: t7, directives: e, schema: n }, s, r, i) {
let o = n.tags.find((a) => (a.default === true || t7 && a.default === "key") && a.test?.test(s)) || n[ee];
if (n.compat) {
let a = n.compat.find((l) => l.default && l.test?.test(s)) ?? n[ee];
if (o.tag !== a.tag) {
let l = e.tagString(o.tag), c = e.tagString(a.tag), u = `Value may be parsed as either ${l} or ${c}`;
i(r, "TAG_RESOLVE_FAILED", u, true);
}
}
return o;
}
function Mi(t7, e, n) {
if (e) {
n ?? (n = e.length);
for (let s = n - 1; s >= 0; --s) {
let r = e[s];
switch (r.type) {
case "space":
case "comment":
case "newline":
t7 -= r.source.length;
continue;
}
for (r = e[++s]; r?.type === "space"; ) t7 += r.source.length, r = e[++s];
break;
}
}
return t7;
}
function qs(t7, e, n, s) {
let r = t7.atKey, { spaceBefore: i, comment: o, anchor: a, tag: l } = n, c, u = true;
switch (e.type) {
case "alias":
c = Ra(t7, e, s), (a || l) && s(e, "ALIAS_PROPS", "An alias node must not specify any properties");
break;
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
case "block-scalar":
c = Rs(t7, e, l, s), a && (c.anchor = a.source.substring(1));
break;
case "block-map":
case "block-seq":
case "flow-collection":
try {
c = Di(Ba, t7, e, n, s), a && (c.anchor = a.source.substring(1));
} catch (f) {
let p = f instanceof Error ? f.message : String(f);
s(e, "RESOURCE_EXHAUSTION", p);
}
break;
default: {
let f = e.type === "error" ? e.message : `Unsupported token (type: ${e.type})`;
s(e, "UNEXPECTED_TOKEN", f), u = false;
}
}
return c ?? (c = Wn(t7, e.offset, void 0, null, n, s)), a && c.anchor === "" && s(a, "BAD_ALIAS", "Anchor cannot be an empty string"), r && t7.options.stringKeys && (!C(c) || typeof c.value != "string" || c.tag && c.tag !== "tag:yaml.org,2002:str") && s(l ?? e, "NON_STRING_KEY", "With stringKeys, all keys must be strings"), i && (c.spaceBefore = true), o && (e.type === "scalar" && e.source === "" ? c.comment = o : c.commentBefore = o), t7.options.keepSourceTokens && u && (c.srcToken = e), c;
}
function Wn(t7, e, n, s, { spaceBefore: r, comment: i, anchor: o, tag: a, end: l }, c) {
let u = { type: "scalar", offset: Mi(e, n, s), indent: -1, source: "" }, f = Rs(t7, u, a, c);
return o && (f.anchor = o.source.substring(1), f.anchor === "" && c(o, "BAD_ALIAS", "Anchor cannot be an empty string")), r && (f.spaceBefore = true), i && (f.comment = i, f.range[2] = l), f;
}
function Ra({ options: t7 }, { offset: e, source: n, end: s }, r) {
let i = new de(n.substring(1));
i.source === "" && r(e, "BAD_ALIAS", "Alias cannot be an empty string"), i.source.endsWith(":") && r(e + n.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
let o = e + n.length, a = be(s, o, t7.strict, r);
return i.range = [e, o, a.offset], a.comment && (i.comment = a.comment), i;
}
function $i(t7, e, { offset: n, start: s, value: r, end: i }, o) {
let a = Object.assign({ _directives: e }, t7), l = new ye(void 0, a), c = { atKey: false, atRoot: true, directives: l.directives, options: l.options, schema: l.schema }, u = we(s, { indicator: "doc-start", next: r ?? i?.[0], offset: n, onError: o, parentIndent: 0, startOnNewline: true });
u.found && (l.directives.docStart = true, r && (r.type === "block-map" || r.type === "block-seq") && !u.hasNewline && o(u.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")), l.contents = r ? qs(c, r, u, o) : Wn(c, u.end, s, null, u, o);
let f = l.contents.range[2], p = be(i, f, false, o);
return p.comment && (l.comment = p.comment), l.range = [n, f, p.offset], l;
}
function Ut(t7) {
if (typeof t7 == "number") return [t7, t7 + 1];
if (Array.isArray(t7)) return t7.length === 2 ? t7 : [t7[0], t7[1]];
let { offset: e, source: n } = t7;
return [e, e + (typeof n == "string" ? n.length : 1)];
}
function Bi(t7) {
let e = "", n = false, s = false;
for (let r = 0; r < t7.length; ++r) {
let i = t7[r];
switch (i[0]) {
case "#":
e += (e === "" ? "" : s ? `
` : `
`) + (i.substring(1) || " "), n = true, s = false;
break;
case "%":
t7[r + 1]?.[0] !== "#" && (r += 1), n = false;
break;
default:
n || (s = true), n = false;
}
}
return { comment: e, afterEmptyLine: s };
}
function Ri(t7, e = true, n) {
if (t7) {
let s = (r, i, o) => {
let a = typeof r == "number" ? r : Array.isArray(r) ? r[0] : r.offset;
if (n) n(a, i, o);
else throw new te([a, a + 1], i, o);
};
switch (t7.type) {
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
return Jn(t7, e, s);
case "block-scalar":
return Hn({ options: { strict: e } }, t7, s);
}
}
return null;
}
function qi(t7, e) {
let { implicitKey: n = false, indent: s, inFlow: r = false, offset: i = -1, type: o = "PLAIN" } = e, a = Te({ type: o, value: t7 }, { implicitKey: n, indent: s > 0 ? " ".repeat(s) : "", inFlow: r, options: { blockQuote: true, lineWidth: -1 } }), l = e.end ?? [{ type: "newline", offset: -1, indent: s, source: `
` }];
switch (a[0]) {
case "|":
case ">": {
let c = a.indexOf(`
`), u = a.substring(0, c), f = a.substring(c + 1) + `
`, p = [{ type: "block-scalar-header", offset: i, indent: s, source: u }];
return Ki(p, l) || p.push({ type: "newline", offset: -1, indent: s, source: `
` }), { type: "block-scalar", offset: i, indent: s, props: p, source: f };
}
case '"':
return { type: "double-quoted-scalar", offset: i, indent: s, source: a, end: l };
case "'":
return { type: "single-quoted-scalar", offset: i, indent: s, source: a, end: l };
default:
return { type: "scalar", offset: i, indent: s, source: a, end: l };
}
}
function Fi(t7, e, n = {}) {
let { afterKey: s = false, implicitKey: r = false, inFlow: i = false, type: o } = n, a = "indent" in t7 ? t7.indent : null;
if (s && typeof a == "number" && (a += 2), !o) switch (t7.type) {
case "single-quoted-scalar":
o = "QUOTE_SINGLE";
break;
case "double-quoted-scalar":
o = "QUOTE_DOUBLE";
break;
case "block-scalar": {
let c = t7.props[0];
if (c.type !== "block-scalar-header") throw new Error("Invalid block scalar header");
o = c.source[0] === ">" ? "BLOCK_FOLDED" : "BLOCK_LITERAL";
break;
}
default:
o = "PLAIN";
}
let l = Te({ type: o, value: e }, { implicitKey: r || a === null, indent: a !== null && a > 0 ? " ".repeat(a) : "", inFlow: i, options: { blockQuote: true, lineWidth: -1 } });
switch (l[0]) {
case "|":
case ">":
qa(t7, l);
break;
case '"':
Fs(t7, l, "double-quoted-scalar");
break;
case "'":
Fs(t7, l, "single-quoted-scalar");
break;
default:
Fs(t7, l, "scalar");
}
}
function qa(t7, e) {
let n = e.indexOf(`
`), s = e.substring(0, n), r = e.substring(n + 1) + `
`;
if (t7.type === "block-scalar") {
let i = t7.props[0];
if (i.type !== "block-scalar-header") throw new Error("Invalid block scalar header");
i.source = s, t7.source = r;
} else {
let { offset: i } = t7, o = "indent" in t7 ? t7.indent : -1, a = [{ type: "block-scalar-header", offset: i, indent: o, source: s }];
Ki(a, "end" in t7 ? t7.end : void 0) || a.push({ type: "newline", offset: -1, indent: o, source: `
` });
for (let l of Object.keys(t7)) l !== "type" && l !== "offset" && delete t7[l];
Object.assign(t7, { type: "block-scalar", indent: o, props: a, source: r });
}
}
function Ki(t7, e) {
if (e) for (let n of e) switch (n.type) {
case "space":
case "comment":
t7.push(n);
break;
case "newline":
return t7.push(n), true;
}
return false;
}
function Fs(t7, e, n) {
switch (t7.type) {
case "scalar":
case "double-quoted-scalar":
case "single-quoted-scalar":
t7.type = n, t7.source = e;
break;
case "block-scalar": {
let s = t7.props.slice(1), r = e.length;
t7.props[0].type === "block-scalar-header" && (r -= t7.props[0].source.length);
for (let i of s) i.offset += r;
delete t7.props, Object.assign(t7, { type: n, source: e, end: s });
break;
}
case "block-map":
case "block-seq": {
let r = { type: "newline", offset: t7.offset + e.length, indent: t7.indent, source: `
` };
delete t7.items, Object.assign(t7, { type: n, source: e, end: [r] });
break;
}
default: {
let s = "indent" in t7 ? t7.indent : -1, r = "end" in t7 && Array.isArray(t7.end) ? t7.end.filter((i) => i.type === "space" || i.type === "comment" || i.type === "newline") : [];
for (let i of Object.keys(t7)) i !== "type" && i !== "offset" && delete t7[i];
Object.assign(t7, { type: n, indent: s, source: e, end: r });
}
}
}
function zn(t7) {
switch (t7.type) {
case "block-scalar": {
let e = "";
for (let n of t7.props) e += zn(n);
return e + t7.source;
}
case "block-map":
case "block-seq": {
let e = "";
for (let n of t7.items) e += Xn(n);
return e;
}
case "flow-collection": {
let e = t7.start.source;
for (let n of t7.items) e += Xn(n);
for (let n of t7.end) e += n.source;
return e;
}
case "document": {
let e = Xn(t7);
if (t7.end) for (let n of t7.end) e += n.source;
return e;
}
default: {
let e = t7.source;
if ("end" in t7 && t7.end) for (let n of t7.end) e += n.source;
return e;
}
}
}
function Xn({ start: t7, key: e, sep: n, value: s }) {
let r = "";
for (let i of t7) r += i.source;
if (e && (r += zn(e)), n) for (let i of n) r += i.source;
return s && (r += zn(s)), r;
}
function Re(t7, e) {
"type" in t7 && t7.type === "document" && (t7 = { start: t7.start, value: t7.value }), ji(Object.freeze([]), t7, e);
}
function ji(t7, e, n) {
let s = n(e, t7);
if (typeof s == "symbol") return s;
for (let r of ["key", "value"]) {
let i = e[r];
if (i && "items" in i) {
for (let o = 0; o < i.items.length; ++o) {
let a = ji(Object.freeze(t7.concat([[r, o]])), i.items[o], n);
if (typeof a == "number") o = a - 1;
else {
if (a === Ks) return Ks;
a === Ui && (i.items.splice(o, 1), o -= 1);
}
}
typeof s == "function" && r === "key" && (s = s(e, t7));
}
}
return typeof s == "function" ? s(e, t7) : s;
}
function Ua(t7) {
switch (t7) {
case jt:
return "<BOM>";
case Vt:
return "<DOC>";
case Gt:
return "<FLOW_END>";
case pt:
return "<SCALAR>";
default:
return JSON.stringify(t7);
}
}
function Ys(t7) {
switch (t7) {
case jt:
return "byte-order-mark";
case Vt:
return "doc-mode";
case Gt:
return "flow-error-end";
case pt:
return "scalar";
case "---":
return "doc-start";
case "...":
return "doc-end";
case "":
case `
`:
case `\r
`:
return "newline";
case "-":
return "seq-item-ind";
case "?":
return "explicit-key-ind";
case ":":
return "map-value-ind";
case "{":
return "flow-map-start";
case "}":
return "flow-map-end";
case "[":
return "flow-seq-start";
case "]":
return "flow-seq-end";
case ",":
return "comma";
}
switch (t7[0]) {
case " ":
case " ":
return "space";
case "#":
return "comment";
case "%":
return "directive-line";
case "*":
return "alias";
case "&":
return "anchor";
case "!":
return "tag";
case "'":
return "single-quoted-scalar";
case '"':
return "double-quoted-scalar";
case "|":
case ">":
return "block-scalar-header";
}
return null;
}
function ue(t7) {
switch (t7) {
case void 0:
case " ":
case `
`:
case "\r":
case " ":
return true;
default:
return false;
}
}
function Fe(t7, e) {
for (let n = 0; n < t7.length; ++n) if (t7[n].type === e) return true;
return false;
}
function Gi(t7) {
for (let e = 0; e < t7.length; ++e) switch (t7[e].type) {
case "space":
case "comment":
case "newline":
break;
default:
return e;
}
return -1;
}
function Hi(t7) {
switch (t7?.type) {
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
case "flow-collection":
return true;
default:
return false;
}
}
function es(t7) {
switch (t7.type) {
case "document":
return t7.start;
case "block-map": {
let e = t7.items[t7.items.length - 1];
return e.sep ?? e.start;
}
case "block-seq":
return t7.items[t7.items.length - 1].start;
default:
return [];
}
}
function ht(t7) {
if (t7.length === 0) return [];
let e = t7.length;
e: for (; --e >= 0; ) switch (t7[e].type) {
case "doc-start":
case "explicit-key-ind":
case "map-value-ind":
case "seq-item-ind":
case "newline":
break e;
}
for (; t7[++e]?.type === "space"; ) ;
return t7.splice(e, t7.length);
}
function ts(t7, e) {
if (e.length < 1e5) Array.prototype.push.apply(t7, e);
else for (let n = 0; n < e.length; ++n) t7.push(e[n]);
}
function Qi(t7) {
if (t7.start.type === "flow-seq-start") for (let e of t7.items) e.sep && !e.value && !Fe(e.start, "explicit-key-ind") && !Fe(e.sep, "map-value-ind") && (e.key && (e.value = e.key), delete e.key, Hi(e.value) ? e.value.end ? ts(e.value.end, e.sep) : e.value.end = e.sep : ts(e.start, e.sep), delete e.sep);
}
function Ji(t7) {
let e = t7.prettyErrors !== false;
return { lineCounter: t7.lineCounter || e && new qe() || null, prettyErrors: e };
}
function Wi(t7, e = {}) {
let { lineCounter: n, prettyErrors: s } = Ji(e), r = new Ie(n?.addNewLine), i = new _e(e), o = Array.from(i.compose(r.parse(t7)));
if (s && n) for (let a of o) a.errors.forEach(Kt(t7, n)), a.warnings.forEach(Kt(t7, n));
return o.length > 0 ? o : Object.assign([], { empty: true }, i.streamInfo());
}
function Vs(t7, e = {}) {
let { lineCounter: n, prettyErrors: s } = Ji(e), r = new Ie(n?.addNewLine), i = new _e(e), o = null;
for (let a of i.compose(r.parse(t7), true, t7.length)) if (!o) o = a;
else if (o.options.logLevel !== "silent") {
o.errors.push(new te(a.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
break;
}
return s && n && (o.errors.forEach(Kt(t7, n)), o.warnings.forEach(Kt(t7, n))), o;
}
function Xi(t7, e, n) {
let s;
typeof e == "function" ? s = e : n === void 0 && e && typeof e == "object" && (n = e);
let r = Vs(t7, n);
if (!r) return null;
if (r.warnings.forEach((i) => In(r.options.logLevel, i)), r.errors.length > 0) {
if (r.options.logLevel !== "silent") throw r.errors[0];
r.errors = [];
}
return r.toJS(Object.assign({ reviver: s }, n));
}
function zi(t7, e, n) {
let s = null;
if (typeof e == "function" || Array.isArray(e) ? s = e : n === void 0 && e && (n = e), typeof n == "string" && (n = n.length), typeof n == "number") {
let r = Math.round(n);
n = r < 1 ? void 0 : r > 8 ? { indent: 8 } : { indent: r };
}
if (t7 === void 0) {
let { keepUndefined: r } = n ?? e ?? {};
if (!r) return;
}
return ne(t7) && !s ? t7.toString(n) : new ye(t7, s, n).toString(n);
}
function eo(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "flow-collection") throw new Error("Expected flow-collection CST node for flow sequence");
let r = t7.items.map((o, a) => {
let l = s.items[a];
if (Ga(o, l)) return Ce(ie(o.items), l, e, _t);
if (T(o)) return Ce(o, l, e, _t);
{
let c = [];
for (let f of q(l.start)) {
if (Ee(f)) {
c.push(f);
continue;
}
if (f.type === "comma") continue;
throw new Error(`Unexpected token type in sequence item start: ${f.type}`);
}
let u = e.transformNode(o, { tokens: c });
return ti(Z(u.position.start, u.position.end), u);
}
});
if (t7.items.length < s.items.length) for (let o = t7.items.length; o < s.items.length; o++) {
let a = s.items[o];
for (let l of D(a.start, e)) {
if (l.type === "comma") continue;
throw new Error(`Unexpected token type in collection item start: ${l.type}`);
}
}
let i = null;
for (let o of q(s.end)) {
if (o.type === "comment") {
e.transformComment(o);
continue;
}
if (o.type === "flow-seq-end") {
i = o;
continue;
}
throw new Error(`Unexpected token type in flow seq end: ${o.type}`);
}
if (!i) throw new Error("Expected flow-seq-end token");
return ei(e.transformRange([s.start.offset, i.offset + i.source.length]), e.transformContentProperties(t7, n.tokens), r);
}
function Ga(t7, e) {
if (t7.srcToken) return false;
if (!U(t7)) return false;
return t7.items.length !== 1 ? false : t7.items[0].srcToken === e;
}
function ss(t7, e, n) {
return { type: "mapping", position: t7, leadingComments: [], ...e, children: n };
}
function rs(t7, e, n) {
return { type: "mappingItem", position: t7, leadingComments: [], children: [e, n] };
}
function to(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "block-map") throw new Error("Expected block mapping srcToken");
let r = t7.items.map((i, o) => {
let a = s.items[o];
return Ce(i, a, e, rs);
});
if (t7.items.length < s.items.length) for (let i = t7.items.length; i < s.items.length; i++) {
let o = s.items[i];
for (let a of D(o.start, e)) throw new Error(`Unexpected token type in collection item start: ${a.type}`);
}
return ss(Z(r[0].position.start, ie(r).position.end), e.transformContentProperties(t7, n.tokens), r);
}
function Qs(t7, e, n) {
return { type: "plain", position: t7, leadingComments: [], trailingComment: null, ...e, value: n };
}
function no(t7, e, n) {
for (let s = e; s >= 0; s--) if (n.test(t7[s])) return s;
return -1;
}
function so(t7, e, n) {
if (t7.range[0] === t7.range[1]) {
let r = no(e.text, t7.range[0] - 1, /\S/u) + 1;
return Qs(e.transformRange([r, r]), e.transformContentProperties(t7, n.tokens), "");
}
let s = t7.srcToken;
if (!s || s.type !== "scalar") throw new Error("Expected plain scalar srcToken");
for (let r of D(s.end, e)) throw new Error(`Unexpected token type in plain scalar end: ${r.type}`);
return Qs(e.transformRange(t7.range), e.transformContentProperties(t7, n.tokens), t7.source);
}
function ro(t7) {
return { ...t7, type: "quoteDouble" };
}
function io(t7, e, n) {
return { type: "quoteValue", position: t7, ...e, leadingComments: [], trailingComment: null, value: n };
}
function is(t7, e, n, s) {
for (let r of D(e.end, n)) throw new Error(`Unexpected token type in quote value end: ${r.type}`);
return io(n.transformRange(t7.range), n.transformContentProperties(t7, s.tokens), t7.source);
}
function oo(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "double-quoted-scalar") throw new Error("Expected double-quoted scalar srcToken");
return ro(is(t7, s, e, n));
}
function ao(t7) {
return { ...t7, type: "quoteSingle" };
}
function lo(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "single-quoted-scalar") throw new Error("Expected single-quoted scalar srcToken");
return ao(is(t7, s, e, n));
}
function co(t7, e, n) {
return { type: "sequence", position: t7, leadingComments: [], endComments: [], ...e, children: n };
}
function fo(t7, e) {
return { type: "sequenceItem", position: t7, leadingComments: [], trailingComment: null, endComments: [], children: e ? [e] : [] };
}
function uo(t7, e, n) {
let s = t7.srcToken;
if (!s || s.type !== "block-seq") throw new Error("Expected block sequence srcToken");
let r = t7.items.map((i, o) => {
let a = s.items[o], l = [], c = null;
for (let f of q(a.start)) {
if (Ee(f)) {
l.push(f);
continue;
}
if (f.type === "seq-item-ind") {
c = f;
continue;
}
throw new Error(`Unexpected token type in sequence item start: ${f.type}`);
}
let u = Qa(i, e, { tokens: l });
return fo(Z(c ? e.transformOffset(c.offset) : u.position.start, u?.position.end ?? e.transformOffset(c.offset + c.source.length)), u);
});
if (t7.items.length < s.items.length) for (let i = t7.items.length; i < s.items.length; i++) {
let o = s.items[i];
for (let a of D(o.start, e)) throw new Error(`Unexpected token type in collection item start: ${a.type}`);
}
return co(Z(r[0].position.start, ie(r).position.end), e.transformContentProperties(t7, n.tokens), r);
}
function Qa(t7, e, n) {
if (!T(t7)) return It(t7, n) ? (D(n.tokens, e), null) : e.transformNode(t7, n);
let s = t7.srcToken, r = Ce(t7, s, e, rs);
return ss(r.position, e.transformContentProperties(t7.key, n.tokens), [r]);
}
function po(t7, e, n) {
if (t7 == null) return null;
if (H(t7)) return Vr(t7, e, n);
if (U(t7)) return t7.flow ? Zr(t7, e, n) : to(t7, e, n);
if (J(t7)) return t7.flow ? eo(t7, e, n) : uo(t7, e, n);
if (C(t7)) {
switch (t7.type) {
case "BLOCK_FOLDED":
return Hr(t7, e, n);
case "BLOCK_LITERAL":
return Wr(t7, e, n);
case "PLAIN":
return so(t7, e, n);
case "QUOTE_DOUBLE":
return oo(t7, e, n);
case "QUOTE_SINGLE":
return lo(t7, e, n);
}
throw new Error(`Unexpected scalar type: ${t7.type}`);
}
throw new Error("Unexpected unknown node type");
}
function It(t7, e) {
return !t7 || t7.range[0] === t7.range[1] && e.tokens.every((n) => n.type === "comment");
}
function ho(t7, e, n, s, r, i) {
return { type: "document", position: t7, trailingComment: i, directivesEndMarker: e, documentEndMarker: n, children: [s, r] };
}
function go(t7, e, n) {
return { type: "documentBody", position: t7, endComments: n, children: e ? [e] : [] };
}
function yo(t7, e, n) {
for (let s = e; s < t7.length; s++) if (n.test(t7[s])) return s;
return null;
}
function wo(t7, e, n, s, r, i, o) {
let { documentTrailingComment: a, endComments: l, propTokens: c } = Ja(e, n, r, i, o), u = s.contents && (s.contents.range[0] < s.contents.range[1] || c.some((g) => g.type === "tag" || g.type === "anchor")), f = u ? o.transformNode(s.contents, { tokens: c }) : null;
if (!u) for (let g of D(c, o)) throw new Error(`Unexpected token type in empty document body: ${g.type}`);
let { position: p, documentEndPoint: h } = Wa(t7, s, f, i, o);
return { documentBody: go(p, f, l), documentEndPoint: h, documentTrailingComment: a };
}
function Ja(t7, e, n, s, r) {
let i = [], o = [], a = [];
for (let c of t7) {
if (Ee(c)) {
a.push(c);
continue;
}
throw new Error(`Unexpected token type: ${c.type}`);
}
for (let c of D(n, r)) throw new Error(`Unexpected token type: ${c.type}`);
let l = s ? r.transformOffset(s.offset) : null;
if (e) for (let c of q(e.end, s?.end)) {
if (c.type === "comment") {
let u = r.transformComment(c);
l ? l.line === u.position.start.line ? o.push(u) : u.position.start.line < l.line && i.push(u) : i.push(u);
continue;
}
throw new Error(`Unexpected token type: ${c.type}`);
}
if (o.length > 1) throw new Error(`Unexpected multiple document trailing comments at ${ve(o[1].position.start)}`);
return { propTokens: a, endComments: i, documentTrailingComment: ie(o) || null };
}
function Wa(t7, e, n, s, r) {
let i = s ? Math.max(0, s.offset - 1) : yo(r.text, e.range[2], /\S/u) ?? r.text.length;
r.text[i - 1] === "\r" && i--;
let o = n !== null ? n.position.start.offset : i;
if (t7) {
let l = t7.offset + t7.source.length + 1;
o < l && l <= i && (o = l);
}
let a = r.transformRange([o, i]);
return { position: a, documentEndPoint: s ? r.transformOffset(s.offset + s.source.length) : a.end };
}
function bo(t7, e, n, s) {
return { type: "documentHead", position: t7, endComments: n, trailingComment: s, children: e };
}
function ko(t7, e, n) {
return { type: "directive", position: t7, leadingComments: [], trailingComment: null, name: e, parameters: n };
}
function So(t7, e) {
let n = t7.source.trim().split(/[\t ]+/), s = n.shift().replace(/^%/, "");
return ko(e.transformRange([t7.offset, t7.offset + t7.source.length]), s, n);
}
function Eo(t7, e, n, s) {
let { directives: r, endCommentCandidates: i } = Xa(t7, s), o = [], a = null;
if (e) {
for (let u of q(e.start)) if (o.push(u), !a && u.type === "doc-start") {
for (let f of o) if (f.type === "comment") {
let p = s.transformComment(f);
i.push(p);
}
o = [], a = u;
}
}
let l = za(r, n, a, s), c = null;
if (a && o.length > 0) {
let u = o[0];
u.type === "comment" && s.transformOffset(u.offset).line === l.end.line && (c = s.transformComment(u), o.shift());
}
return { documentHead: bo(l, r, a ? i : [], c), docStart: a, tokensBeforeBody: o };
}
function Xa(t7, e) {
let n = [], s = [], r = null;
for (let i of t7) if (i.type === "comment") {
let o = e.transformComment(i);
r && r.position.end.line === o.position.start.line && !r.trailingComment ? (r.trailingComment = o, r.position.end = o.position.end) : s.push(o);
} else {
let o = So(i, e);
n.push(o), r = o, s = [];
}
return { directives: n, endCommentCandidates: s };
}
function za(t7, e, n, s) {
let r = n ? [n.offset, n.offset + n.source.length] : e.contents ? [e.contents.range[0], e.contents.range[0]] : [e.range[0], e.range[0]];
return t7.length !== 0 && (r[0] = t7[0].position.start.offset), s.transformRange(r);
}
function Co(t7, e) {
let { documentHead: n, tokensBeforeBody: s, docStart: r } = Eo(t7.tokensBeforeBody, t7.cstNode, t7.node, e), { documentBody: i, documentEndPoint: o, documentTrailingComment: a } = wo(r, s, t7.cstNode, t7.node, t7.tokensAfterBody, t7.documentEnd, e);
return ho(Z(n.position.start, o), !!r, !!t7.documentEnd, n, i, a);
}
function No(t7, e, n) {
if (t7.length === 0) return [];
let s = [], r = [], i = [], o = null, a = (l) => {
let c = { tokensBeforeBody: [...i, ...r], cstNode: l, node: t7[s.length], tokensAfterBody: [], documentEnd: null };
return s.push(c), i.length = 0, r.length = 0, c;
};
for (let l of q(e)) {
if (l.type === "document") {
if (s.length >= t7.length) throw new Error(`Unexpected 'document' token at ${ve(n.transformOffset(l.offset))}`);
o = a(l);
continue;
}
if (l.type === "comment") {
r.push(l);
continue;
}
if (l.type === "directive") {
i.push(...r, l), r.length = 0;
continue;
}
if (l.type === "doc-end") {
if (!o || o.documentEnd) throw new Error(`Unexpected 'doc-end' token at ${ve(n.transformOffset(l.offset))}`);
o.tokensAfterBody = [...r], r.length = 0, o.documentEnd = l;
continue;
}
}
if (i.length > 0) {
let [l] = i;
throw new Error(`Unexpected '${l.type}' token at ${ve(n.transformOffset(l.offset))}`);
}
return r.length > 0 && (o || (o = a(null)), r.length > 0 && (o.tokensAfterBody.push(...r), r.length = 0)), s.map((l) => Co(l, n));
}
function Hs(t7, e, n, s) {
let r = e(t7);
return (i) => {
s(r, i) && n(t7, r = i);
};
}
function Js(t7) {
if (t7 === null || !("children" in t7)) return;
let e = t7.children;
if (e.forEach(Js), t7.type === "document") {
let [i, o] = t7.children;
i.position.start.offset === i.position.end.offset ? i.position.start = i.position.end = o.position.start : o.position.start.offset === o.position.end.offset && (o.position.start = o.position.end = i.position.end);
}
let n = Hs(t7.position, Za, el, sl), s = Hs(t7.position, tl, nl, rl);
"endComments" in t7 && t7.endComments.length !== 0 && (n(t7.endComments[0].position.start), s(ie(t7.endComments).position.end));
let r = e.filter((i) => i !== null);
if (r.length !== 0) {
let i = r[0], o = ie(r);
n(i.position.start), s(o.position.end), "leadingComments" in i && i.leadingComments.length !== 0 && n(i.leadingComments[0].position.start), "tag" in i && i.tag && n(i.tag.position.start), "anchor" in i && i.anchor && n(i.anchor.position.start), "trailingComment" in o && o.trailingComment && s(o.trailingComment.position.end);
}
}
function Za(t7) {
return t7.start;
}
function el(t7, e) {
t7.start = e;
}
function tl(t7) {
return t7.end;
}
function nl(t7, e) {
t7.end = e;
}
function sl(t7, e) {
return e.offset < t7.offset;
}
function rl(t7, e) {
return e.offset > t7.offset;
}
function Ws(t7, e) {
let n = new qe(), s = new mo(t7, n), r = new Ie(n.addNewLine), i = new _e({ keepSourceTokens: true, uniqueKeys: e?.uniqueKeys, lineCounter: n, merge: true }), o = [], a = [...r.parse(t7)];
for (let f of i.compose(a, true, t7.length)) {
let { errors: p } = f;
if (p.length > 0) throw new Ot(s, p[0]);
o.push(f);
}
let l = No(o, a, s), c = s.comments.sort((f, p) => f.position.start.offset - p.position.end.offset), u = Br(s.transformRange([0, t7.length]), l, c);
return xr(u), Js(u), u;
}
function il(t7, e) {
let n = new SyntaxError(t7 + " (" + e.loc.start.line + ":" + e.loc.start.column + ")");
return Object.assign(n, e);
}
function al(t7) {
let e;
try {
e = Ws(t7, ol);
} catch (n) {
throw n instanceof Ot ? Ao(n.message, { loc: n.position, cause: n }) : n;
}
return delete e.comments, e;
}
var Oo, Qt, To, Ht, Io, V, Lo, Po, Jt, vo, dt, gt, yt, Wt, Xt, Ue, zt, je, Ve, Ge, Zt, Qe, en, ke, tn, He, nn, rn, xo, os, Zs, re, on, tr, nr, kt, Se, ln, Bo, O, Ro, wt, bc, cs, kc, Sc, or, fs, us, ps, ar, cr, Et, Ko, fr, P, ur, Uo, pr, Nt, mr, hr, dr, gr, yr, wr, br, kr, Sr, We, Go, _r, Ir, Lr, ia, Pr, vr, dn, oa, Dr, Xs, Ot, Gs, wn, bn, oe, bs, ee, Ne, G, H, ne, U, T, C, J, kn, W, ni, me, ma, ha, he, xe, de, Cn, y, da, nt, tt, ai, ge, Es, Nn, vt, Tn, On, Ns, Ln, le, fi, v, x, ce, F, fe, $e, Ke, Mt, Mn, $n, Bn, Rn, Os, qn, Fn, Kn, mi, Yn, Na, Aa, di, $t, Bt, it, Rt, Ls, Ps, yi, wi, bi, qt, ki, Si, Ei, Ci, ot, Ft, jn, Vn, at, xs, Ai, Ti, Oi, Ta, lt, ye, ft, te, ut, Kt, Ii, Ms, $s, Da, Ba, _e, Us, Yi, Ks, Fa, Ui, jt, Vt, Gt, pt, Ka, Ya, Vi, ja, Zn, Va, js, mt, qe, Ie, Zi, Ha, mo, Ao, ol, ll, cl, fl;
var init_yaml = __esm({
"../../node_modules/.pnpm/prettier@3.9.9/node_modules/prettier/plugins/yaml.mjs"() {
init_esm_shims();
Oo = Object.defineProperty;
Qt = (t7, e) => {
for (var n in e) Oo(t7, n, { get: e[n], enumerable: true });
};
To = {};
Qt(To, { __parsePrettierYamlConfig: () => fl, languages: () => vr, options: () => Dr, parsers: () => Xs, printers: () => cl });
Ht = (t7, e) => (n, s, ...r) => n | 1 && s == null ? void 0 : (e.call(s) ?? s[t7]).apply(s, r);
Io = Ht("at", function() {
if (Array.isArray(this) || typeof this == "string") return _o;
});
V = Io;
Lo = String.prototype.replaceAll ?? function(t7, e) {
return t7.global ? this.replace(t7, e) : this.split(t7).join(e);
};
Po = Ht("replaceAll", function() {
if (typeof this == "string") return Lo;
});
Jt = Po;
vo = () => {
};
dt = vo;
gt = "string";
yt = "array";
Wt = "cursor";
Xt = "indent";
Ue = "align";
zt = "trim";
je = "group";
Ve = "fill";
Ge = "if-break";
Zt = "indent-if-break";
Qe = "line-suffix";
en = "line-suffix-boundary";
ke = "line";
tn = "label";
He = "break-parent";
nn = /* @__PURE__ */ new Set([Wt, Xt, Ue, zt, je, Ve, Ge, Zt, Qe, en, ke, tn, He]);
rn = Do;
xo = (t7) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(t7);
os = class extends Error {
name = "InvalidDocError";
constructor(e) {
super(Mo(e)), this.doc = e;
}
};
Zs = os;
re = dt;
on = dt;
tr = dt;
nr = dt;
kt = { type: He };
Se = { type: ke };
ln = { type: ke, soft: true };
Bo = { type: ke, hard: true };
O = [Bo, kt];
Ro = { type: ke, hard: true, literal: true };
wt = [Ro, kt];
bc = cn(/\s/);
cs = cn(" ");
kc = cn(",; ");
Sc = cn(/[^\n\r]/);
or = (t7) => t7 === `
` || t7 === "\r" || t7 === "\u2028" || t7 === "\u2029";
fs = qo;
us = Fo;
ps = class extends Error {
name = "UnexpectedNodeError";
constructor(e, n, s = "type") {
super(`Unexpected ${n} node ${s}: ${JSON.stringify(e[s])}.`), this.node = e;
}
};
ar = ps;
lr.getVisitorKeys = () => [];
cr = lr;
Et = null;
Ko = 10;
for (let t7 = 0; t7 <= Ko; t7++) Ct();
fr = Yo;
P = [["children", "anchor", "tag", "indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"], ["anchor", "tag", "indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"], ["key", "value", "children", "anchor", "tag", "indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"], ["content", "children", "anchor", "tag", "indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"], ["indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"]];
ur = { root: P[0], document: ["head", "body", "children", "anchor", "tag", "indicatorComment", "leadingComments", "middleComments", "trailingComment", "endComments"], documentHead: P[0], documentBody: P[0], directive: P[1], alias: P[1], blockLiteral: P[1], blockFolded: P[0], plain: P[0], quoteSingle: P[1], quoteDouble: P[1], mapping: P[0], mappingItem: P[2], mappingKey: P[3], mappingValue: P[3], sequence: P[0], sequenceItem: P[3], flowMapping: P[0], flowMappingItem: P[2], flowSequence: P[0], flowSequenceItem: P[3], comment: P[1], tag: P[4], anchor: P[4] };
Uo = fr(ur);
pr = Uo;
Nt = (t7) => t7.position.start.offset;
mr = (t7) => t7.position.end.offset;
hr = "format";
dr = /^\s*#[^\S\n]*@(?:noformat|noprettier)\s*?(?:\n|$)/;
gr = /^\s*#[^\S\n]*@(?:format|prettier)\s*?(?:\n|$)/;
yr = /^\s*@(?:format|prettier)\s*$/;
wr = (t7) => yr.test(t7);
br = (t7) => gr.test(t7);
kr = (t7) => dr.test(t7);
Sr = (t7) => `# @${hr}
${t7}`;
hs.ignoredProperties = /* @__PURE__ */ new Set(["position"]);
We = jo;
Go = /* @__PURE__ */ new WeakMap();
_r = Qo;
Ir = Jo;
Lr = zo;
ia = { preprocess: Lr, embed: cr, print: ea, massageAstNode: hs, insertPragma: Sr, getVisitorKeys: pr };
Pr = ia;
vr = [{ name: "YAML", type: "data", aceMode: "yaml", extensions: [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yaml.sed", ".yml.mysql"], filenames: [".clang-format", ".clang-tidy", ".clangd", ".gemrc", "CITATION.cff", "glide.lock", "pixi.lock", ".prettierrc", ".stylelintrc", ".lintstagedrc"], tmScope: "source.yaml", aliases: ["yml"], codemirrorMode: "yaml", codemirrorMimeType: "text/x-yaml", parsers: ["yaml"], vscodeLanguageIds: ["yaml", "ansible", "dockercompose", "github-actions-workflow", "home-assistant"], linguistLanguageId: 407 }];
dn = { bracketSpacing: { category: "Common", type: "boolean", default: true, description: "Print spaces between brackets.", oppositeDescription: "Do not print spaces between brackets." }, objectWrap: { category: "Common", type: "choice", default: "preserve", description: "How to wrap object literals.", choices: [{ value: "preserve", description: "Keep as multi-line, if there is a newline between the opening brace and first property." }, { value: "collapse", description: "Fit to a single line when possible." }] }, singleQuote: { category: "Common", type: "boolean", default: false, description: "Use single quotes instead of double quotes." }, proseWrap: { category: "Common", type: "choice", default: "preserve", description: "How to wrap prose.", choices: [{ value: "always", description: "Wrap prose if it exceeds the print width." }, { value: "never", description: "Do not wrap prose." }, { value: "preserve", description: "Wrap prose as-is." }] }, bracketSameLine: { category: "Common", type: "boolean", default: false, description: "Put > of opening tags on the last line instead of on a new line." }, singleAttributePerLine: { category: "Common", type: "boolean", default: false, description: "Enforce single attribute per line in HTML, Vue and JSX." } };
oa = { bracketSpacing: dn.bracketSpacing, singleQuote: dn.singleQuote, proseWrap: dn.proseWrap };
Dr = oa;
Xs = {};
Qt(Xs, { yaml: () => ll });
Ot = class extends SyntaxError {
name = "YAMLSyntaxError";
code;
source;
position;
constructor(t7, e) {
super(e.message, { cause: e }), this.cause ?? (this.cause = e), this.code = e.code, this.source = t7.text, this.position = t7.transformRange(e.pos);
}
};
Gs = {};
Qt(Gs, { Alias: () => de, CST: () => Us, Composer: () => _e, Document: () => ye, Lexer: () => mt, LineCounter: () => qe, Pair: () => v, Parser: () => Ie, Scalar: () => y, Schema: () => lt, YAMLError: () => ft, YAMLMap: () => x, YAMLParseError: () => te, YAMLSeq: () => F, YAMLWarning: () => ut, isAlias: () => H, isCollection: () => I, isDocument: () => ne, isMap: () => U, isNode: () => _, isPair: () => T, isScalar: () => C, isSeq: () => J, parse: () => Xi, parseAllDocuments: () => Wi, parseDocument: () => Vs, stringify: () => zi, visit: () => ae, visitAsync: () => Lt });
wn = /* @__PURE__ */ Symbol.for("yaml.alias");
bn = /* @__PURE__ */ Symbol.for("yaml.document");
oe = /* @__PURE__ */ Symbol.for("yaml.map");
bs = /* @__PURE__ */ Symbol.for("yaml.pair");
ee = /* @__PURE__ */ Symbol.for("yaml.scalar");
Ne = /* @__PURE__ */ Symbol.for("yaml.seq");
G = /* @__PURE__ */ Symbol.for("yaml.node.type");
H = (t7) => !!t7 && typeof t7 == "object" && t7[G] === wn;
ne = (t7) => !!t7 && typeof t7 == "object" && t7[G] === bn;
U = (t7) => !!t7 && typeof t7 == "object" && t7[G] === oe;
T = (t7) => !!t7 && typeof t7 == "object" && t7[G] === bs;
C = (t7) => !!t7 && typeof t7 == "object" && t7[G] === ee;
J = (t7) => !!t7 && typeof t7 == "object" && t7[G] === Ne;
kn = (t7) => (C(t7) || I(t7)) && !!t7.anchor;
W = /* @__PURE__ */ Symbol("break visit");
ni = /* @__PURE__ */ Symbol("skip children");
me = /* @__PURE__ */ Symbol("remove node");
ae.BREAK = W;
ae.SKIP = ni;
ae.REMOVE = me;
Lt.BREAK = W;
Lt.SKIP = ni;
Lt.REMOVE = me;
ma = { "!": "%21", ",": "%2C", "[": "%5B", "]": "%5D", "{": "%7B", "}": "%7D" };
ha = (t7) => t7.replace(/[!,[\]{}]/g, (e) => ma[e]);
he = class t {
constructor(e, n) {
this.docStart = null, this.docEnd = false, this.yaml = Object.assign({}, t.defaultYaml, e), this.tags = Object.assign({}, t.defaultTags, n);
}
clone() {
let e = new t(this.yaml, this.tags);
return e.docStart = this.docStart, e;
}
atDocument() {
let e = new t(this.yaml, this.tags);
switch (this.yaml.version) {
case "1.1":
this.atNextDocument = true;
break;
case "1.2":
this.atNextDocument = false, this.yaml = { explicit: t.defaultYaml.explicit, version: "1.2" }, this.tags = Object.assign({}, t.defaultTags);
break;
}
return e;
}
add(e, n) {
this.atNextDocument && (this.yaml = { explicit: t.defaultYaml.explicit, version: "1.1" }, this.tags = Object.assign({}, t.defaultTags), this.atNextDocument = false);
let s = e.trim().split(/[ \t]+/), r = s.shift();
switch (r) {
case "%TAG": {
if (s.length !== 2 && (n(0, "%TAG directive should contain exactly two parts"), s.length < 2)) return false;
let [i, o] = s;
return this.tags[i] = o, true;
}
case "%YAML": {
if (this.yaml.explicit = true, s.length !== 1) return n(0, "%YAML directive should contain exactly one part"), false;
let [i] = s;
if (i === "1.1" || i === "1.2") return this.yaml.version = i, true;
{
let o = /^\d+\.\d+$/.test(i);
return n(6, `Unsupported YAML version ${i}`, o), false;
}
}
default:
return n(0, `Unknown directive ${r}`, true), false;
}
}
tagName(e, n) {
if (e === "!") return "!";
if (e[0] !== "!") return n(`Not a valid tag: ${e}`), null;
if (e[1] === "<") {
let o = e.slice(2, -1);
return o === "!" || o === "!!" ? (n(`Verbatim tags aren't resolved, so ${e} is invalid.`), null) : (e[e.length - 1] !== ">" && n("Verbatim tags must end with a >"), o);
}
let [, s, r] = e.match(/^(.*!)([^!]*)$/s);
r || n(`The ${e} tag has no suffix`);
let i = this.tags[s];
if (i) try {
return i + decodeURIComponent(r);
} catch (o) {
return n(String(o)), null;
}
return s === "!" ? e : (n(`Could not resolve tag: ${e}`), null);
}
tagString(e) {
for (let [n, s] of Object.entries(this.tags)) if (e.startsWith(s)) return n + ha(e.substring(s.length));
return e[0] === "!" ? e : `!<${e}>`;
}
toString(e) {
let n = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], s = Object.entries(this.tags), r;
if (e && s.length > 0 && _(e.contents)) {
let i = {};
ae(e.contents, (o, a) => {
_(a) && a.tag && (i[a.tag] = true);
}), r = Object.keys(i);
} else r = [];
for (let [i, o] of s) i === "!!" && o === "tag:yaml.org,2002:" || (!e || r.some((a) => a.startsWith(o))) && n.push(`%TAG ${i} ${o}`);
return n.join(`
`);
}
};
he.defaultYaml = { explicit: false, version: "1.2" };
he.defaultTags = { "!!": "tag:yaml.org,2002:" };
xe = class {
constructor(e) {
Object.defineProperty(this, G, { value: e });
}
clone() {
let e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
return this.range && (e.range = this.range.slice()), e;
}
toJS(e, { mapAsMap: n, maxAliasCount: s, onAnchor: r, reviver: i } = {}) {
if (!ne(e)) throw new TypeError("A document argument is required");
let o = { anchors: /* @__PURE__ */ new Map(), doc: e, keep: true, mapAsMap: n === true, mapKeyWarned: false, maxAliasCount: typeof s == "number" ? s : 100 }, a = B(this, "", o);
if (typeof r == "function") for (let { count: l, res: c } of o.anchors.values()) r(c, l);
return typeof i == "function" ? De(i, { "": a }, "", a) : a;
}
};
de = class extends xe {
constructor(e) {
super(wn), this.source = e, Object.defineProperty(this, "tag", { set() {
throw new Error("Alias nodes cannot have tags");
} });
}
resolve(e, n) {
if (n?.maxAliasCount === 0) throw new ReferenceError("Alias resolution is disabled");
let s;
n?.aliasResolveCache ? s = n.aliasResolveCache : (s = [], ae(e, { Node: (i, o) => {
(H(o) || kn(o)) && s.push(o);
} }), n && (n.aliasResolveCache = s));
let r;
for (let i of s) {
if (i === this) break;
i.anchor === this.source && (r = i);
}
return r;
}
toJSON(e, n) {
if (!n) return { source: this.source };
let { anchors: s, doc: r, maxAliasCount: i } = n, o = this.resolve(r, n);
if (!o) {
let l = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new ReferenceError(l);
}
let a = s.get(o);
if (a || (B(o, null, n), a = s.get(o)), a?.res === void 0) {
let l = "This should not happen: Alias anchor was not resolved?";
throw new ReferenceError(l);
}
if (i >= 0 && (a.count += 1, a.aliasCount === 0 && (a.aliasCount = En(r, o, s)), a.count * a.aliasCount > i)) {
let l = "Excessive alias count indicates a resource exhaustion attack";
throw new ReferenceError(l);
}
return a.res;
}
toString(e, n, s) {
let r = `*${this.source}`;
if (e) {
if (Sn(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
let i = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new Error(i);
}
if (e.implicitKey) return `${r} `;
}
return r;
}
};
Cn = (t7) => !t7 || typeof t7 != "function" && typeof t7 != "object";
y = class extends xe {
constructor(e) {
super(ee), this.value = e;
}
toJSON(e, n) {
return n?.keep ? this.value : B(this.value, e, n);
}
toString() {
return String(this.value);
}
};
y.BLOCK_FOLDED = "BLOCK_FOLDED";
y.BLOCK_LITERAL = "BLOCK_LITERAL";
y.PLAIN = "PLAIN";
y.QUOTE_DOUBLE = "QUOTE_DOUBLE";
y.QUOTE_SINGLE = "QUOTE_SINGLE";
da = "tag:yaml.org,2002:";
nt = (t7) => t7 == null || typeof t7 == "object" && !!t7[Symbol.iterator]().next().done;
tt = class extends xe {
constructor(e, n) {
super(e), Object.defineProperty(this, "schema", { value: n, configurable: true, enumerable: false, writable: true });
}
clone(e) {
let n = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
return e && (n.schema = e), n.items = n.items.map((s) => _(s) || T(s) ? s.clone(e) : s), this.range && (n.range = this.range.slice()), n;
}
addIn(e, n) {
if (nt(e)) this.add(n);
else {
let [s, ...r] = e, i = this.get(s, true);
if (I(i)) i.addIn(r, n);
else if (i === void 0 && this.schema) this.set(s, Pt(this.schema, r, n));
else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`);
}
}
deleteIn(e) {
let [n, ...s] = e;
if (s.length === 0) return this.delete(n);
let r = this.get(n, true);
if (I(r)) return r.deleteIn(s);
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);
}
getIn(e, n) {
let [s, ...r] = e, i = this.get(s, true);
return r.length === 0 ? !n && C(i) ? i.value : i : I(i) ? i.getIn(r, n) : void 0;
}
hasAllNullValues(e) {
return this.items.every((n) => {
if (!T(n)) return false;
let s = n.value;
return s == null || e && C(s) && s.value == null && !s.commentBefore && !s.comment && !s.tag;
});
}
hasIn(e) {
let [n, ...s] = e;
if (s.length === 0) return this.has(n);
let r = this.get(n, true);
return I(r) ? r.hasIn(s) : false;
}
setIn(e, n) {
let [s, ...r] = e;
if (r.length === 0) this.set(s, n);
else {
let i = this.get(s, true);
if (I(i)) i.setIn(r, n);
else if (i === void 0 && this.schema) this.set(s, Pt(this.schema, r, n));
else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`);
}
}
};
ai = (t7) => t7.replace(/^(?!$)(?: $)?/gm, "#");
ge = (t7, e, n) => t7.endsWith(`
`) ? se(n, e) : n.includes(`
`) ? `
` + se(n, e) : (t7.endsWith(" ") ? "" : " ") + n;
Es = "flow";
Nn = "block";
vt = "quoted";
Tn = (t7, e) => ({ indentAtStart: e ? t7.indent.length : t7.indentAtStart, lineWidth: t7.options.lineWidth, minContentWidth: t7.options.minContentWidth });
On = (t7) => /^(%|---|\.\.\.)/m.test(t7);
try {
Ns = new RegExp(`(^|(?<!
))
+(?!
|$)`, "g");
} catch {
Ns = /\n+(?!\n|$)/g;
}
Ln = "<<";
le = { identify: (t7) => t7 === Ln || typeof t7 == "symbol" && t7.description === Ln, default: "key", tag: "tag:yaml.org,2002:merge", test: /^<<$/, resolve: () => Object.assign(new y(Symbol(Ln)), { addToJSMap: Ts }), stringify: () => Ln };
fi = (t7, e) => (le.identify(e) || C(e) && (!e.type || e.type === y.PLAIN) && le.identify(e.value)) && t7?.doc.schema.tags.some((n) => n.tag === le.tag && n.default);
v = class t2 {
constructor(e, n = null) {
Object.defineProperty(this, G, { value: bs }), this.key = e, this.value = n;
}
clone(e) {
let { key: n, value: s } = this;
return _(n) && (n = n.clone(e)), _(s) && (s = s.clone(e)), new t2(n, s);
}
toJSON(e, n) {
let s = n?.mapAsMap ? /* @__PURE__ */ new Map() : {};
return Pn(n, s, this);
}
toString(e, n, s) {
return e?.doc ? ci(this, e, n, s) : JSON.stringify(this);
}
};
x = class extends tt {
static get tagName() {
return "tag:yaml.org,2002:map";
}
constructor(e) {
super(oe, e), this.items = [];
}
static from(e, n, s) {
let { keepUndefined: r, replacer: i } = s, o = new this(e), a = (l, c) => {
if (typeof i == "function") c = i.call(n, l, c);
else if (Array.isArray(i) && !i.includes(l)) return;
(c !== void 0 || r) && o.items.push(rt(l, c, s));
};
if (n instanceof Map) for (let [l, c] of n) a(l, c);
else if (n && typeof n == "object") for (let l of Object.keys(n)) a(l, n[l]);
return typeof e.sortMapEntries == "function" && o.items.sort(e.sortMapEntries), o;
}
add(e, n) {
let s;
T(e) ? s = e : !e || typeof e != "object" || !("key" in e) ? s = new v(e, e?.value) : s = new v(e.key, e.value);
let r = Me(this.items, s.key), i = this.schema?.sortMapEntries;
if (r) {
if (!n) throw new Error(`Key ${s.key} already set`);
C(r.value) && Cn(s.value) ? r.value.value = s.value : r.value = s.value;
} else if (i) {
let o = this.items.findIndex((a) => i(s, a) < 0);
o === -1 ? this.items.push(s) : this.items.splice(o, 0, s);
} else this.items.push(s);
}
delete(e) {
let n = Me(this.items, e);
return n ? this.items.splice(this.items.indexOf(n), 1).length > 0 : false;
}
get(e, n) {
let r = Me(this.items, e)?.value;
return (!n && C(r) ? r.value : r) ?? void 0;
}
has(e) {
return !!Me(this.items, e);
}
set(e, n) {
this.add(new v(e, n), true);
}
toJSON(e, n, s) {
let r = s ? new s() : n?.mapAsMap ? /* @__PURE__ */ new Map() : {};
n?.onCreate && n.onCreate(r);
for (let i of this.items) Pn(n, r, i);
return r;
}
toString(e, n, s) {
if (!e) return JSON.stringify(this);
for (let r of this.items) if (!T(r)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);
return !e.allNullValues && this.hasAllNullValues(false) && (e = Object.assign({}, e, { allNullValues: true })), Dn(this, e, { blockItemPrefix: "", flowChars: { start: "{", end: "}" }, itemIndent: e.indent || "", onChompKeep: s, onComment: n });
}
};
ce = { collection: "map", default: true, nodeClass: x, tag: "tag:yaml.org,2002:map", resolve(t7, e) {
return U(t7) || e("Expected a mapping for this tag"), t7;
}, createNode: (t7, e, n) => x.from(t7, e, n) };
F = class extends tt {
static get tagName() {
return "tag:yaml.org,2002:seq";
}
constructor(e) {
super(Ne, e), this.items = [];
}
add(e) {
this.items.push(e);
}
delete(e) {
let n = xn(e);
return typeof n != "number" ? false : this.items.splice(n, 1).length > 0;
}
get(e, n) {
let s = xn(e);
if (typeof s != "number") return;
let r = this.items[s];
return !n && C(r) ? r.value : r;
}
has(e) {
let n = xn(e);
return typeof n == "number" && n < this.items.length;
}
set(e, n) {
let s = xn(e);
if (typeof s != "number") throw new Error(`Expected a valid index, not ${e}.`);
let r = this.items[s];
C(r) && Cn(n) ? r.value = n : this.items[s] = n;
}
toJSON(e, n) {
let s = [];
n?.onCreate && n.onCreate(s);
let r = 0;
for (let i of this.items) s.push(B(i, String(r++), n));
return s;
}
toString(e, n, s) {
return e ? Dn(this, e, { blockItemPrefix: "- ", flowChars: { start: "[", end: "]" }, itemIndent: (e.indent || "") + " ", onChompKeep: s, onComment: n }) : JSON.stringify(this);
}
static from(e, n, s) {
let { replacer: r } = s, i = new this(e);
if (n && Symbol.iterator in Object(n)) {
let o = 0;
for (let a of n) {
if (typeof r == "function") {
let l = n instanceof Set ? a : String(o++);
a = r.call(n, l, a);
}
i.items.push(Ae(a, void 0, s));
}
}
return i;
}
};
fe = { collection: "seq", default: true, nodeClass: F, tag: "tag:yaml.org,2002:seq", resolve(t7, e) {
return J(t7) || e("Expected a sequence for this tag"), t7;
}, createNode: (t7, e, n) => F.from(t7, e, n) };
$e = { identify: (t7) => typeof t7 == "string", default: true, tag: "tag:yaml.org,2002:str", resolve: (t7) => t7, stringify(t7, e, n, s) {
return e = Object.assign({ actualString: true }, e), Te(t7, e, n, s);
} };
Ke = { identify: (t7) => t7 == null, createNode: () => new y(null), default: true, tag: "tag:yaml.org,2002:null", test: /^(?:~|[Nn]ull|NULL)?$/, resolve: () => new y(null), stringify: ({ source: t7 }, e) => typeof t7 == "string" && Ke.test.test(t7) ? t7 : e.options.nullStr };
Mt = { identify: (t7) => typeof t7 == "boolean", default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, resolve: (t7) => new y(t7[0] === "t" || t7[0] === "T"), stringify({ source: t7, value: e }, n) {
if (t7 && Mt.test.test(t7)) {
let s = t7[0] === "t" || t7[0] === "T";
if (e === s) return t7;
}
return e ? n.options.trueStr : n.options.falseStr;
} };
Mn = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, resolve: (t7) => t7.slice(-3).toLowerCase() === "nan" ? NaN : t7[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, stringify: j };
$n = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", format: "EXP", test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/, resolve: (t7) => parseFloat(t7), stringify(t7) {
let e = Number(t7.value);
return isFinite(e) ? e.toExponential() : j(t7);
} };
Bn = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/, resolve(t7) {
let e = new y(parseFloat(t7)), n = t7.indexOf(".");
return n !== -1 && t7[t7.length - 1] === "0" && (e.minFractionDigits = t7.length - n - 1), e;
}, stringify: j };
Rn = (t7) => typeof t7 == "bigint" || Number.isInteger(t7);
Os = (t7, e, n, { intAsBigInt: s }) => s ? BigInt(t7) : parseInt(t7.substring(e), n);
qn = { identify: (t7) => Rn(t7) && t7 >= 0, default: true, tag: "tag:yaml.org,2002:int", format: "OCT", test: /^0o[0-7]+$/, resolve: (t7, e, n) => Os(t7, 2, 8, n), stringify: (t7) => pi(t7, 8, "0o") };
Fn = { identify: Rn, default: true, tag: "tag:yaml.org,2002:int", test: /^[-+]?[0-9]+$/, resolve: (t7, e, n) => Os(t7, 0, 10, n), stringify: j };
Kn = { identify: (t7) => Rn(t7) && t7 >= 0, default: true, tag: "tag:yaml.org,2002:int", format: "HEX", test: /^0x[0-9a-fA-F]+$/, resolve: (t7, e, n) => Os(t7, 2, 16, n), stringify: (t7) => pi(t7, 16, "0x") };
mi = [ce, fe, $e, Ke, Mt, qn, Fn, Kn, Mn, $n, Bn];
Yn = ({ value: t7 }) => JSON.stringify(t7);
Na = [{ identify: (t7) => typeof t7 == "string", default: true, tag: "tag:yaml.org,2002:str", resolve: (t7) => t7, stringify: Yn }, { identify: (t7) => t7 == null, createNode: () => new y(null), default: true, tag: "tag:yaml.org,2002:null", test: /^null$/, resolve: () => null, stringify: Yn }, { identify: (t7) => typeof t7 == "boolean", default: true, tag: "tag:yaml.org,2002:bool", test: /^true$|^false$/, resolve: (t7) => t7 === "true", stringify: Yn }, { identify: hi, default: true, tag: "tag:yaml.org,2002:int", test: /^-?(?:0|[1-9][0-9]*)$/, resolve: (t7, e, { intAsBigInt: n }) => n ? BigInt(t7) : parseInt(t7, 10), stringify: ({ value: t7 }) => hi(t7) ? t7.toString() : JSON.stringify(t7) }, { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, resolve: (t7) => parseFloat(t7), stringify: Yn }];
Aa = { default: true, tag: "", test: /^/, resolve(t7, e) {
return e(`Unresolved plain scalar ${JSON.stringify(t7)}`), t7;
} };
di = [ce, fe].concat(Na, Aa);
$t = { identify: (t7) => t7 instanceof Uint8Array, default: false, tag: "tag:yaml.org,2002:binary", resolve(t7, e) {
if (typeof atob == "function") {
let n = atob(t7.replace(/[\n\r]/g, "")), s = new Uint8Array(n.length);
for (let r = 0; r < n.length; ++r) s[r] = n.charCodeAt(r);
return s;
} else return t7;
}, stringify({ comment: t7, type: e, value: n }, s, r, i) {
if (!n) return "";
let o = n, a;
if (typeof btoa == "function") {
let l = "";
for (let c = 0; c < o.length; ++c) l += String.fromCharCode(o[c]);
a = btoa(l);
} else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
if (e ?? (e = y.BLOCK_LITERAL), e !== y.QUOTE_DOUBLE) {
let l = Math.max(s.options.lineWidth - s.indent.length, s.options.minContentWidth), c = Math.ceil(a.length / l), u = new Array(c);
for (let f = 0, p = 0; f < c; ++f, p += l) u[f] = a.substr(p, l);
a = u.join(e === y.BLOCK_LITERAL ? `
` : " ");
}
return Te({ comment: t7, type: e, value: a }, s, r, i);
} };
Bt = { collection: "seq", default: false, tag: "tag:yaml.org,2002:pairs", resolve: _s, createNode: Is };
it = class t3 extends F {
constructor() {
super(), this.add = x.prototype.add.bind(this), this.delete = x.prototype.delete.bind(this), this.get = x.prototype.get.bind(this), this.has = x.prototype.has.bind(this), this.set = x.prototype.set.bind(this), this.tag = t3.tag;
}
toJSON(e, n) {
if (!n) return super.toJSON(e);
let s = /* @__PURE__ */ new Map();
n?.onCreate && n.onCreate(s);
for (let r of this.items) {
let i, o;
if (T(r) ? (i = B(r.key, "", n), o = B(r.value, i, n)) : i = B(r, "", n), s.has(i)) throw new Error("Ordered maps must not include duplicate keys");
s.set(i, o);
}
return s;
}
static from(e, n, s) {
let r = Is(e, n, s), i = new this();
return i.items = r.items, i;
}
};
it.tag = "tag:yaml.org,2002:omap";
Rt = { collection: "seq", identify: (t7) => t7 instanceof Map, nodeClass: it, default: false, tag: "tag:yaml.org,2002:omap", resolve(t7, e) {
let n = _s(t7, e), s = [];
for (let { key: r } of n.items) C(r) && (s.includes(r.value) ? e(`Ordered maps must not include duplicate keys: ${r.value}`) : s.push(r.value));
return Object.assign(new it(), n);
}, createNode: (t7, e, n) => it.from(t7, e, n) };
Ls = { identify: (t7) => t7 === true, default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, resolve: () => new y(true), stringify: gi };
Ps = { identify: (t7) => t7 === false, default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/, resolve: () => new y(false), stringify: gi };
yi = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, resolve: (t7) => t7.slice(-3).toLowerCase() === "nan" ? NaN : t7[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, stringify: j };
wi = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", format: "EXP", test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/, resolve: (t7) => parseFloat(t7.replace(/_/g, "")), stringify(t7) {
let e = Number(t7.value);
return isFinite(e) ? e.toExponential() : j(t7);
} };
bi = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/, resolve(t7) {
let e = new y(parseFloat(t7.replace(/_/g, ""))), n = t7.indexOf(".");
if (n !== -1) {
let s = t7.substring(n + 1).replace(/_/g, "");
s[s.length - 1] === "0" && (e.minFractionDigits = s.length);
}
return e;
}, stringify: j };
qt = (t7) => typeof t7 == "bigint" || Number.isInteger(t7);
ki = { identify: qt, default: true, tag: "tag:yaml.org,2002:int", format: "BIN", test: /^[-+]?0b[0-1_]+$/, resolve: (t7, e, n) => Un(t7, 2, 2, n), stringify: (t7) => vs(t7, 2, "0b") };
Si = { identify: qt, default: true, tag: "tag:yaml.org,2002:int", format: "OCT", test: /^[-+]?0[0-7_]+$/, resolve: (t7, e, n) => Un(t7, 1, 8, n), stringify: (t7) => vs(t7, 8, "0") };
Ei = { identify: qt, default: true, tag: "tag:yaml.org,2002:int", test: /^[-+]?[0-9][0-9_]*$/, resolve: (t7, e, n) => Un(t7, 0, 10, n), stringify: j };
Ci = { identify: qt, default: true, tag: "tag:yaml.org,2002:int", format: "HEX", test: /^[-+]?0x[0-9a-fA-F_]+$/, resolve: (t7, e, n) => Un(t7, 2, 16, n), stringify: (t7) => vs(t7, 16, "0x") };
ot = class t4 extends x {
constructor(e) {
super(e), this.tag = t4.tag;
}
add(e) {
let n;
T(e) ? n = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? n = new v(e.key, null) : n = new v(e, null), Me(this.items, n.key) || this.items.push(n);
}
get(e, n) {
let s = Me(this.items, e);
return !n && T(s) ? C(s.key) ? s.key.value : s.key : s;
}
set(e, n) {
if (typeof n != "boolean") throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);
let s = Me(this.items, e);
s && !n ? this.items.splice(this.items.indexOf(s), 1) : !s && n && this.items.push(new v(e));
}
toJSON(e, n) {
return super.toJSON(e, n, Set);
}
toString(e, n, s) {
if (!e) return JSON.stringify(this);
if (this.hasAllNullValues(true)) return super.toString(Object.assign({}, e, { allNullValues: true }), n, s);
throw new Error("Set items must all have null values");
}
static from(e, n, s) {
let { replacer: r } = s, i = new this(e);
if (n && Symbol.iterator in Object(n)) for (let o of n) typeof r == "function" && (o = r.call(n, o, o)), i.items.push(rt(o, null, s));
return i;
}
};
ot.tag = "tag:yaml.org,2002:set";
Ft = { collection: "map", identify: (t7) => t7 instanceof Set, nodeClass: ot, default: false, tag: "tag:yaml.org,2002:set", createNode: (t7, e, n) => ot.from(t7, e, n), resolve(t7, e) {
if (U(t7)) {
if (t7.hasAllNullValues(true)) return Object.assign(new ot(), t7);
e("Set items must all have null values");
} else e("Expected a mapping for this tag");
return t7;
} };
jn = { identify: (t7) => typeof t7 == "bigint" || Number.isInteger(t7), default: true, tag: "tag:yaml.org,2002:int", format: "TIME", test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/, resolve: (t7, e, { intAsBigInt: n }) => Ds(t7, n), stringify: Ni };
Vn = { identify: (t7) => typeof t7 == "number", default: true, tag: "tag:yaml.org,2002:float", format: "TIME", test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/, resolve: (t7) => Ds(t7, false), stringify: Ni };
at = { identify: (t7) => t7 instanceof Date, default: true, tag: "tag:yaml.org,2002:timestamp", test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"), resolve(t7) {
let e = t7.match(at.test);
if (!e) throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
let [, n, s, r, i, o, a] = e.map(Number), l = e[7] ? Number((e[7] + "00").substr(1, 3)) : 0, c = Date.UTC(n, s - 1, r, i || 0, o || 0, a || 0, l), u = e[8];
if (u && u !== "Z") {
let f = Ds(u, false);
Math.abs(f) < 30 && (f *= 60), c -= 6e4 * f;
}
return new Date(c);
}, stringify: ({ value: t7 }) => t7?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? "" };
xs = [ce, fe, $e, Ke, Ls, Ps, ki, Si, Ei, Ci, yi, wi, bi, $t, le, Rt, Bt, Ft, jn, Vn, at];
Ai = /* @__PURE__ */ new Map([["core", mi], ["failsafe", [ce, fe, $e]], ["json", di], ["yaml11", xs], ["yaml-1.1", xs]]);
Ti = { binary: $t, bool: Mt, float: Bn, floatExp: $n, floatNaN: Mn, floatTime: Vn, int: Fn, intHex: Kn, intOct: qn, intTime: jn, map: ce, merge: le, null: Ke, omap: Rt, pairs: Bt, seq: fe, set: Ft, timestamp: at };
Oi = { "tag:yaml.org,2002:binary": $t, "tag:yaml.org,2002:merge": le, "tag:yaml.org,2002:omap": Rt, "tag:yaml.org,2002:pairs": Bt, "tag:yaml.org,2002:set": Ft, "tag:yaml.org,2002:timestamp": at };
Ta = (t7, e) => t7.key < e.key ? -1 : t7.key > e.key ? 1 : 0;
lt = class t5 {
constructor({ compat: e, customTags: n, merge: s, resolveKnownTags: r, schema: i, sortMapEntries: o, toStringDefaults: a }) {
this.compat = Array.isArray(e) ? Gn(e, "compat") : e ? Gn(null, e) : null, this.name = typeof i == "string" && i || "core", this.knownTags = r ? Oi : {}, this.tags = Gn(n, this.name, s), this.toStringOptions = a ?? null, Object.defineProperty(this, oe, { value: ce }), Object.defineProperty(this, ee, { value: $e }), Object.defineProperty(this, Ne, { value: fe }), this.sortMapEntries = typeof o == "function" ? o : o === true ? Ta : null;
}
clone() {
let e = Object.create(t5.prototype, Object.getOwnPropertyDescriptors(this));
return e.tags = this.tags.slice(), e;
}
};
ye = class t6 {
constructor(e, n, s) {
this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, G, { value: bn });
let r = null;
typeof n == "function" || Array.isArray(n) ? r = n : s === void 0 && n && (s = n, n = void 0);
let i = Object.assign({ intAsBigInt: false, keepSourceTokens: false, logLevel: "warn", prettyErrors: true, strict: true, stringKeys: false, uniqueKeys: true, version: "1.2" }, s);
this.options = i;
let { version: o } = i;
s?._directives ? (this.directives = s._directives.atDocument(), this.directives.yaml.explicit && (o = this.directives.yaml.version)) : this.directives = new he({ version: o }), this.setSchema(o, s), this.contents = e === void 0 ? null : this.createNode(e, r, s);
}
clone() {
let e = Object.create(t6.prototype, { [G]: { value: bn } });
return e.commentBefore = this.commentBefore, e.comment = this.comment, e.errors = this.errors.slice(), e.warnings = this.warnings.slice(), e.options = Object.assign({}, this.options), this.directives && (e.directives = this.directives.clone()), e.schema = this.schema.clone(), e.contents = _(this.contents) ? this.contents.clone(e.schema) : this.contents, this.range && (e.range = this.range.slice()), e;
}
add(e) {
ct(this.contents) && this.contents.add(e);
}
addIn(e, n) {
ct(this.contents) && this.contents.addIn(e, n);
}
createAlias(e, n) {
if (!e.anchor) {
let s = ks(this);
e.anchor = !n || s.has(n) ? Ss(n || "a", s) : n;
}
return new de(e.anchor);
}
createNode(e, n, s) {
let r;
if (typeof n == "function") e = n.call({ "": e }, "", e), r = n;
else if (Array.isArray(n)) {
let d = (k) => typeof k == "number" || k instanceof String || k instanceof Number, b = n.filter(d).map(String);
b.length > 0 && (n = n.concat(b)), r = n;
} else s === void 0 && n && (s = n, n = void 0);
let { aliasDuplicateObjects: i, anchorPrefix: o, flow: a, keepUndefined: l, onTagObj: c, tag: u } = s ?? {}, { onAnchor: f, setAnchors: p, sourceObjects: h } = oi(this, o || "a"), g = { aliasDuplicateObjects: i ?? true, keepUndefined: l ?? false, onAnchor: f, onTagObj: c, replacer: r, schema: this.schema, sourceObjects: h }, m = Ae(e, u, g);
return a && I(m) && (m.flow = true), p(), m;
}
createPair(e, n, s = {}) {
let r = this.createNode(e, null, s), i = this.createNode(n, null, s);
return new v(r, i);
}
delete(e) {
return ct(this.contents) ? this.contents.delete(e) : false;
}
deleteIn(e) {
return nt(e) ? this.contents == null ? false : (this.contents = null, true) : ct(this.contents) ? this.contents.deleteIn(e) : false;
}
get(e, n) {
return I(this.contents) ? this.contents.get(e, n) : void 0;
}
getIn(e, n) {
return nt(e) ? !n && C(this.contents) ? this.contents.value : this.contents : I(this.contents) ? this.contents.getIn(e, n) : void 0;
}
has(e) {
return I(this.contents) ? this.contents.has(e) : false;
}
hasIn(e) {
return nt(e) ? this.contents !== void 0 : I(this.contents) ? this.contents.hasIn(e) : false;
}
set(e, n) {
this.contents == null ? this.contents = Pt(this.schema, [e], n) : ct(this.contents) && this.contents.set(e, n);
}
setIn(e, n) {
nt(e) ? this.contents = n : this.contents == null ? this.contents = Pt(this.schema, Array.from(e), n) : ct(this.contents) && this.contents.setIn(e, n);
}
setSchema(e, n = {}) {
typeof e == "number" && (e = String(e));
let s;
switch (e) {
case "1.1":
this.directives ? this.directives.yaml.version = "1.1" : this.directives = new he({ version: "1.1" }), s = { resolveKnownTags: false, schema: "yaml-1.1" };
break;
case "1.2":
case "next":
this.directives ? this.directives.yaml.version = e : this.directives = new he({ version: e }), s = { resolveKnownTags: true, schema: "core" };
break;
case null:
this.directives && delete this.directives, s = null;
break;
default: {
let r = JSON.stringify(e);
throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`);
}
}
if (n.schema instanceof Object) this.schema = n.schema;
else if (s) this.schema = new lt(Object.assign(s, n));
else throw new Error("With a null YAML version, the { schema: Schema } option is required");
}
toJS({ json: e, jsonArg: n, mapAsMap: s, maxAliasCount: r, onAnchor: i, reviver: o } = {}) {
let a = { anchors: /* @__PURE__ */ new Map(), doc: this, keep: !e, mapAsMap: s === true, mapKeyWarned: false, maxAliasCount: typeof r == "number" ? r : 100 }, l = B(this.contents, n ?? "", a);
if (typeof i == "function") for (let { count: c, res: u } of a.anchors.values()) i(u, c);
return typeof o == "function" ? De(o, { "": l }, "", l) : l;
}
toJSON(e, n) {
return this.toJS({ json: true, jsonArg: e, mapAsMap: false, onAnchor: n });
}
toString(e = {}) {
if (this.errors.length > 0) throw new Error("Document with errors cannot be stringified");
if ("indent" in e && (!Number.isInteger(e.indent) || Number(e.indent) <= 0)) {
let n = JSON.stringify(e.indent);
throw new Error(`"indent" option must be a positive integer, not ${n}`);
}
return _i(this, e);
}
};
ft = class extends Error {
constructor(e, n, s, r) {
super(), this.name = e, this.code = s, this.message = r, this.pos = n;
}
};
te = class extends ft {
constructor(e, n, s) {
super("YAMLParseError", e, n, s);
}
};
ut = class extends ft {
constructor(e, n, s) {
super("YAMLWarning", e, n, s);
}
};
Kt = (t7, e) => (n) => {
if (n.pos[0] === -1) return;
n.linePos = n.pos.map((a) => e.linePos(a));
let { line: s, col: r } = n.linePos[0];
n.message += ` at line ${s}, column ${r}`;
let i = r - 1, o = t7.substring(e.lineStarts[s - 1], e.lineStarts[s]).replace(/[\n\r]+$/, "");
if (i >= 60 && o.length > 80) {
let a = Math.min(i - 39, o.length - 79);
o = "\u2026" + o.substring(a), i -= a - 1;
}
if (o.length > 80 && (o = o.substring(0, 79) + "\u2026"), s > 1 && /^ *$/.test(o.substring(0, i))) {
let a = t7.substring(e.lineStarts[s - 2], e.lineStarts[s - 1]);
a.length > 80 && (a = a.substring(0, 79) + `\u2026
`), o = a + o;
}
if (/[^ ]/.test(o)) {
let a = 1, l = n.linePos[1];
l?.line === s && l.col > r && (a = Math.max(1, Math.min(l.col - r, 80 - i)));
let c = " ".repeat(i) + "^".repeat(a);
n.message += `:
${o}
${c}
`;
}
};
Ii = "All mapping items must start at the same column";
Ms = "Block collections are not allowed within flow collections";
$s = (t7) => t7 && (t7.type === "block-map" || t7.type === "block-seq");
Da = { 0: "\0", a: "\x07", b: "\b", e: "\x1B", f: "\f", n: `
`, r: "\r", t: " ", v: "\v", N: "\x85", _: "\xA0", L: "\u2028", P: "\u2029", " ": " ", '"': '"', "/": "/", "\\": "\\", " ": " " };
Ba = { composeNode: qs, composeEmptyNode: Wn };
_e = class {
constructor(e = {}) {
this.doc = null, this.atDirectives = false, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (n, s, r, i) => {
let o = Ut(n);
i ? this.warnings.push(new ut(o, s, r)) : this.errors.push(new te(o, s, r));
}, this.directives = new he({ version: e.version || "1.2" }), this.options = e;
}
decorate(e, n) {
let { comment: s, afterEmptyLine: r } = Bi(this.prelude);
if (s) {
let i = e.contents;
if (n) e.comment = e.comment ? `${e.comment}
${s}` : s;
else if (r || e.directives.docStart || !i) e.commentBefore = s;
else if (I(i) && !i.flow && i.items.length > 0) {
let o = i.items[0];
T(o) && (o = o.key);
let a = o.commentBefore;
o.commentBefore = a ? `${s}
${a}` : s;
} else {
let o = i.commentBefore;
i.commentBefore = o ? `${s}
${o}` : s;
}
}
if (n) {
for (let i = 0; i < this.errors.length; ++i) e.errors.push(this.errors[i]);
for (let i = 0; i < this.warnings.length; ++i) e.warnings.push(this.warnings[i]);
} else e.errors = this.errors, e.warnings = this.warnings;
this.prelude = [], this.errors = [], this.warnings = [];
}
streamInfo() {
return { comment: Bi(this.prelude).comment, directives: this.directives, errors: this.errors, warnings: this.warnings };
}
*compose(e, n = false, s = -1) {
for (let r of e) yield* this.next(r);
yield* this.end(n, s);
}
*next(e) {
switch (e.type) {
case "directive":
this.directives.add(e.source, (n, s, r) => {
let i = Ut(e);
i[0] += n, this.onError(i, "BAD_DIRECTIVE", s, r);
}), this.prelude.push(e.source), this.atDirectives = true;
break;
case "document": {
let n = $i(this.options, this.directives, e, this.onError);
this.atDirectives && !n.directives.docStart && this.onError(e, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"), this.decorate(n, false), this.doc && (yield this.doc), this.doc = n, this.atDirectives = false;
break;
}
case "byte-order-mark":
case "space":
break;
case "comment":
case "newline":
this.prelude.push(e.source);
break;
case "error": {
let n = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message, s = new te(Ut(e), "UNEXPECTED_TOKEN", n);
this.atDirectives || !this.doc ? this.errors.push(s) : this.doc.errors.push(s);
break;
}
case "doc-end": {
if (!this.doc) {
let s = "Unexpected doc-end without preceding document";
this.errors.push(new te(Ut(e), "UNEXPECTED_TOKEN", s));
break;
}
this.doc.directives.docEnd = true;
let n = be(e.end, e.offset + e.source.length, this.doc.options.strict, this.onError);
if (this.decorate(this.doc, true), n.comment) {
let s = this.doc.comment;
this.doc.comment = s ? `${s}
${n.comment}` : n.comment;
}
this.doc.range[2] = n.offset;
break;
}
default:
this.errors.push(new te(Ut(e), "UNEXPECTED_TOKEN", `Unsupported token ${e.type}`));
}
}
*end(e = false, n = -1) {
if (this.doc) this.decorate(this.doc, true), yield this.doc, this.doc = null;
else if (e) {
let s = Object.assign({ _directives: this.directives }, this.options), r = new ye(void 0, s);
this.atDirectives && this.onError(n, "MISSING_CHAR", "Missing directives-end indicator line"), r.range = [0, n, n], this.decorate(r, false), yield r;
}
}
};
Us = {};
Qt(Us, { BOM: () => jt, DOCUMENT: () => Vt, FLOW_END: () => Gt, SCALAR: () => pt, createScalarToken: () => qi, isCollection: () => Ka, isScalar: () => Ya, prettyToken: () => Ua, resolveAsScalar: () => Ri, setScalarValue: () => Fi, stringify: () => Yi, tokenType: () => Ys, visit: () => Re });
Yi = (t7) => "type" in t7 ? zn(t7) : Xn(t7);
Ks = /* @__PURE__ */ Symbol("break visit");
Fa = /* @__PURE__ */ Symbol("skip children");
Ui = /* @__PURE__ */ Symbol("remove item");
Re.BREAK = Ks;
Re.SKIP = Fa;
Re.REMOVE = Ui;
Re.itemAtPath = (t7, e) => {
let n = t7;
for (let [s, r] of e) {
let i = n?.[s];
if (i && "items" in i) n = i.items[r];
else return;
}
return n;
};
Re.parentCollection = (t7, e) => {
let n = Re.itemAtPath(t7, e.slice(0, -1)), s = e[e.length - 1][0], r = n?.[s];
if (r && "items" in r) return r;
throw new Error("Parent collection not found");
};
jt = "\uFEFF";
Vt = "";
Gt = "";
pt = "";
Ka = (t7) => !!t7 && "items" in t7;
Ya = (t7) => !!t7 && (t7.type === "scalar" || t7.type === "single-quoted-scalar" || t7.type === "double-quoted-scalar" || t7.type === "block-scalar");
Vi = new Set("0123456789ABCDEFabcdef");
ja = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
Zn = new Set(",[]{}");
Va = new Set(` ,[]{}
\r `);
js = (t7) => !t7 || Va.has(t7);
mt = class {
constructor() {
this.atEnd = false, this.blockScalarIndent = -1, this.blockScalarKeep = false, this.buffer = "", this.flowKey = false, this.flowLevel = 0, this.indentNext = 0, this.indentValue = 0, this.lineEndPos = null, this.next = null, this.pos = 0;
}
*lex(e, n = false) {
if (e) {
if (typeof e != "string") throw TypeError("source is not a string");
this.buffer = this.buffer ? this.buffer + e : e, this.lineEndPos = null;
}
this.atEnd = !n;
let s = this.next ?? "stream";
for (; s && (n || this.hasChars(1)); ) s = yield* this.parseNext(s);
}
atLineEnd() {
let e = this.pos, n = this.buffer[e];
for (; n === " " || n === " "; ) n = this.buffer[++e];
return !n || n === "#" || n === `
` ? true : n === "\r" ? this.buffer[e + 1] === `
` : false;
}
charAt(e) {
return this.buffer[this.pos + e];
}
continueScalar(e) {
let n = this.buffer[e];
if (this.indentNext > 0) {
let s = 0;
for (; n === " "; ) n = this.buffer[++s + e];
if (n === "\r") {
let r = this.buffer[s + e + 1];
if (r === `
` || !r && !this.atEnd) return e + s + 1;
}
return n === `
` || s >= this.indentNext || !n && !this.atEnd ? e + s : -1;
}
if (n === "-" || n === ".") {
let s = this.buffer.substr(e, 3);
if ((s === "---" || s === "...") && ue(this.buffer[e + 3])) return -1;
}
return e;
}
getLine() {
let e = this.lineEndPos;
return (typeof e != "number" || e !== -1 && e < this.pos) && (e = this.buffer.indexOf(`
`, this.pos), this.lineEndPos = e), e === -1 ? this.atEnd ? this.buffer.substring(this.pos) : null : (this.buffer[e - 1] === "\r" && (e -= 1), this.buffer.substring(this.pos, e));
}
hasChars(e) {
return this.pos + e <= this.buffer.length;
}
setNext(e) {
return this.buffer = this.buffer.substring(this.pos), this.pos = 0, this.lineEndPos = null, this.next = e, null;
}
peek(e) {
return this.buffer.substr(this.pos, e);
}
*parseNext(e) {
switch (e) {
case "stream":
return yield* this.parseStream();
case "line-start":
return yield* this.parseLineStart();
case "block-start":
return yield* this.parseBlockStart();
case "doc":
return yield* this.parseDocument();
case "flow":
return yield* this.parseFlowCollection();
case "quoted-scalar":
return yield* this.parseQuotedScalar();
case "block-scalar":
return yield* this.parseBlockScalar();
case "plain-scalar":
return yield* this.parsePlainScalar();
}
}
*parseStream() {
let e = this.getLine();
if (e === null) return this.setNext("stream");
if (e[0] === jt && (yield* this.pushCount(1), e = e.substring(1)), e[0] === "%") {
let n = e.length, s = e.indexOf("#");
for (; s !== -1; ) {
let i = e[s - 1];
if (i === " " || i === " ") {
n = s - 1;
break;
} else s = e.indexOf("#", s + 1);
}
for (; ; ) {
let i = e[n - 1];
if (i === " " || i === " ") n -= 1;
else break;
}
let r = (yield* this.pushCount(n)) + (yield* this.pushSpaces(true));
return yield* this.pushCount(e.length - r), this.pushNewline(), "stream";
}
if (this.atLineEnd()) {
let n = yield* this.pushSpaces(true);
return yield* this.pushCount(e.length - n), yield* this.pushNewline(), "stream";
}
return yield Vt, yield* this.parseLineStart();
}
*parseLineStart() {
let e = this.charAt(0);
if (!e && !this.atEnd) return this.setNext("line-start");
if (e === "-" || e === ".") {
if (!this.atEnd && !this.hasChars(4)) return this.setNext("line-start");
let n = this.peek(3);
if ((n === "---" || n === "...") && ue(this.charAt(3))) return yield* this.pushCount(3), this.indentValue = 0, this.indentNext = 0, n === "---" ? "doc" : "stream";
}
return this.indentValue = yield* this.pushSpaces(false), this.indentNext > this.indentValue && !ue(this.charAt(1)) && (this.indentNext = this.indentValue), yield* this.parseBlockStart();
}
*parseBlockStart() {
let [e, n] = this.peek(2);
if (!n && !this.atEnd) return this.setNext("block-start");
if ((e === "-" || e === "?" || e === ":") && ue(n)) {
let s = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
return this.indentNext = this.indentValue + 1, this.indentValue += s, "block-start";
}
return "doc";
}
*parseDocument() {
yield* this.pushSpaces(true);
let e = this.getLine();
if (e === null) return this.setNext("doc");
let n = yield* this.pushIndicators();
switch (e[n]) {
case "#":
yield* this.pushCount(e.length - n);
case void 0:
return yield* this.pushNewline(), yield* this.parseLineStart();
case "{":
case "[":
return yield* this.pushCount(1), this.flowKey = false, this.flowLevel = 1, "flow";
case "}":
case "]":
return yield* this.pushCount(1), "doc";
case "*":
return yield* this.pushUntil(js), "doc";
case '"':
case "'":
return yield* this.parseQuotedScalar();
case "|":
case ">":
return n += yield* this.parseBlockScalarHeader(), n += yield* this.pushSpaces(true), yield* this.pushCount(e.length - n), yield* this.pushNewline(), yield* this.parseBlockScalar();
default:
return yield* this.parsePlainScalar();
}
}
*parseFlowCollection() {
let e, n, s = -1;
do
e = yield* this.pushNewline(), e > 0 ? (n = yield* this.pushSpaces(false), this.indentValue = s = n) : n = 0, n += yield* this.pushSpaces(true);
while (e + n > 0);
let r = this.getLine();
if (r === null) return this.setNext("flow");
if ((s !== -1 && s < this.indentNext && r[0] !== "#" || s === 0 && (r.startsWith("---") || r.startsWith("...")) && ue(r[3])) && !(s === this.indentNext - 1 && this.flowLevel === 1 && (r[0] === "]" || r[0] === "}"))) return this.flowLevel = 0, yield Gt, yield* this.parseLineStart();
let i = 0;
for (; r[i] === ","; ) i += yield* this.pushCount(1), i += yield* this.pushSpaces(true), this.flowKey = false;
switch (i += yield* this.pushIndicators(), r[i]) {
case void 0:
return "flow";
case "#":
return yield* this.pushCount(r.length - i), "flow";
case "{":
case "[":
return yield* this.pushCount(1), this.flowKey = false, this.flowLevel += 1, "flow";
case "}":
case "]":
return yield* this.pushCount(1), this.flowKey = true, this.flowLevel -= 1, this.flowLevel ? "flow" : "doc";
case "*":
return yield* this.pushUntil(js), "flow";
case '"':
case "'":
return this.flowKey = true, yield* this.parseQuotedScalar();
case ":": {
let o = this.charAt(1);
if (this.flowKey || ue(o) || o === ",") return this.flowKey = false, yield* this.pushCount(1), yield* this.pushSpaces(true), "flow";
}
default:
return this.flowKey = false, yield* this.parsePlainScalar();
}
}
*parseQuotedScalar() {
let e = this.charAt(0), n = this.buffer.indexOf(e, this.pos + 1);
if (e === "'") for (; n !== -1 && this.buffer[n + 1] === "'"; ) n = this.buffer.indexOf("'", n + 2);
else for (; n !== -1; ) {
let i = 0;
for (; this.buffer[n - 1 - i] === "\\"; ) i += 1;
if (i % 2 === 0) break;
n = this.buffer.indexOf('"', n + 1);
}
let s = this.buffer.substring(0, n), r = s.indexOf(`
`, this.pos);
if (r !== -1) {
for (; r !== -1; ) {
let i = this.continueScalar(r + 1);
if (i === -1) break;
r = s.indexOf(`
`, i);
}
r !== -1 && (n = r - (s[r - 1] === "\r" ? 2 : 1));
}
if (n === -1) {
if (!this.atEnd) return this.setNext("quoted-scalar");
n = this.buffer.length;
}
return yield* this.pushToIndex(n + 1, false), this.flowLevel ? "flow" : "doc";
}
*parseBlockScalarHeader() {
this.blockScalarIndent = -1, this.blockScalarKeep = false;
let e = this.pos;
for (; ; ) {
let n = this.buffer[++e];
if (n === "+") this.blockScalarKeep = true;
else if (n > "0" && n <= "9") this.blockScalarIndent = Number(n) - 1;
else if (n !== "-") break;
}
return yield* this.pushUntil((n) => ue(n) || n === "#");
}
*parseBlockScalar() {
let e = this.pos - 1, n = 0, s;
e: for (let i = this.pos; s = this.buffer[i]; ++i) switch (s) {
case " ":
n += 1;
break;
case `
`:
e = i, n = 0;
break;
case "\r": {
let o = this.buffer[i + 1];
if (!o && !this.atEnd) return this.setNext("block-scalar");
if (o === `
`) break;
}
default:
break e;
}
if (!s && !this.atEnd) return this.setNext("block-scalar");
if (n >= this.indentNext) {
this.blockScalarIndent === -1 ? this.indentNext = n : this.indentNext = this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext);
do {
let i = this.continueScalar(e + 1);
if (i === -1) break;
e = this.buffer.indexOf(`
`, i);
} while (e !== -1);
if (e === -1) {
if (!this.atEnd) return this.setNext("block-scalar");
e = this.buffer.length;
}
}
let r = e + 1;
for (s = this.buffer[r]; s === " "; ) s = this.buffer[++r];
if (s === " ") {
for (; s === " " || s === " " || s === "\r" || s === `
`; ) s = this.buffer[++r];
e = r - 1;
} else if (!this.blockScalarKeep) do {
let i = e - 1, o = this.buffer[i];
o === "\r" && (o = this.buffer[--i]);
let a = i;
for (; o === " "; ) o = this.buffer[--i];
if (o === `
` && i >= this.pos && i + 1 + n > a) e = i;
else break;
} while (true);
return yield pt, yield* this.pushToIndex(e + 1, true), yield* this.parseLineStart();
}
*parsePlainScalar() {
let e = this.flowLevel > 0, n = this.pos - 1, s = this.pos - 1, r;
for (; r = this.buffer[++s]; ) if (r === ":") {
let i = this.buffer[s + 1];
if (ue(i) || e && Zn.has(i)) break;
n = s;
} else if (ue(r)) {
let i = this.buffer[s + 1];
if (r === "\r" && (i === `
` ? (s += 1, r = `
`, i = this.buffer[s + 1]) : n = s), i === "#" || e && Zn.has(i)) break;
if (r === `
`) {
let o = this.continueScalar(s + 1);
if (o === -1) break;
s = Math.max(s, o - 2);
}
} else {
if (e && Zn.has(r)) break;
n = s;
}
return !r && !this.atEnd ? this.setNext("plain-scalar") : (yield pt, yield* this.pushToIndex(n + 1, true), e ? "flow" : "doc");
}
*pushCount(e) {
return e > 0 ? (yield this.buffer.substr(this.pos, e), this.pos += e, e) : 0;
}
*pushToIndex(e, n) {
let s = this.buffer.slice(this.pos, e);
return s ? (yield s, this.pos += s.length, s.length) : (n && (yield ""), 0);
}
*pushIndicators() {
let e = 0;
e: for (; ; ) {
switch (this.charAt(0)) {
case "!":
e += yield* this.pushTag(), e += yield* this.pushSpaces(true);
continue e;
case "&":
e += yield* this.pushUntil(js), e += yield* this.pushSpaces(true);
continue e;
case "-":
case "?":
case ":": {
let n = this.flowLevel > 0, s = this.charAt(1);
if (ue(s) || n && Zn.has(s)) {
n ? this.flowKey && (this.flowKey = false) : this.indentNext = this.indentValue + 1, e += yield* this.pushCount(1), e += yield* this.pushSpaces(true);
continue e;
}
}
}
break e;
}
return e;
}
*pushTag() {
if (this.charAt(1) === "<") {
let e = this.pos + 2, n = this.buffer[e];
for (; !ue(n) && n !== ">"; ) n = this.buffer[++e];
return yield* this.pushToIndex(n === ">" ? e + 1 : e, false);
} else {
let e = this.pos + 1, n = this.buffer[e];
for (; n; ) if (ja.has(n)) n = this.buffer[++e];
else if (n === "%" && Vi.has(this.buffer[e + 1]) && Vi.has(this.buffer[e + 2])) n = this.buffer[e += 3];
else break;
return yield* this.pushToIndex(e, false);
}
}
*pushNewline() {
let e = this.buffer[this.pos];
return e === `
` ? yield* this.pushCount(1) : e === "\r" && this.charAt(1) === `
` ? yield* this.pushCount(2) : 0;
}
*pushSpaces(e) {
let n = this.pos - 1, s;
do
s = this.buffer[++n];
while (s === " " || e && s === " ");
let r = n - this.pos;
return r > 0 && (yield this.buffer.substr(this.pos, r), this.pos = n), r;
}
*pushUntil(e) {
let n = this.pos, s = this.buffer[n];
for (; !e(s); ) s = this.buffer[++n];
return yield* this.pushToIndex(n, false);
}
};
qe = class {
constructor() {
this.lineStarts = [], this.addNewLine = (e) => this.lineStarts.push(e), this.linePos = (e) => {
let n = 0, s = this.lineStarts.length;
for (; n < s; ) {
let i = n + s >> 1;
this.lineStarts[i] < e ? n = i + 1 : s = i;
}
if (this.lineStarts[n] === e) return { line: n + 1, col: 1 };
if (n === 0) return { line: 0, col: e };
let r = this.lineStarts[n - 1];
return { line: n, col: e - r + 1 };
};
}
};
Ie = class {
constructor(e) {
this.atNewLine = true, this.atScalar = false, this.indent = 0, this.offset = 0, this.onKeyLine = false, this.stack = [], this.source = "", this.type = "", this.lexer = new mt(), this.onNewLine = e;
}
*parse(e, n = false) {
this.onNewLine && this.offset === 0 && this.onNewLine(0);
for (let s of this.lexer.lex(e, n)) yield* this.next(s);
n || (yield* this.end());
}
*next(e) {
if (this.source = e, this.atScalar) {
this.atScalar = false, yield* this.step(), this.offset += e.length;
return;
}
let n = Ys(e);
if (n) if (n === "scalar") this.atNewLine = false, this.atScalar = true, this.type = "scalar";
else {
switch (this.type = n, yield* this.step(), n) {
case "newline":
this.atNewLine = true, this.indent = 0, this.onNewLine && this.onNewLine(this.offset + e.length);
break;
case "space":
this.atNewLine && e[0] === " " && (this.indent += e.length);
break;
case "explicit-key-ind":
case "map-value-ind":
case "seq-item-ind":
this.atNewLine && (this.indent += e.length);
break;
case "doc-mode":
case "flow-error-end":
return;
default:
this.atNewLine = false;
}
this.offset += e.length;
}
else {
let s = `Not a YAML token: ${e}`;
yield* this.pop({ type: "error", offset: this.offset, message: s, source: e }), this.offset += e.length;
}
}
*end() {
for (; this.stack.length > 0; ) yield* this.pop();
}
get sourceToken() {
return { type: this.type, offset: this.offset, indent: this.indent, source: this.source };
}
*step() {
let e = this.peek(1);
if (this.type === "doc-end" && e?.type !== "doc-end") {
for (; this.stack.length > 0; ) yield* this.pop();
this.stack.push({ type: "doc-end", offset: this.offset, source: this.source });
return;
}
if (!e) return yield* this.stream();
switch (e.type) {
case "document":
return yield* this.document(e);
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
return yield* this.scalar(e);
case "block-scalar":
return yield* this.blockScalar(e);
case "block-map":
return yield* this.blockMap(e);
case "block-seq":
return yield* this.blockSequence(e);
case "flow-collection":
return yield* this.flowCollection(e);
case "doc-end":
return yield* this.documentEnd(e);
}
yield* this.pop();
}
peek(e) {
return this.stack[this.stack.length - e];
}
*pop(e) {
let n = e ?? this.stack.pop();
if (!n) yield { type: "error", offset: this.offset, source: "", message: "Tried to pop an empty stack" };
else if (this.stack.length === 0) yield n;
else {
let s = this.peek(1);
switch (n.type === "block-scalar" ? n.indent = "indent" in s ? s.indent : 0 : n.type === "flow-collection" && s.type === "document" && (n.indent = 0), n.type === "flow-collection" && Qi(n), s.type) {
case "document":
s.value = n;
break;
case "block-scalar":
s.props.push(n);
break;
case "block-map": {
let r = s.items[s.items.length - 1];
if (r.value) {
s.items.push({ start: [], key: n, sep: [] }), this.onKeyLine = true;
return;
} else if (r.sep) r.value = n;
else {
Object.assign(r, { key: n, sep: [] }), this.onKeyLine = !r.explicitKey;
return;
}
break;
}
case "block-seq": {
let r = s.items[s.items.length - 1];
r.value ? s.items.push({ start: [], value: n }) : r.value = n;
break;
}
case "flow-collection": {
let r = s.items[s.items.length - 1];
!r || r.value ? s.items.push({ start: [], key: n, sep: [] }) : r.sep ? r.value = n : Object.assign(r, { key: n, sep: [] });
return;
}
default:
yield* this.pop(), yield* this.pop(n);
}
if ((s.type === "document" || s.type === "block-map" || s.type === "block-seq") && (n.type === "block-map" || n.type === "block-seq")) {
let r = n.items[n.items.length - 1];
r && !r.sep && !r.value && r.start.length > 0 && Gi(r.start) === -1 && (n.indent === 0 || r.start.every((i) => i.type !== "comment" || i.indent < n.indent)) && (s.type === "document" ? s.end = r.start : s.items.push({ start: r.start }), n.items.splice(-1, 1));
}
}
}
*stream() {
switch (this.type) {
case "directive-line":
yield { type: "directive", offset: this.offset, source: this.source };
return;
case "byte-order-mark":
case "space":
case "comment":
case "newline":
yield this.sourceToken;
return;
case "doc-mode":
case "doc-start": {
let e = { type: "document", offset: this.offset, start: [] };
this.type === "doc-start" && e.start.push(this.sourceToken), this.stack.push(e);
return;
}
}
yield { type: "error", offset: this.offset, message: `Unexpected ${this.type} token in YAML stream`, source: this.source };
}
*document(e) {
if (e.value) return yield* this.lineEnd(e);
switch (this.type) {
case "doc-start": {
Gi(e.start) !== -1 ? (yield* this.pop(), yield* this.step()) : e.start.push(this.sourceToken);
return;
}
case "anchor":
case "tag":
case "space":
case "comment":
case "newline":
e.start.push(this.sourceToken);
return;
}
let n = this.startBlockValue(e);
n ? this.stack.push(n) : yield { type: "error", offset: this.offset, message: `Unexpected ${this.type} token in YAML document`, source: this.source };
}
*scalar(e) {
if (this.type === "map-value-ind") {
let n = es(this.peek(2)), s = ht(n), r;
e.end ? (r = e.end, r.push(this.sourceToken), delete e.end) : r = [this.sourceToken];
let i = { type: "block-map", offset: e.offset, indent: e.indent, items: [{ start: s, key: e, sep: r }] };
this.onKeyLine = true, this.stack[this.stack.length - 1] = i;
} else yield* this.lineEnd(e);
}
*blockScalar(e) {
switch (this.type) {
case "space":
case "comment":
case "newline":
e.props.push(this.sourceToken);
return;
case "scalar":
if (e.source = this.source, this.atNewLine = true, this.indent = 0, this.onNewLine) {
let n = this.source.indexOf(`
`) + 1;
for (; n !== 0; ) this.onNewLine(this.offset + n), n = this.source.indexOf(`
`, n) + 1;
}
yield* this.pop();
break;
default:
yield* this.pop(), yield* this.step();
}
}
*blockMap(e) {
let n = e.items[e.items.length - 1];
switch (this.type) {
case "newline":
if (this.onKeyLine = false, n.value) {
let s = "end" in n.value ? n.value.end : void 0;
(Array.isArray(s) ? s[s.length - 1] : void 0)?.type === "comment" ? s?.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
} else n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
return;
case "space":
case "comment":
if (n.value) e.items.push({ start: [this.sourceToken] });
else if (n.sep) n.sep.push(this.sourceToken);
else {
if (this.atIndentedComment(n.start, e.indent)) {
let r = e.items[e.items.length - 2]?.value?.end;
if (Array.isArray(r)) {
ts(r, n.start), r.push(this.sourceToken), e.items.pop();
return;
}
}
n.start.push(this.sourceToken);
}
return;
}
if (this.indent >= e.indent) {
let s = !this.onKeyLine && this.indent === e.indent, r = s && (n.sep || n.explicitKey) && this.type !== "seq-item-ind", i = [];
if (r && n.sep && !n.value) {
let o = [];
for (let a = 0; a < n.sep.length; ++a) {
let l = n.sep[a];
switch (l.type) {
case "newline":
o.push(a);
break;
case "space":
break;
case "comment":
l.indent > e.indent && (o.length = 0);
break;
default:
o.length = 0;
}
}
o.length >= 2 && (i = n.sep.splice(o[1]));
}
switch (this.type) {
case "anchor":
case "tag":
r || n.value ? (i.push(this.sourceToken), e.items.push({ start: i }), this.onKeyLine = true) : n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
return;
case "explicit-key-ind":
!n.sep && !n.explicitKey ? (n.start.push(this.sourceToken), n.explicitKey = true) : r || n.value ? (i.push(this.sourceToken), e.items.push({ start: i, explicitKey: true })) : this.stack.push({ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: [this.sourceToken], explicitKey: true }] }), this.onKeyLine = true;
return;
case "map-value-ind":
if (n.explicitKey) if (n.sep) if (n.value) e.items.push({ start: [], key: null, sep: [this.sourceToken] });
else if (Fe(n.sep, "map-value-ind")) this.stack.push({ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: i, key: null, sep: [this.sourceToken] }] });
else if (Hi(n.key) && !Fe(n.sep, "newline")) {
let o = ht(n.start), a = n.key, l = n.sep;
l.push(this.sourceToken), delete n.key, delete n.sep, this.stack.push({ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: o, key: a, sep: l }] });
} else i.length > 0 ? n.sep = n.sep.concat(i, this.sourceToken) : n.sep.push(this.sourceToken);
else if (Fe(n.start, "newline")) Object.assign(n, { key: null, sep: [this.sourceToken] });
else {
let o = ht(n.start);
this.stack.push({ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: o, key: null, sep: [this.sourceToken] }] });
}
else n.sep ? n.value || r ? e.items.push({ start: i, key: null, sep: [this.sourceToken] }) : Fe(n.sep, "map-value-ind") ? this.stack.push({ type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: [], key: null, sep: [this.sourceToken] }] }) : n.sep.push(this.sourceToken) : Object.assign(n, { key: null, sep: [this.sourceToken] });
this.onKeyLine = true;
return;
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar": {
let o = this.flowScalar(this.type);
r || n.value ? (e.items.push({ start: i, key: o, sep: [] }), this.onKeyLine = true) : n.sep ? this.stack.push(o) : (Object.assign(n, { key: o, sep: [] }), this.onKeyLine = true);
return;
}
default: {
let o = this.startBlockValue(e);
if (o) {
if (o.type === "block-seq") {
if (!n.explicitKey && n.sep && !Fe(n.sep, "newline")) {
yield* this.pop({ type: "error", offset: this.offset, message: "Unexpected block-seq-ind on same line with key", source: this.source });
return;
}
} else s && e.items.push({ start: i });
this.stack.push(o);
return;
}
}
}
}
yield* this.pop(), yield* this.step();
}
*blockSequence(e) {
let n = e.items[e.items.length - 1];
switch (this.type) {
case "newline":
if (n.value) {
let s = "end" in n.value ? n.value.end : void 0;
(Array.isArray(s) ? s[s.length - 1] : void 0)?.type === "comment" ? s?.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
} else n.start.push(this.sourceToken);
return;
case "space":
case "comment":
if (n.value) e.items.push({ start: [this.sourceToken] });
else {
if (this.atIndentedComment(n.start, e.indent)) {
let r = e.items[e.items.length - 2]?.value?.end;
if (Array.isArray(r)) {
ts(r, n.start), r.push(this.sourceToken), e.items.pop();
return;
}
}
n.start.push(this.sourceToken);
}
return;
case "anchor":
case "tag":
if (n.value || this.indent <= e.indent) break;
n.start.push(this.sourceToken);
return;
case "seq-item-ind":
if (this.indent !== e.indent) break;
n.value || Fe(n.start, "seq-item-ind") ? e.items.push({ start: [this.sourceToken] }) : n.start.push(this.sourceToken);
return;
}
if (this.indent > e.indent) {
let s = this.startBlockValue(e);
if (s) {
this.stack.push(s);
return;
}
}
yield* this.pop(), yield* this.step();
}
*flowCollection(e) {
let n = e.items[e.items.length - 1];
if (this.type === "flow-error-end") {
let s;
do
yield* this.pop(), s = this.peek(1);
while (s?.type === "flow-collection");
} else if (e.end.length === 0) {
switch (this.type) {
case "comma":
case "explicit-key-ind":
!n || n.sep ? e.items.push({ start: [this.sourceToken] }) : n.start.push(this.sourceToken);
return;
case "map-value-ind":
!n || n.value ? e.items.push({ start: [], key: null, sep: [this.sourceToken] }) : n.sep ? n.sep.push(this.sourceToken) : Object.assign(n, { key: null, sep: [this.sourceToken] });
return;
case "space":
case "comment":
case "newline":
case "anchor":
case "tag":
!n || n.value ? e.items.push({ start: [this.sourceToken] }) : n.sep ? n.sep.push(this.sourceToken) : n.start.push(this.sourceToken);
return;
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar": {
let r = this.flowScalar(this.type);
!n || n.value ? e.items.push({ start: [], key: r, sep: [] }) : n.sep ? this.stack.push(r) : Object.assign(n, { key: r, sep: [] });
return;
}
case "flow-map-end":
case "flow-seq-end":
e.end.push(this.sourceToken);
return;
}
let s = this.startBlockValue(e);
s ? this.stack.push(s) : (yield* this.pop(), yield* this.step());
} else {
let s = this.peek(2);
if (s.type === "block-map" && (this.type === "map-value-ind" && s.indent === e.indent || this.type === "newline" && !s.items[s.items.length - 1].sep)) yield* this.pop(), yield* this.step();
else if (this.type === "map-value-ind" && s.type !== "flow-collection") {
let r = es(s), i = ht(r);
Qi(e);
let o = e.end.splice(1, e.end.length);
o.push(this.sourceToken);
let a = { type: "block-map", offset: e.offset, indent: e.indent, items: [{ start: i, key: e, sep: o }] };
this.onKeyLine = true, this.stack[this.stack.length - 1] = a;
} else yield* this.lineEnd(e);
}
}
flowScalar(e) {
if (this.onNewLine) {
let n = this.source.indexOf(`
`) + 1;
for (; n !== 0; ) this.onNewLine(this.offset + n), n = this.source.indexOf(`
`, n) + 1;
}
return { type: e, offset: this.offset, indent: this.indent, source: this.source };
}
startBlockValue(e) {
switch (this.type) {
case "alias":
case "scalar":
case "single-quoted-scalar":
case "double-quoted-scalar":
return this.flowScalar(this.type);
case "block-scalar-header":
return { type: "block-scalar", offset: this.offset, indent: this.indent, props: [this.sourceToken], source: "" };
case "flow-map-start":
case "flow-seq-start":
return { type: "flow-collection", offset: this.offset, indent: this.indent, start: this.sourceToken, items: [], end: [] };
case "seq-item-ind":
return { type: "block-seq", offset: this.offset, indent: this.indent, items: [{ start: [this.sourceToken] }] };
case "explicit-key-ind": {
this.onKeyLine = true;
let n = es(e), s = ht(n);
return s.push(this.sourceToken), { type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: s, explicitKey: true }] };
}
case "map-value-ind": {
this.onKeyLine = true;
let n = es(e), s = ht(n);
return { type: "block-map", offset: this.offset, indent: this.indent, items: [{ start: s, key: null, sep: [this.sourceToken] }] };
}
}
return null;
}
atIndentedComment(e, n) {
return this.type !== "comment" || this.indent <= n ? false : e.every((s) => s.type === "newline" || s.type === "space");
}
*documentEnd(e) {
this.type !== "doc-mode" && (e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop()));
}
*lineEnd(e) {
switch (this.type) {
case "comma":
case "doc-start":
case "doc-end":
case "flow-seq-end":
case "flow-map-end":
case "map-value-ind":
yield* this.pop(), yield* this.step();
break;
case "newline":
this.onKeyLine = false;
default:
e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop());
}
}
};
Zi = Gs;
Ha = class {
text;
comments = [];
#e;
constructor(t7, e) {
this.text = t7, this.#e = e;
}
transformOffset(t7) {
let { line: e, col: n } = this.#e.linePos(t7);
return { line: e, column: n, offset: t7 };
}
transformRange(t7) {
let [e, n] = t7.map((s) => this.transformOffset(s));
return Z(e, n);
}
transformNode(t7, e) {
return po(t7, this, e);
}
transformComment(t7) {
let e = qr(t7, this);
return this.comments.push(e), e;
}
transformContentProperties(t7, e) {
return Ur(t7, e, this);
}
};
mo = Ha;
Ao = il;
ol = { uniqueKeys: false };
ll = { astFormat: "yaml", parse: al, hasPragma: br, hasIgnorePragma: kr, locStart: Nt, locEnd: mr };
cl = { yaml: Pr };
fl = Zi.parse;
}
});
init_yaml();
export {
fl as __parsePrettierYamlConfig,
To as default,
vr as languages,
Dr as options,
Xs as parsers,
cl as printers
};