repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

pi: install bundled writing-skills checker

6f4acaed50b0f1d593cf3497e945fe23209db2c5

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (6)

pi/agent/skills/writing-skills/SKILL.md

Modified
59 59 mutation tests may touch isolated temporary fixtures only.
60 60 These flags restrict the test setup, not an OS sandbox;
61 61 inspect target instructions and helpers before running them.
62 -Do not launch a visible terminal solely for a headless skill test;
63 -use `terminal-harness` when interaction or terminal UI is under test.
62 +Use an interactive-terminal workflow only when interaction or terminal UI is under test.
64 63 Keep scenario, acceptance criteria, command, model/settings, outputs,
65 64 and verdict in temporary evidence.
66 65 Report blocked checks and residual gaps explicitly;
69 68 ## Authoring rules
70 +- Split broad workflows into independently useful, single-outcome skills;
71 + grouping directories need no `SKILL.md`.
72 +- Express composition as natural-language outcomes;
73 + never name, path, or mandate loading another skill.
71 74 - `name`: 1-64 lowercase letters/digits, single internal hyphens;
72 75 match the directory for portability.
73 76 - `description`: non-empty, at most 1024 characters;
88 91 ## Mechanical checks
90 -From this skill directory, install locked parser dependencies once
91 -with `npm ci --ignore-scripts`.
92 93 Run `node scripts/check.mjs <skill-dir>`;
93 94 see [checker scope](references/checker.md).
94 -It reads only: YAML/name/description, local Markdown links,
95 -and package/test declarations.
96 -It never runs the target's scripts or claims semantic correctness
97 -or test coverage.
99 -Run the target's reviewed tests and repository formatter/linter separately.
100 -Finish with scope, actual RED/GREEN evidence, checks run, and remaining gaps.
95 +Run target tests and repository checks separately.
96 +Finish with scope, RED/GREEN evidence, checks, and gaps.

pi/agent/skills/writing-skills/package-lock.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "writing-skills",
3 - "lockfileVersion": 3,
4 - "requires": true,
5 - "packages": {
6 - "": {
7 - "name": "writing-skills",
8 - "dependencies": {
9 - "marked": "18.0.5",
10 - "yaml": "2.9.0"
11 - },
12 - "engines": {
13 - "node": ">=20"
14 - }
15 - },
16 - "node_modules/marked": {
17 - "version": "18.0.5",
18 - "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.5.tgz",
19 - "integrity": "sha512-S6GcvALHg6K4ohtu4E7x0a1AqhAjp6cV8KhLSyN9qVapnzJkusVBxZRcIU9AeYsbe6P1hKDusSbEOzGyyuce6w==",
20 - "license": "MIT",
21 - "bin": {
22 - "marked": "bin/marked.js"
23 - },
24 - "engines": {
25 - "node": ">= 20"
26 - }
27 - },
28 - "node_modules/yaml": {
29 - "version": "2.9.0",
30 - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz",
31 - "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==",
32 - "license": "ISC",
33 - "bin": {
34 - "yaml": "bin.mjs"
35 - },
36 - "engines": {
37 - "node": ">= 14.6"
38 - },
39 - "funding": {
40 - "url": "https://github.com/sponsors/eemeli"
41 - }
42 - }
43 - }
44 -}

pi/agent/skills/writing-skills/package.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "writing-skills",
3 - "private": true,
4 - "type": "module",
5 - "engines": {
6 - "node": ">=20"
7 - },
8 - "scripts": {
9 - "test": "node --test scripts/check.test.mjs"
10 - },
11 - "dependencies": {
12 - "marked": "18.0.5",
13 - "yaml": "2.9.0"
14 - }
15 -}

pi/agent/skills/writing-skills/references/checker.md

