@statelyai/sdk 0.39.1 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +10 -0
  2. package/dist/assetStorage.d.mts +1 -1
  3. package/dist/chunk-D1OLi6Wq.mjs +46 -0
  4. package/dist/editorHostProtocol.d.mts +3 -3
  5. package/dist/embed.d.mts +4 -3
  6. package/dist/embed.mjs +10 -3
  7. package/dist/{graph-CfWCJS4m.d.mts → graph-DbZdSisK.d.mts} +1 -1
  8. package/dist/graph.d.mts +1 -1
  9. package/dist/{index-DfMkVP94.d.mts → index-DqF1xP8P.d.mts} +50 -406
  10. package/dist/index.d.mts +5 -5
  11. package/dist/index.mjs +3 -3
  12. package/dist/{inspect-DXtP_tPO.mjs → inspect-CDjr4saL.mjs} +1 -1
  13. package/dist/{inspect-JNvMtuzC.d.mts → inspect-ruD95iBM.d.mts} +1 -1
  14. package/dist/inspect.d.mts +2 -2
  15. package/dist/inspect.mjs +2 -2
  16. package/dist/machineGraph-DYtFKHlq-BpWpGU22.mjs +3 -0
  17. package/dist/machineGraph-DYtFKHlq-ChbeTHlv.mjs +1023 -0
  18. package/dist/patchTypes.d.mts +1 -1
  19. package/dist/{protocol-D3XQmmmv.d.mts → protocol-BvElOcXs.d.mts} +17 -5
  20. package/dist/protocol.d.mts +1 -1
  21. package/dist/relay.d.mts +1 -1
  22. package/dist/rolldown-runtime-95iHPtFO-Bo6l7CbO.mjs +114 -0
  23. package/dist/{studio-DL0yj2Pi.mjs → schemas-DsQ8UYlM.mjs} +36 -1642
  24. package/dist/sourceCoverage.d.mts +101 -0
  25. package/dist/sourceCoverage.mjs +3572 -0
  26. package/dist/studio-DH7OeLao.mjs +1604 -0
  27. package/dist/{studio-ClBs4caM.d.mts → studio-DRw9sxCm.d.mts} +20 -2
  28. package/dist/studio.d.mts +1 -1
  29. package/dist/studio.mjs +1 -1
  30. package/dist/{version-gEUUpYtd.mjs → version-eag6cuvm.mjs} +1 -1
  31. package/dist/xstateSource-BUCx2xA4-CWteIFJn.d.mts +451 -0
  32. package/dist/xstateSource-JvwXWv6G-KnMMoZlG.mjs +151753 -0
  33. package/package.json +9 -5
  34. /package/dist/{editor-sync-types-Ch5P5XRj.d.mts → editor-sync-types-BjgSBGxf.d.mts} +0 -0
  35. /package/dist/{patchTypes-BZ7gzwAP.d.mts → patchTypes-BFlvJTDJ.d.mts} +0 -0
