@statelyai/sdk 0.12.0 → 0.12.1

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.
@@ -1,4 +1,5 @@
1
1
  import ts from "typescript";
2
+ import "xstate/graph";
2
3
 
3
4
  //#region src/statelyPragma.ts
4
5
  function findStatelyPragmaAttachments(sourceText, fileName = "machine.ts") {
@@ -4427,7 +4428,2526 @@ const describe = describe$1;
4427
4428
  const meta = meta$1;
4428
4429
 
4429
4430
  //#endregion
4430
- //#region ../graph-tools/src/emittedNodeIds.ts
4431
+ //#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
4432
+ /*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT */
4433
+ var __create = Object.create;
4434
+ var __defProp = Object.defineProperty;
4435
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4436
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4437
+ var __getProtoOf = Object.getPrototypeOf;
4438
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4439
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4440
+ var __copyProps = (to, from, except, desc) => {
4441
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
4442
+ key = keys[i];
4443
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
4444
+ get: ((k) => from[k]).bind(null, key),
4445
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
4446
+ });
4447
+ }
4448
+ return to;
4449
+ };
4450
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
4451
+ value: mod,
4452
+ enumerable: true
4453
+ }) : target, mod));
4454
+ var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4455
+ function isNothing(subject) {
4456
+ return typeof subject === "undefined" || subject === null;
4457
+ }
4458
+ function isObject(subject) {
4459
+ return typeof subject === "object" && subject !== null;
4460
+ }
4461
+ function toArray(sequence) {
4462
+ if (Array.isArray(sequence)) return sequence;
4463
+ else if (isNothing(sequence)) return [];
4464
+ return [sequence];
4465
+ }
4466
+ function extend(target, source) {
4467
+ if (source) {
4468
+ const sourceKeys = Object.keys(source);
4469
+ for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
4470
+ const key = sourceKeys[index];
4471
+ target[key] = source[key];
4472
+ }
4473
+ }
4474
+ return target;
4475
+ }
4476
+ function repeat(string, count) {
4477
+ let result = "";
4478
+ for (let cycle = 0; cycle < count; cycle += 1) result += string;
4479
+ return result;
4480
+ }
4481
+ function isNegativeZero(number) {
4482
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
4483
+ }
4484
+ module.exports.isNothing = isNothing;
4485
+ module.exports.isObject = isObject;
4486
+ module.exports.toArray = toArray;
4487
+ module.exports.repeat = repeat;
4488
+ module.exports.isNegativeZero = isNegativeZero;
4489
+ module.exports.extend = extend;
4490
+ }));
4491
+ var require_exception = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4492
+ function formatError(exception, compact) {
4493
+ let where = "";
4494
+ const message = exception.reason || "(unknown reason)";
4495
+ if (!exception.mark) return message;
4496
+ if (exception.mark.name) where += "in \"" + exception.mark.name + "\" ";
4497
+ where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
4498
+ if (!compact && exception.mark.snippet) where += "\n\n" + exception.mark.snippet;
4499
+ return message + " " + where;
4500
+ }
4501
+ function YAMLException(reason, mark) {
4502
+ Error.call(this);
4503
+ this.name = "YAMLException";
4504
+ this.reason = reason;
4505
+ this.mark = mark;
4506
+ this.message = formatError(this, false);
4507
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
4508
+ else this.stack = (/* @__PURE__ */ new Error()).stack || "";
4509
+ }
4510
+ YAMLException.prototype = Object.create(Error.prototype);
4511
+ YAMLException.prototype.constructor = YAMLException;
4512
+ YAMLException.prototype.toString = function toString(compact) {
4513
+ return this.name + ": " + formatError(this, compact);
4514
+ };
4515
+ module.exports = YAMLException;
4516
+ }));
4517
+ var require_snippet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4518
+ var common = require_common();
4519
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
4520
+ let head = "";
4521
+ let tail = "";
4522
+ const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
4523
+ if (position - lineStart > maxHalfLength) {
4524
+ head = " ... ";
4525
+ lineStart = position - maxHalfLength + head.length;
4526
+ }
4527
+ if (lineEnd - position > maxHalfLength) {
4528
+ tail = " ...";
4529
+ lineEnd = position + maxHalfLength - tail.length;
4530
+ }
4531
+ return {
4532
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
4533
+ pos: position - lineStart + head.length
4534
+ };
4535
+ }
4536
+ function padStart(string, max) {
4537
+ return common.repeat(" ", max - string.length) + string;
4538
+ }
4539
+ function makeSnippet(mark, options) {
4540
+ options = Object.create(options || null);
4541
+ if (!mark.buffer) return null;
4542
+ if (!options.maxLength) options.maxLength = 79;
4543
+ if (typeof options.indent !== "number") options.indent = 1;
4544
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
4545
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
4546
+ const re = /\r?\n|\r|\0/g;
4547
+ const lineStarts = [0];
4548
+ const lineEnds = [];
4549
+ let match;
4550
+ let foundLineNo = -1;
4551
+ while (match = re.exec(mark.buffer)) {
4552
+ lineEnds.push(match.index);
4553
+ lineStarts.push(match.index + match[0].length);
4554
+ if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
4555
+ }
4556
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
4557
+ let result = "";
4558
+ const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
4559
+ const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
4560
+ for (let i = 1; i <= options.linesBefore; i++) {
4561
+ if (foundLineNo - i < 0) break;
4562
+ const line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
4563
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
4564
+ }
4565
+ const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
4566
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
4567
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
4568
+ for (let i = 1; i <= options.linesAfter; i++) {
4569
+ if (foundLineNo + i >= lineEnds.length) break;
4570
+ const line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
4571
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
4572
+ }
4573
+ return result.replace(/\n$/, "");
4574
+ }
4575
+ module.exports = makeSnippet;
4576
+ }));
4577
+ var require_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4578
+ var YAMLException = require_exception();
4579
+ var TYPE_CONSTRUCTOR_OPTIONS = [
4580
+ "kind",
4581
+ "multi",
4582
+ "resolve",
4583
+ "construct",
4584
+ "instanceOf",
4585
+ "predicate",
4586
+ "represent",
4587
+ "representName",
4588
+ "defaultStyle",
4589
+ "styleAliases"
4590
+ ];
4591
+ var YAML_NODE_KINDS = [
4592
+ "scalar",
4593
+ "sequence",
4594
+ "mapping"
4595
+ ];
4596
+ function compileStyleAliases(map) {
4597
+ const result = {};
4598
+ if (map !== null) Object.keys(map).forEach(function(style) {
4599
+ map[style].forEach(function(alias) {
4600
+ result[String(alias)] = style;
4601
+ });
4602
+ });
4603
+ return result;
4604
+ }
4605
+ function Type(tag, options) {
4606
+ options = options || {};
4607
+ Object.keys(options).forEach(function(name) {
4608
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) throw new YAMLException("Unknown option \"" + name + "\" is met in definition of \"" + tag + "\" YAML type.");
4609
+ });
4610
+ this.options = options;
4611
+ this.tag = tag;
4612
+ this.kind = options["kind"] || null;
4613
+ this.resolve = options["resolve"] || function() {
4614
+ return true;
4615
+ };
4616
+ this.construct = options["construct"] || function(data) {
4617
+ return data;
4618
+ };
4619
+ this.instanceOf = options["instanceOf"] || null;
4620
+ this.predicate = options["predicate"] || null;
4621
+ this.represent = options["represent"] || null;
4622
+ this.representName = options["representName"] || null;
4623
+ this.defaultStyle = options["defaultStyle"] || null;
4624
+ this.multi = options["multi"] || false;
4625
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
4626
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) throw new YAMLException("Unknown kind \"" + this.kind + "\" is specified for \"" + tag + "\" YAML type.");
4627
+ }
4628
+ module.exports = Type;
4629
+ }));
4630
+ var require_schema = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4631
+ var YAMLException = require_exception();
4632
+ var Type = require_type();
4633
+ function compileList(schema, name) {
4634
+ const result = [];
4635
+ schema[name].forEach(function(currentType) {
4636
+ let newIndex = result.length;
4637
+ result.forEach(function(previousType, previousIndex) {
4638
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) newIndex = previousIndex;
4639
+ });
4640
+ result[newIndex] = currentType;
4641
+ });
4642
+ return result;
4643
+ }
4644
+ function compileMap() {
4645
+ const result = {
4646
+ scalar: {},
4647
+ sequence: {},
4648
+ mapping: {},
4649
+ fallback: {},
4650
+ multi: {
4651
+ scalar: [],
4652
+ sequence: [],
4653
+ mapping: [],
4654
+ fallback: []
4655
+ }
4656
+ };
4657
+ function collectType(type) {
4658
+ if (type.multi) {
4659
+ result.multi[type.kind].push(type);
4660
+ result.multi["fallback"].push(type);
4661
+ } else result[type.kind][type.tag] = result["fallback"][type.tag] = type;
4662
+ }
4663
+ for (let index = 0, length = arguments.length; index < length; index += 1) arguments[index].forEach(collectType);
4664
+ return result;
4665
+ }
4666
+ function Schema(definition) {
4667
+ return this.extend(definition);
4668
+ }
4669
+ Schema.prototype.extend = function extend(definition) {
4670
+ let implicit = [];
4671
+ let explicit = [];
4672
+ if (definition instanceof Type) explicit.push(definition);
4673
+ else if (Array.isArray(definition)) explicit = explicit.concat(definition);
4674
+ else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
4675
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
4676
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
4677
+ } else throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
4678
+ implicit.forEach(function(type) {
4679
+ if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
4680
+ 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.");
4681
+ 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.");
4682
+ });
4683
+ explicit.forEach(function(type) {
4684
+ if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
4685
+ });
4686
+ const result = Object.create(Schema.prototype);
4687
+ result.implicit = (this.implicit || []).concat(implicit);
4688
+ result.explicit = (this.explicit || []).concat(explicit);
4689
+ result.compiledImplicit = compileList(result, "implicit");
4690
+ result.compiledExplicit = compileList(result, "explicit");
4691
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
4692
+ return result;
4693
+ };
4694
+ module.exports = Schema;
4695
+ }));
4696
+ var require_str = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4697
+ module.exports = new (require_type())("tag:yaml.org,2002:str", {
4698
+ kind: "scalar",
4699
+ construct: function(data) {
4700
+ return data !== null ? data : "";
4701
+ }
4702
+ });
4703
+ }));
4704
+ var require_seq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4705
+ module.exports = new (require_type())("tag:yaml.org,2002:seq", {
4706
+ kind: "sequence",
4707
+ construct: function(data) {
4708
+ return data !== null ? data : [];
4709
+ }
4710
+ });
4711
+ }));
4712
+ var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4713
+ module.exports = new (require_type())("tag:yaml.org,2002:map", {
4714
+ kind: "mapping",
4715
+ construct: function(data) {
4716
+ return data !== null ? data : {};
4717
+ }
4718
+ });
4719
+ }));
4720
+ var require_failsafe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4721
+ module.exports = new (require_schema())({ explicit: [
4722
+ require_str(),
4723
+ require_seq(),
4724
+ require_map()
4725
+ ] });
4726
+ }));
4727
+ var require_null = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4728
+ var Type = require_type();
4729
+ function resolveYamlNull(data) {
4730
+ if (data === null) return true;
4731
+ const max = data.length;
4732
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
4733
+ }
4734
+ function constructYamlNull() {
4735
+ return null;
4736
+ }
4737
+ function isNull(object) {
4738
+ return object === null;
4739
+ }
4740
+ module.exports = new Type("tag:yaml.org,2002:null", {
4741
+ kind: "scalar",
4742
+ resolve: resolveYamlNull,
4743
+ construct: constructYamlNull,
4744
+ predicate: isNull,
4745
+ represent: {
4746
+ canonical: function() {
4747
+ return "~";
4748
+ },
4749
+ lowercase: function() {
4750
+ return "null";
4751
+ },
4752
+ uppercase: function() {
4753
+ return "NULL";
4754
+ },
4755
+ camelcase: function() {
4756
+ return "Null";
4757
+ },
4758
+ empty: function() {
4759
+ return "";
4760
+ }
4761
+ },
4762
+ defaultStyle: "lowercase"
4763
+ });
4764
+ }));
4765
+ var require_bool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4766
+ var Type = require_type();
4767
+ function resolveYamlBoolean(data) {
4768
+ if (data === null) return false;
4769
+ const max = data.length;
4770
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
4771
+ }
4772
+ function constructYamlBoolean(data) {
4773
+ return data === "true" || data === "True" || data === "TRUE";
4774
+ }
4775
+ function isBoolean(object) {
4776
+ return Object.prototype.toString.call(object) === "[object Boolean]";
4777
+ }
4778
+ module.exports = new Type("tag:yaml.org,2002:bool", {
4779
+ kind: "scalar",
4780
+ resolve: resolveYamlBoolean,
4781
+ construct: constructYamlBoolean,
4782
+ predicate: isBoolean,
4783
+ represent: {
4784
+ lowercase: function(object) {
4785
+ return object ? "true" : "false";
4786
+ },
4787
+ uppercase: function(object) {
4788
+ return object ? "TRUE" : "FALSE";
4789
+ },
4790
+ camelcase: function(object) {
4791
+ return object ? "True" : "False";
4792
+ }
4793
+ },
4794
+ defaultStyle: "lowercase"
4795
+ });
4796
+ }));
4797
+ var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4798
+ var common = require_common();
4799
+ var Type = require_type();
4800
+ function isHexCode(c) {
4801
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
4802
+ }
4803
+ function isOctCode(c) {
4804
+ return c >= 48 && c <= 55;
4805
+ }
4806
+ function isDecCode(c) {
4807
+ return c >= 48 && c <= 57;
4808
+ }
4809
+ function resolveYamlInteger(data) {
4810
+ if (data === null) return false;
4811
+ const max = data.length;
4812
+ let index = 0;
4813
+ let hasDigits = false;
4814
+ if (!max) return false;
4815
+ let ch = data[index];
4816
+ if (ch === "-" || ch === "+") ch = data[++index];
4817
+ if (ch === "0") {
4818
+ if (index + 1 === max) return true;
4819
+ ch = data[++index];
4820
+ if (ch === "b") {
4821
+ index++;
4822
+ for (; index < max; index++) {
4823
+ ch = data[index];
4824
+ if (ch !== "0" && ch !== "1") return false;
4825
+ hasDigits = true;
4826
+ }
4827
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
4828
+ }
4829
+ if (ch === "x") {
4830
+ index++;
4831
+ for (; index < max; index++) {
4832
+ if (!isHexCode(data.charCodeAt(index))) return false;
4833
+ hasDigits = true;
4834
+ }
4835
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
4836
+ }
4837
+ if (ch === "o") {
4838
+ index++;
4839
+ for (; index < max; index++) {
4840
+ if (!isOctCode(data.charCodeAt(index))) return false;
4841
+ hasDigits = true;
4842
+ }
4843
+ return hasDigits && Number.isFinite(parseYamlInteger(data));
4844
+ }
4845
+ }
4846
+ for (; index < max; index++) {
4847
+ if (!isDecCode(data.charCodeAt(index))) return false;
4848
+ hasDigits = true;
4849
+ }
4850
+ if (!hasDigits) return false;
4851
+ return Number.isFinite(parseYamlInteger(data));
4852
+ }
4853
+ function parseYamlInteger(data) {
4854
+ let value = data;
4855
+ let sign = 1;
4856
+ let ch = value[0];
4857
+ if (ch === "-" || ch === "+") {
4858
+ if (ch === "-") sign = -1;
4859
+ value = value.slice(1);
4860
+ ch = value[0];
4861
+ }
4862
+ if (value === "0") return 0;
4863
+ if (ch === "0") {
4864
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
4865
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
4866
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
4867
+ }
4868
+ return sign * parseInt(value, 10);
4869
+ }
4870
+ function constructYamlInteger(data) {
4871
+ return parseYamlInteger(data);
4872
+ }
4873
+ function isInteger(object) {
4874
+ return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
4875
+ }
4876
+ module.exports = new Type("tag:yaml.org,2002:int", {
4877
+ kind: "scalar",
4878
+ resolve: resolveYamlInteger,
4879
+ construct: constructYamlInteger,
4880
+ predicate: isInteger,
4881
+ represent: {
4882
+ binary: function(obj) {
4883
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
4884
+ },
4885
+ octal: function(obj) {
4886
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
4887
+ },
4888
+ decimal: function(obj) {
4889
+ return obj.toString(10);
4890
+ },
4891
+ hexadecimal: function(obj) {
4892
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
4893
+ }
4894
+ },
4895
+ defaultStyle: "decimal",
4896
+ styleAliases: {
4897
+ binary: [2, "bin"],
4898
+ octal: [8, "oct"],
4899
+ decimal: [10, "dec"],
4900
+ hexadecimal: [16, "hex"]
4901
+ }
4902
+ });
4903
+ }));
4904
+ var require_float = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4905
+ var common = require_common();
4906
+ var Type = require_type();
4907
+ 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))$");
4908
+ var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4909
+ function resolveYamlFloat(data) {
4910
+ if (data === null) return false;
4911
+ if (!YAML_FLOAT_PATTERN.test(data)) return false;
4912
+ if (Number.isFinite(parseFloat(data, 10))) return true;
4913
+ return YAML_FLOAT_SPECIAL_PATTERN.test(data);
4914
+ }
4915
+ function constructYamlFloat(data) {
4916
+ let value = data.toLowerCase();
4917
+ const sign = value[0] === "-" ? -1 : 1;
4918
+ if ("+-".indexOf(value[0]) >= 0) value = value.slice(1);
4919
+ if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
4920
+ else if (value === ".nan") return NaN;
4921
+ return sign * parseFloat(value, 10);
4922
+ }
4923
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
4924
+ function representYamlFloat(object, style) {
4925
+ if (isNaN(object)) switch (style) {
4926
+ case "lowercase": return ".nan";
4927
+ case "uppercase": return ".NAN";
4928
+ case "camelcase": return ".NaN";
4929
+ }
4930
+ else if (Number.POSITIVE_INFINITY === object) switch (style) {
4931
+ case "lowercase": return ".inf";
4932
+ case "uppercase": return ".INF";
4933
+ case "camelcase": return ".Inf";
4934
+ }
4935
+ else if (Number.NEGATIVE_INFINITY === object) switch (style) {
4936
+ case "lowercase": return "-.inf";
4937
+ case "uppercase": return "-.INF";
4938
+ case "camelcase": return "-.Inf";
4939
+ }
4940
+ else if (common.isNegativeZero(object)) return "-0.0";
4941
+ const res = object.toString(10);
4942
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
4943
+ }
4944
+ function isFloat(object) {
4945
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
4946
+ }
4947
+ module.exports = new Type("tag:yaml.org,2002:float", {
4948
+ kind: "scalar",
4949
+ resolve: resolveYamlFloat,
4950
+ construct: constructYamlFloat,
4951
+ predicate: isFloat,
4952
+ represent: representYamlFloat,
4953
+ defaultStyle: "lowercase"
4954
+ });
4955
+ }));
4956
+ var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4957
+ module.exports = require_failsafe().extend({ implicit: [
4958
+ require_null(),
4959
+ require_bool(),
4960
+ require_int(),
4961
+ require_float()
4962
+ ] });
4963
+ }));
4964
+ var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4965
+ module.exports = require_json();
4966
+ }));
4967
+ var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4968
+ var Type = require_type();
4969
+ var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
4970
+ 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]))?))?$");
4971
+ function resolveYamlTimestamp(data) {
4972
+ if (data === null) return false;
4973
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
4974
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
4975
+ return false;
4976
+ }
4977
+ function constructYamlTimestamp(data) {
4978
+ let fraction = 0;
4979
+ let delta = null;
4980
+ let match = YAML_DATE_REGEXP.exec(data);
4981
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
4982
+ if (match === null) throw new Error("Date resolve error");
4983
+ const year = +match[1];
4984
+ const month = +match[2] - 1;
4985
+ const day = +match[3];
4986
+ if (!match[4]) return new Date(Date.UTC(year, month, day));
4987
+ const hour = +match[4];
4988
+ const minute = +match[5];
4989
+ const second = +match[6];
4990
+ if (match[7]) {
4991
+ fraction = match[7].slice(0, 3);
4992
+ while (fraction.length < 3) fraction += "0";
4993
+ fraction = +fraction;
4994
+ }
4995
+ if (match[9]) {
4996
+ const tzHour = +match[10];
4997
+ const tzMinute = +(match[11] || 0);
4998
+ delta = (tzHour * 60 + tzMinute) * 6e4;
4999
+ if (match[9] === "-") delta = -delta;
5000
+ }
5001
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
5002
+ if (delta) date.setTime(date.getTime() - delta);
5003
+ return date;
5004
+ }
5005
+ function representYamlTimestamp(object) {
5006
+ return object.toISOString();
5007
+ }
5008
+ module.exports = new Type("tag:yaml.org,2002:timestamp", {
5009
+ kind: "scalar",
5010
+ resolve: resolveYamlTimestamp,
5011
+ construct: constructYamlTimestamp,
5012
+ instanceOf: Date,
5013
+ represent: representYamlTimestamp
5014
+ });
5015
+ }));
5016
+ var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5017
+ var Type = require_type();
5018
+ function resolveYamlMerge(data) {
5019
+ return data === "<<" || data === null;
5020
+ }
5021
+ module.exports = new Type("tag:yaml.org,2002:merge", {
5022
+ kind: "scalar",
5023
+ resolve: resolveYamlMerge
5024
+ });
5025
+ }));
5026
+ var require_binary = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5027
+ var Type = require_type();
5028
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
5029
+ function resolveYamlBinary(data) {
5030
+ if (data === null) return false;
5031
+ let bitlen = 0;
5032
+ const max = data.length;
5033
+ const map = BASE64_MAP;
5034
+ for (let idx = 0; idx < max; idx++) {
5035
+ const code = map.indexOf(data.charAt(idx));
5036
+ if (code > 64) continue;
5037
+ if (code < 0) return false;
5038
+ bitlen += 6;
5039
+ }
5040
+ return bitlen % 8 === 0;
5041
+ }
5042
+ function constructYamlBinary(data) {
5043
+ const input = data.replace(/[\r\n=]/g, "");
5044
+ const max = input.length;
5045
+ const map = BASE64_MAP;
5046
+ let bits = 0;
5047
+ const result = [];
5048
+ for (let idx = 0; idx < max; idx++) {
5049
+ if (idx % 4 === 0 && idx) {
5050
+ result.push(bits >> 16 & 255);
5051
+ result.push(bits >> 8 & 255);
5052
+ result.push(bits & 255);
5053
+ }
5054
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
5055
+ }
5056
+ const tailbits = max % 4 * 6;
5057
+ if (tailbits === 0) {
5058
+ result.push(bits >> 16 & 255);
5059
+ result.push(bits >> 8 & 255);
5060
+ result.push(bits & 255);
5061
+ } else if (tailbits === 18) {
5062
+ result.push(bits >> 10 & 255);
5063
+ result.push(bits >> 2 & 255);
5064
+ } else if (tailbits === 12) result.push(bits >> 4 & 255);
5065
+ return new Uint8Array(result);
5066
+ }
5067
+ function representYamlBinary(object) {
5068
+ let result = "";
5069
+ let bits = 0;
5070
+ const max = object.length;
5071
+ const map = BASE64_MAP;
5072
+ for (let idx = 0; idx < max; idx++) {
5073
+ if (idx % 3 === 0 && idx) {
5074
+ result += map[bits >> 18 & 63];
5075
+ result += map[bits >> 12 & 63];
5076
+ result += map[bits >> 6 & 63];
5077
+ result += map[bits & 63];
5078
+ }
5079
+ bits = (bits << 8) + object[idx];
5080
+ }
5081
+ const tail = max % 3;
5082
+ if (tail === 0) {
5083
+ result += map[bits >> 18 & 63];
5084
+ result += map[bits >> 12 & 63];
5085
+ result += map[bits >> 6 & 63];
5086
+ result += map[bits & 63];
5087
+ } else if (tail === 2) {
5088
+ result += map[bits >> 10 & 63];
5089
+ result += map[bits >> 4 & 63];
5090
+ result += map[bits << 2 & 63];
5091
+ result += map[64];
5092
+ } else if (tail === 1) {
5093
+ result += map[bits >> 2 & 63];
5094
+ result += map[bits << 4 & 63];
5095
+ result += map[64];
5096
+ result += map[64];
5097
+ }
5098
+ return result;
5099
+ }
5100
+ function isBinary(obj) {
5101
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
5102
+ }
5103
+ module.exports = new Type("tag:yaml.org,2002:binary", {
5104
+ kind: "scalar",
5105
+ resolve: resolveYamlBinary,
5106
+ construct: constructYamlBinary,
5107
+ predicate: isBinary,
5108
+ represent: representYamlBinary
5109
+ });
5110
+ }));
5111
+ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5112
+ var Type = require_type();
5113
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
5114
+ var _toString = Object.prototype.toString;
5115
+ function resolveYamlOmap(data) {
5116
+ if (data === null) return true;
5117
+ const objectKeys = [];
5118
+ const object = data;
5119
+ for (let index = 0, length = object.length; index < length; index += 1) {
5120
+ const pair = object[index];
5121
+ let pairHasKey = false;
5122
+ if (_toString.call(pair) !== "[object Object]") return false;
5123
+ let pairKey;
5124
+ for (pairKey in pair) if (_hasOwnProperty.call(pair, pairKey)) if (!pairHasKey) pairHasKey = true;
5125
+ else return false;
5126
+ if (!pairHasKey) return false;
5127
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
5128
+ else return false;
5129
+ }
5130
+ return true;
5131
+ }
5132
+ function constructYamlOmap(data) {
5133
+ return data !== null ? data : [];
5134
+ }
5135
+ module.exports = new Type("tag:yaml.org,2002:omap", {
5136
+ kind: "sequence",
5137
+ resolve: resolveYamlOmap,
5138
+ construct: constructYamlOmap
5139
+ });
5140
+ }));
5141
+ var require_pairs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5142
+ var Type = require_type();
5143
+ var _toString = Object.prototype.toString;
5144
+ function resolveYamlPairs(data) {
5145
+ if (data === null) return true;
5146
+ const object = data;
5147
+ const result = new Array(object.length);
5148
+ for (let index = 0, length = object.length; index < length; index += 1) {
5149
+ const pair = object[index];
5150
+ if (_toString.call(pair) !== "[object Object]") return false;
5151
+ const keys = Object.keys(pair);
5152
+ if (keys.length !== 1) return false;
5153
+ result[index] = [keys[0], pair[keys[0]]];
5154
+ }
5155
+ return true;
5156
+ }
5157
+ function constructYamlPairs(data) {
5158
+ if (data === null) return [];
5159
+ const object = data;
5160
+ const result = new Array(object.length);
5161
+ for (let index = 0, length = object.length; index < length; index += 1) {
5162
+ const pair = object[index];
5163
+ const keys = Object.keys(pair);
5164
+ result[index] = [keys[0], pair[keys[0]]];
5165
+ }
5166
+ return result;
5167
+ }
5168
+ module.exports = new Type("tag:yaml.org,2002:pairs", {
5169
+ kind: "sequence",
5170
+ resolve: resolveYamlPairs,
5171
+ construct: constructYamlPairs
5172
+ });
5173
+ }));
5174
+ var require_set = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5175
+ var Type = require_type();
5176
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
5177
+ function resolveYamlSet(data) {
5178
+ if (data === null) return true;
5179
+ const object = data;
5180
+ for (const key in object) if (_hasOwnProperty.call(object, key)) {
5181
+ if (object[key] !== null) return false;
5182
+ }
5183
+ return true;
5184
+ }
5185
+ function constructYamlSet(data) {
5186
+ return data !== null ? data : {};
5187
+ }
5188
+ module.exports = new Type("tag:yaml.org,2002:set", {
5189
+ kind: "mapping",
5190
+ resolve: resolveYamlSet,
5191
+ construct: constructYamlSet
5192
+ });
5193
+ }));
5194
+ var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5195
+ module.exports = require_core().extend({
5196
+ implicit: [require_timestamp(), require_merge()],
5197
+ explicit: [
5198
+ require_binary(),
5199
+ require_omap(),
5200
+ require_pairs(),
5201
+ require_set()
5202
+ ]
5203
+ });
5204
+ }));
5205
+ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5206
+ var common = require_common();
5207
+ var YAMLException = require_exception();
5208
+ var makeSnippet = require_snippet();
5209
+ var DEFAULT_SCHEMA = require_default();
5210
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
5211
+ var CONTEXT_FLOW_IN = 1;
5212
+ var CONTEXT_FLOW_OUT = 2;
5213
+ var CONTEXT_BLOCK_IN = 3;
5214
+ var CONTEXT_BLOCK_OUT = 4;
5215
+ var CHOMPING_CLIP = 1;
5216
+ var CHOMPING_STRIP = 2;
5217
+ var CHOMPING_KEEP = 3;
5218
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
5219
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
5220
+ var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
5221
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
5222
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
5223
+ function _class(obj) {
5224
+ return Object.prototype.toString.call(obj);
5225
+ }
5226
+ function isEol(c) {
5227
+ return c === 10 || c === 13;
5228
+ }
5229
+ function isWhiteSpace(c) {
5230
+ return c === 9 || c === 32;
5231
+ }
5232
+ function isWsOrEol(c) {
5233
+ return c === 9 || c === 32 || c === 10 || c === 13;
5234
+ }
5235
+ function isFlowIndicator(c) {
5236
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
5237
+ }
5238
+ function fromHexCode(c) {
5239
+ if (c >= 48 && c <= 57) return c - 48;
5240
+ const lc = c | 32;
5241
+ if (lc >= 97 && lc <= 102) return lc - 97 + 10;
5242
+ return -1;
5243
+ }
5244
+ function escapedHexLen(c) {
5245
+ if (c === 120) return 2;
5246
+ if (c === 117) return 4;
5247
+ if (c === 85) return 8;
5248
+ return 0;
5249
+ }
5250
+ function fromDecimalCode(c) {
5251
+ if (c >= 48 && c <= 57) return c - 48;
5252
+ return -1;
5253
+ }
5254
+ function simpleEscapeSequence(c) {
5255
+ switch (c) {
5256
+ case 48: return "\0";
5257
+ case 97: return "\x07";
5258
+ case 98: return "\b";
5259
+ case 116: return " ";
5260
+ case 9: return " ";
5261
+ case 110: return "\n";
5262
+ case 118: return "\v";
5263
+ case 102: return "\f";
5264
+ case 114: return "\r";
5265
+ case 101: return "\x1B";
5266
+ case 32: return " ";
5267
+ case 34: return "\"";
5268
+ case 47: return "/";
5269
+ case 92: return "\\";
5270
+ case 78: return "…";
5271
+ case 95: return "\xA0";
5272
+ case 76: return "\u2028";
5273
+ case 80: return "\u2029";
5274
+ default: return "";
5275
+ }
5276
+ }
5277
+ function charFromCodepoint(c) {
5278
+ if (c <= 65535) return String.fromCharCode(c);
5279
+ return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
5280
+ }
5281
+ function setProperty(object, key, value) {
5282
+ if (key === "__proto__") Object.defineProperty(object, key, {
5283
+ configurable: true,
5284
+ enumerable: true,
5285
+ writable: true,
5286
+ value
5287
+ });
5288
+ else object[key] = value;
5289
+ }
5290
+ var simpleEscapeCheck = new Array(256);
5291
+ var simpleEscapeMap = new Array(256);
5292
+ for (let i = 0; i < 256; i++) {
5293
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
5294
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
5295
+ }
5296
+ function State(input, options) {
5297
+ this.input = input;
5298
+ this.filename = options["filename"] || null;
5299
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
5300
+ this.onWarning = options["onWarning"] || null;
5301
+ this.legacy = options["legacy"] || false;
5302
+ this.json = options["json"] || false;
5303
+ this.listener = options["listener"] || null;
5304
+ this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
5305
+ this.maxMergeSeqLength = typeof options["maxMergeSeqLength"] === "number" ? options["maxMergeSeqLength"] : 20;
5306
+ this.implicitTypes = this.schema.compiledImplicit;
5307
+ this.typeMap = this.schema.compiledTypeMap;
5308
+ this.length = input.length;
5309
+ this.position = 0;
5310
+ this.line = 0;
5311
+ this.lineStart = 0;
5312
+ this.lineIndent = 0;
5313
+ this.depth = 0;
5314
+ this.firstTabInLine = -1;
5315
+ this.documents = [];
5316
+ this.anchorMapTransactions = [];
5317
+ }
5318
+ function generateError(state, message) {
5319
+ const mark = {
5320
+ name: state.filename,
5321
+ buffer: state.input.slice(0, -1),
5322
+ position: state.position,
5323
+ line: state.line,
5324
+ column: state.position - state.lineStart
5325
+ };
5326
+ mark.snippet = makeSnippet(mark);
5327
+ return new YAMLException(message, mark);
5328
+ }
5329
+ function throwError(state, message) {
5330
+ throw generateError(state, message);
5331
+ }
5332
+ function throwWarning(state, message) {
5333
+ if (state.onWarning) state.onWarning.call(null, generateError(state, message));
5334
+ }
5335
+ function storeAnchor(state, name, value) {
5336
+ const transactions = state.anchorMapTransactions;
5337
+ if (transactions.length !== 0) {
5338
+ const transaction = transactions[transactions.length - 1];
5339
+ if (!_hasOwnProperty.call(transaction, name)) transaction[name] = {
5340
+ existed: _hasOwnProperty.call(state.anchorMap, name),
5341
+ value: state.anchorMap[name]
5342
+ };
5343
+ }
5344
+ state.anchorMap[name] = value;
5345
+ }
5346
+ function beginAnchorTransaction(state) {
5347
+ state.anchorMapTransactions.push(Object.create(null));
5348
+ }
5349
+ function commitAnchorTransaction(state) {
5350
+ const transaction = state.anchorMapTransactions.pop();
5351
+ const transactions = state.anchorMapTransactions;
5352
+ if (transactions.length === 0) return;
5353
+ const parent = transactions[transactions.length - 1];
5354
+ const names = Object.keys(transaction);
5355
+ for (let index = 0, length = names.length; index < length; index += 1) {
5356
+ const name = names[index];
5357
+ if (!_hasOwnProperty.call(parent, name)) parent[name] = transaction[name];
5358
+ }
5359
+ }
5360
+ function rollbackAnchorTransaction(state) {
5361
+ const transaction = state.anchorMapTransactions.pop();
5362
+ const names = Object.keys(transaction);
5363
+ for (let index = names.length - 1; index >= 0; index -= 1) {
5364
+ const entry = transaction[names[index]];
5365
+ if (entry.existed) state.anchorMap[names[index]] = entry.value;
5366
+ else delete state.anchorMap[names[index]];
5367
+ }
5368
+ }
5369
+ function snapshotState(state) {
5370
+ return {
5371
+ position: state.position,
5372
+ line: state.line,
5373
+ lineStart: state.lineStart,
5374
+ lineIndent: state.lineIndent,
5375
+ firstTabInLine: state.firstTabInLine,
5376
+ tag: state.tag,
5377
+ anchor: state.anchor,
5378
+ kind: state.kind,
5379
+ result: state.result
5380
+ };
5381
+ }
5382
+ function restoreState(state, snapshot) {
5383
+ state.position = snapshot.position;
5384
+ state.line = snapshot.line;
5385
+ state.lineStart = snapshot.lineStart;
5386
+ state.lineIndent = snapshot.lineIndent;
5387
+ state.firstTabInLine = snapshot.firstTabInLine;
5388
+ state.tag = snapshot.tag;
5389
+ state.anchor = snapshot.anchor;
5390
+ state.kind = snapshot.kind;
5391
+ state.result = snapshot.result;
5392
+ }
5393
+ var directiveHandlers = {
5394
+ YAML: function handleYamlDirective(state, name, args) {
5395
+ if (state.version !== null) throwError(state, "duplication of %YAML directive");
5396
+ if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
5397
+ const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
5398
+ if (match === null) throwError(state, "ill-formed argument of the YAML directive");
5399
+ const major = parseInt(match[1], 10);
5400
+ const minor = parseInt(match[2], 10);
5401
+ if (major !== 1) throwError(state, "unacceptable YAML version of the document");
5402
+ state.version = args[0];
5403
+ state.checkLineBreaks = minor < 2;
5404
+ if (minor !== 1 && minor !== 2) throwWarning(state, "unsupported YAML version of the document");
5405
+ },
5406
+ TAG: function handleTagDirective(state, name, args) {
5407
+ let prefix;
5408
+ if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
5409
+ const handle = args[0];
5410
+ prefix = args[1];
5411
+ if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
5412
+ if (_hasOwnProperty.call(state.tagMap, handle)) throwError(state, "there is a previously declared suffix for \"" + handle + "\" tag handle");
5413
+ if (!PATTERN_TAG_URI.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
5414
+ try {
5415
+ prefix = decodeURIComponent(prefix);
5416
+ } catch (err) {
5417
+ throwError(state, "tag prefix is malformed: " + prefix);
5418
+ }
5419
+ state.tagMap[handle] = prefix;
5420
+ }
5421
+ };
5422
+ function captureSegment(state, start, end, checkJson) {
5423
+ if (start < end) {
5424
+ const _result = state.input.slice(start, end);
5425
+ if (checkJson) for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
5426
+ const _character = _result.charCodeAt(_position);
5427
+ if (!(_character === 9 || _character >= 32 && _character <= 1114111)) throwError(state, "expected valid JSON character");
5428
+ }
5429
+ else if (PATTERN_NON_PRINTABLE.test(_result)) throwError(state, "the stream contains non-printable characters");
5430
+ state.result += _result;
5431
+ }
5432
+ }
5433
+ function mergeMappings(state, destination, source, overridableKeys) {
5434
+ if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
5435
+ const sourceKeys = Object.keys(source);
5436
+ for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
5437
+ const key = sourceKeys[index];
5438
+ if (!_hasOwnProperty.call(destination, key)) {
5439
+ setProperty(destination, key, source[key]);
5440
+ overridableKeys[key] = true;
5441
+ }
5442
+ }
5443
+ }
5444
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
5445
+ if (Array.isArray(keyNode)) {
5446
+ keyNode = Array.prototype.slice.call(keyNode);
5447
+ for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
5448
+ if (Array.isArray(keyNode[index])) throwError(state, "nested arrays are not supported inside keys");
5449
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") keyNode[index] = "[object Object]";
5450
+ }
5451
+ }
5452
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") keyNode = "[object Object]";
5453
+ keyNode = String(keyNode);
5454
+ if (_result === null) _result = {};
5455
+ if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) {
5456
+ if (valueNode.length > state.maxMergeSeqLength) throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
5457
+ const seen = /* @__PURE__ */ new Set();
5458
+ for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
5459
+ const src = valueNode[index];
5460
+ if (seen.has(src)) continue;
5461
+ seen.add(src);
5462
+ mergeMappings(state, _result, src, overridableKeys);
5463
+ }
5464
+ } else mergeMappings(state, _result, valueNode, overridableKeys);
5465
+ else {
5466
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
5467
+ state.line = startLine || state.line;
5468
+ state.lineStart = startLineStart || state.lineStart;
5469
+ state.position = startPos || state.position;
5470
+ throwError(state, "duplicated mapping key");
5471
+ }
5472
+ setProperty(_result, keyNode, valueNode);
5473
+ delete overridableKeys[keyNode];
5474
+ }
5475
+ return _result;
5476
+ }
5477
+ function readLineBreak(state) {
5478
+ const ch = state.input.charCodeAt(state.position);
5479
+ if (ch === 10) state.position++;
5480
+ else if (ch === 13) {
5481
+ state.position++;
5482
+ if (state.input.charCodeAt(state.position) === 10) state.position++;
5483
+ } else throwError(state, "a line break is expected");
5484
+ state.line += 1;
5485
+ state.lineStart = state.position;
5486
+ state.firstTabInLine = -1;
5487
+ }
5488
+ function skipSeparationSpace(state, allowComments, checkIndent) {
5489
+ let lineBreaks = 0;
5490
+ let ch = state.input.charCodeAt(state.position);
5491
+ while (ch !== 0) {
5492
+ while (isWhiteSpace(ch)) {
5493
+ if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
5494
+ ch = state.input.charCodeAt(++state.position);
5495
+ }
5496
+ if (allowComments && ch === 35) do
5497
+ ch = state.input.charCodeAt(++state.position);
5498
+ while (ch !== 10 && ch !== 13 && ch !== 0);
5499
+ if (isEol(ch)) {
5500
+ readLineBreak(state);
5501
+ ch = state.input.charCodeAt(state.position);
5502
+ lineBreaks++;
5503
+ state.lineIndent = 0;
5504
+ while (ch === 32) {
5505
+ state.lineIndent++;
5506
+ ch = state.input.charCodeAt(++state.position);
5507
+ }
5508
+ } else break;
5509
+ }
5510
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) throwWarning(state, "deficient indentation");
5511
+ return lineBreaks;
5512
+ }
5513
+ function testDocumentSeparator(state) {
5514
+ let _position = state.position;
5515
+ let ch = state.input.charCodeAt(_position);
5516
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
5517
+ _position += 3;
5518
+ ch = state.input.charCodeAt(_position);
5519
+ if (ch === 0 || isWsOrEol(ch)) return true;
5520
+ }
5521
+ return false;
5522
+ }
5523
+ function writeFoldedLines(state, count) {
5524
+ if (count === 1) state.result += " ";
5525
+ else if (count > 1) state.result += common.repeat("\n", count - 1);
5526
+ }
5527
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
5528
+ let captureStart;
5529
+ let captureEnd;
5530
+ let hasPendingContent;
5531
+ let _line;
5532
+ let _lineStart;
5533
+ let _lineIndent;
5534
+ const _kind = state.kind;
5535
+ const _result = state.result;
5536
+ let ch = state.input.charCodeAt(state.position);
5537
+ 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;
5538
+ if (ch === 63 || ch === 45) {
5539
+ const following = state.input.charCodeAt(state.position + 1);
5540
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) return false;
5541
+ }
5542
+ state.kind = "scalar";
5543
+ state.result = "";
5544
+ captureStart = captureEnd = state.position;
5545
+ hasPendingContent = false;
5546
+ while (ch !== 0) {
5547
+ if (ch === 58) {
5548
+ const following = state.input.charCodeAt(state.position + 1);
5549
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) break;
5550
+ } else if (ch === 35) {
5551
+ if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
5552
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) break;
5553
+ else if (isEol(ch)) {
5554
+ _line = state.line;
5555
+ _lineStart = state.lineStart;
5556
+ _lineIndent = state.lineIndent;
5557
+ skipSeparationSpace(state, false, -1);
5558
+ if (state.lineIndent >= nodeIndent) {
5559
+ hasPendingContent = true;
5560
+ ch = state.input.charCodeAt(state.position);
5561
+ continue;
5562
+ } else {
5563
+ state.position = captureEnd;
5564
+ state.line = _line;
5565
+ state.lineStart = _lineStart;
5566
+ state.lineIndent = _lineIndent;
5567
+ break;
5568
+ }
5569
+ }
5570
+ if (hasPendingContent) {
5571
+ captureSegment(state, captureStart, captureEnd, false);
5572
+ writeFoldedLines(state, state.line - _line);
5573
+ captureStart = captureEnd = state.position;
5574
+ hasPendingContent = false;
5575
+ }
5576
+ if (!isWhiteSpace(ch)) captureEnd = state.position + 1;
5577
+ ch = state.input.charCodeAt(++state.position);
5578
+ }
5579
+ captureSegment(state, captureStart, captureEnd, false);
5580
+ if (state.result) return true;
5581
+ state.kind = _kind;
5582
+ state.result = _result;
5583
+ return false;
5584
+ }
5585
+ function readSingleQuotedScalar(state, nodeIndent) {
5586
+ let captureStart;
5587
+ let captureEnd;
5588
+ let ch = state.input.charCodeAt(state.position);
5589
+ if (ch !== 39) return false;
5590
+ state.kind = "scalar";
5591
+ state.result = "";
5592
+ state.position++;
5593
+ captureStart = captureEnd = state.position;
5594
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 39) {
5595
+ captureSegment(state, captureStart, state.position, true);
5596
+ ch = state.input.charCodeAt(++state.position);
5597
+ if (ch === 39) {
5598
+ captureStart = state.position;
5599
+ state.position++;
5600
+ captureEnd = state.position;
5601
+ } else return true;
5602
+ } else if (isEol(ch)) {
5603
+ captureSegment(state, captureStart, captureEnd, true);
5604
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
5605
+ captureStart = captureEnd = state.position;
5606
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
5607
+ else {
5608
+ state.position++;
5609
+ if (!isWhiteSpace(ch)) captureEnd = state.position;
5610
+ }
5611
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
5612
+ }
5613
+ function readDoubleQuotedScalar(state, nodeIndent) {
5614
+ let captureStart;
5615
+ let captureEnd;
5616
+ let tmp;
5617
+ let ch = state.input.charCodeAt(state.position);
5618
+ if (ch !== 34) return false;
5619
+ state.kind = "scalar";
5620
+ state.result = "";
5621
+ state.position++;
5622
+ captureStart = captureEnd = state.position;
5623
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 34) {
5624
+ captureSegment(state, captureStart, state.position, true);
5625
+ state.position++;
5626
+ return true;
5627
+ } else if (ch === 92) {
5628
+ captureSegment(state, captureStart, state.position, true);
5629
+ ch = state.input.charCodeAt(++state.position);
5630
+ if (isEol(ch)) skipSeparationSpace(state, false, nodeIndent);
5631
+ else if (ch < 256 && simpleEscapeCheck[ch]) {
5632
+ state.result += simpleEscapeMap[ch];
5633
+ state.position++;
5634
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
5635
+ let hexLength = tmp;
5636
+ let hexResult = 0;
5637
+ for (; hexLength > 0; hexLength--) {
5638
+ ch = state.input.charCodeAt(++state.position);
5639
+ if ((tmp = fromHexCode(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
5640
+ else throwError(state, "expected hexadecimal character");
5641
+ }
5642
+ state.result += charFromCodepoint(hexResult);
5643
+ state.position++;
5644
+ } else throwError(state, "unknown escape sequence");
5645
+ captureStart = captureEnd = state.position;
5646
+ } else if (isEol(ch)) {
5647
+ captureSegment(state, captureStart, captureEnd, true);
5648
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
5649
+ captureStart = captureEnd = state.position;
5650
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
5651
+ else {
5652
+ state.position++;
5653
+ if (!isWhiteSpace(ch)) captureEnd = state.position;
5654
+ }
5655
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
5656
+ }
5657
+ function readFlowCollection(state, nodeIndent) {
5658
+ let readNext = true;
5659
+ let _line;
5660
+ let _lineStart;
5661
+ let _pos;
5662
+ const _tag = state.tag;
5663
+ let _result;
5664
+ const _anchor = state.anchor;
5665
+ let terminator;
5666
+ let isPair;
5667
+ let isExplicitPair;
5668
+ let isMapping;
5669
+ const overridableKeys = Object.create(null);
5670
+ let keyNode;
5671
+ let keyTag;
5672
+ let valueNode;
5673
+ let ch = state.input.charCodeAt(state.position);
5674
+ if (ch === 91) {
5675
+ terminator = 93;
5676
+ isMapping = false;
5677
+ _result = [];
5678
+ } else if (ch === 123) {
5679
+ terminator = 125;
5680
+ isMapping = true;
5681
+ _result = {};
5682
+ } else return false;
5683
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5684
+ ch = state.input.charCodeAt(++state.position);
5685
+ while (ch !== 0) {
5686
+ skipSeparationSpace(state, true, nodeIndent);
5687
+ ch = state.input.charCodeAt(state.position);
5688
+ if (ch === terminator) {
5689
+ state.position++;
5690
+ state.tag = _tag;
5691
+ state.anchor = _anchor;
5692
+ state.kind = isMapping ? "mapping" : "sequence";
5693
+ state.result = _result;
5694
+ return true;
5695
+ } else if (!readNext) throwError(state, "missed comma between flow collection entries");
5696
+ else if (ch === 44) throwError(state, "expected the node content, but found ','");
5697
+ keyTag = keyNode = valueNode = null;
5698
+ isPair = isExplicitPair = false;
5699
+ if (ch === 63) {
5700
+ if (isWsOrEol(state.input.charCodeAt(state.position + 1))) {
5701
+ isPair = isExplicitPair = true;
5702
+ state.position++;
5703
+ skipSeparationSpace(state, true, nodeIndent);
5704
+ }
5705
+ }
5706
+ _line = state.line;
5707
+ _lineStart = state.lineStart;
5708
+ _pos = state.position;
5709
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
5710
+ keyTag = state.tag;
5711
+ keyNode = state.result;
5712
+ skipSeparationSpace(state, true, nodeIndent);
5713
+ ch = state.input.charCodeAt(state.position);
5714
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
5715
+ isPair = true;
5716
+ ch = state.input.charCodeAt(++state.position);
5717
+ skipSeparationSpace(state, true, nodeIndent);
5718
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
5719
+ valueNode = state.result;
5720
+ }
5721
+ if (isMapping) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
5722
+ else if (isPair) _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
5723
+ else _result.push(keyNode);
5724
+ skipSeparationSpace(state, true, nodeIndent);
5725
+ ch = state.input.charCodeAt(state.position);
5726
+ if (ch === 44) {
5727
+ readNext = true;
5728
+ ch = state.input.charCodeAt(++state.position);
5729
+ } else readNext = false;
5730
+ }
5731
+ throwError(state, "unexpected end of the stream within a flow collection");
5732
+ }
5733
+ function readBlockScalar(state, nodeIndent) {
5734
+ let folding;
5735
+ let chomping = CHOMPING_CLIP;
5736
+ let didReadContent = false;
5737
+ let detectedIndent = false;
5738
+ let textIndent = nodeIndent;
5739
+ let emptyLines = 0;
5740
+ let atMoreIndented = false;
5741
+ let tmp;
5742
+ let ch = state.input.charCodeAt(state.position);
5743
+ if (ch === 124) folding = false;
5744
+ else if (ch === 62) folding = true;
5745
+ else return false;
5746
+ state.kind = "scalar";
5747
+ state.result = "";
5748
+ while (ch !== 0) {
5749
+ ch = state.input.charCodeAt(++state.position);
5750
+ if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
5751
+ else throwError(state, "repeat of a chomping mode identifier");
5752
+ 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");
5753
+ else if (!detectedIndent) {
5754
+ textIndent = nodeIndent + tmp - 1;
5755
+ detectedIndent = true;
5756
+ } else throwError(state, "repeat of an indentation width identifier");
5757
+ else break;
5758
+ }
5759
+ if (isWhiteSpace(ch)) {
5760
+ do
5761
+ ch = state.input.charCodeAt(++state.position);
5762
+ while (isWhiteSpace(ch));
5763
+ if (ch === 35) do
5764
+ ch = state.input.charCodeAt(++state.position);
5765
+ while (!isEol(ch) && ch !== 0);
5766
+ }
5767
+ while (ch !== 0) {
5768
+ readLineBreak(state);
5769
+ state.lineIndent = 0;
5770
+ ch = state.input.charCodeAt(state.position);
5771
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
5772
+ state.lineIndent++;
5773
+ ch = state.input.charCodeAt(++state.position);
5774
+ }
5775
+ if (!detectedIndent && state.lineIndent > textIndent) textIndent = state.lineIndent;
5776
+ if (isEol(ch)) {
5777
+ emptyLines++;
5778
+ continue;
5779
+ }
5780
+ if (!detectedIndent && textIndent === 0) throwError(state, "missing indentation for block scalar");
5781
+ if (state.lineIndent < textIndent) {
5782
+ if (chomping === CHOMPING_KEEP) state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5783
+ else if (chomping === CHOMPING_CLIP) {
5784
+ if (didReadContent) state.result += "\n";
5785
+ }
5786
+ break;
5787
+ }
5788
+ if (folding) if (isWhiteSpace(ch)) {
5789
+ atMoreIndented = true;
5790
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5791
+ } else if (atMoreIndented) {
5792
+ atMoreIndented = false;
5793
+ state.result += common.repeat("\n", emptyLines + 1);
5794
+ } else if (emptyLines === 0) {
5795
+ if (didReadContent) state.result += " ";
5796
+ } else state.result += common.repeat("\n", emptyLines);
5797
+ else state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5798
+ didReadContent = true;
5799
+ detectedIndent = true;
5800
+ emptyLines = 0;
5801
+ const captureStart = state.position;
5802
+ while (!isEol(ch) && ch !== 0) ch = state.input.charCodeAt(++state.position);
5803
+ captureSegment(state, captureStart, state.position, false);
5804
+ }
5805
+ return true;
5806
+ }
5807
+ function readBlockSequence(state, nodeIndent) {
5808
+ const _tag = state.tag;
5809
+ const _anchor = state.anchor;
5810
+ const _result = [];
5811
+ let detected = false;
5812
+ if (state.firstTabInLine !== -1) return false;
5813
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5814
+ let ch = state.input.charCodeAt(state.position);
5815
+ while (ch !== 0) {
5816
+ if (state.firstTabInLine !== -1) {
5817
+ state.position = state.firstTabInLine;
5818
+ throwError(state, "tab characters must not be used in indentation");
5819
+ }
5820
+ if (ch !== 45) break;
5821
+ if (!isWsOrEol(state.input.charCodeAt(state.position + 1))) break;
5822
+ detected = true;
5823
+ state.position++;
5824
+ if (skipSeparationSpace(state, true, -1)) {
5825
+ if (state.lineIndent <= nodeIndent) {
5826
+ _result.push(null);
5827
+ ch = state.input.charCodeAt(state.position);
5828
+ continue;
5829
+ }
5830
+ }
5831
+ const _line = state.line;
5832
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
5833
+ _result.push(state.result);
5834
+ skipSeparationSpace(state, true, -1);
5835
+ ch = state.input.charCodeAt(state.position);
5836
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a sequence entry");
5837
+ else if (state.lineIndent < nodeIndent) break;
5838
+ }
5839
+ if (detected) {
5840
+ state.tag = _tag;
5841
+ state.anchor = _anchor;
5842
+ state.kind = "sequence";
5843
+ state.result = _result;
5844
+ return true;
5845
+ }
5846
+ return false;
5847
+ }
5848
+ function readBlockMapping(state, nodeIndent, flowIndent) {
5849
+ let allowCompact;
5850
+ let _keyLine;
5851
+ let _keyLineStart;
5852
+ let _keyPos;
5853
+ const _tag = state.tag;
5854
+ const _anchor = state.anchor;
5855
+ const _result = {};
5856
+ const overridableKeys = Object.create(null);
5857
+ let keyTag = null;
5858
+ let keyNode = null;
5859
+ let valueNode = null;
5860
+ let atExplicitKey = false;
5861
+ let detected = false;
5862
+ if (state.firstTabInLine !== -1) return false;
5863
+ if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5864
+ let ch = state.input.charCodeAt(state.position);
5865
+ while (ch !== 0) {
5866
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
5867
+ state.position = state.firstTabInLine;
5868
+ throwError(state, "tab characters must not be used in indentation");
5869
+ }
5870
+ const following = state.input.charCodeAt(state.position + 1);
5871
+ const _line = state.line;
5872
+ if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
5873
+ if (ch === 63) {
5874
+ if (atExplicitKey) {
5875
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5876
+ keyTag = keyNode = valueNode = null;
5877
+ }
5878
+ detected = true;
5879
+ atExplicitKey = true;
5880
+ allowCompact = true;
5881
+ } else if (atExplicitKey) {
5882
+ atExplicitKey = false;
5883
+ allowCompact = true;
5884
+ } else throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
5885
+ state.position += 1;
5886
+ ch = following;
5887
+ } else {
5888
+ _keyLine = state.line;
5889
+ _keyLineStart = state.lineStart;
5890
+ _keyPos = state.position;
5891
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
5892
+ if (state.line === _line) {
5893
+ ch = state.input.charCodeAt(state.position);
5894
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
5895
+ if (ch === 58) {
5896
+ ch = state.input.charCodeAt(++state.position);
5897
+ if (!isWsOrEol(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
5898
+ if (atExplicitKey) {
5899
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5900
+ keyTag = keyNode = valueNode = null;
5901
+ }
5902
+ detected = true;
5903
+ atExplicitKey = false;
5904
+ allowCompact = false;
5905
+ keyTag = state.tag;
5906
+ keyNode = state.result;
5907
+ } else if (detected) throwError(state, "can not read an implicit mapping pair; a colon is missed");
5908
+ else {
5909
+ state.tag = _tag;
5910
+ state.anchor = _anchor;
5911
+ return true;
5912
+ }
5913
+ } else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
5914
+ else {
5915
+ state.tag = _tag;
5916
+ state.anchor = _anchor;
5917
+ return true;
5918
+ }
5919
+ }
5920
+ if (state.line === _line || state.lineIndent > nodeIndent) {
5921
+ if (atExplicitKey) {
5922
+ _keyLine = state.line;
5923
+ _keyLineStart = state.lineStart;
5924
+ _keyPos = state.position;
5925
+ }
5926
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) if (atExplicitKey) keyNode = state.result;
5927
+ else valueNode = state.result;
5928
+ if (!atExplicitKey) {
5929
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
5930
+ keyTag = keyNode = valueNode = null;
5931
+ }
5932
+ skipSeparationSpace(state, true, -1);
5933
+ ch = state.input.charCodeAt(state.position);
5934
+ }
5935
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
5936
+ else if (state.lineIndent < nodeIndent) break;
5937
+ }
5938
+ if (atExplicitKey) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5939
+ if (detected) {
5940
+ state.tag = _tag;
5941
+ state.anchor = _anchor;
5942
+ state.kind = "mapping";
5943
+ state.result = _result;
5944
+ }
5945
+ return detected;
5946
+ }
5947
+ function readTagProperty(state) {
5948
+ let isVerbatim = false;
5949
+ let isNamed = false;
5950
+ let tagHandle;
5951
+ let tagName;
5952
+ let ch = state.input.charCodeAt(state.position);
5953
+ if (ch !== 33) return false;
5954
+ if (state.tag !== null) throwError(state, "duplication of a tag property");
5955
+ ch = state.input.charCodeAt(++state.position);
5956
+ if (ch === 60) {
5957
+ isVerbatim = true;
5958
+ ch = state.input.charCodeAt(++state.position);
5959
+ } else if (ch === 33) {
5960
+ isNamed = true;
5961
+ tagHandle = "!!";
5962
+ ch = state.input.charCodeAt(++state.position);
5963
+ } else tagHandle = "!";
5964
+ let _position = state.position;
5965
+ if (isVerbatim) {
5966
+ do
5967
+ ch = state.input.charCodeAt(++state.position);
5968
+ while (ch !== 0 && ch !== 62);
5969
+ if (state.position < state.length) {
5970
+ tagName = state.input.slice(_position, state.position);
5971
+ ch = state.input.charCodeAt(++state.position);
5972
+ } else throwError(state, "unexpected end of the stream within a verbatim tag");
5973
+ } else {
5974
+ while (ch !== 0 && !isWsOrEol(ch)) {
5975
+ if (ch === 33) if (!isNamed) {
5976
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
5977
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
5978
+ isNamed = true;
5979
+ _position = state.position + 1;
5980
+ } else throwError(state, "tag suffix cannot contain exclamation marks");
5981
+ ch = state.input.charCodeAt(++state.position);
5982
+ }
5983
+ tagName = state.input.slice(_position, state.position);
5984
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
5985
+ }
5986
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) throwError(state, "tag name cannot contain such characters: " + tagName);
5987
+ try {
5988
+ tagName = decodeURIComponent(tagName);
5989
+ } catch (err) {
5990
+ throwError(state, "tag name is malformed: " + tagName);
5991
+ }
5992
+ if (isVerbatim) state.tag = tagName;
5993
+ else if (_hasOwnProperty.call(state.tagMap, tagHandle)) state.tag = state.tagMap[tagHandle] + tagName;
5994
+ else if (tagHandle === "!") state.tag = "!" + tagName;
5995
+ else if (tagHandle === "!!") state.tag = "tag:yaml.org,2002:" + tagName;
5996
+ else throwError(state, "undeclared tag handle \"" + tagHandle + "\"");
5997
+ return true;
5998
+ }
5999
+ function readAnchorProperty(state) {
6000
+ let ch = state.input.charCodeAt(state.position);
6001
+ if (ch !== 38) return false;
6002
+ if (state.anchor !== null) throwError(state, "duplication of an anchor property");
6003
+ ch = state.input.charCodeAt(++state.position);
6004
+ const _position = state.position;
6005
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
6006
+ if (state.position === _position) throwError(state, "name of an anchor node must contain at least one character");
6007
+ state.anchor = state.input.slice(_position, state.position);
6008
+ return true;
6009
+ }
6010
+ function readAlias(state) {
6011
+ let ch = state.input.charCodeAt(state.position);
6012
+ if (ch !== 42) return false;
6013
+ ch = state.input.charCodeAt(++state.position);
6014
+ const _position = state.position;
6015
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
6016
+ if (state.position === _position) throwError(state, "name of an alias node must contain at least one character");
6017
+ const alias = state.input.slice(_position, state.position);
6018
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) throwError(state, "unidentified alias \"" + alias + "\"");
6019
+ state.result = state.anchorMap[alias];
6020
+ skipSeparationSpace(state, true, -1);
6021
+ return true;
6022
+ }
6023
+ function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
6024
+ const fallbackState = snapshotState(state);
6025
+ beginAnchorTransaction(state);
6026
+ restoreState(state, propertyStart);
6027
+ state.tag = null;
6028
+ state.anchor = null;
6029
+ state.kind = null;
6030
+ state.result = null;
6031
+ if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
6032
+ commitAnchorTransaction(state);
6033
+ return true;
6034
+ }
6035
+ rollbackAnchorTransaction(state);
6036
+ restoreState(state, fallbackState);
6037
+ return false;
6038
+ }
6039
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
6040
+ let allowBlockScalars;
6041
+ let allowBlockCollections;
6042
+ let indentStatus = 1;
6043
+ let atNewLine = false;
6044
+ let hasContent = false;
6045
+ let propertyStart = null;
6046
+ let type;
6047
+ let flowIndent;
6048
+ let blockIndent;
6049
+ if (state.depth >= state.maxDepth) throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
6050
+ state.depth += 1;
6051
+ if (state.listener !== null) state.listener("open", state);
6052
+ state.tag = null;
6053
+ state.anchor = null;
6054
+ state.kind = null;
6055
+ state.result = null;
6056
+ const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
6057
+ if (allowToSeek) {
6058
+ if (skipSeparationSpace(state, true, -1)) {
6059
+ atNewLine = true;
6060
+ if (state.lineIndent > parentIndent) indentStatus = 1;
6061
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
6062
+ else if (state.lineIndent < parentIndent) indentStatus = -1;
6063
+ }
6064
+ }
6065
+ if (indentStatus === 1) while (true) {
6066
+ const ch = state.input.charCodeAt(state.position);
6067
+ const propertyState = snapshotState(state);
6068
+ if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) break;
6069
+ if (!readTagProperty(state) && !readAnchorProperty(state)) break;
6070
+ if (propertyStart === null) propertyStart = propertyState;
6071
+ if (skipSeparationSpace(state, true, -1)) {
6072
+ atNewLine = true;
6073
+ allowBlockCollections = allowBlockStyles;
6074
+ if (state.lineIndent > parentIndent) indentStatus = 1;
6075
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
6076
+ else if (state.lineIndent < parentIndent) indentStatus = -1;
6077
+ } else allowBlockCollections = false;
6078
+ }
6079
+ if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
6080
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
6081
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) flowIndent = parentIndent;
6082
+ else flowIndent = parentIndent + 1;
6083
+ blockIndent = state.position - state.lineStart;
6084
+ if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) hasContent = true;
6085
+ else {
6086
+ const ch = state.input.charCodeAt(state.position);
6087
+ if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(state, propertyStart, propertyStart.position - propertyStart.lineStart, flowIndent)) hasContent = true;
6088
+ else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) hasContent = true;
6089
+ else if (readAlias(state)) {
6090
+ hasContent = true;
6091
+ if (state.tag !== null || state.anchor !== null) throwError(state, "alias node should not have any properties");
6092
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
6093
+ hasContent = true;
6094
+ if (state.tag === null) state.tag = "?";
6095
+ }
6096
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
6097
+ }
6098
+ else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
6099
+ }
6100
+ if (state.tag === null) {
6101
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
6102
+ } else if (state.tag === "?") {
6103
+ if (state.result !== null && state.kind !== "scalar") throwError(state, "unacceptable node kind for !<?> tag; it should be \"scalar\", not \"" + state.kind + "\"");
6104
+ for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
6105
+ type = state.implicitTypes[typeIndex];
6106
+ if (type.resolve(state.result)) {
6107
+ state.result = type.construct(state.result);
6108
+ state.tag = type.tag;
6109
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
6110
+ break;
6111
+ }
6112
+ }
6113
+ } else if (state.tag !== "!") {
6114
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) type = state.typeMap[state.kind || "fallback"][state.tag];
6115
+ else {
6116
+ type = null;
6117
+ const typeList = state.typeMap.multi[state.kind || "fallback"];
6118
+ for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
6119
+ type = typeList[typeIndex];
6120
+ break;
6121
+ }
6122
+ }
6123
+ if (!type) throwError(state, "unknown tag !<" + state.tag + ">");
6124
+ 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 + "\"");
6125
+ if (!type.resolve(state.result, state.tag)) throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
6126
+ else {
6127
+ state.result = type.construct(state.result, state.tag);
6128
+ if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
6129
+ }
6130
+ }
6131
+ if (state.listener !== null) state.listener("close", state);
6132
+ state.depth -= 1;
6133
+ return state.tag !== null || state.anchor !== null || hasContent;
6134
+ }
6135
+ function readDocument(state) {
6136
+ const documentStart = state.position;
6137
+ let hasDirectives = false;
6138
+ let ch;
6139
+ state.version = null;
6140
+ state.checkLineBreaks = state.legacy;
6141
+ state.tagMap = Object.create(null);
6142
+ state.anchorMap = Object.create(null);
6143
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
6144
+ skipSeparationSpace(state, true, -1);
6145
+ ch = state.input.charCodeAt(state.position);
6146
+ if (state.lineIndent > 0 || ch !== 37) break;
6147
+ hasDirectives = true;
6148
+ ch = state.input.charCodeAt(++state.position);
6149
+ let _position = state.position;
6150
+ while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
6151
+ const directiveName = state.input.slice(_position, state.position);
6152
+ const directiveArgs = [];
6153
+ if (directiveName.length < 1) throwError(state, "directive name must not be less than one character in length");
6154
+ while (ch !== 0) {
6155
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
6156
+ if (ch === 35) {
6157
+ do
6158
+ ch = state.input.charCodeAt(++state.position);
6159
+ while (ch !== 0 && !isEol(ch));
6160
+ break;
6161
+ }
6162
+ if (isEol(ch)) break;
6163
+ _position = state.position;
6164
+ while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
6165
+ directiveArgs.push(state.input.slice(_position, state.position));
6166
+ }
6167
+ if (ch !== 0) readLineBreak(state);
6168
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) directiveHandlers[directiveName](state, directiveName, directiveArgs);
6169
+ else throwWarning(state, "unknown document directive \"" + directiveName + "\"");
6170
+ }
6171
+ skipSeparationSpace(state, true, -1);
6172
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
6173
+ state.position += 3;
6174
+ skipSeparationSpace(state, true, -1);
6175
+ } else if (hasDirectives) throwError(state, "directives end mark is expected");
6176
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
6177
+ skipSeparationSpace(state, true, -1);
6178
+ 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");
6179
+ state.documents.push(state.result);
6180
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
6181
+ if (state.input.charCodeAt(state.position) === 46) {
6182
+ state.position += 3;
6183
+ skipSeparationSpace(state, true, -1);
6184
+ }
6185
+ return;
6186
+ }
6187
+ if (state.position < state.length - 1) throwError(state, "end of the stream or a document separator is expected");
6188
+ }
6189
+ function loadDocuments(input, options) {
6190
+ input = String(input);
6191
+ options = options || {};
6192
+ if (input.length !== 0) {
6193
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) input += "\n";
6194
+ if (input.charCodeAt(0) === 65279) input = input.slice(1);
6195
+ }
6196
+ const state = new State(input, options);
6197
+ const nullpos = input.indexOf("\0");
6198
+ if (nullpos !== -1) {
6199
+ state.position = nullpos;
6200
+ throwError(state, "null byte is not allowed in input");
6201
+ }
6202
+ state.input += "\0";
6203
+ while (state.input.charCodeAt(state.position) === 32) {
6204
+ state.lineIndent += 1;
6205
+ state.position += 1;
6206
+ }
6207
+ while (state.position < state.length - 1) readDocument(state);
6208
+ return state.documents;
6209
+ }
6210
+ function loadAll(input, iterator, options) {
6211
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
6212
+ options = iterator;
6213
+ iterator = null;
6214
+ }
6215
+ const documents = loadDocuments(input, options);
6216
+ if (typeof iterator !== "function") return documents;
6217
+ for (let index = 0, length = documents.length; index < length; index += 1) iterator(documents[index]);
6218
+ }
6219
+ function load(input, options) {
6220
+ const documents = loadDocuments(input, options);
6221
+ if (documents.length === 0) return;
6222
+ else if (documents.length === 1) return documents[0];
6223
+ throw new YAMLException("expected a single document in the stream, but found more");
6224
+ }
6225
+ module.exports.loadAll = loadAll;
6226
+ module.exports.load = load;
6227
+ }));
6228
+ var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6229
+ var common = require_common();
6230
+ var YAMLException = require_exception();
6231
+ var DEFAULT_SCHEMA = require_default();
6232
+ var _toString = Object.prototype.toString;
6233
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
6234
+ var CHAR_BOM = 65279;
6235
+ var CHAR_TAB = 9;
6236
+ var CHAR_LINE_FEED = 10;
6237
+ var CHAR_CARRIAGE_RETURN = 13;
6238
+ var CHAR_SPACE = 32;
6239
+ var CHAR_EXCLAMATION = 33;
6240
+ var CHAR_DOUBLE_QUOTE = 34;
6241
+ var CHAR_SHARP = 35;
6242
+ var CHAR_PERCENT = 37;
6243
+ var CHAR_AMPERSAND = 38;
6244
+ var CHAR_SINGLE_QUOTE = 39;
6245
+ var CHAR_ASTERISK = 42;
6246
+ var CHAR_COMMA = 44;
6247
+ var CHAR_MINUS = 45;
6248
+ var CHAR_COLON = 58;
6249
+ var CHAR_EQUALS = 61;
6250
+ var CHAR_GREATER_THAN = 62;
6251
+ var CHAR_QUESTION = 63;
6252
+ var CHAR_COMMERCIAL_AT = 64;
6253
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
6254
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
6255
+ var CHAR_GRAVE_ACCENT = 96;
6256
+ var CHAR_LEFT_CURLY_BRACKET = 123;
6257
+ var CHAR_VERTICAL_LINE = 124;
6258
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
6259
+ var ESCAPE_SEQUENCES = {};
6260
+ ESCAPE_SEQUENCES[0] = "\\0";
6261
+ ESCAPE_SEQUENCES[7] = "\\a";
6262
+ ESCAPE_SEQUENCES[8] = "\\b";
6263
+ ESCAPE_SEQUENCES[9] = "\\t";
6264
+ ESCAPE_SEQUENCES[10] = "\\n";
6265
+ ESCAPE_SEQUENCES[11] = "\\v";
6266
+ ESCAPE_SEQUENCES[12] = "\\f";
6267
+ ESCAPE_SEQUENCES[13] = "\\r";
6268
+ ESCAPE_SEQUENCES[27] = "\\e";
6269
+ ESCAPE_SEQUENCES[34] = "\\\"";
6270
+ ESCAPE_SEQUENCES[92] = "\\\\";
6271
+ ESCAPE_SEQUENCES[133] = "\\N";
6272
+ ESCAPE_SEQUENCES[160] = "\\_";
6273
+ ESCAPE_SEQUENCES[8232] = "\\L";
6274
+ ESCAPE_SEQUENCES[8233] = "\\P";
6275
+ var DEPRECATED_BOOLEANS_SYNTAX = [
6276
+ "y",
6277
+ "Y",
6278
+ "yes",
6279
+ "Yes",
6280
+ "YES",
6281
+ "on",
6282
+ "On",
6283
+ "ON",
6284
+ "n",
6285
+ "N",
6286
+ "no",
6287
+ "No",
6288
+ "NO",
6289
+ "off",
6290
+ "Off",
6291
+ "OFF"
6292
+ ];
6293
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
6294
+ function compileStyleMap(schema, map) {
6295
+ if (map === null) return {};
6296
+ const result = {};
6297
+ const keys = Object.keys(map);
6298
+ for (let index = 0, length = keys.length; index < length; index += 1) {
6299
+ let tag = keys[index];
6300
+ let style = String(map[tag]);
6301
+ if (tag.slice(0, 2) === "!!") tag = "tag:yaml.org,2002:" + tag.slice(2);
6302
+ const type = schema.compiledTypeMap["fallback"][tag];
6303
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) style = type.styleAliases[style];
6304
+ result[tag] = style;
6305
+ }
6306
+ return result;
6307
+ }
6308
+ function encodeHex(character) {
6309
+ let handle;
6310
+ let length;
6311
+ const string = character.toString(16).toUpperCase();
6312
+ if (character <= 255) {
6313
+ handle = "x";
6314
+ length = 2;
6315
+ } else if (character <= 65535) {
6316
+ handle = "u";
6317
+ length = 4;
6318
+ } else if (character <= 4294967295) {
6319
+ handle = "U";
6320
+ length = 8;
6321
+ } else throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
6322
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
6323
+ }
6324
+ var QUOTING_TYPE_SINGLE = 1;
6325
+ var QUOTING_TYPE_DOUBLE = 2;
6326
+ function State(options) {
6327
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
6328
+ this.indent = Math.max(1, options["indent"] || 2);
6329
+ this.noArrayIndent = options["noArrayIndent"] || false;
6330
+ this.skipInvalid = options["skipInvalid"] || false;
6331
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
6332
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
6333
+ this.sortKeys = options["sortKeys"] || false;
6334
+ this.lineWidth = options["lineWidth"] || 80;
6335
+ this.noRefs = options["noRefs"] || false;
6336
+ this.noCompatMode = options["noCompatMode"] || false;
6337
+ this.condenseFlow = options["condenseFlow"] || false;
6338
+ this.quotingType = options["quotingType"] === "\"" ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
6339
+ this.forceQuotes = options["forceQuotes"] || false;
6340
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
6341
+ this.implicitTypes = this.schema.compiledImplicit;
6342
+ this.explicitTypes = this.schema.compiledExplicit;
6343
+ this.tag = null;
6344
+ this.result = "";
6345
+ this.duplicates = [];
6346
+ this.usedDuplicates = null;
6347
+ }
6348
+ function indentString(string, spaces) {
6349
+ const ind = common.repeat(" ", spaces);
6350
+ let position = 0;
6351
+ let result = "";
6352
+ const length = string.length;
6353
+ while (position < length) {
6354
+ let line;
6355
+ const next = string.indexOf("\n", position);
6356
+ if (next === -1) {
6357
+ line = string.slice(position);
6358
+ position = length;
6359
+ } else {
6360
+ line = string.slice(position, next + 1);
6361
+ position = next + 1;
6362
+ }
6363
+ if (line.length && line !== "\n") result += ind;
6364
+ result += line;
6365
+ }
6366
+ return result;
6367
+ }
6368
+ function generateNextLine(state, level) {
6369
+ return "\n" + common.repeat(" ", state.indent * level);
6370
+ }
6371
+ function testImplicitResolving(state, str) {
6372
+ for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) if (state.implicitTypes[index].resolve(str)) return true;
6373
+ return false;
6374
+ }
6375
+ function isWhitespace(c) {
6376
+ return c === CHAR_SPACE || c === CHAR_TAB;
6377
+ }
6378
+ function isPrintable(c) {
6379
+ return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
6380
+ }
6381
+ function isNsCharOrWhitespace(c) {
6382
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
6383
+ }
6384
+ function isPlainSafe(c, prev, inblock) {
6385
+ const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
6386
+ const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
6387
+ 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;
6388
+ }
6389
+ function isPlainSafeFirst(c) {
6390
+ 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;
6391
+ }
6392
+ function isPlainSafeLast(c) {
6393
+ return !isWhitespace(c) && c !== CHAR_COLON;
6394
+ }
6395
+ function codePointAt(string, pos) {
6396
+ const first = string.charCodeAt(pos);
6397
+ let second;
6398
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
6399
+ second = string.charCodeAt(pos + 1);
6400
+ if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
6401
+ }
6402
+ return first;
6403
+ }
6404
+ function needIndentIndicator(string) {
6405
+ return /^\n* /.test(string);
6406
+ }
6407
+ var STYLE_PLAIN = 1;
6408
+ var STYLE_SINGLE = 2;
6409
+ var STYLE_LITERAL = 3;
6410
+ var STYLE_FOLDED = 4;
6411
+ var STYLE_DOUBLE = 5;
6412
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
6413
+ let i;
6414
+ let char = 0;
6415
+ let prevChar = null;
6416
+ let hasLineBreak = false;
6417
+ let hasFoldableLine = false;
6418
+ const shouldTrackWidth = lineWidth !== -1;
6419
+ let previousLineBreak = -1;
6420
+ let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
6421
+ if (singleLineOnly || forceQuotes) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6422
+ char = codePointAt(string, i);
6423
+ if (!isPrintable(char)) return STYLE_DOUBLE;
6424
+ plain = plain && isPlainSafe(char, prevChar, inblock);
6425
+ prevChar = char;
6426
+ }
6427
+ else {
6428
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6429
+ char = codePointAt(string, i);
6430
+ if (char === CHAR_LINE_FEED) {
6431
+ hasLineBreak = true;
6432
+ if (shouldTrackWidth) {
6433
+ hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
6434
+ previousLineBreak = i;
6435
+ }
6436
+ } else if (!isPrintable(char)) return STYLE_DOUBLE;
6437
+ plain = plain && isPlainSafe(char, prevChar, inblock);
6438
+ prevChar = char;
6439
+ }
6440
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
6441
+ }
6442
+ if (!hasLineBreak && !hasFoldableLine) {
6443
+ if (plain && !forceQuotes && !testAmbiguousType(string)) return STYLE_PLAIN;
6444
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
6445
+ }
6446
+ if (indentPerLevel > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
6447
+ if (!forceQuotes) return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
6448
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
6449
+ }
6450
+ function writeScalar(state, string, level, iskey, inblock) {
6451
+ state.dump = function() {
6452
+ if (string.length === 0) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"\"" : "''";
6453
+ if (!state.noCompatMode) {
6454
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"" + string + "\"" : "'" + string + "'";
6455
+ }
6456
+ const indent = state.indent * Math.max(1, level);
6457
+ const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
6458
+ const singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
6459
+ function testAmbiguity(string) {
6460
+ return testImplicitResolving(state, string);
6461
+ }
6462
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
6463
+ case STYLE_PLAIN: return string;
6464
+ case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'";
6465
+ case STYLE_LITERAL: return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
6466
+ case STYLE_FOLDED: return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
6467
+ case STYLE_DOUBLE: return "\"" + escapeString(string, lineWidth) + "\"";
6468
+ default: throw new YAMLException("impossible error: invalid scalar style");
6469
+ }
6470
+ }();
6471
+ }
6472
+ function blockHeader(string, indentPerLevel) {
6473
+ const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
6474
+ const clip = string[string.length - 1] === "\n";
6475
+ return indentIndicator + (clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-") + "\n";
6476
+ }
6477
+ function dropEndingNewline(string) {
6478
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
6479
+ }
6480
+ function foldString(string, width) {
6481
+ const lineRe = /(\n+)([^\n]*)/g;
6482
+ let result = function() {
6483
+ let nextLF = string.indexOf("\n");
6484
+ nextLF = nextLF !== -1 ? nextLF : string.length;
6485
+ lineRe.lastIndex = nextLF;
6486
+ return foldLine(string.slice(0, nextLF), width);
6487
+ }();
6488
+ let prevMoreIndented = string[0] === "\n" || string[0] === " ";
6489
+ let moreIndented;
6490
+ let match;
6491
+ while (match = lineRe.exec(string)) {
6492
+ const prefix = match[1];
6493
+ const line = match[2];
6494
+ moreIndented = line[0] === " ";
6495
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
6496
+ prevMoreIndented = moreIndented;
6497
+ }
6498
+ return result;
6499
+ }
6500
+ function foldLine(line, width) {
6501
+ if (line === "" || line[0] === " ") return line;
6502
+ const breakRe = / [^ ]/g;
6503
+ let match;
6504
+ let start = 0;
6505
+ let end;
6506
+ let curr = 0;
6507
+ let next = 0;
6508
+ let result = "";
6509
+ while (match = breakRe.exec(line)) {
6510
+ next = match.index;
6511
+ if (next - start > width) {
6512
+ end = curr > start ? curr : next;
6513
+ result += "\n" + line.slice(start, end);
6514
+ start = end + 1;
6515
+ }
6516
+ curr = next;
6517
+ }
6518
+ result += "\n";
6519
+ if (line.length - start > width && curr > start) result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
6520
+ else result += line.slice(start);
6521
+ return result.slice(1);
6522
+ }
6523
+ function escapeString(string) {
6524
+ let result = "";
6525
+ let char = 0;
6526
+ for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6527
+ char = codePointAt(string, i);
6528
+ const escapeSeq = ESCAPE_SEQUENCES[char];
6529
+ if (!escapeSeq && isPrintable(char)) {
6530
+ result += string[i];
6531
+ if (char >= 65536) result += string[i + 1];
6532
+ } else result += escapeSeq || encodeHex(char);
6533
+ }
6534
+ return result;
6535
+ }
6536
+ function writeFlowSequence(state, level, object) {
6537
+ let _result = "";
6538
+ const _tag = state.tag;
6539
+ for (let index = 0, length = object.length; index < length; index += 1) {
6540
+ let value = object[index];
6541
+ if (state.replacer) value = state.replacer.call(object, String(index), value);
6542
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
6543
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
6544
+ _result += state.dump;
6545
+ }
6546
+ }
6547
+ state.tag = _tag;
6548
+ state.dump = "[" + _result + "]";
6549
+ }
6550
+ function writeBlockSequence(state, level, object, compact) {
6551
+ let _result = "";
6552
+ const _tag = state.tag;
6553
+ for (let index = 0, length = object.length; index < length; index += 1) {
6554
+ let value = object[index];
6555
+ if (state.replacer) value = state.replacer.call(object, String(index), value);
6556
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
6557
+ if (!compact || _result !== "") _result += generateNextLine(state, level);
6558
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
6559
+ else _result += "- ";
6560
+ _result += state.dump;
6561
+ }
6562
+ }
6563
+ state.tag = _tag;
6564
+ state.dump = _result || "[]";
6565
+ }
6566
+ function writeFlowMapping(state, level, object) {
6567
+ let _result = "";
6568
+ const _tag = state.tag;
6569
+ const objectKeyList = Object.keys(object);
6570
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
6571
+ let pairBuffer = "";
6572
+ if (_result !== "") pairBuffer += ", ";
6573
+ if (state.condenseFlow) pairBuffer += "\"";
6574
+ const objectKey = objectKeyList[index];
6575
+ let objectValue = object[objectKey];
6576
+ if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
6577
+ if (!writeNode(state, level, objectKey, false, false)) continue;
6578
+ if (state.dump.length > 1024) pairBuffer += "? ";
6579
+ pairBuffer += state.dump + (state.condenseFlow ? "\"" : "") + ":" + (state.condenseFlow ? "" : " ");
6580
+ if (!writeNode(state, level, objectValue, false, false)) continue;
6581
+ pairBuffer += state.dump;
6582
+ _result += pairBuffer;
6583
+ }
6584
+ state.tag = _tag;
6585
+ state.dump = "{" + _result + "}";
6586
+ }
6587
+ function writeBlockMapping(state, level, object, compact) {
6588
+ let _result = "";
6589
+ const _tag = state.tag;
6590
+ const objectKeyList = Object.keys(object);
6591
+ if (state.sortKeys === true) objectKeyList.sort();
6592
+ else if (typeof state.sortKeys === "function") objectKeyList.sort(state.sortKeys);
6593
+ else if (state.sortKeys) throw new YAMLException("sortKeys must be a boolean or a function");
6594
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
6595
+ let pairBuffer = "";
6596
+ if (!compact || _result !== "") pairBuffer += generateNextLine(state, level);
6597
+ const objectKey = objectKeyList[index];
6598
+ let objectValue = object[objectKey];
6599
+ if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
6600
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) continue;
6601
+ const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
6602
+ if (explicitPair) if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += "?";
6603
+ else pairBuffer += "? ";
6604
+ pairBuffer += state.dump;
6605
+ if (explicitPair) pairBuffer += generateNextLine(state, level);
6606
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) continue;
6607
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += ":";
6608
+ else pairBuffer += ": ";
6609
+ pairBuffer += state.dump;
6610
+ _result += pairBuffer;
6611
+ }
6612
+ state.tag = _tag;
6613
+ state.dump = _result || "{}";
6614
+ }
6615
+ function detectType(state, object, explicit) {
6616
+ const typeList = explicit ? state.explicitTypes : state.implicitTypes;
6617
+ for (let index = 0, length = typeList.length; index < length; index += 1) {
6618
+ const type = typeList[index];
6619
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
6620
+ if (explicit) if (type.multi && type.representName) state.tag = type.representName(object);
6621
+ else state.tag = type.tag;
6622
+ else state.tag = "?";
6623
+ if (type.represent) {
6624
+ const style = state.styleMap[type.tag] || type.defaultStyle;
6625
+ let _result;
6626
+ if (_toString.call(type.represent) === "[object Function]") _result = type.represent(object, style);
6627
+ else if (_hasOwnProperty.call(type.represent, style)) _result = type.represent[style](object, style);
6628
+ else throw new YAMLException("!<" + type.tag + "> tag resolver accepts not \"" + style + "\" style");
6629
+ state.dump = _result;
6630
+ }
6631
+ return true;
6632
+ }
6633
+ }
6634
+ return false;
6635
+ }
6636
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
6637
+ state.tag = null;
6638
+ state.dump = object;
6639
+ if (!detectType(state, object, false)) detectType(state, object, true);
6640
+ const type = _toString.call(state.dump);
6641
+ const inblock = block;
6642
+ if (block) block = state.flowLevel < 0 || state.flowLevel > level;
6643
+ const objectOrArray = type === "[object Object]" || type === "[object Array]";
6644
+ let duplicateIndex;
6645
+ let duplicate;
6646
+ if (objectOrArray) {
6647
+ duplicateIndex = state.duplicates.indexOf(object);
6648
+ duplicate = duplicateIndex !== -1;
6649
+ }
6650
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) compact = false;
6651
+ if (duplicate && state.usedDuplicates[duplicateIndex]) state.dump = "*ref_" + duplicateIndex;
6652
+ else {
6653
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) state.usedDuplicates[duplicateIndex] = true;
6654
+ if (type === "[object Object]") if (block && Object.keys(state.dump).length !== 0) {
6655
+ writeBlockMapping(state, level, state.dump, compact);
6656
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
6657
+ } else {
6658
+ writeFlowMapping(state, level, state.dump);
6659
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
6660
+ }
6661
+ else if (type === "[object Array]") if (block && state.dump.length !== 0) {
6662
+ if (state.noArrayIndent && !isblockseq && level > 0) writeBlockSequence(state, level - 1, state.dump, compact);
6663
+ else writeBlockSequence(state, level, state.dump, compact);
6664
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
6665
+ } else {
6666
+ writeFlowSequence(state, level, state.dump);
6667
+ if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
6668
+ }
6669
+ else if (type === "[object String]") {
6670
+ if (state.tag !== "?") writeScalar(state, state.dump, level, iskey, inblock);
6671
+ } else if (type === "[object Undefined]") return false;
6672
+ else {
6673
+ if (state.skipInvalid) return false;
6674
+ throw new YAMLException("unacceptable kind of an object to dump " + type);
6675
+ }
6676
+ if (state.tag !== null && state.tag !== "?") {
6677
+ let tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
6678
+ if (state.tag[0] === "!") tagStr = "!" + tagStr;
6679
+ else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") tagStr = "!!" + tagStr.slice(18);
6680
+ else tagStr = "!<" + tagStr + ">";
6681
+ state.dump = tagStr + " " + state.dump;
6682
+ }
6683
+ }
6684
+ return true;
6685
+ }
6686
+ function getDuplicateReferences(object, state) {
6687
+ const objects = [];
6688
+ const duplicatesIndexes = [];
6689
+ inspectNode(object, objects, duplicatesIndexes);
6690
+ const length = duplicatesIndexes.length;
6691
+ for (let index = 0; index < length; index += 1) state.duplicates.push(objects[duplicatesIndexes[index]]);
6692
+ state.usedDuplicates = new Array(length);
6693
+ }
6694
+ function inspectNode(object, objects, duplicatesIndexes) {
6695
+ if (object !== null && typeof object === "object") {
6696
+ const index = objects.indexOf(object);
6697
+ if (index !== -1) {
6698
+ if (duplicatesIndexes.indexOf(index) === -1) duplicatesIndexes.push(index);
6699
+ } else {
6700
+ objects.push(object);
6701
+ if (Array.isArray(object)) for (let i = 0, length = object.length; i < length; i += 1) inspectNode(object[i], objects, duplicatesIndexes);
6702
+ else {
6703
+ const objectKeyList = Object.keys(object);
6704
+ for (let i = 0, length = objectKeyList.length; i < length; i += 1) inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
6705
+ }
6706
+ }
6707
+ }
6708
+ }
6709
+ function dump(input, options) {
6710
+ options = options || {};
6711
+ const state = new State(options);
6712
+ if (!state.noRefs) getDuplicateReferences(input, state);
6713
+ let value = input;
6714
+ if (state.replacer) value = state.replacer.call({ "": value }, "", value);
6715
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
6716
+ return "";
6717
+ }
6718
+ module.exports.dump = dump;
6719
+ }));
6720
+ var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
6721
+ var loader = require_loader();
6722
+ var dumper = require_dumper();
6723
+ function renamed(from, to) {
6724
+ return function() {
6725
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
6726
+ };
6727
+ }
6728
+ module.exports.Type = require_type();
6729
+ module.exports.Schema = require_schema();
6730
+ module.exports.FAILSAFE_SCHEMA = require_failsafe();
6731
+ module.exports.JSON_SCHEMA = require_json();
6732
+ module.exports.CORE_SCHEMA = require_core();
6733
+ module.exports.DEFAULT_SCHEMA = require_default();
6734
+ module.exports.load = loader.load;
6735
+ module.exports.loadAll = loader.loadAll;
6736
+ module.exports.dump = dumper.dump;
6737
+ module.exports.YAMLException = require_exception();
6738
+ module.exports.types = {
6739
+ binary: require_binary(),
6740
+ float: require_float(),
6741
+ map: require_map(),
6742
+ null: require_null(),
6743
+ pairs: require_pairs(),
6744
+ set: require_set(),
6745
+ timestamp: require_timestamp(),
6746
+ bool: require_bool(),
6747
+ int: require_int(),
6748
+ merge: require_merge(),
6749
+ omap: require_omap(),
6750
+ seq: require_seq(),
6751
+ str: require_str()
6752
+ };
6753
+ module.exports.safeLoad = renamed("safeLoad", "load");
6754
+ module.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
6755
+ module.exports.safeDump = renamed("safeDump", "dump");
6756
+ })))(), 1);
6757
+ var { Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
6758
+ var index_vite_proxy_tmp_default = import_js_yaml.default;
6759
+
6760
+ //#endregion
6761
+ //#region ../graph-tools/dist/index.mjs
6762
+ /**
6763
+ * Converts a graph to an adjacency list representation.
6764
+ *
6765
+ * @example
6766
+ * ```ts
6767
+ * import { createGraph, toAdjacencyList } from '@statelyai/graph';
6768
+ *
6769
+ * const graph = createGraph({
6770
+ * nodes: { a: {}, b: {}, c: {} },
6771
+ * edges: [{ source: 'a', target: 'b' }, { source: 'a', target: 'c' }],
6772
+ * });
6773
+ *
6774
+ * toAdjacencyList(graph);
6775
+ * // { a: ['b', 'c'], b: [], c: [] }
6776
+ * ```
6777
+ */
6778
+ function toAdjacencyList(graph) {
6779
+ const adj = {};
6780
+ for (const node of graph.nodes) adj[node.id] = [];
6781
+ for (const edge of graph.edges) {
6782
+ adj[edge.sourceId]?.push(edge.targetId);
6783
+ if (graph.mode !== "directed") adj[edge.targetId]?.push(edge.sourceId);
6784
+ }
6785
+ return adj;
6786
+ }
6787
+ /**
6788
+ * Parses an adjacency list into a graph.
6789
+ *
6790
+ * @example
6791
+ * ```ts
6792
+ * import { fromAdjacencyList } from '@statelyai/graph';
6793
+ *
6794
+ * const graph = fromAdjacencyList({
6795
+ * a: ['b', 'c'],
6796
+ * b: ['c'],
6797
+ * c: [],
6798
+ * });
6799
+ *
6800
+ * graph.nodes; // [{id: 'a', ...}, {id: 'b', ...}, {id: 'c', ...}]
6801
+ * graph.edges; // [{sourceId: 'a', targetId: 'b', ...}, ...]
6802
+ * ```
6803
+ */
6804
+ function fromAdjacencyList(adj, options) {
6805
+ const directed = options?.directed ?? true;
6806
+ const seen = /* @__PURE__ */ new Set();
6807
+ const nodes = Object.keys(adj).map((id) => ({
6808
+ type: "node",
6809
+ id,
6810
+ parentId: null,
6811
+ initialNodeId: null,
6812
+ label: "",
6813
+ data: void 0
6814
+ }));
6815
+ const edges = [];
6816
+ let edgeIdx = 0;
6817
+ for (const [sourceId, targets] of Object.entries(adj)) for (const targetId of targets) {
6818
+ const key = directed ? `${sourceId}->${targetId}` : [sourceId, targetId].sort().join("<->");
6819
+ if (!seen.has(key)) {
6820
+ seen.add(key);
6821
+ edges.push({
6822
+ type: "edge",
6823
+ id: `e${edgeIdx++}`,
6824
+ sourceId,
6825
+ targetId,
6826
+ label: "",
6827
+ data: void 0
6828
+ });
6829
+ }
6830
+ }
6831
+ return {
6832
+ id: options?.id ?? "",
6833
+ mode: directed ? "directed" : "undirected",
6834
+ initialNodeId: null,
6835
+ nodes,
6836
+ edges,
6837
+ data: void 0
6838
+ };
6839
+ }
6840
+ /**
6841
+ * Converts a graph to an edge list of `[source, target]` tuples.
6842
+ *
6843
+ * @example
6844
+ * ```ts
6845
+ * import { createGraph, toEdgeList } from '@statelyai/graph';
6846
+ *
6847
+ * const graph = createGraph({
6848
+ * nodes: { a: {}, b: {}, c: {} },
6849
+ * edges: [{ source: 'a', target: 'b' }, { source: 'b', target: 'c' }],
6850
+ * });
6851
+ *
6852
+ * toEdgeList(graph);
6853
+ * // [['a', 'b'], ['b', 'c']]
6854
+ * ```
6855
+ */
6856
+ function toEdgeList(graph) {
6857
+ return graph.edges.map((e) => [e.sourceId, e.targetId]);
6858
+ }
6859
+ /**
6860
+ * Parses an edge list of `[source, target]` tuples into a graph.
6861
+ *
6862
+ * @example
6863
+ * ```ts
6864
+ * import { fromEdgeList } from '@statelyai/graph';
6865
+ *
6866
+ * const graph = fromEdgeList([
6867
+ * ['a', 'b'],
6868
+ * ['b', 'c'],
6869
+ * ]);
6870
+ *
6871
+ * graph.nodes; // [{id: 'a', ...}, {id: 'b', ...}, {id: 'c', ...}]
6872
+ * graph.edges; // [{sourceId: 'a', targetId: 'b', ...}, ...]
6873
+ * ```
6874
+ */
6875
+ function fromEdgeList(edges, options) {
6876
+ const directed = options?.directed ?? true;
6877
+ const nodeIds = /* @__PURE__ */ new Set();
6878
+ for (const [source, target] of edges) {
6879
+ nodeIds.add(source);
6880
+ nodeIds.add(target);
6881
+ }
6882
+ const nodes = [...nodeIds].map((id) => ({
6883
+ type: "node",
6884
+ id,
6885
+ parentId: null,
6886
+ initialNodeId: null,
6887
+ label: "",
6888
+ data: void 0
6889
+ }));
6890
+ const edgeObjects = edges.map(([sourceId, targetId], i) => ({
6891
+ type: "edge",
6892
+ id: `e${i}`,
6893
+ sourceId,
6894
+ targetId,
6895
+ label: "",
6896
+ data: void 0
6897
+ }));
6898
+ return {
6899
+ id: options?.id ?? "",
6900
+ mode: directed ? "directed" : "undirected",
6901
+ initialNodeId: null,
6902
+ nodes,
6903
+ edges: edgeObjects,
6904
+ data: void 0
6905
+ };
6906
+ }
6907
+ /**
6908
+ * Create a `GraphFormatConverter` from a pair of `to`/`from` functions.
6909
+ *
6910
+ * @example
6911
+ * ```ts
6912
+ * import { createFormatConverter } from '@statelyai/graph';
6913
+ *
6914
+ * const yamlConverter = createFormatConverter(
6915
+ * (graph) => toYAML(graph),
6916
+ * (yaml) => fromYAML(yaml),
6917
+ * );
6918
+ *
6919
+ * const yaml = yamlConverter.to(graph);
6920
+ * const graph = yamlConverter.from(yaml);
6921
+ * ```
6922
+ */
6923
+ function createFormatConverter(to, from) {
6924
+ return {
6925
+ to,
6926
+ from
6927
+ };
6928
+ }
6929
+ createFormatConverter(toAdjacencyList, fromAdjacencyList);
6930
+ createFormatConverter(toEdgeList, fromEdgeList);
6931
+ const LAYOUT_KEYS = {
6932
+ node: [
6933
+ "x",
6934
+ "y",
6935
+ "width",
6936
+ "height",
6937
+ "style",
6938
+ "color",
6939
+ "shape"
6940
+ ],
6941
+ edge: [
6942
+ "x",
6943
+ "y",
6944
+ "width",
6945
+ "height",
6946
+ "style",
6947
+ "color"
6948
+ ]
6949
+ };
6950
+ new Set(LAYOUT_KEYS.node), new Set(LAYOUT_KEYS.edge);
4431
6951
  function isAutoGeneratedId(id) {
4432
6952
  return !!id && id.startsWith("$auto-");
4433
6953
  }
@@ -4454,9 +6974,6 @@ function getEmittedNodeId(graph, node) {
4454
6974
  function getResolvedNodeId(graph, node) {
4455
6975
  return getEmittedNodeId(graph, node) ?? getDefaultPathId(graph, node);
4456
6976
  }
4457
-
4458
- //#endregion
4459
- //#region ../graph-tools/src/serializeJS.ts
4460
6977
  /**
4461
6978
  * Serializes JavaScript values as JS source code (not JSON).
4462
6979
  * - Unquoted keys for valid identifiers
@@ -4523,21 +7040,29 @@ function indentRawCode(code, indent) {
4523
7040
  const pad = " ".repeat(indent);
4524
7041
  return [lines[0], ...lines.slice(1).map((line) => line.trim() === "" ? "" : `${pad}${line}`)].join("\n");
4525
7042
  }
4526
-
4527
- //#endregion
4528
- //#region ../graph-tools/src/textUtils.ts
7043
+ /**
7044
+ * Pure string utilities used by codegen.
7045
+ */
7046
+ /**
7047
+ * Removes common leading whitespace from all non-empty lines.
7048
+ */
7049
+ function dedent(text) {
7050
+ const lines = text.split("\n");
7051
+ const nonEmptyLines = lines.filter((l) => l.trim().length > 0);
7052
+ if (nonEmptyLines.length === 0) return text;
7053
+ const minIndent = Math.min(...nonEmptyLines.map((l) => l.match(/^(\s*)/)[1].length));
7054
+ if (minIndent === 0) return text;
7055
+ return lines.map((l) => l.trim().length > 0 ? l.slice(minIndent) : l).join("\n");
7056
+ }
4529
7057
  /**
4530
7058
  * Strips `export default` wrapper from an expression string.
4531
7059
  * E.g. `"export default assign({ ... })"` → `"assign({ ... })"`
4532
7060
  */
4533
- function stripExportDefault$1(code) {
7061
+ function stripExportDefault(code) {
4534
7062
  const trimmed = code.trim();
4535
7063
  if (trimmed.startsWith("export default ")) return trimmed.slice(15).replace(/;$/, "");
4536
7064
  return trimmed;
4537
7065
  }
4538
-
4539
- //#endregion
4540
- //#region ../graph-tools/src/graphToMachineConfig.ts
4541
7066
  /**
4542
7067
  * Graph-native transition references. Transitions point at invoke/action/state
4543
7068
  * blocks by graph id (`@statelyai.*`); the literal `xstate.*` event is produced
@@ -4577,7 +7102,7 @@ function findInvokeByActorId(node, actorId) {
4577
7102
  return invokes.find((inv) => inv.id === actorId) ?? invokes.find((inv) => (inv.invocationId ?? inv.id) === actorId);
4578
7103
  }
4579
7104
  /** Resolve a spawn action block id to its spawned actor id (`params.id`). */
4580
- function resolveSpawnActorId(node, actionId) {
7105
+ function resolveSpawnActorId$1(node, actionId) {
4581
7106
  const spawnId = [...node.data.entry ?? [], ...node.data.exit ?? []].find((action) => action.id === actionId)?.params?.["id"];
4582
7107
  return typeof spawnId === "string" && spawnId ? spawnId : actionId;
4583
7108
  }
@@ -4731,7 +7256,7 @@ const XSTATE_BUILT_IN_ACTIONS = {
4731
7256
  importKind: "named",
4732
7257
  paramsSchema: builtInActionParamSchemas["xstate.enqueue"],
4733
7258
  emit(params) {
4734
- return typeof params?.code === "string" ? stripExportDefault$1(params.code) : "";
7259
+ return typeof params?.code === "string" ? stripExportDefault(params.code) : "";
4735
7260
  }
4736
7261
  },
4737
7262
  "xstate.raise": {
@@ -4850,11 +7375,11 @@ function actionCodeExpression(expr, source) {
4850
7375
  }]
4851
7376
  };
4852
7377
  }
4853
- function inlineCodeExpression(expr) {
7378
+ function inlineCodeExpression$1(expr) {
4854
7379
  return {
4855
7380
  "@type": "code",
4856
7381
  lang: "ts",
4857
- expr: stripExportDefault$1(expr)
7382
+ expr: stripExportDefault(expr)
4858
7383
  };
4859
7384
  }
4860
7385
  /**
@@ -4868,7 +7393,7 @@ function serializeGuard(guard, asTypeRef) {
4868
7393
  type: guard.type,
4869
7394
  params: guard.params
4870
7395
  } : { type: guard.type };
4871
- return guard.code ? inlineCodeExpression(guard.code) : guard;
7396
+ return guard.code ? inlineCodeExpression$1(guard.code) : guard;
4872
7397
  }
4873
7398
  /**
4874
7399
  * Converts a built-in xstate ActionItem to a code expression directive,
@@ -4876,13 +7401,13 @@ function serializeGuard(guard, asTypeRef) {
4876
7401
  */
4877
7402
  function serializeActionItem(action) {
4878
7403
  const { type, params } = action;
4879
- if (type === "xstate.enqueue" && typeof params?.code === "string") return inlineCodeExpression(params.code);
7404
+ if (type === "xstate.enqueue" && typeof params?.code === "string") return inlineCodeExpression$1(params.code);
4880
7405
  const exprCode = type === "xstate.expr" && typeof params?.code === "string" ? params.code : void 0;
4881
7406
  if (isBuiltInActionType(type)) {
4882
7407
  const builtInAction = XSTATE_BUILT_IN_ACTIONS[type];
4883
7408
  return actionCodeExpression(emitBuiltInAction(type, params), builtInAction);
4884
7409
  }
4885
- if (exprCode) return inlineCodeExpression(exprCode);
7410
+ if (exprCode) return inlineCodeExpression$1(exprCode);
4886
7411
  if (!params || Object.keys(params).length === 0) return { type };
4887
7412
  return {
4888
7413
  type,
@@ -4971,7 +7496,7 @@ function graphToMachineConfig(graph, options = {}) {
4971
7496
  else if (ref.kind === "stateDone") {
4972
7497
  if (!onDone[type]) onDone[type] = [];
4973
7498
  onDone[type].push(transitionObject);
4974
- } else pushOn(`xstate.${ref.kind === "actionDone" ? "done" : "error"}.actor.${resolveSpawnActorId(node, ref.blockId)}`);
7499
+ } else pushOn(`xstate.${ref.kind === "actionDone" ? "done" : "error"}.actor.${resolveSpawnActorId$1(node, ref.blockId)}`);
4975
7500
  else if (type === "" && node.data.type === "choice") choiceArr.push(transitionObject);
4976
7501
  else if (type === "") alwaysArr.push(transitionObject);
4977
7502
  else if (type.startsWith("xstate.after.")) {
@@ -5022,9 +7547,7 @@ function graphToMachineConfig(graph, options = {}) {
5022
7547
  if (graph.data.context !== void 0 && graph.data.context !== null) config.context = graph.data.context;
5023
7548
  return deepSimplify(config);
5024
7549
  }
5025
-
5026
- //#endregion
5027
- //#region src/jsonSchemaToTSType.ts
7550
+ const INLINE_EXPRESSION_DIRECTIVE_FIELDS = ["input", "output"];
5028
7551
  function jsonSchemaToTSType(schema) {
5029
7552
  if (!schema) return "unknown";
5030
7553
  if (schema.enum) return schema.enum.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join(" | ");
@@ -5101,35 +7624,6 @@ function isRequiredProperty(key, def, required) {
5101
7624
  if (required.has(key)) return true;
5102
7625
  return typeof def === "object" && def !== null && def.required === true;
5103
7626
  }
5104
-
5105
- //#endregion
5106
- //#region src/textUtils.ts
5107
- /**
5108
- * Pure string utilities used by codegen.
5109
- */
5110
- /**
5111
- * Removes common leading whitespace from all non-empty lines.
5112
- */
5113
- function dedent(text) {
5114
- const lines = text.split("\n");
5115
- const nonEmptyLines = lines.filter((l) => l.trim().length > 0);
5116
- if (nonEmptyLines.length === 0) return text;
5117
- const minIndent = Math.min(...nonEmptyLines.map((l) => l.match(/^(\s*)/)[1].length));
5118
- if (minIndent === 0) return text;
5119
- return lines.map((l) => l.trim().length > 0 ? l.slice(minIndent) : l).join("\n");
5120
- }
5121
- /**
5122
- * Strips `export default` wrapper from an expression string.
5123
- * E.g. `"export default assign({ ... })"` → `"assign({ ... })"`
5124
- */
5125
- function stripExportDefault(code) {
5126
- const trimmed = code.trim();
5127
- if (trimmed.startsWith("export default ")) return trimmed.slice(15).replace(/;$/, "");
5128
- return trimmed;
5129
- }
5130
-
5131
- //#endregion
5132
- //#region src/graphToXStateTS.ts
5133
7627
  function graphToXStateTS(graph, options = {}) {
5134
7628
  const { exportStyle = "named", targetLanguage = "typescript", xstateVersion = 5, ...configOptions } = options;
5135
7629
  const schemas = graph.data.schemas;
@@ -5506,6 +8000,1195 @@ function isCompleteFunctionExpression(code) {
5506
8000
  if (ts.isParenthesizedExpression(expression)) expression = expression.expression;
5507
8001
  return ts.isFunctionExpression(expression) || ts.isArrowFunction(expression);
5508
8002
  }
8003
+ const XSTATE_V6_FN_TRANSITION_META = "@statelyai.xstate.v6.fnTransition";
8004
+ const XSTATE_V6_FN_SOURCE_META = "@statelyai.xstate.v6.fnSource";
8005
+ function sourceFile(source) {
8006
+ return ts.createSourceFile("machine.ts", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
8007
+ }
8008
+ function propName(name) {
8009
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) return name.text;
8010
+ return null;
8011
+ }
8012
+ function unwrapExpression(node) {
8013
+ if (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isParenthesizedExpression(node)) return unwrapExpression(node.expression);
8014
+ return node;
8015
+ }
8016
+ function propertyContext(parent, key) {
8017
+ if (parent.transitionMap) return {
8018
+ v6: parent.v6,
8019
+ transitionValue: true
8020
+ };
8021
+ if (parent.transitionValue && key === "actions") return {
8022
+ v6: parent.v6,
8023
+ actionValue: true
8024
+ };
8025
+ if (parent.transitionValue && key === "context") return {
8026
+ v6: parent.v6,
8027
+ assignmentMap: true,
8028
+ transitionContext: true
8029
+ };
8030
+ if (parent.assignmentMap) return {
8031
+ v6: parent.v6,
8032
+ assignmentValue: true
8033
+ };
8034
+ if (key === "meta") return {
8035
+ v6: parent.v6,
8036
+ metaValue: true
8037
+ };
8038
+ if (parent.transitionValue && key === "to") return {
8039
+ v6: parent.v6,
8040
+ transitionValue: true
8041
+ };
8042
+ if (key === "entry" || key === "exit") return {
8043
+ v6: parent.v6,
8044
+ actionValue: true
8045
+ };
8046
+ if (key === "input" || key === "output") return {
8047
+ v6: parent.v6,
8048
+ ioValue: true
8049
+ };
8050
+ if (key === "on" || key === "after") return {
8051
+ v6: parent.v6,
8052
+ transitionMap: true
8053
+ };
8054
+ if (key === "always" || key === "choice" || key === "onDone" || key === "onError" || key === "onSnapshot" || key === "onTimeout") return {
8055
+ v6: parent.v6,
8056
+ transitionValue: true
8057
+ };
8058
+ return { v6: parent.v6 };
8059
+ }
8060
+ function fallbackFunctionTransition(fn, actions = []) {
8061
+ return {
8062
+ ...actions.length ? { actions } : void 0,
8063
+ meta: {
8064
+ [XSTATE_V6_FN_TRANSITION_META]: true,
8065
+ [XSTATE_V6_FN_SOURCE_META]: fn.getText()
8066
+ }
8067
+ };
8068
+ }
8069
+ function conditionText(cond) {
8070
+ return cond.negated ? `!(${cond.text})` : cond.text;
8071
+ }
8072
+ function simplifyConditions(conds) {
8073
+ const seen = /* @__PURE__ */ new Set();
8074
+ return conds.filter((cond) => {
8075
+ if (cond.negated) return false;
8076
+ const key = conditionText(cond);
8077
+ if (seen.has(key)) return false;
8078
+ seen.add(key);
8079
+ return true;
8080
+ });
8081
+ }
8082
+ function hashString(value) {
8083
+ let hash = 5381;
8084
+ for (let i = 0; i < value.length; i++) hash = hash * 33 ^ value.charCodeAt(i);
8085
+ return (hash >>> 0).toString(36);
8086
+ }
8087
+ function inlineGuardCode(params, condition) {
8088
+ return `${params} => ${condition}`;
8089
+ }
8090
+ function guardFromConditions(conds, params) {
8091
+ const simplified = simplifyConditions(conds);
8092
+ if (simplified.length === 0) return void 0;
8093
+ const code = inlineGuardCode(params, simplified.map(conditionText).join(" && "));
8094
+ return {
8095
+ type: `inline:${hashString(code)}`,
8096
+ code
8097
+ };
8098
+ }
8099
+ function wrapAssignExpression(expr) {
8100
+ return `{{ ${expr.trim()} }}`;
8101
+ }
8102
+ function hasSpreadAssignment(node) {
8103
+ return node.properties.some((property) => ts.isSpreadAssignment(property));
8104
+ }
8105
+ function mergeActions(left, right) {
8106
+ return [...left ?? [], ...right];
8107
+ }
8108
+ function transitionFromValue(value, actions) {
8109
+ if (typeof value === "string") {
8110
+ if (actions.length === 0) return value;
8111
+ return {
8112
+ target: value,
8113
+ actions
8114
+ };
8115
+ }
8116
+ if (!value || typeof value !== "object" || Array.isArray(value)) return actions.length ? { actions } : null;
8117
+ const record = { ...value };
8118
+ if (actions.length) record.actions = mergeActions(Array.isArray(record.actions) ? record.actions : record.actions ? [record.actions] : void 0, actions);
8119
+ return record;
8120
+ }
8121
+ function expressionBranches(expression, bindings, depth) {
8122
+ const node = unwrapExpression(expression);
8123
+ if (ts.isConditionalExpression(node)) {
8124
+ const cond = node.condition.getText();
8125
+ return [...expressionBranches(node.whenTrue, bindings, depth + 1).map((branch) => ({
8126
+ ...branch,
8127
+ conds: [{ text: cond }, ...branch.conds]
8128
+ })), ...expressionBranches(node.whenFalse, bindings, depth + 1).map((branch) => ({
8129
+ ...branch,
8130
+ conds: [{
8131
+ text: cond,
8132
+ negated: true
8133
+ }, ...branch.conds]
8134
+ }))];
8135
+ }
8136
+ if (ts.isBinaryExpression(node) && (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken || node.operatorToken.kind === ts.SyntaxKind.BarBarToken)) {
8137
+ const cond = node.left.getText();
8138
+ if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) return [...expressionBranches(node.right, bindings, depth + 1).map((branch) => ({
8139
+ ...branch,
8140
+ conds: [{ text: cond }, ...branch.conds]
8141
+ })), {
8142
+ conds: [{
8143
+ text: cond,
8144
+ negated: true
8145
+ }],
8146
+ actions: []
8147
+ }];
8148
+ return [{
8149
+ conds: [{ text: cond }],
8150
+ actions: [],
8151
+ result: node.left.getText()
8152
+ }, ...expressionBranches(node.right, bindings, depth + 1).map((branch) => ({
8153
+ ...branch,
8154
+ conds: [{
8155
+ text: cond,
8156
+ negated: true
8157
+ }, ...branch.conds]
8158
+ }))];
8159
+ }
8160
+ if (ts.isObjectLiteralExpression(node)) {
8161
+ const targetProperty = node.properties.find((property) => ts.isPropertyAssignment(property) && propName(property.name) === "target");
8162
+ const target = targetProperty ? unwrapExpression(targetProperty.initializer) : null;
8163
+ if (target && (ts.isConditionalExpression(target) || ts.isBinaryExpression(target) && (target.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken || target.operatorToken.kind === ts.SyntaxKind.BarBarToken))) return expressionBranches(target, bindings, depth + 1).map((branch) => ({
8164
+ ...branch,
8165
+ result: objectLiteralToValue(node, bindings, {
8166
+ v6: true,
8167
+ transitionValue: true
8168
+ }, depth + 1, new Map([["target", branch.result]]))
8169
+ }));
8170
+ }
8171
+ return [{
8172
+ conds: [],
8173
+ actions: [],
8174
+ result: expressionToValue(node, bindings, {
8175
+ v6: true,
8176
+ transitionValue: true
8177
+ }, depth + 1)
8178
+ }];
8179
+ }
8180
+ function mergeBranchPrefix(prefix, branch) {
8181
+ return {
8182
+ conds: [...prefix.conds, ...branch.conds],
8183
+ actions: [...prefix.actions, ...branch.actions],
8184
+ result: branch.result,
8185
+ unknown: prefix.unknown || branch.unknown
8186
+ };
8187
+ }
8188
+ function expressionStatementAction(statement, enqName, bindings) {
8189
+ const expression = unwrapExpression(statement.expression);
8190
+ if (!ts.isCallExpression(expression)) return null;
8191
+ const callee = expression.expression;
8192
+ if (ts.isIdentifier(callee) && callee.text === enqName) return {
8193
+ type: "xstate.expr",
8194
+ params: {
8195
+ code: expression.getText(),
8196
+ lang: "ts"
8197
+ }
8198
+ };
8199
+ if (!ts.isPropertyAccessExpression(callee)) return null;
8200
+ if (!ts.isIdentifier(callee.expression) || callee.expression.text !== enqName) return null;
8201
+ const method = callee.name.text;
8202
+ const args = expression.arguments;
8203
+ const value = (index) => {
8204
+ const arg = args[index];
8205
+ return arg && ts.isExpression(arg) ? expressionToValue(arg, bindings, {}, 0) : void 0;
8206
+ };
8207
+ const spreadOpts = (index) => {
8208
+ const opts = value(index);
8209
+ return opts && typeof opts === "object" && !Array.isArray(opts) ? opts : {};
8210
+ };
8211
+ if (method === "emit") return {
8212
+ type: "xstate.emit",
8213
+ params: { event: value(0) }
8214
+ };
8215
+ if (method === "raise") return {
8216
+ type: "xstate.raise",
8217
+ params: {
8218
+ event: value(0),
8219
+ ...spreadOpts(1)
8220
+ }
8221
+ };
8222
+ if (method === "sendTo") return {
8223
+ type: "xstate.sendTo",
8224
+ params: {
8225
+ to: value(0),
8226
+ event: value(1),
8227
+ ...spreadOpts(2)
8228
+ }
8229
+ };
8230
+ if (method === "cancel") return {
8231
+ type: "xstate.cancel",
8232
+ params: { sendId: value(0) }
8233
+ };
8234
+ if (method === "log") return {
8235
+ type: "xstate.log",
8236
+ params: { label: value(0) }
8237
+ };
8238
+ if (method === "spawn") return {
8239
+ type: "xstate.spawnChild",
8240
+ params: {
8241
+ src: value(0),
8242
+ ...spreadOpts(1)
8243
+ }
8244
+ };
8245
+ if (method === "stop") return {
8246
+ type: "xstate.stopChild",
8247
+ params: { actorRef: value(0) }
8248
+ };
8249
+ return {
8250
+ type: "xstate.expr",
8251
+ params: {
8252
+ code: expression.getText(),
8253
+ lang: "ts"
8254
+ }
8255
+ };
8256
+ }
8257
+ function statementBranches(statements, bindings, enqName, prefixes = [{
8258
+ conds: [],
8259
+ actions: []
8260
+ }]) {
8261
+ let open = prefixes;
8262
+ const done = [];
8263
+ const scopedBindings = new Map(bindings);
8264
+ for (const statement of statements) {
8265
+ const nextOpen = [];
8266
+ for (const prefix of open) {
8267
+ if (ts.isVariableStatement(statement)) {
8268
+ for (const declaration of statement.declarationList.declarations) if (ts.isIdentifier(declaration.name) && declaration.initializer) scopedBindings.set(declaration.name.text, declaration.initializer);
8269
+ nextOpen.push(prefix);
8270
+ continue;
8271
+ }
8272
+ if (ts.isReturnStatement(statement)) {
8273
+ if (!statement.expression) {
8274
+ done.push({
8275
+ ...prefix,
8276
+ result: void 0
8277
+ });
8278
+ continue;
8279
+ }
8280
+ for (const branch of expressionBranches(statement.expression, scopedBindings, 0)) done.push(mergeBranchPrefix(prefix, branch));
8281
+ continue;
8282
+ }
8283
+ if (ts.isExpressionStatement(statement)) {
8284
+ const action = expressionStatementAction(statement, enqName, scopedBindings);
8285
+ if (action) {
8286
+ nextOpen.push({
8287
+ ...prefix,
8288
+ actions: [...prefix.actions, action]
8289
+ });
8290
+ continue;
8291
+ }
8292
+ }
8293
+ if (ts.isIfStatement(statement)) {
8294
+ const cond = statement.expression.getText();
8295
+ const thenBranches = statementBranches(ts.isBlock(statement.thenStatement) ? statement.thenStatement.statements : [statement.thenStatement], scopedBindings, enqName, [{
8296
+ ...prefix,
8297
+ conds: [...prefix.conds, { text: cond }]
8298
+ }]);
8299
+ const elseStatements = statement.elseStatement ? ts.isBlock(statement.elseStatement) ? statement.elseStatement.statements : [statement.elseStatement] : [];
8300
+ const elseBranches = elseStatements.length > 0 ? statementBranches(elseStatements, scopedBindings, enqName, [{
8301
+ ...prefix,
8302
+ conds: [...prefix.conds, {
8303
+ text: cond,
8304
+ negated: true
8305
+ }]
8306
+ }]) : [{
8307
+ ...prefix,
8308
+ conds: [...prefix.conds, {
8309
+ text: cond,
8310
+ negated: true
8311
+ }]
8312
+ }];
8313
+ for (const branch of [...thenBranches, ...elseBranches]) if ("result" in branch) done.push(branch);
8314
+ else nextOpen.push(branch);
8315
+ continue;
8316
+ }
8317
+ if (ts.isSwitchStatement(statement)) {
8318
+ const expr = statement.expression.getText();
8319
+ const prior = [];
8320
+ for (const clause of statement.caseBlock.clauses) {
8321
+ const ownCond = ts.isCaseClause(clause) ? { text: `${expr} === ${clause.expression.getText()}` } : null;
8322
+ const conds = ownCond ? [...prior, ownCond] : prior.length ? [...prior] : [];
8323
+ const branches = statementBranches(clause.statements, scopedBindings, enqName, [{
8324
+ ...prefix,
8325
+ conds: [...prefix.conds, ...conds]
8326
+ }]);
8327
+ for (const branch of branches) if ("result" in branch) done.push(branch);
8328
+ else nextOpen.push(branch);
8329
+ if (ownCond) prior.push({
8330
+ ...ownCond,
8331
+ negated: true
8332
+ });
8333
+ }
8334
+ continue;
8335
+ }
8336
+ nextOpen.push({
8337
+ ...prefix,
8338
+ unknown: true
8339
+ });
8340
+ }
8341
+ open = nextOpen;
8342
+ }
8343
+ return [...done, ...open];
8344
+ }
8345
+ function enqueueParamName(fn) {
8346
+ const param = fn.parameters[1];
8347
+ return param && ts.isIdentifier(param.name) ? param.name.text : "enq";
8348
+ }
8349
+ function guardParams(fn) {
8350
+ const param = fn.parameters[0];
8351
+ if (!param) return "()";
8352
+ return `(${param.getText()})`;
8353
+ }
8354
+ function normalizeFunctionTransition(fn, bindings, depth) {
8355
+ const preservedActions = fn.body && ts.isBlock(fn.body) && fn.body.statements.some((statement) => ts.isExpressionStatement(statement)) ? [enqueueAction(fn)] : [];
8356
+ const transitions = (ts.isArrowFunction(fn) && !ts.isBlock(fn.body) ? expressionBranches(fn.body, bindings, depth + 1) : fn.body && ts.isBlock(fn.body) ? statementBranches(fn.body.statements, bindings, enqueueParamName(fn)) : []).filter((branch) => !branch.unknown).map((branch) => {
8357
+ const transition = transitionFromValue(branch.result, branch.actions.length ? preservedActions : []);
8358
+ if (!transition) return null;
8359
+ if (typeof transition === "string") {
8360
+ const guard = guardFromConditions(branch.conds, guardParams(fn));
8361
+ return guard ? {
8362
+ target: transition,
8363
+ guard
8364
+ } : transition;
8365
+ }
8366
+ const guard = guardFromConditions(branch.conds, guardParams(fn));
8367
+ return guard ? {
8368
+ ...transition,
8369
+ guard
8370
+ } : transition;
8371
+ }).filter((transition) => Boolean(transition));
8372
+ if (transitions.length === 1) return transitions[0];
8373
+ if (transitions.length > 1) return transitions;
8374
+ return fallbackFunctionTransition(fn, preservedActions);
8375
+ }
8376
+ function inlineAction(fn) {
8377
+ return {
8378
+ type: "xstate.expr",
8379
+ params: {
8380
+ code: fn.getText(),
8381
+ lang: "ts"
8382
+ }
8383
+ };
8384
+ }
8385
+ function enqueueAction(fn) {
8386
+ return {
8387
+ type: "xstate.enqueue",
8388
+ params: {
8389
+ code: fn.getText(),
8390
+ lang: "ts"
8391
+ }
8392
+ };
8393
+ }
8394
+ function inlineCodeExpression(expr) {
8395
+ return {
8396
+ "@type": "code",
8397
+ lang: "ts",
8398
+ expr
8399
+ };
8400
+ }
8401
+ function normalizeFunctionAction(fn, _bindings) {
8402
+ return enqueueAction(fn);
8403
+ }
8404
+ function objectLiteralToValue(node, bindings, context, depth, overrides = /* @__PURE__ */ new Map()) {
8405
+ const result = {};
8406
+ for (const property of node.properties) {
8407
+ if (ts.isSpreadAssignment(property)) {
8408
+ const spread = expressionToValue(property.expression, bindings, context, depth + 1);
8409
+ if (spread && typeof spread === "object" && !Array.isArray(spread)) Object.assign(result, spread);
8410
+ continue;
8411
+ }
8412
+ if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property)) continue;
8413
+ const key = propName(property.name);
8414
+ if (!key) continue;
8415
+ if (overrides.has(key)) {
8416
+ result[key] = overrides.get(key);
8417
+ continue;
8418
+ }
8419
+ if (ts.isShorthandPropertyAssignment(property)) {
8420
+ result[key] = expressionToValue(property.name, bindings, propertyContext(context, key), depth + 1);
8421
+ continue;
8422
+ }
8423
+ result[key] = expressionToValue(property.initializer, bindings, propertyContext(context, key), depth + 1);
8424
+ }
8425
+ if (context.transitionValue && "to" in result) {
8426
+ const to = result.to;
8427
+ const { to: _to, ...rest } = result;
8428
+ if (typeof to === "string") return {
8429
+ ...rest,
8430
+ target: to
8431
+ };
8432
+ if (Array.isArray(to)) return to.map((item) => typeof item === "string" ? {
8433
+ ...rest,
8434
+ target: item
8435
+ } : item && typeof item === "object" ? {
8436
+ ...rest,
8437
+ ...item
8438
+ } : rest);
8439
+ if (to && typeof to === "object" && !Array.isArray(to)) return {
8440
+ ...rest,
8441
+ ...to
8442
+ };
8443
+ }
8444
+ return result;
8445
+ }
8446
+ function expressionToValue(expression, bindings, context = {}, depth = 0) {
8447
+ if (depth > 30) return void 0;
8448
+ const node = unwrapExpression(expression);
8449
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return context.ioValue ? inlineCodeExpression(JSON.stringify(node.text)) : node.text;
8450
+ if (ts.isNumericLiteral(node)) return context.ioValue ? inlineCodeExpression(node.text) : Number(node.text);
8451
+ if (node.kind === ts.SyntaxKind.TrueKeyword) return context.ioValue ? inlineCodeExpression("true") : true;
8452
+ if (node.kind === ts.SyntaxKind.FalseKeyword) return context.ioValue ? inlineCodeExpression("false") : false;
8453
+ if (node.kind === ts.SyntaxKind.NullKeyword) return context.ioValue ? inlineCodeExpression("null") : null;
8454
+ if (context.assignmentValue) {
8455
+ if (ts.isIdentifier(node) && node.text === "undefined") return void 0;
8456
+ return wrapAssignExpression(node.getText());
8457
+ }
8458
+ if (context.transitionContext && !ts.isObjectLiteralExpression(node)) return inlineCodeExpression(node.getText());
8459
+ if (context.ioValue && !ts.isObjectLiteralExpression(node)) return inlineCodeExpression(node.getText());
8460
+ if (context.transitionContext && ts.isObjectLiteralExpression(node) && hasSpreadAssignment(node)) return inlineCodeExpression(node.getText());
8461
+ if (ts.isIdentifier(node)) {
8462
+ if (node.text === "undefined") return void 0;
8463
+ const binding = bindings.get(node.text);
8464
+ return binding ? expressionToValue(binding, bindings, context, depth + 1) : context.metaValue ? inlineCodeExpression(node.getText()) : node.text;
8465
+ }
8466
+ if (ts.isObjectLiteralExpression(node)) return objectLiteralToValue(node, bindings, context, depth);
8467
+ if (ts.isArrayLiteralExpression(node)) {
8468
+ const values = node.elements.map((element) => expressionToValue(element, bindings, context, depth + 1));
8469
+ return context.actionValue ? values.flat() : values;
8470
+ }
8471
+ if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
8472
+ if (context.metaValue) return inlineCodeExpression(node.getText());
8473
+ if (context.v6 && context.transitionValue) return normalizeFunctionTransition(node, bindings, depth);
8474
+ if (context.v6 && context.actionValue) return normalizeFunctionAction(node, bindings);
8475
+ return node.getText();
8476
+ }
8477
+ if (ts.isCallExpression(node)) {
8478
+ if (context.metaValue) return inlineCodeExpression(node.getText());
8479
+ if (context.actionValue) return inlineAction(node);
8480
+ const callee = node.expression.getText();
8481
+ const type = callee.includes(".") ? callee.split(".").pop() : callee;
8482
+ return { type: type === "assign" ? "xstate.assign" : type };
8483
+ }
8484
+ return context.metaValue ? inlineCodeExpression(node.getText()) : node.getText();
8485
+ }
8486
+ function collectBindings(file) {
8487
+ const bindings = /* @__PURE__ */ new Map();
8488
+ for (const statement of file.statements) {
8489
+ if (!ts.isVariableStatement(statement)) continue;
8490
+ for (const declaration of statement.declarationList.declarations) if (ts.isIdentifier(declaration.name) && declaration.initializer) bindings.set(declaration.name.text, declaration.initializer);
8491
+ }
8492
+ return bindings;
8493
+ }
8494
+ function isCreateMachineCall(node) {
8495
+ const expression = node.expression;
8496
+ if (ts.isIdentifier(expression)) return expression.text === "createMachine";
8497
+ if (ts.isPropertyAccessExpression(expression)) return expression.name.text === "createMachine";
8498
+ return false;
8499
+ }
8500
+ function hasV6Syntax(source) {
8501
+ const file = sourceFile(source);
8502
+ let found = false;
8503
+ function visit(node) {
8504
+ if (found) return;
8505
+ if (ts.isPropertyAssignment(node) && (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name))) {
8506
+ const key = node.name.text;
8507
+ if (key === "triggers" || key === "internalEvents" || key === "timeout" || key === "onTimeout" || key === "choice" || key === "route") {
8508
+ found = true;
8509
+ return;
8510
+ }
8511
+ if ((key === "on" || key === "after" || key === "always" || key === "choice" || key === "onDone" || key === "onError" || key === "onSnapshot" || key === "onTimeout" || key === "entry" || key === "exit" || key === "actions" && !ts.isObjectLiteralExpression(node.initializer)) && node.initializer.getText().includes("=>")) {
8512
+ found = true;
8513
+ return;
8514
+ }
8515
+ }
8516
+ ts.forEachChild(node, visit);
8517
+ }
8518
+ visit(file);
8519
+ return found;
8520
+ }
8521
+ function detectXStateSourceProfile(source) {
8522
+ return hasV6Syntax(source) ? "xstate-v6-alpha" : "xstate-v5";
8523
+ }
8524
+ function xstateSourceToConfig(source, options = {}) {
8525
+ const file = sourceFile(source);
8526
+ const bindings = collectBindings(file);
8527
+ let found = null;
8528
+ const profile = options.profile === "auto" || !options.profile ? detectXStateSourceProfile(source) : options.profile;
8529
+ function visit(node) {
8530
+ if (found || !ts.isCallExpression(node) || !isCreateMachineCall(node)) {
8531
+ ts.forEachChild(node, visit);
8532
+ return;
8533
+ }
8534
+ const arg = node.arguments[0];
8535
+ if (!arg) return;
8536
+ const value = expressionToValue(arg, bindings, { v6: profile === "xstate-v6-alpha" });
8537
+ if (value && typeof value === "object" && !Array.isArray(value)) found = value;
8538
+ }
8539
+ visit(file);
8540
+ if (!found) throw new Error("No createMachine(...) or setup(...).createMachine(...) call found.");
8541
+ return found;
8542
+ }
8543
+ const colorSchema = _enum([
8544
+ "green",
8545
+ "red",
8546
+ "purple",
8547
+ "blue",
8548
+ "orange",
8549
+ "yellow",
8550
+ "pink",
8551
+ "teal"
8552
+ ]);
8553
+ const stateTypeSchema = _enum([
8554
+ "normal",
8555
+ "parallel",
8556
+ "history",
8557
+ "final"
8558
+ ]).nullable();
8559
+ const actionLocationSchema$1 = union([object({
8560
+ nodeId: string(),
8561
+ group: _enum(["entry", "exit"])
8562
+ }), object({
8563
+ edgeId: string(),
8564
+ group: literal("transition")
8565
+ })]);
8566
+ const createStatePatchSchema$1 = object({
8567
+ op: literal("createState"),
8568
+ description: string().optional(),
8569
+ id: string().optional(),
8570
+ parentId: string(),
8571
+ key: string(),
8572
+ type: stateTypeSchema.optional(),
8573
+ x: number().optional(),
8574
+ y: number().optional(),
8575
+ color: colorSchema.nullable().optional(),
8576
+ initial: boolean().optional()
8577
+ });
8578
+ const updateStatePatchSchema$1 = object({
8579
+ op: literal("updateState"),
8580
+ description: string().optional(),
8581
+ stateId: string(),
8582
+ key: string().optional(),
8583
+ type: stateTypeSchema.optional(),
8584
+ stateDescription: string().optional(),
8585
+ initialId: string().nullable().optional(),
8586
+ color: colorSchema.nullable().optional(),
8587
+ meta: record(string(), unknown()).nullable().optional(),
8588
+ history: _enum(["shallow", "deep"]).nullable().optional()
8589
+ });
8590
+ const deleteStatePatchSchema$1 = object({
8591
+ op: literal("deleteState"),
8592
+ description: string().optional(),
8593
+ stateId: string()
8594
+ });
8595
+ const guardSchema = object({
8596
+ type: string(),
8597
+ code: string().optional(),
8598
+ params: record(string(), unknown()).optional()
8599
+ });
8600
+ const createTransitionPatchSchema$1 = object({
8601
+ op: literal("createTransition"),
8602
+ description: string().optional(),
8603
+ id: string().optional(),
8604
+ sourceId: string(),
8605
+ targetId: string(),
8606
+ eventType: string(),
8607
+ transitionType: _enum([
8608
+ "normal",
8609
+ "targetless",
8610
+ "reenter"
8611
+ ]).optional(),
8612
+ guard: guardSchema.optional(),
8613
+ color: colorSchema.nullable().optional(),
8614
+ transitionDescription: string().nullable().optional()
8615
+ });
8616
+ const updateTransitionPatchSchema$1 = object({
8617
+ op: literal("updateTransition"),
8618
+ description: string().optional(),
8619
+ transitionId: string(),
8620
+ sourceId: string().optional(),
8621
+ targetId: string().optional(),
8622
+ eventType: string().optional(),
8623
+ transitionType: _enum([
8624
+ "normal",
8625
+ "targetless",
8626
+ "reenter"
8627
+ ]).optional(),
8628
+ transitionDescription: string().nullable().optional(),
8629
+ color: colorSchema.nullable().optional(),
8630
+ meta: record(string(), unknown()).nullable().optional()
8631
+ });
8632
+ const deleteTransitionPatchSchema$1 = object({
8633
+ op: literal("deleteTransition"),
8634
+ description: string().optional(),
8635
+ transitionId: string()
8636
+ });
8637
+ const createActionPatchSchema$1 = object({
8638
+ op: literal("createAction"),
8639
+ description: string().optional(),
8640
+ location: actionLocationSchema$1,
8641
+ action: object({
8642
+ id: string().optional(),
8643
+ type: string(),
8644
+ params: record(string(), unknown()).optional()
8645
+ }),
8646
+ index: number().optional()
8647
+ });
8648
+ const updateActionPatchSchema$1 = object({
8649
+ op: literal("updateAction"),
8650
+ description: string().optional(),
8651
+ location: actionLocationSchema$1,
8652
+ actionId: string(),
8653
+ data: object({
8654
+ type: string().optional(),
8655
+ params: record(string(), unknown()).optional()
8656
+ })
8657
+ });
8658
+ const deleteActionPatchSchema$1 = object({
8659
+ op: literal("deleteAction"),
8660
+ description: string().optional(),
8661
+ location: actionLocationSchema$1,
8662
+ actionId: string()
8663
+ });
8664
+ const setGuardPatchSchema$1 = object({
8665
+ op: literal("setGuard"),
8666
+ description: string().optional(),
8667
+ edgeId: string(),
8668
+ guard: guardSchema
8669
+ });
8670
+ const deleteGuardPatchSchema$1 = object({
8671
+ op: literal("deleteGuard"),
8672
+ description: string().optional(),
8673
+ edgeId: string()
8674
+ });
8675
+ const machinePatchSchema = discriminatedUnion("op", [
8676
+ createStatePatchSchema$1,
8677
+ updateStatePatchSchema$1,
8678
+ deleteStatePatchSchema$1,
8679
+ createTransitionPatchSchema$1,
8680
+ updateTransitionPatchSchema$1,
8681
+ deleteTransitionPatchSchema$1,
8682
+ createActionPatchSchema$1,
8683
+ updateActionPatchSchema$1,
8684
+ deleteActionPatchSchema$1,
8685
+ setGuardPatchSchema$1,
8686
+ deleteGuardPatchSchema$1
8687
+ ]);
8688
+ const validationLevelSchema = _enum([
8689
+ "info",
8690
+ "warning",
8691
+ "error"
8692
+ ]);
8693
+ const validationIssueKindSchema = _enum([
8694
+ "correctness",
8695
+ "reachability",
8696
+ "optimization",
8697
+ "maintainability",
8698
+ "security"
8699
+ ]);
8700
+ const validationIssueCodeSchema = _enum([
8701
+ "parse_error",
8702
+ "unsupported_format",
8703
+ "empty_state_key",
8704
+ "invalid_state_key",
8705
+ "duplicate_state_key",
8706
+ "history_initial",
8707
+ "missing_initial",
8708
+ "invalid_initial",
8709
+ "unreachable_state",
8710
+ "final_state_invokes",
8711
+ "invalid_state_children",
8712
+ "empty_parallel",
8713
+ "single_child_compound",
8714
+ "noop_transient_state",
8715
+ "on_done_unreachable",
8716
+ "duplicate_transition",
8717
+ "invalid_delay",
8718
+ "repeated_guard",
8719
+ "transition_never_taken",
8720
+ "missing_guard",
8721
+ "redundant_transition",
8722
+ "eventless_cycle",
8723
+ "missing_delay_implementation",
8724
+ "invalid_final_transition",
8725
+ "invalid_history_transition",
8726
+ "parallel_region_transition",
8727
+ "duplicate_source_name",
8728
+ "undefined_action",
8729
+ "undefined_guard",
8730
+ "undefined_actor"
8731
+ ]);
8732
+ const validationFixKindSchema = _enum([
8733
+ "patch",
8734
+ "rewrite",
8735
+ "advice",
8736
+ "proposedPatch"
8737
+ ]);
8738
+ const validationFixSourceSchema = _enum(["deterministic", "llm"]);
8739
+ const validationIssueTargetSchema = object({
8740
+ nodeIds: array(string()).optional(),
8741
+ edgeIds: array(string()).optional(),
8742
+ source: object({
8743
+ path: string().optional(),
8744
+ start: number().optional(),
8745
+ end: number().optional()
8746
+ }).optional()
8747
+ });
8748
+ const validationFixSchema = object({
8749
+ kind: validationFixKindSchema,
8750
+ source: validationFixSourceSchema,
8751
+ title: string(),
8752
+ patches: array(unknown()).optional(),
8753
+ output: unknown().optional(),
8754
+ diff: unknown().optional(),
8755
+ confidence: number().optional(),
8756
+ rationale: string().optional(),
8757
+ rank: number().optional(),
8758
+ postValidation: object({
8759
+ ok: boolean(),
8760
+ remainingIssueCodes: array(validationIssueCodeSchema)
8761
+ }).optional()
8762
+ });
8763
+ const validationIssueSchema = object({
8764
+ code: validationIssueCodeSchema,
8765
+ kind: validationIssueKindSchema,
8766
+ level: validationLevelSchema,
8767
+ message: string(),
8768
+ target: validationIssueTargetSchema,
8769
+ metadata: record(string(), unknown()).optional(),
8770
+ fixes: array(validationFixSchema).optional(),
8771
+ source: _enum(["deterministic", "llm"]).optional(),
8772
+ nodeIds: array(string()),
8773
+ edgeIds: array(string())
8774
+ });
8775
+ const machineFormatSchema = _enum([
8776
+ "xstate",
8777
+ "json",
8778
+ "yaml",
8779
+ "scxml",
8780
+ "mermaid"
8781
+ ]);
8782
+ const xstateSourceProfileSchema = _enum([
8783
+ "auto",
8784
+ "xstate-v5",
8785
+ "xstate-v6-alpha"
8786
+ ]);
8787
+ const machineInputSchema = object({
8788
+ machine: union([record(string(), unknown()), string()]),
8789
+ format: machineFormatSchema.optional(),
8790
+ profile: xstateSourceProfileSchema.optional(),
8791
+ xstateVersion: union([literal(5), literal(6)]).optional()
8792
+ });
8793
+ const graphSchema = record(string(), unknown());
8794
+ const convertMachineFormatInputSchema = object({
8795
+ machine: union([record(string(), unknown()), string()]).optional(),
8796
+ graph: graphSchema.optional(),
8797
+ format: machineFormatSchema.optional(),
8798
+ to: machineFormatSchema
8799
+ }).refine((value) => Boolean(value.machine) !== Boolean(value.graph), { message: "Provide exactly one of machine or graph." });
8800
+ const applyMachinePatchesInputSchema = object({
8801
+ graph: graphSchema,
8802
+ patches: array(machinePatchSchema),
8803
+ outputFormat: machineFormatSchema.default("json")
8804
+ });
8805
+ const diffMachinesInputSchema = object({
8806
+ left: machineInputSchema,
8807
+ right: machineInputSchema,
8808
+ includePatches: boolean().optional()
8809
+ });
8810
+ const generateMachinePathsInputSchema = machineInputSchema.extend({
8811
+ targetPath: array(string()).optional(),
8812
+ kind: _enum(["shortest", "simple"]).default("shortest"),
8813
+ max: number().int().positive().optional()
8814
+ });
8815
+ const simulateMachineStepInputSchema = machineInputSchema.extend({
8816
+ stateValue: unknown(),
8817
+ event: object({ type: string() }).passthrough(),
8818
+ guardState: record(string(), boolean()).optional()
8819
+ });
8820
+ const pointSchema = object({
8821
+ x: number(),
8822
+ y: number()
8823
+ });
8824
+ const canvasColorSchema = _enum([
8825
+ "green",
8826
+ "red",
8827
+ "purple",
8828
+ "blue",
8829
+ "orange",
8830
+ "yellow",
8831
+ "pink",
8832
+ "teal"
8833
+ ]);
8834
+ const editorStateTypeSchema = _enum([
8835
+ "normal",
8836
+ "parallel",
8837
+ "history",
8838
+ "final",
8839
+ "choice"
8840
+ ]).nullable();
8841
+ const actionLocationSchema = union([object({
8842
+ nodeId: string(),
8843
+ group: _enum(["entry", "exit"])
8844
+ }), object({
8845
+ edgeId: string(),
8846
+ group: literal("transition")
8847
+ })]);
8848
+ const implementationSourceTypeSchema = _enum([
8849
+ "action",
8850
+ "guard",
8851
+ "actor",
8852
+ "delay"
8853
+ ]);
8854
+ const createNodePatchSchema = object({
8855
+ op: literal("createNode"),
8856
+ description: string().optional(),
8857
+ id: string().optional(),
8858
+ parentId: string(),
8859
+ key: string(),
8860
+ type: editorStateTypeSchema.optional(),
8861
+ x: number().optional(),
8862
+ y: number().optional()
8863
+ });
8864
+ const updateNodePatchSchema = object({
8865
+ op: literal("updateNode"),
8866
+ description: string().optional(),
8867
+ nodeId: string(),
8868
+ data: object({
8869
+ key: string().optional(),
8870
+ type: editorStateTypeSchema.optional(),
8871
+ description: string().optional(),
8872
+ initialId: string().nullable().optional()
8873
+ })
8874
+ });
8875
+ const deleteNodePatchSchema = object({
8876
+ op: literal("deleteNode"),
8877
+ description: string().optional(),
8878
+ nodeId: string()
8879
+ });
8880
+ const createEdgePatchSchema = object({
8881
+ op: literal("createEdge"),
8882
+ description: string().optional(),
8883
+ id: string().optional(),
8884
+ sourceId: string(),
8885
+ targetId: string(),
8886
+ eventType: string(),
8887
+ transitionType: _enum([
8888
+ "normal",
8889
+ "targetless",
8890
+ "reenter"
8891
+ ]).optional()
8892
+ });
8893
+ const updateEdgePatchSchema = object({
8894
+ op: literal("updateEdge"),
8895
+ description: string().optional(),
8896
+ edgeId: string(),
8897
+ data: object({
8898
+ sourceId: string().optional(),
8899
+ targetId: string().optional(),
8900
+ eventType: string().optional(),
8901
+ transitionType: _enum([
8902
+ "normal",
8903
+ "targetless",
8904
+ "reenter"
8905
+ ]).optional(),
8906
+ description: string().nullable().optional()
8907
+ })
8908
+ });
8909
+ const deleteEdgePatchSchema = object({
8910
+ op: literal("deleteEdge"),
8911
+ description: string().optional(),
8912
+ edgeId: string()
8913
+ });
8914
+ const createStatePatchSchema = object({
8915
+ op: literal("createState"),
8916
+ description: string().optional(),
8917
+ id: string().optional(),
8918
+ parentId: string(),
8919
+ key: string(),
8920
+ type: editorStateTypeSchema.optional(),
8921
+ x: number().optional(),
8922
+ y: number().optional(),
8923
+ color: canvasColorSchema.nullable().optional(),
8924
+ initial: boolean().optional()
8925
+ });
8926
+ const updateStatePatchSchema = object({
8927
+ op: literal("updateState"),
8928
+ description: string().optional(),
8929
+ stateId: string(),
8930
+ key: string().optional(),
8931
+ type: editorStateTypeSchema.optional(),
8932
+ stateDescription: string().optional(),
8933
+ initialId: string().nullable().optional(),
8934
+ color: canvasColorSchema.nullable().optional(),
8935
+ meta: record(string(), unknown()).nullable().optional(),
8936
+ history: _enum(["shallow", "deep"]).nullable().optional()
8937
+ });
8938
+ const deleteStatePatchSchema = object({
8939
+ op: literal("deleteState"),
8940
+ description: string().optional(),
8941
+ stateId: string()
8942
+ });
8943
+ const createTransitionPatchSchema = object({
8944
+ op: literal("createTransition"),
8945
+ description: string().optional(),
8946
+ id: string().optional(),
8947
+ sourceId: string(),
8948
+ targetId: string(),
8949
+ eventType: string(),
8950
+ transitionType: _enum([
8951
+ "normal",
8952
+ "targetless",
8953
+ "reenter"
8954
+ ]).optional(),
8955
+ guard: object({
8956
+ type: string(),
8957
+ code: string().optional(),
8958
+ params: record(string(), unknown()).optional()
8959
+ }).optional(),
8960
+ color: canvasColorSchema.nullable().optional(),
8961
+ transitionDescription: string().nullable().optional()
8962
+ });
8963
+ const updateTransitionPatchSchema = object({
8964
+ op: literal("updateTransition"),
8965
+ description: string().optional(),
8966
+ transitionId: string(),
8967
+ sourceId: string().optional(),
8968
+ targetId: string().optional(),
8969
+ eventType: string().optional(),
8970
+ transitionType: _enum([
8971
+ "normal",
8972
+ "targetless",
8973
+ "reenter"
8974
+ ]).optional(),
8975
+ transitionDescription: string().nullable().optional(),
8976
+ color: canvasColorSchema.nullable().optional(),
8977
+ meta: record(string(), unknown()).nullable().optional()
8978
+ });
8979
+ const deleteTransitionPatchSchema = object({
8980
+ op: literal("deleteTransition"),
8981
+ description: string().optional(),
8982
+ transitionId: string()
8983
+ });
8984
+ const createActionPatchSchema = object({
8985
+ op: literal("createAction"),
8986
+ description: string().optional(),
8987
+ location: actionLocationSchema,
8988
+ action: object({
8989
+ id: string().optional(),
8990
+ type: string(),
8991
+ params: record(string(), unknown()).optional()
8992
+ }),
8993
+ index: number().optional()
8994
+ });
8995
+ const updateActionPatchSchema = object({
8996
+ op: literal("updateAction"),
8997
+ description: string().optional(),
8998
+ location: actionLocationSchema,
8999
+ actionId: string(),
9000
+ data: object({
9001
+ type: string().optional(),
9002
+ params: record(string(), unknown()).optional()
9003
+ })
9004
+ });
9005
+ const deleteActionPatchSchema = object({
9006
+ op: literal("deleteAction"),
9007
+ description: string().optional(),
9008
+ location: actionLocationSchema,
9009
+ actionId: string()
9010
+ });
9011
+ const createInvokePatchSchema = object({
9012
+ op: literal("createInvoke"),
9013
+ description: string().optional(),
9014
+ nodeId: string(),
9015
+ invoke: object({
9016
+ id: string().optional(),
9017
+ invocationId: string().optional(),
9018
+ src: string(),
9019
+ code: string().optional(),
9020
+ input: record(string(), unknown()).optional(),
9021
+ output: record(string(), unknown()).optional()
9022
+ })
9023
+ });
9024
+ const updateInvokePatchSchema = object({
9025
+ op: literal("updateInvoke"),
9026
+ description: string().optional(),
9027
+ nodeId: string(),
9028
+ invokeId: string(),
9029
+ data: object({
9030
+ invocationId: string().optional(),
9031
+ src: string().optional(),
9032
+ code: string().optional(),
9033
+ input: record(string(), unknown()).optional(),
9034
+ output: record(string(), unknown()).optional()
9035
+ })
9036
+ });
9037
+ const deleteInvokePatchSchema = object({
9038
+ op: literal("deleteInvoke"),
9039
+ description: string().optional(),
9040
+ nodeId: string(),
9041
+ invokeId: string()
9042
+ });
9043
+ const implementationPatchDataSchema = object({
9044
+ id: string(),
9045
+ name: string().optional(),
9046
+ code: string().optional()
9047
+ });
9048
+ const createImplementationPatchSchema = object({
9049
+ op: literal("createImplementation"),
9050
+ description: string().optional(),
9051
+ sourceType: implementationSourceTypeSchema,
9052
+ implementation: implementationPatchDataSchema
9053
+ });
9054
+ const updateImplementationPatchSchema = object({
9055
+ op: literal("updateImplementation"),
9056
+ description: string().optional(),
9057
+ sourceType: implementationSourceTypeSchema,
9058
+ implementationId: string(),
9059
+ data: object({
9060
+ name: string().optional(),
9061
+ code: string().optional()
9062
+ })
9063
+ });
9064
+ const deleteImplementationPatchSchema = object({
9065
+ op: literal("deleteImplementation"),
9066
+ description: string().optional(),
9067
+ sourceType: implementationSourceTypeSchema,
9068
+ implementationId: string()
9069
+ });
9070
+ const setGuardPatchSchema = object({
9071
+ op: literal("setGuard"),
9072
+ description: string().optional(),
9073
+ edgeId: string(),
9074
+ guard: object({
9075
+ type: string(),
9076
+ code: string().optional(),
9077
+ params: record(string(), unknown()).optional()
9078
+ })
9079
+ });
9080
+ const deleteGuardPatchSchema = object({
9081
+ op: literal("deleteGuard"),
9082
+ description: string().optional(),
9083
+ edgeId: string()
9084
+ });
9085
+ const createTagPatchSchema = object({
9086
+ op: literal("createTag"),
9087
+ description: string().optional(),
9088
+ nodeId: string(),
9089
+ tag: object({ name: string() })
9090
+ });
9091
+ const deleteTagPatchSchema = object({
9092
+ op: literal("deleteTag"),
9093
+ description: string().optional(),
9094
+ nodeId: string(),
9095
+ tagName: string()
9096
+ });
9097
+ const createAnnotationPatchSchema = object({
9098
+ op: literal("createAnnotation"),
9099
+ description: string().optional(),
9100
+ id: string().optional(),
9101
+ parentId: string().nullable(),
9102
+ content: string(),
9103
+ x: number().optional(),
9104
+ y: number().optional()
9105
+ });
9106
+ const updateAnnotationPatchSchema = object({
9107
+ op: literal("updateAnnotation"),
9108
+ description: string().optional(),
9109
+ annotationId: string(),
9110
+ data: object({ content: string().optional() })
9111
+ });
9112
+ const deleteAnnotationPatchSchema = object({
9113
+ op: literal("deleteAnnotation"),
9114
+ description: string().optional(),
9115
+ annotationId: string()
9116
+ });
9117
+ const setContextPatchSchema = object({
9118
+ op: literal("setContext"),
9119
+ description: string().optional(),
9120
+ context: record(string(), unknown())
9121
+ });
9122
+ const updateSchemasPatchSchema = object({
9123
+ op: literal("updateSchemas"),
9124
+ description: string().optional(),
9125
+ schemas: object({
9126
+ context: record(string(), unknown()).nullable().optional(),
9127
+ events: record(string(), unknown()).nullable().optional(),
9128
+ input: unknown().nullable().optional(),
9129
+ output: unknown().nullable().optional()
9130
+ })
9131
+ });
9132
+ /** Full union: generic graph ops + semantic state machine ops */
9133
+ const graphPatchSchema = discriminatedUnion("op", [
9134
+ createNodePatchSchema,
9135
+ updateNodePatchSchema,
9136
+ deleteNodePatchSchema,
9137
+ createEdgePatchSchema,
9138
+ updateEdgePatchSchema,
9139
+ deleteEdgePatchSchema,
9140
+ createStatePatchSchema,
9141
+ updateStatePatchSchema,
9142
+ deleteStatePatchSchema,
9143
+ createTransitionPatchSchema,
9144
+ updateTransitionPatchSchema,
9145
+ deleteTransitionPatchSchema,
9146
+ createActionPatchSchema,
9147
+ updateActionPatchSchema,
9148
+ deleteActionPatchSchema,
9149
+ createInvokePatchSchema,
9150
+ updateInvokePatchSchema,
9151
+ deleteInvokePatchSchema,
9152
+ createImplementationPatchSchema,
9153
+ updateImplementationPatchSchema,
9154
+ deleteImplementationPatchSchema,
9155
+ setGuardPatchSchema,
9156
+ deleteGuardPatchSchema,
9157
+ createTagPatchSchema,
9158
+ deleteTagPatchSchema,
9159
+ createAnnotationPatchSchema,
9160
+ updateAnnotationPatchSchema,
9161
+ deleteAnnotationPatchSchema,
9162
+ setContextPatchSchema,
9163
+ updateSchemasPatchSchema
9164
+ ]);
9165
+ /** AI-only schema: semantic ops + shared ops (no generic graph ops) */
9166
+ const aiPatchSchema = discriminatedUnion("op", [
9167
+ createStatePatchSchema,
9168
+ updateStatePatchSchema,
9169
+ deleteStatePatchSchema,
9170
+ createTransitionPatchSchema,
9171
+ updateTransitionPatchSchema,
9172
+ deleteTransitionPatchSchema,
9173
+ createActionPatchSchema,
9174
+ updateActionPatchSchema,
9175
+ deleteActionPatchSchema,
9176
+ createInvokePatchSchema,
9177
+ updateInvokePatchSchema,
9178
+ deleteInvokePatchSchema,
9179
+ createImplementationPatchSchema,
9180
+ updateImplementationPatchSchema,
9181
+ deleteImplementationPatchSchema,
9182
+ setGuardPatchSchema,
9183
+ deleteGuardPatchSchema,
9184
+ createTagPatchSchema,
9185
+ deleteTagPatchSchema,
9186
+ createAnnotationPatchSchema,
9187
+ updateAnnotationPatchSchema,
9188
+ deleteAnnotationPatchSchema,
9189
+ setContextPatchSchema,
9190
+ updateSchemasPatchSchema
9191
+ ]);
5509
9192
 
5510
9193
  //#endregion
5511
- export { upsertStatelyPragma as S, string as _, graphToMachineConfig as a, findStatelyPragmaAttachments as b, serializeJS as c, boolean as d, discriminatedUnion as f, record as g, object as h, jsonSchemaToTSType as i, _enum as l, number as m, contextSchemaToTSType as n, RawCode as o, literal as p, eventsSchemaToTSType as r, raw as s, graphToXStateTS as t, array as u, union as v, getStatelyPragma as x, unknown as y };
9194
+ export { eventsSchemaToTSType as a, jsonSchemaToTSType as c, xstateSourceToConfig as d, findStatelyPragmaAttachments as f, detectXStateSourceProfile as i, raw as l, upsertStatelyPragma as m, RawCode as n, graphToMachineConfig as o, getStatelyPragma as p, contextSchemaToTSType as r, graphToXStateTS as s, INLINE_EXPRESSION_DIRECTIVE_FIELDS as t, serializeJS as u };