Modified
3 3 # Checker scope
5 5 Run from the writing-skills directory:
7 7 ```sh
8 -npm ci --ignore-scripts
9 8 node scripts/check.mjs /path/to/target-skill
10 -npm test
13 -`npm ci` installs this checker's locked `yaml` and `marked` parsers,
14 -not target dependencies.
15 11 The checker accepts one skill directory containing `SKILL.md`,
16 12 not a discovery root or loose Markdown skill.
17 13 It works from any cwd when the script and target paths resolve correctly.

pi/agent/skills/writing-skills/scripts/check.mjs

Modified + mode changed
old mode 100644 new mode 100755
1 1 #!/usr/bin/env node
2 +import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
4 +// scripts/check.mjs
2 5 import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
3 6 import {
4 - basename,
5 - dirname,
6 - isAbsolute,
7 - join,
8 - relative,
9 - resolve,
7 + basename,
8 + dirname,
9 + isAbsolute,
10 + join,
11 + relative,
12 + resolve
10 13 } from "node:path";
11 14 import { fileURLToPath } from "node:url";
12 -import { marked } from "marked";
13 -import { parse } from "yaml";
15 -const frontmatterFence = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
16 -const namePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
17 -const scriptPattern = /\.(?:mjs|cjs|js|ts|sh|bash|nu|py|ps1|cmd|bat)$/i;
16 +// node_modules/js-yaml/dist/js-yaml.mjs
17 +var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
18 +function defineScalarTag(tagName, options) {
19 + return {
20 + tagName,
21 + nodeKind: "scalar",
22 + implicit: options.implicit ?? false,
23 + matchByTagPrefix: options.matchByTagPrefix ?? false,
24 + implicitFirstChars: options.implicitFirstChars ?? null,
25 + resolve: options.resolve,
26 + identify: options.identify,
27 + represent: options.represent ?? ((data) => String(data)),
28 + representTagName: options.representTagName ?? (() => tagName)
29 + };
31 +function defineSequenceTag(tagName, options) {
32 + const carrierIsResult = options.finalize === void 0;
33 + return {
34 + tagName,
35 + nodeKind: "sequence",
36 + implicit: false,
37 + matchByTagPrefix: options.matchByTagPrefix ?? false,
38 + create: options.create,
39 + addItem: options.addItem,
40 + finalize: options.finalize ?? ((carrier) => carrier),
41 + carrierIsResult,
42 + identify: options.identify,
43 + represent: options.represent ?? ((data) => data),
44 + representTagName: options.representTagName ?? (() => tagName)
45 + };
47 +function defineMappingTag(tagName, options) {
48 + const carrierIsResult = options.finalize === void 0;
49 + return {
50 + tagName,
51 + nodeKind: "mapping",
52 + implicit: false,
53 + matchByTagPrefix: options.matchByTagPrefix ?? false,
54 + create: options.create,
55 + addPair: options.addPair,
56 + has: options.has,
57 + keys: options.keys,
58 + get: options.get,
59 + finalize: options.finalize ?? ((carrier) => carrier),
60 + carrierIsResult,
61 + identify: options.identify,
62 + represent: options.represent ?? ((data) => data),
63 + representTagName: options.representTagName ?? (() => tagName)
64 + };
66 +var strTag = defineScalarTag("tag:yaml.org,2002:str", {
67 + resolve: (source) => source,
68 + identify: (data) => typeof data === "string"
69 +});
70 +var NULL_VALUES$1 = [
71 + "",
72 + "~",
73 + "null",
74 + "Null",
75 + "NULL"
76 +];
77 +var nullCoreTag = defineScalarTag("tag:yaml.org,2002:null", {
78 + implicit: true,
79 + implicitFirstChars: [
80 + "",
81 + "~",
82 + "n",
83 + "N"
84 + ],
85 + resolve: (source) => {
86 + if (NULL_VALUES$1.indexOf(source) !== -1) return null;
87 + return NOT_RESOLVED;
88 + },
89 + identify: (object) => object === null,
90 + represent: () => "null"
91 +});
92 +var nullJsonTag = defineScalarTag("tag:yaml.org,2002:null", {
93 + implicit: true,
94 + implicitFirstChars: ["n"],
95 + resolve: (source, isExplicit) => {
96 + if (source === "null" || isExplicit && source === "") return null;
97 + return NOT_RESOLVED;
98 + },
99 + identify: (object) => object === null,
100 + represent: () => "null"
101 +});
102 +var NULL_VALUES = [
103 + "",
104 + "~",
105 + "null",
106 + "Null",
107 + "NULL"
109 +var nullYaml11Tag = defineScalarTag("tag:yaml.org,2002:null", {
110 + implicit: true,
111 + implicitFirstChars: [
112 + "",
113 + "~",
114 + "n",
115 + "N"
116 + ],
117 + resolve: (source) => {
118 + if (NULL_VALUES.indexOf(source) !== -1) return null;
119 + return NOT_RESOLVED;
120 + },
121 + identify: (object) => object === null,
122 + represent: () => "null"
123 +});
124 +var TRUE_VALUES$2 = [
125 + "true",
126 + "True",
127 + "TRUE"
129 +var FALSE_VALUES$2 = [
130 + "false",
131 + "False",
132 + "FALSE"
134 +var boolCoreTag = defineScalarTag("tag:yaml.org,2002:bool", {
135 + implicit: true,
136 + implicitFirstChars: [
137 + "t",
138 + "T",
139 + "f",
140 + "F"
141 + ],
142 + resolve: (source) => {
143 + if (TRUE_VALUES$2.indexOf(source) !== -1) return true;
144 + if (FALSE_VALUES$2.indexOf(source) !== -1) return false;
145 + return NOT_RESOLVED;
146 + },
147 + identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
148 + represent: (object) => object ? "true" : "false"
149 +});
150 +var TRUE_VALUES$1 = ["true"];
151 +var FALSE_VALUES$1 = ["false"];
152 +var boolJsonTag = defineScalarTag("tag:yaml.org,2002:bool", {
153 + implicit: true,
154 + implicitFirstChars: ["t", "f"],
155 + resolve: (source) => {
156 + if (TRUE_VALUES$1.indexOf(source) !== -1) return true;
157 + if (FALSE_VALUES$1.indexOf(source) !== -1) return false;
158 + return NOT_RESOLVED;
159 + },
160 + identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
161 + represent: (object) => object ? "true" : "false"
162 +});
163 +var TRUE_VALUES = [
164 + "true",
165 + "True",
166 + "TRUE",
167 + "y",
168 + "Y",
169 + "yes",
170 + "Yes",
171 + "YES",
172 + "on",
173 + "On",
174 + "ON"
176 +var FALSE_VALUES = [
177 + "false",
178 + "False",
179 + "FALSE",
180 + "n",
181 + "N",
182 + "no",
183 + "No",
184 + "NO",
185 + "off",
186 + "Off",
187 + "OFF"
189 +var boolYaml11Tag = defineScalarTag("tag:yaml.org,2002:bool", {
190 + implicit: true,
191 + implicitFirstChars: [
192 + "y",
193 + "Y",
194 + "n",
195 + "N",
196 + "t",
197 + "T",
198 + "f",
199 + "F",
200 + "o",
201 + "O"
202 + ],
203 + resolve: (source) => {
204 + if (TRUE_VALUES.indexOf(source) !== -1) return true;
205 + if (FALSE_VALUES.indexOf(source) !== -1) return false;
206 + return NOT_RESOLVED;
207 + },
208 + identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
209 + represent: (object) => object ? "true" : "false"
210 +});
211 +var YAML_INTEGER_IMPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
212 +var YAML_INTEGER_EXPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
213 +function parseYamlInteger$2(source) {
214 + let value = source;
215 + let sign = 1;
216 + if (value[0] === "-" || value[0] === "+") {
217 + if (value[0] === "-") sign = -1;
218 + value = value.slice(1);
220 + if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
221 + if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
222 + if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
223 + return sign * parseInt(value, 10);
225 +function resolveYamlInteger$2(source, isExplicit) {
226 + if (isExplicit) {
227 + if (!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
228 + } else if (!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
229 + const result = parseYamlInteger$2(source);
230 + return Number.isFinite(result) ? result : NOT_RESOLVED;
232 +var intCoreTag = defineScalarTag("tag:yaml.org,2002:int", {
233 + implicit: true,
234 + implicitFirstChars: [
235 + "-",
236 + "+",
237 + ..."0123456789"
238 + ],
239 + resolve: resolveYamlInteger$2,
240 + identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
241 + represent: (object) => object.toString(10)
242 +});
243 +var YAML_INTEGER_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)$");
244 +var YAML_INTEGER_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
245 +function parseYamlInteger$1(source) {
246 + let value = source;
247 + let sign = 1;
248 + if (value[0] === "-" || value[0] === "+") {
249 + if (value[0] === "-") sign = -1;
250 + value = value.slice(1);
252 + if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
253 + if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
254 + if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
255 + return sign * parseInt(value, 10);
257 +function resolveYamlInteger$1(source, isExplicit) {
258 + if (isExplicit) {
259 + if (!YAML_INTEGER_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
260 + } else if (!YAML_INTEGER_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
261 + const result = parseYamlInteger$1(source);
262 + return Number.isFinite(result) ? result : NOT_RESOLVED;
264 +var intJsonTag = defineScalarTag("tag:yaml.org,2002:int", {
265 + implicit: true,
266 + implicitFirstChars: ["-", ..."0123456789"],
267 + resolve: resolveYamlInteger$1,
268 + identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
269 + represent: (object) => object.toString(10)
270 +});
271 +var YAML_INTEGER_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");
272 +function parseYamlInteger(source) {
273 + let value = source.replace(/_/g, "");
274 + let sign = 1;
275 + if (value[0] === "-" || value[0] === "+") {
276 + if (value[0] === "-") sign = -1;
277 + value = value.slice(1);
279 + if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
280 + if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
281 + if (value.includes(":")) {
282 + let result = 0;
283 + for (const part of value.split(":")) result = result * 60 + Number(part);
284 + return sign * result;
286 + if (value !== "0" && value[0] === "0") return sign * parseInt(value, 8);
287 + return sign * parseInt(value, 10);
289 +function resolveYamlInteger(source) {
290 + if (!YAML_INTEGER_PATTERN.test(source)) return NOT_RESOLVED;
291 + const result = parseYamlInteger(source);
292 + return Number.isFinite(result) ? result : NOT_RESOLVED;
294 +var intYaml11Tag = defineScalarTag("tag:yaml.org,2002:int", {
295 + implicit: true,
296 + implicitFirstChars: [
297 + "-",
298 + "+",
299 + ..."0123456789"
300 + ],
301 + resolve: resolveYamlInteger,
302 + identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
303 + represent: (object) => object.toString(10)
304 +});
305 +var YAML_FLOAT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
306 +var YAML_FLOAT_SPECIAL_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
307 +function resolveYamlFloat$2(source) {
308 + if (!YAML_FLOAT_PATTERN$1.test(source)) return NOT_RESOLVED;
309 + let value = source.toLowerCase();
310 + const sign = value[0] === "-" ? -1 : 1;
311 + if ("+-".includes(value[0])) value = value.slice(1);
312 + if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
313 + if (value === ".nan") return NaN;
314 + const result = sign * parseFloat(value);
315 + if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN$1.test(source)) return result;
316 + return NOT_RESOLVED;
318 +function representYamlFloat$2(object) {
319 + if (isNaN(object)) return ".nan";
320 + if (object === Number.POSITIVE_INFINITY) return ".inf";
321 + if (object === Number.NEGATIVE_INFINITY) return "-.inf";
322 + if (Object.is(object, -0)) return "-0.0";
323 + const result = object.toString(10);
324 + return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
326 +var floatCoreTag = defineScalarTag("tag:yaml.org,2002:float", {
327 + implicit: true,
328 + implicitFirstChars: [
329 + "-",
330 + "+",
331 + ".",
332 + ..."0123456789"
333 + ],
334 + resolve: resolveYamlFloat$2,
335 + identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
336 + represent: representYamlFloat$2
337 +});
338 +var YAML_FLOAT_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
339 +var YAML_FLOAT_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
340 +function resolveYamlFloat$1(source, isExplicit) {
341 + if (isExplicit) {
342 + if (!YAML_FLOAT_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
343 + let value = source.toLowerCase();
344 + const sign = value[0] === "-" ? -1 : 1;
345 + if ("+-".includes(value[0])) value = value.slice(1);
346 + if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
347 + if (value === ".nan") return NaN;
348 + const result2 = sign * parseFloat(value);
349 + return Number.isFinite(result2) ? result2 : NOT_RESOLVED;
351 + if (!YAML_FLOAT_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
352 + const result = Number(source);
353 + if (Number.isFinite(result)) return result;
354 + return NOT_RESOLVED;
356 +function representYamlFloat$1(object) {
357 + if (isNaN(object)) return ".nan";
358 + if (object === Number.POSITIVE_INFINITY) return ".inf";
359 + if (object === Number.NEGATIVE_INFINITY) return "-.inf";
360 + if (Object.is(object, -0)) return "-0.0";
361 + const result = object.toString(10);
362 + return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
364 +var floatJsonTag = defineScalarTag("tag:yaml.org,2002:float", {
365 + implicit: true,
366 + implicitFirstChars: ["-", ..."0123456789"],
367 + resolve: resolveYamlFloat$1,
368 + identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
369 + represent: representYamlFloat$1
370 +});
371 +var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
372 +var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
373 +function resolveYamlFloat(source) {
374 + if (!YAML_FLOAT_PATTERN.test(source)) return NOT_RESOLVED;
375 + let value = source.toLowerCase().replace(/_/g, "");
376 + const sign = value[0] === "-" ? -1 : 1;
377 + if ("+-".includes(value[0])) value = value.slice(1);
378 + if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
379 + if (value === ".nan") return NaN;
380 + let result = 0;
381 + if (value.includes(":")) {
382 + for (const part of value.split(":")) result = result * 60 + Number(part);
383 + result *= sign;
384 + } else result = sign * parseFloat(value);
385 + if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN.test(source)) return result;
386 + return NOT_RESOLVED;
388 +function representYamlFloat(object) {
389 + if (isNaN(object)) return ".nan";
390 + if (object === Number.POSITIVE_INFINITY) return ".inf";
391 + if (object === Number.NEGATIVE_INFINITY) return "-.inf";
392 + if (Object.is(object, -0)) return "-0.0";
393 + const result = object.toString(10);
394 + return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
396 +var floatYaml11Tag = defineScalarTag("tag:yaml.org,2002:float", {
397 + implicit: true,
398 + implicitFirstChars: [
399 + "-",
400 + "+",
401 + ".",
402 + ..."0123456789"
403 + ],
404 + resolve: resolveYamlFloat,
405 + identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
406 + represent: representYamlFloat
407 +});
408 +var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
409 + implicit: true,
410 + implicitFirstChars: ["<"],
411 + resolve: (source, isExplicit) => {
412 + if (source === "<<" || isExplicit && source === "") return "<<";
413 + return NOT_RESOLVED;
414 + },
415 + identify: () => false
416 +});
417 +var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
418 +function resolveYamlBinary(source) {
419 + const input = source.replace(/\s/g, "");
420 + if (input.length % 4 !== 0 || !BASE64_PATTERN.test(input)) return NOT_RESOLVED;
421 + const binary = atob(input);
422 + const result = new Uint8Array(binary.length);
423 + for (let index = 0; index < binary.length; index++) result[index] = binary.charCodeAt(index);
424 + return result;
426 +function representYamlBinary(object) {
427 + let binary = "";
428 + for (let index = 0; index < object.length; index++) binary += String.fromCharCode(object[index]);
429 + return btoa(binary);
431 +var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
432 + resolve: resolveYamlBinary,
433 + identify: (object) => Object.prototype.toString.call(object) === "[object Uint8Array]",
434 + represent: representYamlBinary
435 +});
436 +var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
437 +var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
438 +function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
439 + const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
440 + date.setUTCFullYear(year, month, day);
441 + return date;
443 +function resolveYamlTimestamp(source) {
444 + let match = YAML_DATE_REGEXP.exec(source);
445 + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
446 + if (match === null) return NOT_RESOLVED;
447 + const year = +match[1];
448 + const month = +match[2] - 1;
449 + const day = +match[3];
450 + if (!match[4]) {
451 + const date2 = makeUtcDate(year, month, day);
452 + if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
453 + return date2;
455 + const hour = +match[4];
456 + const minute = +match[5];
457 + const second = +match[6];
458 + let fraction = 0;
459 + if (hour > 23 || minute > 59 || second > 59) return NOT_RESOLVED;
460 + if (match[7]) {
461 + let value = match[7].slice(0, 3);
462 + while (value.length < 3) value += "0";
463 + fraction = +value;
465 + const date = makeUtcDate(year, month, day, hour, minute, second, fraction);
466 + if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
467 + if (match[9]) {
468 + const offsetHour = +match[10];
469 + const offsetMinute = +(match[11] || 0);
470 + if (offsetHour > 23 || offsetMinute > 59) return NOT_RESOLVED;
471 + const offset = (offsetHour * 60 + offsetMinute) * 6e4;
472 + date.setTime(date.getTime() - (match[9] === "-" ? -offset : offset));
474 + return date;
476 +var timestampTag = defineScalarTag("tag:yaml.org,2002:timestamp", {
477 + implicit: true,
478 + implicitFirstChars: [..."0123456789"],
479 + resolve: resolveYamlTimestamp,
480 + identify: (object) => object instanceof Date,
481 + represent: (object) => object.toISOString()
482 +});
483 +var seqTag = defineSequenceTag("tag:yaml.org,2002:seq", {
484 + create: () => [],
485 + addItem: (container, item) => {
486 + container.push(item);
487 + },
488 + identify: Array.isArray
489 +});
490 +function isPlainObject(data) {
491 + if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
492 + const prototype = Object.getPrototypeOf(data);
493 + return prototype === null || prototype === Object.prototype;
495 +function pick(object, keys) {
496 + const result = {};
497 + for (const key of keys) if (object[key] !== void 0) result[key] = object[key];
498 + return result;
500 +var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
501 + create: () => ({
502 + list: [],
503 + seen: /* @__PURE__ */ new Set()
504 + }),
505 + addItem: (carrier, item) => {
506 + let key;
507 + if (item instanceof Map) {
508 + if (item.size !== 1) return "cannot resolve an ordered map item";
509 + key = item.keys().next().value;
510 + } else if (isPlainObject(item)) {
511 + const itemKeys = Object.keys(item);
512 + if (itemKeys.length !== 1) return "cannot resolve an ordered map item";
513 + key = itemKeys[0];
514 + } else return "cannot resolve an ordered map item";
515 + if (carrier.seen.has(key)) return "duplicate key in ordered map";
516 + carrier.seen.add(key);
517 + carrier.list.push(item);
518 + return "";
519 + },
520 + finalize: (carrier) => carrier.list,
521 + identify: () => false
522 +});
523 +var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
524 + create: () => [],
525 + addItem: (container, item) => {
526 + if (item instanceof Map) {
527 + if (item.size !== 1) return "cannot resolve a pairs item";
528 + container.push(item.entries().next().value);
529 + return "";
531 + if (Object.prototype.toString.call(item) !== "[object Object]") return "cannot resolve a pairs item";
532 + const object = item;
533 + const keys = Object.keys(object);
534 + if (keys.length !== 1) return "cannot resolve a pairs item";
535 + container.push([keys[0], object[keys[0]]]);
536 + return "";
537 + },
538 + identify: () => false
539 +});
540 +var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
541 + create: () => ({}),
542 + identify: isPlainObject,
543 + represent: (o) => {
544 + const map = /* @__PURE__ */ new Map();
545 + for (const key of Object.keys(o)) map.set(key, o[key]);
546 + return map;
547 + },
548 + addPair: (container, key, value) => {
549 + if (key !== null && typeof key === "object") return "object-based map does not support complex keys";
550 + const normalizedKey = String(key);
551 + if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
552 + value,
553 + enumerable: true,
554 + configurable: true,
555 + writable: true
556 + });
557 + else container[normalizedKey] = value;
558 + return "";
559 + },
560 + has: (container, key) => {
561 + if (key !== null && typeof key === "object") return false;
562 + return Object.prototype.hasOwnProperty.call(container, String(key));
563 + },
564 + keys: (container) => Object.keys(container),
565 + get: (container, key) => {
566 + const normalizedKey = String(key);
567 + if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
568 + return container[normalizedKey];
570 +});
571 +var setTag = defineMappingTag("tag:yaml.org,2002:set", {
572 + create: () => /* @__PURE__ */ new Set(),
573 + identify: (data) => data instanceof Set,
574 + represent: (data) => {
575 + const map = /* @__PURE__ */ new Map();
576 + for (const key of data) map.set(key, null);
577 + return map;
578 + },
579 + addPair: (container, key, value) => {
580 + if (value !== null) return "cannot resolve a set item";
581 + container.add(key);
582 + return "";
583 + },
584 + has: (container, key) => container.has(key),
585 + keys: (container) => container.keys(),
586 + get: () => null
587 +});
588 +function createTagDefinitionMap() {
589 + return {
590 + scalar: /* @__PURE__ */ Object.create(null),
591 + sequence: /* @__PURE__ */ Object.create(null),
592 + mapping: /* @__PURE__ */ Object.create(null)
593 + };
595 +function createTagDefinitionListMap() {
596 + return {
597 + scalar: [],
598 + sequence: [],
599 + mapping: []
600 + };
602 +function compileTags(tags) {
603 + const result = [];
604 + for (const tag of tags) {
605 + let index = result.length;
606 + for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
607 + const previous = result[previousIndex];
608 + if (previous.nodeKind === tag.nodeKind && previous.tagName === tag.tagName && previous.matchByTagPrefix === tag.matchByTagPrefix) {
609 + index = previousIndex;
610 + break;
613 + result[index] = tag;
615 + return result;
617 +var Schema = class Schema2 {
618 + tags;
619 + /** @internal */
620 + implicitScalarTags;
621 + /**
622 + * Dispatch implicit scalar resolvers by `source.charAt(0)`. Each bucket holds
623 + * the resolvers that may match that key, in schema order; a key absent from
624 + * the map uses
625 + * {@link Schema.implicitScalarAnyFirstChar}
626 + * (resolvers that declared no first-char constraint, so they apply to any
627 + * first character).
628 + */
629 + implicitScalarByFirstChar;
630 + implicitScalarAnyFirstChar;
631 + /**
632 + * The default scalar tag (`!!str`), resolved once so the composer's fallback
633 + * for unresolved plain scalars avoids a keyed lookup per scalar.
635 + * @internal
636 + */
637 + defaultScalarTag;
638 + /**
639 + * The default container tags (`!!seq` / `!!map`), used by the dumper: when a
640 + * value is identified by its default tag, the tag is implicit and not
641 + * printed. Undefined if the schema does not define them (then such values
642 + * can't be dumped).
644 + * @internal
645 + */
646 + defaultSequenceTag;
647 + /** @internal */
648 + defaultMappingTag;
649 + exact;
650 + prefix;
651 + constructor(tags) {
652 + const compiledTags = compileTags(tags);
653 + const implicitScalarTags = [];
654 + const exact = createTagDefinitionMap();
655 + const prefix = createTagDefinitionListMap();
656 + for (const tag of compiledTags) {
657 + if (tag.nodeKind === "scalar" && tag.implicit) {
658 + if (tag.matchByTagPrefix) throw new Error("Implicit scalar tags cannot match by tag prefix");
659 + implicitScalarTags.push(tag);
661 + switch (tag.nodeKind) {
662 + case "scalar":
663 + if (tag.matchByTagPrefix) prefix.scalar.push(tag);
664 + else exact.scalar[tag.tagName] = tag;
665 + break;
666 + case "sequence":
667 + if (tag.matchByTagPrefix) prefix.sequence.push(tag);
668 + else exact.sequence[tag.tagName] = tag;
669 + break;
670 + case "mapping":
671 + if (tag.matchByTagPrefix) prefix.mapping.push(tag);
672 + else exact.mapping[tag.tagName] = tag;
673 + break;
676 + const implicitScalarAnyFirstChar = implicitScalarTags.filter((tag) => tag.implicitFirstChars === null);
677 + const keys = /* @__PURE__ */ new Set();
678 + for (const tag of implicitScalarTags) if (tag.implicitFirstChars !== null) for (const key of tag.implicitFirstChars) keys.add(key);
679 + const implicitScalarByFirstChar = /* @__PURE__ */ new Map();
680 + for (const key of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag) => tag.implicitFirstChars === null || tag.implicitFirstChars.indexOf(key) !== -1));
681 + const defaultScalarTag = exact.scalar["tag:yaml.org,2002:str"];
682 + if (!defaultScalarTag) throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");
683 + this.tags = compiledTags;
684 + this.implicitScalarTags = implicitScalarTags;
685 + this.implicitScalarByFirstChar = implicitScalarByFirstChar;
686 + this.implicitScalarAnyFirstChar = implicitScalarAnyFirstChar;
687 + this.defaultScalarTag = defaultScalarTag;
688 + this.defaultSequenceTag = exact.sequence["tag:yaml.org,2002:seq"];
689 + this.defaultMappingTag = exact.mapping["tag:yaml.org,2002:map"];
690 + this.exact = exact;
691 + this.prefix = prefix;
693 + /** @internal */
694 + lookupScalarTag(tagName) {
695 + const exactTag = this.exact.scalar[tagName];
696 + if (exactTag) return exactTag;
697 + for (const tag of this.prefix.scalar) if (tagName.startsWith(tag.tagName)) return tag;
699 + /** @internal */
700 + lookupSequenceTag(tagName) {
701 + const exactTag = this.exact.sequence[tagName];
702 + if (exactTag) return exactTag;
703 + for (const tag of this.prefix.sequence) if (tagName.startsWith(tag.tagName)) return tag;
705 + /** @internal */
706 + lookupMappingTag(tagName) {
707 + const exactTag = this.exact.mapping[tagName];
708 + if (exactTag) return exactTag;
709 + for (const tag of this.prefix.mapping) if (tagName.startsWith(tag.tagName)) return tag;
711 + /** @internal */
712 + resolveImplicitScalarTag(source) {
713 + const candidates = this.implicitScalarByFirstChar.get(source.charAt(0)) ?? this.implicitScalarAnyFirstChar;
714 + for (const tag2 of candidates) {
715 + const value = tag2.resolve(source, false, tag2.tagName);
716 + if (value !== NOT_RESOLVED) return {
717 + value,
718 + tag: tag2
719 + };
721 + const tag = this.defaultScalarTag;
722 + return {
723 + value: tag.resolve(source, false, tag.tagName),
724 + tag
725 + };
727 + /**
728 + * Creates a new schema with the specified tags added. If a tag already
729 + * exists, it is replaced by the specified tag.
731 + * @example
733 + * ```javascript
734 + * import { CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
736 + * const schema = CORE_SCHEMA.withTags(mergeTag, realMapTag)
737 + * ```
738 + */
739 + withTags(...tags) {
740 + let flatTags = [];
741 + for (const tag of tags) flatTags = flatTags.concat(tag);
742 + return new Schema2([...this.tags, ...flatTags]);
745 +var FAILSAFE_SCHEMA = new Schema([
746 + strTag,
747 + seqTag,
748 + mapTag
749 +]);
750 +var JSON_SCHEMA = new Schema([
751 + ...FAILSAFE_SCHEMA.tags,
752 + nullJsonTag,
753 + boolJsonTag,
754 + intJsonTag,
755 + floatJsonTag
756 +]);
757 +var CORE_SCHEMA = new Schema([
758 + ...FAILSAFE_SCHEMA.tags,
759 + nullCoreTag,
760 + boolCoreTag,
761 + intCoreTag,
762 + floatCoreTag
763 +]);
764 +var YAML11_SCHEMA = new Schema([
765 + ...FAILSAFE_SCHEMA.tags,
766 + nullYaml11Tag,
767 + boolYaml11Tag,
768 + intYaml11Tag,
769 + floatYaml11Tag,
770 + timestampTag,
771 + mergeTag,
772 + binaryTag,
773 + omapTag,
774 + pairsTag,
775 + setTag
776 +]);
777 +var DUMP_SCHEMA = YAML11_SCHEMA.withTags({
778 + ...intYaml11Tag,
779 + resolve: (source, isExplicit, tagName) => {
780 + const result = intYaml11Tag.resolve(source, isExplicit, tagName);
781 + return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
783 +}, {
784 + ...floatYaml11Tag,
785 + resolve: (source, isExplicit, tagName) => {
786 + const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
787 + return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
789 +});
790 +var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
791 + create: () => /* @__PURE__ */ new Map(),
792 + addPair: (container, key, value) => {
793 + container.set(key, value);
794 + return "";
795 + },
796 + has: (container, key) => container.has(key),
797 + keys: (container) => container.keys(),
798 + get: (container, key) => container.get(key),
799 + identify: (data) => data instanceof Map || isPlainObject(data),
800 + represent: (data) => {
801 + if (data instanceof Map) return data;
802 + const map = /* @__PURE__ */ new Map();
803 + const obj = data;
804 + for (const key of Object.keys(obj)) map.set(key, obj[key]);
805 + return map;
807 +});
808 +function normalizeKey(key) {
809 + if (Array.isArray(key)) {
810 + const array = Array.prototype.slice.call(key);
811 + for (let index = 0; index < array.length; index++) {
812 + if (Array.isArray(array[index])) return null;
813 + if (typeof array[index] === "object" && Object.prototype.toString.call(array[index]) === "[object Object]") array[index] = "[object Object]";
815 + return String(array);
817 + if (typeof key === "object" && Object.prototype.toString.call(key) === "[object Object]") return "[object Object]";
818 + return String(key);
820 +var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
821 + create: () => ({}),
822 + identify: isPlainObject,
823 + represent: (o) => {
824 + const map = /* @__PURE__ */ new Map();
825 + for (const key of Object.keys(o)) map.set(key, o[key]);
826 + return map;
827 + },
828 + addPair: (container, key, value) => {
829 + const normalizedKey = normalizeKey(key);
830 + if (normalizedKey === null) return "nested arrays are not supported inside keys";
831 + if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
832 + value,
833 + enumerable: true,
834 + configurable: true,
835 + writable: true
836 + });
837 + else container[normalizedKey] = value;
838 + return "";
839 + },
840 + has: (container, key) => {
841 + const normalizedKey = normalizeKey(key);
842 + return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
843 + },
844 + keys: (container) => Object.keys(container),
845 + get: (container, key) => {
846 + const normalizedKey = String(key);
847 + if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
848 + return container[normalizedKey];
850 +});
851 +var DEFAULT_SNIPPET_OPTIONS = {
852 + maxLength: 79,
853 + indent: 1,
854 + linesBefore: 3,
855 + linesAfter: 2
857 +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
858 + let head = "";
859 + let tail = "";
860 + const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
861 + if (position - lineStart > maxHalfLength) {
862 + head = " ... ";
863 + lineStart = position - maxHalfLength + head.length;
865 + if (lineEnd - position > maxHalfLength) {
866 + tail = " ...";
867 + lineEnd = position + maxHalfLength - tail.length;
869 + return {
870 + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
871 + pos: position - lineStart + head.length
872 + };
874 +function padStart(string, max) {
875 + return " ".repeat(Math.max(max - string.length, 0)) + string;
877 +function makeSnippet(mark, options) {
878 + if (!mark.buffer) return null;
879 + const opts = {
880 + ...DEFAULT_SNIPPET_OPTIONS,
881 + ...options
882 + };
883 + const re = /\r?\n|\r|\0/g;
884 + const lineStarts = [0];
885 + const lineEnds = [];
886 + let match;
887 + let foundLineNo = -1;
888 + while (match = re.exec(mark.buffer)) {
889 + lineEnds.push(match.index);
890 + lineStarts.push(match.index + match[0].length);
891 + if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
893 + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
894 + let result = "";
895 + const lineNoLength = Math.min(mark.line + opts.linesAfter, lineEnds.length).toString().length;
896 + const maxLineLength = opts.maxLength - (opts.indent + lineNoLength + 3);
897 + for (let i = 1; i <= opts.linesBefore; i++) {
898 + if (foundLineNo - i < 0) break;
899 + const line2 = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
900 + result = `${" ".repeat(opts.indent)}${padStart((mark.line - i + 1).toString(), lineNoLength)} | ${line2.str}
901 +${result}`;
903 + const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
904 + result += `${" ".repeat(opts.indent)}${padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}
906 + result += `${"-".repeat(opts.indent + lineNoLength + 3 + line.pos)}^
908 + for (let i = 1; i <= opts.linesAfter; i++) {
909 + if (foundLineNo + i >= lineEnds.length) break;
910 + const line2 = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
911 + result += `${" ".repeat(opts.indent)}${padStart((mark.line + i + 1).toString(), lineNoLength)} | ${line2.str}
914 + return result.replace(/\n$/, "");
916 +function formatError(exception, compact) {
917 + let where = "";
918 + if (!exception.mark) return exception.reason;
919 + if (exception.mark.name) where += `in "${exception.mark.name}" `;
920 + where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
921 + if (!compact && exception.mark.snippet) where += `
923 +${exception.mark.snippet}`;
924 + return `${exception.reason} ${where}`;
926 +var YAMLException = class YAMLException2 extends Error {
927 + reason;
928 + mark;
929 + /**
930 + * Optional `mark` contains source snippet data. Usually, use
931 + * {@link YAMLException.throwAt} instead of passing it directly.
932 + */
933 + constructor(reason, mark) {
934 + super();
935 + this.name = "YAMLException";
936 + this.reason = reason;
937 + this.mark = mark;
938 + this.message = formatError(this, false);
939 + if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
941 + /**
942 + * Returns the formatted error, omitting the source snippet in compact mode.
943 + */
944 + toString(compact) {
945 + return `${this.name}: ${formatError(this, compact)}`;
947 + /**
948 + * Builds a YAMLException with a source snippet and throws it. `source` is
949 + * the raw input text; `position` is an offset into it.
950 + */
951 + static throwAt(source, position, message, filename = "") {
952 + let line = 0;
953 + let lineStart = 0;
954 + for (let index = 0; index < position; index++) {
955 + const ch = source.charCodeAt(index);
956 + if (ch === 10) {
957 + line++;
958 + lineStart = index + 1;
959 + } else if (ch === 13) {
960 + line++;
961 + if (source.charCodeAt(index + 1) === 10) index++;
962 + lineStart = index + 1;
965 + const mark = {
966 + name: filename,
967 + buffer: source,
968 + position,
969 + line,
970 + column: position - lineStart
971 + };
972 + mark.snippet = makeSnippet(mark);
973 + throw new YAMLException2(message, mark);
976 +var EVENT_ID = {
977 + DOCUMENT: 1,
978 + SEQUENCE: 2,
979 + MAPPING: 3,
980 + SCALAR: 4,
981 + ALIAS: 5,
982 + POP: 6
984 +var SCALAR_STYLE = {
985 + PLAIN: 1,
986 + SINGLE_QUOTED: 2,
987 + DOUBLE_QUOTED: 3,
988 + LITERAL_BLOCK: 4,
989 + FOLDED_BLOCK: 5
991 +var COLLECTION_STYLE = {
992 + BLOCK: 1,
993 + FLOW: 2
995 +var CHOMPING_MODE = {
996 + CLIP: 1,
997 + STRIP: 2,
998 + KEEP: 3
1000 +var NO_RANGE$3 = -1;
1001 +function simpleEscapeSequence(c) {
1002 + switch (c) {
1003 + case 48:
1004 + return "\0";
1005 + case 97:
1006 + return "\x07";
1007 + case 98:
1008 + return "\b";
1009 + case 116:
1010 + return " ";
1011 + case 9:
1012 + return " ";
1013 + case 110:
1014 + return "\n";
1015 + case 118:
1016 + return "\v";
1017 + case 102:
1018 + return "\f";
1019 + case 114:
1020 + return "\r";
1021 + case 101:
1022 + return "\x1B";
1023 + case 32:
1024 + return " ";
1025 + case 34:
1026 + return '"';
1027 + case 47:
1028 + return "/";
1029 + case 92:
1030 + return "\\";
1031 + case 78:
1032 + return "\x85";
1033 + case 95:
1034 + return "\xA0";
1035 + case 76:
1036 + return "\u2028";
1037 + case 80:
1038 + return "\u2029";
1039 + default:
1040 + return "";
1043 +var simpleEscapeCheck = new Array(256);
1044 +var simpleEscapeMap = new Array(256);
1045 +for (let i = 0; i < 256; i++) {
1046 + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1047 + simpleEscapeMap[i] = simpleEscapeSequence(i);
1049 +function charFromCodepoint(c) {
1050 + if (c <= 65535) return String.fromCharCode(c);
1051 + return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
1053 +function fromHexCode$1(c) {
1054 + if (c >= 48 && c <= 57) return c - 48;
1055 + return (c | 32) - 97 + 10;
1057 +function escapedHexLen$1(c) {
1058 + if (c === 120) return 2;
1059 + if (c === 117) return 4;
1060 + return 8;
1062 +function skipFoldedBreaks(input, position, end) {
1063 + let breaks = 0;
1064 + while (position < end) {
1065 + const ch = input.charCodeAt(position);
1066 + if (ch === 10) {
1067 + breaks++;
1068 + position++;
1069 + } else if (ch === 13) {
1070 + breaks++;
1071 + position++;
1072 + if (input.charCodeAt(position) === 10) position++;
1073 + } else if (ch === 32 || ch === 9) position++;
1074 + else break;
1076 + return {
1077 + position,
1078 + breaks
1079 + };
1081 +function foldedBreaks(count) {
1082 + if (count === 1) return " ";
1083 + return "\n".repeat(count - 1);
1085 +function getPlainValue(input, start, end) {
1086 + let result = "";
1087 + let position = start;
1088 + let captureStart = start;
1089 + let captureEnd = start;
1090 + while (position < end) {
1091 + const ch = input.charCodeAt(position);
1092 + if (ch === 10 || ch === 13) {
1093 + result += input.slice(captureStart, captureEnd);
1094 + const fold = skipFoldedBreaks(input, position, end);
1095 + result += foldedBreaks(fold.breaks);
1096 + position = captureStart = captureEnd = fold.position;
1097 + } else {
1098 + position++;
1099 + if (ch !== 32 && ch !== 9) captureEnd = position;
1102 + return result + input.slice(captureStart, captureEnd);
1104 +function getSingleQuotedValue(input, start, end) {
1105 + let result = "";
1106 + let position = start;
1107 + let captureStart = start;
1108 + let captureEnd = start;
1109 + while (position < end) {
1110 + const ch = input.charCodeAt(position);
1111 + if (ch === 39) {
1112 + result += input.slice(captureStart, position) + "'";
1113 + position += 2;
1114 + captureStart = captureEnd = position;
1115 + } else if (ch === 10 || ch === 13) {
1116 + result += input.slice(captureStart, captureEnd);
1117 + const fold = skipFoldedBreaks(input, position, end);
1118 + result += foldedBreaks(fold.breaks);
1119 + position = captureStart = captureEnd = fold.position;
1120 + } else {
1121 + position++;
1122 + if (ch !== 32 && ch !== 9) captureEnd = position;
1125 + return result + input.slice(captureStart, end);
1127 +function getDoubleQuotedValue(input, start, end) {
1128 + let result = "";
1129 + let position = start;
1130 + let captureStart = start;
1131 + let captureEnd = start;
1132 + while (position < end) {
1133 + const ch = input.charCodeAt(position);
1134 + if (ch === 92) {
1135 + result += input.slice(captureStart, position);
1136 + position++;
1137 + const escaped = input.charCodeAt(position);
1138 + if (escaped === 10 || escaped === 13) position = skipFoldedBreaks(input, position, end).position;
1139 + else if (escaped < 256 && simpleEscapeCheck[escaped]) {
1140 + result += simpleEscapeMap[escaped];
1141 + position++;
1142 + } else {
1143 + let hexLength = escapedHexLen$1(escaped);
1144 + let hexResult = 0;
1145 + for (; hexLength > 0; hexLength--) {
1146 + position++;
1147 + const digit = fromHexCode$1(input.charCodeAt(position));
1148 + hexResult = (hexResult << 4) + digit;
1150 + result += charFromCodepoint(hexResult);
1151 + position++;
1153 + captureStart = captureEnd = position;
1154 + } else if (ch === 10 || ch === 13) {
1155 + result += input.slice(captureStart, captureEnd);
1156 + const fold = skipFoldedBreaks(input, position, end);
1157 + result += foldedBreaks(fold.breaks);
1158 + position = captureStart = captureEnd = fold.position;
1159 + } else {
1160 + position++;
1161 + if (ch !== 32 && ch !== 9) captureEnd = position;
1164 + return result + input.slice(captureStart, end);
1166 +function getBlockValue(input, start, end, indent, chomping, folded) {
1167 + const textIndent = indent < 0 ? 0 : indent;
1168 + const region = input.slice(start, end).replace(/\r\n?/g, "\n");
1169 + const lines = region === "" ? [] : (region.endsWith("\n") ? region.slice(0, -1) : region).split("\n");
1170 + let result = "";
1171 + let didReadContent = false;
1172 + let emptyLines = 0;
1173 + let atMoreIndented = false;
1174 + for (const line of lines) {
1175 + let column = 0;
1176 + while (column < textIndent && line.charCodeAt(column) === 32) column++;
1177 + if (indent < 0 || column >= line.length) {
1178 + emptyLines++;
1179 + continue;
1181 + const content = line.slice(textIndent);
1182 + const first = content.charCodeAt(0);
1183 + if (folded) if (first === 32 || first === 9) {
1184 + atMoreIndented = true;
1185 + result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
1186 + } else if (atMoreIndented) {
1187 + atMoreIndented = false;
1188 + result += "\n".repeat(emptyLines + 1);
1189 + } else if (emptyLines === 0) {
1190 + if (didReadContent) result += " ";
1191 + } else result += "\n".repeat(emptyLines);
1192 + else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
1193 + result += content;
1194 + didReadContent = true;
1195 + emptyLines = 0;
1197 + if (chomping === CHOMPING_MODE.KEEP) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
1198 + else if (chomping !== CHOMPING_MODE.STRIP) {
1199 + if (didReadContent) result += "\n";
1201 + return result;
1203 +function getScalarValue(input, scalar) {
1204 + if (scalar.valueStart === NO_RANGE$3) return "";
1205 + const { valueStart, valueEnd } = scalar;
1206 + if (scalar.fast) return input.slice(valueStart, valueEnd);
1207 + switch (scalar.style) {
1208 + case SCALAR_STYLE.SINGLE_QUOTED:
1209 + return getSingleQuotedValue(input, valueStart, valueEnd);
1210 + case SCALAR_STYLE.DOUBLE_QUOTED:
1211 + return getDoubleQuotedValue(input, valueStart, valueEnd);
1212 + case SCALAR_STYLE.LITERAL_BLOCK:
1213 + return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
1214 + case SCALAR_STYLE.FOLDED_BLOCK:
1215 + return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
1216 + default:
1217 + return getPlainValue(input, valueStart, valueEnd);
1220 +var DEFAULT_TAG_HANDLERS = Object.assign(/* @__PURE__ */ Object.create(null), {
1221 + "!": "!",
1222 + "!!": "tag:yaml.org,2002:"
1223 +});
1224 +function tagNameFull(rawTag, tagHandlers) {
1225 + if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
1226 + const handleEnd = rawTag.indexOf("!", 1);
1227 + const handle = handleEnd === -1 ? "!" : rawTag.slice(0, handleEnd + 1);
1228 + const prefix = tagHandlers?.[handle] ?? DEFAULT_TAG_HANDLERS[handle] ?? handle;
1229 + return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
1231 +var NO_RANGE$2 = -1;
1232 +var MERGE_TAG_NAME = "tag:yaml.org,2002:merge";
1233 +var DEFAULT_CONSTRUCTOR_OPTIONS = {
1234 + filename: "",
1235 + schema: CORE_SCHEMA,
1236 + json: false,
1237 + maxTotalMergeKeys: 1e4,
1238 + maxAliases: -1
1240 +function eventPosition$1(event) {
1241 + if ("tagStart" in event && event.tagStart !== NO_RANGE$2) return event.tagStart;
1242 + if ("anchorStart" in event && event.anchorStart !== NO_RANGE$2) return event.anchorStart;
1243 + if ("valueStart" in event && event.valueStart !== NO_RANGE$2) return event.valueStart;
1244 + if ("start" in event) return event.start;
1245 + return 0;
1247 +function throwError$1(state, message) {
1248 + YAMLException.throwAt(state.source, state.position, message, state.filename);
1250 +function finalizeCollection(state, position, tag, carrier) {
1251 + try {
1252 + return tag.finalize(carrier);
1253 + } catch (error) {
1254 + if (error instanceof YAMLException) throw error;
1255 + YAMLException.throwAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
1258 +function constructScalar(state, event) {
1259 + const source = getScalarValue(state.source, event);
1260 + const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
1261 + const strTag2 = state.schema.defaultScalarTag;
1262 + if (rawTag !== "") {
1263 + if (rawTag === "!") return {
1264 + value: source,
1265 + tag: strTag2
1266 + };
1267 + const tagName = tagNameFull(rawTag, state.tagHandlers);
1268 + const scalarTag = state.schema.lookupScalarTag(tagName);
1269 + if (scalarTag) {
1270 + const result = scalarTag.resolve(source, true, tagName);
1271 + if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
1272 + return {
1273 + value: result,
1274 + tag: scalarTag
1275 + };
1277 + const collectionTagDef = state.schema.lookupMappingTag(tagName) ?? state.schema.lookupSequenceTag(tagName);
1278 + if (collectionTagDef) {
1279 + if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
1280 + const carrier = collectionTagDef.create(tagName);
1281 + return {
1282 + value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier),
1283 + tag: collectionTagDef
1284 + };
1286 + throwError$1(state, `unknown scalar tag !<${tagName}>`);
1288 + if (event.style === SCALAR_STYLE.PLAIN) return state.schema.resolveImplicitScalarTag(source);
1289 + return {
1290 + value: strTag2.resolve(source, false, strTag2.tagName),
1291 + tag: strTag2
1292 + };
1294 +function collectionTagName(state, event, defaultTagName) {
1295 + const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
1296 + return rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
1298 +function isMappingTag(tag) {
1299 + return tag.nodeKind === "mapping";
1301 +function chargeMergeWork(state) {
1302 + state.totalMergeKeys++;
1303 + if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
1305 +function mergeKeys(state, frame, source, sourceTag) {
1306 + chargeMergeWork(state);
1307 + for (const sourceKey of sourceTag.keys(source)) {
1308 + chargeMergeWork(state);
1309 + if (frame.tag.has(frame.value, sourceKey)) continue;
1310 + const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
1311 + if (err) throwError$1(state, err);
1312 + frame.overridable ??= /* @__PURE__ */ new Set();
1313 + frame.overridable.add(sourceKey);
1316 +function mergeSource(state, frame, source, sourceTag) {
1317 + state.position = frame.keyPosition;
1318 + if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
1319 + else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) {
1320 + if (source.length > 100) throwError$1(state, "abnormal merge sequence size");
1321 + for (const element of source) {
1322 + const elementTag = state.nodeTags.get(element);
1323 + if (!elementTag) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
1324 + mergeKeys(state, frame, element, elementTag);
1326 + } else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
1328 +function addMappingValue(state, frame, key, value, tag) {
1329 + state.position = frame.keyPosition;
1330 + if (frame.keyIsMerge) {
1331 + mergeSource(state, frame, value, tag);
1332 + return;
1334 + if (!state.json && frame.tag.has(frame.value, key) && !frame.overridable?.has(key)) throwError$1(state, "duplicated mapping key");
1335 + const err = frame.tag.addPair(frame.value, key, value);
1336 + if (err) throwError$1(state, err);
1337 + frame.overridable?.delete(key);
1339 +function addValue(state, value, tag) {
1340 + const frame = state.frames[state.frames.length - 1];
1341 + if (frame.kind === "document") {
1342 + frame.value = value;
1343 + frame.hasValue = true;
1344 + } else if (frame.kind === "sequence") {
1345 + if (isMappingTag(tag)) state.nodeTags.set(value, tag);
1346 + const err = frame.tag.addItem(frame.value, value, frame.index++);
1347 + if (err) throwError$1(state, err);
1348 + } else if (frame.hasKey) {
1349 + const key = frame.key;
1350 + frame.key = void 0;
1351 + frame.hasKey = false;
1352 + addMappingValue(state, frame, key, value, tag);
1353 + } else {
1354 + frame.key = value;
1355 + frame.keyPosition = state.position;
1356 + frame.hasKey = true;
1357 + frame.keyIsMerge = tag.tagName === MERGE_TAG_NAME;
1360 +function storeAnchor(state, event, value, tag, isValueFinal) {
1361 + if (event.anchorStart !== NO_RANGE$2) {
1362 + const anchor = {
1363 + value,
1364 + tag,
1365 + isValueFinal
1366 + };
1367 + state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
1368 + return anchor;
1370 + return null;
1372 +function constructFromEvents(events, options) {
1373 + const state = {
1374 + ...DEFAULT_CONSTRUCTOR_OPTIONS,
1375 + ...options,
1376 + events,
1377 + documents: [],
1378 + eventIndex: 0,
1379 + position: 0,
1380 + frames: [],
1381 + anchors: /* @__PURE__ */ new Map(),
1382 + nodeTags: /* @__PURE__ */ new Map(),
1383 + tagHandlers: /* @__PURE__ */ Object.create(null),
1384 + totalMergeKeys: 0,
1385 + aliasCount: 0
1386 + };
1387 + while (state.eventIndex < state.events.length) {
1388 + const event = state.events[state.eventIndex++];
1389 + state.position = eventPosition$1(event);
1390 + switch (event.type) {
1391 + case EVENT_ID.DOCUMENT:
1392 + state.anchors = /* @__PURE__ */ new Map();
1393 + state.nodeTags = /* @__PURE__ */ new Map();
1394 + state.aliasCount = 0;
1395 + state.tagHandlers = /* @__PURE__ */ Object.create(null);
1396 + for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
1397 + state.frames.push({
1398 + kind: "document",
1399 + position: state.position,
1400 + value: void 0,
1401 + hasValue: false
1402 + });
1403 + break;
1404 + case EVENT_ID.SCALAR: {
1405 + const { value, tag } = constructScalar(state, event);
1406 + storeAnchor(state, event, value, tag, true);
1407 + addValue(state, value, tag);
1408 + break;
1410 + case EVENT_ID.SEQUENCE: {
1411 + const tagName = collectionTagName(state, event, "tag:yaml.org,2002:seq");
1412 + const tag = state.schema.lookupSequenceTag(tagName);
1413 + if (!tag) throwError$1(state, `unknown sequence tag !<${tagName}>`);
1414 + const value = tag.create(tagName);
1415 + const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
1416 + state.frames.push({
1417 + kind: "sequence",
1418 + position: state.position,
1419 + value,
1420 + tag,
1421 + anchor,
1422 + index: 0
1423 + });
1424 + break;
1426 + case EVENT_ID.MAPPING: {
1427 + const tagName = collectionTagName(state, event, "tag:yaml.org,2002:map");
1428 + const tag = state.schema.lookupMappingTag(tagName);
1429 + if (!tag) throwError$1(state, `unknown mapping tag !<${tagName}>`);
1430 + const value = tag.create(tagName);
1431 + const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
1432 + state.frames.push({
1433 + kind: "mapping",
1434 + position: state.position,
1435 + value,
1436 + tag,
1437 + anchor,
1438 + key: void 0,
1439 + keyPosition: state.position,
1440 + hasKey: false,
1441 + keyIsMerge: false,
1442 + overridable: null
1443 + });
1444 + break;
1446 + case EVENT_ID.ALIAS: {
1447 + if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
1448 + const name = state.source.slice(event.anchorStart, event.anchorEnd);
1449 + const anchor = state.anchors.get(name);
1450 + if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
1451 + if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
1452 + addValue(state, anchor.value, anchor.tag);
1453 + break;
1455 + case EVENT_ID.POP: {
1456 + const frame = state.frames.pop();
1457 + if (frame.kind === "mapping" && frame.hasKey) {
1458 + state.position = frame.keyPosition;
1459 + throwError$1(state, "incomplete mapping pair in event stream");
1461 + if (frame.kind === "document") state.documents.push(frame.value);
1462 + else {
1463 + const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
1464 + if (frame.anchor) {
1465 + frame.anchor.value = value;
1466 + frame.anchor.isValueFinal = true;
1468 + addValue(state, value, frame.tag);
1470 + break;
1474 + return state.documents;
1476 +var NO_RANGE$1 = -1;
1477 +var HAS_OWN = Object.prototype.hasOwnProperty;
1478 +var CONTEXT_FLOW_IN = 1;
1479 +var CONTEXT_FLOW_OUT = 2;
1480 +var CONTEXT_BLOCK_IN = 3;
1481 +var CONTEXT_BLOCK_OUT = 4;
1482 +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1483 +var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
1484 +var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
1485 +var NS_URI_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
1486 +var NS_TAG_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
1487 +var PATTERN_TAG_URI = new RegExp(`^(?:${NS_URI_CHAR})*$`);
1488 +var PATTERN_TAG_SUFFIX = new RegExp(`^(?:${NS_TAG_CHAR})+$`);
1489 +var PATTERN_TAG_PREFIX = new RegExp(`^(?:!(?:${NS_URI_CHAR})*|${NS_TAG_CHAR}(?:${NS_URI_CHAR})*)$`);
1490 +var DEFAULT_PARSER_OPTIONS = {
1491 + filename: "",
1492 + maxDepth: 100
1494 +function addDocumentEvent(state, explicitStart, explicitEnd) {
1495 + state.events.push({
1496 + type: EVENT_ID.DOCUMENT,
1497 + explicitStart,
1498 + explicitEnd,
1499 + directives: state.directives
1500 + });
1502 +function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
1503 + state.events.push({
1504 + type: EVENT_ID.SEQUENCE,
1505 + start,
1506 + anchorStart,
1507 + anchorEnd,
1508 + tagStart,
1509 + tagEnd,
1510 + style
1511 + });
1513 +function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
1514 + state.events.push({
1515 + type: EVENT_ID.MAPPING,
1516 + start,
1517 + anchorStart,
1518 + anchorEnd,
1519 + tagStart,
1520 + tagEnd,
1521 + style
1522 + });
1524 +function insertFlowPairMappingEvent(state, snapshot) {
1525 + state.events.splice(snapshot.eventsLength, 0, {
1526 + type: EVENT_ID.MAPPING,
1527 + start: snapshot.position,
1528 + anchorStart: NO_RANGE$1,
1529 + anchorEnd: NO_RANGE$1,
1530 + tagStart: NO_RANGE$1,
1531 + tagEnd: NO_RANGE$1,
1532 + style: COLLECTION_STYLE.FLOW
1533 + });
1535 +function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = CHOMPING_MODE.CLIP, indent = -1, fast = false) {
1536 + state.events.push({
1537 + type: EVENT_ID.SCALAR,
1538 + valueStart,
1539 + valueEnd,
1540 + anchorStart,
1541 + anchorEnd,
1542 + tagStart,
1543 + tagEnd,
1544 + style,
1545 + chomping,
1546 + indent,
1547 + fast
1548 + });
1550 +function addAliasEvent(state, anchorStart, anchorEnd) {
1551 + state.events.push({
1552 + type: EVENT_ID.ALIAS,
1553 + anchorStart,
1554 + anchorEnd
1555 + });
1557 +function addPopEvent(state) {
1558 + state.events.push({ type: EVENT_ID.POP });
1560 +function addEmptyScalarEvent(state) {
1561 + addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, SCALAR_STYLE.PLAIN);
1563 +function emptyProperties() {
1564 + return {
1565 + anchorStart: NO_RANGE$1,
1566 + anchorEnd: NO_RANGE$1,
1567 + tagStart: NO_RANGE$1,
1568 + tagEnd: NO_RANGE$1
1569 + };
1571 +function snapshotState(state) {
1572 + return {
1573 + position: state.position,
1574 + line: state.line,
1575 + lineStart: state.lineStart,
1576 + lineIndent: state.lineIndent,
1577 + firstTabInLine: state.firstTabInLine,
1578 + eventsLength: state.events.length
1579 + };
1581 +function restoreState(state, snapshot) {
1582 + state.position = snapshot.position;
1583 + state.line = snapshot.line;
1584 + state.lineStart = snapshot.lineStart;
1585 + state.lineIndent = snapshot.lineIndent;
1586 + state.firstTabInLine = snapshot.firstTabInLine;
1587 + state.events.length = snapshot.eventsLength;
1589 +function throwError(state, message) {
1590 + YAMLException.throwAt(state.input.slice(0, state.length), state.position, message, state.filename);
1592 +function isEol(c) {
1593 + return c === 10 || c === 13;
1595 +function isWhiteSpace(c) {
1596 + return c === 9 || c === 32;
1598 +function isWsOrEol(c) {
1599 + return isWhiteSpace(c) || isEol(c);
1601 +function isWsOrEolOrEnd(c) {
1602 + return c === 0 || isWsOrEol(c);
1604 +function isFlowIndicator(c) {
1605 + return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1607 +function fromDecimalCode(c) {
1608 + return c >= 48 && c <= 57 ? c - 48 : -1;
1610 +function fromHexCode(c) {
1611 + if (c >= 48 && c <= 57) return c - 48;
1612 + const lc = c | 32;
1613 + if (lc >= 97 && lc <= 102) return lc - 97 + 10;
1614 + return -1;
1616 +function escapedHexLen(c) {
1617 + if (c === 120) return 2;
1618 + if (c === 117) return 4;
1619 + if (c === 85) return 8;
1620 + return 0;
1622 +function isSimpleEscape(c) {
1623 + return c === 48 || c === 97 || c === 98 || c === 116 || c === 9 || c === 110 || c === 118 || c === 102 || c === 114 || c === 101 || c === 32 || c === 34 || c === 47 || c === 92 || c === 78 || c === 95 || c === 76 || c === 80;
1625 +function consumeLineBreak(state) {
1626 + if (state.input.charCodeAt(state.position) === 10) state.position++;
1627 + else {
1628 + state.position++;
1629 + if (state.input.charCodeAt(state.position) === 10) state.position++;
1631 + state.line++;
1632 + state.lineStart = state.position;
1633 + state.lineIndent = 0;
1634 + state.firstTabInLine = -1;
1636 +function skipSeparationSpace(state, allowComments) {
1637 + let lineBreaks = 0;
1638 + let ch = state.input.charCodeAt(state.position);
1639 + let hasSeparation = state.position === state.lineStart || isWsOrEol(state.input.charCodeAt(state.position - 1));
1640 + while (ch !== 0) {
1641 + while (isWhiteSpace(ch)) {
1642 + hasSeparation = true;
1643 + if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
1644 + ch = state.input.charCodeAt(++state.position);
1646 + if (allowComments && hasSeparation && ch === 35) do
1647 + ch = state.input.charCodeAt(++state.position);
1648 + while (!isEol(ch) && ch !== 0);
1649 + if (!isEol(ch)) break;
1650 + consumeLineBreak(state);
1651 + lineBreaks++;
1652 + hasSeparation = true;
1653 + ch = state.input.charCodeAt(state.position);
1654 + while (ch === 32) {
1655 + state.lineIndent++;
1656 + ch = state.input.charCodeAt(++state.position);
1659 + return lineBreaks;
1661 +function testDocumentSeparator(state, position = state.position) {
1662 + const ch = state.input.charCodeAt(position);
1663 + if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(position + 1) && ch === state.input.charCodeAt(position + 2)) {
1664 + const following = state.input.charCodeAt(position + 3);
1665 + return following === 0 || isWsOrEol(following);
1667 + return false;
1669 +function skipByteOrderMark(state) {
1670 + if (state.position === state.lineStart && state.input.charCodeAt(state.position) === 65279) {
1671 + state.position++;
1672 + state.lineStart = state.position;
1675 +function testDocumentBoundary(state) {
1676 + if (state.position !== state.lineStart) return false;
1677 + if (testDocumentSeparator(state)) return true;
1678 + if (state.input.charCodeAt(state.position) !== 65279) return false;
1679 + const snapshot = snapshotState(state);
1680 + skipByteOrderMark(state);
1681 + skipSeparationSpace(state, true);
1682 + const ch = state.input.charCodeAt(state.position);
1683 + const result = state.position === state.lineStart && (ch === 37 || ch === 45 && testDocumentSeparator(state));
1684 + restoreState(state, snapshot);
1685 + return result;
1687 +function skipUntilLineEnd(state) {
1688 + let ch = state.input.charCodeAt(state.position);
1689 + while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
1691 +function checkPrintable(state, start, end) {
1692 + if (PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state, "the stream contains non-printable characters");
1694 +function readTagProperty(state, props, inFlow) {
1695 + if (state.input.charCodeAt(state.position) !== 33) return false;
1696 + if (props.tagStart !== NO_RANGE$1) throwError(state, "duplication of a tag property");
1697 + const start = state.position;
1698 + let isVerbatim = false;
1699 + let isNamed = false;
1700 + let tagHandle = "!";
1701 + let ch = state.input.charCodeAt(++state.position);
1702 + if (ch === 60) {
1703 + isVerbatim = true;
1704 + ch = state.input.charCodeAt(++state.position);
1705 + } else if (ch === 33) {
1706 + isNamed = true;
1707 + tagHandle = "!!";
1708 + ch = state.input.charCodeAt(++state.position);
1710 + let suffixStart = state.position;
1711 + let tagName;
1712 + if (isVerbatim) {
1713 + while (ch !== 0 && ch !== 62) ch = state.input.charCodeAt(++state.position);
1714 + if (ch !== 62) throwError(state, "unexpected end of the stream within a verbatim tag");
1715 + tagName = state.input.slice(suffixStart, state.position);
1716 + state.position++;
1717 + } else {
1718 + while (ch !== 0 && !isWsOrEol(ch) && !(inFlow && isFlowIndicator(ch))) {
1719 + if (ch === 33) if (!isNamed) {
1720 + tagHandle = state.input.slice(suffixStart - 1, state.position + 1);
1721 + if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
1722 + isNamed = true;
1723 + suffixStart = state.position + 1;
1724 + } else throwError(state, "tag suffix cannot contain exclamation marks");
1725 + ch = state.input.charCodeAt(++state.position);
1727 + tagName = state.input.slice(suffixStart, state.position);
1728 + if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
1730 + if (tagName && !(isVerbatim ? PATTERN_TAG_URI.test(tagName) : PATTERN_TAG_SUFFIX.test(tagName))) throwError(state, `tag name cannot contain such characters: ${tagName}`);
1731 + if (!isVerbatim && tagHandle !== "!" && tagHandle !== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state, `undeclared tag handle "${tagHandle}"`);
1732 + props.tagStart = start;
1733 + props.tagEnd = state.position;
1734 + return true;
1736 +function readAnchorProperty(state, props) {
1737 + if (state.input.charCodeAt(state.position) !== 38) return false;
1738 + if (props.anchorStart !== NO_RANGE$1) throwError(state, "duplication of an anchor property");
1739 + state.position++;
1740 + const start = state.position;
1741 + while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
1742 + if (state.position === start) throwError(state, "name of an anchor node must contain at least one character");
1743 + props.anchorStart = start;
1744 + props.anchorEnd = state.position;
1745 + return true;
1747 +function readAlias(state, props) {
1748 + if (state.input.charCodeAt(state.position) !== 42) return false;
1749 + if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) throwError(state, "alias node should not have any properties");
1750 + state.position++;
1751 + const start = state.position;
1752 + while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
1753 + if (state.position === start) throwError(state, "name of an alias node must contain at least one character");
1754 + addAliasEvent(state, start, state.position);
1755 + return true;
1757 +function readFlowScalarBreak(state, nodeIndent) {
1758 + skipSeparationSpace(state, false);
1759 + if (state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
1761 +function readSingleQuotedScalar(state, nodeIndent, props) {
1762 + if (state.input.charCodeAt(state.position) !== 39) return false;
1763 + state.position++;
1764 + const start = state.position;
1765 + let simple = true;
1766 + while (state.input.charCodeAt(state.position) !== 0) {
1767 + const ch = state.input.charCodeAt(state.position);
1768 + if (ch === 39) {
1769 + if (state.input.charCodeAt(state.position + 1) === 39) {
1770 + simple = false;
1771 + state.position += 2;
1772 + continue;
1774 + const end = state.position;
1775 + state.position++;
1776 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.SINGLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
1777 + return true;
1779 + if (isEol(ch)) {
1780 + simple = false;
1781 + readFlowScalarBreak(state, nodeIndent);
1782 + } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
1783 + else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
1784 + else state.position++;
1786 + throwError(state, "unexpected end of the stream within a single quoted scalar");
1788 +function readDoubleQuotedScalar(state, nodeIndent, props) {
1789 + if (state.input.charCodeAt(state.position) !== 34) return false;
1790 + state.position++;
1791 + const start = state.position;
1792 + let simple = true;
1793 + while (state.input.charCodeAt(state.position) !== 0) {
1794 + const ch = state.input.charCodeAt(state.position);
1795 + if (ch === 34) {
1796 + const end = state.position;
1797 + state.position++;
1798 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.DOUBLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
1799 + return true;
1801 + if (ch === 92) {
1802 + simple = false;
1803 + const escaped = state.input.charCodeAt(++state.position);
1804 + if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
1805 + else if (isSimpleEscape(escaped)) state.position++;
1806 + else {
1807 + let hexLength = escapedHexLen(escaped);
1808 + if (hexLength === 0) throwError(state, "unknown escape sequence");
1809 + while (hexLength-- > 0) {
1810 + state.position++;
1811 + if (fromHexCode(state.input.charCodeAt(state.position)) < 0) throwError(state, "expected hexadecimal character");
1813 + state.position++;
1815 + } else if (isEol(ch)) {
1816 + simple = false;
1817 + readFlowScalarBreak(state, nodeIndent);
1818 + } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
1819 + else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
1820 + else state.position++;
1822 + throwError(state, "unexpected end of the stream within a double quoted scalar");
1824 +function readBlockScalar(state, parentIndent, props) {
1825 + const ch = state.input.charCodeAt(state.position);
1826 + let chomping = CHOMPING_MODE.CLIP;
1827 + let indent = -1;
1828 + let detectedIndent = false;
1829 + if (ch !== 124 && ch !== 62) return false;
1830 + const style = ch === 124 ? SCALAR_STYLE.LITERAL_BLOCK : SCALAR_STYLE.FOLDED_BLOCK;
1831 + state.position++;
1832 + while (state.input.charCodeAt(state.position) !== 0) {
1833 + const current = state.input.charCodeAt(state.position);
1834 + const digit = fromDecimalCode(current);
1835 + if (current === 43 || current === 45) {
1836 + if (chomping !== CHOMPING_MODE.CLIP) throwError(state, "repeat of a chomping mode identifier");
1837 + chomping = current === 43 ? CHOMPING_MODE.KEEP : CHOMPING_MODE.STRIP;
1838 + state.position++;
1839 + } else if (digit >= 0) {
1840 + if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1841 + if (detectedIndent) throwError(state, "repeat of an indentation width identifier");
1842 + indent = parentIndent + digit - 1;
1843 + detectedIndent = true;
1844 + state.position++;
1845 + } else break;
1847 + let hadWhitespace = false;
1848 + while (isWhiteSpace(state.input.charCodeAt(state.position))) {
1849 + hadWhitespace = true;
1850 + state.position++;
1852 + if (hadWhitespace && state.input.charCodeAt(state.position) === 35) skipUntilLineEnd(state);
1853 + if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
1854 + else if (state.input.charCodeAt(state.position) !== 0) throwError(state, "a line break is expected");
1855 + let contentIndent = detectedIndent ? indent : -1;
1856 + let maxLeadingIndent = 0;
1857 + const valueStart = state.position;
1858 + let valueEnd = state.position;
1859 + while (state.input.charCodeAt(state.position) !== 0) {
1860 + const linePosition = state.position;
1861 + let column = 0;
1862 + while (state.input.charCodeAt(linePosition + column) === 32) column++;
1863 + const first = state.input.charCodeAt(linePosition + column);
1864 + if (first === 0) {
1865 + if (contentIndent >= 0) {
1866 + if (column > contentIndent) valueEnd = linePosition + column;
1867 + } else if (column > 0) valueEnd = linePosition + column;
1868 + break;
1870 + if (testDocumentBoundary(state)) break;
1871 + if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
1872 + if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
1873 + if (first === 9 && column < parentIndent) {
1874 + state.position = linePosition + column;
1875 + throwError(state, "tab characters must not be used in indentation");
1877 + if (column < maxLeadingIndent) {
1878 + state.position = linePosition + column;
1879 + throwError(state, "bad indentation of a mapping entry");
1882 + if (contentIndent === -1 && first !== 0 && !isEol(first) && column < parentIndent) {
1883 + state.lineIndent = column;
1884 + state.position = linePosition + column;
1885 + break;
1887 + if (!detectedIndent && first !== 0 && !isEol(first) && contentIndent === -1) contentIndent = column;
1888 + const requiredIndent = contentIndent === -1 ? parentIndent + 1 : contentIndent;
1889 + if (first !== 0 && !isEol(first) && column < requiredIndent) {
1890 + state.lineIndent = column;
1891 + state.position = linePosition + column;
1892 + break;
1894 + skipUntilLineEnd(state);
1895 + valueEnd = state.position;
1896 + if (isEol(state.input.charCodeAt(state.position))) {
1897 + consumeLineBreak(state);
1898 + valueEnd = state.position;
1901 + checkPrintable(state, valueStart, valueEnd);
1902 + addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
1903 + return true;
1905 +function canStartPlainScalar(state, nodeContext) {
1906 + const ch = state.input.charCodeAt(state.position);
1907 + const inFlow = nodeContext === CONTEXT_FLOW_IN;
1908 + if (ch === 0 || isWsOrEol(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96 || inFlow && isFlowIndicator(ch)) return false;
1909 + if (ch === 63 || ch === 45) {
1910 + const following = state.input.charCodeAt(state.position + 1);
1911 + if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) return false;
1913 + return true;
1915 +function readPlainScalar(state, nodeIndent, nodeContext, props) {
1916 + if (!canStartPlainScalar(state, nodeContext)) return false;
1917 + const start = state.position;
1918 + let end = state.position;
1919 + let ch = state.input.charCodeAt(state.position);
1920 + const inFlow = nodeContext === CONTEXT_FLOW_IN;
1921 + let multiline = false;
1922 + while (ch !== 0) {
1923 + if (testDocumentBoundary(state)) break;
1924 + if (ch === 58) {
1925 + const following = state.input.charCodeAt(state.position + 1);
1926 + if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
1927 + } else if (ch === 35) {
1928 + if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
1929 + } else if (inFlow && isFlowIndicator(ch)) break;
1930 + else if (isEol(ch)) {
1931 + const savedPosition = state.position;
1932 + const savedLine = state.line;
1933 + const savedLineStart = state.lineStart;
1934 + const savedLineIndent = state.lineIndent;
1935 + skipSeparationSpace(state, false);
1936 + if (state.lineIndent >= nodeIndent) {
1937 + multiline = true;
1938 + ch = state.input.charCodeAt(state.position);
1939 + continue;
1941 + state.position = savedPosition;
1942 + state.line = savedLine;
1943 + state.lineStart = savedLineStart;
1944 + state.lineIndent = savedLineIndent;
1945 + break;
1947 + if (!isWhiteSpace(ch)) end = state.position + 1;
1948 + ch = state.input.charCodeAt(++state.position);
1950 + if (end === start) return false;
1951 + checkPrintable(state, start, end);
1952 + addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN, CHOMPING_MODE.CLIP, -1, !multiline);
1953 + return true;
1955 +function skipFlowSeparationSpace(state, nodeIndent) {
1956 + const startLine = state.line;
1957 + skipSeparationSpace(state, true);
1958 + if (state.line > startLine && state.lineIndent < nodeIndent || state.firstTabInLine !== -1 && state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
1960 +function readFlowCollection(state, nodeIndent, props) {
1961 + const ch = state.input.charCodeAt(state.position);
1962 + const isMapping = ch === 123;
1963 + const start = state.position;
1964 + let readNext = true;
1965 + if (ch !== 91 && ch !== 123) return false;
1966 + const terminator = isMapping ? 125 : 93;
1967 + if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
1968 + else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
1969 + state.position++;
1970 + while (state.input.charCodeAt(state.position) !== 0) {
1971 + skipFlowSeparationSpace(state, nodeIndent);
1972 + let ch2 = state.input.charCodeAt(state.position);
1973 + if (ch2 === terminator) {
1974 + state.position++;
1975 + addPopEvent(state);
1976 + return true;
1977 + } else if (!readNext) throwError(state, "missed comma between flow collection entries");
1978 + else if (ch2 === 44) throwError(state, "expected the node content, but found ','");
1979 + let isPair = false;
1980 + let isExplicitPair = false;
1981 + if (ch2 === 63 && isWsOrEol(state.input.charCodeAt(state.position + 1))) {
1982 + isPair = isExplicitPair = true;
1983 + state.position += 1;
1984 + skipFlowSeparationSpace(state, nodeIndent);
1986 + const entryLine = state.line;
1987 + const entryStart = snapshotState(state);
1988 + const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1989 + skipFlowSeparationSpace(state, nodeIndent);
1990 + ch2 = state.input.charCodeAt(state.position);
1991 + if ((isMapping || isExplicitPair || state.line === entryLine) && ch2 === 58) {
1992 + isPair = true;
1993 + state.position++;
1994 + skipFlowSeparationSpace(state, nodeIndent);
1995 + if (!isMapping) {
1996 + insertFlowPairMappingEvent(state, entryStart);
1997 + if (!keyWasRead) addEmptyScalarEvent(state);
1998 + } else if (!keyWasRead) addEmptyScalarEvent(state);
1999 + if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
2000 + skipFlowSeparationSpace(state, nodeIndent);
2001 + if (!isMapping) addPopEvent(state);
2002 + } else if (isMapping && isPair) {
2003 + if (!keyWasRead) addEmptyScalarEvent(state);
2004 + addEmptyScalarEvent(state);
2005 + } else if (isMapping) addEmptyScalarEvent(state);
2006 + else if (isPair) {
2007 + insertFlowPairMappingEvent(state, entryStart);
2008 + if (!keyWasRead) addEmptyScalarEvent(state);
2009 + addEmptyScalarEvent(state);
2010 + addPopEvent(state);
2012 + ch2 = state.input.charCodeAt(state.position);
2013 + if (ch2 === 44) {
2014 + readNext = true;
2015 + state.position++;
2016 + } else readNext = false;
2018 + throwError(state, "unexpected end of the stream within a flow collection");
2020 +function readBlockSequence(state, nodeIndent, props) {
2021 + if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
2022 + addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
2023 + while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
2024 + if (state.firstTabInLine !== -1) {
2025 + state.position = state.firstTabInLine;
2026 + throwError(state, "tab characters must not be used in indentation");
2028 + const entryLine = state.line;
2029 + state.position++;
2030 + const hadBreak = skipSeparationSpace(state, true) > 0;
2031 + if (state.firstTabInLine !== -1 && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
2032 + if (hadBreak && state.lineIndent <= nodeIndent) addEmptyScalarEvent(state);
2033 + else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
2034 + skipSeparationSpace(state, true);
2035 + if (state.lineIndent < nodeIndent || state.position >= state.length) break;
2036 + if (state.lineIndent > nodeIndent) throwError(state, "bad indentation of a sequence entry");
2037 + if (state.line === entryLine && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
2039 + addPopEvent(state);
2040 + return true;
2042 +function readBlockMapping(state, nodeIndent, flowIndent, props) {
2043 + let atExplicitKey = false;
2044 + let detected = false;
2045 + let mappingOpened = false;
2046 + let pendingExplicitKey = false;
2047 + if (state.firstTabInLine !== -1) return false;
2048 + let ch = state.input.charCodeAt(state.position);
2049 + while (ch !== 0) {
2050 + if (!atExplicitKey && state.firstTabInLine !== -1) {
2051 + state.position = state.firstTabInLine;
2052 + throwError(state, "tab characters must not be used in indentation");
2054 + const following = state.input.charCodeAt(state.position + 1);
2055 + const entryLine = state.line;
2056 + if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
2057 + if (!mappingOpened) {
2058 + addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
2059 + mappingOpened = true;
2061 + if (ch === 63) {
2062 + if (atExplicitKey) addEmptyScalarEvent(state);
2063 + detected = true;
2064 + atExplicitKey = true;
2065 + } else if (atExplicitKey) atExplicitKey = false;
2066 + else {
2067 + addEmptyScalarEvent(state);
2068 + detected = true;
2069 + atExplicitKey = false;
2071 + state.position += 1;
2072 + pendingExplicitKey = true;
2073 + } else {
2074 + if (atExplicitKey) {
2075 + addEmptyScalarEvent(state);
2076 + atExplicitKey = false;
2078 + const beforeKey = snapshotState(state);
2079 + if (!parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
2080 + if (state.line === entryLine) {
2081 + ch = state.input.charCodeAt(state.position);
2082 + while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
2083 + if (ch === 58) {
2084 + ch = state.input.charCodeAt(++state.position);
2085 + if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
2086 + if (!mappingOpened) {
2087 + restoreState(state, beforeKey);
2088 + addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
2089 + mappingOpened = true;
2090 + parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
2091 + ch = state.input.charCodeAt(state.position);
2092 + while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
2093 + state.position++;
2095 + detected = true;
2096 + atExplicitKey = false;
2097 + pendingExplicitKey = false;
2098 + } else if (detected) throwError(state, "expected ':' after a mapping key");
2099 + else {
2100 + if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
2101 + restoreState(state, beforeKey);
2102 + return false;
2104 + return true;
2106 + } else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
2107 + else {
2108 + if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
2109 + restoreState(state, beforeKey);
2110 + return false;
2112 + return true;
2115 + if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, pendingExplicitKey)) pendingExplicitKey = false;
2116 + if (!atExplicitKey) {
2117 + if (pendingExplicitKey) {
2118 + addEmptyScalarEvent(state);
2119 + pendingExplicitKey = false;
2122 + skipSeparationSpace(state, true);
2123 + ch = state.input.charCodeAt(state.position);
2124 + if ((state.line === entryLine || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
2125 + else if (state.lineIndent < nodeIndent) break;
2127 + if (!detected) return false;
2128 + if (atExplicitKey) addEmptyScalarEvent(state);
2129 + if (mappingOpened) addPopEvent(state);
2130 + return true;
2132 +function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping = true) {
2133 + if (state.depth >= state.maxDepth) throwError(state, `nesting exceeded maxDepth (${state.maxDepth})`);
2134 + state.depth++;
2135 + let indentStatus = 1;
2136 + let atNewLine = false;
2137 + let hasContent = false;
2138 + let propertyStart = null;
2139 + const props = emptyProperties();
2140 + let allowBlockScalars = nodeContext === CONTEXT_BLOCK_OUT || nodeContext === CONTEXT_BLOCK_IN;
2141 + let allowBlockCollections = allowBlockScalars;
2142 + const allowBlockStyles = allowBlockScalars;
2143 + if (allowToSeek && skipSeparationSpace(state, true)) {
2144 + atNewLine = true;
2145 + if (state.lineIndent > parentIndent) indentStatus = 1;
2146 + else if (state.lineIndent === parentIndent) indentStatus = 0;
2147 + else indentStatus = -1;
2149 + if (indentStatus === 1) while (true) {
2150 + const ch = state.input.charCodeAt(state.position);
2151 + const propertyState = snapshotState(state);
2152 + if (atNewLine && indentStatus !== 1 && (ch === 33 || ch === 38)) break;
2153 + if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
2154 + const fallbackState = snapshotState(state);
2155 + const flowIndent = parentIndent + 1;
2156 + if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) {
2157 + state.depth--;
2158 + return true;
2160 + restoreState(state, fallbackState);
2162 + if (atNewLine && (ch === 33 && props.tagStart !== NO_RANGE$1 || ch === 38 && props.anchorStart !== NO_RANGE$1)) break;
2163 + if (!readTagProperty(state, props, nodeContext === CONTEXT_FLOW_IN) && !readAnchorProperty(state, props)) break;
2164 + if (propertyStart === null) propertyStart = propertyState;
2165 + if (skipSeparationSpace(state, true)) {
2166 + atNewLine = true;
2167 + allowBlockCollections = allowBlockStyles;
2168 + if (state.lineIndent > parentIndent) indentStatus = 1;
2169 + else if (state.lineIndent === parentIndent) indentStatus = 0;
2170 + else indentStatus = -1;
2171 + } else allowBlockCollections = false;
2173 + if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
2174 + if (indentStatus === 1 || nodeContext === CONTEXT_BLOCK_OUT) {
2175 + const flowIndent = nodeContext === CONTEXT_FLOW_IN || nodeContext === CONTEXT_FLOW_OUT ? parentIndent : parentIndent + 1;
2176 + const blockIndent = state.position - state.lineStart;
2177 + if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent, props) || readBlockMapping(state, blockIndent, flowIndent, props)) || readFlowCollection(state, flowIndent, props)) hasContent = true;
2178 + else {
2179 + const ch = state.input.charCodeAt(state.position);
2180 + if (propertyStart !== null && allowPropertyMapping && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62) {
2181 + const fallbackState = snapshotState(state);
2182 + const propertyIndent = propertyStart.position - propertyStart.lineStart;
2183 + restoreState(state, propertyStart);
2184 + if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) hasContent = true;
2185 + else restoreState(state, fallbackState);
2187 + if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
2189 + else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent, props);
2191 + allowBlockScalars = allowBlockScalars && !hasContent;
2192 + if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
2193 + addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN);
2194 + hasContent = true;
2196 + state.depth--;
2197 + return hasContent || props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1;
2199 +function readDirective(state) {
2200 + if (state.lineIndent > 0 || state.input.charCodeAt(state.position) !== 37) return false;
2201 + state.position++;
2202 + const nameStart = state.position;
2203 + while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
2204 + const name = state.input.slice(nameStart, state.position);
2205 + const args = [];
2206 + if (name.length === 0) throwError(state, "directive name must not be less than one character in length");
2207 + while (state.input.charCodeAt(state.position) !== 0 && !isEol(state.input.charCodeAt(state.position))) {
2208 + while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position++;
2209 + if (state.input.charCodeAt(state.position) === 35 || isEol(state.input.charCodeAt(state.position)) || state.input.charCodeAt(state.position) === 0) break;
2210 + const start = state.position;
2211 + while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
2212 + args.push(state.input.slice(start, state.position));
2214 + if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
2215 + if (name === "YAML") {
2216 + if (state.directives.some((directive) => directive.kind === "yaml")) throwError(state, "duplication of %YAML directive");
2217 + if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
2218 + const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
2219 + if (match === null) throwError(state, "ill-formed argument of the YAML directive");
2220 + if (parseInt(match[1], 10) !== 1) throwError(state, "unacceptable YAML version of the document");
2221 + state.directives.push({
2222 + kind: "yaml",
2223 + version: args[0]
2224 + });
2225 + } else if (name === "TAG") {
2226 + if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
2227 + const [handle, prefix] = args;
2228 + if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
2229 + if (HAS_OWN.call(state.tagHandlers, handle)) throwError(state, `there is a previously declared suffix for "${handle}" tag handle`);
2230 + if (!PATTERN_TAG_PREFIX.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
2231 + state.tagHandlers[handle] = prefix;
2232 + state.directives.push({
2233 + kind: "tag",
2234 + handle,
2235 + prefix
2236 + });
2238 + return true;
2240 +function readDocument(state) {
2241 + state.directives = [];
2242 + state.tagHandlers = /* @__PURE__ */ Object.create(null);
2243 + let hasDirectives = false;
2244 + skipSeparationSpace(state, true);
2245 + while (readDirective(state)) {
2246 + hasDirectives = true;
2247 + skipSeparationSpace(state, true);
2249 + let explicitStart = false;
2250 + let explicitEnd = false;
2251 + let allowCompact = true;
2252 + if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 3))) {
2253 + explicitStart = true;
2254 + const markerLine = state.line;
2255 + state.position += 3;
2256 + skipSeparationSpace(state, true);
2257 + allowCompact = state.line > markerLine;
2258 + } else if (hasDirectives) throwError(state, "directives end mark is expected");
2259 + const documentEventIndex = state.events.length;
2260 + if (!explicitStart && state.position === state.lineStart && state.input.charCodeAt(state.position) === 46 && testDocumentSeparator(state)) {
2261 + state.position += 3;
2262 + skipSeparationSpace(state, true);
2263 + return;
2265 + addDocumentEvent(state, explicitStart, false);
2266 + if (!parseNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
2267 + skipSeparationSpace(state, true);
2268 + if (state.position === state.lineStart && testDocumentSeparator(state)) {
2269 + explicitEnd = state.input.charCodeAt(state.position) === 46;
2270 + if (explicitEnd) {
2271 + const markerLine = state.line;
2272 + state.position += 3;
2273 + skipSeparationSpace(state, true);
2274 + if (state.line === markerLine && state.position < state.length) throwError(state, "end of the stream or a document separator is expected");
2277 + const documentEvent = state.events[documentEventIndex];
2278 + if (documentEvent?.type === EVENT_ID.DOCUMENT) documentEvent.explicitEnd = explicitEnd;
2279 + addPopEvent(state);
2280 + if (!explicitEnd && state.position < state.length && !testDocumentBoundary(state)) throwError(state, "end of the stream or a document separator is expected");
2282 +function parseEvents(input, options) {
2283 + const length = input.length;
2284 + const state = {
2285 + ...DEFAULT_PARSER_OPTIONS,
2286 + ...options,
2287 + input: `${input}\0`,
2288 + length,
2289 + position: 0,
2290 + line: 0,
2291 + lineStart: 0,
2292 + lineIndent: 0,
2293 + firstTabInLine: -1,
2294 + depth: 0,
2295 + directives: [],
2296 + tagHandlers: /* @__PURE__ */ Object.create(null),
2297 + events: []
2298 + };
2299 + const nullpos = input.indexOf("\0");
2300 + if (nullpos !== -1) YAMLException.throwAt(input, nullpos, "null byte is not allowed in input", state.filename);
2301 + while (state.position < state.length) {
2302 + skipByteOrderMark(state);
2303 + skipSeparationSpace(state, true);
2304 + if (state.position >= state.length) break;
2305 + const documentStart = state.position;
2306 + readDocument(state);
2307 + if (state.position === documentStart)
2308 + throwError(state, "can not read a document");
2310 + return state.events;
2312 +var DEFAULT_LOAD_OPTIONS = {
2313 + ...DEFAULT_PARSER_OPTIONS,
2314 + ...DEFAULT_CONSTRUCTOR_OPTIONS
2316 +function loadDocuments(input, options = {}) {
2317 + const opts = {
2318 + ...DEFAULT_LOAD_OPTIONS,
2319 + ...options
2320 + };
2321 + const source = String(input);
2322 + const PARSER_OPT_KEYS = Object.keys(DEFAULT_PARSER_OPTIONS);
2323 + const CONSTRUCTOR_OPT_KEYS = Object.keys(DEFAULT_CONSTRUCTOR_OPTIONS);
2324 + return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
2325 + ...pick(opts, CONSTRUCTOR_OPT_KEYS),
2326 + source
2327 + });
2329 +function load(input, options) {
2330 + const documents = loadDocuments(input, options);
2331 + if (documents.length === 0) throw new YAMLException("expected a document, but the input is empty");
2332 + if (documents.length === 1) return documents[0];
2333 + throw new YAMLException("expected a single document in the stream, but found more");
2335 +function hasBit(mask, bit) {
2336 + return (mask & 1 << bit) !== 0;
2338 +var DEFAULT_SCALAR_STYLE_RULES = {
2339 + applyQuoteFlowKeysOption,
2340 + doubleQuoteForInvisibles,
2341 + doubleQuoteWhitespaceOnly,
2342 + applyForceQuotesOption,
2343 + tryLongOrMultilineAsBlock,
2344 + quoteInvalidPlain,
2345 + fallbackToDoubleQuoted
2347 +function _preferredQuotedStyle(layout) {
2348 + if (layout.presenterOptions.quoteStyle === "single" && hasBit(layout.allowedStylesMask, SCALAR_STYLE.SINGLE_QUOTED)) return SCALAR_STYLE.SINGLE_QUOTED;
2349 + return SCALAR_STYLE.DOUBLE_QUOTED;
2351 +function applyQuoteFlowKeysOption(layout) {
2352 + if (!layout.presenterOptions.quoteFlowKeys) return;
2353 + if (!layout.isKey || !layout.flowOnly || layout.style !== SCALAR_STYLE.PLAIN) return;
2354 + layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
2356 +function doubleQuoteForInvisibles(layout) {
2357 + if (layout.style === SCALAR_STYLE.PLAIN && /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
2359 +function doubleQuoteWhitespaceOnly(layout) {
2360 + if (layout.style === SCALAR_STYLE.PLAIN && /^\s+$/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
2362 +function applyForceQuotesOption(layout) {
2363 + if (!layout.presenterOptions.forceQuotes) return;
2364 + if (layout.isKey || layout.style !== SCALAR_STYLE.PLAIN) return;
2365 + layout.style = layout.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout);
2367 +function tryLongOrMultilineAsBlock(layout) {
2368 + if (layout.style !== SCALAR_STYLE.PLAIN || layout.isKey) return;
2369 + const value = layout.node.value;
2370 + const multiline = value.indexOf("\n") !== -1;
2371 + if (!hasBit(layout.allowedStylesMask, SCALAR_STYLE.LITERAL_BLOCK)) {
2372 + if (multiline) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
2373 + return;
2375 + const w2 = layout.presenterOptions.lineWidth;
2376 + if (w2 === -1) {
2377 + if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
2378 + return;
2380 + const availableWidth = Math.max(Math.min(w2, 40), w2 - layout.shiftOfContent);
2381 + let position = 0;
2382 + let shouldFold = false;
2383 + while (position <= value.length) {
2384 + let lineEnd = value.length;
2385 + const nextLineBreak = value.indexOf("\n", position);
2386 + if (nextLineBreak !== -1) lineEnd = nextLineBreak;
2387 + const line = value.slice(position, lineEnd);
2388 + if (line.length > availableWidth && line[0] !== " " && / [^ \t]/.test(line)) shouldFold = true;
2389 + if (nextLineBreak === -1) break;
2390 + position = nextLineBreak + 1;
2392 + if (shouldFold) layout.style = SCALAR_STYLE.FOLDED_BLOCK;
2393 + else if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
2395 +function quoteInvalidPlain(layout) {
2396 + if (layout.style === SCALAR_STYLE.PLAIN && !hasBit(layout.allowedStylesMask, SCALAR_STYLE.PLAIN)) layout.style = _preferredQuotedStyle(layout);
2398 +function fallbackToDoubleQuoted(layout) {
2399 + if (!hasBit(layout.allowedStylesMask, layout.style)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
2401 +var SRC_C_PRINTABLE = "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
2402 +var SRC_B_CHAR = "[\\n\\r]";
2403 +var SRC_C_BYTE_ORDER_MARK = "\\uFEFF";
2404 +var SRC_S_WHITE = "[ \\t]";
2405 +var SRC_NB_CHAR = `(?:(?!(?:${SRC_B_CHAR}|${SRC_C_BYTE_ORDER_MARK}))${SRC_C_PRINTABLE})`;
2406 +var SRC_NS_CHAR = `(?:(?!${SRC_S_WHITE})${SRC_NB_CHAR})`;
2407 +var SRC_NB_JSON = "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
2408 +var SRC_C_INDICATOR = "[-?:,\\[\\]{}#&*!|>'\"%@`]";
2409 +var SRC_C_FLOW_INDICATOR = "[,\\[\\]{}]";
2410 +var SRC_NS_PLAIN_SAFE_FLOW_OUT = SRC_NS_CHAR;
2411 +var SRC_NS_PLAIN_SAFE_FLOW_IN = `(?:(?!${SRC_C_FLOW_INDICATOR})${SRC_NS_CHAR})`;
2412 +var SRC_NS_PLAIN_FIRST_FLOW_OUT = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))`;
2413 +var SRC_NS_PLAIN_FIRST_FLOW_IN = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))`;
2414 +var SRC_NS_PLAIN_CHAR_FLOW_OUT = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))#*`;
2415 +var SRC_NS_PLAIN_CHAR_FLOW_IN = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))#*`;
2416 +var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_OUT})*`;
2417 +var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_IN})*`;
2418 +var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT = `${SRC_NS_PLAIN_FIRST_FLOW_OUT}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
2419 +var SRC_NS_PLAIN_ONE_LINE_FLOW_IN = `${SRC_NS_PLAIN_FIRST_FLOW_IN}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
2420 +var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
2421 +var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
2422 +var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
2423 +var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
2424 +var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT = `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT})*`;
2425 +var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN = `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN})*`;
2426 +var NS_PLAIN_FLOW_OUT = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT})$`, "u");
2427 +var NS_PLAIN_FLOW_IN = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN})$`, "u");
2428 +var NS_PLAIN_BLOCK_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY})$`, "u");
2429 +var NS_PLAIN_FLOW_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY})$`, "u");
2430 +var NB_SINGLE_ONE_LINE = new RegExp(`^(?:${SRC_NB_JSON})*$`, "u");
2431 +var NB_SINGLE_MULTI_LINE = new RegExp(`^(?:${SRC_NB_JSON}|\\n)*$`, "u");
2432 +var BLOCK_SCALAR_CONTENT = new RegExp(`^(?:${SRC_NB_CHAR}|\\n)*$`, "u");
2433 +var DEFAULT_PRESENTER_OPTIONS = {
2434 + indent: 2,
2435 + seqNoIndent: false,
2436 + seqInlineFirst: true,
2437 + lineWidth: 80,
2438 + flowBracketPadding: false,
2439 + flowSkipCommaSpace: false,
2440 + flowSkipColonSpace: false,
2441 + quoteFlowKeys: false,
2442 + quoteStyle: "single",
2443 + forceQuotes: false,
2444 + scalarStyleRules: Object.keys(DEFAULT_SCALAR_STYLE_RULES).map((name) => Reflect.get(DEFAULT_SCALAR_STYLE_RULES, name)),
2445 + tagBeforeAnchor: false
2447 +var DEFAULT_DUMP_OPTIONS = {
2448 + ...DEFAULT_PRESENTER_OPTIONS,
2449 + schema: DUMP_SCHEMA,
2450 + skipInvalid: false,
2451 + noRefs: false,
2452 + flowLevel: -1,
2453 + sortKeys: false,
2454 + transform: () => {
2457 +var EVENT_DOCUMENT = EVENT_ID.DOCUMENT;
2458 +var EVENT_SEQUENCE = EVENT_ID.SEQUENCE;
2459 +var EVENT_MAPPING = EVENT_ID.MAPPING;
2460 +var EVENT_SCALAR = EVENT_ID.SCALAR;
2461 +var EVENT_ALIAS = EVENT_ID.ALIAS;
2462 +var EVENT_POP = EVENT_ID.POP;
2463 +var SCALAR_STYLE_PLAIN = SCALAR_STYLE.PLAIN;
2464 +var SCALAR_STYLE_SINGLE_QUOTED = SCALAR_STYLE.SINGLE_QUOTED;
2465 +var SCALAR_STYLE_DOUBLE_QUOTED = SCALAR_STYLE.DOUBLE_QUOTED;
2466 +var SCALAR_STYLE_LITERAL_BLOCK = SCALAR_STYLE.LITERAL_BLOCK;
2467 +var SCALAR_STYLE_FOLDED_BLOCK = SCALAR_STYLE.FOLDED_BLOCK;
2468 +var COLLECTION_STYLE_BLOCK = COLLECTION_STYLE.BLOCK;
2469 +var COLLECTION_STYLE_FLOW = COLLECTION_STYLE.FLOW;
2470 +var CHOMPING_CLIP = CHOMPING_MODE.CLIP;
2471 +var CHOMPING_STRIP = CHOMPING_MODE.STRIP;
2472 +var CHOMPING_KEEP = CHOMPING_MODE.KEEP;
2474 +// node_modules/marked/lib/marked.esm.js
2475 +function M() {
2476 + return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
2478 +var T = M();
2479 +function N(l3) {
2480 + T = l3;
2482 +var _ = { exec: () => null };
2483 +function E(l3) {
2484 + let e = [];
2485 + return (t) => {
2486 + let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
2487 + return s || (s = l3(n), e[n] = s), s;
2488 + };
2490 +function d(l3, e = "") {
2491 + let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
2492 + let i = typeof r == "string" ? r : r.source;
2493 + return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
2494 + }, getRegex: () => new RegExp(t, e) };
2495 + return n;
2497 +var Te = ((l3 = "") => {
2498 + try {
2499 + return !!new RegExp("(?<=1)(?<!1)" + l3);
2500 + } catch {
2501 + return false;
2503 +})();
2504 +var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: E((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: E((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: E((l3) => new RegExp(`^ {0,${l3}}>`)) };
2505 +var Oe = /^(?:[ \t]*(?:\n|$))+/;
2506 +var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
2507 +var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
2508 +var B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
2509 +var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
2510 +var j = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
2511 +var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
2512 +var ae = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
2513 +var Se = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
2514 +var F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
2515 +var $e = /^[^\n]+/;
2516 +var U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
2517 +var Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
2518 +var _e = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, j).getRegex();
2519 +var H = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
2520 +var K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
2521 +var ze = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
2522 +var le = d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
2523 +var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex();
2524 +var W = { blockquote: Me, code: we, def: Le, fences: ye, heading: Pe, hr: B, html: ze, lheading: ae, list: _e, newline: Oe, paragraph: le, table: _, text: $e };
2525 +var se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
2526 +var Ee = { ...W, lheading: Se, table: se, paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex() };
2527 +var Ie = { ...W, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
2528 +]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
2529 +var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
2530 +var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
2531 +var ue = /^( {2,}|\\)\n(?!\s*$)/;
2532 +var Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
2533 +var I = /[\p{P}\p{S}]/u;
2534 +var Z = /[\s\p{P}\p{S}]/u;
2535 +var X = /[^\s\p{P}\p{S}]/u;
2536 +var De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex();
2537 +var pe = /(?!~)[\p{P}\p{S}]/u;
2538 +var qe = /(?!~)[\s\p{P}\p{S}]/u;
2539 +var ve = /(?:[^\s\p{P}\p{S}]|~)/u;
2540 +var He = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
2541 +var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
2542 +var Ze = d(ce, "u").replace(/punct/g, I).getRegex();
2543 +var Ge = d(ce, "u").replace(/punct/g, pe).getRegex();
2544 +var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
2545 +var Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2546 +var Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex();
2547 +var je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2548 +var Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex();
2549 +var Ue = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
2550 +var Ke = d(Ue, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
2551 +var We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex();
2552 +var Xe = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
2553 +var Je = d(K).replace("(?:-->|$)", "-->").getRegex();
2554 +var Ve = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
2555 +var v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
2556 +var Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
2557 +var ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex();
2558 +var de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex();
2559 +var et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
2560 +var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
2561 +var J = { _backpedal: _, anyPunctuation: We, autolink: Xe, blockSkip: He, br: ue, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Ae, link: Ye, nolink: de, punctuation: De, reflink: ke, reflinkSearch: et, tag: Ve, text: Be, url: _ };
2562 +var tt = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex() };
2563 +var Q = { ...J, emStrongRDelimAst: Qe, emStrongLDelim: Ge, delLDelim: Fe, delRDelim: Ke, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
2564 +var nt = { ...Q, br: d(ue).replace("{2,}", "*").getRegex(), text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
2565 +var D = { normal: W, gfm: Ee, pedantic: Ie };
2566 +var A = { normal: J, gfm: Q, breaks: nt, pedantic: tt };
2567 +var rt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
2568 +var ge = (l3) => rt[l3];
2569 +function O(l3, e) {
2570 + if (e) {
2571 + if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
2572 + } else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
2573 + return l3;
2575 +function V(l3) {
2576 + try {
2577 + l3 = encodeURI(l3).replace(m.percentDecode, "%");
2578 + } catch {
2579 + return null;
2581 + return l3;
2583 +function Y(l3, e) {
2584 + let t = l3.replace(m.findPipe, (r, i, o) => {
2585 + let u = false, a = i;
2586 + for (; --a >= 0 && o[a] === "\\"; ) u = !u;
2587 + return u ? "|" : " |";
2588 + }), n = t.split(m.splitPipe), s = 0;
2589 + if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
2590 + else for (; n.length < e; ) n.push("");
2591 + for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
2592 + return n;
2594 +function $(l3, e, t) {
2595 + let n = l3.length;
2596 + if (n === 0) return "";
2597 + let s = 0;
2598 + for (; s < n; ) {
2599 + let r = l3.charAt(n - s - 1);
2600 + if (r === e && !t) s++;
2601 + else if (r !== e && t) s++;
2602 + else break;
2604 + return l3.slice(0, n - s);
2606 +function ee(l3) {
2607 + let e = l3.split(`
2608 +`), t = e.length - 1;
2609 + for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
2610 + return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
2611 +`);
2613 +function fe(l3, e) {
2614 + if (l3.indexOf(e[1]) === -1) return -1;
2615 + let t = 0;
2616 + for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
2617 + else if (l3[n] === e[0]) t++;
2618 + else if (l3[n] === e[1] && (t--, t < 0)) return n;
2619 + return t > 0 ? -2 : -1;
2621 +function me(l3, e = 0) {
2622 + let t = e, n = "";
2623 + for (let s of l3) if (s === " ") {
2624 + let r = 4 - t % 4;
2625 + n += " ".repeat(r), t += r;
2626 + } else n += s, t++;
2627 + return n;
2629 +function xe(l3, e, t, n, s) {
2630 + let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
2631 + n.state.inLink = true;
2632 + let u = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
2633 + return n.state.inLink = false, u;
2635 +function st(l3, e, t) {
2636 + let n = l3.match(t.other.indentCodeCompensation);
2637 + if (n === null) return e;
2638 + let s = n[1];
2639 + return e.split(`
2640 +`).map((r) => {
2641 + let i = r.match(t.other.beginningSpace);
2642 + if (i === null) return r;
2643 + let [o] = i;
2644 + return o.length >= s.length ? r.slice(s.length) : r;
2645 + }).join(`
2646 +`);
2648 +var w = class {
2649 + options;
2650 + rules;
2651 + lexer;
2652 + constructor(e) {
2653 + this.options = e || T;
2655 + space(e) {
2656 + let t = this.rules.block.newline.exec(e);
2657 + if (t && t[0].length > 0) return { type: "space", raw: t[0] };
2659 + code(e) {
2660 + let t = this.rules.block.code.exec(e);
2661 + if (t) {
2662 + let n = this.options.pedantic ? t[0] : ee(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
2663 + return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
2666 + fences(e) {
2667 + let t = this.rules.block.fences.exec(e);
2668 + if (t) {
2669 + let n = t[0], s = st(n, t[3] || "", this.rules);
2670 + return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
2673 + heading(e) {
2674 + let t = this.rules.block.heading.exec(e);
2675 + if (t) {
2676 + let n = t[2].trim();
2677 + if (this.rules.other.endingHash.test(n)) {
2678 + let s = $(n, "#");
2679 + (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
2681 + return { type: "heading", raw: $(t[0], `
2682 +`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
2685 + hr(e) {
2686 + let t = this.rules.block.hr.exec(e);
2687 + if (t) return { type: "hr", raw: $(t[0], `
2688 +`) };
2690 + blockquote(e) {
2691 + let t = this.rules.block.blockquote.exec(e);
2692 + if (t) {
2693 + let n = $(t[0], `
2694 +`).split(`
2695 +`), s = "", r = "", i = [];
2696 + for (; n.length > 0; ) {
2697 + let o = false, u = [], a;
2698 + for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = true;
2699 + else if (!o) u.push(n[a]);
2700 + else break;
2701 + n = n.slice(a);
2702 + let c = u.join(`
2703 +`), p = c.replace(this.rules.other.blockquoteSetextReplace, `
2704 + $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
2705 + s = s ? `${s}
2706 +${c}` : c, r = r ? `${r}
2707 +${p}` : p;
2708 + let k = this.lexer.state.top;
2709 + if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = k, n.length === 0) break;
2710 + let h = i.at(-1);
2711 + if (h?.type === "code") break;
2712 + if (h?.type === "blockquote") {
2713 + let R = h, f = R.raw + `
2714 +` + n.join(`
2715 +`), S = this.blockquote(f);
2716 + i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
2717 + break;
2718 + } else if (h?.type === "list") {
2719 + let R = h, f = R.raw + `
2720 +` + n.join(`
2721 +`), S = this.list(f);
2722 + i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
2723 +`);
2724 + continue;
2727 + return { type: "blockquote", raw: s, tokens: i, text: r };
2730 + list(e) {
2731 + let t = this.rules.block.list.exec(e);
2732 + if (t) {
2733 + let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
2734 + n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
2735 + let i = this.rules.other.listItemRegex(n), o = false;
2736 + for (; e; ) {
2737 + let a = false, c = "", p = "";
2738 + if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
2739 + c = t[0], e = e.substring(c.length);
2740 + let k = me(t[2].split(`
2741 +`, 1)[0], t[1].length), h = e.split(`
2742 +`, 1)[0], R = !k.trim(), f = 0;
2743 + if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
2744 +`, e = e.substring(h.length + 1), a = true), !a) {
2745 + let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
2746 + for (; e; ) {
2747 + let G = e.split(`
2748 +`, 1)[0], C;
2749 + if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h)) break;
2750 + if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) p += `
2751 +` + C.slice(f);
2752 + else {
2753 + if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k)) break;
2754 + p += `
2755 +` + h;
2757 + R = !h.trim(), c += G + `
2758 +`, e = e.substring(G.length + 1), k = C.slice(f);
2761 + r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c) && (o = true)), r.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c;
2763 + let u = r.items.at(-1);
2764 + if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
2765 + else return;
2766 + r.raw = r.raw.trimEnd();
2767 + for (let a of r.items) {
2768 + this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
2769 + let c = a.tokens[0];
2770 + if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
2771 + a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
2772 + for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
2773 + this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
2774 + break;
2776 + let p = this.rules.other.listTaskCheckbox.exec(a.raw);
2777 + if (p) {
2778 + let k = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
2779 + a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : a.tokens.unshift(k);
2781 + } else a.task && (a.task = false);
2782 + if (!r.loose) {
2783 + let p = a.tokens.filter((h) => h.type === "space"), k = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
2784 + r.loose = k;
2787 + if (r.loose) for (let a of r.items) {
2788 + a.loose = true;
2789 + for (let c of a.tokens) c.type === "text" && (c.type = "paragraph");
2791 + return r;
2794 + html(e) {
2795 + let t = this.rules.block.html.exec(e);
2796 + if (t) {
2797 + let n = ee(t[0]);
2798 + return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
2801 + def(e) {
2802 + let t = this.rules.block.def.exec(e);
2803 + if (t) {
2804 + let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
2805 + return { type: "def", tag: n, raw: $(t[0], `
2806 +`), href: s, title: r };
2809 + table(e) {
2810 + let t = this.rules.block.table.exec(e);
2811 + if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
2812 + let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
2813 +`) : [], i = { type: "table", raw: $(t[0], `
2814 +`), header: [], align: [], rows: [] };
2815 + if (n.length === s.length) {
2816 + for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
2817 + for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
2818 + for (let o of r) i.rows.push(Y(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
2819 + return i;
2822 + lheading(e) {
2823 + let t = this.rules.block.lheading.exec(e);
2824 + if (t) {
2825 + let n = t[1].trim();
2826 + return { type: "heading", raw: $(t[0], `
2827 +`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
2830 + paragraph(e) {
2831 + let t = this.rules.block.paragraph.exec(e);
2832 + if (t) {
2833 + let n = t[1].charAt(t[1].length - 1) === `
2834 +` ? t[1].slice(0, -1) : t[1];
2835 + return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
2838 + text(e) {
2839 + let t = this.rules.block.text.exec(e);
2840 + if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
2842 + escape(e) {
2843 + let t = this.rules.inline.escape.exec(e);
2844 + if (t) return { type: "escape", raw: t[0], text: t[1] };
2846 + tag(e) {
2847 + let t = this.rules.inline.tag.exec(e);
2848 + if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
2850 + link(e) {
2851 + let t = this.rules.inline.link.exec(e);
2852 + if (t) {
2853 + let n = t[2].trim();
2854 + if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
2855 + if (!this.rules.other.endAngleBracket.test(n)) return;
2856 + let i = $(n.slice(0, -1), "\\");
2857 + if ((n.length - i.length) % 2 === 0) return;
2858 + } else {
2859 + let i = fe(t[2], "()");
2860 + if (i === -2) return;
2861 + if (i > -1) {
2862 + let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
2863 + t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
2866 + let s = t[2], r = "";
2867 + if (this.options.pedantic) {
2868 + let i = this.rules.other.pedanticHrefTitle.exec(s);
2869 + i && (s = i[1], r = i[3]);
2870 + } else r = t[3] ? t[3].slice(1, -1) : "";
2871 + return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
2874 + reflink(e, t) {
2875 + let n;
2876 + if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
2877 + let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
2878 + if (!r) {
2879 + let i = n[0].charAt(0);
2880 + return { type: "text", raw: i, text: i };
2882 + return xe(n, r, n[0], this.lexer, this.rules);
2885 + emStrong(e, t, n = "") {
2886 + let s = this.rules.inline.emStrongLDelim.exec(e);
2887 + if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
2888 + if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
2889 + let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
2890 + for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null; ) {
2891 + if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
2892 + if (u = [...o].length, s[3] || s[4]) {
2893 + a += u;
2894 + continue;
2895 + } else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
2896 + c += u;
2897 + continue;
2899 + if (a -= u, a > 0) continue;
2900 + u = Math.min(u, u + a + c);
2901 + let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
2902 + if (Math.min(i, u) % 2) {
2903 + let f = h.slice(1, -1);
2904 + return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
2906 + let R = h.slice(2, -2);
2907 + return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
2911 + codespan(e) {
2912 + let t = this.rules.inline.code.exec(e);
2913 + if (t) {
2914 + let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
2915 + return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
2918 + br(e) {
2919 + let t = this.rules.inline.br.exec(e);
2920 + if (t) return { type: "br", raw: t[0] };
2922 + del(e, t, n = "") {
2923 + let s = this.rules.inline.delLDelim.exec(e);
2924 + if (!s) return;
2925 + if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
2926 + let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
2927 + for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) !== null; ) {
2928 + if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
2929 + if (s[3] || s[4]) {
2930 + a += u;
2931 + continue;
2933 + if (a -= u, a > 0) continue;
2934 + u = Math.min(u, u + a);
2935 + let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
2936 + return { type: "del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
2940 + autolink(e) {
2941 + let t = this.rules.inline.autolink.exec(e);
2942 + if (t) {
2943 + let n, s;
2944 + return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
2947 + url(e) {
2948 + let t;
2949 + if (t = this.rules.inline.url.exec(e)) {
2950 + let n, s;
2951 + if (t[2] === "@") n = t[0], s = "mailto:" + n;
2952 + else {
2953 + let r;
2954 + do
2955 + r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
2956 + while (r !== t[0]);
2957 + n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
2959 + return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
2962 + inlineText(e) {
2963 + let t = this.rules.inline.text.exec(e);
2964 + if (t) {
2965 + let n = this.lexer.state.inRawBlock;
2966 + return { type: "text", raw: t[0], text: t[0], escaped: n };
2970 +var x = class l {
2971 + tokens;
2972 + options;
2973 + state;
2974 + inlineQueue;
2975 + tokenizer;
2976 + constructor(e) {
2977 + this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
2978 + let t = { other: m, block: D.normal, inline: A.normal };
2979 + this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
2981 + static get rules() {
2982 + return { block: D, inline: A };
2984 + static lex(e, t) {
2985 + return new l(t).lex(e);
2987 + static lexInline(e, t) {
2988 + return new l(t).inlineTokens(e);
2990 + lex(e) {
2991 + e = e.replace(m.carriageReturn, `
2992 +`), this.blockTokens(e, this.tokens);
2993 + for (let t = 0; t < this.inlineQueue.length; t++) {
2994 + let n = this.inlineQueue[t];
2995 + this.inlineTokens(n.src, n.tokens);
2997 + return this.inlineQueue = [], this.tokens;
2999 + blockTokens(e, t = [], n = false) {
3000 + this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
3001 + let s = 1 / 0;
3002 + for (; e; ) {
3003 + if (e.length < s) s = e.length;
3004 + else {
3005 + this.infiniteLoopError(e.charCodeAt(0));
3006 + break;
3008 + let r;
3009 + if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
3010 + if (r = this.tokenizer.space(e)) {
3011 + e = e.substring(r.raw.length);
3012 + let o = t.at(-1);
3013 + r.raw.length === 1 && o !== void 0 ? o.raw += `
3014 +` : t.push(r);
3015 + continue;
3017 + if (r = this.tokenizer.code(e)) {
3018 + e = e.substring(r.raw.length);
3019 + let o = t.at(-1);
3020 + o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
3021 +`) ? "" : `
3022 +`) + r.raw, o.text += `
3023 +` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
3024 + continue;
3026 + if (r = this.tokenizer.fences(e)) {
3027 + e = e.substring(r.raw.length), t.push(r);
3028 + continue;
3030 + if (r = this.tokenizer.heading(e)) {
3031 + e = e.substring(r.raw.length), t.push(r);
3032 + continue;
3034 + if (r = this.tokenizer.hr(e)) {
3035 + e = e.substring(r.raw.length), t.push(r);
3036 + continue;
3038 + if (r = this.tokenizer.blockquote(e)) {
3039 + e = e.substring(r.raw.length), t.push(r);
3040 + continue;
3042 + if (r = this.tokenizer.list(e)) {
3043 + e = e.substring(r.raw.length), t.push(r);
3044 + continue;
3046 + if (r = this.tokenizer.html(e)) {
3047 + e = e.substring(r.raw.length), t.push(r);
3048 + continue;
3050 + if (r = this.tokenizer.def(e)) {
3051 + e = e.substring(r.raw.length);
3052 + let o = t.at(-1);
3053 + o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
3054 +`) ? "" : `
3055 +`) + r.raw, o.text += `
3056 +` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
3057 + continue;
3059 + if (r = this.tokenizer.table(e)) {
3060 + e = e.substring(r.raw.length), t.push(r);
3061 + continue;
3063 + if (r = this.tokenizer.lheading(e)) {
3064 + e = e.substring(r.raw.length), t.push(r);
3065 + continue;
3067 + let i = e;
3068 + if (this.options.extensions?.startBlock) {
3069 + let o = 1 / 0, u = e.slice(1), a;
3070 + this.options.extensions.startBlock.forEach((c) => {
3071 + a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
3072 + }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
3074 + if (this.state.top && (r = this.tokenizer.paragraph(i))) {
3075 + let o = t.at(-1);
3076 + n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
3077 +`) ? "" : `
3078 +`) + r.raw, o.text += `
3079 +` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
3080 + continue;
3082 + if (r = this.tokenizer.text(e)) {
3083 + e = e.substring(r.raw.length);
3084 + let o = t.at(-1);
3085 + o?.type === "text" ? (o.raw += (o.raw.endsWith(`
3086 +`) ? "" : `
3087 +`) + r.raw, o.text += `
3088 +` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
3089 + continue;
3091 + if (e) {
3092 + this.infiniteLoopError(e.charCodeAt(0));
3093 + break;
3096 + return this.state.top = true, t;
3098 + inline(e, t = []) {
3099 + return this.inlineQueue.push({ src: e, tokens: t }), t;
3101 + inlineTokens(e, t = []) {
3102 + this.tokenizer.lexer = this;
3103 + let n = e, s = null;
3104 + if (this.tokens.links) {
3105 + let a = Object.keys(this.tokens.links);
3106 + if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; ) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
3108 + for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
3109 + let r;
3110 + for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; ) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
3111 + n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
3112 + let i = false, o = "", u = 1 / 0;
3113 + for (; e; ) {
3114 + if (e.length < u) u = e.length;
3115 + else {
3116 + this.infiniteLoopError(e.charCodeAt(0));
3117 + break;
3119 + i || (o = ""), i = false;
3120 + let a;
3121 + if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false)) continue;
3122 + if (a = this.tokenizer.escape(e)) {
3123 + e = e.substring(a.raw.length), t.push(a);
3124 + continue;
3126 + if (a = this.tokenizer.tag(e)) {
3127 + e = e.substring(a.raw.length), t.push(a);
3128 + continue;
3130 + if (a = this.tokenizer.link(e)) {
3131 + e = e.substring(a.raw.length), t.push(a);
3132 + continue;
3134 + if (a = this.tokenizer.reflink(e, this.tokens.links)) {
3135 + e = e.substring(a.raw.length);
3136 + let p = t.at(-1);
3137 + a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
3138 + continue;
3140 + if (a = this.tokenizer.emStrong(e, n, o)) {
3141 + e = e.substring(a.raw.length), t.push(a);
3142 + continue;
3144 + if (a = this.tokenizer.codespan(e)) {
3145 + e = e.substring(a.raw.length), t.push(a);
3146 + continue;
3148 + if (a = this.tokenizer.br(e)) {
3149 + e = e.substring(a.raw.length), t.push(a);
3150 + continue;
3152 + if (a = this.tokenizer.del(e, n, o)) {
3153 + e = e.substring(a.raw.length), t.push(a);
3154 + continue;
3156 + if (a = this.tokenizer.autolink(e)) {
3157 + e = e.substring(a.raw.length), t.push(a);
3158 + continue;
3160 + if (!this.state.inLink && (a = this.tokenizer.url(e))) {
3161 + e = e.substring(a.raw.length), t.push(a);
3162 + continue;
3164 + let c = e;
3165 + if (this.options.extensions?.startInline) {
3166 + let p = 1 / 0, k = e.slice(1), h;
3167 + this.options.extensions.startInline.forEach((R) => {
3168 + h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
3169 + }), p < 1 / 0 && p >= 0 && (c = e.substring(0, p + 1));
3171 + if (a = this.tokenizer.inlineText(c)) {
3172 + e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
3173 + let p = t.at(-1);
3174 + p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
3175 + continue;
3177 + if (e) {
3178 + this.infiniteLoopError(e.charCodeAt(0));
3179 + break;
3182 + return t;
3184 + infiniteLoopError(e) {
3185 + let t = "Infinite loop on byte: " + e;
3186 + if (this.options.silent) console.error(t);
3187 + else throw new Error(t);
3190 +var y = class {
3191 + options;
3192 + parser;
3193 + constructor(e) {
3194 + this.options = e || T;
3196 + space(e) {
3197 + return "";
3199 + code({ text: e, lang: t, escaped: n }) {
3200 + let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
3202 + return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
3203 +` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
3206 + blockquote({ tokens: e }) {
3207 + return `<blockquote>
3208 +${this.parser.parse(e)}</blockquote>
3211 + html({ text: e }) {
3212 + return e;
3214 + def(e) {
3215 + return "";
3217 + heading({ tokens: e, depth: t }) {
3218 + return `<h${t}>${this.parser.parseInline(e)}</h${t}>
3221 + hr(e) {
3222 + return `<hr>
3225 + list(e) {
3226 + let t = e.ordered, n = e.start, s = "";
3227 + for (let o = 0; o < e.items.length; o++) {
3228 + let u = e.items[o];
3229 + s += this.listitem(u);
3231 + let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
3232 + return "<" + r + i + `>
3233 +` + s + "</" + r + `>
3236 + listitem(e) {
3237 + return `<li>${this.parser.parse(e.tokens)}</li>
3240 + checkbox({ checked: e }) {
3241 + return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
3243 + paragraph({ tokens: e }) {
3244 + return `<p>${this.parser.parseInline(e)}</p>
3247 + table(e) {
3248 + let t = "", n = "";
3249 + for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
3250 + t += this.tablerow({ text: n });
3251 + let s = "";
3252 + for (let r = 0; r < e.rows.length; r++) {
3253 + let i = e.rows[r];
3254 + n = "";
3255 + for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
3256 + s += this.tablerow({ text: n });
3258 + return s && (s = `<tbody>${s}</tbody>`), `<table>
3259 +<thead>
3260 +` + t + `</thead>
3261 +` + s + `</table>
3264 + tablerow({ text: e }) {
3265 + return `<tr>
3266 +${e}</tr>
3269 + tablecell(e) {
3270 + let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
3271 + return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
3274 + strong({ tokens: e }) {
3275 + return `<strong>${this.parser.parseInline(e)}</strong>`;
3277 + em({ tokens: e }) {
3278 + return `<em>${this.parser.parseInline(e)}</em>`;
3280 + codespan({ text: e }) {
3281 + return `<code>${O(e, true)}</code>`;
3283 + br(e) {
3284 + return "<br>";
3286 + del({ tokens: e }) {
3287 + return `<del>${this.parser.parseInline(e)}</del>`;
3289 + link({ href: e, title: t, tokens: n }) {
3290 + let s = this.parser.parseInline(n), r = V(e);
3291 + if (r === null) return s;
3292 + e = r;
3293 + let i = '<a href="' + e + '"';
3294 + return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
3296 + image({ href: e, title: t, text: n, tokens: s }) {
3297 + s && (n = this.parser.parseInline(s, this.parser.textRenderer));
3298 + let r = V(e);
3299 + if (r === null) return O(n);
3300 + e = r;
3301 + let i = `<img src="${e}" alt="${O(n)}"`;
3302 + return t && (i += ` title="${O(t)}"`), i += ">", i;
3304 + text(e) {
3305 + return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
3308 +var L = class {
3309 + strong({ text: e }) {
3310 + return e;
3312 + em({ text: e }) {
3313 + return e;
3315 + codespan({ text: e }) {
3316 + return e;
3318 + del({ text: e }) {
3319 + return e;
3321 + html({ text: e }) {
3322 + return e;
3324 + text({ text: e }) {
3325 + return e;
3327 + link({ text: e }) {
3328 + return "" + e;
3330 + image({ text: e }) {
3331 + return "" + e;
3333 + br() {
3334 + return "";
3336 + checkbox({ raw: e }) {
3337 + return e;
3340 +var b = class l2 {
3341 + options;
3342 + renderer;
3343 + textRenderer;
3344 + constructor(e) {
3345 + this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
3347 + static parse(e, t) {
3348 + return new l2(t).parse(e);
3350 + static parseInline(e, t) {
3351 + return new l2(t).parseInline(e);
3353 + parse(e) {
3354 + this.renderer.parser = this;
3355 + let t = "";
3356 + for (let n = 0; n < e.length; n++) {
3357 + let s = e[n];
3358 + if (this.options.extensions?.renderers?.[s.type]) {
3359 + let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
3360 + if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
3361 + t += o || "";
3362 + continue;
3365 + let r = s;
3366 + switch (r.type) {
3367 + case "space": {
3368 + t += this.renderer.space(r);
3369 + break;
3371 + case "hr": {
3372 + t += this.renderer.hr(r);
3373 + break;
3375 + case "heading": {
3376 + t += this.renderer.heading(r);
3377 + break;
3379 + case "code": {
3380 + t += this.renderer.code(r);
3381 + break;
3383 + case "table": {
3384 + t += this.renderer.table(r);
3385 + break;
3387 + case "blockquote": {
3388 + t += this.renderer.blockquote(r);
3389 + break;
3391 + case "list": {
3392 + t += this.renderer.list(r);
3393 + break;
3395 + case "checkbox": {
3396 + t += this.renderer.checkbox(r);
3397 + break;
3399 + case "html": {
3400 + t += this.renderer.html(r);
3401 + break;
3403 + case "def": {
3404 + t += this.renderer.def(r);
3405 + break;
3407 + case "paragraph": {
3408 + t += this.renderer.paragraph(r);
3409 + break;
3411 + case "text": {
3412 + t += this.renderer.text(r);
3413 + break;
3415 + default: {
3416 + let i = 'Token with "' + r.type + '" type was not found.';
3417 + if (this.options.silent) return console.error(i), "";
3418 + throw new Error(i);
3422 + return t;
3424 + parseInline(e, t = this.renderer) {
3425 + this.renderer.parser = this;
3426 + let n = "";
3427 + for (let s = 0; s < e.length; s++) {
3428 + let r = e[s];
3429 + if (this.options.extensions?.renderers?.[r.type]) {
3430 + let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
3431 + if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
3432 + n += o || "";
3433 + continue;
3436 + let i = r;
3437 + switch (i.type) {
3438 + case "escape": {
3439 + n += t.text(i);
3440 + break;
3442 + case "html": {
3443 + n += t.html(i);
3444 + break;
3446 + case "link": {
3447 + n += t.link(i);
3448 + break;
3450 + case "image": {
3451 + n += t.image(i);
3452 + break;
3454 + case "checkbox": {
3455 + n += t.checkbox(i);
3456 + break;
3458 + case "strong": {
3459 + n += t.strong(i);
3460 + break;
3462 + case "em": {
3463 + n += t.em(i);
3464 + break;
3466 + case "codespan": {
3467 + n += t.codespan(i);
3468 + break;
3470 + case "br": {
3471 + n += t.br(i);
3472 + break;
3474 + case "del": {
3475 + n += t.del(i);
3476 + break;
3478 + case "text": {
3479 + n += t.text(i);
3480 + break;
3482 + default: {
3483 + let o = 'Token with "' + i.type + '" type was not found.';
3484 + if (this.options.silent) return console.error(o), "";
3485 + throw new Error(o);
3489 + return n;
3492 +var P = class {
3493 + options;
3494 + block;
3495 + constructor(e) {
3496 + this.options = e || T;
3498 + static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
3499 + static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
3500 + preprocess(e) {
3501 + return e;
3503 + postprocess(e) {
3504 + return e;
3506 + processAllTokens(e) {
3507 + return e;
3509 + emStrongMask(e) {
3510 + return e;
3512 + provideLexer(e = this.block) {
3513 + return e ? x.lex : x.lexInline;
3515 + provideParser(e = this.block) {
3516 + return e ? b.parse : b.parseInline;
3519 +var q = class {
3520 + defaults = M();
3521 + options = this.setOptions;
3522 + parse = this.parseMarkdown(true);
3523 + parseInline = this.parseMarkdown(false);
3524 + Parser = b;
3525 + Renderer = y;
3526 + TextRenderer = L;
3527 + Lexer = x;
3528 + Tokenizer = w;
3529 + Hooks = P;
3530 + constructor(...e) {
3531 + this.use(...e);
3533 + walkTokens(e, t) {
3534 + let n = [];
3535 + for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
3536 + case "table": {
3537 + let r = s;
3538 + for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
3539 + for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
3540 + break;
3542 + case "list": {
3543 + let r = s;
3544 + n = n.concat(this.walkTokens(r.items, t));
3545 + break;
3547 + default: {
3548 + let r = s;
3549 + this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
3550 + let o = r[i].flat(1 / 0);
3551 + n = n.concat(this.walkTokens(o, t));
3552 + }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
3555 + return n;
3557 + use(...e) {
3558 + let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
3559 + return e.forEach((n) => {
3560 + let s = { ...n };
3561 + if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
3562 + if (!r.name) throw new Error("extension name required");
3563 + if ("renderer" in r) {
3564 + let i = t.renderers[r.name];
3565 + i ? t.renderers[r.name] = function(...o) {
3566 + let u = r.renderer.apply(this, o);
3567 + return u === false && (u = i.apply(this, o)), u;
3568 + } : t.renderers[r.name] = r.renderer;
3570 + if ("tokenizer" in r) {
3571 + if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
3572 + let i = t[r.level];
3573 + i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
3575 + "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
3576 + }), s.extensions = t), n.renderer) {
3577 + let r = this.defaults.renderer || new y(this.defaults);
3578 + for (let i in n.renderer) {
3579 + if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
3580 + if (["options", "parser"].includes(i)) continue;
3581 + let o = i, u = n.renderer[o], a = r[o];
3582 + r[o] = (...c) => {
3583 + let p = u.apply(r, c);
3584 + return p === false && (p = a.apply(r, c)), p || "";
3585 + };
3587 + s.renderer = r;
3589 + if (n.tokenizer) {
3590 + let r = this.defaults.tokenizer || new w(this.defaults);
3591 + for (let i in n.tokenizer) {
3592 + if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
3593 + if (["options", "rules", "lexer"].includes(i)) continue;
3594 + let o = i, u = n.tokenizer[o], a = r[o];
3595 + r[o] = (...c) => {
3596 + let p = u.apply(r, c);
3597 + return p === false && (p = a.apply(r, c)), p;
3598 + };
3600 + s.tokenizer = r;
3602 + if (n.hooks) {
3603 + let r = this.defaults.hooks || new P();
3604 + for (let i in n.hooks) {
3605 + if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
3606 + if (["options", "block"].includes(i)) continue;
3607 + let o = i, u = n.hooks[o], a = r[o];
3608 + P.passThroughHooks.has(i) ? r[o] = (c) => {
3609 + if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
3610 + let k = await u.call(r, c);
3611 + return a.call(r, k);
3612 + })();
3613 + let p = u.call(r, c);
3614 + return a.call(r, p);
3615 + } : r[o] = (...c) => {
3616 + if (this.defaults.async) return (async () => {
3617 + let k = await u.apply(r, c);
3618 + return k === false && (k = await a.apply(r, c)), k;
3619 + })();
3620 + let p = u.apply(r, c);
3621 + return p === false && (p = a.apply(r, c)), p;
3622 + };
3624 + s.hooks = r;
3626 + if (n.walkTokens) {
3627 + let r = this.defaults.walkTokens, i = n.walkTokens;
3628 + s.walkTokens = function(o) {
3629 + let u = [];
3630 + return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
3631 + };
3633 + this.defaults = { ...this.defaults, ...s };
3634 + }), this;
3636 + setOptions(e) {
3637 + return this.defaults = { ...this.defaults, ...e }, this;
3639 + lexer(e, t) {
3640 + return x.lex(e, t ?? this.defaults);
3642 + parser(e, t) {
3643 + return b.parse(e, t ?? this.defaults);
3645 + parseMarkdown(e) {
3646 + return (n, s) => {
3647 + let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
3648 + if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
3649 + if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
3650 + if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
3651 + if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
3652 + let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
3653 + i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
3654 + let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
3655 + return i.hooks ? await i.hooks.postprocess(h) : h;
3656 + })().catch(o);
3657 + try {
3658 + i.hooks && (n = i.hooks.preprocess(n));
3659 + let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
3660 + i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
3661 + let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
3662 + return i.hooks && (p = i.hooks.postprocess(p)), p;
3663 + } catch (u) {
3664 + return o(u);
3666 + };
3668 + onError(e, t) {
3669 + return (n) => {
3670 + if (n.message += `
3671 +Please report this to https://github.com/markedjs/marked.`, e) {
3672 + let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
3673 + return t ? Promise.resolve(s) : s;
3675 + if (t) return Promise.reject(n);
3676 + throw n;
3677 + };
3680 +var z = new q();
3681 +function g(l3, e) {
3682 + return z.parse(l3, e);
3684 +g.options = g.setOptions = function(l3) {
3685 + return z.setOptions(l3), g.defaults = z.defaults, N(g.defaults), g;
3687 +g.getDefaults = M;
3688 +g.defaults = T;
3689 +g.use = function(...l3) {
3690 + return z.use(...l3), g.defaults = z.defaults, N(g.defaults), g;
3692 +g.walkTokens = function(l3, e) {
3693 + return z.walkTokens(l3, e);
3695 +g.parseInline = z.parseInline;
3696 +g.Parser = b;
3697 +g.parser = b.parse;
3698 +g.Renderer = y;
3699 +g.TextRenderer = L;
3700 +g.Lexer = x;
3701 +g.lexer = x.lex;
3702 +g.Tokenizer = w;
3703 +g.Hooks = P;
3704 +g.parse = g;
3705 +var Ft = g.options;
3706 +var Ut = g.setOptions;
3707 +var Kt = g.use;
3708 +var Wt = g.walkTokens;
3709 +var Xt = g.parseInline;
3710 +var Vt = b.parse;
3711 +var Yt = x.lex;
3713 +// scripts/check.mjs
3714 +var frontmatterFence = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
3715 +var namePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
3716 +var scriptPattern = /\.(?:mjs|cjs|js|ts|sh|bash|nu|py|ps1|cmd|bat)$/i;
19 3717 function filesUnder(dir) {
20 - return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
21 - if (entry.name === "node_modules" || entry.name === ".git") return [];
22 - const path = join(dir, entry.name);
23 - if (entry.isDirectory()) return filesUnder(path);
24 - return entry.isFile() ? [path] : [];
25 - });
3718 + return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
3719 + if (entry.name === "node_modules" || entry.name === ".git") return [];
3720 + const path = join(dir, entry.name);
3721 + if (entry.isDirectory()) return filesUnder(path);
3722 + return entry.isFile() ? [path] : [];
3723 + });
28 -export function checkSkill(directory) {
29 - const root = resolve(directory);
30 - if (!statSync(root).isDirectory())
31 - throw new Error("Expected a skill directory");
32 - const skill = join(root, "SKILL.md");
33 - const text = readFileSync(skill, "utf8");
34 - const issues = [];
35 - const add = (path, code, message) =>
36 - issues.push({
37 - path: relative(root, path).split("\\").join("/"),
38 - code,
39 - message,
40 - });
41 - const fence = text.match(frontmatterFence);
42 - if (!fence) {
43 - add(
44 - skill,
45 - "frontmatter.fence",
46 - "Expected opening and closing YAML frontmatter fences",
47 - );
48 - } else {
49 - let data;
50 - try {
51 - data = parse(fence[1]);
52 - } catch {
53 - add(
54 - skill,
55 - "frontmatter.yaml",
56 - "Invalid YAML frontmatter, keys, or aliases",
57 - );
58 - }
59 - if (data !== undefined) {
60 - if (!data || typeof data !== "object" || Array.isArray(data)) {
61 - add(skill, "frontmatter.mapping", "Frontmatter must be a YAML mapping");
62 - } else {
63 - const { name, description } = data;
64 - if (
65 - typeof name !== "string" ||
66 - name.length > 64 ||
67 - !namePattern.test(name)
68 - ) {
69 - add(
70 - skill,
71 - "name.invalid",
72 - "Name must be 1-64 lowercase letters/digits with single internal hyphens",
73 - );
74 - } else if (name !== basename(root)) {
75 - add(
76 - skill,
77 - "name.directory",
78 - "Name must match directory for Agent Skills portability",
79 - );
80 - }
81 - if (
82 - typeof description !== "string" ||
83 - !description.trim() ||
84 - description.length > 1024
85 - ) {
86 - add(
87 - skill,
88 - "description.invalid",
89 - "Description must be a non-empty string of at most 1024 characters",
90 - );
91 - }
92 - const invocation = data["disable-model-invocation"];
93 - if (invocation !== undefined && typeof invocation !== "boolean") {
94 - add(
95 - skill,
96 - "invocation.invalid",
97 - "disable-model-invocation must be a boolean when present",
98 - );
99 - }
100 - }
101 - }
102 - }
104 - const files = filesUnder(root).sort();
105 - for (const file of files.filter((path) => path.endsWith(".md"))) {
106 - const body = readFileSync(file, "utf8").replace(frontmatterFence, "");
107 - marked.walkTokens(marked.lexer(body), (token) => {
108 - if (token.type !== "link" && token.type !== "image") return;
109 - const href = token.href;
110 - if (
111 - !href ||
112 - /^[a-z][a-z\d+.-]*:|^[#/?\\]/i.test(href) ||
113 - isAbsolute(href)
114 - )
115 - return;
116 - let target;
117 - try {
118 - target = decodeURIComponent(href.split(/[?#]/, 1)[0]);
119 - } catch {
120 - add(file, "link.encoding", "Local link has invalid percent encoding");
121 - return;
122 - }
123 - if (!existsSync(resolve(dirname(file), target))) {
124 - add(file, "link.missing", `Missing local link target: ${href}`);
125 - }
126 - });
127 - }
129 - const scripted = files.some((file) => scriptPattern.test(file));
130 - const packageFile = join(root, "package.json");
131 - if (!existsSync(packageFile)) {
132 - if (scripted)
133 - add(
134 - packageFile,
135 - "package.missing",
136 - "Scripted skills require package.json",
137 - );
138 - } else {
139 - let manifest;
140 - try {
141 - manifest = JSON.parse(readFileSync(packageFile, "utf8"));
142 - } catch {
143 - manifest = null;
144 - }
145 - if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
146 - add(
147 - packageFile,
148 - "package.json",
149 - "Expected a JSON object in package.json",
150 - );
151 - } else if (
152 - scripted &&
153 - (typeof manifest.scripts?.test !== "string" ||
154 - !/^node\s+--test(?:\s|$)/.test(manifest.scripts.test))
155 - ) {
156 - add(
157 - packageFile,
158 - "tests.command",
159 - "scripts.test must invoke node --test directly",
160 - );
161 - }
162 - }
163 - if (scripted && !files.some((file) => file.endsWith(".test.mjs"))) {
164 - add(
165 - packageFile,
166 - "tests.missing",
167 - "Scripted skills require at least one .test.mjs file",
168 - );
169 - }
170 - return { skill: root, ok: issues.length === 0, issues };
3725 +function checkSkill(directory) {
3726 + const root = resolve(directory);
3727 + if (!statSync(root).isDirectory())
3728 + throw new Error("Expected a skill directory");
3729 + const skill = join(root, "SKILL.md");
3730 + const text = readFileSync(skill, "utf8");
3731 + const issues = [];
3732 + const add = (path, code, message) => issues.push({
3733 + path: relative(root, path).split("\\").join("/"),
3734 + code,
3735 + message
3736 + });
3737 + const fence = text.match(frontmatterFence);
3738 + if (!fence) {
3739 + add(
3740 + skill,
3741 + "frontmatter.fence",
3742 + "Expected opening and closing YAML frontmatter fences"
3743 + );
3744 + } else {
3745 + let data;
3746 + try {
3747 + data = load(fence[1]);
3748 + } catch {
3749 + add(
3750 + skill,
3751 + "frontmatter.yaml",
3752 + "Invalid YAML frontmatter, keys, or aliases"
3753 + );
3755 + if (data !== void 0) {
3756 + if (!data || typeof data !== "object" || Array.isArray(data)) {
3757 + add(skill, "frontmatter.mapping", "Frontmatter must be a YAML mapping");
3758 + } else {
3759 + const { name, description } = data;
3760 + if (typeof name !== "string" || name.length > 64 || !namePattern.test(name)) {
3761 + add(
3762 + skill,
3763 + "name.invalid",
3764 + "Name must be 1-64 lowercase letters/digits with single internal hyphens"
3765 + );
3766 + } else if (name !== basename(root)) {
3767 + add(
3768 + skill,
3769 + "name.directory",
3770 + "Name must match directory for Agent Skills portability"
3771 + );
3773 + if (typeof description !== "string" || !description.trim() || description.length > 1024) {
3774 + add(
3775 + skill,
3776 + "description.invalid",
3777 + "Description must be a non-empty string of at most 1024 characters"
3778 + );
3780 + const invocation = data["disable-model-invocation"];
3781 + if (invocation !== void 0 && typeof invocation !== "boolean") {
3782 + add(
3783 + skill,
3784 + "invocation.invalid",
3785 + "disable-model-invocation must be a boolean when present"
3786 + );
3791 + const files = filesUnder(root).sort();
3792 + for (const file of files.filter((path) => path.endsWith(".md"))) {
3793 + const body = readFileSync(file, "utf8").replace(frontmatterFence, "");
3794 + g.walkTokens(g.lexer(body), (token) => {
3795 + if (token.type !== "link" && token.type !== "image") return;
3796 + const href = token.href;
3797 + if (!href || /^[a-z][a-z\d+.-]*:|^[#/?\\]/i.test(href) || isAbsolute(href))
3798 + return;
3799 + let target;
3800 + try {
3801 + target = decodeURIComponent(href.split(/[?#]/, 1)[0]);
3802 + } catch {
3803 + add(file, "link.encoding", "Local link has invalid percent encoding");
3804 + return;
3806 + if (!existsSync(resolve(dirname(file), target))) {
3807 + add(file, "link.missing", `Missing local link target: ${href}`);
3809 + });
3811 + const scripted = files.some((file) => scriptPattern.test(file));
3812 + const packageFile = join(root, "package.json");
3813 + if (!existsSync(packageFile)) {
3814 + if (scripted)
3815 + add(
3816 + packageFile,
3817 + "package.missing",
3818 + "Scripted skills require package.json"
3819 + );
3820 + } else {
3821 + let manifest;
3822 + try {
3823 + manifest = JSON.parse(readFileSync(packageFile, "utf8"));
3824 + } catch {
3825 + manifest = null;
3827 + if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
3828 + add(
3829 + packageFile,
3830 + "package.json",
3831 + "Expected a JSON object in package.json"
3832 + );
3833 + } else if (scripted && (typeof manifest.scripts?.test !== "string" || !/^node\s+--test(?:\s|$)/.test(manifest.scripts.test))) {
3834 + add(
3835 + packageFile,
3836 + "tests.command",
3837 + "scripts.test must invoke node --test directly"
3838 + );
3841 + if (scripted && !files.some((file) => file.endsWith(".test.mjs"))) {
3842 + add(
3843 + packageFile,
3844 + "tests.missing",
3845 + "Scripted skills require at least one .test.mjs file"
3846 + );
3848 + return { skill: root, ok: issues.length === 0, issues };
173 -if (
174 - process.argv[1] &&
175 - resolve(process.argv[1]) === fileURLToPath(import.meta.url)
176 -) {
177 - try {
178 - if (process.argv.length !== 3)
179 - throw new Error("Usage: node scripts/check.mjs <skill-dir>");
180 - const result = checkSkill(process.argv[2]);
181 - console.log(JSON.stringify(result, null, 2));
182 - process.exitCode = result.ok ? 0 : 1;
183 - } catch (error) {
184 - console.log(JSON.stringify({ error: error.message }));
185 - process.exitCode = 2;
186 - }
3850 +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
3851 + try {
3852 + if (process.argv.length !== 3)
3853 + throw new Error("Usage: node scripts/check.mjs <skill-dir>");
3854 + const result = checkSkill(process.argv[2]);
3855 + console.log(JSON.stringify(result, null, 2));
3856 + process.exitCode = result.ok ? 0 : 1;
3857 + } catch (error) {
3858 + console.log(JSON.stringify({ error: error.message }));
3859 + process.exitCode = 2;
3862 +export {
3863 + checkSkill
3865 +/*! Bundled license information:
3867 +js-yaml/dist/js-yaml.mjs:
3868 + (*! js-yaml 5.4.1 https://github.com/nodeca/js-yaml @license MIT *)

pi/agent/skills/writing-skills/scripts/check.test.mjs

Deleted
deleted file mode 100644
1 -import assert from "node:assert/strict";
2 -import { spawnSync } from "node:child_process";
3 -import {
4 - mkdirSync,
5 - mkdtempSync,
6 - readFileSync,
7 - rmSync,
8 - symlinkSync,
9 - writeFileSync,
10 -} from "node:fs";
11 -import { tmpdir } from "node:os";
12 -import { dirname, join } from "node:path";
13 -import { test } from "node:test";
14 -import { fileURLToPath } from "node:url";
15 -import { checkSkill } from "./check.mjs";
17 -const cli = fileURLToPath(new URL("./check.mjs", import.meta.url));
18 -const header = '---\nname: example\ndescription: "Use when testing."\n---\n';
20 -function fixture(t, files = {}) {
21 - const temp = mkdtempSync(join(tmpdir(), "writing skills-"));
22 - t.after(() => rmSync(temp, { recursive: true, force: true }));
23 - const root = join(temp, "example");
24 - for (const [path, content] of Object.entries({
25 - "SKILL.md": header,
26 - ...files,
27 - })) {
28 - const dest = join(root, path);
29 - mkdirSync(dirname(dest), { recursive: true });
30 - writeFileSync(dest, content);
31 - }
32 - return root;
35 -function codes(root) {
36 - return checkSkill(root).issues.map((issue) => issue.code);
39 -test("valid prose-only skill needs neither package nor tests", (t) => {
40 - const result = checkSkill(fixture(t));
41 - assert.equal(result.ok, true);
42 - assert.deepEqual(result.issues, []);
43 -});
45 -for (const [label, content, expected] of [
46 - ["missing fences", "name: example", "frontmatter.fence"],
47 - ["unclosed fence", "---\nname: example", "frontmatter.fence"],
48 - ["invalid YAML", "---\nname: [\n---\n", "frontmatter.yaml"],
49 - [
50 - "duplicate YAML key",
51 - header.replace("name: example", "name: example\nname: other"),
52 - "frontmatter.yaml",
53 - ],
54 - ["non-mapping YAML", "---\n- example\n---\n", "frontmatter.mapping"],
55 - ["missing name", header.replace("name: example\n", ""), "name.invalid"],
56 - ["non-string name", header.replace("example", "123"), "name.invalid"],
57 - [
58 - "consecutive hyphens",
59 - header.replace("example", "ex--ample"),
60 - "name.invalid",
61 - ],
62 - ["uppercase name", header.replace("example", "Example"), "name.invalid"],
63 - ["leading hyphen", header.replace("example", "-example"), "name.invalid"],
64 - ["trailing hyphen", header.replace("example", "example-"), "name.invalid"],
65 - ["long name", header.replace("example", "a".repeat(65)), "name.invalid"],
66 - ["directory mismatch", header.replace("example", "other"), "name.directory"],
67 - ["missing description", "---\nname: example\n---\n", "description.invalid"],
68 - [
69 - "empty description",
70 - header.replace('"Use when testing."', '" "'),
71 - "description.invalid",
72 - ],
73 - [
74 - "non-string description",
75 - header.replace('"Use when testing."', "false"),
76 - "description.invalid",
77 - ],
78 - [
79 - "long description",
80 - header.replace("Use when testing.", "x".repeat(1025)),
81 - "description.invalid",
82 - ],
83 - [
84 - "non-boolean invocation flag",
85 - header.replace(
86 - "name: example",
87 - 'name: example\ndisable-model-invocation: "false"',
88 - ),
89 - "invocation.invalid",
90 - ],
91 -]) {
92 - test(label, (t) =>
93 - assert.ok(codes(fixture(t, { "SKILL.md": content })).includes(expected)),
94 - );
97 -test("YAML folded descriptions, comments, CRLF and unknown metadata are valid", (t) => {
98 - const content =
99 - "---\nname: example # comment\ndescription: >-\n Use when testing:\n quoted punctuation is not required here.\ndisable-model-invocation: true\nmetadata:\n topic: checks\n---\n";
100 - assert.deepEqual(
101 - codes(
102 - fixture(t, { "SKILL.md": `\uFEFF${content.replaceAll("\n", "\r\n")}` }),
103 - ),
104 - [],
105 - );
106 -});
108 -test("YAML scalar aliases resolve", (t) => {
109 - const root = fixture(t, {
110 - "SKILL.md": header.replace(
111 - 'description: "Use when testing."',
112 - 'label: &label "Use when testing."\ndescription: *label',
113 - ),
114 - });
115 - assert.deepEqual(codes(root), []);
116 -});
118 -test("unresolved YAML aliases fail even in optional metadata", (t) => {
119 - const root = fixture(t, {
120 - "SKILL.md": header.replace(
121 - "name: example",
122 - "name: example\nmetadata: *missing",
123 - ),
124 - });
125 - assert.ok(codes(root).includes("frontmatter.yaml"));
126 -});
128 -test("local inline, image, reference and nested Markdown links resolve per document", (t) => {
129 - const root = fixture(t, {
130 - "SKILL.md": `${header}\n[ref](references/guide.md#part)\n![image](assets/pic.png)\n[space][s]\n\n[s]: <references/a b.md>\n`,
131 - "references/guide.md":
132 - "[back](../SKILL.md)\n[encoded](a%20b.md?view=1#part)\n[parenthesized](a(b).md)",
133 - "references/a b.md": "OK",
134 - "references/a(b).md": "OK",
135 - "assets/pic.png": "fixture",
136 - });
137 - assert.deepEqual(codes(root), []);
138 -});
140 -test("missing local links report their source file", (t) => {
141 - const root = fixture(t, {
142 - "references/guide.md": "[missing](gone.md)\n![missing](gone.png)",
143 - });
144 - const result = checkSkill(root);
145 - assert.equal(result.ok, false);
146 - assert.deepEqual(
147 - result.issues.map(({ path, code }) => [path, code]),
148 - [
149 - ["references/guide.md", "link.missing"],
150 - ["references/guide.md", "link.missing"],
151 - ],
152 - );
153 -});
155 -test("external URLs, anchors, absolute links and code examples are not local-link checks", (t) => {
156 - const root = fixture(t, {
157 - "SKILL.md": `${header}
158 -[web](https://example.test/missing)
159 -[mail](mailto:test@example.test)
160 -[anchor](#missing)
161 -[absolute](/missing)
162 -[windows](C:/missing)
163 -[network](//example.test/missing)
164 -\`[code](missing.md)\`
166 -\`\`\`md
167 -[example](missing.md)
168 -\`\`\`
169 -`,
170 - });
171 - assert.deepEqual(codes(root), []);
172 -});
174 -test("bad URL encoding is an actionable issue", (t) => {
175 - assert.ok(
176 - codes(fixture(t, { "SKILL.md": `${header}[bad](missing%ZZ.md)` })).includes(
177 - "link.encoding",
178 - ),
179 - );
180 -});
182 -test("dependencies and VCS internals are not traversed", (t) => {
183 - assert.deepEqual(
184 - codes(
185 - fixture(t, {
186 - "node_modules/pkg/SKILL.md": "[bad](gone)",
187 - ".git/internal.md": "[bad](gone)",
188 - }),
189 - ),
190 - [],
191 - );
192 -});
194 -test("directory symlinks are not traversed", (t) => {
195 - const root = fixture(t);
196 - const external = join(dirname(root), "outside");
197 - mkdirSync(external);
198 - writeFileSync(join(external, "bad.md"), "[bad](gone)");
199 - symlinkSync(
200 - external,
201 - join(root, "references"),
202 - process.platform === "win32" ? "junction" : "dir",
203 - );
204 - assert.deepEqual(codes(root), []);
205 -});
207 -const helper = {
208 - "scripts/helper.mjs": 'throw new Error("must never execute");',
209 -};
210 -const testFile = {
211 - "scripts/helper.test.mjs": 'throw new Error("must never execute");',
212 -};
213 -const manifest = (command) => JSON.stringify({ scripts: { test: command } });
215 -for (const [label, files, expected] of [
216 - ["missing package and tests", helper, ["package.missing", "tests.missing"]],
217 - [
218 - "bad JSON",
219 - { ...helper, ...testFile, "package.json": "{" },
220 - ["package.json"],
221 - ],
222 - [
223 - "non-object manifest",
224 - { ...helper, ...testFile, "package.json": "null" },
225 - ["package.json"],
226 - ],
227 - [
228 - "missing test command",
229 - { ...helper, ...testFile, "package.json": "{}" },
230 - ["tests.command"],
231 - ],
232 - [
233 - "non-string test command",
234 - { ...helper, ...testFile, "package.json": manifest(42) },
235 - ["tests.command"],
236 - ],
237 - [
238 - "fake test command",
239 - { ...helper, ...testFile, "package.json": manifest("echo node --test") },
240 - ["tests.command"],
241 - ],
242 - [
243 - "missing tests",
244 - { ...helper, "package.json": manifest("node --test") },
245 - ["tests.missing"],
246 - ],
247 - [
248 - "valid scripted skill",
249 - {
250 - ...helper,
251 - ...testFile,
252 - "package.json": manifest("node --test scripts/*.test.mjs"),
253 - },
254 - [],
255 - ],
256 - [
257 - "nested tests",
258 - {
259 - ...helper,
260 - "test/nested/helper.test.mjs": "",
261 - "package.json": manifest("node --test"),
262 - },
263 - [],
264 - ],
265 - [
266 - "domain-specific helper",
267 - {
268 - "scripts/helper.ps1": "",
269 - ...testFile,
270 - "package.json": manifest("node --test"),
271 - },
272 - [],
273 - ],
274 -]) {
275 - test(label, (t) => assert.deepEqual(codes(fixture(t, files)), expected));
278 -test("CLI succeeds from unrelated cwd and paths with spaces", (t) => {
279 - const root = fixture(t, { "references/path with spaces.md": "OK" });
280 - const result = spawnSync(process.execPath, [cli, root], {
281 - cwd: tmpdir(),
282 - encoding: "utf8",
283 - });
284 - assert.equal(result.status, 0, result.stderr);
285 - assert.equal(JSON.parse(result.stdout).ok, true);
286 -});
288 -test("CLI returns 1 for findings", (t) => {
289 - const result = spawnSync(
290 - process.execPath,
291 - [cli, fixture(t, { "SKILL.md": "bad" })],
292 - { encoding: "utf8" },
293 - );
294 - assert.equal(result.status, 1);
295 - assert.equal(JSON.parse(result.stdout).ok, false);
296 -});
298 -test("CLI returns 2 for usage or inaccessible input", (t) => {
299 - const root = fixture(t);
300 - for (const args of [[], [root, "extra"], [join(root, "missing")]]) {
301 - const result = spawnSync(process.execPath, [cli, ...args], {
302 - encoding: "utf8",
303 - });
304 - assert.equal(result.status, 2, result.stderr);
305 - assert.ok(JSON.parse(result.stdout).error);
306 - }
307 -});
309 -test("checker audits itself", () => {
310 - const root = fileURLToPath(new URL("..", import.meta.url));
311 - assert.deepEqual(codes(root), []);
312 - assert.ok(readFileSync(join(root, "SKILL.md"), "utf8").includes("check.mjs"));
313 -});