@@ -0,0 +1,3572 @@
1
+ import { a as __toESM$1 } from "./chunk-D1OLi6Wq.mjs";
2
+ import { At as boolean, Bt as discriminatedUnion, Er as toJSONSchema, Et as array, Lt as custom, Nn as record, Rn as string, St as _null, Tn as object, Xn as union, Zn as unknown, dn as literal, un as lazy, wn as number, yt as _enum } from "./schemas-DsQ8UYlM.mjs";
3
+ import { a as XSTATE_V5_PROFILE, d as isCodeExpression, l as XSTATE_V6_PROFILE, r as LEGACY_MACHINE_PROFILES } from "./rolldown-runtime-95iHPtFO-Bo6l7CbO.mjs";
4
+ import { l as stripExportDefault } from "./machineGraph-DYtFKHlq-ChbeTHlv.mjs";
5
+ import { i as require_typescript, n as getXStateSourceCoverageAnalysis, t as getXStateCoverageBranchProjection } from "./xstateSource-JvwXWv6G-KnMMoZlG.mjs";
6
+ import "xstate";
7
+ import "xstate/graph";
8
+
9
+ //#region ../graph-tools/dist/validation-Dw_E9VuI.mjs
10
+ function resolveProfileData(data, namespace) {
11
+ const prefix = `${namespace}.`;
12
+ return Object.fromEntries(Object.entries(data).filter(([key]) => key.startsWith(prefix)).map(([key, value]) => [key.slice(prefix.length), value]));
13
+ }
14
+ const ARCHITECTURE_PROFILE = "@statelyai/architecture@1.0.0";
15
+ const ARCHITECTURE_NAMESPACE = "@statelyai.architecture";
16
+ const architectureTargetSchema = discriminatedUnion("kind", [object({
17
+ kind: literal("machine"),
18
+ machineId: string().min(1),
19
+ projectId: string().min(1).optional()
20
+ }), object({
21
+ kind: literal("view"),
22
+ viewId: string().min(1)
23
+ })]);
24
+ const architectureViewSchema = object({
25
+ id: string().min(1),
26
+ name: string().min(1),
27
+ kind: _enum([
28
+ "system-context",
29
+ "container",
30
+ "component",
31
+ "custom"
32
+ ]),
33
+ nodeIds: array(string()),
34
+ edgeIds: array(string())
35
+ });
36
+ const architectureGraphDataSchema = object({
37
+ version: literal(1),
38
+ views: array(architectureViewSchema),
39
+ activeViewId: string().optional(),
40
+ projectOverview: boolean().optional()
41
+ });
42
+ const architectureNodeDataSchema = object({
43
+ kind: string().optional(),
44
+ externalId: string().optional(),
45
+ technology: string().optional(),
46
+ target: architectureTargetSchema.optional()
47
+ });
48
+ const architectureEdgeDataSchema = object({
49
+ kind: string().optional(),
50
+ externalId: string().optional(),
51
+ technology: string().optional()
52
+ });
53
+ function architectureData(data) {
54
+ return resolveProfileData(Object.fromEntries(Object.entries(data)), ARCHITECTURE_NAMESPACE);
55
+ }
56
+ function getArchitectureNodeData(node) {
57
+ const data = architectureData(node.data);
58
+ if (!Object.keys(data).length) return void 0;
59
+ const parsed = architectureNodeDataSchema.safeParse(data);
60
+ return parsed.success ? parsed.data : void 0;
61
+ }
62
+ const jsonSchema7Schema = lazy(() => object({
63
+ $schema: string().optional(),
64
+ type: _enum([
65
+ "object",
66
+ "array",
67
+ "string",
68
+ "number",
69
+ "integer",
70
+ "boolean",
71
+ "null"
72
+ ]).optional(),
73
+ properties: record(string(), jsonSchema7Schema).optional(),
74
+ items: jsonSchema7Schema.optional(),
75
+ additionalProperties: union([boolean(), jsonSchema7Schema]).optional(),
76
+ required: array(string()).optional(),
77
+ anyOf: array(jsonSchema7Schema).optional(),
78
+ oneOf: array(jsonSchema7Schema).optional(),
79
+ enum: array(union([
80
+ string(),
81
+ number(),
82
+ boolean(),
83
+ _null()
84
+ ])).optional(),
85
+ const: union([
86
+ string(),
87
+ number(),
88
+ boolean(),
89
+ _null()
90
+ ]).optional(),
91
+ minLength: number().optional()
92
+ }).strict());
93
+ function draft7Schema(schema) {
94
+ return jsonSchema7Schema.parse(toJSONSchema(schema, { target: "draft-7" }));
95
+ }
96
+ const ARCHITECTURE_PROFILE_MANIFEST = {
97
+ profile: ARCHITECTURE_PROFILE,
98
+ namespace: ARCHITECTURE_NAMESPACE,
99
+ lineage: "@statelyai/architecture",
100
+ projection: {
101
+ readOnlyPaths: [
102
+ "initialNodeId",
103
+ "nodes.*.initialNodeId",
104
+ "nodes.*.data.initialId",
105
+ "nodes.*.data.entry",
106
+ "nodes.*.data.exit",
107
+ "nodes.*.data.invokes",
108
+ "nodes.*.data.history",
109
+ "edges.*.data.guard",
110
+ "edges.*.data.actions",
111
+ "edges.*.data.transitionType"
112
+ ],
113
+ adapt: (graph) => ({ data: {
114
+ nodes: Object.fromEntries(graph.nodes.map((node) => [node.id, { kind: getArchitectureNodeData(node)?.kind ?? "component" }])),
115
+ edges: Object.fromEntries(graph.edges.map((edge) => [edge.id, { kind: "relationship" }]))
116
+ } }),
117
+ analyzeCompatibility: (graph) => graph.nodes.some((node) => node.data.initialId || Array.isArray(node.data.entry) && node.data.entry.length || Array.isArray(node.data.exit) && node.data.exit.length || Array.isArray(node.data.invokes) && node.data.invokes.length) || graph.edges.some((edge) => edge.data.guard || Array.isArray(edge.data.actions) && edge.data.actions.length || edge.data.transitionType && edge.data.transitionType !== "normal") ? [{
118
+ level: "warning",
119
+ message: "State-machine initial states, effects, guards and transition behavior are retained but read-only in Architecture. Relationships describe structure; architecture simulation is unavailable."
120
+ }] : []
121
+ },
122
+ name: "Architecture",
123
+ description: "Components, relationships, and navigable system views.",
124
+ selectable: true,
125
+ restrictFormatsToListed: true,
126
+ defaultFormat: "xgraph",
127
+ graph: { dataSchema: draft7Schema(architectureGraphDataSchema) },
128
+ authoring: {
129
+ terminology: {
130
+ node: "component",
131
+ edge: "relationship",
132
+ graph: "architecture"
133
+ },
134
+ nodeTypes: [
135
+ "element",
136
+ "actor",
137
+ "person",
138
+ "system",
139
+ "container",
140
+ "component",
141
+ "service",
142
+ "database",
143
+ "queue",
144
+ "group",
145
+ "junction"
146
+ ].map((kind) => ({
147
+ kind,
148
+ label: kind.charAt(0).toUpperCase() + kind.slice(1),
149
+ authorable: true,
150
+ canContain: true,
151
+ dataSchema: draft7Schema(architectureNodeDataSchema)
152
+ })),
153
+ edgeTypes: [{
154
+ kind: "relationship",
155
+ label: "Relationship",
156
+ authorable: true,
157
+ dataSchema: draft7Schema(architectureEdgeDataSchema)
158
+ }],
159
+ attachments: {
160
+ actions: false,
161
+ guards: false,
162
+ invokes: false,
163
+ tags: false
164
+ },
165
+ supportsInitialNode: false,
166
+ supportsTargetlessEdges: false,
167
+ supportsReenterEdges: false
168
+ },
169
+ operations: {
170
+ simulate: false,
171
+ validate: true,
172
+ export: true
173
+ },
174
+ formats: [{
175
+ format: "xgraph",
176
+ import: true,
177
+ export: true
178
+ }, ...[
179
+ "structurizr-json",
180
+ "d2",
181
+ "mermaid"
182
+ ].map((format) => ({
183
+ format,
184
+ import: true,
185
+ export: false
186
+ }))]
187
+ };
188
+ function analyzeXStateV5Compatibility(graph) {
189
+ const issues = [];
190
+ const graphPaths = [["data.version", graph.data.version], ["data.options", graph.data.options]].filter(([, value]) => value != null);
191
+ if (graphPaths.length) issues.push({
192
+ level: "warning",
193
+ message: "XState v6 machine fields are retained but read-only in XState v5.",
194
+ readOnlyPaths: graphPaths.map(([path]) => path)
195
+ });
196
+ for (const node of graph.nodes) {
197
+ const paths = [
198
+ ["data.initialInput", node.data.initialInput],
199
+ ["data.timeout", node.data.timeout],
200
+ ["data.route", node.data.route],
201
+ ["data.schemas", node.data.schemas]
202
+ ].filter(([, value]) => value != null);
203
+ if (paths.length) issues.push({
204
+ level: "warning",
205
+ message: `XState v6 fields on ${node.data.key ?? node.id} are retained but read-only in XState v5.`,
206
+ nodeIds: [node.id],
207
+ readOnlyPaths: paths.map(([path]) => `nodes.${node.id}.${path}`)
208
+ });
209
+ }
210
+ for (const edge of graph.edges) {
211
+ const paths = [["data.matches", edge.data.matches], ["data.input", edge.data.input]].filter(([, value]) => value != null);
212
+ if (paths.length) issues.push({
213
+ level: "warning",
214
+ message: "XState v6 transition fields are retained but read-only in XState v5.",
215
+ edgeIds: [edge.id],
216
+ readOnlyPaths: paths.map(([path]) => `edges.${edge.id}.${path}`)
217
+ });
218
+ }
219
+ return issues;
220
+ }
221
+ const XSTATE_V5_PROJECTION = {
222
+ readOnlyPaths: [
223
+ "data.version",
224
+ "data.options",
225
+ "nodes.*.data.initialInput",
226
+ "nodes.*.data.timeout",
227
+ "nodes.*.data.route",
228
+ "nodes.*.data.schemas",
229
+ "edges.*.data.matches",
230
+ "edges.*.data.input"
231
+ ],
232
+ analyzeCompatibility: analyzeXStateV5Compatibility
233
+ };
234
+ const XSTATE_V6_PROJECTION = {};
235
+ /**
236
+ * Derive LangGraph authoring kinds into its namespace. Canonical fields and
237
+ * graph topology are never returned, so the adapter cannot rewrite them.
238
+ */
239
+ const LANGGRAPH_PROJECTION = { adapt: (graph) => ({ data: {
240
+ nodes: Object.fromEntries(graph.nodes.map((node) => [node.id, { kind: node.data.type === "final" ? "end" : node.data.kind === "agent" || node.data.kind === "task" || node.data.kind === "entrypoint" ? node.data.kind : "node" }])),
241
+ edges: Object.fromEntries(graph.edges.map((edge) => {
242
+ const source = graph.nodes.find((node) => node.id === edge.sourceId);
243
+ return [edge.id, { kind: edge.data.kind === "call" ? "call" : edge.data.kind === "conditional" || edge.data.guard != null || source?.data.type === "choice" ? "conditional" : "edge" }];
244
+ }))
245
+ } }) };
246
+ /** Stately's semantic projection of the LangGraph 1.x APIs across runtimes. */
247
+ const LANGGRAPH_PROFILE = "@statelyai/langgraph@1.0.0";
248
+ const LANGGRAPH_PROFILE_MANIFEST = {
249
+ profile: LANGGRAPH_PROFILE,
250
+ namespace: "@statelyai.langgraph",
251
+ lineage: "@statelyai/langgraph",
252
+ projection: LANGGRAPH_PROJECTION,
253
+ selectable: false,
254
+ name: "LangGraph",
255
+ description: "LangGraph 1.x graph semantics for Python and JavaScript/TypeScript source.",
256
+ restrictFormatsToListed: true,
257
+ authoring: {
258
+ terminology: {
259
+ node: "node",
260
+ edge: "edge",
261
+ graph: "graph"
262
+ },
263
+ nodeTypes: [
264
+ {
265
+ kind: "node",
266
+ label: "Node",
267
+ description: "Graph API node",
268
+ authorable: true
269
+ },
270
+ {
271
+ kind: "task",
272
+ label: "Task",
273
+ description: "Functional API task",
274
+ authorable: true
275
+ },
276
+ {
277
+ kind: "entrypoint",
278
+ label: "Entrypoint",
279
+ description: "Functional API entrypoint",
280
+ authorable: true
281
+ },
282
+ {
283
+ kind: "agent",
284
+ label: "Agent",
285
+ description: "Prebuilt agent",
286
+ authorable: true
287
+ },
288
+ {
289
+ kind: "end",
290
+ label: "END",
291
+ description: "Terminal sentinel",
292
+ authorable: true,
293
+ terminal: true
294
+ }
295
+ ],
296
+ edgeTypes: [
297
+ {
298
+ kind: "edge",
299
+ label: "Edge",
300
+ description: "Direct route",
301
+ authorable: true
302
+ },
303
+ {
304
+ kind: "conditional",
305
+ label: "Conditional edge",
306
+ description: "Runtime-routed branch",
307
+ authorable: true
308
+ },
309
+ {
310
+ kind: "call",
311
+ label: "Call",
312
+ description: "Functional API call",
313
+ authorable: true
314
+ }
315
+ ],
316
+ attachments: {},
317
+ supportsInitialNode: false,
318
+ supportsTargetlessEdges: false,
319
+ supportsReenterEdges: false
320
+ },
321
+ operations: {
322
+ simulate: false,
323
+ validate: false,
324
+ export: false
325
+ },
326
+ formats: [
327
+ {
328
+ format: "python",
329
+ import: true,
330
+ export: false,
331
+ sourcePreserving: true
332
+ },
333
+ {
334
+ format: "typescript",
335
+ import: true,
336
+ export: false,
337
+ sourcePreserving: true
338
+ },
339
+ {
340
+ format: "javascript",
341
+ import: true,
342
+ export: false,
343
+ sourcePreserving: true
344
+ }
345
+ ],
346
+ features: {
347
+ graphApi: true,
348
+ functionalApi: true,
349
+ prebuiltAgents: true
350
+ }
351
+ };
352
+ let syntaxChecker;
353
+ /**
354
+ * Installs the parser used to validate profile code blocks. The main entry
355
+ * stays free of the TypeScript compiler, so `@statelyai/graph-tools/typescript`
356
+ * installs a TypeScript-backed checker when it loads. Until then, profile code
357
+ * is treated as syntactically valid.
358
+ */
359
+ function setProfileCodeSyntaxChecker(checker) {
360
+ syntaxChecker = checker;
361
+ }
362
+ function hasNoParseErrors(source) {
363
+ return syntaxChecker ? syntaxChecker(source) : true;
364
+ }
365
+ const XSTATE_FORMATS = [
366
+ {
367
+ format: "typescript",
368
+ import: true,
369
+ export: true,
370
+ sourcePreserving: true
371
+ },
372
+ {
373
+ format: "javascript",
374
+ import: true,
375
+ export: true,
376
+ sourcePreserving: true
377
+ },
378
+ {
379
+ format: "json",
380
+ import: true,
381
+ export: true
382
+ },
383
+ {
384
+ format: "yaml",
385
+ import: true,
386
+ export: true
387
+ }
388
+ ];
389
+ const XSTATE_AUTHORING = {
390
+ terminology: {
391
+ node: "state",
392
+ edge: "transition",
393
+ graph: "machine"
394
+ },
395
+ nodeTypes: [
396
+ {
397
+ kind: "normal",
398
+ label: "Normal",
399
+ description: "Basic state",
400
+ authorable: true,
401
+ canContain: true
402
+ },
403
+ {
404
+ kind: "parallel",
405
+ label: "Parallel",
406
+ description: "Concurrent child states",
407
+ authorable: true,
408
+ canContain: true
409
+ },
410
+ {
411
+ kind: "final",
412
+ label: "Final",
413
+ description: "Terminal state",
414
+ authorable: true,
415
+ terminal: true
416
+ },
417
+ {
418
+ kind: "history",
419
+ label: "History",
420
+ description: "Restores previous state",
421
+ authorable: true
422
+ },
423
+ {
424
+ kind: "choice",
425
+ label: "Choice",
426
+ description: "Guarded eventless routing",
427
+ authorable: true
428
+ }
429
+ ],
430
+ edgeTypes: [{
431
+ kind: "transition",
432
+ label: "Transition",
433
+ authorable: true
434
+ }],
435
+ attachments: {
436
+ actions: true,
437
+ guards: true,
438
+ invokes: true,
439
+ tags: true
440
+ },
441
+ supportsInitialNode: true,
442
+ supportsTargetlessEdges: true,
443
+ supportsReenterEdges: true
444
+ };
445
+ function isExpression(code) {
446
+ return code.trim().length > 0 && hasNoParseErrors(`(${code})`);
447
+ }
448
+ function isImplementation(code) {
449
+ return isExpression(stripExportDefault(code)) || hasNoParseErrors(`function implementation() {\n${code}\n}`);
450
+ }
451
+ function isAsyncImplementation(code) {
452
+ return isExpression(stripExportDefault(code)) || hasNoParseErrors(`async function implementation() {\n${code}\n}`);
453
+ }
454
+ function pathEndsWith(location, suffix) {
455
+ return suffix.every((segment, index) => location.path[location.path.length - suffix.length + index] === segment);
456
+ }
457
+ function commented(code) {
458
+ return code.replace(/\r\n?|\u2028|\u2029/g, "\n").split("\n").map((line) => `// ${line}`).join("\n");
459
+ }
460
+ function indent(code, spaces) {
461
+ const prefix = " ".repeat(spaces);
462
+ return code.split("\n").map((line) => `${prefix}${line}`).join("\n");
463
+ }
464
+ function indentAfterFirstLine(code, spaces) {
465
+ const [first = "", ...rest] = code.split("\n");
466
+ if (rest.length === 0) return first;
467
+ return `${first}\n${indent(rest.join("\n"), spaces)}`;
468
+ }
469
+ const throwingBody = (invalidCode) => `// FIXME(stately): authored code does not compile\n${commented(invalidCode)}\nthrow new Error('Invalid authored code');`;
470
+ const falseBody = (invalidCode) => `// FIXME(stately): authored code does not compile\n${commented(invalidCode)}\nreturn false;`;
471
+ const throwingExpression = (invalidCode) => `(() => {\n${indent(throwingBody(invalidCode), 2)}\n})()`;
472
+ const functionThrowingExpression = (invalidCode) => `() => {\n${indent(throwingBody(invalidCode), 2)}\n}`;
473
+ const functionFalseExpression = (invalidCode) => `() => {\n${indent(falseBody(invalidCode), 2)}\n}`;
474
+ const throwingImplementationBody = (invalidCode) => indentAfterFirstLine(throwingBody(invalidCode), 2);
475
+ const falseImplementationBody = (invalidCode) => indentAfterFirstLine(falseBody(invalidCode), 2);
476
+ function implementationTarget(location, collection) {
477
+ const index = location.path[3];
478
+ const implementations = location.graph.data.implementations?.[collection];
479
+ const implementation = typeof index === "number" ? implementations?.[index] : void 0;
480
+ if (!implementation?.id) return void 0;
481
+ return {
482
+ kind: "source",
483
+ sourceType: collection === "actors" ? "actor" : collection.slice(0, -1),
484
+ id: implementation.id,
485
+ label: implementation.name || implementation.id
486
+ };
487
+ }
488
+ function entityTarget(location) {
489
+ const [collection, index] = location.path;
490
+ const isNode = collection === "nodes" && typeof index === "number";
491
+ const isEdge = collection === "edges" && typeof index === "number";
492
+ const owner = isNode ? location.graph.nodes[index] : isEdge ? location.graph.edges[index] : void 0;
493
+ if (!owner) return void 0;
494
+ const dataOffset = location.path.indexOf("data");
495
+ const field = location.path[dataOffset + 1];
496
+ const itemIndex = location.path[dataOffset + 2];
497
+ if ((field === "entry" || field === "exit" || field === "actions") && typeof itemIndex === "number") {
498
+ const action = owner.data[field]?.[itemIndex];
499
+ if (action?.id) return {
500
+ kind: "entity",
501
+ id: `action:${action.id}`,
502
+ label: action.type ? `Action: ${action.type}` : "Action"
503
+ };
504
+ }
505
+ if (field === "invokes" && typeof itemIndex === "number") {
506
+ const invoke = owner.data.invokes?.[itemIndex];
507
+ if (invoke?.id) return {
508
+ kind: "entity",
509
+ id: `invoke:${invoke.id}`,
510
+ label: invoke.src ? `Invoke: ${invoke.src}` : "Invoke"
511
+ };
512
+ }
513
+ if (isEdge && field === "guard") return {
514
+ kind: "entity",
515
+ id: `guard:${owner.id}`,
516
+ label: "Guard"
517
+ };
518
+ if (isEdge && field === "context") return {
519
+ kind: "entity",
520
+ id: `context:${owner.id}`,
521
+ label: "Context"
522
+ };
523
+ if (field === "meta") return {
524
+ kind: "entity",
525
+ id: `meta:${owner.id}`,
526
+ label: "Meta"
527
+ };
528
+ }
529
+ const implementationBlock = (name, collection, exportInvalid, isValid = isImplementation) => ({
530
+ name,
531
+ matches: ({ path }) => path.length === 6 && path[0] === "data" && path[1] === "implementations" && path[2] === collection && typeof path[3] === "number" && path[4] === "code" && path[5] === "body",
532
+ isValid,
533
+ exportInvalid,
534
+ getTarget: (location) => implementationTarget(location, collection)
535
+ });
536
+ const XSTATE_CODE_BLOCKS = [
537
+ implementationBlock("action implementation", "actions", throwingImplementationBody),
538
+ implementationBlock("guard implementation", "guards", falseImplementationBody),
539
+ implementationBlock("actor implementation", "actors", throwingImplementationBody, isAsyncImplementation),
540
+ implementationBlock("delay implementation", "delays", throwingImplementationBody),
541
+ {
542
+ name: "inline guard",
543
+ matches: (location) => pathEndsWith(location, ["guard", "code"]),
544
+ isValid: isExpression,
545
+ exportInvalid: functionFalseExpression,
546
+ getTarget: entityTarget
547
+ },
548
+ {
549
+ name: "inline action",
550
+ matches: (location) => {
551
+ if (!pathEndsWith(location, ["params", "code"])) return false;
552
+ const owner = location.ancestors.at(-2);
553
+ return !!owner && typeof owner === "object" && owner.type === "xstate.expr";
554
+ },
555
+ isValid: isExpression,
556
+ exportInvalid: functionThrowingExpression,
557
+ getTarget: entityTarget,
558
+ getSourceValue: (location) => {
559
+ const owner = location.ancestors.at(-2);
560
+ return owner && typeof owner === "object" ? owner : void 0;
561
+ }
562
+ },
563
+ {
564
+ name: "code expression",
565
+ matches: (location) => pathEndsWith(location, ["expr"]) && !!location.parent && typeof location.parent === "object" && location.parent["@type"] === "code",
566
+ isValid: isExpression,
567
+ exportInvalid: throwingExpression,
568
+ getTarget: entityTarget
569
+ }
570
+ ];
571
+ const XSTATE_PROFILE_MANIFESTS = [{
572
+ profile: XSTATE_V5_PROFILE,
573
+ namespace: "@statelyai.xstate",
574
+ lineage: "@statelyai/xstate",
575
+ projection: XSTATE_V5_PROJECTION,
576
+ name: "XState v5",
577
+ formats: [...XSTATE_FORMATS],
578
+ authoring: XSTATE_AUTHORING,
579
+ code: { blocks: XSTATE_CODE_BLOCKS },
580
+ operations: {
581
+ simulate: true,
582
+ validate: true,
583
+ export: true
584
+ }
585
+ }, {
586
+ profile: XSTATE_V6_PROFILE,
587
+ namespace: "@statelyai.xstate",
588
+ lineage: "@statelyai/xstate",
589
+ projection: XSTATE_V6_PROJECTION,
590
+ name: "XState v6 alpha",
591
+ formats: [...XSTATE_FORMATS],
592
+ authoring: XSTATE_AUTHORING,
593
+ code: { blocks: XSTATE_CODE_BLOCKS },
594
+ operations: {
595
+ simulate: true,
596
+ validate: true,
597
+ export: true
598
+ }
599
+ }];
600
+ const PROFILE_MANIFESTS = new Map([
601
+ ...XSTATE_PROFILE_MANIFESTS,
602
+ LANGGRAPH_PROFILE_MANIFEST,
603
+ ARCHITECTURE_PROFILE_MANIFEST
604
+ ].map((manifest) => [manifest.profile, manifest]));
605
+ const colorSchema = _enum([
606
+ "green",
607
+ "red",
608
+ "purple",
609
+ "blue",
610
+ "orange",
611
+ "yellow",
612
+ "pink",
613
+ "teal"
614
+ ]);
615
+ const stateTypeSchema = _enum([
616
+ "normal",
617
+ "parallel",
618
+ "history",
619
+ "final"
620
+ ]).nullable();
621
+ const actionLocationSchema = union([object({
622
+ nodeId: string(),
623
+ group: _enum(["entry", "exit"])
624
+ }), object({
625
+ edgeId: string(),
626
+ group: literal("transition")
627
+ })]);
628
+ const createStatePatchSchema = object({
629
+ op: literal("createState"),
630
+ description: string().optional(),
631
+ id: string().optional(),
632
+ parentId: string(),
633
+ key: string(),
634
+ type: stateTypeSchema.optional(),
635
+ x: number().optional(),
636
+ y: number().optional(),
637
+ color: colorSchema.nullable().optional(),
638
+ initial: boolean().optional()
639
+ });
640
+ const updateStatePatchSchema = object({
641
+ op: literal("updateState"),
642
+ description: string().optional(),
643
+ stateId: string(),
644
+ key: string().optional(),
645
+ type: stateTypeSchema.optional(),
646
+ stateDescription: string().optional(),
647
+ initialId: string().nullable().optional(),
648
+ color: colorSchema.nullable().optional(),
649
+ meta: record(string(), unknown()).nullable().optional(),
650
+ history: _enum(["shallow", "deep"]).nullable().optional()
651
+ });
652
+ const deleteStatePatchSchema = object({
653
+ op: literal("deleteState"),
654
+ description: string().optional(),
655
+ stateId: string()
656
+ });
657
+ const guardSchema = object({
658
+ type: string(),
659
+ code: string().optional(),
660
+ params: record(string(), unknown()).optional()
661
+ });
662
+ const createTransitionPatchSchema = object({
663
+ op: literal("createTransition"),
664
+ description: string().optional(),
665
+ id: string().optional(),
666
+ sourceId: string(),
667
+ targetId: string(),
668
+ eventType: string(),
669
+ matches: record(string(), unknown()).optional(),
670
+ transitionType: _enum([
671
+ "normal",
672
+ "targetless",
673
+ "reenter"
674
+ ]).optional(),
675
+ guard: guardSchema.optional(),
676
+ color: colorSchema.nullable().optional(),
677
+ transitionDescription: string().nullable().optional()
678
+ });
679
+ const updateTransitionPatchSchema = object({
680
+ op: literal("updateTransition"),
681
+ description: string().optional(),
682
+ transitionId: string(),
683
+ sourceId: string().optional(),
684
+ targetId: string().optional(),
685
+ eventType: string().optional(),
686
+ matches: record(string(), unknown()).optional(),
687
+ transitionType: _enum([
688
+ "normal",
689
+ "targetless",
690
+ "reenter"
691
+ ]).optional(),
692
+ transitionDescription: string().nullable().optional(),
693
+ color: colorSchema.nullable().optional(),
694
+ meta: record(string(), unknown()).nullable().optional()
695
+ });
696
+ const deleteTransitionPatchSchema = object({
697
+ op: literal("deleteTransition"),
698
+ description: string().optional(),
699
+ transitionId: string()
700
+ });
701
+ const createActionPatchSchema = object({
702
+ op: literal("createAction"),
703
+ description: string().optional(),
704
+ location: actionLocationSchema,
705
+ action: object({
706
+ id: string().optional(),
707
+ type: string(),
708
+ params: record(string(), unknown()).optional()
709
+ }),
710
+ index: number().optional()
711
+ });
712
+ const updateActionPatchSchema = object({
713
+ op: literal("updateAction"),
714
+ description: string().optional(),
715
+ location: actionLocationSchema,
716
+ actionId: string(),
717
+ data: object({
718
+ type: string().optional(),
719
+ params: record(string(), unknown()).optional()
720
+ })
721
+ });
722
+ const deleteActionPatchSchema = object({
723
+ op: literal("deleteAction"),
724
+ description: string().optional(),
725
+ location: actionLocationSchema,
726
+ actionId: string()
727
+ });
728
+ const setGuardPatchSchema = object({
729
+ op: literal("setGuard"),
730
+ description: string().optional(),
731
+ edgeId: string(),
732
+ guard: guardSchema
733
+ });
734
+ const deleteGuardPatchSchema = object({
735
+ op: literal("deleteGuard"),
736
+ description: string().optional(),
737
+ edgeId: string()
738
+ });
739
+ const machinePatchSchema = discriminatedUnion("op", [
740
+ createStatePatchSchema,
741
+ updateStatePatchSchema,
742
+ deleteStatePatchSchema,
743
+ createTransitionPatchSchema,
744
+ updateTransitionPatchSchema,
745
+ deleteTransitionPatchSchema,
746
+ createActionPatchSchema,
747
+ updateActionPatchSchema,
748
+ deleteActionPatchSchema,
749
+ setGuardPatchSchema,
750
+ deleteGuardPatchSchema
751
+ ]);
752
+ const validationLevelSchema = _enum([
753
+ "info",
754
+ "warning",
755
+ "error"
756
+ ]);
757
+ const validationIssueKindSchema = _enum([
758
+ "correctness",
759
+ "reachability",
760
+ "optimization",
761
+ "maintainability",
762
+ "security"
763
+ ]);
764
+ const validationIssueCodeSchema = _enum([
765
+ "parse_error",
766
+ "unsupported_format",
767
+ "empty_state_key",
768
+ "invalid_state_key",
769
+ "duplicate_state_key",
770
+ "history_initial",
771
+ "missing_initial",
772
+ "invalid_initial",
773
+ "unreachable_state",
774
+ "final_state_invokes",
775
+ "invalid_state_children",
776
+ "empty_parallel",
777
+ "single_child_compound",
778
+ "noop_transient_state",
779
+ "sole_default_choice",
780
+ "on_done_unreachable",
781
+ "duplicate_transition",
782
+ "invalid_delay",
783
+ "repeated_guard",
784
+ "transition_never_taken",
785
+ "missing_guard",
786
+ "redundant_transition",
787
+ "eventless_cycle",
788
+ "missing_delay_implementation",
789
+ "invalid_final_transition",
790
+ "invalid_history_transition",
791
+ "invalid_choice_event",
792
+ "parallel_region_transition",
793
+ "duplicate_source_name",
794
+ "undefined_action",
795
+ "undefined_guard",
796
+ "undefined_actor"
797
+ ]);
798
+ const validationFixKindSchema = _enum([
799
+ "patch",
800
+ "rewrite",
801
+ "advice",
802
+ "proposedPatch"
803
+ ]);
804
+ const validationFixSourceSchema = _enum(["deterministic", "llm"]);
805
+ const validationIssueTargetSchema = object({
806
+ nodeIds: array(string()).optional(),
807
+ edgeIds: array(string()).optional(),
808
+ source: object({
809
+ path: string().optional(),
810
+ start: number().optional(),
811
+ end: number().optional()
812
+ }).optional()
813
+ });
814
+ const validationFixSchema = object({
815
+ kind: validationFixKindSchema,
816
+ source: validationFixSourceSchema,
817
+ title: string(),
818
+ patches: array(unknown()).optional(),
819
+ output: unknown().optional(),
820
+ diff: unknown().optional(),
821
+ confidence: number().optional(),
822
+ rationale: string().optional(),
823
+ rank: number().optional(),
824
+ postValidation: object({
825
+ ok: boolean(),
826
+ remainingIssueCodes: array(validationIssueCodeSchema)
827
+ }).optional()
828
+ });
829
+ const validationIssueSchema = object({
830
+ code: validationIssueCodeSchema,
831
+ kind: validationIssueKindSchema,
832
+ level: validationLevelSchema,
833
+ message: string(),
834
+ target: validationIssueTargetSchema,
835
+ metadata: record(string(), unknown()).optional(),
836
+ fixes: array(validationFixSchema).optional(),
837
+ source: _enum(["deterministic", "llm"]).optional(),
838
+ nodeIds: array(string()),
839
+ edgeIds: array(string())
840
+ });
841
+
842
+ //#endregion
843
+ //#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
844
+ var import_typescript = /* @__PURE__ */ __toESM$1(require_typescript(), 1);
845
+ /*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT */
846
+ var __create = Object.create;
847
+ var __defProp = Object.defineProperty;
848
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
849
+ var __getOwnPropNames = Object.getOwnPropertyNames;
850
+ var __getProtoOf = Object.getPrototypeOf;
851
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
852
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
853
+ var __copyProps = (to, from, except, desc) => {
854
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
855
+ key = keys[i];
856
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
857
+ get: ((k) => from[k]).bind(null, key),
858
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
859
+ });
860
+ }
861
+ return to;
862
+ };
863
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
864
+ value: mod,
865
+ enumerable: true
866
+ }) : target, mod));
867
+ var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
868
+ function isNothing(subject) {
869
+ return typeof subject === "undefined" || subject === null;
870
+ }
871
+ function isObject(subject) {
872
+ return typeof subject === "object" && subject !== null;
873
+ }
874
+ function toArray(sequence) {
875
+ if (Array.isArray(sequence)) return sequence;
876
+ else if (isNothing(sequence)) return [];
877
+ return [sequence];
878
+ }
879
+ function extend(target, source) {
880
+ if (source) {
881
+ const sourceKeys = Object.keys(source);
882
+ for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
883
+ const key = sourceKeys[index];
884
+ target[key] = source[key];
885
+ }
886
+ }
887
+ return target;
888
+ }
889
+ function repeat(string, count) {
890
+ let result = "";
891
+ for (let cycle = 0; cycle < count; cycle += 1) result += string;
892
+ return result;
893
+ }
894
+ function isNegativeZero(number) {
895
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
896
+ }
897
+ module.exports.isNothing = isNothing;
898
+ module.exports.isObject = isObject;
899
+ module.exports.toArray = toArray;
900
+ module.exports.repeat = repeat;
901
+ module.exports.isNegativeZero = isNegativeZero;
902
+ module.exports.extend = extend;
903
+ }));
904
+ var require_exception = /* @__PURE__ */ __commonJSMin(((exports, module) => {
905
+ function formatError(exception, compact) {
906
+ let where = "";
907
+ const message = exception.reason || "(unknown reason)";
908
+ if (!exception.mark) return message;
909
+ if (exception.mark.name) where += "in \"" + exception.mark.name + "\" ";
910
+ where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
911
+ if (!compact && exception.mark.snippet) where += "\n\n" + exception.mark.snippet;
912
+ return message + " " + where;
913
+ }
914
+ function YAMLException(reason, mark) {
915
+ Error.call(this);
916
+ this.name = "YAMLException";
917
+ this.reason = reason;
918
+ this.mark = mark;
919
+ this.message = formatError(this, false);
920
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
921
+ else this.stack = (/* @__PURE__ */ new Error()).stack || "";
922
+ }
923
+ YAMLException.prototype = Object.create(Error.prototype);
924
+ YAMLException.prototype.constructor = YAMLException;
925
+ YAMLException.prototype.toString = function toString(compact) {
926
+ return this.name + ": " + formatError(this, compact);
927
+ };
928
+ module.exports = YAMLException;
929
+ }));
930
+ var require_snippet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
931
+ var common = require_common();
932
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
933
+ let head = "";
934
+ let tail = "";
935
+ const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
936
+ if (position - lineStart > maxHalfLength) {
937
+ head = " ... ";
938
+ lineStart = position - maxHalfLength + head.length;
939
+ }
940
+ if (lineEnd - position > maxHalfLength) {
941
+ tail = " ...";
942
+ lineEnd = position + maxHalfLength - tail.length;
943
+ }
944
+ return {
945
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
946
+ pos: position - lineStart + head.length
947
+ };
948
+ }
949
+ function padStart(string, max) {
950
+ return common.repeat(" ", max - string.length) + string;
951
+ }
952
+ function makeSnippet(mark, options) {
953
+ options = Object.create(options || null);
954
+ if (!mark.buffer) return null;
955
+ if (!options.maxLength) options.maxLength = 79;
956
+ if (typeof options.indent !== "number") options.indent = 1;
957
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
958
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
959
+ const re = /\r?\n|\r|\0/g;
960
+ const lineStarts = [0];
961
+ const lineEnds = [];
962
+ let match;
963
+ let foundLineNo = -1;
964
+ while (match = re.exec(mark.buffer)) {
965
+ lineEnds.push(match.index);
966
+ lineStarts.push(match.index + match[0].length);
967
+ if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
968
+ }
969
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
970
+ let result = "";
971
+ const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
972
+ const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
973
+ for (let i = 1; i <= options.linesBefore; i++) {
974
+ if (foundLineNo - i < 0) break;
975
+ const line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
976
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
977
+ }
978
+ const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
979
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
980
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
981
+ for (let i = 1; i <= options.linesAfter; i++) {
982
+ if (foundLineNo + i >= lineEnds.length) break;
983
+ const line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
984
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
985
+ }
986
+ return result.replace(/\n$/, "");
987
+ }
988
+ module.exports = makeSnippet;
989
+ }));
990
+ var require_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
991
+ var YAMLException = require_exception();
992
+ var TYPE_CONSTRUCTOR_OPTIONS = [
993
+ "kind",
994
+ "multi",
995
+ "resolve",
996
+ "construct",
997
+ "instanceOf",
998
+ "predicate",
999
+ "represent",
1000
+ "representName",
1001
+ "defaultStyle",
1002
+ "styleAliases"
1003
+ ];
1004
+ var YAML_NODE_KINDS = [
1005
+ "scalar",
1006
+ "sequence",
1007
+ "mapping"
1008
+ ];
1009
+ function compileStyleAliases(map) {
1010
+ const result = {};
1011
+ if (map !== null) Object.keys(map).forEach(function(style) {
1012
+ map[style].forEach(function(alias) {
1013
+ result[String(alias)] = style;
1014
+ });
1015
+ });
1016
+ return result;
1017
+ }
1018
+ function Type(tag, options) {
1019
+ options = options || {};
1020
+ Object.keys(options).forEach(function(name) {
1021
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) throw new YAMLException("Unknown option \"" + name + "\" is met in definition of \"" + tag + "\" YAML type.");
1022
+ });
1023
+ this.options = options;
1024
+ this.tag = tag;
1025
+ this.kind = options["kind"] || null;
1026
+ this.resolve = options["resolve"] || function() {
1027
+ return true;
1028
+ };
1029
+ this.construct = options["construct"] || function(data) {
1030
+ return data;
1031
+ };
1032
+ this.instanceOf = options["instanceOf"] || null;
1033
+ this.predicate = options["predicate"] || null;
1034
+ this.represent = options["represent"] || null;
1035
+ this.representName = options["representName"] || null;
1036
+ this.defaultStyle = options["defaultStyle"] || null;
1037
+ this.multi = options["multi"] || false;
1038
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
1039
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) throw new YAMLException("Unknown kind \"" + this.kind + "\" is specified for \"" + tag + "\" YAML type.");
1040
+ }
1041
+ module.exports = Type;
1042
+ }));
1043
+ var require_schema = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1044
+ var YAMLException = require_exception();
1045
+ var Type = require_type();
1046
+ function compileList(schema, name) {
1047
+ const result = [];
1048
+ schema[name].forEach(function(currentType) {
1049
+ let newIndex = result.length;
1050
+ result.forEach(function(previousType, previousIndex) {
1051
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) newIndex = previousIndex;
1052
+ });
1053
+ result[newIndex] = currentType;
1054
+ });
1055
+ return result;
1056
+ }
1057
+ function compileMap() {
1058
+ const result = {
1059
+ scalar: {},
1060
+ sequence: {},
1061
+ mapping: {},
1062
+ fallback: {},
1063
+ multi: {
1064
+ scalar: [],
1065
+ sequence: [],
1066
+ mapping: [],
1067
+ fallback: []
1068
+ }
1069
+ };
1070
+ function collectType(type) {
1071
+ if (type.multi) {
1072
+ result.multi[type.kind].push(type);
1073
+ result.multi["fallback"].push(type);
1074
+ } else result[type.kind][type.tag] = result["fallback"][type.tag] = type;
1075
+ }
1076
+ for (let index = 0, length = arguments.length; index < length; index += 1) arguments[index].forEach(collectType);
1077
+ return result;
1078
+ }
1079
+ function Schema(definition) {
1080
+ return this.extend(definition);
1081
+ }
1082
+ Schema.prototype.extend = function extend(definition) {
1083
+ let implicit = [];
1084
+ let explicit = [];
1085
+ if (definition instanceof Type) explicit.push(definition);
1086
+ else if (Array.isArray(definition)) explicit = explicit.concat(definition);
1087
+ else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
1088
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
1089
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
1090
+ } else throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
1091
+ implicit.forEach(function(type) {
1092
+ if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
1093
+ if (type.loadKind && type.loadKind !== "scalar") throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
1094
+ if (type.multi) throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
1095
+ });
1096
+ explicit.forEach(function(type) {
1097
+ if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
1098
+ });
1099
+ const result = Object.create(Schema.prototype);
1100
+ result.implicit = (this.implicit || []).concat(implicit);
1101
+ result.explicit = (this.explicit || []).concat(explicit);
1102
+ result.compiledImplicit = compileList(result, "implicit");
1103
+ result.compiledExplicit = compileList(result, "explicit");
1104
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
1105
+ return result;
1106
+ };
1107
+ module.exports = Schema;
1108
+ }));
1109
+ var require_str = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1110
+ module.exports = new (require_type())("tag:yaml.org,2002:str", {
1111
+ kind: "scalar",
1112
+ construct: function(data) {
1113
+ return data !== null ? data : "";
1114
+ }
1115
+ });
1116
+ }));
1117
+ var require_seq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1118
+ module.exports = new (require_type())("tag:yaml.org,2002:seq", {
1119
+ kind: "sequence",
1120
+ construct: function(data) {
1121
+ return data !== null ? data : [];
1122
+ }
1123
+ });
1124
+ }));
1125
+ var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1126
+ module.exports = new (require_type())("tag:yaml.org,2002:map", {
1127
+ kind: "mapping",
1128
+ construct: function(data) {
1129
+ return data !== null ? data : {};
1130
+ }
1131
+ });
1132
+ }));
1133
+ var require_failsafe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1134
+ module.exports = new (require_schema())({ explicit: [
1135
+ require_str(),
1136
+ require_seq(),
1137
+ require_map()
1138
+ ] });
1139
+ }));
1140
+ var require_null = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1141
+ var Type = require_type();
1142
+ function resolveYamlNull(data) {
1143
+ if (data === null) return true;
1144
+ const max = data.length;
1145
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
1146
+ }
1147
+ function constructYamlNull() {
1148
+ return null;
1149
+ }
1150
+ function isNull(object) {
1151
+ return object === null;
1152
+ }
1153
+ module.exports = new Type("tag:yaml.org,2002:null", {
1154
+ kind: "scalar",
1155
+ resolve: resolveYamlNull,
1156
+ construct: constructYamlNull,
1157
+ predicate: isNull,
1158
+ represent: {
1159
+ canonical: function() {
1160
+ return "~";
1161
+ },
1162
+ lowercase: function() {
1163
+ return "null";
1164
+ },
1165
+ uppercase: function() {
1166
+ return "NULL";
1167
+ },
1168
+ camelcase: function() {
1169
+ return "Null";
1170
+ },
1171
+ empty: function() {
1172
+ return "";
1173
+ }
1174
+ },
1175
+ defaultStyle: "lowercase"
1176
+ });
1177
+ }));
1178
+ var require_bool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1179
+ var Type = require_type();
1180
+ function resolveYamlBoolean(data) {
1181
+ if (data === null) return false;
1182
+ const max = data.length;
1183
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
1184
+ }
1185
+ function constructYamlBoolean(data) {
1186
+ return data === "true" || data === "True" || data === "TRUE";
1187
+ }
1188
+ function isBoolean(object) {
1189
+ return Object.prototype.toString.call(object) === "[object Boolean]";
1190
+ }
1191
+ module.exports = new Type("tag:yaml.org,2002:bool", {
1192
+ kind: "scalar",
1193
+ resolve: resolveYamlBoolean,
1194
+ construct: constructYamlBoolean,
1195
+ predicate: isBoolean,
1196
+ represent: {
1197
+ lowercase: function(object) {
1198
+ return object ? "true" : "false";
1199
+ },
1200
+ uppercase: function(object) {
1201
+ return object ? "TRUE" : "FALSE";
1202
+ },
1203
+ camelcase: function(object) {
1204
+ return object ? "True" : "False";
1205
+ }
1206
+ },
1207
+ defaultStyle: "lowercase"
1208
+ });
1209
+ }));
1210
+ var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1211
+ var common = require_common();
1212
+ var Type = require_type();
1213
+ function isHexCode(c) {
1214
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
1215
+ }
1216
+ function isOctCode(c) {
1217
+ return c >= 48 && c <= 55;
1218
+ }
1219
+ function isDecCode(c) {
1220
+ return c >= 48 && c <= 57;
1221
+ }
1222
+ function resolveYamlInteger(data) {
1223
+ if (data === null) return false;
1224
+ const max = data.length;
1225
+ let index = 0;
1226
+ let hasDigits = false;
1227
+ if (!max) return false;
1228
+ let ch = data[index];
1229
+ if (ch === "-" || ch === "+") ch = data[++index];
1230
+ if (ch === "0") {
1231
+ if (index + 1 === max) return true;
1232
+ ch = data[++index];
1233
+ if (ch === "b") {
1234
+ index++;
1235
+ for (; index < max; index++) {
1236
+ ch = data[index];
1237
+ if (ch !== "0" && ch !== "1") return false;
1238
+ hasDigits = true;
1239
+ }
1240
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
1241
+ }
1242
+ if (ch === "x") {
1243
+ index++;
1244
+ for (; index < max; index++) {
1245
+ if (!isHexCode(data.charCodeAt(index))) return false;
1246
+ hasDigits = true;
1247
+ }
1248
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
1249
+ }
1250
+ if (ch === "o") {
1251
+ index++;
1252
+ for (; index < max; index++) {
1253
+ if (!isOctCode(data.charCodeAt(index))) return false;
1254
+ hasDigits = true;
1255
+ }
1256
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
1257
+ }
1258
+ }
1259
+ for (; index < max; index++) {
1260
+ if (!isDecCode(data.charCodeAt(index))) return false;
1261
+ hasDigits = true;
1262
+ }
1263
+ if (!hasDigits) return false;
1264
+ return Number.isFinite(parseYamlInteger(data));
1265
+ }
1266
+ function parseYamlInteger(data) {
1267
+ let value = data;
1268
+ let sign = 1;
1269
+ let ch = value[0];
1270
+ if (ch === "-" || ch === "+") {
1271
+ if (ch === "-") sign = -1;
1272
+ value = value.slice(1);
1273
+ ch = value[0];
1274
+ }
1275
+ if (value === "0") return 0;
1276
+ if (ch === "0") {
1277
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
1278
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
1279
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
1280
+ }
1281
+ return sign * parseInt(value, 10);
1282
+ }
1283
+ function constructYamlInteger(data) {
1284
+ return parseYamlInteger(data);
1285
+ }
1286
+ function isInteger(object) {
1287
+ return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
1288
+ }
1289
+ module.exports = new Type("tag:yaml.org,2002:int", {
1290
+ kind: "scalar",
1291
+ resolve: resolveYamlInteger,
1292
+ construct: constructYamlInteger,
1293
+ predicate: isInteger,
1294
+ represent: {
1295
+ binary: function(obj) {
1296
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
1297
+ },
1298
+ octal: function(obj) {
1299
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
1300
+ },
1301
+ decimal: function(obj) {
1302
+ return obj.toString(10);
1303
+ },
1304
+ hexadecimal: function(obj) {
1305
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
1306
+ }
1307
+ },
1308
+ defaultStyle: "decimal",
1309
+ styleAliases: {
1310
+ binary: [2, "bin"],
1311
+ octal: [8, "oct"],
1312
+ decimal: [10, "dec"],
1313
+ hexadecimal: [16, "hex"]
1314
+ }
1315
+ });
1316
+ }));
1317
+ var require_float = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1318
+ var common = require_common();
1319
+ var Type = require_type();
1320
+ var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
1321
+ var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
1322
+ function resolveYamlFloat(data) {
1323
+ if (data === null) return false;
1324
+ if (!YAML_FLOAT_PATTERN.test(data)) return false;
1325
+ if (Number.isFinite(parseFloat(data, 10))) return true;
1326
+ return YAML_FLOAT_SPECIAL_PATTERN.test(data);
1327
+ }
1328
+ function constructYamlFloat(data) {
1329
+ let value = data.toLowerCase();
1330
+ const sign = value[0] === "-" ? -1 : 1;
1331
+ if ("+-".indexOf(value[0]) >= 0) value = value.slice(1);
1332
+ if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
1333
+ else if (value === ".nan") return NaN;
1334
+ return sign * parseFloat(value, 10);
1335
+ }
1336
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
1337
+ function representYamlFloat(object, style) {
1338
+ if (isNaN(object)) switch (style) {
1339
+ case "lowercase": return ".nan";
1340
+ case "uppercase": return ".NAN";
1341
+ case "camelcase": return ".NaN";
1342
+ }
1343
+ else if (Number.POSITIVE_INFINITY === object) switch (style) {
1344
+ case "lowercase": return ".inf";
1345
+ case "uppercase": return ".INF";
1346
+ case "camelcase": return ".Inf";
1347
+ }
1348
+ else if (Number.NEGATIVE_INFINITY === object) switch (style) {
1349
+ case "lowercase": return "-.inf";
1350
+ case "uppercase": return "-.INF";
1351
+ case "camelcase": return "-.Inf";
1352
+ }
1353
+ else if (common.isNegativeZero(object)) return "-0.0";
1354
+ const res = object.toString(10);
1355
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
1356
+ }
1357
+ function isFloat(object) {
1358
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
1359
+ }
1360
+ module.exports = new Type("tag:yaml.org,2002:float", {
1361
+ kind: "scalar",
1362
+ resolve: resolveYamlFloat,
1363
+ construct: constructYamlFloat,
1364
+ predicate: isFloat,
1365
+ represent: representYamlFloat,
1366
+ defaultStyle: "lowercase"
1367
+ });
1368
+ }));
1369
+ var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1370
+ module.exports = require_failsafe().extend({ implicit: [
1371
+ require_null(),
1372
+ require_bool(),
1373
+ require_int(),
1374
+ require_float()
1375
+ ] });
1376
+ }));
1377
+ var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1378
+ module.exports = require_json();
1379
+ }));
1380
+ var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1381
+ var Type = require_type();
1382
+ var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
1383
+ 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]))?))?$");
1384
+ function resolveYamlTimestamp(data) {
1385
+ if (data === null) return false;
1386
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
1387
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
1388
+ return false;
1389
+ }
1390
+ function constructYamlTimestamp(data) {
1391
+ let fraction = 0;
1392
+ let delta = null;
1393
+ let match = YAML_DATE_REGEXP.exec(data);
1394
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
1395
+ if (match === null) throw new Error("Date resolve error");
1396
+ const year = +match[1];
1397
+ const month = +match[2] - 1;
1398
+ const day = +match[3];
1399
+ if (!match[4]) return new Date(Date.UTC(year, month, day));
1400
+ const hour = +match[4];
1401
+ const minute = +match[5];
1402
+ const second = +match[6];
1403
+ if (match[7]) {
1404
+ fraction = match[7].slice(0, 3);
1405
+ while (fraction.length < 3) fraction += "0";
1406
+ fraction = +fraction;
1407
+ }
1408
+ if (match[9]) {
1409
+ const tzHour = +match[10];
1410
+ const tzMinute = +(match[11] || 0);
1411
+ delta = (tzHour * 60 + tzMinute) * 6e4;
1412
+ if (match[9] === "-") delta = -delta;
1413
+ }
1414
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1415
+ if (delta) date.setTime(date.getTime() - delta);
1416
+ return date;
1417
+ }
1418
+ function representYamlTimestamp(object) {
1419
+ return object.toISOString();
1420
+ }
1421
+ module.exports = new Type("tag:yaml.org,2002:timestamp", {
1422
+ kind: "scalar",
1423
+ resolve: resolveYamlTimestamp,
1424
+ construct: constructYamlTimestamp,
1425
+ instanceOf: Date,
1426
+ represent: representYamlTimestamp
1427
+ });
1428
+ }));
1429
+ var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1430
+ var Type = require_type();
1431
+ function resolveYamlMerge(data) {
1432
+ return data === "<<" || data === null;
1433
+ }
1434
+ module.exports = new Type("tag:yaml.org,2002:merge", {
1435
+ kind: "scalar",
1436
+ resolve: resolveYamlMerge
1437
+ });
1438
+ }));
1439
+ var require_binary = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1440
+ var Type = require_type();
1441
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
1442
+ function resolveYamlBinary(data) {
1443
+ if (data === null) return false;
1444
+ let bitlen = 0;
1445
+ const max = data.length;
1446
+ const map = BASE64_MAP;
1447
+ for (let idx = 0; idx < max; idx++) {
1448
+ const code = map.indexOf(data.charAt(idx));
1449
+ if (code > 64) continue;
1450
+ if (code < 0) return false;
1451
+ bitlen += 6;
1452
+ }
1453
+ return bitlen % 8 === 0;
1454
+ }
1455
+ function constructYamlBinary(data) {
1456
+ const input = data.replace(/[\r\n=]/g, "");
1457
+ const max = input.length;
1458
+ const map = BASE64_MAP;
1459
+ let bits = 0;
1460
+ const result = [];
1461
+ for (let idx = 0; idx < max; idx++) {
1462
+ if (idx % 4 === 0 && idx) {
1463
+ result.push(bits >> 16 & 255);
1464
+ result.push(bits >> 8 & 255);
1465
+ result.push(bits & 255);
1466
+ }
1467
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
1468
+ }
1469
+ const tailbits = max % 4 * 6;
1470
+ if (tailbits === 0) {
1471
+ result.push(bits >> 16 & 255);
1472
+ result.push(bits >> 8 & 255);
1473
+ result.push(bits & 255);
1474
+ } else if (tailbits === 18) {
1475
+ result.push(bits >> 10 & 255);
1476
+ result.push(bits >> 2 & 255);
1477
+ } else if (tailbits === 12) result.push(bits >> 4 & 255);
1478
+ return new Uint8Array(result);
1479
+ }
1480
+ function representYamlBinary(object) {
1481
+ let result = "";
1482
+ let bits = 0;
1483
+ const max = object.length;
1484
+ const map = BASE64_MAP;
1485
+ for (let idx = 0; idx < max; idx++) {
1486
+ if (idx % 3 === 0 && idx) {
1487
+ result += map[bits >> 18 & 63];
1488
+ result += map[bits >> 12 & 63];
1489
+ result += map[bits >> 6 & 63];
1490
+ result += map[bits & 63];
1491
+ }
1492
+ bits = (bits << 8) + object[idx];
1493
+ }
1494
+ const tail = max % 3;
1495
+ if (tail === 0) {
1496
+ result += map[bits >> 18 & 63];
1497
+ result += map[bits >> 12 & 63];
1498
+ result += map[bits >> 6 & 63];
1499
+ result += map[bits & 63];
1500
+ } else if (tail === 2) {
1501
+ result += map[bits >> 10 & 63];
1502
+ result += map[bits >> 4 & 63];
1503
+ result += map[bits << 2 & 63];
1504
+ result += map[64];
1505
+ } else if (tail === 1) {
1506
+ result += map[bits >> 2 & 63];
1507
+ result += map[bits << 4 & 63];
1508
+ result += map[64];
1509
+ result += map[64];
1510
+ }
1511
+ return result;
1512
+ }
1513
+ function isBinary(obj) {
1514
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
1515
+ }
1516
+ module.exports = new Type("tag:yaml.org,2002:binary", {
1517
+ kind: "scalar",
1518
+ resolve: resolveYamlBinary,
1519
+ construct: constructYamlBinary,
1520
+ predicate: isBinary,
1521
+ represent: representYamlBinary
1522
+ });
1523
+ }));
1524
+ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1525
+ var Type = require_type();
1526
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1527
+ var _toString = Object.prototype.toString;
1528
+ function resolveYamlOmap(data) {
1529
+ if (data === null) return true;
1530
+ const objectKeys = [];
1531
+ const object = data;
1532
+ for (let index = 0, length = object.length; index < length; index += 1) {
1533
+ const pair = object[index];
1534
+ let pairHasKey = false;
1535
+ if (_toString.call(pair) !== "[object Object]") return false;
1536
+ let pairKey;
1537
+ for (pairKey in pair) if (_hasOwnProperty.call(pair, pairKey)) if (!pairHasKey) pairHasKey = true;
1538
+ else return false;
1539
+ if (!pairHasKey) return false;
1540
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
1541
+ else return false;
1542
+ }
1543
+ return true;
1544
+ }
1545
+ function constructYamlOmap(data) {
1546
+ return data !== null ? data : [];
1547
+ }
1548
+ module.exports = new Type("tag:yaml.org,2002:omap", {
1549
+ kind: "sequence",
1550
+ resolve: resolveYamlOmap,
1551
+ construct: constructYamlOmap
1552
+ });
1553
+ }));
1554
+ var require_pairs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1555
+ var Type = require_type();
1556
+ var _toString = Object.prototype.toString;
1557
+ function resolveYamlPairs(data) {
1558
+ if (data === null) return true;
1559
+ const object = data;
1560
+ const result = new Array(object.length);
1561
+ for (let index = 0, length = object.length; index < length; index += 1) {
1562
+ const pair = object[index];
1563
+ if (_toString.call(pair) !== "[object Object]") return false;
1564
+ const keys = Object.keys(pair);
1565
+ if (keys.length !== 1) return false;
1566
+ result[index] = [keys[0], pair[keys[0]]];
1567
+ }
1568
+ return true;
1569
+ }
1570
+ function constructYamlPairs(data) {
1571
+ if (data === null) return [];
1572
+ const object = data;
1573
+ const result = new Array(object.length);
1574
+ for (let index = 0, length = object.length; index < length; index += 1) {
1575
+ const pair = object[index];
1576
+ const keys = Object.keys(pair);
1577
+ result[index] = [keys[0], pair[keys[0]]];
1578
+ }
1579
+ return result;
1580
+ }
1581
+ module.exports = new Type("tag:yaml.org,2002:pairs", {
1582
+ kind: "sequence",
1583
+ resolve: resolveYamlPairs,
1584
+ construct: constructYamlPairs
1585
+ });
1586
+ }));
1587
+ var require_set = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1588
+ var Type = require_type();
1589
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1590
+ function resolveYamlSet(data) {
1591
+ if (data === null) return true;
1592
+ const object = data;
1593
+ for (const key in object) if (_hasOwnProperty.call(object, key)) {
1594
+ if (object[key] !== null) return false;
1595
+ }
1596
+ return true;
1597
+ }
1598
+ function constructYamlSet(data) {
1599
+ return data !== null ? data : {};
1600
+ }
1601
+ module.exports = new Type("tag:yaml.org,2002:set", {
1602
+ kind: "mapping",
1603
+ resolve: resolveYamlSet,
1604
+ construct: constructYamlSet
1605
+ });
1606
+ }));
1607
+ var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1608
+ module.exports = require_core().extend({
1609
+ implicit: [require_timestamp(), require_merge()],
1610
+ explicit: [
1611
+ require_binary(),
1612
+ require_omap(),
1613
+ require_pairs(),
1614
+ require_set()
1615
+ ]
1616
+ });
1617
+ }));
1618
+ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1619
+ var common = require_common();
1620
+ var YAMLException = require_exception();
1621
+ var makeSnippet = require_snippet();
1622
+ var DEFAULT_SCHEMA = require_default();
1623
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1624
+ var CONTEXT_FLOW_IN = 1;
1625
+ var CONTEXT_FLOW_OUT = 2;
1626
+ var CONTEXT_BLOCK_IN = 3;
1627
+ var CONTEXT_BLOCK_OUT = 4;
1628
+ var CHOMPING_CLIP = 1;
1629
+ var CHOMPING_STRIP = 2;
1630
+ var CHOMPING_KEEP = 3;
1631
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1632
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1633
+ var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
1634
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
1635
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
1636
+ function _class(obj) {
1637
+ return Object.prototype.toString.call(obj);
1638
+ }
1639
+ function isEol(c) {
1640
+ return c === 10 || c === 13;
1641
+ }
1642
+ function isWhiteSpace(c) {
1643
+ return c === 9 || c === 32;
1644
+ }
1645
+ function isWsOrEol(c) {
1646
+ return c === 9 || c === 32 || c === 10 || c === 13;
1647
+ }
1648
+ function isFlowIndicator(c) {
1649
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1650
+ }
1651
+ function fromHexCode(c) {
1652
+ if (c >= 48 && c <= 57) return c - 48;
1653
+ const lc = c | 32;
1654
+ if (lc >= 97 && lc <= 102) return lc - 97 + 10;
1655
+ return -1;
1656
+ }
1657
+ function escapedHexLen(c) {
1658
+ if (c === 120) return 2;
1659
+ if (c === 117) return 4;
1660
+ if (c === 85) return 8;
1661
+ return 0;
1662
+ }
1663
+ function fromDecimalCode(c) {
1664
+ if (c >= 48 && c <= 57) return c - 48;
1665
+ return -1;
1666
+ }
1667
+ function simpleEscapeSequence(c) {
1668
+ switch (c) {
1669
+ case 48: return "\0";
1670
+ case 97: return "\x07";
1671
+ case 98: return "\b";
1672
+ case 116: return " ";
1673
+ case 9: return " ";
1674
+ case 110: return "\n";
1675
+ case 118: return "\v";
1676
+ case 102: return "\f";
1677
+ case 114: return "\r";
1678
+ case 101: return "\x1B";
1679
+ case 32: return " ";
1680
+ case 34: return "\"";
1681
+ case 47: return "/";
1682
+ case 92: return "\\";
1683
+ case 78: return "…";
1684
+ case 95: return "\xA0";
1685
+ case 76: return "\u2028";
1686
+ case 80: return "\u2029";
1687
+ default: return "";
1688
+ }
1689
+ }
1690
+ function charFromCodepoint(c) {
1691
+ if (c <= 65535) return String.fromCharCode(c);
1692
+ return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
1693
+ }
1694
+ function setProperty(object, key, value) {
1695
+ if (key === "__proto__") Object.defineProperty(object, key, {
1696
+ configurable: true,
1697
+ enumerable: true,
1698
+ writable: true,
1699
+ value
1700
+ });
1701
+ else object[key] = value;
1702
+ }
1703
+ var simpleEscapeCheck = new Array(256);
1704
+ var simpleEscapeMap = new Array(256);
1705
+ for (let i = 0; i < 256; i++) {
1706
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1707
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1708
+ }
1709
+ function State(input, options) {
1710
+ this.input = input;
1711
+ this.filename = options["filename"] || null;
1712
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
1713
+ this.onWarning = options["onWarning"] || null;
1714
+ this.legacy = options["legacy"] || false;
1715
+ this.json = options["json"] || false;
1716
+ this.listener = options["listener"] || null;
1717
+ this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
1718
+ this.maxMergeSeqLength = typeof options["maxMergeSeqLength"] === "number" ? options["maxMergeSeqLength"] : 20;
1719
+ this.implicitTypes = this.schema.compiledImplicit;
1720
+ this.typeMap = this.schema.compiledTypeMap;
1721
+ this.length = input.length;
1722
+ this.position = 0;
1723
+ this.line = 0;
1724
+ this.lineStart = 0;
1725
+ this.lineIndent = 0;
1726
+ this.depth = 0;
1727
+ this.firstTabInLine = -1;
1728
+ this.documents = [];
1729
+ this.anchorMapTransactions = [];
1730
+ }
1731
+ function generateError(state, message) {
1732
+ const mark = {
1733
+ name: state.filename,
1734
+ buffer: state.input.slice(0, -1),
1735
+ position: state.position,
1736
+ line: state.line,
1737
+ column: state.position - state.lineStart
1738
+ };
1739
+ mark.snippet = makeSnippet(mark);
1740
+ return new YAMLException(message, mark);
1741
+ }
1742
+ function throwError(state, message) {
1743
+ throw generateError(state, message);
1744
+ }
1745
+ function throwWarning(state, message) {
1746
+ if (state.onWarning) state.onWarning.call(null, generateError(state, message));
1747
+ }
1748
+ function storeAnchor(state, name, value) {
1749
+ const transactions = state.anchorMapTransactions;
1750
+ if (transactions.length !== 0) {
1751
+ const transaction = transactions[transactions.length - 1];
1752
+ if (!_hasOwnProperty.call(transaction, name)) transaction[name] = {
1753
+ existed: _hasOwnProperty.call(state.anchorMap, name),
1754
+ value: state.anchorMap[name]
1755
+ };
1756
+ }
1757
+ state.anchorMap[name] = value;
1758
+ }
1759
+ function beginAnchorTransaction(state) {
1760
+ state.anchorMapTransactions.push(Object.create(null));
1761
+ }
1762
+ function commitAnchorTransaction(state) {
1763
+ const transaction = state.anchorMapTransactions.pop();
1764
+ const transactions = state.anchorMapTransactions;
1765
+ if (transactions.length === 0) return;
1766
+ const parent = transactions[transactions.length - 1];
1767
+ const names = Object.keys(transaction);
1768
+ for (let index = 0, length = names.length; index < length; index += 1) {
1769
+ const name = names[index];
1770
+ if (!_hasOwnProperty.call(parent, name)) parent[name] = transaction[name];
1771
+ }
1772
+ }
1773
+ function rollbackAnchorTransaction(state) {
1774
+ const transaction = state.anchorMapTransactions.pop();
1775
+ const names = Object.keys(transaction);
1776
+ for (let index = names.length - 1; index >= 0; index -= 1) {
1777
+ const entry = transaction[names[index]];
1778
+ if (entry.existed) state.anchorMap[names[index]] = entry.value;
1779
+ else delete state.anchorMap[names[index]];
1780
+ }
1781
+ }
1782
+ function snapshotState(state) {
1783
+ return {
1784
+ position: state.position,
1785
+ line: state.line,
1786
+ lineStart: state.lineStart,
1787
+ lineIndent: state.lineIndent,
1788
+ firstTabInLine: state.firstTabInLine,
1789
+ tag: state.tag,
1790
+ anchor: state.anchor,
1791
+ kind: state.kind,
1792
+ result: state.result
1793
+ };
1794
+ }
1795
+ function restoreState(state, snapshot) {
1796
+ state.position = snapshot.position;
1797
+ state.line = snapshot.line;
1798
+ state.lineStart = snapshot.lineStart;
1799
+ state.lineIndent = snapshot.lineIndent;
1800
+ state.firstTabInLine = snapshot.firstTabInLine;
1801
+ state.tag = snapshot.tag;
1802
+ state.anchor = snapshot.anchor;
1803
+ state.kind = snapshot.kind;
1804
+ state.result = snapshot.result;
1805
+ }
1806
+ var directiveHandlers = {
1807
+ YAML: function handleYamlDirective(state, name, args) {
1808
+ if (state.version !== null) throwError(state, "duplication of %YAML directive");
1809
+ if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
1810
+ const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1811
+ if (match === null) throwError(state, "ill-formed argument of the YAML directive");
1812
+ const major = parseInt(match[1], 10);
1813
+ const minor = parseInt(match[2], 10);
1814
+ if (major !== 1) throwError(state, "unacceptable YAML version of the document");
1815
+ state.version = args[0];
1816
+ state.checkLineBreaks = minor < 2;
1817
+ if (minor !== 1 && minor !== 2) throwWarning(state, "unsupported YAML version of the document");
1818
+ },
1819
+ TAG: function handleTagDirective(state, name, args) {
1820
+ let prefix;
1821
+ if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
1822
+ const handle = args[0];
1823
+ prefix = args[1];
1824
+ if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1825
+ if (_hasOwnProperty.call(state.tagMap, handle)) throwError(state, "there is a previously declared suffix for \"" + handle + "\" tag handle");
1826
+ if (!PATTERN_TAG_URI.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1827
+ try {
1828
+ prefix = decodeURIComponent(prefix);
1829
+ } catch (err) {
1830
+ throwError(state, "tag prefix is malformed: " + prefix);
1831
+ }
1832
+ state.tagMap[handle] = prefix;
1833
+ }
1834
+ };
1835
+ function captureSegment(state, start, end, checkJson) {
1836
+ if (start < end) {
1837
+ const _result = state.input.slice(start, end);
1838
+ if (checkJson) for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
1839
+ const _character = _result.charCodeAt(_position);
1840
+ if (!(_character === 9 || _character >= 32 && _character <= 1114111)) throwError(state, "expected valid JSON character");
1841
+ }
1842
+ else if (PATTERN_NON_PRINTABLE.test(_result)) throwError(state, "the stream contains non-printable characters");
1843
+ state.result += _result;
1844
+ }
1845
+ }
1846
+ function mergeMappings(state, destination, source, overridableKeys) {
1847
+ if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1848
+ const sourceKeys = Object.keys(source);
1849
+ for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1850
+ const key = sourceKeys[index];
1851
+ if (!_hasOwnProperty.call(destination, key)) {
1852
+ setProperty(destination, key, source[key]);
1853
+ overridableKeys[key] = true;
1854
+ }
1855
+ }
1856
+ }
1857
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1858
+ if (Array.isArray(keyNode)) {
1859
+ keyNode = Array.prototype.slice.call(keyNode);
1860
+ for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1861
+ if (Array.isArray(keyNode[index])) throwError(state, "nested arrays are not supported inside keys");
1862
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") keyNode[index] = "[object Object]";
1863
+ }
1864
+ }
1865
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") keyNode = "[object Object]";
1866
+ keyNode = String(keyNode);
1867
+ if (_result === null) _result = {};
1868
+ if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) {
1869
+ if (valueNode.length > state.maxMergeSeqLength) throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
1870
+ const seen = /* @__PURE__ */ new Set();
1871
+ for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1872
+ const src = valueNode[index];
1873
+ if (seen.has(src)) continue;
1874
+ seen.add(src);
1875
+ mergeMappings(state, _result, src, overridableKeys);
1876
+ }
1877
+ } else mergeMappings(state, _result, valueNode, overridableKeys);
1878
+ else {
1879
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
1880
+ state.line = startLine || state.line;
1881
+ state.lineStart = startLineStart || state.lineStart;
1882
+ state.position = startPos || state.position;
1883
+ throwError(state, "duplicated mapping key");
1884
+ }
1885
+ setProperty(_result, keyNode, valueNode);
1886
+ delete overridableKeys[keyNode];
1887
+ }
1888
+ return _result;
1889
+ }
1890
+ function readLineBreak(state) {
1891
+ const ch = state.input.charCodeAt(state.position);
1892
+ if (ch === 10) state.position++;
1893
+ else if (ch === 13) {
1894
+ state.position++;
1895
+ if (state.input.charCodeAt(state.position) === 10) state.position++;
1896
+ } else throwError(state, "a line break is expected");
1897
+ state.line += 1;
1898
+ state.lineStart = state.position;
1899
+ state.firstTabInLine = -1;
1900
+ }
1901
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1902
+ let lineBreaks = 0;
1903
+ let ch = state.input.charCodeAt(state.position);
1904
+ while (ch !== 0) {
1905
+ while (isWhiteSpace(ch)) {
1906
+ if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
1907
+ ch = state.input.charCodeAt(++state.position);
1908
+ }
1909
+ if (allowComments && ch === 35) do
1910
+ ch = state.input.charCodeAt(++state.position);
1911
+ while (ch !== 10 && ch !== 13 && ch !== 0);
1912
+ if (isEol(ch)) {
1913
+ readLineBreak(state);
1914
+ ch = state.input.charCodeAt(state.position);
1915
+ lineBreaks++;
1916
+ state.lineIndent = 0;
1917
+ while (ch === 32) {
1918
+ state.lineIndent++;
1919
+ ch = state.input.charCodeAt(++state.position);
1920
+ }
1921
+ } else break;
1922
+ }
1923
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) throwWarning(state, "deficient indentation");
1924
+ return lineBreaks;
1925
+ }
1926
+ function testDocumentSeparator(state) {
1927
+ let _position = state.position;
1928
+ let ch = state.input.charCodeAt(_position);
1929
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1930
+ _position += 3;
1931
+ ch = state.input.charCodeAt(_position);
1932
+ if (ch === 0 || isWsOrEol(ch)) return true;
1933
+ }
1934
+ return false;
1935
+ }
1936
+ function writeFoldedLines(state, count) {
1937
+ if (count === 1) state.result += " ";
1938
+ else if (count > 1) state.result += common.repeat("\n", count - 1);
1939
+ }
1940
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1941
+ let captureStart;
1942
+ let captureEnd;
1943
+ let hasPendingContent;
1944
+ let _line;
1945
+ let _lineStart;
1946
+ let _lineIndent;
1947
+ const _kind = state.kind;
1948
+ const _result = state.result;
1949
+ let ch = state.input.charCodeAt(state.position);
1950
+ if (isWsOrEol(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) return false;
1951
+ if (ch === 63 || ch === 45) {
1952
+ const following = state.input.charCodeAt(state.position + 1);
1953
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) return false;
1954
+ }
1955
+ state.kind = "scalar";
1956
+ state.result = "";
1957
+ captureStart = captureEnd = state.position;
1958
+ hasPendingContent = false;
1959
+ while (ch !== 0) {
1960
+ if (ch === 58) {
1961
+ const following = state.input.charCodeAt(state.position + 1);
1962
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) break;
1963
+ } else if (ch === 35) {
1964
+ if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
1965
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) break;
1966
+ else if (isEol(ch)) {
1967
+ _line = state.line;
1968
+ _lineStart = state.lineStart;
1969
+ _lineIndent = state.lineIndent;
1970
+ skipSeparationSpace(state, false, -1);
1971
+ if (state.lineIndent >= nodeIndent) {
1972
+ hasPendingContent = true;
1973
+ ch = state.input.charCodeAt(state.position);
1974
+ continue;
1975
+ } else {
1976
+ state.position = captureEnd;
1977
+ state.line = _line;
1978
+ state.lineStart = _lineStart;
1979
+ state.lineIndent = _lineIndent;
1980
+ break;
1981
+ }
1982
+ }
1983
+ if (hasPendingContent) {
1984
+ captureSegment(state, captureStart, captureEnd, false);
1985
+ writeFoldedLines(state, state.line - _line);
1986
+ captureStart = captureEnd = state.position;
1987
+ hasPendingContent = false;
1988
+ }
1989
+ if (!isWhiteSpace(ch)) captureEnd = state.position + 1;
1990
+ ch = state.input.charCodeAt(++state.position);
1991
+ }
1992
+ captureSegment(state, captureStart, captureEnd, false);
1993
+ if (state.result) return true;
1994
+ state.kind = _kind;
1995
+ state.result = _result;
1996
+ return false;
1997
+ }
1998
+ function readSingleQuotedScalar(state, nodeIndent) {
1999
+ let captureStart;
2000
+ let captureEnd;
2001
+ let ch = state.input.charCodeAt(state.position);
2002
+ if (ch !== 39) return false;
2003
+ state.kind = "scalar";
2004
+ state.result = "";
2005
+ state.position++;
2006
+ captureStart = captureEnd = state.position;
2007
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 39) {
2008
+ captureSegment(state, captureStart, state.position, true);
2009
+ ch = state.input.charCodeAt(++state.position);
2010
+ if (ch === 39) {
2011
+ captureStart = state.position;
2012
+ state.position++;
2013
+ captureEnd = state.position;
2014
+ } else return true;
2015
+ } else if (isEol(ch)) {
2016
+ captureSegment(state, captureStart, captureEnd, true);
2017
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
2018
+ captureStart = captureEnd = state.position;
2019
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
2020
+ else {
2021
+ state.position++;
2022
+ if (!isWhiteSpace(ch)) captureEnd = state.position;
2023
+ }
2024
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
2025
+ }
2026
+ function readDoubleQuotedScalar(state, nodeIndent) {
2027
+ let captureStart;
2028
+ let captureEnd;
2029
+ let tmp;
2030
+ let ch = state.input.charCodeAt(state.position);
2031
+ if (ch !== 34) return false;
2032
+ state.kind = "scalar";
2033
+ state.result = "";
2034
+ state.position++;
2035
+ captureStart = captureEnd = state.position;
2036
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 34) {
2037
+ captureSegment(state, captureStart, state.position, true);
2038
+ state.position++;
2039
+ return true;
2040
+ } else if (ch === 92) {
2041
+ captureSegment(state, captureStart, state.position, true);
2042
+ ch = state.input.charCodeAt(++state.position);
2043
+ if (isEol(ch)) skipSeparationSpace(state, false, nodeIndent);
2044
+ else if (ch < 256 && simpleEscapeCheck[ch]) {
2045
+ state.result += simpleEscapeMap[ch];
2046
+ state.position++;
2047
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
2048
+ let hexLength = tmp;
2049
+ let hexResult = 0;
2050
+ for (; hexLength > 0; hexLength--) {
2051
+ ch = state.input.charCodeAt(++state.position);
2052
+ if ((tmp = fromHexCode(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
2053
+ else throwError(state, "expected hexadecimal character");
2054
+ }
2055
+ state.result += charFromCodepoint(hexResult);
2056
+ state.position++;
2057
+ } else throwError(state, "unknown escape sequence");
2058
+ captureStart = captureEnd = state.position;
2059
+ } else if (isEol(ch)) {
2060
+ captureSegment(state, captureStart, captureEnd, true);
2061
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
2062
+ captureStart = captureEnd = state.position;
2063
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
2064
+ else {
2065
+ state.position++;
2066
+ if (!isWhiteSpace(ch)) captureEnd = state.position;
2067
+ }
2068
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
2069
+ }
2070
+ function readFlowCollection(state, nodeIndent) {
2071
+ let readNext = true;
2072
+ let _line;
2073
+ let _lineStart;
2074
+ let _pos;
2075
+ const _tag = state.tag;
2076
+ let _result;
2077
+ const _anchor = state.anchor;
2078
+ let terminator;
2079
+ let isPair;
2080
+ let isExplicitPair;
2081
+ let isMapping;
2082
+ const overridableKeys = Object.create(null);
2083
+ let keyNode;
2084
+ let keyTag;
2085
+ let valueNode;
2086
+ let ch = state.input.charCodeAt(state.position);
2087
+ if (ch === 91) {
2088
+ terminator = 93;
2089
+ isMapping = false;
2090
+ _result = [];
2091
+ } else if (ch === 123) {
2092
+ terminator = 125;
2093
+ isMapping = true;
2094
+ _result = {};
2095
+ } else return false;
2096
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
2097
+ ch = state.input.charCodeAt(++state.position);
2098
+ while (ch !== 0) {
2099
+ skipSeparationSpace(state, true, nodeIndent);
2100
+ ch = state.input.charCodeAt(state.position);
2101
+ if (ch === terminator) {
2102
+ state.position++;
2103
+ state.tag = _tag;
2104
+ state.anchor = _anchor;
2105
+ state.kind = isMapping ? "mapping" : "sequence";
2106
+ state.result = _result;
2107
+ return true;
2108
+ } else if (!readNext) throwError(state, "missed comma between flow collection entries");
2109
+ else if (ch === 44) throwError(state, "expected the node content, but found ','");
2110
+ keyTag = keyNode = valueNode = null;
2111
+ isPair = isExplicitPair = false;
2112
+ if (ch === 63) {
2113
+ if (isWsOrEol(state.input.charCodeAt(state.position + 1))) {
2114
+ isPair = isExplicitPair = true;
2115
+ state.position++;
2116
+ skipSeparationSpace(state, true, nodeIndent);
2117
+ }
2118
+ }
2119
+ _line = state.line;
2120
+ _lineStart = state.lineStart;
2121
+ _pos = state.position;
2122
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2123
+ keyTag = state.tag;
2124
+ keyNode = state.result;
2125
+ skipSeparationSpace(state, true, nodeIndent);
2126
+ ch = state.input.charCodeAt(state.position);
2127
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
2128
+ isPair = true;
2129
+ ch = state.input.charCodeAt(++state.position);
2130
+ skipSeparationSpace(state, true, nodeIndent);
2131
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2132
+ valueNode = state.result;
2133
+ }
2134
+ if (isMapping) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
2135
+ else if (isPair) _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
2136
+ else _result.push(keyNode);
2137
+ skipSeparationSpace(state, true, nodeIndent);
2138
+ ch = state.input.charCodeAt(state.position);
2139
+ if (ch === 44) {
2140
+ readNext = true;
2141
+ ch = state.input.charCodeAt(++state.position);
2142
+ } else readNext = false;
2143
+ }
2144
+ throwError(state, "unexpected end of the stream within a flow collection");
2145
+ }
2146
+ function readBlockScalar(state, nodeIndent) {
2147
+ let folding;
2148
+ let chomping = CHOMPING_CLIP;
2149
+ let didReadContent = false;
2150
+ let detectedIndent = false;
2151
+ let textIndent = nodeIndent;
2152
+ let emptyLines = 0;
2153
+ let atMoreIndented = false;
2154
+ let tmp;
2155
+ let ch = state.input.charCodeAt(state.position);
2156
+ if (ch === 124) folding = false;
2157
+ else if (ch === 62) folding = true;
2158
+ else return false;
2159
+ state.kind = "scalar";
2160
+ state.result = "";
2161
+ while (ch !== 0) {
2162
+ ch = state.input.charCodeAt(++state.position);
2163
+ if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
2164
+ else throwError(state, "repeat of a chomping mode identifier");
2165
+ else if ((tmp = fromDecimalCode(ch)) >= 0) if (tmp === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
2166
+ else if (!detectedIndent) {
2167
+ textIndent = nodeIndent + tmp - 1;
2168
+ detectedIndent = true;
2169
+ } else throwError(state, "repeat of an indentation width identifier");
2170
+ else break;
2171
+ }
2172
+ if (isWhiteSpace(ch)) {
2173
+ do
2174
+ ch = state.input.charCodeAt(++state.position);
2175
+ while (isWhiteSpace(ch));
2176
+ if (ch === 35) do
2177
+ ch = state.input.charCodeAt(++state.position);
2178
+ while (!isEol(ch) && ch !== 0);
2179
+ }
2180
+ while (ch !== 0) {
2181
+ readLineBreak(state);
2182
+ state.lineIndent = 0;
2183
+ ch = state.input.charCodeAt(state.position);
2184
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
2185
+ state.lineIndent++;
2186
+ ch = state.input.charCodeAt(++state.position);
2187
+ }
2188
+ if (!detectedIndent && state.lineIndent > textIndent) textIndent = state.lineIndent;
2189
+ if (isEol(ch)) {
2190
+ emptyLines++;
2191
+ continue;
2192
+ }
2193
+ if (!detectedIndent && textIndent === 0) throwError(state, "missing indentation for block scalar");
2194
+ if (state.lineIndent < textIndent) {
2195
+ if (chomping === CHOMPING_KEEP) state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2196
+ else if (chomping === CHOMPING_CLIP) {
2197
+ if (didReadContent) state.result += "\n";
2198
+ }
2199
+ break;
2200
+ }
2201
+ if (folding) if (isWhiteSpace(ch)) {
2202
+ atMoreIndented = true;
2203
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2204
+ } else if (atMoreIndented) {
2205
+ atMoreIndented = false;
2206
+ state.result += common.repeat("\n", emptyLines + 1);
2207
+ } else if (emptyLines === 0) {
2208
+ if (didReadContent) state.result += " ";
2209
+ } else state.result += common.repeat("\n", emptyLines);
2210
+ else state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2211
+ didReadContent = true;
2212
+ detectedIndent = true;
2213
+ emptyLines = 0;
2214
+ const captureStart = state.position;
2215
+ while (!isEol(ch) && ch !== 0) ch = state.input.charCodeAt(++state.position);
2216
+ captureSegment(state, captureStart, state.position, false);
2217
+ }
2218
+ return true;
2219
+ }
2220
+ function readBlockSequence(state, nodeIndent) {
2221
+ const _tag = state.tag;
2222
+ const _anchor = state.anchor;
2223
+ const _result = [];
2224
+ let detected = false;
2225
+ if (state.firstTabInLine !== -1) return false;
2226
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
2227
+ let ch = state.input.charCodeAt(state.position);
2228
+ while (ch !== 0) {
2229
+ if (state.firstTabInLine !== -1) {
2230
+ state.position = state.firstTabInLine;
2231
+ throwError(state, "tab characters must not be used in indentation");
2232
+ }
2233
+ if (ch !== 45) break;
2234
+ if (!isWsOrEol(state.input.charCodeAt(state.position + 1))) break;
2235
+ detected = true;
2236
+ state.position++;
2237
+ if (skipSeparationSpace(state, true, -1)) {
2238
+ if (state.lineIndent <= nodeIndent) {
2239
+ _result.push(null);
2240
+ ch = state.input.charCodeAt(state.position);
2241
+ continue;
2242
+ }
2243
+ }
2244
+ const _line = state.line;
2245
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
2246
+ _result.push(state.result);
2247
+ skipSeparationSpace(state, true, -1);
2248
+ ch = state.input.charCodeAt(state.position);
2249
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a sequence entry");
2250
+ else if (state.lineIndent < nodeIndent) break;
2251
+ }
2252
+ if (detected) {
2253
+ state.tag = _tag;
2254
+ state.anchor = _anchor;
2255
+ state.kind = "sequence";
2256
+ state.result = _result;
2257
+ return true;
2258
+ }
2259
+ return false;
2260
+ }
2261
+ function readBlockMapping(state, nodeIndent, flowIndent) {
2262
+ let allowCompact;
2263
+ let _keyLine;
2264
+ let _keyLineStart;
2265
+ let _keyPos;
2266
+ const _tag = state.tag;
2267
+ const _anchor = state.anchor;
2268
+ const _result = {};
2269
+ const overridableKeys = Object.create(null);
2270
+ let keyTag = null;
2271
+ let keyNode = null;
2272
+ let valueNode = null;
2273
+ let atExplicitKey = false;
2274
+ let detected = false;
2275
+ if (state.firstTabInLine !== -1) return false;
2276
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
2277
+ let ch = state.input.charCodeAt(state.position);
2278
+ while (ch !== 0) {
2279
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
2280
+ state.position = state.firstTabInLine;
2281
+ throwError(state, "tab characters must not be used in indentation");
2282
+ }
2283
+ const following = state.input.charCodeAt(state.position + 1);
2284
+ const _line = state.line;
2285
+ if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
2286
+ if (ch === 63) {
2287
+ if (atExplicitKey) {
2288
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2289
+ keyTag = keyNode = valueNode = null;
2290
+ }
2291
+ detected = true;
2292
+ atExplicitKey = true;
2293
+ allowCompact = true;
2294
+ } else if (atExplicitKey) {
2295
+ atExplicitKey = false;
2296
+ allowCompact = true;
2297
+ } else throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
2298
+ state.position += 1;
2299
+ ch = following;
2300
+ } else {
2301
+ _keyLine = state.line;
2302
+ _keyLineStart = state.lineStart;
2303
+ _keyPos = state.position;
2304
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
2305
+ if (state.line === _line) {
2306
+ ch = state.input.charCodeAt(state.position);
2307
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
2308
+ if (ch === 58) {
2309
+ ch = state.input.charCodeAt(++state.position);
2310
+ if (!isWsOrEol(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
2311
+ if (atExplicitKey) {
2312
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2313
+ keyTag = keyNode = valueNode = null;
2314
+ }
2315
+ detected = true;
2316
+ atExplicitKey = false;
2317
+ allowCompact = false;
2318
+ keyTag = state.tag;
2319
+ keyNode = state.result;
2320
+ } else if (detected) throwError(state, "can not read an implicit mapping pair; a colon is missed");
2321
+ else {
2322
+ state.tag = _tag;
2323
+ state.anchor = _anchor;
2324
+ return true;
2325
+ }
2326
+ } else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
2327
+ else {
2328
+ state.tag = _tag;
2329
+ state.anchor = _anchor;
2330
+ return true;
2331
+ }
2332
+ }
2333
+ if (state.line === _line || state.lineIndent > nodeIndent) {
2334
+ if (atExplicitKey) {
2335
+ _keyLine = state.line;
2336
+ _keyLineStart = state.lineStart;
2337
+ _keyPos = state.position;
2338
+ }
2339
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) if (atExplicitKey) keyNode = state.result;
2340
+ else valueNode = state.result;
2341
+ if (!atExplicitKey) {
2342
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
2343
+ keyTag = keyNode = valueNode = null;
2344
+ }
2345
+ skipSeparationSpace(state, true, -1);
2346
+ ch = state.input.charCodeAt(state.position);
2347
+ }
2348
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
2349
+ else if (state.lineIndent < nodeIndent) break;
2350
+ }
2351
+ if (atExplicitKey) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2352
+ if (detected) {
2353
+ state.tag = _tag;
2354
+ state.anchor = _anchor;
2355
+ state.kind = "mapping";
2356
+ state.result = _result;
2357
+ }
2358
+ return detected;
2359
+ }
2360
+ function readTagProperty(state) {
2361
+ let isVerbatim = false;
2362
+ let isNamed = false;
2363
+ let tagHandle;
2364
+ let tagName;
2365
+ let ch = state.input.charCodeAt(state.position);
2366
+ if (ch !== 33) return false;
2367
+ if (state.tag !== null) throwError(state, "duplication of a tag property");
2368
+ ch = state.input.charCodeAt(++state.position);
2369
+ if (ch === 60) {
2370
+ isVerbatim = true;
2371
+ ch = state.input.charCodeAt(++state.position);
2372
+ } else if (ch === 33) {
2373
+ isNamed = true;
2374
+ tagHandle = "!!";
2375
+ ch = state.input.charCodeAt(++state.position);
2376
+ } else tagHandle = "!";
2377
+ let _position = state.position;
2378
+ if (isVerbatim) {
2379
+ do
2380
+ ch = state.input.charCodeAt(++state.position);
2381
+ while (ch !== 0 && ch !== 62);
2382
+ if (state.position < state.length) {
2383
+ tagName = state.input.slice(_position, state.position);
2384
+ ch = state.input.charCodeAt(++state.position);
2385
+ } else throwError(state, "unexpected end of the stream within a verbatim tag");
2386
+ } else {
2387
+ while (ch !== 0 && !isWsOrEol(ch)) {
2388
+ if (ch === 33) if (!isNamed) {
2389
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
2390
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
2391
+ isNamed = true;
2392
+ _position = state.position + 1;
2393
+ } else throwError(state, "tag suffix cannot contain exclamation marks");
2394
+ ch = state.input.charCodeAt(++state.position);
2395
+ }
2396
+ tagName = state.input.slice(_position, state.position);
2397
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
2398
+ }
2399
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) throwError(state, "tag name cannot contain such characters: " + tagName);
2400
+ try {
2401
+ tagName = decodeURIComponent(tagName);
2402
+ } catch (err) {
2403
+ throwError(state, "tag name is malformed: " + tagName);
2404
+ }
2405
+ if (isVerbatim) state.tag = tagName;
2406
+ else if (_hasOwnProperty.call(state.tagMap, tagHandle)) state.tag = state.tagMap[tagHandle] + tagName;
2407
+ else if (tagHandle === "!") state.tag = "!" + tagName;
2408
+ else if (tagHandle === "!!") state.tag = "tag:yaml.org,2002:" + tagName;
2409
+ else throwError(state, "undeclared tag handle \"" + tagHandle + "\"");
2410
+ return true;
2411
+ }
2412
+ function readAnchorProperty(state) {
2413
+ let ch = state.input.charCodeAt(state.position);
2414
+ if (ch !== 38) return false;
2415
+ if (state.anchor !== null) throwError(state, "duplication of an anchor property");
2416
+ ch = state.input.charCodeAt(++state.position);
2417
+ const _position = state.position;
2418
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
2419
+ if (state.position === _position) throwError(state, "name of an anchor node must contain at least one character");
2420
+ state.anchor = state.input.slice(_position, state.position);
2421
+ return true;
2422
+ }
2423
+ function readAlias(state) {
2424
+ let ch = state.input.charCodeAt(state.position);
2425
+ if (ch !== 42) return false;
2426
+ ch = state.input.charCodeAt(++state.position);
2427
+ const _position = state.position;
2428
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
2429
+ if (state.position === _position) throwError(state, "name of an alias node must contain at least one character");
2430
+ const alias = state.input.slice(_position, state.position);
2431
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) throwError(state, "unidentified alias \"" + alias + "\"");
2432
+ state.result = state.anchorMap[alias];
2433
+ skipSeparationSpace(state, true, -1);
2434
+ return true;
2435
+ }
2436
+ function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
2437
+ const fallbackState = snapshotState(state);
2438
+ beginAnchorTransaction(state);
2439
+ restoreState(state, propertyStart);
2440
+ state.tag = null;
2441
+ state.anchor = null;
2442
+ state.kind = null;
2443
+ state.result = null;
2444
+ if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
2445
+ commitAnchorTransaction(state);
2446
+ return true;
2447
+ }
2448
+ rollbackAnchorTransaction(state);
2449
+ restoreState(state, fallbackState);
2450
+ return false;
2451
+ }
2452
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2453
+ let allowBlockScalars;
2454
+ let allowBlockCollections;
2455
+ let indentStatus = 1;
2456
+ let atNewLine = false;
2457
+ let hasContent = false;
2458
+ let propertyStart = null;
2459
+ let type;
2460
+ let flowIndent;
2461
+ let blockIndent;
2462
+ if (state.depth >= state.maxDepth) throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
2463
+ state.depth += 1;
2464
+ if (state.listener !== null) state.listener("open", state);
2465
+ state.tag = null;
2466
+ state.anchor = null;
2467
+ state.kind = null;
2468
+ state.result = null;
2469
+ const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
2470
+ if (allowToSeek) {
2471
+ if (skipSeparationSpace(state, true, -1)) {
2472
+ atNewLine = true;
2473
+ if (state.lineIndent > parentIndent) indentStatus = 1;
2474
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
2475
+ else if (state.lineIndent < parentIndent) indentStatus = -1;
2476
+ }
2477
+ }
2478
+ if (indentStatus === 1) while (true) {
2479
+ const ch = state.input.charCodeAt(state.position);
2480
+ const propertyState = snapshotState(state);
2481
+ if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) break;
2482
+ if (!readTagProperty(state) && !readAnchorProperty(state)) break;
2483
+ if (propertyStart === null) propertyStart = propertyState;
2484
+ if (skipSeparationSpace(state, true, -1)) {
2485
+ atNewLine = true;
2486
+ allowBlockCollections = allowBlockStyles;
2487
+ if (state.lineIndent > parentIndent) indentStatus = 1;
2488
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
2489
+ else if (state.lineIndent < parentIndent) indentStatus = -1;
2490
+ } else allowBlockCollections = false;
2491
+ }
2492
+ if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
2493
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2494
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) flowIndent = parentIndent;
2495
+ else flowIndent = parentIndent + 1;
2496
+ blockIndent = state.position - state.lineStart;
2497
+ if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) hasContent = true;
2498
+ else {
2499
+ const ch = state.input.charCodeAt(state.position);
2500
+ if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(state, propertyStart, propertyStart.position - propertyStart.lineStart, flowIndent)) hasContent = true;
2501
+ else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) hasContent = true;
2502
+ else if (readAlias(state)) {
2503
+ hasContent = true;
2504
+ if (state.tag !== null || state.anchor !== null) throwError(state, "alias node should not have any properties");
2505
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2506
+ hasContent = true;
2507
+ if (state.tag === null) state.tag = "?";
2508
+ }
2509
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
2510
+ }
2511
+ else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2512
+ }
2513
+ if (state.tag === null) {
2514
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
2515
+ } else if (state.tag === "?") {
2516
+ if (state.result !== null && state.kind !== "scalar") throwError(state, "unacceptable node kind for !<?> tag; it should be \"scalar\", not \"" + state.kind + "\"");
2517
+ for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2518
+ type = state.implicitTypes[typeIndex];
2519
+ if (type.resolve(state.result)) {
2520
+ state.result = type.construct(state.result);
2521
+ state.tag = type.tag;
2522
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
2523
+ break;
2524
+ }
2525
+ }
2526
+ } else if (state.tag !== "!") {
2527
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) type = state.typeMap[state.kind || "fallback"][state.tag];
2528
+ else {
2529
+ type = null;
2530
+ const typeList = state.typeMap.multi[state.kind || "fallback"];
2531
+ for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2532
+ type = typeList[typeIndex];
2533
+ break;
2534
+ }
2535
+ }
2536
+ if (!type) throwError(state, "unknown tag !<" + state.tag + ">");
2537
+ if (state.result !== null && type.kind !== state.kind) throwError(state, "unacceptable node kind for !<" + state.tag + "> tag; it should be \"" + type.kind + "\", not \"" + state.kind + "\"");
2538
+ if (!type.resolve(state.result, state.tag)) throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2539
+ else {
2540
+ state.result = type.construct(state.result, state.tag);
2541
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
2542
+ }
2543
+ }
2544
+ if (state.listener !== null) state.listener("close", state);
2545
+ state.depth -= 1;
2546
+ return state.tag !== null || state.anchor !== null || hasContent;
2547
+ }
2548
+ function readDocument(state) {
2549
+ const documentStart = state.position;
2550
+ let hasDirectives = false;
2551
+ let ch;
2552
+ state.version = null;
2553
+ state.checkLineBreaks = state.legacy;
2554
+ state.tagMap = Object.create(null);
2555
+ state.anchorMap = Object.create(null);
2556
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2557
+ skipSeparationSpace(state, true, -1);
2558
+ ch = state.input.charCodeAt(state.position);
2559
+ if (state.lineIndent > 0 || ch !== 37) break;
2560
+ hasDirectives = true;
2561
+ ch = state.input.charCodeAt(++state.position);
2562
+ let _position = state.position;
2563
+ while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
2564
+ const directiveName = state.input.slice(_position, state.position);
2565
+ const directiveArgs = [];
2566
+ if (directiveName.length < 1) throwError(state, "directive name must not be less than one character in length");
2567
+ while (ch !== 0) {
2568
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
2569
+ if (ch === 35) {
2570
+ do
2571
+ ch = state.input.charCodeAt(++state.position);
2572
+ while (ch !== 0 && !isEol(ch));
2573
+ break;
2574
+ }
2575
+ if (isEol(ch)) break;
2576
+ _position = state.position;
2577
+ while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
2578
+ directiveArgs.push(state.input.slice(_position, state.position));
2579
+ }
2580
+ if (ch !== 0) readLineBreak(state);
2581
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) directiveHandlers[directiveName](state, directiveName, directiveArgs);
2582
+ else throwWarning(state, "unknown document directive \"" + directiveName + "\"");
2583
+ }
2584
+ skipSeparationSpace(state, true, -1);
2585
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2586
+ state.position += 3;
2587
+ skipSeparationSpace(state, true, -1);
2588
+ } else if (hasDirectives) throwError(state, "directives end mark is expected");
2589
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2590
+ skipSeparationSpace(state, true, -1);
2591
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) throwWarning(state, "non-ASCII line breaks are interpreted as content");
2592
+ state.documents.push(state.result);
2593
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2594
+ if (state.input.charCodeAt(state.position) === 46) {
2595
+ state.position += 3;
2596
+ skipSeparationSpace(state, true, -1);
2597
+ }
2598
+ return;
2599
+ }
2600
+ if (state.position < state.length - 1) throwError(state, "end of the stream or a document separator is expected");
2601
+ }
2602
+ function loadDocuments(input, options) {
2603
+ input = String(input);
2604
+ options = options || {};
2605
+ if (input.length !== 0) {
2606
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) input += "\n";
2607
+ if (input.charCodeAt(0) === 65279) input = input.slice(1);
2608
+ }
2609
+ const state = new State(input, options);
2610
+ const nullpos = input.indexOf("\0");
2611
+ if (nullpos !== -1) {
2612
+ state.position = nullpos;
2613
+ throwError(state, "null byte is not allowed in input");
2614
+ }
2615
+ state.input += "\0";
2616
+ while (state.input.charCodeAt(state.position) === 32) {
2617
+ state.lineIndent += 1;
2618
+ state.position += 1;
2619
+ }
2620
+ while (state.position < state.length - 1) readDocument(state);
2621
+ return state.documents;
2622
+ }
2623
+ function loadAll(input, iterator, options) {
2624
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2625
+ options = iterator;
2626
+ iterator = null;
2627
+ }
2628
+ const documents = loadDocuments(input, options);
2629
+ if (typeof iterator !== "function") return documents;
2630
+ for (let index = 0, length = documents.length; index < length; index += 1) iterator(documents[index]);
2631
+ }
2632
+ function load(input, options) {
2633
+ const documents = loadDocuments(input, options);
2634
+ if (documents.length === 0) return;
2635
+ else if (documents.length === 1) return documents[0];
2636
+ throw new YAMLException("expected a single document in the stream, but found more");
2637
+ }
2638
+ module.exports.loadAll = loadAll;
2639
+ module.exports.load = load;
2640
+ }));
2641
+ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2642
+ var common = require_common();
2643
+ var YAMLException = require_exception();
2644
+ var DEFAULT_SCHEMA = require_default();
2645
+ var _toString = Object.prototype.toString;
2646
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2647
+ var CHAR_BOM = 65279;
2648
+ var CHAR_TAB = 9;
2649
+ var CHAR_LINE_FEED = 10;
2650
+ var CHAR_CARRIAGE_RETURN = 13;
2651
+ var CHAR_SPACE = 32;
2652
+ var CHAR_EXCLAMATION = 33;
2653
+ var CHAR_DOUBLE_QUOTE = 34;
2654
+ var CHAR_SHARP = 35;
2655
+ var CHAR_PERCENT = 37;
2656
+ var CHAR_AMPERSAND = 38;
2657
+ var CHAR_SINGLE_QUOTE = 39;
2658
+ var CHAR_ASTERISK = 42;
2659
+ var CHAR_COMMA = 44;
2660
+ var CHAR_MINUS = 45;
2661
+ var CHAR_COLON = 58;
2662
+ var CHAR_EQUALS = 61;
2663
+ var CHAR_GREATER_THAN = 62;
2664
+ var CHAR_QUESTION = 63;
2665
+ var CHAR_COMMERCIAL_AT = 64;
2666
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2667
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2668
+ var CHAR_GRAVE_ACCENT = 96;
2669
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2670
+ var CHAR_VERTICAL_LINE = 124;
2671
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2672
+ var ESCAPE_SEQUENCES = {};
2673
+ ESCAPE_SEQUENCES[0] = "\\0";
2674
+ ESCAPE_SEQUENCES[7] = "\\a";
2675
+ ESCAPE_SEQUENCES[8] = "\\b";
2676
+ ESCAPE_SEQUENCES[9] = "\\t";
2677
+ ESCAPE_SEQUENCES[10] = "\\n";
2678
+ ESCAPE_SEQUENCES[11] = "\\v";
2679
+ ESCAPE_SEQUENCES[12] = "\\f";
2680
+ ESCAPE_SEQUENCES[13] = "\\r";
2681
+ ESCAPE_SEQUENCES[27] = "\\e";
2682
+ ESCAPE_SEQUENCES[34] = "\\\"";
2683
+ ESCAPE_SEQUENCES[92] = "\\\\";
2684
+ ESCAPE_SEQUENCES[133] = "\\N";
2685
+ ESCAPE_SEQUENCES[160] = "\\_";
2686
+ ESCAPE_SEQUENCES[8232] = "\\L";
2687
+ ESCAPE_SEQUENCES[8233] = "\\P";
2688
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2689
+ "y",
2690
+ "Y",
2691
+ "yes",
2692
+ "Yes",
2693
+ "YES",
2694
+ "on",
2695
+ "On",
2696
+ "ON",
2697
+ "n",
2698
+ "N",
2699
+ "no",
2700
+ "No",
2701
+ "NO",
2702
+ "off",
2703
+ "Off",
2704
+ "OFF"
2705
+ ];
2706
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2707
+ function compileStyleMap(schema, map) {
2708
+ if (map === null) return {};
2709
+ const result = {};
2710
+ const keys = Object.keys(map);
2711
+ for (let index = 0, length = keys.length; index < length; index += 1) {
2712
+ let tag = keys[index];
2713
+ let style = String(map[tag]);
2714
+ if (tag.slice(0, 2) === "!!") tag = "tag:yaml.org,2002:" + tag.slice(2);
2715
+ const type = schema.compiledTypeMap["fallback"][tag];
2716
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) style = type.styleAliases[style];
2717
+ result[tag] = style;
2718
+ }
2719
+ return result;
2720
+ }
2721
+ function encodeHex(character) {
2722
+ let handle;
2723
+ let length;
2724
+ const string = character.toString(16).toUpperCase();
2725
+ if (character <= 255) {
2726
+ handle = "x";
2727
+ length = 2;
2728
+ } else if (character <= 65535) {
2729
+ handle = "u";
2730
+ length = 4;
2731
+ } else if (character <= 4294967295) {
2732
+ handle = "U";
2733
+ length = 8;
2734
+ } else throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
2735
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
2736
+ }
2737
+ var QUOTING_TYPE_SINGLE = 1;
2738
+ var QUOTING_TYPE_DOUBLE = 2;
2739
+ function State(options) {
2740
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
2741
+ this.indent = Math.max(1, options["indent"] || 2);
2742
+ this.noArrayIndent = options["noArrayIndent"] || false;
2743
+ this.skipInvalid = options["skipInvalid"] || false;
2744
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2745
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2746
+ this.sortKeys = options["sortKeys"] || false;
2747
+ this.lineWidth = options["lineWidth"] || 80;
2748
+ this.noRefs = options["noRefs"] || false;
2749
+ this.noCompatMode = options["noCompatMode"] || false;
2750
+ this.condenseFlow = options["condenseFlow"] || false;
2751
+ this.quotingType = options["quotingType"] === "\"" ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2752
+ this.forceQuotes = options["forceQuotes"] || false;
2753
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2754
+ this.implicitTypes = this.schema.compiledImplicit;
2755
+ this.explicitTypes = this.schema.compiledExplicit;
2756
+ this.tag = null;
2757
+ this.result = "";
2758
+ this.duplicates = [];
2759
+ this.usedDuplicates = null;
2760
+ }
2761
+ function indentString(string, spaces) {
2762
+ const ind = common.repeat(" ", spaces);
2763
+ let position = 0;
2764
+ let result = "";
2765
+ const length = string.length;
2766
+ while (position < length) {
2767
+ let line;
2768
+ const next = string.indexOf("\n", position);
2769
+ if (next === -1) {
2770
+ line = string.slice(position);
2771
+ position = length;
2772
+ } else {
2773
+ line = string.slice(position, next + 1);
2774
+ position = next + 1;
2775
+ }
2776
+ if (line.length && line !== "\n") result += ind;
2777
+ result += line;
2778
+ }
2779
+ return result;
2780
+ }
2781
+ function generateNextLine(state, level) {
2782
+ return "\n" + common.repeat(" ", state.indent * level);
2783
+ }
2784
+ function testImplicitResolving(state, str) {
2785
+ for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) if (state.implicitTypes[index].resolve(str)) return true;
2786
+ return false;
2787
+ }
2788
+ function isWhitespace(c) {
2789
+ return c === CHAR_SPACE || c === CHAR_TAB;
2790
+ }
2791
+ function isPrintable(c) {
2792
+ return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
2793
+ }
2794
+ function isNsCharOrWhitespace(c) {
2795
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2796
+ }
2797
+ function isPlainSafe(c, prev, inblock) {
2798
+ const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2799
+ const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2800
+ return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar;
2801
+ }
2802
+ function isPlainSafeFirst(c) {
2803
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
2804
+ }
2805
+ function isPlainSafeLast(c) {
2806
+ return !isWhitespace(c) && c !== CHAR_COLON;
2807
+ }
2808
+ function codePointAt(string, pos) {
2809
+ const first = string.charCodeAt(pos);
2810
+ let second;
2811
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2812
+ second = string.charCodeAt(pos + 1);
2813
+ if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
2814
+ }
2815
+ return first;
2816
+ }
2817
+ function needIndentIndicator(string) {
2818
+ return /^\n* /.test(string);
2819
+ }
2820
+ var STYLE_PLAIN = 1;
2821
+ var STYLE_SINGLE = 2;
2822
+ var STYLE_LITERAL = 3;
2823
+ var STYLE_FOLDED = 4;
2824
+ var STYLE_DOUBLE = 5;
2825
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2826
+ let i;
2827
+ let char = 0;
2828
+ let prevChar = null;
2829
+ let hasLineBreak = false;
2830
+ let hasFoldableLine = false;
2831
+ const shouldTrackWidth = lineWidth !== -1;
2832
+ let previousLineBreak = -1;
2833
+ let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2834
+ if (singleLineOnly || forceQuotes) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2835
+ char = codePointAt(string, i);
2836
+ if (!isPrintable(char)) return STYLE_DOUBLE;
2837
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2838
+ prevChar = char;
2839
+ }
2840
+ else {
2841
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2842
+ char = codePointAt(string, i);
2843
+ if (char === CHAR_LINE_FEED) {
2844
+ hasLineBreak = true;
2845
+ if (shouldTrackWidth) {
2846
+ hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2847
+ previousLineBreak = i;
2848
+ }
2849
+ } else if (!isPrintable(char)) return STYLE_DOUBLE;
2850
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2851
+ prevChar = char;
2852
+ }
2853
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2854
+ }
2855
+ if (!hasLineBreak && !hasFoldableLine) {
2856
+ if (plain && !forceQuotes && !testAmbiguousType(string)) return STYLE_PLAIN;
2857
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2858
+ }
2859
+ if (indentPerLevel > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
2860
+ if (!forceQuotes) return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2861
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2862
+ }
2863
+ function writeScalar(state, string, level, iskey, inblock) {
2864
+ state.dump = function() {
2865
+ if (string.length === 0) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"\"" : "''";
2866
+ if (!state.noCompatMode) {
2867
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"" + string + "\"" : "'" + string + "'";
2868
+ }
2869
+ const indent = state.indent * Math.max(1, level);
2870
+ const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2871
+ const singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2872
+ function testAmbiguity(string) {
2873
+ return testImplicitResolving(state, string);
2874
+ }
2875
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
2876
+ case STYLE_PLAIN: return string;
2877
+ case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'";
2878
+ case STYLE_LITERAL: return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2879
+ case STYLE_FOLDED: return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2880
+ case STYLE_DOUBLE: return "\"" + escapeString(string, lineWidth) + "\"";
2881
+ default: throw new YAMLException("impossible error: invalid scalar style");
2882
+ }
2883
+ }();
2884
+ }
2885
+ function blockHeader(string, indentPerLevel) {
2886
+ const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2887
+ const clip = string[string.length - 1] === "\n";
2888
+ return indentIndicator + (clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-") + "\n";
2889
+ }
2890
+ function dropEndingNewline(string) {
2891
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2892
+ }
2893
+ function foldString(string, width) {
2894
+ const lineRe = /(\n+)([^\n]*)/g;
2895
+ let result = function() {
2896
+ let nextLF = string.indexOf("\n");
2897
+ nextLF = nextLF !== -1 ? nextLF : string.length;
2898
+ lineRe.lastIndex = nextLF;
2899
+ return foldLine(string.slice(0, nextLF), width);
2900
+ }();
2901
+ let prevMoreIndented = string[0] === "\n" || string[0] === " ";
2902
+ let moreIndented;
2903
+ let match;
2904
+ while (match = lineRe.exec(string)) {
2905
+ const prefix = match[1];
2906
+ const line = match[2];
2907
+ moreIndented = line[0] === " ";
2908
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2909
+ prevMoreIndented = moreIndented;
2910
+ }
2911
+ return result;
2912
+ }
2913
+ function foldLine(line, width) {
2914
+ if (line === "" || line[0] === " ") return line;
2915
+ const breakRe = / [^ ]/g;
2916
+ let match;
2917
+ let start = 0;
2918
+ let end;
2919
+ let curr = 0;
2920
+ let next = 0;
2921
+ let result = "";
2922
+ while (match = breakRe.exec(line)) {
2923
+ next = match.index;
2924
+ if (next - start > width) {
2925
+ end = curr > start ? curr : next;
2926
+ result += "\n" + line.slice(start, end);
2927
+ start = end + 1;
2928
+ }
2929
+ curr = next;
2930
+ }
2931
+ result += "\n";
2932
+ if (line.length - start > width && curr > start) result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2933
+ else result += line.slice(start);
2934
+ return result.slice(1);
2935
+ }
2936
+ function escapeString(string) {
2937
+ let result = "";
2938
+ let char = 0;
2939
+ for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2940
+ char = codePointAt(string, i);
2941
+ const escapeSeq = ESCAPE_SEQUENCES[char];
2942
+ if (!escapeSeq && isPrintable(char)) {
2943
+ result += string[i];
2944
+ if (char >= 65536) result += string[i + 1];
2945
+ } else result += escapeSeq || encodeHex(char);
2946
+ }
2947
+ return result;
2948
+ }
2949
+ function writeFlowSequence(state, level, object) {
2950
+ let _result = "";
2951
+ const _tag = state.tag;
2952
+ for (let index = 0, length = object.length; index < length; index += 1) {
2953
+ let value = object[index];
2954
+ if (state.replacer) value = state.replacer.call(object, String(index), value);
2955
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2956
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2957
+ _result += state.dump;
2958
+ }
2959
+ }
2960
+ state.tag = _tag;
2961
+ state.dump = "[" + _result + "]";
2962
+ }
2963
+ function writeBlockSequence(state, level, object, compact) {
2964
+ let _result = "";
2965
+ const _tag = state.tag;
2966
+ for (let index = 0, length = object.length; index < length; index += 1) {
2967
+ let value = object[index];
2968
+ if (state.replacer) value = state.replacer.call(object, String(index), value);
2969
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2970
+ if (!compact || _result !== "") _result += generateNextLine(state, level);
2971
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
2972
+ else _result += "- ";
2973
+ _result += state.dump;
2974
+ }
2975
+ }
2976
+ state.tag = _tag;
2977
+ state.dump = _result || "[]";
2978
+ }
2979
+ function writeFlowMapping(state, level, object) {
2980
+ let _result = "";
2981
+ const _tag = state.tag;
2982
+ const objectKeyList = Object.keys(object);
2983
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
2984
+ let pairBuffer = "";
2985
+ if (_result !== "") pairBuffer += ", ";
2986
+ if (state.condenseFlow) pairBuffer += "\"";
2987
+ const objectKey = objectKeyList[index];
2988
+ let objectValue = object[objectKey];
2989
+ if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
2990
+ if (!writeNode(state, level, objectKey, false, false)) continue;
2991
+ if (state.dump.length > 1024) pairBuffer += "? ";
2992
+ pairBuffer += state.dump + (state.condenseFlow ? "\"" : "") + ":" + (state.condenseFlow ? "" : " ");
2993
+ if (!writeNode(state, level, objectValue, false, false)) continue;
2994
+ pairBuffer += state.dump;
2995
+ _result += pairBuffer;
2996
+ }
2997
+ state.tag = _tag;
2998
+ state.dump = "{" + _result + "}";
2999
+ }
3000
+ function writeBlockMapping(state, level, object, compact) {
3001
+ let _result = "";
3002
+ const _tag = state.tag;
3003
+ const objectKeyList = Object.keys(object);
3004
+ if (state.sortKeys === true) objectKeyList.sort();
3005
+ else if (typeof state.sortKeys === "function") objectKeyList.sort(state.sortKeys);
3006
+ else if (state.sortKeys) throw new YAMLException("sortKeys must be a boolean or a function");
3007
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
3008
+ let pairBuffer = "";
3009
+ if (!compact || _result !== "") pairBuffer += generateNextLine(state, level);
3010
+ const objectKey = objectKeyList[index];
3011
+ let objectValue = object[objectKey];
3012
+ if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
3013
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) continue;
3014
+ const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
3015
+ if (explicitPair) if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += "?";
3016
+ else pairBuffer += "? ";
3017
+ pairBuffer += state.dump;
3018
+ if (explicitPair) pairBuffer += generateNextLine(state, level);
3019
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) continue;
3020
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += ":";
3021
+ else pairBuffer += ": ";
3022
+ pairBuffer += state.dump;
3023
+ _result += pairBuffer;
3024
+ }
3025
+ state.tag = _tag;
3026
+ state.dump = _result || "{}";
3027
+ }
3028
+ function detectType(state, object, explicit) {
3029
+ const typeList = explicit ? state.explicitTypes : state.implicitTypes;
3030
+ for (let index = 0, length = typeList.length; index < length; index += 1) {
3031
+ const type = typeList[index];
3032
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
3033
+ if (explicit) if (type.multi && type.representName) state.tag = type.representName(object);
3034
+ else state.tag = type.tag;
3035
+ else state.tag = "?";
3036
+ if (type.represent) {
3037
+ const style = state.styleMap[type.tag] || type.defaultStyle;
3038
+ let _result;
3039
+ if (_toString.call(type.represent) === "[object Function]") _result = type.represent(object, style);
3040
+ else if (_hasOwnProperty.call(type.represent, style)) _result = type.represent[style](object, style);
3041
+ else throw new YAMLException("!<" + type.tag + "> tag resolver accepts not \"" + style + "\" style");
3042
+ state.dump = _result;
3043
+ }
3044
+ return true;
3045
+ }
3046
+ }
3047
+ return false;
3048
+ }
3049
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3050
+ state.tag = null;
3051
+ state.dump = object;
3052
+ if (!detectType(state, object, false)) detectType(state, object, true);
3053
+ const type = _toString.call(state.dump);
3054
+ const inblock = block;
3055
+ if (block) block = state.flowLevel < 0 || state.flowLevel > level;
3056
+ const objectOrArray = type === "[object Object]" || type === "[object Array]";
3057
+ let duplicateIndex;
3058
+ let duplicate;
3059
+ if (objectOrArray) {
3060
+ duplicateIndex = state.duplicates.indexOf(object);
3061
+ duplicate = duplicateIndex !== -1;
3062
+ }
3063
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) compact = false;
3064
+ if (duplicate && state.usedDuplicates[duplicateIndex]) state.dump = "*ref_" + duplicateIndex;
3065
+ else {
3066
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) state.usedDuplicates[duplicateIndex] = true;
3067
+ if (type === "[object Object]") if (block && Object.keys(state.dump).length !== 0) {
3068
+ writeBlockMapping(state, level, state.dump, compact);
3069
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
3070
+ } else {
3071
+ writeFlowMapping(state, level, state.dump);
3072
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3073
+ }
3074
+ else if (type === "[object Array]") if (block && state.dump.length !== 0) {
3075
+ if (state.noArrayIndent && !isblockseq && level > 0) writeBlockSequence(state, level - 1, state.dump, compact);
3076
+ else writeBlockSequence(state, level, state.dump, compact);
3077
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
3078
+ } else {
3079
+ writeFlowSequence(state, level, state.dump);
3080
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3081
+ }
3082
+ else if (type === "[object String]") {
3083
+ if (state.tag !== "?") writeScalar(state, state.dump, level, iskey, inblock);
3084
+ } else if (type === "[object Undefined]") return false;
3085
+ else {
3086
+ if (state.skipInvalid) return false;
3087
+ throw new YAMLException("unacceptable kind of an object to dump " + type);
3088
+ }
3089
+ if (state.tag !== null && state.tag !== "?") {
3090
+ let tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
3091
+ if (state.tag[0] === "!") tagStr = "!" + tagStr;
3092
+ else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") tagStr = "!!" + tagStr.slice(18);
3093
+ else tagStr = "!<" + tagStr + ">";
3094
+ state.dump = tagStr + " " + state.dump;
3095
+ }
3096
+ }
3097
+ return true;
3098
+ }
3099
+ function getDuplicateReferences(object, state) {
3100
+ const objects = [];
3101
+ const duplicatesIndexes = [];
3102
+ inspectNode(object, objects, duplicatesIndexes);
3103
+ const length = duplicatesIndexes.length;
3104
+ for (let index = 0; index < length; index += 1) state.duplicates.push(objects[duplicatesIndexes[index]]);
3105
+ state.usedDuplicates = new Array(length);
3106
+ }
3107
+ function inspectNode(object, objects, duplicatesIndexes) {
3108
+ if (object !== null && typeof object === "object") {
3109
+ const index = objects.indexOf(object);
3110
+ if (index !== -1) {
3111
+ if (duplicatesIndexes.indexOf(index) === -1) duplicatesIndexes.push(index);
3112
+ } else {
3113
+ objects.push(object);
3114
+ if (Array.isArray(object)) for (let i = 0, length = object.length; i < length; i += 1) inspectNode(object[i], objects, duplicatesIndexes);
3115
+ else {
3116
+ const objectKeyList = Object.keys(object);
3117
+ for (let i = 0, length = objectKeyList.length; i < length; i += 1) inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
3118
+ }
3119
+ }
3120
+ }
3121
+ }
3122
+ function dump(input, options) {
3123
+ options = options || {};
3124
+ const state = new State(options);
3125
+ if (!state.noRefs) getDuplicateReferences(input, state);
3126
+ let value = input;
3127
+ if (state.replacer) value = state.replacer.call({ "": value }, "", value);
3128
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
3129
+ return "";
3130
+ }
3131
+ module.exports.dump = dump;
3132
+ }));
3133
+ var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
3134
+ var loader = require_loader();
3135
+ var dumper = require_dumper();
3136
+ function renamed(from, to) {
3137
+ return function() {
3138
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
3139
+ };
3140
+ }
3141
+ module.exports.Type = require_type();
3142
+ module.exports.Schema = require_schema();
3143
+ module.exports.FAILSAFE_SCHEMA = require_failsafe();
3144
+ module.exports.JSON_SCHEMA = require_json();
3145
+ module.exports.CORE_SCHEMA = require_core();
3146
+ module.exports.DEFAULT_SCHEMA = require_default();
3147
+ module.exports.load = loader.load;
3148
+ module.exports.loadAll = loader.loadAll;
3149
+ module.exports.dump = dumper.dump;
3150
+ module.exports.YAMLException = require_exception();
3151
+ module.exports.types = {
3152
+ binary: require_binary(),
3153
+ float: require_float(),
3154
+ map: require_map(),
3155
+ null: require_null(),
3156
+ pairs: require_pairs(),
3157
+ set: require_set(),
3158
+ timestamp: require_timestamp(),
3159
+ bool: require_bool(),
3160
+ int: require_int(),
3161
+ merge: require_merge(),
3162
+ omap: require_omap(),
3163
+ seq: require_seq(),
3164
+ str: require_str()
3165
+ };
3166
+ module.exports.safeLoad = renamed("safeLoad", "load");
3167
+ module.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
3168
+ module.exports.safeDump = renamed("safeDump", "dump");
3169
+ })))(), 1);
3170
+ var { Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
3171
+ var index_vite_proxy_tmp_default = import_js_yaml.default;
3172
+
3173
+ //#endregion
3174
+ //#region ../graph-tools/dist/typescript.mjs
3175
+ function hasNoTypeScriptParseErrors(source) {
3176
+ return (import_typescript.default.createSourceFile("profile-code.ts", source, import_typescript.default.ScriptTarget.Latest, false, import_typescript.default.ScriptKind.TS).parseDiagnostics?.length ?? 0) === 0;
3177
+ }
3178
+ /** Validates profile code blocks with the TypeScript parser. */
3179
+ function installTypeScriptProfileCodeSyntax() {
3180
+ setProfileCodeSyntaxChecker(hasNoTypeScriptParseErrors);
3181
+ }
3182
+ /** Map from xstate action type to the import name */
3183
+ const BUILTIN_ACTION_IMPORTS = {
3184
+ "xstate.raise": "raise",
3185
+ "xstate.sendTo": "sendTo",
3186
+ "xstate.cancel": "cancel",
3187
+ "xstate.emit": "emit",
3188
+ "xstate.spawnChild": "spawnChild",
3189
+ "xstate.stopChild": "stopChild",
3190
+ "xstate.log": "log",
3191
+ "xstate.assign": "assign",
3192
+ "xstate.choose": "enqueueActions"
3193
+ };
3194
+ const XSTATE_ACTOR_LOGIC_HELPERS = new Set([
3195
+ "createMachine",
3196
+ "createAsyncLogic",
3197
+ "createCallbackLogic",
3198
+ "createEventObservableLogic",
3199
+ "createListenerLogic",
3200
+ "createLogic",
3201
+ "createObservableLogic",
3202
+ "createSubscriptionLogic",
3203
+ "fromPromise",
3204
+ "fromCallback",
3205
+ "fromObservable",
3206
+ "fromEventObservable",
3207
+ "fromTransition"
3208
+ ]);
3209
+ const XSTATE_IMPLEMENTATION_HELPERS = new Set([
3210
+ ...Object.values(BUILTIN_ACTION_IMPORTS),
3211
+ "enqueueActions",
3212
+ "sendParent",
3213
+ "forwardTo",
3214
+ "stop",
3215
+ "and",
3216
+ "or",
3217
+ "not",
3218
+ "stateIn",
3219
+ ...XSTATE_ACTOR_LOGIC_HELPERS
3220
+ ]);
3221
+ const machineFormatSchema = _enum([
3222
+ "xstate",
3223
+ "json",
3224
+ "yaml",
3225
+ "scxml",
3226
+ "mermaid"
3227
+ ]);
3228
+ const canonicalMachineProfileSchema = custom((value) => typeof value === "string" && /^@statelyai\/xstate@\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(value), "Expected an exact @statelyai/xstate profile reference.");
3229
+ const xstateSourceProfileSchema = union([
3230
+ literal("auto"),
3231
+ _enum(LEGACY_MACHINE_PROFILES),
3232
+ canonicalMachineProfileSchema
3233
+ ]);
3234
+ const machineInputSchema = object({
3235
+ machine: union([record(string(), unknown()), string()]),
3236
+ format: machineFormatSchema.optional(),
3237
+ profile: xstateSourceProfileSchema.optional(),
3238
+ xstateVersion: union([literal(5), literal(6)]).optional()
3239
+ });
3240
+ const graphSchema = record(string(), unknown());
3241
+ const convertMachineFormatInputSchema = object({
3242
+ machine: union([record(string(), unknown()), string()]).optional(),
3243
+ graph: graphSchema.optional(),
3244
+ format: machineFormatSchema.optional(),
3245
+ to: machineFormatSchema
3246
+ }).refine((value) => Boolean(value.machine) !== Boolean(value.graph), { message: "Provide exactly one of machine or graph." });
3247
+ const applyMachinePatchesInputSchema = object({
3248
+ graph: graphSchema,
3249
+ patches: array(machinePatchSchema),
3250
+ outputFormat: machineFormatSchema.default("json")
3251
+ });
3252
+ const diffMachinesInputSchema = object({
3253
+ left: machineInputSchema,
3254
+ right: machineInputSchema,
3255
+ includePatches: boolean().optional()
3256
+ });
3257
+ const generateMachinePathsInputSchema = machineInputSchema.extend({
3258
+ targetPath: array(string()).optional(),
3259
+ kind: _enum(["shortest", "simple"]).default("shortest"),
3260
+ max: number().int().positive().optional()
3261
+ });
3262
+ const simulateMachineStepInputSchema = machineInputSchema.extend({
3263
+ stateValue: unknown(),
3264
+ event: object({ type: string() }).passthrough(),
3265
+ guardState: record(string(), boolean()).optional()
3266
+ });
3267
+ const SOURCE_COVERAGE_META = "@statelyai.sourceCoverage";
3268
+ async function sourceHash(source) {
3269
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(source));
3270
+ return Array.from(new Uint8Array(digest), (n) => n.toString(16).padStart(2, "0")).join("");
3271
+ }
3272
+ function analyze(source) {
3273
+ const analysis = getXStateSourceCoverageAnalysis(source);
3274
+ const diagnostics = [...analysis.diagnostics];
3275
+ const obligations = [];
3276
+ const sites = /* @__PURE__ */ new Map();
3277
+ const wrappers = /* @__PURE__ */ new Map();
3278
+ const implicit = /* @__PURE__ */ new Map();
3279
+ const identifiers = /* @__PURE__ */ new Set();
3280
+ const collect = (node) => {
3281
+ if (import_typescript.default.isIdentifier(node)) identifiers.add(node.text);
3282
+ import_typescript.default.forEachChild(node, collect);
3283
+ };
3284
+ collect(analysis.file);
3285
+ let controlName = "__xstateSourceCoverage";
3286
+ while (identifiers.has(controlName)) controlName += "_";
3287
+ for (const entry of analysis.entries) {
3288
+ const scope = JSON.stringify([entry.machineIndex, entry.path]);
3289
+ wrappers.set(entry.node, {
3290
+ scope,
3291
+ mode: entry.mode
3292
+ });
3293
+ const byId = /* @__PURE__ */ new Map();
3294
+ for (const branch of entry.branches) {
3295
+ const value = branch.result;
3296
+ const origin = branch.origin ?? branch.fallthrough ?? entry.fn?.body ?? entry.node;
3297
+ const siteId = entry.mode === "static" ? "static" : branch.shortCircuit === "and" ? `${origin.getStart()}-${origin.end}:false` : branch.origin ? `${origin.getStart()}-${origin.end}` : `${origin.end}:fallthrough`;
3298
+ const id = `${scope}#${siteId}`;
3299
+ const target = typeof value === "string" && entry.mode === "static" ? value : value?.target;
3300
+ const targets = target === void 0 ? [] : Array.isArray(target) ? target : [target];
3301
+ if (branch.unknown || isCodeExpression(value) || targets.some((item) => typeof item !== "string") || entry.mode === "function" && value !== void 0 && (!value || typeof value !== "object" || Array.isArray(value))) {
3302
+ diagnostics.push({
3303
+ code: "unresolved-outcome",
3304
+ path: entry.path,
3305
+ message: "A returned outcome or destination cannot be completely enumerated.",
3306
+ start: origin.getStart(),
3307
+ end: origin.end
3308
+ });
3309
+ continue;
3310
+ }
3311
+ const kind = targets.length ? "transition" : value === void 0 && !branch.actions.length && !branch.contextUpdates ? "refusal" : "targetless";
3312
+ const predicates = branch.conds.map((condition) => condition.negated ? `!(${condition.text})` : condition.text);
3313
+ const existing = byId.get(id);
3314
+ if (existing) {
3315
+ if (existing.kind !== kind || JSON.stringify(existing.targets) !== JSON.stringify(targets)) diagnostics.push({
3316
+ code: "ambiguous-outcome-site",
3317
+ path: entry.path,
3318
+ message: "A shared return site resolves to different outcomes that cannot be distinguished by instrumentation.",
3319
+ start: origin.getStart(),
3320
+ end: origin.end
3321
+ });
3322
+ existing.predicates.push(predicates);
3323
+ continue;
3324
+ }
3325
+ const position = analysis.file.getLineAndCharacterOfPosition(origin.getStart());
3326
+ const obligation = {
3327
+ id,
3328
+ machineIndex: entry.machineIndex,
3329
+ path: entry.path,
3330
+ eventType: entry.eventType,
3331
+ kind,
3332
+ targets,
3333
+ predicates: [predicates],
3334
+ location: {
3335
+ start: origin.getStart(),
3336
+ end: origin.end,
3337
+ line: position.line + 1,
3338
+ column: position.character + 1
3339
+ }
3340
+ };
3341
+ byId.set(id, obligation);
3342
+ obligations.push(obligation);
3343
+ if (entry.mode === "function") if (!branch.origin && (branch.fallthrough ?? entry.fn?.body)) implicit.set(branch.fallthrough ?? entry.fn.body, siteId);
3344
+ else sites.set(origin, {
3345
+ siteId,
3346
+ kind: branch.shortCircuit === "and" ? "and" : import_typescript.default.isReturnStatement(origin) ? "empty-return" : "value"
3347
+ });
3348
+ }
3349
+ }
3350
+ const uniqueDiagnostics = [...new Map(diagnostics.map((d) => [`${d.code}:${d.path}:${d.start}:${d.end}`, d])).values()];
3351
+ return {
3352
+ ...analysis,
3353
+ obligations,
3354
+ diagnostics: uniqueDiagnostics,
3355
+ sites,
3356
+ wrappers,
3357
+ implicit,
3358
+ controlName
3359
+ };
3360
+ }
3361
+ /** Extracts all supported outcomes; unresolved syntax prevents completeness. */
3362
+ async function extractXStateSourceCoverage(source, options = {}) {
3363
+ const analysis = analyze(source);
3364
+ return {
3365
+ schemaVersion: 1,
3366
+ criterion: "transition-outcomes",
3367
+ source: {
3368
+ fileName: options.fileName ?? "machine.ts",
3369
+ hash: await sourceHash(source),
3370
+ algorithm: "SHA-256"
3371
+ },
3372
+ extractor: "stately-source-coverage/1",
3373
+ complete: analysis.diagnostics.length === 0,
3374
+ machineCount: analysis.machineCount,
3375
+ obligations: analysis.obligations,
3376
+ diagnostics: analysis.diagnostics
3377
+ };
3378
+ }
3379
+ /**
3380
+ * Adds file-local instrumentation without evaluating source. The host imports
3381
+ * the returned control export and installs an observer during synchronous
3382
+ * transition calculation. No globals or shared process-wide recorder are used.
3383
+ */
3384
+ async function instrumentXStateSourceCoverage(source, options = {}) {
3385
+ const manifest = await extractXStateSourceCoverage(source, options);
3386
+ const analysis = analyze(source);
3387
+ if (!manifest.complete) throw Object.assign(/* @__PURE__ */ new Error("Complete source extraction is required before instrumentation."), { diagnostics: manifest.diagnostics });
3388
+ if (analysis.entries.some((entry) => entry.mode === "static" && entry.branches.some((branch) => typeof branch.result === "string"))) throw new Error("Source instrumentation requires v6 object transitions; string transitions belong to v5.");
3389
+ const name = analysis.controlName;
3390
+ const prelude = `
3391
+ export const ${name} = {
3392
+ observer: undefined as undefined | ((id: string) => void),
3393
+ faults: 0,
3394
+ ids: new Set(${JSON.stringify(manifest.obligations.map((obligation) => obligation.id))}),
3395
+ scope: undefined as string | undefined,
3396
+ hit<T>(site: string, value: T): T {
3397
+ if (this.scope !== undefined) {
3398
+ const id = this.scope + '#' + site;
3399
+ if (this.ids.has(id)) {
3400
+ try { this.observer?.(id); } catch { this.faults++; }
3401
+ }
3402
+ }
3403
+ return value;
3404
+ },
3405
+ and<T, U>(site: string, left: T, right: () => U): T | U {
3406
+ return left ? right() : this.hit(site, left);
3407
+ },
3408
+ wrap<T extends (...args: any[]) => any>(scope: string, fn: T): T {
3409
+ const control = this;
3410
+ return function(this: unknown, ...args: any[]) {
3411
+ const previous = control.scope; control.scope = scope;
3412
+ try { return fn.apply(this, args); } finally { control.scope = previous; }
3413
+ } as T;
3414
+ },
3415
+ static(scope: string, value: any): any {
3416
+ const config = typeof value === 'string' ? { target: value } : value;
3417
+ return { ...config, [Symbol.for(${JSON.stringify(SOURCE_COVERAGE_META)})]: scope + '#static' };
3418
+ }
3419
+ };`;
3420
+ const control = import_typescript.default.factory.createIdentifier(name);
3421
+ const invoke = (method, args) => import_typescript.default.factory.createCallExpression(import_typescript.default.factory.createPropertyAccessExpression(control, method), void 0, args);
3422
+ const transformed = import_typescript.default.transform(analysis.file, [(context) => (root) => {
3423
+ const visit = (original) => {
3424
+ let node = import_typescript.default.visitEachChild(original, visit, context);
3425
+ const site = analysis.sites.get(original);
3426
+ if (site?.kind === "empty-return" && import_typescript.default.isReturnStatement(node)) node = import_typescript.default.factory.updateReturnStatement(node, invoke("hit", [import_typescript.default.factory.createStringLiteral(site.siteId), import_typescript.default.factory.createVoidZero()]));
3427
+ else if (site?.kind === "and" && import_typescript.default.isBinaryExpression(node)) node = invoke("and", [
3428
+ import_typescript.default.factory.createStringLiteral(site.siteId),
3429
+ node.left,
3430
+ import_typescript.default.factory.createArrowFunction(void 0, void 0, [], void 0, import_typescript.default.factory.createToken(import_typescript.default.SyntaxKind.EqualsGreaterThanToken), node.right)
3431
+ ]);
3432
+ else if (site?.kind === "value" && import_typescript.default.isExpression(node)) node = invoke("hit", [import_typescript.default.factory.createStringLiteral(site.siteId), node]);
3433
+ const fallthrough = analysis.implicit.get(original);
3434
+ if (fallthrough && import_typescript.default.isBlock(node)) node = import_typescript.default.factory.updateBlock(node, [...node.statements, import_typescript.default.factory.createExpressionStatement(invoke("hit", [import_typescript.default.factory.createStringLiteral(fallthrough), import_typescript.default.factory.createVoidZero()]))]);
3435
+ const wrapper = analysis.wrappers.get(original);
3436
+ if (wrapper && import_typescript.default.isExpression(node)) node = invoke(wrapper.mode === "static" ? "static" : "wrap", [import_typescript.default.factory.createStringLiteral(wrapper.scope), node]);
3437
+ return node;
3438
+ };
3439
+ return import_typescript.default.visitNode(root, visit);
3440
+ }]);
3441
+ try {
3442
+ return {
3443
+ manifest,
3444
+ controlExport: name,
3445
+ source: prelude + "\n" + import_typescript.default.createPrinter().printFile(transformed.transformed[0]),
3446
+ metadataKey: SOURCE_COVERAGE_META
3447
+ };
3448
+ } finally {
3449
+ transformed.dispose();
3450
+ }
3451
+ }
3452
+ /** Produces a source-linked coverage graph that the existing Viz canvas can render. */
3453
+ async function createXStateSourceCoverageGraph(source, report, options = {}) {
3454
+ const { extractXStateMachineConfigEntries, detectXStateSourceProfile } = await import("./xstateSource-JvwXWv6G-KnMMoZlG.mjs").then((n) => n.r).then((n) => n.c);
3455
+ const { machineConfigToGraph } = await import("./machineGraph-DYtFKHlq-BpWpGU22.mjs").then((n) => n.i);
3456
+ const manifest = await extractXStateSourceCoverage(source, options);
3457
+ if (report && report.sourceHash !== manifest.source.hash) throw new Error("Coverage report source revision does not match this graph.");
3458
+ const analysis = analyze(source);
3459
+ const machineIndex = options.machineIndex ?? 0;
3460
+ const config = extractXStateMachineConfigEntries(source, { includeNested: true }).find((entry) => entry.machineIndex === machineIndex)?.config;
3461
+ if (!config) throw new Error(`Machine ${machineIndex} was not found.`);
3462
+ const lookup = (path) => {
3463
+ const keys = path.split("/").slice(1).map((key) => key.replaceAll("~1", "/").replaceAll("~0", "~"));
3464
+ let parent = config;
3465
+ for (const [index, key] of keys.entries()) {
3466
+ if (index === keys.length - 1) return parent ? {
3467
+ parent,
3468
+ key
3469
+ } : void 0;
3470
+ if (key === "0" && !Array.isArray(parent)) continue;
3471
+ parent = parent?.[key];
3472
+ }
3473
+ };
3474
+ for (const entry of analysis.entries.filter((entry) => entry.machineIndex === machineIndex)) {
3475
+ const slot = lookup(entry.path.endsWith("/to") ? entry.path.slice(0, -3) : entry.path);
3476
+ if (!slot) continue;
3477
+ const branches = entry.mode === "function" ? entry.branches.map((branch) => getXStateCoverageBranchProjection(branch, entry.fn)).filter(Boolean) : Array.isArray(slot.parent[slot.key]) ? slot.parent[slot.key] : [slot.parent[slot.key]];
3478
+ const sourceBranches = entry.branches.filter((branch) => branch.result !== void 0 || branch.actions.length || branch.contextUpdates);
3479
+ if (branches.length !== sourceBranches.length) continue;
3480
+ const scope = JSON.stringify([entry.machineIndex, entry.path]);
3481
+ slot.parent[slot.key] = branches.map((branch, index) => {
3482
+ if (!branch) return branch;
3483
+ const sourceBranch = sourceBranches[index];
3484
+ const origin = sourceBranch.origin ?? sourceBranch.fallthrough ?? entry.fn?.body ?? entry.node;
3485
+ const id = `${scope}#${entry.mode === "static" ? "static" : sourceBranch.shortCircuit === "and" ? `${origin.getStart()}-${origin.end}:false` : sourceBranch.origin ? `${origin.getStart()}-${origin.end}` : `${origin.end}:fallthrough`}`;
3486
+ const object = typeof branch === "string" ? { target: branch } : branch;
3487
+ return {
3488
+ ...object,
3489
+ meta: {
3490
+ ...object.meta,
3491
+ [SOURCE_COVERAGE_META]: id
3492
+ }
3493
+ };
3494
+ });
3495
+ if (!Array.isArray(branches) || branches.length === 1) slot.parent[slot.key] = slot.parent[slot.key][0];
3496
+ }
3497
+ const graph = machineConfigToGraph(config, { profile: options.profile ?? detectXStateSourceProfile(source) });
3498
+ for (const edge of graph.edges) {
3499
+ const id = edge.data.meta?.[SOURCE_COVERAGE_META];
3500
+ if (typeof id !== "string" || !report) continue;
3501
+ const covered = report.covered.includes(id);
3502
+ edge.data.color = covered ? "#15803d" : "#b91c1c";
3503
+ edge.data.meta = {
3504
+ ...edge.data.meta,
3505
+ "@statelyai.coverage": {
3506
+ outcomeId: id,
3507
+ covered,
3508
+ witnessCount: report.counts[id] ?? 0
3509
+ }
3510
+ };
3511
+ }
3512
+ graph.data = {
3513
+ ...graph.data,
3514
+ sourceCoverage: {
3515
+ sourceHash: manifest.source.hash,
3516
+ extractionComplete: manifest.complete,
3517
+ diagnostics: manifest.diagnostics,
3518
+ refusals: manifest.obligations.filter((o) => o.machineIndex === machineIndex && o.kind === "refusal").map((o) => ({
3519
+ ...o,
3520
+ covered: report?.covered.includes(o.id) ?? false
3521
+ }))
3522
+ }
3523
+ };
3524
+ return {
3525
+ manifest,
3526
+ graph
3527
+ };
3528
+ }
3529
+ /** Boundary suggestions, not evidence: every candidate still needs execution. */
3530
+ function getXStateSourceCoverageEventCases(manifest, state, seeds) {
3531
+ const cases = [...seeds];
3532
+ for (const obligation of manifest.obligations) for (const conditions of obligation.predicates) for (const condition of conditions) {
3533
+ const file = import_typescript.default.createSourceFile("predicate.ts", condition, import_typescript.default.ScriptTarget.Latest, true);
3534
+ const literal = (node) => {
3535
+ if (import_typescript.default.isNumericLiteral(node)) return Number(node.text);
3536
+ if (import_typescript.default.isStringLiteral(node)) return node.text;
3537
+ if (node.kind === import_typescript.default.SyntaxKind.TrueKeyword) return true;
3538
+ if (node.kind === import_typescript.default.SyntaxKind.FalseKeyword) return false;
3539
+ if (import_typescript.default.isPropertyAccessExpression(node) && import_typescript.default.isIdentifier(node.expression) && node.expression.text === "context") return state.context?.[node.name.text];
3540
+ };
3541
+ const visit = (node) => {
3542
+ if (import_typescript.default.isBinaryExpression(node)) for (const [field, value] of [[node.left, node.right], [node.right, node.left]]) {
3543
+ if (!import_typescript.default.isPropertyAccessExpression(field) || !import_typescript.default.isIdentifier(field.expression) || field.expression.text !== "event") continue;
3544
+ const boundary = literal(value);
3545
+ const values = typeof boundary === "number" ? [
3546
+ boundary,
3547
+ boundary - 1,
3548
+ boundary + 1
3549
+ ] : typeof boundary === "boolean" ? [boundary, !boundary] : typeof boundary === "string" ? [boundary] : [];
3550
+ for (const seed of seeds.filter((seed) => seed.type === obligation.eventType)) for (const value of values) cases.push({
3551
+ ...seed,
3552
+ [field.name.text]: value
3553
+ });
3554
+ }
3555
+ import_typescript.default.forEachChild(node, visit);
3556
+ };
3557
+ visit(file);
3558
+ }
3559
+ return [...new Map(cases.map((event) => [JSON.stringify(event), event])).values()];
3560
+ }
3561
+ /**
3562
+ * TypeScript-compiler-backed graph tools: XState code generation, XState
3563
+ * source parsing, profile detection, and machine format conversion.
3564
+ *
3565
+ * Kept out of the main entry so browser bundles only load the TypeScript
3566
+ * compiler when they need it. Loading this entry also validates profile code
3567
+ * blocks with the TypeScript parser.
3568
+ */
3569
+ installTypeScriptProfileCodeSyntax();
3570
+
3571
+ //#endregion
3572
+ export { createXStateSourceCoverageGraph, extractXStateSourceCoverage, getXStateSourceCoverageEventCases, instrumentXStateSourceCoverage };