@pactflow/openapi-pact-comparator 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -4177,2388 +4177,2230 @@ function useColor() {
4177
4177
 
4178
4178
  const program = new Command();
4179
4179
 
4180
- var version = "2.2.0";
4180
+ var version = "2.3.0";
4181
4181
  var packageJson = {
4182
4182
  version: version};
4183
4183
 
4184
- /*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT */
4185
- //#region \0rolldown/runtime.js
4186
- var __create = Object.create;
4187
- var __defProp = Object.defineProperty;
4188
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4189
- var __getOwnPropNames = Object.getOwnPropertyNames;
4190
- var __getProtoOf = Object.getPrototypeOf;
4191
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4192
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4193
- var __copyProps = (to, from, except, desc) => {
4194
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
4195
- key = keys[i];
4196
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
4197
- get: ((k) => from[k]).bind(null, key),
4198
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
4199
- });
4200
- }
4201
- return to;
4202
- };
4203
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(__defProp(target, "default", {
4204
- value: mod,
4205
- enumerable: true
4206
- }) , mod));
4207
- //#endregion
4208
- //#region lib/common.js
4209
- var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4210
- function isNothing(subject) {
4211
- return typeof subject === "undefined" || subject === null;
4212
- }
4213
- function isObject(subject) {
4214
- return typeof subject === "object" && subject !== null;
4215
- }
4216
- function toArray(sequence) {
4217
- if (Array.isArray(sequence)) return sequence;
4218
- else if (isNothing(sequence)) return [];
4219
- return [sequence];
4220
- }
4221
- function extend(target, source) {
4222
- if (source) {
4223
- const sourceKeys = Object.keys(source);
4224
- for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
4225
- const key = sourceKeys[index];
4226
- target[key] = source[key];
4227
- }
4228
- }
4229
- return target;
4230
- }
4231
- function repeat(string, count) {
4232
- let result = "";
4233
- for (let cycle = 0; cycle < count; cycle += 1) result += string;
4234
- return result;
4235
- }
4236
- function isNegativeZero(number) {
4237
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
4238
- }
4239
- module.exports.isNothing = isNothing;
4240
- module.exports.isObject = isObject;
4241
- module.exports.toArray = toArray;
4242
- module.exports.repeat = repeat;
4243
- module.exports.isNegativeZero = isNegativeZero;
4244
- module.exports.extend = extend;
4245
- }));
4246
- //#endregion
4247
- //#region lib/exception.js
4248
- var require_exception = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4249
- function formatError(exception, compact) {
4250
- let where = "";
4251
- const message = exception.reason || "(unknown reason)";
4252
- if (!exception.mark) return message;
4253
- if (exception.mark.name) where += "in \"" + exception.mark.name + "\" ";
4254
- where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
4255
- if (!compact && exception.mark.snippet) where += "\n\n" + exception.mark.snippet;
4256
- return message + " " + where;
4257
- }
4258
- function YAMLException(reason, mark) {
4259
- Error.call(this);
4260
- this.name = "YAMLException";
4261
- this.reason = reason;
4262
- this.mark = mark;
4263
- this.message = formatError(this, false);
4264
- if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
4265
- else this.stack = (/* @__PURE__ */ new Error()).stack || "";
4266
- }
4267
- YAMLException.prototype = Object.create(Error.prototype);
4268
- YAMLException.prototype.constructor = YAMLException;
4269
- YAMLException.prototype.toString = function toString(compact) {
4270
- return this.name + ": " + formatError(this, compact);
4184
+ /*! js-yaml 5.2.1 https://github.com/nodeca/js-yaml @license MIT */
4185
+ //#region src/tag.ts
4186
+ var NOT_RESOLVED = Symbol("NOT_RESOLVED");
4187
+ var MERGE_KEY = Symbol("MERGE_KEY");
4188
+ function defineScalarTag(tagName, options) {
4189
+ return {
4190
+ tagName,
4191
+ nodeKind: "scalar",
4192
+ implicit: options.implicit ?? false,
4193
+ matchByTagPrefix: options.matchByTagPrefix ?? false,
4194
+ implicitFirstChars: options.implicitFirstChars ?? null,
4195
+ resolve: options.resolve,
4196
+ identify: options.identify ?? null,
4197
+ represent: options.represent ?? ((data) => String(data)),
4198
+ representTagName: options.representTagName ?? null
4271
4199
  };
4272
- module.exports = YAMLException;
4273
- }));
4200
+ }
4201
+ function defineSequenceTag(tagName, options) {
4202
+ const carrierIsResult = options.finalize === void 0;
4203
+ return {
4204
+ tagName,
4205
+ nodeKind: "sequence",
4206
+ implicit: false,
4207
+ matchByTagPrefix: options.matchByTagPrefix ?? false,
4208
+ create: options.create,
4209
+ addItem: options.addItem,
4210
+ finalize: options.finalize ?? ((carrier) => carrier),
4211
+ carrierIsResult,
4212
+ identify: options.identify ?? null,
4213
+ represent: options.represent ?? ((data) => data),
4214
+ representTagName: options.representTagName ?? null
4215
+ };
4216
+ }
4217
+ function defineMappingTag(tagName, options) {
4218
+ const carrierIsResult = options.finalize === void 0;
4219
+ return {
4220
+ tagName,
4221
+ nodeKind: "mapping",
4222
+ implicit: false,
4223
+ matchByTagPrefix: options.matchByTagPrefix ?? false,
4224
+ create: options.create,
4225
+ addPair: options.addPair,
4226
+ has: options.has,
4227
+ keys: options.keys,
4228
+ get: options.get,
4229
+ finalize: options.finalize ?? ((carrier) => carrier),
4230
+ carrierIsResult,
4231
+ identify: options.identify ?? null,
4232
+ represent: options.represent ?? ((data) => data),
4233
+ representTagName: options.representTagName ?? null
4234
+ };
4235
+ }
4274
4236
  //#endregion
4275
- //#region lib/snippet.js
4276
- var require_snippet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4277
- var common = require_common();
4278
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
4279
- let head = "";
4280
- let tail = "";
4281
- const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
4282
- if (position - lineStart > maxHalfLength) {
4283
- head = " ... ";
4284
- lineStart = position - maxHalfLength + head.length;
4285
- }
4286
- if (lineEnd - position > maxHalfLength) {
4287
- tail = " ...";
4288
- lineEnd = position + maxHalfLength - tail.length;
4289
- }
4290
- return {
4291
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
4292
- pos: position - lineStart + head.length
4293
- };
4294
- }
4295
- function padStart(string, max) {
4296
- return common.repeat(" ", max - string.length) + string;
4297
- }
4298
- function makeSnippet(mark, options) {
4299
- options = Object.create(options || null);
4300
- if (!mark.buffer) return null;
4301
- if (!options.maxLength) options.maxLength = 79;
4302
- if (typeof options.indent !== "number") options.indent = 1;
4303
- if (typeof options.linesBefore !== "number") options.linesBefore = 3;
4304
- if (typeof options.linesAfter !== "number") options.linesAfter = 2;
4305
- const re = /\r?\n|\r|\0/g;
4306
- const lineStarts = [0];
4307
- const lineEnds = [];
4308
- let match;
4309
- let foundLineNo = -1;
4310
- while (match = re.exec(mark.buffer)) {
4311
- lineEnds.push(match.index);
4312
- lineStarts.push(match.index + match[0].length);
4313
- if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
4314
- }
4315
- if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
4316
- let result = "";
4317
- const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
4318
- const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
4319
- for (let i = 1; i <= options.linesBefore; i++) {
4320
- if (foundLineNo - i < 0) break;
4321
- const line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
4322
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
4323
- }
4324
- const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
4325
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
4326
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
4327
- for (let i = 1; i <= options.linesAfter; i++) {
4328
- if (foundLineNo + i >= lineEnds.length) break;
4329
- const line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
4330
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
4331
- }
4332
- return result.replace(/\n$/, "");
4333
- }
4334
- module.exports = makeSnippet;
4335
- }));
4237
+ //#region src/tag/scalar/str.ts
4238
+ var strTag = defineScalarTag("tag:yaml.org,2002:str", {
4239
+ resolve: (source) => source,
4240
+ identify: (data) => typeof data === "string"
4241
+ });
4336
4242
  //#endregion
4337
- //#region lib/type.js
4338
- var require_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4339
- var YAMLException = require_exception();
4340
- var TYPE_CONSTRUCTOR_OPTIONS = [
4341
- "kind",
4342
- "multi",
4343
- "resolve",
4344
- "construct",
4345
- "instanceOf",
4346
- "predicate",
4347
- "represent",
4348
- "representName",
4349
- "defaultStyle",
4350
- "styleAliases"
4351
- ];
4352
- var YAML_NODE_KINDS = [
4353
- "scalar",
4354
- "sequence",
4355
- "mapping"
4356
- ];
4357
- function compileStyleAliases(map) {
4358
- const result = {};
4359
- if (map !== null) Object.keys(map).forEach(function(style) {
4360
- map[style].forEach(function(alias) {
4361
- result[String(alias)] = style;
4362
- });
4363
- });
4364
- return result;
4365
- }
4366
- function Type(tag, options) {
4367
- options = options || {};
4368
- Object.keys(options).forEach(function(name) {
4369
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) throw new YAMLException("Unknown option \"" + name + "\" is met in definition of \"" + tag + "\" YAML type.");
4370
- });
4371
- this.options = options;
4372
- this.tag = tag;
4373
- this.kind = options["kind"] || null;
4374
- this.resolve = options["resolve"] || function() {
4375
- return true;
4376
- };
4377
- this.construct = options["construct"] || function(data) {
4378
- return data;
4379
- };
4380
- this.instanceOf = options["instanceOf"] || null;
4381
- this.predicate = options["predicate"] || null;
4382
- this.represent = options["represent"] || null;
4383
- this.representName = options["representName"] || null;
4384
- this.defaultStyle = options["defaultStyle"] || null;
4385
- this.multi = options["multi"] || false;
4386
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
4387
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) throw new YAMLException("Unknown kind \"" + this.kind + "\" is specified for \"" + tag + "\" YAML type.");
4388
- }
4389
- module.exports = Type;
4390
- }));
4243
+ //#region src/tag/scalar/null_core.ts
4244
+ var NULL_VALUES$1 = [
4245
+ "",
4246
+ "~",
4247
+ "null",
4248
+ "Null",
4249
+ "NULL"
4250
+ ];
4251
+ var nullCoreTag = defineScalarTag("tag:yaml.org,2002:null", {
4252
+ implicit: true,
4253
+ implicitFirstChars: [
4254
+ "",
4255
+ "~",
4256
+ "n",
4257
+ "N"
4258
+ ],
4259
+ resolve: (source) => {
4260
+ if (NULL_VALUES$1.indexOf(source) !== -1) return null;
4261
+ return NOT_RESOLVED;
4262
+ },
4263
+ identify: (object) => object === null,
4264
+ represent: () => "null"
4265
+ });
4391
4266
  //#endregion
4392
- //#region lib/schema.js
4393
- var require_schema = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4394
- var YAMLException = require_exception();
4395
- var Type = require_type();
4396
- function compileList(schema, name) {
4397
- const result = [];
4398
- schema[name].forEach(function(currentType) {
4399
- let newIndex = result.length;
4400
- result.forEach(function(previousType, previousIndex) {
4401
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) newIndex = previousIndex;
4402
- });
4403
- result[newIndex] = currentType;
4404
- });
4405
- return result;
4406
- }
4407
- function compileMap() {
4408
- const result = {
4409
- scalar: {},
4410
- sequence: {},
4411
- mapping: {},
4412
- fallback: {},
4413
- multi: {
4414
- scalar: [],
4415
- sequence: [],
4416
- mapping: [],
4417
- fallback: []
4418
- }
4419
- };
4420
- function collectType(type) {
4421
- if (type.multi) {
4422
- result.multi[type.kind].push(type);
4423
- result.multi["fallback"].push(type);
4424
- } else result[type.kind][type.tag] = result["fallback"][type.tag] = type;
4425
- }
4426
- for (let index = 0, length = arguments.length; index < length; index += 1) arguments[index].forEach(collectType);
4427
- return result;
4428
- }
4429
- function Schema(definition) {
4430
- return this.extend(definition);
4431
- }
4432
- Schema.prototype.extend = function extend(definition) {
4433
- let implicit = [];
4434
- let explicit = [];
4435
- if (definition instanceof Type) explicit.push(definition);
4436
- else if (Array.isArray(definition)) explicit = explicit.concat(definition);
4437
- else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
4438
- if (definition.implicit) implicit = implicit.concat(definition.implicit);
4439
- if (definition.explicit) explicit = explicit.concat(definition.explicit);
4440
- } else throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
4441
- implicit.forEach(function(type) {
4442
- if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
4443
- 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.");
4444
- 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.");
4445
- });
4446
- explicit.forEach(function(type) {
4447
- if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
4448
- });
4449
- const result = Object.create(Schema.prototype);
4450
- result.implicit = (this.implicit || []).concat(implicit);
4451
- result.explicit = (this.explicit || []).concat(explicit);
4452
- result.compiledImplicit = compileList(result, "implicit");
4453
- result.compiledExplicit = compileList(result, "explicit");
4454
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
4455
- return result;
4456
- };
4457
- module.exports = Schema;
4458
- }));
4267
+ //#region src/tag/scalar/null_json.ts
4268
+ var nullJsonTag = defineScalarTag("tag:yaml.org,2002:null", {
4269
+ implicit: true,
4270
+ implicitFirstChars: ["n"],
4271
+ resolve: (source, isExplicit) => {
4272
+ if (source === "null" || isExplicit && source === "") return null;
4273
+ return NOT_RESOLVED;
4274
+ },
4275
+ identify: (object) => object === null,
4276
+ represent: () => "null"
4277
+ });
4459
4278
  //#endregion
4460
- //#region lib/type/str.js
4461
- var require_str = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4462
- module.exports = new (require_type())("tag:yaml.org,2002:str", {
4463
- kind: "scalar",
4464
- construct: function(data) {
4465
- return data !== null ? data : "";
4466
- }
4467
- });
4468
- }));
4279
+ //#region src/tag/scalar/null_yaml11.ts
4280
+ var NULL_VALUES = [
4281
+ "",
4282
+ "~",
4283
+ "null",
4284
+ "Null",
4285
+ "NULL"
4286
+ ];
4287
+ var nullYaml11Tag = defineScalarTag("tag:yaml.org,2002:null", {
4288
+ implicit: true,
4289
+ implicitFirstChars: [
4290
+ "",
4291
+ "~",
4292
+ "n",
4293
+ "N"
4294
+ ],
4295
+ resolve: (source) => {
4296
+ if (NULL_VALUES.indexOf(source) !== -1) return null;
4297
+ return NOT_RESOLVED;
4298
+ },
4299
+ identify: (object) => object === null,
4300
+ represent: () => "null"
4301
+ });
4469
4302
  //#endregion
4470
- //#region lib/type/seq.js
4471
- var require_seq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4472
- module.exports = new (require_type())("tag:yaml.org,2002:seq", {
4473
- kind: "sequence",
4474
- construct: function(data) {
4475
- return data !== null ? data : [];
4476
- }
4477
- });
4478
- }));
4303
+ //#region src/tag/scalar/bool_core.ts
4304
+ var TRUE_VALUES$2 = [
4305
+ "true",
4306
+ "True",
4307
+ "TRUE"
4308
+ ];
4309
+ var FALSE_VALUES$2 = [
4310
+ "false",
4311
+ "False",
4312
+ "FALSE"
4313
+ ];
4314
+ var boolCoreTag = defineScalarTag("tag:yaml.org,2002:bool", {
4315
+ implicit: true,
4316
+ implicitFirstChars: [
4317
+ "t",
4318
+ "T",
4319
+ "f",
4320
+ "F"
4321
+ ],
4322
+ resolve: (source) => {
4323
+ if (TRUE_VALUES$2.indexOf(source) !== -1) return true;
4324
+ if (FALSE_VALUES$2.indexOf(source) !== -1) return false;
4325
+ return NOT_RESOLVED;
4326
+ },
4327
+ identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
4328
+ represent: (object) => object ? "true" : "false"
4329
+ });
4479
4330
  //#endregion
4480
- //#region lib/type/map.js
4481
- var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4482
- module.exports = new (require_type())("tag:yaml.org,2002:map", {
4483
- kind: "mapping",
4484
- construct: function(data) {
4485
- return data !== null ? data : {};
4486
- }
4487
- });
4488
- }));
4331
+ //#region src/tag/scalar/bool_json.ts
4332
+ var TRUE_VALUES$1 = ["true"];
4333
+ var FALSE_VALUES$1 = ["false"];
4334
+ var boolJsonTag = defineScalarTag("tag:yaml.org,2002:bool", {
4335
+ implicit: true,
4336
+ implicitFirstChars: ["t", "f"],
4337
+ resolve: (source) => {
4338
+ if (TRUE_VALUES$1.indexOf(source) !== -1) return true;
4339
+ if (FALSE_VALUES$1.indexOf(source) !== -1) return false;
4340
+ return NOT_RESOLVED;
4341
+ },
4342
+ identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
4343
+ represent: (object) => object ? "true" : "false"
4344
+ });
4489
4345
  //#endregion
4490
- //#region lib/schema/failsafe.js
4491
- var require_failsafe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4492
- module.exports = new (require_schema())({ explicit: [
4493
- require_str(),
4494
- require_seq(),
4495
- require_map()
4496
- ] });
4497
- }));
4346
+ //#region src/tag/scalar/bool_yaml11.ts
4347
+ var TRUE_VALUES = [
4348
+ "true",
4349
+ "True",
4350
+ "TRUE",
4351
+ "y",
4352
+ "Y",
4353
+ "yes",
4354
+ "Yes",
4355
+ "YES",
4356
+ "on",
4357
+ "On",
4358
+ "ON"
4359
+ ];
4360
+ var FALSE_VALUES = [
4361
+ "false",
4362
+ "False",
4363
+ "FALSE",
4364
+ "n",
4365
+ "N",
4366
+ "no",
4367
+ "No",
4368
+ "NO",
4369
+ "off",
4370
+ "Off",
4371
+ "OFF"
4372
+ ];
4373
+ var boolYaml11Tag = defineScalarTag("tag:yaml.org,2002:bool", {
4374
+ implicit: true,
4375
+ implicitFirstChars: [
4376
+ "y",
4377
+ "Y",
4378
+ "n",
4379
+ "N",
4380
+ "t",
4381
+ "T",
4382
+ "f",
4383
+ "F",
4384
+ "o",
4385
+ "O"
4386
+ ],
4387
+ resolve: (source) => {
4388
+ if (TRUE_VALUES.indexOf(source) !== -1) return true;
4389
+ if (FALSE_VALUES.indexOf(source) !== -1) return false;
4390
+ return NOT_RESOLVED;
4391
+ },
4392
+ identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
4393
+ represent: (object) => object ? "true" : "false"
4394
+ });
4498
4395
  //#endregion
4499
- //#region lib/type/null.js
4500
- var require_null = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4501
- var Type = require_type();
4502
- function resolveYamlNull(data) {
4503
- if (data === null) return true;
4504
- const max = data.length;
4505
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
4506
- }
4507
- function constructYamlNull() {
4508
- return null;
4509
- }
4510
- function isNull(object) {
4511
- return object === null;
4512
- }
4513
- module.exports = new Type("tag:yaml.org,2002:null", {
4514
- kind: "scalar",
4515
- resolve: resolveYamlNull,
4516
- construct: constructYamlNull,
4517
- predicate: isNull,
4518
- represent: {
4519
- canonical: function() {
4520
- return "~";
4521
- },
4522
- lowercase: function() {
4523
- return "null";
4524
- },
4525
- uppercase: function() {
4526
- return "NULL";
4527
- },
4528
- camelcase: function() {
4529
- return "Null";
4530
- },
4531
- empty: function() {
4532
- return "";
4533
- }
4534
- },
4535
- defaultStyle: "lowercase"
4536
- });
4537
- }));
4396
+ //#region src/tag/scalar/int_core.ts
4397
+ var YAML_INTEGER_IMPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
4398
+ var YAML_INTEGER_EXPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
4399
+ function parseYamlInteger$2(source) {
4400
+ let value = source;
4401
+ let sign = 1;
4402
+ if (value[0] === "-" || value[0] === "+") {
4403
+ if (value[0] === "-") sign = -1;
4404
+ value = value.slice(1);
4405
+ }
4406
+ if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
4407
+ if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
4408
+ if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
4409
+ return sign * parseInt(value, 10);
4410
+ }
4411
+ function resolveYamlInteger$2(source, isExplicit) {
4412
+ if (isExplicit) {
4413
+ if (!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
4414
+ } else if (!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
4415
+ const result = parseYamlInteger$2(source);
4416
+ return Number.isFinite(result) ? result : NOT_RESOLVED;
4417
+ }
4418
+ var intCoreTag = defineScalarTag("tag:yaml.org,2002:int", {
4419
+ implicit: true,
4420
+ implicitFirstChars: [
4421
+ "-",
4422
+ "+",
4423
+ ..."0123456789"
4424
+ ],
4425
+ resolve: resolveYamlInteger$2,
4426
+ identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
4427
+ represent: (object) => object.toString(10)
4428
+ });
4538
4429
  //#endregion
4539
- //#region lib/type/bool.js
4540
- var require_bool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4541
- var Type = require_type();
4542
- function resolveYamlBoolean(data) {
4543
- if (data === null) return false;
4544
- const max = data.length;
4545
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
4546
- }
4547
- function constructYamlBoolean(data) {
4548
- return data === "true" || data === "True" || data === "TRUE";
4549
- }
4550
- function isBoolean(object) {
4551
- return Object.prototype.toString.call(object) === "[object Boolean]";
4552
- }
4553
- module.exports = new Type("tag:yaml.org,2002:bool", {
4554
- kind: "scalar",
4555
- resolve: resolveYamlBoolean,
4556
- construct: constructYamlBoolean,
4557
- predicate: isBoolean,
4558
- represent: {
4559
- lowercase: function(object) {
4560
- return object ? "true" : "false";
4561
- },
4562
- uppercase: function(object) {
4563
- return object ? "TRUE" : "FALSE";
4564
- },
4565
- camelcase: function(object) {
4566
- return object ? "True" : "False";
4567
- }
4568
- },
4569
- defaultStyle: "lowercase"
4570
- });
4571
- }));
4430
+ //#region src/tag/scalar/int_json.ts
4431
+ var YAML_INTEGER_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)$");
4432
+ var YAML_INTEGER_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
4433
+ function parseYamlInteger$1(source) {
4434
+ let value = source;
4435
+ let sign = 1;
4436
+ if (value[0] === "-" || value[0] === "+") {
4437
+ if (value[0] === "-") sign = -1;
4438
+ value = value.slice(1);
4439
+ }
4440
+ if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
4441
+ if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
4442
+ if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
4443
+ return sign * parseInt(value, 10);
4444
+ }
4445
+ function resolveYamlInteger$1(source, isExplicit) {
4446
+ if (isExplicit) {
4447
+ if (!YAML_INTEGER_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
4448
+ } else if (!YAML_INTEGER_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
4449
+ const result = parseYamlInteger$1(source);
4450
+ return Number.isFinite(result) ? result : NOT_RESOLVED;
4451
+ }
4452
+ var intJsonTag = defineScalarTag("tag:yaml.org,2002:int", {
4453
+ implicit: true,
4454
+ implicitFirstChars: ["-", ..."0123456789"],
4455
+ resolve: resolveYamlInteger$1,
4456
+ identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
4457
+ represent: (object) => object.toString(10)
4458
+ });
4572
4459
  //#endregion
4573
- //#region lib/type/int.js
4574
- var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4575
- var common = require_common();
4576
- var Type = require_type();
4577
- function isHexCode(c) {
4578
- return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
4579
- }
4580
- function isOctCode(c) {
4581
- return c >= 48 && c <= 55;
4582
- }
4583
- function isDecCode(c) {
4584
- return c >= 48 && c <= 57;
4585
- }
4586
- function resolveYamlInteger(data) {
4587
- if (data === null) return false;
4588
- const max = data.length;
4589
- let index = 0;
4590
- let hasDigits = false;
4591
- if (!max) return false;
4592
- let ch = data[index];
4593
- if (ch === "-" || ch === "+") ch = data[++index];
4594
- if (ch === "0") {
4595
- if (index + 1 === max) return true;
4596
- ch = data[++index];
4597
- if (ch === "b") {
4598
- index++;
4599
- for (; index < max; index++) {
4600
- ch = data[index];
4601
- if (ch !== "0" && ch !== "1") return false;
4602
- hasDigits = true;
4603
- }
4604
- return hasDigits && Number.isFinite(parseYamlInteger(data));
4605
- }
4606
- if (ch === "x") {
4607
- index++;
4608
- for (; index < max; index++) {
4609
- if (!isHexCode(data.charCodeAt(index))) return false;
4610
- hasDigits = true;
4611
- }
4612
- return hasDigits && Number.isFinite(parseYamlInteger(data));
4613
- }
4614
- if (ch === "o") {
4615
- index++;
4616
- for (; index < max; index++) {
4617
- if (!isOctCode(data.charCodeAt(index))) return false;
4618
- hasDigits = true;
4619
- }
4620
- return hasDigits && Number.isFinite(parseYamlInteger(data));
4621
- }
4622
- }
4623
- for (; index < max; index++) {
4624
- if (!isDecCode(data.charCodeAt(index))) return false;
4625
- hasDigits = true;
4626
- }
4627
- if (!hasDigits) return false;
4628
- return Number.isFinite(parseYamlInteger(data));
4629
- }
4630
- function parseYamlInteger(data) {
4631
- let value = data;
4632
- let sign = 1;
4633
- let ch = value[0];
4634
- if (ch === "-" || ch === "+") {
4635
- if (ch === "-") sign = -1;
4636
- value = value.slice(1);
4637
- ch = value[0];
4638
- }
4639
- if (value === "0") return 0;
4640
- if (ch === "0") {
4641
- if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
4642
- if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
4643
- if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
4644
- }
4645
- return sign * parseInt(value, 10);
4646
- }
4647
- function constructYamlInteger(data) {
4648
- return parseYamlInteger(data);
4649
- }
4650
- function isInteger(object) {
4651
- return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
4652
- }
4653
- module.exports = new Type("tag:yaml.org,2002:int", {
4654
- kind: "scalar",
4655
- resolve: resolveYamlInteger,
4656
- construct: constructYamlInteger,
4657
- predicate: isInteger,
4658
- represent: {
4659
- binary: function(obj) {
4660
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
4661
- },
4662
- octal: function(obj) {
4663
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
4664
- },
4665
- decimal: function(obj) {
4666
- return obj.toString(10);
4667
- },
4668
- hexadecimal: function(obj) {
4669
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
4670
- }
4671
- },
4672
- defaultStyle: "decimal",
4673
- styleAliases: {
4674
- binary: [2, "bin"],
4675
- octal: [8, "oct"],
4676
- decimal: [10, "dec"],
4677
- hexadecimal: [16, "hex"]
4678
- }
4679
- });
4680
- }));
4460
+ //#region src/tag/scalar/int_yaml11.ts
4461
+ var YAML_INTEGER_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");
4462
+ function parseYamlInteger(source) {
4463
+ let value = source.replace(/_/g, "");
4464
+ let sign = 1;
4465
+ if (value[0] === "-" || value[0] === "+") {
4466
+ if (value[0] === "-") sign = -1;
4467
+ value = value.slice(1);
4468
+ }
4469
+ if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
4470
+ if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
4471
+ if (value.includes(":")) {
4472
+ let result = 0;
4473
+ for (const part of value.split(":")) result = result * 60 + Number(part);
4474
+ return sign * result;
4475
+ }
4476
+ if (value !== "0" && value[0] === "0") return sign * parseInt(value, 8);
4477
+ return sign * parseInt(value, 10);
4478
+ }
4479
+ function resolveYamlInteger(source) {
4480
+ if (!YAML_INTEGER_PATTERN.test(source)) return NOT_RESOLVED;
4481
+ const result = parseYamlInteger(source);
4482
+ return Number.isFinite(result) ? result : NOT_RESOLVED;
4483
+ }
4484
+ var intYaml11Tag = defineScalarTag("tag:yaml.org,2002:int", {
4485
+ implicit: true,
4486
+ implicitFirstChars: [
4487
+ "-",
4488
+ "+",
4489
+ ..."0123456789"
4490
+ ],
4491
+ resolve: resolveYamlInteger,
4492
+ identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
4493
+ represent: (object) => object.toString(10)
4494
+ });
4681
4495
  //#endregion
4682
- //#region lib/type/float.js
4683
- var require_float = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4684
- var common = require_common();
4685
- var Type = require_type();
4686
- 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))$");
4687
- var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4688
- function resolveYamlFloat(data) {
4689
- if (data === null) return false;
4690
- if (!YAML_FLOAT_PATTERN.test(data)) return false;
4691
- if (Number.isFinite(parseFloat(data, 10))) return true;
4692
- return YAML_FLOAT_SPECIAL_PATTERN.test(data);
4693
- }
4694
- function constructYamlFloat(data) {
4695
- let value = data.toLowerCase();
4496
+ //#region src/tag/scalar/float_core.ts
4497
+ var YAML_FLOAT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4498
+ var YAML_FLOAT_SPECIAL_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4499
+ function resolveYamlFloat$2(source) {
4500
+ if (!YAML_FLOAT_PATTERN$1.test(source)) return NOT_RESOLVED;
4501
+ let value = source.toLowerCase();
4502
+ const sign = value[0] === "-" ? -1 : 1;
4503
+ if ("+-".includes(value[0])) value = value.slice(1);
4504
+ if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
4505
+ if (value === ".nan") return NaN;
4506
+ const result = sign * parseFloat(value);
4507
+ if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN$1.test(source)) return result;
4508
+ return NOT_RESOLVED;
4509
+ }
4510
+ function representYamlFloat$2(object) {
4511
+ if (isNaN(object)) return ".nan";
4512
+ if (object === Number.POSITIVE_INFINITY) return ".inf";
4513
+ if (object === Number.NEGATIVE_INFINITY) return "-.inf";
4514
+ if (Object.is(object, -0)) return "-0.0";
4515
+ const result = object.toString(10);
4516
+ return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
4517
+ }
4518
+ var floatCoreTag = defineScalarTag("tag:yaml.org,2002:float", {
4519
+ implicit: true,
4520
+ implicitFirstChars: [
4521
+ "-",
4522
+ "+",
4523
+ ".",
4524
+ ..."0123456789"
4525
+ ],
4526
+ resolve: resolveYamlFloat$2,
4527
+ identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
4528
+ represent: representYamlFloat$2
4529
+ });
4530
+ //#endregion
4531
+ //#region src/tag/scalar/float_json.ts
4532
+ var YAML_FLOAT_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
4533
+ var YAML_FLOAT_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4534
+ function resolveYamlFloat$1(source, isExplicit) {
4535
+ if (isExplicit) {
4536
+ if (!YAML_FLOAT_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
4537
+ let value = source.toLowerCase();
4696
4538
  const sign = value[0] === "-" ? -1 : 1;
4697
- if ("+-".indexOf(value[0]) >= 0) value = value.slice(1);
4539
+ if ("+-".includes(value[0])) value = value.slice(1);
4698
4540
  if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
4699
- else if (value === ".nan") return NaN;
4700
- return sign * parseFloat(value, 10);
4701
- }
4702
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
4703
- function representYamlFloat(object, style) {
4704
- if (isNaN(object)) switch (style) {
4705
- case "lowercase": return ".nan";
4706
- case "uppercase": return ".NAN";
4707
- case "camelcase": return ".NaN";
4708
- }
4709
- else if (Number.POSITIVE_INFINITY === object) switch (style) {
4710
- case "lowercase": return ".inf";
4711
- case "uppercase": return ".INF";
4712
- case "camelcase": return ".Inf";
4713
- }
4714
- else if (Number.NEGATIVE_INFINITY === object) switch (style) {
4715
- case "lowercase": return "-.inf";
4716
- case "uppercase": return "-.INF";
4717
- case "camelcase": return "-.Inf";
4718
- }
4719
- else if (common.isNegativeZero(object)) return "-0.0";
4720
- const res = object.toString(10);
4721
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
4722
- }
4723
- function isFloat(object) {
4724
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
4725
- }
4726
- module.exports = new Type("tag:yaml.org,2002:float", {
4727
- kind: "scalar",
4728
- resolve: resolveYamlFloat,
4729
- construct: constructYamlFloat,
4730
- predicate: isFloat,
4731
- represent: representYamlFloat,
4732
- defaultStyle: "lowercase"
4733
- });
4734
- }));
4735
- //#endregion
4736
- //#region lib/schema/json.js
4737
- var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4738
- module.exports = require_failsafe().extend({ implicit: [
4739
- require_null(),
4740
- require_bool(),
4741
- require_int(),
4742
- require_float()
4743
- ] });
4744
- }));
4541
+ if (value === ".nan") return NaN;
4542
+ const result = sign * parseFloat(value);
4543
+ return Number.isFinite(result) ? result : NOT_RESOLVED;
4544
+ }
4545
+ if (!YAML_FLOAT_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
4546
+ const result = Number(source);
4547
+ if (Number.isFinite(result)) return result;
4548
+ return NOT_RESOLVED;
4549
+ }
4550
+ function representYamlFloat$1(object) {
4551
+ if (isNaN(object)) return ".nan";
4552
+ if (object === Number.POSITIVE_INFINITY) return ".inf";
4553
+ if (object === Number.NEGATIVE_INFINITY) return "-.inf";
4554
+ if (Object.is(object, -0)) return "-0.0";
4555
+ const result = object.toString(10);
4556
+ return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
4557
+ }
4558
+ var floatJsonTag = defineScalarTag("tag:yaml.org,2002:float", {
4559
+ implicit: true,
4560
+ implicitFirstChars: ["-", ..."0123456789"],
4561
+ resolve: resolveYamlFloat$1,
4562
+ identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
4563
+ represent: representYamlFloat$1
4564
+ });
4745
4565
  //#endregion
4746
- //#region lib/schema/core.js
4747
- var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4748
- module.exports = require_json();
4749
- }));
4566
+ //#region src/tag/scalar/float_yaml11.ts
4567
+ var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4568
+ var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
4569
+ function resolveYamlFloat(source) {
4570
+ if (!YAML_FLOAT_PATTERN.test(source)) return NOT_RESOLVED;
4571
+ let value = source.toLowerCase().replace(/_/g, "");
4572
+ const sign = value[0] === "-" ? -1 : 1;
4573
+ if ("+-".includes(value[0])) value = value.slice(1);
4574
+ if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
4575
+ if (value === ".nan") return NaN;
4576
+ let result = 0;
4577
+ if (value.includes(":")) {
4578
+ for (const part of value.split(":")) result = result * 60 + Number(part);
4579
+ result *= sign;
4580
+ } else result = sign * parseFloat(value);
4581
+ if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN.test(source)) return result;
4582
+ return NOT_RESOLVED;
4583
+ }
4584
+ function representYamlFloat(object) {
4585
+ if (isNaN(object)) return ".nan";
4586
+ if (object === Number.POSITIVE_INFINITY) return ".inf";
4587
+ if (object === Number.NEGATIVE_INFINITY) return "-.inf";
4588
+ if (Object.is(object, -0)) return "-0.0";
4589
+ const result = object.toString(10);
4590
+ return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
4591
+ }
4592
+ var floatYaml11Tag = defineScalarTag("tag:yaml.org,2002:float", {
4593
+ implicit: true,
4594
+ implicitFirstChars: [
4595
+ "-",
4596
+ "+",
4597
+ ".",
4598
+ ..."0123456789"
4599
+ ],
4600
+ resolve: resolveYamlFloat,
4601
+ identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
4602
+ represent: representYamlFloat
4603
+ });
4750
4604
  //#endregion
4751
- //#region lib/type/timestamp.js
4752
- var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4753
- var Type = require_type();
4754
- var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
4755
- 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]))?))?$");
4756
- function resolveYamlTimestamp(data) {
4757
- if (data === null) return false;
4758
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
4759
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
4760
- return false;
4605
+ //#region src/tag/scalar/merge.ts
4606
+ var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
4607
+ implicit: true,
4608
+ implicitFirstChars: ["<"],
4609
+ resolve: (source, isExplicit) => {
4610
+ if (source === "<<" || isExplicit && source === "") return MERGE_KEY;
4611
+ return NOT_RESOLVED;
4761
4612
  }
4762
- function constructYamlTimestamp(data) {
4763
- let fraction = 0;
4764
- let delta = null;
4765
- let match = YAML_DATE_REGEXP.exec(data);
4766
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
4767
- if (match === null) throw new Error("Date resolve error");
4768
- const year = +match[1];
4769
- const month = +match[2] - 1;
4770
- const day = +match[3];
4771
- if (!match[4]) return new Date(Date.UTC(year, month, day));
4772
- const hour = +match[4];
4773
- const minute = +match[5];
4774
- const second = +match[6];
4775
- if (match[7]) {
4776
- fraction = match[7].slice(0, 3);
4777
- while (fraction.length < 3) fraction += "0";
4778
- fraction = +fraction;
4779
- }
4780
- if (match[9]) {
4781
- const tzHour = +match[10];
4782
- const tzMinute = +(match[11] || 0);
4783
- delta = (tzHour * 60 + tzMinute) * 6e4;
4784
- if (match[9] === "-") delta = -delta;
4785
- }
4786
- const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
4787
- if (delta) date.setTime(date.getTime() - delta);
4613
+ });
4614
+ //#endregion
4615
+ //#region src/tag/scalar/binary.ts
4616
+ var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
4617
+ function resolveYamlBinary(source) {
4618
+ const input = source.replace(/\s/g, "");
4619
+ if (input.length % 4 !== 0 || !BASE64_PATTERN.test(input)) return NOT_RESOLVED;
4620
+ const binary = atob(input);
4621
+ const result = new Uint8Array(binary.length);
4622
+ for (let index = 0; index < binary.length; index++) result[index] = binary.charCodeAt(index);
4623
+ return result;
4624
+ }
4625
+ function representYamlBinary(object) {
4626
+ let binary = "";
4627
+ for (let index = 0; index < object.length; index++) binary += String.fromCharCode(object[index]);
4628
+ return btoa(binary);
4629
+ }
4630
+ var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
4631
+ resolve: resolveYamlBinary,
4632
+ identify: (object) => Object.prototype.toString.call(object) === "[object Uint8Array]",
4633
+ represent: representYamlBinary
4634
+ });
4635
+ //#endregion
4636
+ //#region src/tag/scalar/timestamp.ts
4637
+ var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
4638
+ 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]))?))?$");
4639
+ function resolveYamlTimestamp(source) {
4640
+ let match = YAML_DATE_REGEXP.exec(source);
4641
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
4642
+ if (match === null) return NOT_RESOLVED;
4643
+ const year = +match[1];
4644
+ const month = +match[2] - 1;
4645
+ const day = +match[3];
4646
+ if (!match[4]) {
4647
+ const date = new Date(Date.UTC(year, month, day));
4648
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
4788
4649
  return date;
4789
4650
  }
4790
- function representYamlTimestamp(object) {
4791
- return object.toISOString();
4792
- }
4793
- module.exports = new Type("tag:yaml.org,2002:timestamp", {
4794
- kind: "scalar",
4795
- resolve: resolveYamlTimestamp,
4796
- construct: constructYamlTimestamp,
4797
- instanceOf: Date,
4798
- represent: representYamlTimestamp
4799
- });
4800
- }));
4651
+ const hour = +match[4];
4652
+ const minute = +match[5];
4653
+ const second = +match[6];
4654
+ let fraction = 0;
4655
+ if (hour > 23 || minute > 59 || second > 59) return NOT_RESOLVED;
4656
+ if (match[7]) {
4657
+ let value = match[7].slice(0, 3);
4658
+ while (value.length < 3) value += "0";
4659
+ fraction = +value;
4660
+ }
4661
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
4662
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
4663
+ if (match[9]) {
4664
+ const offsetHour = +match[10];
4665
+ const offsetMinute = +(match[11] || 0);
4666
+ if (offsetHour > 23 || offsetMinute > 59) return NOT_RESOLVED;
4667
+ const offset = (offsetHour * 60 + offsetMinute) * 6e4;
4668
+ date.setTime(date.getTime() - (match[9] === "-" ? -offset : offset));
4669
+ }
4670
+ return date;
4671
+ }
4672
+ var timestampTag = defineScalarTag("tag:yaml.org,2002:timestamp", {
4673
+ implicit: true,
4674
+ implicitFirstChars: [..."0123456789"],
4675
+ resolve: resolveYamlTimestamp,
4676
+ identify: (object) => object instanceof Date,
4677
+ represent: (object) => object.toISOString()
4678
+ });
4801
4679
  //#endregion
4802
- //#region lib/type/merge.js
4803
- var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4804
- var Type = require_type();
4805
- function resolveYamlMerge(data) {
4806
- return data === "<<" || data === null;
4807
- }
4808
- module.exports = new Type("tag:yaml.org,2002:merge", {
4809
- kind: "scalar",
4810
- resolve: resolveYamlMerge
4811
- });
4812
- }));
4680
+ //#region src/tag/sequence/seq.ts
4681
+ var seqTag = defineSequenceTag("tag:yaml.org,2002:seq", {
4682
+ create: () => [],
4683
+ addItem: (container, item) => {
4684
+ container.push(item);
4685
+ },
4686
+ identify: Array.isArray
4687
+ });
4813
4688
  //#endregion
4814
- //#region lib/type/binary.js
4815
- var require_binary = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4816
- var Type = require_type();
4817
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
4818
- function resolveYamlBinary(data) {
4819
- if (data === null) return false;
4820
- let bitlen = 0;
4821
- const max = data.length;
4822
- const map = BASE64_MAP;
4823
- for (let idx = 0; idx < max; idx++) {
4824
- const code = map.indexOf(data.charAt(idx));
4825
- if (code > 64) continue;
4826
- if (code < 0) return false;
4827
- bitlen += 6;
4828
- }
4829
- return bitlen % 8 === 0;
4830
- }
4831
- function constructYamlBinary(data) {
4832
- const input = data.replace(/[\r\n=]/g, "");
4833
- const max = input.length;
4834
- const map = BASE64_MAP;
4835
- let bits = 0;
4836
- const result = [];
4837
- for (let idx = 0; idx < max; idx++) {
4838
- if (idx % 4 === 0 && idx) {
4839
- result.push(bits >> 16 & 255);
4840
- result.push(bits >> 8 & 255);
4841
- result.push(bits & 255);
4842
- }
4843
- bits = bits << 6 | map.indexOf(input.charAt(idx));
4844
- }
4845
- const tailbits = max % 4 * 6;
4846
- if (tailbits === 0) {
4847
- result.push(bits >> 16 & 255);
4848
- result.push(bits >> 8 & 255);
4849
- result.push(bits & 255);
4850
- } else if (tailbits === 18) {
4851
- result.push(bits >> 10 & 255);
4852
- result.push(bits >> 2 & 255);
4853
- } else if (tailbits === 12) result.push(bits >> 4 & 255);
4854
- return new Uint8Array(result);
4855
- }
4856
- function representYamlBinary(object) {
4857
- let result = "";
4858
- let bits = 0;
4859
- const max = object.length;
4860
- const map = BASE64_MAP;
4861
- for (let idx = 0; idx < max; idx++) {
4862
- if (idx % 3 === 0 && idx) {
4863
- result += map[bits >> 18 & 63];
4864
- result += map[bits >> 12 & 63];
4865
- result += map[bits >> 6 & 63];
4866
- result += map[bits & 63];
4867
- }
4868
- bits = (bits << 8) + object[idx];
4869
- }
4870
- const tail = max % 3;
4871
- if (tail === 0) {
4872
- result += map[bits >> 18 & 63];
4873
- result += map[bits >> 12 & 63];
4874
- result += map[bits >> 6 & 63];
4875
- result += map[bits & 63];
4876
- } else if (tail === 2) {
4877
- result += map[bits >> 10 & 63];
4878
- result += map[bits >> 4 & 63];
4879
- result += map[bits << 2 & 63];
4880
- result += map[64];
4881
- } else if (tail === 1) {
4882
- result += map[bits >> 2 & 63];
4883
- result += map[bits << 4 & 63];
4884
- result += map[64];
4885
- result += map[64];
4886
- }
4887
- return result;
4888
- }
4889
- function isBinary(obj) {
4890
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
4891
- }
4892
- module.exports = new Type("tag:yaml.org,2002:binary", {
4893
- kind: "scalar",
4894
- resolve: resolveYamlBinary,
4895
- construct: constructYamlBinary,
4896
- predicate: isBinary,
4897
- represent: representYamlBinary
4898
- });
4899
- }));
4689
+ //#region src/common/object.ts
4690
+ function isPlainObject$1(data) {
4691
+ if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
4692
+ const prototype = Object.getPrototypeOf(data);
4693
+ return prototype === null || prototype === Object.prototype;
4694
+ }
4695
+ function pick(object, keys) {
4696
+ const result = {};
4697
+ for (const key of keys) if (object[key] !== void 0) result[key] = object[key];
4698
+ return result;
4699
+ }
4900
4700
  //#endregion
4901
- //#region lib/type/omap.js
4902
- var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4903
- var Type = require_type();
4904
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
4905
- var _toString = Object.prototype.toString;
4906
- function resolveYamlOmap(data) {
4907
- if (data === null) return true;
4908
- const objectKeys = [];
4909
- const object = data;
4910
- for (let index = 0, length = object.length; index < length; index += 1) {
4911
- const pair = object[index];
4912
- let pairHasKey = false;
4913
- if (_toString.call(pair) !== "[object Object]") return false;
4914
- let pairKey;
4915
- for (pairKey in pair) if (_hasOwnProperty.call(pair, pairKey)) if (!pairHasKey) pairHasKey = true;
4916
- else return false;
4917
- if (!pairHasKey) return false;
4918
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
4919
- else return false;
4701
+ //#region src/tag/sequence/omap.ts
4702
+ var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
4703
+ create: () => ({
4704
+ list: [],
4705
+ seen: /* @__PURE__ */ new Set()
4706
+ }),
4707
+ addItem: (carrier, item) => {
4708
+ let key;
4709
+ if (item instanceof Map) {
4710
+ if (item.size !== 1) return "cannot resolve an ordered map item";
4711
+ key = item.keys().next().value;
4712
+ } else if (isPlainObject$1(item)) {
4713
+ const itemKeys = Object.keys(item);
4714
+ if (itemKeys.length !== 1) return "cannot resolve an ordered map item";
4715
+ key = itemKeys[0];
4716
+ } else return "cannot resolve an ordered map item";
4717
+ if (carrier.seen.has(key)) return "duplicate key in ordered map";
4718
+ carrier.seen.add(key);
4719
+ carrier.list.push(item);
4720
+ return "";
4721
+ },
4722
+ finalize: (carrier) => carrier.list
4723
+ });
4724
+ //#endregion
4725
+ //#region src/tag/sequence/pairs.ts
4726
+ var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
4727
+ create: () => [],
4728
+ addItem: (container, item) => {
4729
+ if (item instanceof Map) {
4730
+ if (item.size !== 1) return "cannot resolve a pairs item";
4731
+ container.push(item.entries().next().value);
4732
+ return "";
4920
4733
  }
4921
- return true;
4922
- }
4923
- function constructYamlOmap(data) {
4924
- return data !== null ? data : [];
4734
+ if (Object.prototype.toString.call(item) !== "[object Object]") return "cannot resolve a pairs item";
4735
+ const object = item;
4736
+ const keys = Object.keys(object);
4737
+ if (keys.length !== 1) return "cannot resolve a pairs item";
4738
+ container.push([keys[0], object[keys[0]]]);
4739
+ return "";
4925
4740
  }
4926
- module.exports = new Type("tag:yaml.org,2002:omap", {
4927
- kind: "sequence",
4928
- resolve: resolveYamlOmap,
4929
- construct: constructYamlOmap
4930
- });
4931
- }));
4741
+ });
4742
+ //#endregion
4743
+ //#region src/tag/mapping/map.ts
4744
+ var mapTag$5 = defineMappingTag("tag:yaml.org,2002:map", {
4745
+ create: () => ({}),
4746
+ identify: isPlainObject$1,
4747
+ represent: (o) => {
4748
+ const map = /* @__PURE__ */ new Map();
4749
+ for (const key of Object.keys(o)) map.set(key, o[key]);
4750
+ return map;
4751
+ },
4752
+ addPair: (container, key, value) => {
4753
+ if (key !== null && typeof key === "object") return "object-based map does not support complex keys";
4754
+ const normalizedKey = String(key);
4755
+ if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
4756
+ value,
4757
+ enumerable: true,
4758
+ configurable: true,
4759
+ writable: true
4760
+ });
4761
+ else container[normalizedKey] = value;
4762
+ return "";
4763
+ },
4764
+ has: (container, key) => {
4765
+ if (key !== null && typeof key === "object") return false;
4766
+ return Object.prototype.hasOwnProperty.call(container, String(key));
4767
+ },
4768
+ keys: (container) => Object.keys(container),
4769
+ get: (container, key) => container[String(key)]
4770
+ });
4932
4771
  //#endregion
4933
- //#region lib/type/pairs.js
4934
- var require_pairs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4935
- var Type = require_type();
4936
- var _toString = Object.prototype.toString;
4937
- function resolveYamlPairs(data) {
4938
- if (data === null) return true;
4939
- const object = data;
4940
- const result = new Array(object.length);
4941
- for (let index = 0, length = object.length; index < length; index += 1) {
4942
- const pair = object[index];
4943
- if (_toString.call(pair) !== "[object Object]") return false;
4944
- const keys = Object.keys(pair);
4945
- if (keys.length !== 1) return false;
4946
- result[index] = [keys[0], pair[keys[0]]];
4772
+ //#region src/tag/mapping/set.ts
4773
+ var setTag$5 = defineMappingTag("tag:yaml.org,2002:set", {
4774
+ create: () => /* @__PURE__ */ new Set(),
4775
+ identify: (data) => data instanceof Set,
4776
+ represent: (data) => {
4777
+ const map = /* @__PURE__ */ new Map();
4778
+ for (const key of data) map.set(key, null);
4779
+ return map;
4780
+ },
4781
+ addPair: (container, key, value) => {
4782
+ if (value !== null) return "cannot resolve a set item";
4783
+ container.add(key);
4784
+ return "";
4785
+ },
4786
+ has: (container, key) => container.has(key),
4787
+ keys: (container) => container.keys(),
4788
+ get: () => null
4789
+ });
4790
+ //#endregion
4791
+ //#region src/schema.ts
4792
+ function createTagDefinitionMap() {
4793
+ return {
4794
+ scalar: {},
4795
+ sequence: {},
4796
+ mapping: {}
4797
+ };
4798
+ }
4799
+ function createTagDefinitionListMap() {
4800
+ return {
4801
+ scalar: [],
4802
+ sequence: [],
4803
+ mapping: []
4804
+ };
4805
+ }
4806
+ function compileTags(tags) {
4807
+ const result = [];
4808
+ for (const tag of tags) {
4809
+ let index = result.length;
4810
+ for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
4811
+ const previous = result[previousIndex];
4812
+ if (previous.nodeKind === tag.nodeKind && previous.tagName === tag.tagName && previous.matchByTagPrefix === tag.matchByTagPrefix) {
4813
+ index = previousIndex;
4814
+ break;
4815
+ }
4947
4816
  }
4948
- return true;
4949
- }
4950
- function constructYamlPairs(data) {
4951
- if (data === null) return [];
4952
- const object = data;
4953
- const result = new Array(object.length);
4954
- for (let index = 0, length = object.length; index < length; index += 1) {
4955
- const pair = object[index];
4956
- const keys = Object.keys(pair);
4957
- result[index] = [keys[0], pair[keys[0]]];
4817
+ result[index] = tag;
4818
+ }
4819
+ return result;
4820
+ }
4821
+ var Schema = class Schema {
4822
+ tags;
4823
+ implicitScalarTags;
4824
+ implicitScalarByFirstChar;
4825
+ implicitScalarAnyFirstChar;
4826
+ defaultScalarTag;
4827
+ defaultSequenceTag;
4828
+ defaultMappingTag;
4829
+ exact;
4830
+ prefix;
4831
+ constructor(tags) {
4832
+ const compiledTags = compileTags(tags);
4833
+ const implicitScalarTags = [];
4834
+ const exact = createTagDefinitionMap();
4835
+ const prefix = createTagDefinitionListMap();
4836
+ for (const tag of compiledTags) {
4837
+ if (tag.nodeKind === "scalar" && tag.implicit) {
4838
+ if (tag.matchByTagPrefix) throw new Error("Implicit scalar tags cannot match by tag prefix");
4839
+ implicitScalarTags.push(tag);
4840
+ }
4841
+ switch (tag.nodeKind) {
4842
+ case "scalar":
4843
+ if (tag.matchByTagPrefix) prefix.scalar.push(tag);
4844
+ else exact.scalar[tag.tagName] = tag;
4845
+ break;
4846
+ case "sequence":
4847
+ if (tag.matchByTagPrefix) prefix.sequence.push(tag);
4848
+ else exact.sequence[tag.tagName] = tag;
4849
+ break;
4850
+ case "mapping":
4851
+ if (tag.matchByTagPrefix) prefix.mapping.push(tag);
4852
+ else exact.mapping[tag.tagName] = tag;
4853
+ break;
4854
+ }
4958
4855
  }
4959
- return result;
4856
+ const implicitScalarAnyFirstChar = implicitScalarTags.filter((tag) => tag.implicitFirstChars === null);
4857
+ const keys = /* @__PURE__ */ new Set();
4858
+ for (const tag of implicitScalarTags) if (tag.implicitFirstChars !== null) for (const key of tag.implicitFirstChars) keys.add(key);
4859
+ const implicitScalarByFirstChar = /* @__PURE__ */ new Map();
4860
+ for (const key of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag) => tag.implicitFirstChars === null || tag.implicitFirstChars.indexOf(key) !== -1));
4861
+ const defaultScalarTag = exact.scalar["tag:yaml.org,2002:str"];
4862
+ if (!defaultScalarTag) throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");
4863
+ this.tags = compiledTags;
4864
+ this.implicitScalarTags = implicitScalarTags;
4865
+ this.implicitScalarByFirstChar = implicitScalarByFirstChar;
4866
+ this.implicitScalarAnyFirstChar = implicitScalarAnyFirstChar;
4867
+ this.defaultScalarTag = defaultScalarTag;
4868
+ this.defaultSequenceTag = exact.sequence["tag:yaml.org,2002:seq"];
4869
+ this.defaultMappingTag = exact.mapping["tag:yaml.org,2002:map"];
4870
+ this.exact = exact;
4871
+ this.prefix = prefix;
4872
+ }
4873
+ withTags(...tags) {
4874
+ let flatTags = [];
4875
+ for (const tag of tags) flatTags = flatTags.concat(tag);
4876
+ return new Schema([...this.tags, ...flatTags]);
4960
4877
  }
4961
- module.exports = new Type("tag:yaml.org,2002:pairs", {
4962
- kind: "sequence",
4963
- resolve: resolveYamlPairs,
4964
- construct: constructYamlPairs
4965
- });
4966
- }));
4878
+ };
4879
+ var FAILSAFE_SCHEMA = new Schema([
4880
+ strTag,
4881
+ seqTag,
4882
+ mapTag$5
4883
+ ]);
4884
+ new Schema([
4885
+ ...FAILSAFE_SCHEMA.tags,
4886
+ nullJsonTag,
4887
+ boolJsonTag,
4888
+ intJsonTag,
4889
+ floatJsonTag
4890
+ ]);
4891
+ var CORE_SCHEMA = new Schema([
4892
+ ...FAILSAFE_SCHEMA.tags,
4893
+ nullCoreTag,
4894
+ boolCoreTag,
4895
+ intCoreTag,
4896
+ floatCoreTag
4897
+ ]);
4898
+ var YAML11_SCHEMA = new Schema([
4899
+ ...FAILSAFE_SCHEMA.tags,
4900
+ nullYaml11Tag,
4901
+ boolYaml11Tag,
4902
+ intYaml11Tag,
4903
+ floatYaml11Tag,
4904
+ timestampTag,
4905
+ mergeTag,
4906
+ binaryTag,
4907
+ omapTag,
4908
+ pairsTag,
4909
+ setTag$5
4910
+ ]);
4967
4911
  //#endregion
4968
- //#region lib/type/set.js
4969
- var require_set = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4970
- var Type = require_type();
4971
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
4972
- function resolveYamlSet(data) {
4973
- if (data === null) return true;
4974
- const object = data;
4975
- for (const key in object) if (_hasOwnProperty.call(object, key)) {
4976
- if (object[key] !== null) return false;
4977
- }
4978
- return true;
4979
- }
4980
- function constructYamlSet(data) {
4981
- return data !== null ? data : {};
4912
+ //#region src/tag/mapping/real_map.ts
4913
+ defineMappingTag("tag:yaml.org,2002:map", {
4914
+ create: () => /* @__PURE__ */ new Map(),
4915
+ addPair: (container, key, value) => {
4916
+ container.set(key, value);
4917
+ return "";
4918
+ },
4919
+ has: (container, key) => container.has(key),
4920
+ keys: (container) => container.keys(),
4921
+ get: (container, key) => container.get(key),
4922
+ identify: (data) => data instanceof Map || isPlainObject$1(data),
4923
+ represent: (data) => {
4924
+ if (data instanceof Map) return data;
4925
+ const map = /* @__PURE__ */ new Map();
4926
+ const obj = data;
4927
+ for (const key of Object.keys(obj)) map.set(key, obj[key]);
4928
+ return map;
4982
4929
  }
4983
- module.exports = new Type("tag:yaml.org,2002:set", {
4984
- kind: "mapping",
4985
- resolve: resolveYamlSet,
4986
- construct: constructYamlSet
4987
- });
4988
- }));
4989
- //#endregion
4990
- //#region lib/schema/default.js
4991
- var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4992
- module.exports = require_core().extend({
4993
- implicit: [require_timestamp(), require_merge()],
4994
- explicit: [
4995
- require_binary(),
4996
- require_omap(),
4997
- require_pairs(),
4998
- require_set()
4999
- ]
5000
- });
5001
- }));
4930
+ });
5002
4931
  //#endregion
5003
- //#region lib/loader.js
5004
- var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5005
- var common = require_common();
5006
- var YAMLException = require_exception();
5007
- var makeSnippet = require_snippet();
5008
- var DEFAULT_SCHEMA = require_default();
5009
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
5010
- var CONTEXT_FLOW_IN = 1;
5011
- var CONTEXT_FLOW_OUT = 2;
5012
- var CONTEXT_BLOCK_IN = 3;
5013
- var CONTEXT_BLOCK_OUT = 4;
5014
- var CHOMPING_CLIP = 1;
5015
- var CHOMPING_STRIP = 2;
5016
- var CHOMPING_KEEP = 3;
5017
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
5018
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
5019
- var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
5020
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
5021
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
5022
- function _class(obj) {
5023
- return Object.prototype.toString.call(obj);
5024
- }
5025
- function isEol(c) {
5026
- return c === 10 || c === 13;
5027
- }
5028
- function isWhiteSpace(c) {
5029
- return c === 9 || c === 32;
5030
- }
5031
- function isWsOrEol(c) {
5032
- return c === 9 || c === 32 || c === 10 || c === 13;
5033
- }
5034
- function isFlowIndicator(c) {
5035
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
5036
- }
5037
- function fromHexCode(c) {
5038
- if (c >= 48 && c <= 57) return c - 48;
5039
- const lc = c | 32;
5040
- if (lc >= 97 && lc <= 102) return lc - 97 + 10;
5041
- return -1;
5042
- }
5043
- function escapedHexLen(c) {
5044
- if (c === 120) return 2;
5045
- if (c === 117) return 4;
5046
- if (c === 85) return 8;
5047
- return 0;
5048
- }
5049
- function fromDecimalCode(c) {
5050
- if (c >= 48 && c <= 57) return c - 48;
5051
- return -1;
5052
- }
5053
- function simpleEscapeSequence(c) {
5054
- switch (c) {
5055
- case 48: return "\0";
5056
- case 97: return "\x07";
5057
- case 98: return "\b";
5058
- case 116: return " ";
5059
- case 9: return " ";
5060
- case 110: return "\n";
5061
- case 118: return "\v";
5062
- case 102: return "\f";
5063
- case 114: return "\r";
5064
- case 101: return "\x1B";
5065
- case 32: return " ";
5066
- case 34: return "\"";
5067
- case 47: return "/";
5068
- case 92: return "\\";
5069
- case 78: return "…";
5070
- case 95: return "\xA0";
5071
- case 76: return "\u2028";
5072
- case 80: return "\u2029";
5073
- default: return "";
4932
+ //#region src/tag/mapping/legacy_map.ts
4933
+ function normalizeKey(key) {
4934
+ if (Array.isArray(key)) {
4935
+ const array = Array.prototype.slice.call(key);
4936
+ for (let index = 0; index < array.length; index++) {
4937
+ if (Array.isArray(array[index])) return null;
4938
+ if (typeof array[index] === "object" && Object.prototype.toString.call(array[index]) === "[object Object]") array[index] = "[object Object]";
5074
4939
  }
5075
- }
5076
- function charFromCodepoint(c) {
5077
- if (c <= 65535) return String.fromCharCode(c);
5078
- return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
5079
- }
5080
- function setProperty(object, key, value) {
5081
- if (key === "__proto__") Object.defineProperty(object, key, {
5082
- configurable: true,
4940
+ return String(array);
4941
+ }
4942
+ if (typeof key === "object" && Object.prototype.toString.call(key) === "[object Object]") return "[object Object]";
4943
+ return String(key);
4944
+ }
4945
+ defineMappingTag("tag:yaml.org,2002:map", {
4946
+ create: () => ({}),
4947
+ identify: isPlainObject$1,
4948
+ represent: (o) => {
4949
+ const map = /* @__PURE__ */ new Map();
4950
+ for (const key of Object.keys(o)) map.set(key, o[key]);
4951
+ return map;
4952
+ },
4953
+ addPair: (container, key, value) => {
4954
+ const normalizedKey = normalizeKey(key);
4955
+ if (normalizedKey === null) return "nested arrays are not supported inside keys";
4956
+ if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
4957
+ value,
5083
4958
  enumerable: true,
5084
- writable: true,
5085
- value
4959
+ configurable: true,
4960
+ writable: true
5086
4961
  });
5087
- else object[key] = value;
5088
- }
5089
- var simpleEscapeCheck = new Array(256);
5090
- var simpleEscapeMap = new Array(256);
5091
- for (let i = 0; i < 256; i++) {
5092
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
5093
- simpleEscapeMap[i] = simpleEscapeSequence(i);
5094
- }
5095
- function State(input, options) {
5096
- this.input = input;
5097
- this.filename = options["filename"] || null;
5098
- this.schema = options["schema"] || DEFAULT_SCHEMA;
5099
- this.onWarning = options["onWarning"] || null;
5100
- this.legacy = options["legacy"] || false;
5101
- this.json = options["json"] || false;
5102
- this.listener = options["listener"] || null;
5103
- this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
5104
- this.maxMergeSeqLength = typeof options["maxMergeSeqLength"] === "number" ? options["maxMergeSeqLength"] : 20;
5105
- this.implicitTypes = this.schema.compiledImplicit;
5106
- this.typeMap = this.schema.compiledTypeMap;
5107
- this.length = input.length;
5108
- this.position = 0;
5109
- this.line = 0;
5110
- this.lineStart = 0;
5111
- this.lineIndent = 0;
5112
- this.depth = 0;
5113
- this.firstTabInLine = -1;
5114
- this.documents = [];
5115
- this.anchorMapTransactions = [];
5116
- }
5117
- function generateError(state, message) {
5118
- const mark = {
5119
- name: state.filename,
5120
- buffer: state.input.slice(0, -1),
5121
- position: state.position,
5122
- line: state.line,
5123
- column: state.position - state.lineStart
5124
- };
5125
- mark.snippet = makeSnippet(mark);
5126
- return new YAMLException(message, mark);
5127
- }
5128
- function throwError(state, message) {
5129
- throw generateError(state, message);
5130
- }
5131
- function throwWarning(state, message) {
5132
- if (state.onWarning) state.onWarning.call(null, generateError(state, message));
5133
- }
5134
- function storeAnchor(state, name, value) {
5135
- const transactions = state.anchorMapTransactions;
5136
- if (transactions.length !== 0) {
5137
- const transaction = transactions[transactions.length - 1];
5138
- if (!_hasOwnProperty.call(transaction, name)) transaction[name] = {
5139
- existed: _hasOwnProperty.call(state.anchorMap, name),
5140
- value: state.anchorMap[name]
5141
- };
5142
- }
5143
- state.anchorMap[name] = value;
5144
- }
5145
- function beginAnchorTransaction(state) {
5146
- state.anchorMapTransactions.push(Object.create(null));
5147
- }
5148
- function commitAnchorTransaction(state) {
5149
- const transaction = state.anchorMapTransactions.pop();
5150
- const transactions = state.anchorMapTransactions;
5151
- if (transactions.length === 0) return;
5152
- const parent = transactions[transactions.length - 1];
5153
- const names = Object.keys(transaction);
5154
- for (let index = 0, length = names.length; index < length; index += 1) {
5155
- const name = names[index];
5156
- if (!_hasOwnProperty.call(parent, name)) parent[name] = transaction[name];
5157
- }
5158
- }
5159
- function rollbackAnchorTransaction(state) {
5160
- const transaction = state.anchorMapTransactions.pop();
5161
- const names = Object.keys(transaction);
5162
- for (let index = names.length - 1; index >= 0; index -= 1) {
5163
- const entry = transaction[names[index]];
5164
- if (entry.existed) state.anchorMap[names[index]] = entry.value;
5165
- else delete state.anchorMap[names[index]];
5166
- }
5167
- }
5168
- function snapshotState(state) {
5169
- return {
5170
- position: state.position,
5171
- line: state.line,
5172
- lineStart: state.lineStart,
5173
- lineIndent: state.lineIndent,
5174
- firstTabInLine: state.firstTabInLine,
5175
- tag: state.tag,
5176
- anchor: state.anchor,
5177
- kind: state.kind,
5178
- result: state.result
5179
- };
5180
- }
5181
- function restoreState(state, snapshot) {
5182
- state.position = snapshot.position;
5183
- state.line = snapshot.line;
5184
- state.lineStart = snapshot.lineStart;
5185
- state.lineIndent = snapshot.lineIndent;
5186
- state.firstTabInLine = snapshot.firstTabInLine;
5187
- state.tag = snapshot.tag;
5188
- state.anchor = snapshot.anchor;
5189
- state.kind = snapshot.kind;
5190
- state.result = snapshot.result;
5191
- }
5192
- var directiveHandlers = {
5193
- YAML: function handleYamlDirective(state, name, args) {
5194
- if (state.version !== null) throwError(state, "duplication of %YAML directive");
5195
- if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
5196
- const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
5197
- if (match === null) throwError(state, "ill-formed argument of the YAML directive");
5198
- const major = parseInt(match[1], 10);
5199
- const minor = parseInt(match[2], 10);
5200
- if (major !== 1) throwError(state, "unacceptable YAML version of the document");
5201
- state.version = args[0];
5202
- state.checkLineBreaks = minor < 2;
5203
- if (minor !== 1 && minor !== 2) throwWarning(state, "unsupported YAML version of the document");
5204
- },
5205
- TAG: function handleTagDirective(state, name, args) {
5206
- let prefix;
5207
- if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
5208
- const handle = args[0];
5209
- prefix = args[1];
5210
- if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
5211
- if (_hasOwnProperty.call(state.tagMap, handle)) throwError(state, "there is a previously declared suffix for \"" + handle + "\" tag handle");
5212
- if (!PATTERN_TAG_URI.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
5213
- try {
5214
- prefix = decodeURIComponent(prefix);
5215
- } catch (err) {
5216
- throwError(state, "tag prefix is malformed: " + prefix);
5217
- }
5218
- state.tagMap[handle] = prefix;
5219
- }
4962
+ else container[normalizedKey] = value;
4963
+ return "";
4964
+ },
4965
+ has: (container, key) => {
4966
+ const normalizedKey = normalizeKey(key);
4967
+ return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
4968
+ },
4969
+ keys: (container) => Object.keys(container),
4970
+ get: (container, key) => container[String(key)]
4971
+ });
4972
+ //#endregion
4973
+ //#region src/common/snippet.ts
4974
+ var DEFAULT_SNIPPET_OPTIONS = {
4975
+ maxLength: 79,
4976
+ indent: 1,
4977
+ linesBefore: 3,
4978
+ linesAfter: 2
4979
+ };
4980
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
4981
+ let head = "";
4982
+ let tail = "";
4983
+ const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
4984
+ if (position - lineStart > maxHalfLength) {
4985
+ head = " ... ";
4986
+ lineStart = position - maxHalfLength + head.length;
4987
+ }
4988
+ if (lineEnd - position > maxHalfLength) {
4989
+ tail = " ...";
4990
+ lineEnd = position + maxHalfLength - tail.length;
4991
+ }
4992
+ return {
4993
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
4994
+ pos: position - lineStart + head.length
5220
4995
  };
5221
- function captureSegment(state, start, end, checkJson) {
5222
- if (start < end) {
5223
- const _result = state.input.slice(start, end);
5224
- if (checkJson) for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
5225
- const _character = _result.charCodeAt(_position);
5226
- if (!(_character === 9 || _character >= 32 && _character <= 1114111)) throwError(state, "expected valid JSON character");
5227
- }
5228
- else if (PATTERN_NON_PRINTABLE.test(_result)) throwError(state, "the stream contains non-printable characters");
5229
- state.result += _result;
5230
- }
5231
- }
5232
- function mergeMappings(state, destination, source, overridableKeys) {
5233
- if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
5234
- const sourceKeys = Object.keys(source);
5235
- for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
5236
- const key = sourceKeys[index];
5237
- if (!_hasOwnProperty.call(destination, key)) {
5238
- setProperty(destination, key, source[key]);
5239
- overridableKeys[key] = true;
5240
- }
5241
- }
4996
+ }
4997
+ function padStart(string, max) {
4998
+ return " ".repeat(Math.max(max - string.length, 0)) + string;
4999
+ }
5000
+ function makeSnippet(mark, options) {
5001
+ if (!mark.buffer) return null;
5002
+ const opts = {
5003
+ ...DEFAULT_SNIPPET_OPTIONS,
5004
+ ...options
5005
+ };
5006
+ const re = /\r?\n|\r|\0/g;
5007
+ const lineStarts = [0];
5008
+ const lineEnds = [];
5009
+ let match;
5010
+ let foundLineNo = -1;
5011
+ while (match = re.exec(mark.buffer)) {
5012
+ lineEnds.push(match.index);
5013
+ lineStarts.push(match.index + match[0].length);
5014
+ if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
5015
+ }
5016
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
5017
+ let result = "";
5018
+ const lineNoLength = Math.min(mark.line + opts.linesAfter, lineEnds.length).toString().length;
5019
+ const maxLineLength = opts.maxLength - (opts.indent + lineNoLength + 3);
5020
+ for (let i = 1; i <= opts.linesBefore; i++) {
5021
+ if (foundLineNo - i < 0) break;
5022
+ const line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
5023
+ result = `${" ".repeat(opts.indent)}${padStart((mark.line - i + 1).toString(), lineNoLength)} | ${line.str}\n${result}`;
5024
+ }
5025
+ const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
5026
+ result += `${" ".repeat(opts.indent)}${padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}\n`;
5027
+ result += `${"-".repeat(opts.indent + lineNoLength + 3 + line.pos)}^\n`;
5028
+ for (let i = 1; i <= opts.linesAfter; i++) {
5029
+ if (foundLineNo + i >= lineEnds.length) break;
5030
+ const line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
5031
+ result += `${" ".repeat(opts.indent)}${padStart((mark.line + i + 1).toString(), lineNoLength)} | ${line.str}\n`;
5032
+ }
5033
+ return result.replace(/\n$/, "");
5034
+ }
5035
+ //#endregion
5036
+ //#region src/common/exception.ts
5037
+ function formatError(exception, compact) {
5038
+ let where = "";
5039
+ if (!exception.mark) return exception.reason;
5040
+ if (exception.mark.name) where += `in "${exception.mark.name}" `;
5041
+ where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
5042
+ if (!compact && exception.mark.snippet) where += `\n\n${exception.mark.snippet}`;
5043
+ return `${exception.reason} ${where}`;
5044
+ }
5045
+ var YAMLException = class extends Error {
5046
+ reason;
5047
+ mark;
5048
+ constructor(reason, mark) {
5049
+ super();
5050
+ this.name = "YAMLException";
5051
+ this.reason = reason;
5052
+ this.mark = mark;
5053
+ this.message = formatError(this, false);
5054
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
5242
5055
  }
5243
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
5244
- if (Array.isArray(keyNode)) {
5245
- keyNode = Array.prototype.slice.call(keyNode);
5246
- for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
5247
- if (Array.isArray(keyNode[index])) throwError(state, "nested arrays are not supported inside keys");
5248
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") keyNode[index] = "[object Object]";
5249
- }
5250
- }
5251
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") keyNode = "[object Object]";
5252
- keyNode = String(keyNode);
5253
- if (_result === null) _result = {};
5254
- if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) {
5255
- if (valueNode.length > state.maxMergeSeqLength) throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
5256
- const seen = /* @__PURE__ */ new Set();
5257
- for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
5258
- const src = valueNode[index];
5259
- if (seen.has(src)) continue;
5260
- seen.add(src);
5261
- mergeMappings(state, _result, src, overridableKeys);
5262
- }
5263
- } else mergeMappings(state, _result, valueNode, overridableKeys);
5264
- else {
5265
- if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
5266
- state.line = startLine || state.line;
5267
- state.lineStart = startLineStart || state.lineStart;
5268
- state.position = startPos || state.position;
5269
- throwError(state, "duplicated mapping key");
5270
- }
5271
- setProperty(_result, keyNode, valueNode);
5272
- delete overridableKeys[keyNode];
5273
- }
5274
- return _result;
5056
+ toString(compact) {
5057
+ return `${this.name}: ${formatError(this, compact)}`;
5275
5058
  }
5276
- function readLineBreak(state) {
5277
- const ch = state.input.charCodeAt(state.position);
5278
- if (ch === 10) state.position++;
5279
- else if (ch === 13) {
5280
- state.position++;
5281
- if (state.input.charCodeAt(state.position) === 10) state.position++;
5282
- } else throwError(state, "a line break is expected");
5283
- state.line += 1;
5284
- state.lineStart = state.position;
5285
- state.firstTabInLine = -1;
5286
- }
5287
- function skipSeparationSpace(state, allowComments, checkIndent) {
5288
- let lineBreaks = 0;
5289
- let ch = state.input.charCodeAt(state.position);
5290
- while (ch !== 0) {
5291
- while (isWhiteSpace(ch)) {
5292
- if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
5293
- ch = state.input.charCodeAt(++state.position);
5294
- }
5295
- if (allowComments && ch === 35) do
5296
- ch = state.input.charCodeAt(++state.position);
5297
- while (ch !== 10 && ch !== 13 && ch !== 0);
5298
- if (isEol(ch)) {
5299
- readLineBreak(state);
5300
- ch = state.input.charCodeAt(state.position);
5301
- lineBreaks++;
5302
- state.lineIndent = 0;
5303
- while (ch === 32) {
5304
- state.lineIndent++;
5305
- ch = state.input.charCodeAt(++state.position);
5306
- }
5307
- } else break;
5308
- }
5309
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) throwWarning(state, "deficient indentation");
5310
- return lineBreaks;
5311
- }
5312
- function testDocumentSeparator(state) {
5313
- let _position = state.position;
5314
- let ch = state.input.charCodeAt(_position);
5315
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
5316
- _position += 3;
5317
- ch = state.input.charCodeAt(_position);
5318
- if (ch === 0 || isWsOrEol(ch)) return true;
5059
+ };
5060
+ function throwErrorAt(source, position, message, filename = "") {
5061
+ let line = 0;
5062
+ let lineStart = 0;
5063
+ for (let index = 0; index < position; index++) {
5064
+ const ch = source.charCodeAt(index);
5065
+ if (ch === 10) {
5066
+ line++;
5067
+ lineStart = index + 1;
5068
+ } else if (ch === 13) {
5069
+ line++;
5070
+ if (source.charCodeAt(index + 1) === 10) index++;
5071
+ lineStart = index + 1;
5319
5072
  }
5320
- return false;
5321
5073
  }
5322
- function writeFoldedLines(state, count) {
5323
- if (count === 1) state.result += " ";
5324
- else if (count > 1) state.result += common.repeat("\n", count - 1);
5325
- }
5326
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
5327
- let captureStart;
5328
- let captureEnd;
5329
- let hasPendingContent;
5330
- let _line;
5331
- let _lineStart;
5332
- let _lineIndent;
5333
- const _kind = state.kind;
5334
- const _result = state.result;
5335
- let ch = state.input.charCodeAt(state.position);
5336
- 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;
5337
- if (ch === 63 || ch === 45) {
5338
- const following = state.input.charCodeAt(state.position + 1);
5339
- if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) return false;
5340
- }
5341
- state.kind = "scalar";
5342
- state.result = "";
5343
- captureStart = captureEnd = state.position;
5344
- hasPendingContent = false;
5345
- while (ch !== 0) {
5346
- if (ch === 58) {
5347
- const following = state.input.charCodeAt(state.position + 1);
5348
- if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) break;
5349
- } else if (ch === 35) {
5350
- if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
5351
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) break;
5352
- else if (isEol(ch)) {
5353
- _line = state.line;
5354
- _lineStart = state.lineStart;
5355
- _lineIndent = state.lineIndent;
5356
- skipSeparationSpace(state, false, -1);
5357
- if (state.lineIndent >= nodeIndent) {
5358
- hasPendingContent = true;
5359
- ch = state.input.charCodeAt(state.position);
5360
- continue;
5361
- } else {
5362
- state.position = captureEnd;
5363
- state.line = _line;
5364
- state.lineStart = _lineStart;
5365
- state.lineIndent = _lineIndent;
5366
- break;
5367
- }
5368
- }
5369
- if (hasPendingContent) {
5370
- captureSegment(state, captureStart, captureEnd, false);
5371
- writeFoldedLines(state, state.line - _line);
5372
- captureStart = captureEnd = state.position;
5373
- hasPendingContent = false;
5374
- }
5375
- if (!isWhiteSpace(ch)) captureEnd = state.position + 1;
5376
- ch = state.input.charCodeAt(++state.position);
5074
+ const mark = {
5075
+ name: filename,
5076
+ buffer: source,
5077
+ position,
5078
+ line,
5079
+ column: position - lineStart
5080
+ };
5081
+ mark.snippet = makeSnippet(mark);
5082
+ throw new YAMLException(message, mark);
5083
+ }
5084
+ //#endregion
5085
+ //#region src/parser/parser_scalar.ts
5086
+ var NO_RANGE$3 = -1;
5087
+ function simpleEscapeSequence(c) {
5088
+ switch (c) {
5089
+ case 48: return "\0";
5090
+ case 97: return "\x07";
5091
+ case 98: return "\b";
5092
+ case 116: return " ";
5093
+ case 9: return " ";
5094
+ case 110: return "\n";
5095
+ case 118: return "\v";
5096
+ case 102: return "\f";
5097
+ case 114: return "\r";
5098
+ case 101: return "\x1B";
5099
+ case 32: return " ";
5100
+ case 34: return "\"";
5101
+ case 47: return "/";
5102
+ case 92: return "\\";
5103
+ case 78: return "…";
5104
+ case 95: return "\xA0";
5105
+ case 76: return "\u2028";
5106
+ case 80: return "\u2029";
5107
+ default: return "";
5108
+ }
5109
+ }
5110
+ var simpleEscapeCheck = new Array(256);
5111
+ var simpleEscapeMap = new Array(256);
5112
+ for (let i = 0; i < 256; i++) {
5113
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
5114
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
5115
+ }
5116
+ function charFromCodepoint(c) {
5117
+ if (c <= 65535) return String.fromCharCode(c);
5118
+ return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
5119
+ }
5120
+ function fromHexCode$1(c) {
5121
+ if (c >= 48 && c <= 57) return c - 48;
5122
+ return (c | 32) - 97 + 10;
5123
+ }
5124
+ function escapedHexLen$1(c) {
5125
+ if (c === 120) return 2;
5126
+ if (c === 117) return 4;
5127
+ return 8;
5128
+ }
5129
+ function skipFoldedBreaks(input, position, end) {
5130
+ let breaks = 0;
5131
+ while (position < end) {
5132
+ const ch = input.charCodeAt(position);
5133
+ if (ch === 10) {
5134
+ breaks++;
5135
+ position++;
5136
+ } else if (ch === 13) {
5137
+ breaks++;
5138
+ position++;
5139
+ if (input.charCodeAt(position) === 10) position++;
5140
+ } else if (ch === 32 || ch === 9) position++;
5141
+ else break;
5142
+ }
5143
+ return {
5144
+ position,
5145
+ breaks
5146
+ };
5147
+ }
5148
+ function foldedBreaks(count) {
5149
+ if (count === 1) return " ";
5150
+ return "\n".repeat(count - 1);
5151
+ }
5152
+ function getPlainValue(input, start, end) {
5153
+ let result = "";
5154
+ let position = start;
5155
+ let captureStart = start;
5156
+ let captureEnd = start;
5157
+ while (position < end) {
5158
+ const ch = input.charCodeAt(position);
5159
+ if (ch === 10 || ch === 13) {
5160
+ result += input.slice(captureStart, captureEnd);
5161
+ const fold = skipFoldedBreaks(input, position, end);
5162
+ result += foldedBreaks(fold.breaks);
5163
+ position = captureStart = captureEnd = fold.position;
5164
+ } else {
5165
+ position++;
5166
+ if (ch !== 32 && ch !== 9) captureEnd = position;
5377
5167
  }
5378
- captureSegment(state, captureStart, captureEnd, false);
5379
- if (state.result) return true;
5380
- state.kind = _kind;
5381
- state.result = _result;
5382
- return false;
5383
5168
  }
5384
- function readSingleQuotedScalar(state, nodeIndent) {
5385
- let captureStart;
5386
- let captureEnd;
5387
- let ch = state.input.charCodeAt(state.position);
5388
- if (ch !== 39) return false;
5389
- state.kind = "scalar";
5390
- state.result = "";
5391
- state.position++;
5392
- captureStart = captureEnd = state.position;
5393
- while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 39) {
5394
- captureSegment(state, captureStart, state.position, true);
5395
- ch = state.input.charCodeAt(++state.position);
5396
- if (ch === 39) {
5397
- captureStart = state.position;
5398
- state.position++;
5399
- captureEnd = state.position;
5400
- } else return true;
5401
- } else if (isEol(ch)) {
5402
- captureSegment(state, captureStart, captureEnd, true);
5403
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
5404
- captureStart = captureEnd = state.position;
5405
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
5406
- else {
5407
- state.position++;
5408
- if (!isWhiteSpace(ch)) captureEnd = state.position;
5169
+ return result + input.slice(captureStart, captureEnd);
5170
+ }
5171
+ function getSingleQuotedValue(input, start, end) {
5172
+ let result = "";
5173
+ let position = start;
5174
+ let captureStart = start;
5175
+ let captureEnd = start;
5176
+ while (position < end) {
5177
+ const ch = input.charCodeAt(position);
5178
+ if (ch === 39) {
5179
+ result += input.slice(captureStart, position) + "'";
5180
+ position += 2;
5181
+ captureStart = captureEnd = position;
5182
+ } else if (ch === 10 || ch === 13) {
5183
+ result += input.slice(captureStart, captureEnd);
5184
+ const fold = skipFoldedBreaks(input, position, end);
5185
+ result += foldedBreaks(fold.breaks);
5186
+ position = captureStart = captureEnd = fold.position;
5187
+ } else {
5188
+ position++;
5189
+ if (ch !== 32 && ch !== 9) captureEnd = position;
5409
5190
  }
5410
- throwError(state, "unexpected end of the stream within a single quoted scalar");
5411
5191
  }
5412
- function readDoubleQuotedScalar(state, nodeIndent) {
5413
- let captureStart;
5414
- let captureEnd;
5415
- let tmp;
5416
- let ch = state.input.charCodeAt(state.position);
5417
- if (ch !== 34) return false;
5418
- state.kind = "scalar";
5419
- state.result = "";
5420
- state.position++;
5421
- captureStart = captureEnd = state.position;
5422
- while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 34) {
5423
- captureSegment(state, captureStart, state.position, true);
5424
- state.position++;
5425
- return true;
5426
- } else if (ch === 92) {
5427
- captureSegment(state, captureStart, state.position, true);
5428
- ch = state.input.charCodeAt(++state.position);
5429
- if (isEol(ch)) skipSeparationSpace(state, false, nodeIndent);
5430
- else if (ch < 256 && simpleEscapeCheck[ch]) {
5431
- state.result += simpleEscapeMap[ch];
5432
- state.position++;
5433
- } else if ((tmp = escapedHexLen(ch)) > 0) {
5434
- let hexLength = tmp;
5192
+ return result + input.slice(captureStart, end);
5193
+ }
5194
+ function getDoubleQuotedValue(input, start, end) {
5195
+ let result = "";
5196
+ let position = start;
5197
+ let captureStart = start;
5198
+ let captureEnd = start;
5199
+ while (position < end) {
5200
+ const ch = input.charCodeAt(position);
5201
+ if (ch === 92) {
5202
+ result += input.slice(captureStart, position);
5203
+ position++;
5204
+ const escaped = input.charCodeAt(position);
5205
+ if (escaped === 10 || escaped === 13) position = skipFoldedBreaks(input, position, end).position;
5206
+ else if (escaped < 256 && simpleEscapeCheck[escaped]) {
5207
+ result += simpleEscapeMap[escaped];
5208
+ position++;
5209
+ } else {
5210
+ let hexLength = escapedHexLen$1(escaped);
5435
5211
  let hexResult = 0;
5436
5212
  for (; hexLength > 0; hexLength--) {
5437
- ch = state.input.charCodeAt(++state.position);
5438
- if ((tmp = fromHexCode(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
5439
- else throwError(state, "expected hexadecimal character");
5440
- }
5441
- state.result += charFromCodepoint(hexResult);
5442
- state.position++;
5443
- } else throwError(state, "unknown escape sequence");
5444
- captureStart = captureEnd = state.position;
5445
- } else if (isEol(ch)) {
5446
- captureSegment(state, captureStart, captureEnd, true);
5447
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
5448
- captureStart = captureEnd = state.position;
5449
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
5450
- else {
5451
- state.position++;
5452
- if (!isWhiteSpace(ch)) captureEnd = state.position;
5453
- }
5454
- throwError(state, "unexpected end of the stream within a double quoted scalar");
5455
- }
5456
- function readFlowCollection(state, nodeIndent) {
5457
- let readNext = true;
5458
- let _line;
5459
- let _lineStart;
5460
- let _pos;
5461
- const _tag = state.tag;
5462
- let _result;
5463
- const _anchor = state.anchor;
5464
- let terminator;
5465
- let isPair;
5466
- let isExplicitPair;
5467
- let isMapping;
5468
- const overridableKeys = Object.create(null);
5469
- let keyNode;
5470
- let keyTag;
5471
- let valueNode;
5472
- let ch = state.input.charCodeAt(state.position);
5473
- if (ch === 91) {
5474
- terminator = 93;
5475
- isMapping = false;
5476
- _result = [];
5477
- } else if (ch === 123) {
5478
- terminator = 125;
5479
- isMapping = true;
5480
- _result = {};
5481
- } else return false;
5482
- if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5483
- ch = state.input.charCodeAt(++state.position);
5484
- while (ch !== 0) {
5485
- skipSeparationSpace(state, true, nodeIndent);
5486
- ch = state.input.charCodeAt(state.position);
5487
- if (ch === terminator) {
5488
- state.position++;
5489
- state.tag = _tag;
5490
- state.anchor = _anchor;
5491
- state.kind = isMapping ? "mapping" : "sequence";
5492
- state.result = _result;
5493
- return true;
5494
- } else if (!readNext) throwError(state, "missed comma between flow collection entries");
5495
- else if (ch === 44) throwError(state, "expected the node content, but found ','");
5496
- keyTag = keyNode = valueNode = null;
5497
- isPair = isExplicitPair = false;
5498
- if (ch === 63) {
5499
- if (isWsOrEol(state.input.charCodeAt(state.position + 1))) {
5500
- isPair = isExplicitPair = true;
5501
- state.position++;
5502
- skipSeparationSpace(state, true, nodeIndent);
5213
+ position++;
5214
+ const digit = fromHexCode$1(input.charCodeAt(position));
5215
+ hexResult = (hexResult << 4) + digit;
5503
5216
  }
5217
+ result += charFromCodepoint(hexResult);
5218
+ position++;
5504
5219
  }
5505
- _line = state.line;
5506
- _lineStart = state.lineStart;
5507
- _pos = state.position;
5508
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
5509
- keyTag = state.tag;
5510
- keyNode = state.result;
5511
- skipSeparationSpace(state, true, nodeIndent);
5512
- ch = state.input.charCodeAt(state.position);
5513
- if ((isExplicitPair || state.line === _line) && ch === 58) {
5514
- isPair = true;
5515
- ch = state.input.charCodeAt(++state.position);
5516
- skipSeparationSpace(state, true, nodeIndent);
5517
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
5518
- valueNode = state.result;
5519
- }
5520
- if (isMapping) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
5521
- else if (isPair) _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
5522
- else _result.push(keyNode);
5523
- skipSeparationSpace(state, true, nodeIndent);
5524
- ch = state.input.charCodeAt(state.position);
5525
- if (ch === 44) {
5526
- readNext = true;
5527
- ch = state.input.charCodeAt(++state.position);
5528
- } else readNext = false;
5529
- }
5530
- throwError(state, "unexpected end of the stream within a flow collection");
5531
- }
5532
- function readBlockScalar(state, nodeIndent) {
5533
- let folding;
5534
- let chomping = CHOMPING_CLIP;
5535
- let didReadContent = false;
5536
- let detectedIndent = false;
5537
- let textIndent = nodeIndent;
5538
- let emptyLines = 0;
5539
- let atMoreIndented = false;
5540
- let tmp;
5541
- let ch = state.input.charCodeAt(state.position);
5542
- if (ch === 124) folding = false;
5543
- else if (ch === 62) folding = true;
5544
- else return false;
5545
- state.kind = "scalar";
5546
- state.result = "";
5547
- while (ch !== 0) {
5548
- ch = state.input.charCodeAt(++state.position);
5549
- if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
5550
- else throwError(state, "repeat of a chomping mode identifier");
5551
- 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");
5552
- else if (!detectedIndent) {
5553
- textIndent = nodeIndent + tmp - 1;
5554
- detectedIndent = true;
5555
- } else throwError(state, "repeat of an indentation width identifier");
5556
- else break;
5557
- }
5558
- if (isWhiteSpace(ch)) {
5559
- do
5560
- ch = state.input.charCodeAt(++state.position);
5561
- while (isWhiteSpace(ch));
5562
- if (ch === 35) do
5563
- ch = state.input.charCodeAt(++state.position);
5564
- while (!isEol(ch) && ch !== 0);
5220
+ captureStart = captureEnd = position;
5221
+ } else if (ch === 10 || ch === 13) {
5222
+ result += input.slice(captureStart, captureEnd);
5223
+ const fold = skipFoldedBreaks(input, position, end);
5224
+ result += foldedBreaks(fold.breaks);
5225
+ position = captureStart = captureEnd = fold.position;
5226
+ } else {
5227
+ position++;
5228
+ if (ch !== 32 && ch !== 9) captureEnd = position;
5565
5229
  }
5566
- while (ch !== 0) {
5567
- readLineBreak(state);
5568
- state.lineIndent = 0;
5569
- ch = state.input.charCodeAt(state.position);
5570
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
5571
- state.lineIndent++;
5572
- ch = state.input.charCodeAt(++state.position);
5573
- }
5574
- if (!detectedIndent && state.lineIndent > textIndent) textIndent = state.lineIndent;
5575
- if (isEol(ch)) {
5576
- emptyLines++;
5577
- continue;
5578
- }
5579
- if (!detectedIndent && textIndent === 0) throwError(state, "missing indentation for block scalar");
5580
- if (state.lineIndent < textIndent) {
5581
- if (chomping === CHOMPING_KEEP) state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5582
- else if (chomping === CHOMPING_CLIP) {
5583
- if (didReadContent) state.result += "\n";
5584
- }
5585
- break;
5586
- }
5587
- if (folding) if (isWhiteSpace(ch)) {
5588
- atMoreIndented = true;
5589
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5590
- } else if (atMoreIndented) {
5591
- atMoreIndented = false;
5592
- state.result += common.repeat("\n", emptyLines + 1);
5593
- } else if (emptyLines === 0) {
5594
- if (didReadContent) state.result += " ";
5595
- } else state.result += common.repeat("\n", emptyLines);
5596
- else state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
5597
- didReadContent = true;
5598
- detectedIndent = true;
5599
- emptyLines = 0;
5600
- const captureStart = state.position;
5601
- while (!isEol(ch) && ch !== 0) ch = state.input.charCodeAt(++state.position);
5602
- captureSegment(state, captureStart, state.position, false);
5230
+ }
5231
+ return result + input.slice(captureStart, end);
5232
+ }
5233
+ function getBlockValue(input, start, end, indent, chomping, folded) {
5234
+ const textIndent = indent < 0 ? 0 : indent;
5235
+ const region = input.slice(start, end).replace(/\r\n?/g, "\n");
5236
+ const lines = region === "" ? [] : (region.endsWith("\n") ? region.slice(0, -1) : region).split("\n");
5237
+ let result = "";
5238
+ let didReadContent = false;
5239
+ let emptyLines = 0;
5240
+ let atMoreIndented = false;
5241
+ for (const line of lines) {
5242
+ let column = 0;
5243
+ while (column < textIndent && line.charCodeAt(column) === 32) column++;
5244
+ if (indent < 0 || column >= line.length) {
5245
+ emptyLines++;
5246
+ continue;
5603
5247
  }
5604
- return true;
5248
+ const content = line.slice(textIndent);
5249
+ const first = content.charCodeAt(0);
5250
+ if (folded) if (first === 32 || first === 9) {
5251
+ atMoreIndented = true;
5252
+ result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
5253
+ } else if (atMoreIndented) {
5254
+ atMoreIndented = false;
5255
+ result += "\n".repeat(emptyLines + 1);
5256
+ } else if (emptyLines === 0) {
5257
+ if (didReadContent) result += " ";
5258
+ } else result += "\n".repeat(emptyLines);
5259
+ else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
5260
+ result += content;
5261
+ didReadContent = true;
5262
+ emptyLines = 0;
5263
+ }
5264
+ if (chomping === 3) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
5265
+ else if (chomping !== 2) {
5266
+ if (didReadContent) result += "\n";
5267
+ }
5268
+ return result;
5269
+ }
5270
+ function getScalarValue(input, scalar) {
5271
+ if (scalar.valueStart === NO_RANGE$3) return "";
5272
+ const { valueStart, valueEnd } = scalar;
5273
+ if (scalar.fast) return input.slice(valueStart, valueEnd);
5274
+ switch (scalar.style) {
5275
+ case 2: return getSingleQuotedValue(input, valueStart, valueEnd);
5276
+ case 3: return getDoubleQuotedValue(input, valueStart, valueEnd);
5277
+ case 4: return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
5278
+ case 5: return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
5279
+ default: return getPlainValue(input, valueStart, valueEnd);
5605
5280
  }
5606
- function readBlockSequence(state, nodeIndent) {
5607
- const _tag = state.tag;
5608
- const _anchor = state.anchor;
5609
- const _result = [];
5610
- let detected = false;
5611
- if (state.firstTabInLine !== -1) return false;
5612
- if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5613
- let ch = state.input.charCodeAt(state.position);
5614
- while (ch !== 0) {
5615
- if (state.firstTabInLine !== -1) {
5616
- state.position = state.firstTabInLine;
5617
- throwError(state, "tab characters must not be used in indentation");
5618
- }
5619
- if (ch !== 45) break;
5620
- if (!isWsOrEol(state.input.charCodeAt(state.position + 1))) break;
5621
- detected = true;
5622
- state.position++;
5623
- if (skipSeparationSpace(state, true, -1)) {
5624
- if (state.lineIndent <= nodeIndent) {
5625
- _result.push(null);
5626
- ch = state.input.charCodeAt(state.position);
5627
- continue;
5628
- }
5629
- }
5630
- const _line = state.line;
5631
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
5632
- _result.push(state.result);
5633
- skipSeparationSpace(state, true, -1);
5634
- ch = state.input.charCodeAt(state.position);
5635
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a sequence entry");
5636
- else if (state.lineIndent < nodeIndent) break;
5281
+ }
5282
+ //#endregion
5283
+ //#region src/common/tagname.ts
5284
+ var DEFAULT_TAG_HANDLERS = {
5285
+ "!": "!",
5286
+ "!!": "tag:yaml.org,2002:"
5287
+ };
5288
+ function tagNameFull(rawTag, tagHandlers) {
5289
+ if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
5290
+ const handleEnd = rawTag.indexOf("!", 1);
5291
+ const handle = handleEnd === -1 ? "!" : rawTag.slice(0, handleEnd + 1);
5292
+ const prefix = tagHandlers?.[handle] ?? DEFAULT_TAG_HANDLERS[handle] ?? handle;
5293
+ return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
5294
+ }
5295
+ //#endregion
5296
+ //#region src/parser/constructor.ts
5297
+ var NO_RANGE$2 = -1;
5298
+ var DEFAULT_CONSTRUCTOR_OPTIONS = {
5299
+ filename: "",
5300
+ schema: CORE_SCHEMA,
5301
+ json: false,
5302
+ maxTotalMergeKeys: 1e4,
5303
+ maxAliases: -1
5304
+ };
5305
+ function eventPosition$1(event) {
5306
+ if ("tagStart" in event && event.tagStart !== NO_RANGE$2) return event.tagStart;
5307
+ if ("anchorStart" in event && event.anchorStart !== NO_RANGE$2) return event.anchorStart;
5308
+ if ("valueStart" in event && event.valueStart !== NO_RANGE$2) return event.valueStart;
5309
+ if ("start" in event) return event.start;
5310
+ return 0;
5311
+ }
5312
+ function throwError$1(state, message) {
5313
+ throwErrorAt(state.source, state.position, message, state.filename);
5314
+ }
5315
+ function finalizeCollection(state, position, tag, carrier) {
5316
+ try {
5317
+ return tag.finalize(carrier);
5318
+ } catch (error) {
5319
+ if (error instanceof YAMLException) throw error;
5320
+ throwErrorAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
5321
+ }
5322
+ }
5323
+ function lookupTag(exact, prefix, tagName) {
5324
+ const exactTag = exact[tagName];
5325
+ if (exactTag) return exactTag;
5326
+ for (const tag of prefix) if (tagName.startsWith(tag.tagName)) return tag;
5327
+ }
5328
+ function findExplicitTag(state, exact, prefix, tagName, nodeKind) {
5329
+ const tag = lookupTag(exact, prefix, tagName);
5330
+ if (tag) return tag;
5331
+ throwError$1(state, `unknown ${nodeKind} tag !<${tagName}>`);
5332
+ }
5333
+ function constructScalar(state, event) {
5334
+ const source = getScalarValue(state.source, event);
5335
+ const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
5336
+ const strTag = state.schema.defaultScalarTag;
5337
+ if (rawTag !== "") {
5338
+ if (rawTag === "!") return {
5339
+ value: source,
5340
+ tag: strTag
5341
+ };
5342
+ const tagName = tagNameFull(rawTag, state.tagHandlers);
5343
+ const scalarTag = lookupTag(state.schema.exact.scalar, state.schema.prefix.scalar, tagName);
5344
+ if (scalarTag) {
5345
+ const result = scalarTag.resolve(source, true, tagName);
5346
+ if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
5347
+ return {
5348
+ value: result,
5349
+ tag: scalarTag
5350
+ };
5637
5351
  }
5638
- if (detected) {
5639
- state.tag = _tag;
5640
- state.anchor = _anchor;
5641
- state.kind = "sequence";
5642
- state.result = _result;
5643
- return true;
5352
+ const collectionTagDef = lookupTag(state.schema.exact.mapping, state.schema.prefix.mapping, tagName) ?? lookupTag(state.schema.exact.sequence, state.schema.prefix.sequence, tagName);
5353
+ if (collectionTagDef) {
5354
+ if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
5355
+ const carrier = collectionTagDef.create(tagName);
5356
+ return {
5357
+ value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier),
5358
+ tag: collectionTagDef
5359
+ };
5360
+ }
5361
+ throwError$1(state, `unknown scalar tag !<${tagName}>`);
5362
+ }
5363
+ if (event.style === 1) {
5364
+ const candidates = state.schema.implicitScalarByFirstChar.get(source.charAt(0)) ?? state.schema.implicitScalarAnyFirstChar;
5365
+ for (const tag of candidates) {
5366
+ const result = tag.resolve(source, false, tag.tagName);
5367
+ if (result !== NOT_RESOLVED) return {
5368
+ value: result,
5369
+ tag
5370
+ };
5644
5371
  }
5645
- return false;
5646
5372
  }
5647
- function readBlockMapping(state, nodeIndent, flowIndent) {
5648
- let allowCompact;
5649
- let _keyLine;
5650
- let _keyLineStart;
5651
- let _keyPos;
5652
- const _tag = state.tag;
5653
- const _anchor = state.anchor;
5654
- const _result = {};
5655
- const overridableKeys = Object.create(null);
5656
- let keyTag = null;
5657
- let keyNode = null;
5658
- let valueNode = null;
5659
- let atExplicitKey = false;
5660
- let detected = false;
5661
- if (state.firstTabInLine !== -1) return false;
5662
- if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
5663
- let ch = state.input.charCodeAt(state.position);
5664
- while (ch !== 0) {
5665
- if (!atExplicitKey && state.firstTabInLine !== -1) {
5666
- state.position = state.firstTabInLine;
5667
- throwError(state, "tab characters must not be used in indentation");
5373
+ return {
5374
+ value: strTag.resolve(source, false, strTag.tagName),
5375
+ tag: strTag
5376
+ };
5377
+ }
5378
+ function collectionTag(state, event, exact, prefix, defaultTagName, nodeKind) {
5379
+ const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
5380
+ const tagName = rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
5381
+ return {
5382
+ tagName,
5383
+ tag: findExplicitTag(state, exact, prefix, tagName, nodeKind)
5384
+ };
5385
+ }
5386
+ function isMappingTag(tag) {
5387
+ return tag.nodeKind === "mapping";
5388
+ }
5389
+ function mergeKeys(state, frame, source, sourceTag) {
5390
+ for (const sourceKey of sourceTag.keys(source)) {
5391
+ if (state.maxTotalMergeKeys !== -1 && ++state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
5392
+ if (frame.tag.has(frame.value, sourceKey)) continue;
5393
+ const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
5394
+ if (err) throwError$1(state, err);
5395
+ (frame.overridable ??= /* @__PURE__ */ new Set()).add(sourceKey);
5396
+ }
5397
+ }
5398
+ function mergeSource(state, frame, source, sourceTag) {
5399
+ state.position = frame.keyPosition;
5400
+ if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
5401
+ else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) for (const element of source) mergeKeys(state, frame, element, frame.tag);
5402
+ else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
5403
+ }
5404
+ function addMappingValue(state, frame, key, value, tag) {
5405
+ state.position = frame.keyPosition;
5406
+ if (key === MERGE_KEY) {
5407
+ mergeSource(state, frame, value, tag);
5408
+ return;
5409
+ }
5410
+ if (!state.json && frame.tag.has(frame.value, key) && !frame.overridable?.has(key)) throwError$1(state, "duplicated mapping key");
5411
+ const err = frame.tag.addPair(frame.value, key, value);
5412
+ if (err) throwError$1(state, err);
5413
+ frame.overridable?.delete(key);
5414
+ }
5415
+ function addValue(state, value, tag) {
5416
+ const frame = state.frames[state.frames.length - 1];
5417
+ if (frame.kind === "document") {
5418
+ frame.value = value;
5419
+ frame.hasValue = true;
5420
+ } else if (frame.kind === "sequence") {
5421
+ if (frame.merge) {
5422
+ if (!isMappingTag(tag)) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
5423
+ }
5424
+ const err = frame.tag.addItem(frame.value, value, frame.index++);
5425
+ if (err) throwError$1(state, err);
5426
+ } else if (frame.hasKey) {
5427
+ const key = frame.key;
5428
+ frame.key = void 0;
5429
+ frame.hasKey = false;
5430
+ addMappingValue(state, frame, key, value, tag);
5431
+ } else {
5432
+ frame.key = value;
5433
+ frame.keyPosition = state.position;
5434
+ frame.hasKey = true;
5435
+ }
5436
+ }
5437
+ function storeAnchor(state, event, value, tag, isValueFinal) {
5438
+ if (event.anchorStart !== NO_RANGE$2) {
5439
+ const anchor = {
5440
+ value,
5441
+ tag,
5442
+ isValueFinal
5443
+ };
5444
+ state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
5445
+ return anchor;
5446
+ }
5447
+ return null;
5448
+ }
5449
+ function constructFromEvents(events, options) {
5450
+ const state = {
5451
+ ...DEFAULT_CONSTRUCTOR_OPTIONS,
5452
+ ...options,
5453
+ events,
5454
+ documents: [],
5455
+ eventIndex: 0,
5456
+ position: 0,
5457
+ frames: [],
5458
+ anchors: /* @__PURE__ */ new Map(),
5459
+ tagHandlers: Object.create(null),
5460
+ totalMergeKeys: 0,
5461
+ aliasCount: 0
5462
+ };
5463
+ while (state.eventIndex < state.events.length) {
5464
+ const event = state.events[state.eventIndex++];
5465
+ state.position = eventPosition$1(event);
5466
+ switch (event.type) {
5467
+ case 1:
5468
+ state.anchors = /* @__PURE__ */ new Map();
5469
+ state.aliasCount = 0;
5470
+ state.tagHandlers = Object.create(null);
5471
+ for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
5472
+ state.frames.push({
5473
+ kind: "document",
5474
+ position: state.position,
5475
+ value: void 0,
5476
+ hasValue: false
5477
+ });
5478
+ break;
5479
+ case 4: {
5480
+ const { value, tag } = constructScalar(state, event);
5481
+ storeAnchor(state, event, value, tag, true);
5482
+ addValue(state, value, tag);
5483
+ break;
5668
5484
  }
5669
- const following = state.input.charCodeAt(state.position + 1);
5670
- const _line = state.line;
5671
- if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
5672
- if (ch === 63) {
5673
- if (atExplicitKey) {
5674
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5675
- keyTag = keyNode = valueNode = null;
5676
- }
5677
- detected = true;
5678
- atExplicitKey = true;
5679
- allowCompact = true;
5680
- } else if (atExplicitKey) {
5681
- atExplicitKey = false;
5682
- allowCompact = true;
5683
- } else throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
5684
- state.position += 1;
5685
- ch = following;
5686
- } else {
5687
- _keyLine = state.line;
5688
- _keyLineStart = state.lineStart;
5689
- _keyPos = state.position;
5690
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
5691
- if (state.line === _line) {
5692
- ch = state.input.charCodeAt(state.position);
5693
- while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
5694
- if (ch === 58) {
5695
- ch = state.input.charCodeAt(++state.position);
5696
- if (!isWsOrEol(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
5697
- if (atExplicitKey) {
5698
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5699
- keyTag = keyNode = valueNode = null;
5700
- }
5701
- detected = true;
5702
- atExplicitKey = false;
5703
- allowCompact = false;
5704
- keyTag = state.tag;
5705
- keyNode = state.result;
5706
- } else if (detected) throwError(state, "can not read an implicit mapping pair; a colon is missed");
5707
- else {
5708
- state.tag = _tag;
5709
- state.anchor = _anchor;
5710
- return true;
5711
- }
5712
- } else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
5713
- else {
5714
- state.tag = _tag;
5715
- state.anchor = _anchor;
5716
- return true;
5717
- }
5485
+ case 2: {
5486
+ const definition = collectionTag(state, event, state.schema.exact.sequence, state.schema.prefix.sequence, "tag:yaml.org,2002:seq", "sequence");
5487
+ const value = definition.tag.create(definition.tagName);
5488
+ const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
5489
+ const parent = state.frames[state.frames.length - 1];
5490
+ const merge = parent !== void 0 && parent.kind === "mapping" && parent.hasKey && parent.key === MERGE_KEY;
5491
+ state.frames.push({
5492
+ kind: "sequence",
5493
+ position: state.position,
5494
+ value,
5495
+ tag: definition.tag,
5496
+ anchor,
5497
+ index: 0,
5498
+ merge
5499
+ });
5500
+ break;
5718
5501
  }
5719
- if (state.line === _line || state.lineIndent > nodeIndent) {
5720
- if (atExplicitKey) {
5721
- _keyLine = state.line;
5722
- _keyLineStart = state.lineStart;
5723
- _keyPos = state.position;
5724
- }
5725
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) if (atExplicitKey) keyNode = state.result;
5726
- else valueNode = state.result;
5727
- if (!atExplicitKey) {
5728
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
5729
- keyTag = keyNode = valueNode = null;
5502
+ case 3: {
5503
+ const definition = collectionTag(state, event, state.schema.exact.mapping, state.schema.prefix.mapping, "tag:yaml.org,2002:map", "mapping");
5504
+ const value = definition.tag.create(definition.tagName);
5505
+ const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult);
5506
+ state.frames.push({
5507
+ kind: "mapping",
5508
+ position: state.position,
5509
+ value,
5510
+ tag: definition.tag,
5511
+ anchor,
5512
+ key: void 0,
5513
+ keyPosition: state.position,
5514
+ hasKey: false,
5515
+ overridable: null
5516
+ });
5517
+ break;
5518
+ }
5519
+ case 5: {
5520
+ if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
5521
+ const name = state.source.slice(event.anchorStart, event.anchorEnd);
5522
+ const anchor = state.anchors.get(name);
5523
+ if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
5524
+ if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
5525
+ addValue(state, anchor.value, anchor.tag);
5526
+ break;
5527
+ }
5528
+ case 6: {
5529
+ const frame = state.frames.pop();
5530
+ if (frame.kind === "document") state.documents.push(frame.value);
5531
+ else {
5532
+ const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
5533
+ if (frame.anchor) {
5534
+ frame.anchor.value = value;
5535
+ frame.anchor.isValueFinal = true;
5536
+ }
5537
+ addValue(state, value, frame.tag);
5730
5538
  }
5731
- skipSeparationSpace(state, true, -1);
5732
- ch = state.input.charCodeAt(state.position);
5539
+ break;
5733
5540
  }
5734
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
5735
- else if (state.lineIndent < nodeIndent) break;
5736
- }
5737
- if (atExplicitKey) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
5738
- if (detected) {
5739
- state.tag = _tag;
5740
- state.anchor = _anchor;
5741
- state.kind = "mapping";
5742
- state.result = _result;
5743
5541
  }
5744
- return detected;
5745
5542
  }
5746
- function readTagProperty(state) {
5747
- let isVerbatim = false;
5748
- let isNamed = false;
5749
- let tagHandle;
5750
- let tagName;
5751
- let ch = state.input.charCodeAt(state.position);
5752
- if (ch !== 33) return false;
5753
- if (state.tag !== null) throwError(state, "duplication of a tag property");
5754
- ch = state.input.charCodeAt(++state.position);
5755
- if (ch === 60) {
5756
- isVerbatim = true;
5757
- ch = state.input.charCodeAt(++state.position);
5758
- } else if (ch === 33) {
5759
- isNamed = true;
5760
- tagHandle = "!!";
5543
+ return state.documents;
5544
+ }
5545
+ //#endregion
5546
+ //#region src/parser/parser.ts
5547
+ var NO_RANGE$1 = -1;
5548
+ var HAS_OWN = Object.prototype.hasOwnProperty;
5549
+ var CONTEXT_FLOW_IN = 1;
5550
+ var CONTEXT_FLOW_OUT = 2;
5551
+ var CONTEXT_BLOCK_IN = 3;
5552
+ var CONTEXT_BLOCK_OUT = 4;
5553
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
5554
+ var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
5555
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
5556
+ var NS_URI_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
5557
+ var NS_TAG_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
5558
+ var PATTERN_TAG_URI = new RegExp(`^(?:${NS_URI_CHAR})*$`);
5559
+ var PATTERN_TAG_SUFFIX = new RegExp(`^(?:${NS_TAG_CHAR})+$`);
5560
+ var PATTERN_TAG_PREFIX = new RegExp(`^(?:!(?:${NS_URI_CHAR})*|${NS_TAG_CHAR}(?:${NS_URI_CHAR})*)$`);
5561
+ var DEFAULT_PARSER_OPTIONS = {
5562
+ filename: "",
5563
+ maxDepth: 100
5564
+ };
5565
+ function addDocumentEvent(state, explicitStart, explicitEnd) {
5566
+ state.events.push({
5567
+ type: 1,
5568
+ explicitStart,
5569
+ explicitEnd,
5570
+ directives: state.directives
5571
+ });
5572
+ }
5573
+ function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
5574
+ state.events.push({
5575
+ type: 2,
5576
+ start,
5577
+ anchorStart,
5578
+ anchorEnd,
5579
+ tagStart,
5580
+ tagEnd,
5581
+ style
5582
+ });
5583
+ }
5584
+ function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
5585
+ state.events.push({
5586
+ type: 3,
5587
+ start,
5588
+ anchorStart,
5589
+ anchorEnd,
5590
+ tagStart,
5591
+ tagEnd,
5592
+ style
5593
+ });
5594
+ }
5595
+ function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = 1, indent = -1, fast = false) {
5596
+ state.events.push({
5597
+ type: 4,
5598
+ valueStart,
5599
+ valueEnd,
5600
+ anchorStart,
5601
+ anchorEnd,
5602
+ tagStart,
5603
+ tagEnd,
5604
+ style,
5605
+ chomping,
5606
+ indent,
5607
+ fast
5608
+ });
5609
+ }
5610
+ function addAliasEvent(state, anchorStart, anchorEnd) {
5611
+ state.events.push({
5612
+ type: 5,
5613
+ anchorStart,
5614
+ anchorEnd
5615
+ });
5616
+ }
5617
+ function addPopEvent(state) {
5618
+ state.events.push({ type: 6 });
5619
+ }
5620
+ function addEmptyScalarEvent(state) {
5621
+ addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 1);
5622
+ }
5623
+ function emptyProperties() {
5624
+ return {
5625
+ anchorStart: NO_RANGE$1,
5626
+ anchorEnd: NO_RANGE$1,
5627
+ tagStart: NO_RANGE$1,
5628
+ tagEnd: NO_RANGE$1
5629
+ };
5630
+ }
5631
+ function snapshotState(state) {
5632
+ return {
5633
+ position: state.position,
5634
+ line: state.line,
5635
+ lineStart: state.lineStart,
5636
+ lineIndent: state.lineIndent,
5637
+ firstTabInLine: state.firstTabInLine,
5638
+ eventsLength: state.events.length
5639
+ };
5640
+ }
5641
+ function restoreState(state, snapshot) {
5642
+ state.position = snapshot.position;
5643
+ state.line = snapshot.line;
5644
+ state.lineStart = snapshot.lineStart;
5645
+ state.lineIndent = snapshot.lineIndent;
5646
+ state.firstTabInLine = snapshot.firstTabInLine;
5647
+ state.events.length = snapshot.eventsLength;
5648
+ }
5649
+ function throwError(state, message) {
5650
+ throwErrorAt(state.input.slice(0, state.length), state.position, message, state.filename);
5651
+ }
5652
+ function isEol(c) {
5653
+ return c === 10 || c === 13;
5654
+ }
5655
+ function isWhiteSpace(c) {
5656
+ return c === 9 || c === 32;
5657
+ }
5658
+ function isWsOrEol(c) {
5659
+ return isWhiteSpace(c) || isEol(c);
5660
+ }
5661
+ function isWsOrEolOrEnd(c) {
5662
+ return c === 0 || isWsOrEol(c);
5663
+ }
5664
+ function isFlowIndicator(c) {
5665
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
5666
+ }
5667
+ function fromDecimalCode(c) {
5668
+ return c >= 48 && c <= 57 ? c - 48 : -1;
5669
+ }
5670
+ function fromHexCode(c) {
5671
+ if (c >= 48 && c <= 57) return c - 48;
5672
+ const lc = c | 32;
5673
+ if (lc >= 97 && lc <= 102) return lc - 97 + 10;
5674
+ return -1;
5675
+ }
5676
+ function escapedHexLen(c) {
5677
+ if (c === 120) return 2;
5678
+ if (c === 117) return 4;
5679
+ if (c === 85) return 8;
5680
+ return 0;
5681
+ }
5682
+ function isSimpleEscape(c) {
5683
+ return c === 48 || c === 97 || c === 98 || c === 116 || c === 9 || c === 110 || c === 118 || c === 102 || c === 114 || c === 101 || c === 32 || c === 34 || c === 47 || c === 92 || c === 78 || c === 95 || c === 76 || c === 80;
5684
+ }
5685
+ function consumeLineBreak(state) {
5686
+ if (state.input.charCodeAt(state.position) === 10) state.position++;
5687
+ else {
5688
+ state.position++;
5689
+ if (state.input.charCodeAt(state.position) === 10) state.position++;
5690
+ }
5691
+ state.line++;
5692
+ state.lineStart = state.position;
5693
+ state.lineIndent = 0;
5694
+ state.firstTabInLine = -1;
5695
+ }
5696
+ function skipSeparationSpace(state, allowComments) {
5697
+ let lineBreaks = 0;
5698
+ let ch = state.input.charCodeAt(state.position);
5699
+ let hasSeparation = state.position === state.lineStart || isWsOrEol(state.input.charCodeAt(state.position - 1));
5700
+ while (ch !== 0) {
5701
+ while (isWhiteSpace(ch)) {
5702
+ hasSeparation = true;
5703
+ if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
5761
5704
  ch = state.input.charCodeAt(++state.position);
5762
- } else tagHandle = "!";
5763
- let _position = state.position;
5764
- if (isVerbatim) {
5765
- do
5766
- ch = state.input.charCodeAt(++state.position);
5767
- while (ch !== 0 && ch !== 62);
5768
- if (state.position < state.length) {
5769
- tagName = state.input.slice(_position, state.position);
5770
- ch = state.input.charCodeAt(++state.position);
5771
- } else throwError(state, "unexpected end of the stream within a verbatim tag");
5772
- } else {
5773
- while (ch !== 0 && !isWsOrEol(ch)) {
5774
- if (ch === 33) if (!isNamed) {
5775
- tagHandle = state.input.slice(_position - 1, state.position + 1);
5776
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
5777
- isNamed = true;
5778
- _position = state.position + 1;
5779
- } else throwError(state, "tag suffix cannot contain exclamation marks");
5780
- ch = state.input.charCodeAt(++state.position);
5781
- }
5782
- tagName = state.input.slice(_position, state.position);
5783
- if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
5784
5705
  }
5785
- if (tagName && !PATTERN_TAG_URI.test(tagName)) throwError(state, "tag name cannot contain such characters: " + tagName);
5786
- try {
5787
- tagName = decodeURIComponent(tagName);
5788
- } catch (err) {
5789
- throwError(state, "tag name is malformed: " + tagName);
5706
+ if (allowComments && hasSeparation && ch === 35) do
5707
+ ch = state.input.charCodeAt(++state.position);
5708
+ while (!isEol(ch) && ch !== 0);
5709
+ if (!isEol(ch)) break;
5710
+ consumeLineBreak(state);
5711
+ lineBreaks++;
5712
+ hasSeparation = true;
5713
+ ch = state.input.charCodeAt(state.position);
5714
+ while (ch === 32) {
5715
+ state.lineIndent++;
5716
+ ch = state.input.charCodeAt(++state.position);
5790
5717
  }
5791
- if (isVerbatim) state.tag = tagName;
5792
- else if (_hasOwnProperty.call(state.tagMap, tagHandle)) state.tag = state.tagMap[tagHandle] + tagName;
5793
- else if (tagHandle === "!") state.tag = "!" + tagName;
5794
- else if (tagHandle === "!!") state.tag = "tag:yaml.org,2002:" + tagName;
5795
- else throwError(state, "undeclared tag handle \"" + tagHandle + "\"");
5796
- return true;
5797
5718
  }
5798
- function readAnchorProperty(state) {
5799
- let ch = state.input.charCodeAt(state.position);
5800
- if (ch !== 38) return false;
5801
- if (state.anchor !== null) throwError(state, "duplication of an anchor property");
5719
+ return lineBreaks;
5720
+ }
5721
+ function testDocumentSeparator(state, position = state.position) {
5722
+ const ch = state.input.charCodeAt(position);
5723
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(position + 1) && ch === state.input.charCodeAt(position + 2)) {
5724
+ const following = state.input.charCodeAt(position + 3);
5725
+ return following === 0 || isWsOrEol(following);
5726
+ }
5727
+ return false;
5728
+ }
5729
+ function skipUntilLineEnd(state) {
5730
+ let ch = state.input.charCodeAt(state.position);
5731
+ while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
5732
+ }
5733
+ function checkPrintable(state, start, end) {
5734
+ if (PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state, "the stream contains non-printable characters");
5735
+ }
5736
+ function readTagProperty(state, props, inFlow) {
5737
+ if (state.input.charCodeAt(state.position) !== 33) return false;
5738
+ if (props.tagStart !== NO_RANGE$1) throwError(state, "duplication of a tag property");
5739
+ const start = state.position;
5740
+ let isVerbatim = false;
5741
+ let isNamed = false;
5742
+ let tagHandle = "!";
5743
+ let ch = state.input.charCodeAt(++state.position);
5744
+ if (ch === 60) {
5745
+ isVerbatim = true;
5802
5746
  ch = state.input.charCodeAt(++state.position);
5803
- const _position = state.position;
5804
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
5805
- if (state.position === _position) throwError(state, "name of an anchor node must contain at least one character");
5806
- state.anchor = state.input.slice(_position, state.position);
5807
- return true;
5808
- }
5809
- function readAlias(state) {
5810
- let ch = state.input.charCodeAt(state.position);
5811
- if (ch !== 42) return false;
5747
+ } else if (ch === 33) {
5748
+ isNamed = true;
5749
+ tagHandle = "!!";
5812
5750
  ch = state.input.charCodeAt(++state.position);
5813
- const _position = state.position;
5814
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
5815
- if (state.position === _position) throwError(state, "name of an alias node must contain at least one character");
5816
- const alias = state.input.slice(_position, state.position);
5817
- if (!_hasOwnProperty.call(state.anchorMap, alias)) throwError(state, "unidentified alias \"" + alias + "\"");
5818
- state.result = state.anchorMap[alias];
5819
- skipSeparationSpace(state, true, -1);
5820
- return true;
5821
5751
  }
5822
- function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
5823
- const fallbackState = snapshotState(state);
5824
- beginAnchorTransaction(state);
5825
- restoreState(state, propertyStart);
5826
- state.tag = null;
5827
- state.anchor = null;
5828
- state.kind = null;
5829
- state.result = null;
5830
- if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
5831
- commitAnchorTransaction(state);
5832
- return true;
5752
+ let suffixStart = state.position;
5753
+ let tagName;
5754
+ if (isVerbatim) {
5755
+ while (ch !== 0 && ch !== 62) ch = state.input.charCodeAt(++state.position);
5756
+ if (ch !== 62) throwError(state, "unexpected end of the stream within a verbatim tag");
5757
+ tagName = state.input.slice(suffixStart, state.position);
5758
+ state.position++;
5759
+ } else {
5760
+ while (ch !== 0 && !isWsOrEol(ch) && !(inFlow && isFlowIndicator(ch))) {
5761
+ if (ch === 33) if (!isNamed) {
5762
+ tagHandle = state.input.slice(suffixStart - 1, state.position + 1);
5763
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
5764
+ isNamed = true;
5765
+ suffixStart = state.position + 1;
5766
+ } else throwError(state, "tag suffix cannot contain exclamation marks");
5767
+ ch = state.input.charCodeAt(++state.position);
5833
5768
  }
5834
- rollbackAnchorTransaction(state);
5835
- restoreState(state, fallbackState);
5836
- return false;
5837
- }
5838
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
5839
- let allowBlockScalars;
5840
- let allowBlockCollections;
5841
- let indentStatus = 1;
5842
- let atNewLine = false;
5843
- let hasContent = false;
5844
- let propertyStart = null;
5845
- let type;
5846
- let flowIndent;
5847
- let blockIndent;
5848
- if (state.depth >= state.maxDepth) throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
5849
- state.depth += 1;
5850
- if (state.listener !== null) state.listener("open", state);
5851
- state.tag = null;
5852
- state.anchor = null;
5853
- state.kind = null;
5854
- state.result = null;
5855
- const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
5856
- if (allowToSeek) {
5857
- if (skipSeparationSpace(state, true, -1)) {
5858
- atNewLine = true;
5859
- if (state.lineIndent > parentIndent) indentStatus = 1;
5860
- else if (state.lineIndent === parentIndent) indentStatus = 0;
5861
- else if (state.lineIndent < parentIndent) indentStatus = -1;
5769
+ tagName = state.input.slice(suffixStart, state.position);
5770
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
5771
+ }
5772
+ if (tagName && !(isVerbatim ? PATTERN_TAG_URI.test(tagName) : PATTERN_TAG_SUFFIX.test(tagName))) throwError(state, `tag name cannot contain such characters: ${tagName}`);
5773
+ if (!isVerbatim && tagHandle !== "!" && tagHandle !== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state, `undeclared tag handle "${tagHandle}"`);
5774
+ props.tagStart = start;
5775
+ props.tagEnd = state.position;
5776
+ return true;
5777
+ }
5778
+ function readAnchorProperty(state, props) {
5779
+ if (state.input.charCodeAt(state.position) !== 38) return false;
5780
+ if (props.anchorStart !== NO_RANGE$1) throwError(state, "duplication of an anchor property");
5781
+ state.position++;
5782
+ const start = state.position;
5783
+ while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
5784
+ if (state.position === start) throwError(state, "name of an anchor node must contain at least one character");
5785
+ props.anchorStart = start;
5786
+ props.anchorEnd = state.position;
5787
+ return true;
5788
+ }
5789
+ function readAlias(state, props) {
5790
+ if (state.input.charCodeAt(state.position) !== 42) return false;
5791
+ if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) throwError(state, "alias node should not have any properties");
5792
+ state.position++;
5793
+ const start = state.position;
5794
+ while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
5795
+ if (state.position === start) throwError(state, "name of an alias node must contain at least one character");
5796
+ addAliasEvent(state, start, state.position);
5797
+ return true;
5798
+ }
5799
+ function readFlowScalarBreak(state, nodeIndent) {
5800
+ skipSeparationSpace(state, false);
5801
+ if (state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
5802
+ }
5803
+ function readSingleQuotedScalar(state, nodeIndent, props) {
5804
+ if (state.input.charCodeAt(state.position) !== 39) return false;
5805
+ state.position++;
5806
+ const start = state.position;
5807
+ let simple = true;
5808
+ while (state.input.charCodeAt(state.position) !== 0) {
5809
+ const ch = state.input.charCodeAt(state.position);
5810
+ if (ch === 39) {
5811
+ if (state.input.charCodeAt(state.position + 1) === 39) {
5812
+ simple = false;
5813
+ state.position += 2;
5814
+ continue;
5862
5815
  }
5816
+ const end = state.position;
5817
+ state.position++;
5818
+ addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2, 1, -1, simple);
5819
+ return true;
5863
5820
  }
5864
- if (indentStatus === 1) while (true) {
5865
- const ch = state.input.charCodeAt(state.position);
5866
- const propertyState = snapshotState(state);
5867
- if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) break;
5868
- if (!readTagProperty(state) && !readAnchorProperty(state)) break;
5869
- if (propertyStart === null) propertyStart = propertyState;
5870
- if (skipSeparationSpace(state, true, -1)) {
5871
- atNewLine = true;
5872
- allowBlockCollections = allowBlockStyles;
5873
- if (state.lineIndent > parentIndent) indentStatus = 1;
5874
- else if (state.lineIndent === parentIndent) indentStatus = 0;
5875
- else if (state.lineIndent < parentIndent) indentStatus = -1;
5876
- } else allowBlockCollections = false;
5877
- }
5878
- if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
5879
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
5880
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) flowIndent = parentIndent;
5881
- else flowIndent = parentIndent + 1;
5882
- blockIndent = state.position - state.lineStart;
5883
- if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) hasContent = true;
5884
- else {
5885
- const ch = state.input.charCodeAt(state.position);
5886
- if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(state, propertyStart, propertyStart.position - propertyStart.lineStart, flowIndent)) hasContent = true;
5887
- else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) hasContent = true;
5888
- else if (readAlias(state)) {
5889
- hasContent = true;
5890
- if (state.tag !== null || state.anchor !== null) throwError(state, "alias node should not have any properties");
5891
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
5892
- hasContent = true;
5893
- if (state.tag === null) state.tag = "?";
5894
- }
5895
- if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
5896
- }
5897
- else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
5821
+ if (isEol(ch)) {
5822
+ simple = false;
5823
+ readFlowScalarBreak(state, nodeIndent);
5824
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
5825
+ else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
5826
+ else state.position++;
5827
+ }
5828
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
5829
+ }
5830
+ function readDoubleQuotedScalar(state, nodeIndent, props) {
5831
+ if (state.input.charCodeAt(state.position) !== 34) return false;
5832
+ state.position++;
5833
+ const start = state.position;
5834
+ let simple = true;
5835
+ while (state.input.charCodeAt(state.position) !== 0) {
5836
+ const ch = state.input.charCodeAt(state.position);
5837
+ if (ch === 34) {
5838
+ const end = state.position;
5839
+ state.position++;
5840
+ addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 3, 1, -1, simple);
5841
+ return true;
5898
5842
  }
5899
- if (state.tag === null) {
5900
- if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
5901
- } else if (state.tag === "?") {
5902
- if (state.result !== null && state.kind !== "scalar") throwError(state, "unacceptable node kind for !<?> tag; it should be \"scalar\", not \"" + state.kind + "\"");
5903
- for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
5904
- type = state.implicitTypes[typeIndex];
5905
- if (type.resolve(state.result)) {
5906
- state.result = type.construct(state.result);
5907
- state.tag = type.tag;
5908
- if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
5909
- break;
5910
- }
5911
- }
5912
- } else if (state.tag !== "!") {
5913
- if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) type = state.typeMap[state.kind || "fallback"][state.tag];
5843
+ if (ch === 92) {
5844
+ simple = false;
5845
+ const escaped = state.input.charCodeAt(++state.position);
5846
+ if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
5847
+ else if (isSimpleEscape(escaped)) state.position++;
5914
5848
  else {
5915
- type = null;
5916
- const typeList = state.typeMap.multi[state.kind || "fallback"];
5917
- for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
5918
- type = typeList[typeIndex];
5919
- break;
5849
+ let hexLength = escapedHexLen(escaped);
5850
+ if (hexLength === 0) throwError(state, "unknown escape sequence");
5851
+ while (hexLength-- > 0) {
5852
+ state.position++;
5853
+ if (fromHexCode(state.input.charCodeAt(state.position)) < 0) throwError(state, "expected hexadecimal character");
5920
5854
  }
5855
+ state.position++;
5921
5856
  }
5922
- if (!type) throwError(state, "unknown tag !<" + state.tag + ">");
5923
- 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 + "\"");
5924
- if (!type.resolve(state.result, state.tag)) throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
5925
- else {
5926
- state.result = type.construct(state.result, state.tag);
5927
- if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
5928
- }
5929
- }
5930
- if (state.listener !== null) state.listener("close", state);
5931
- state.depth -= 1;
5932
- return state.tag !== null || state.anchor !== null || hasContent;
5857
+ } else if (isEol(ch)) {
5858
+ simple = false;
5859
+ readFlowScalarBreak(state, nodeIndent);
5860
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
5861
+ else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
5862
+ else state.position++;
5863
+ }
5864
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
5865
+ }
5866
+ function readBlockScalar(state, parentIndent, props) {
5867
+ const ch = state.input.charCodeAt(state.position);
5868
+ let chomping = 1;
5869
+ let indent = -1;
5870
+ let detectedIndent = false;
5871
+ if (ch !== 124 && ch !== 62) return false;
5872
+ const style = ch === 124 ? 4 : 5;
5873
+ state.position++;
5874
+ while (state.input.charCodeAt(state.position) !== 0) {
5875
+ const current = state.input.charCodeAt(state.position);
5876
+ const digit = fromDecimalCode(current);
5877
+ if (current === 43 || current === 45) {
5878
+ if (chomping !== 1) throwError(state, "repeat of a chomping mode identifier");
5879
+ chomping = current === 43 ? 3 : 2;
5880
+ state.position++;
5881
+ } else if (digit >= 0) {
5882
+ if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
5883
+ if (detectedIndent) throwError(state, "repeat of an indentation width identifier");
5884
+ indent = parentIndent + digit - 1;
5885
+ detectedIndent = true;
5886
+ state.position++;
5887
+ } else break;
5933
5888
  }
5934
- function readDocument(state) {
5935
- const documentStart = state.position;
5936
- let hasDirectives = false;
5937
- let ch;
5938
- state.version = null;
5939
- state.checkLineBreaks = state.legacy;
5940
- state.tagMap = Object.create(null);
5941
- state.anchorMap = Object.create(null);
5942
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
5943
- skipSeparationSpace(state, true, -1);
5944
- ch = state.input.charCodeAt(state.position);
5945
- if (state.lineIndent > 0 || ch !== 37) break;
5946
- hasDirectives = true;
5947
- ch = state.input.charCodeAt(++state.position);
5948
- let _position = state.position;
5949
- while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
5950
- const directiveName = state.input.slice(_position, state.position);
5951
- const directiveArgs = [];
5952
- if (directiveName.length < 1) throwError(state, "directive name must not be less than one character in length");
5953
- while (ch !== 0) {
5954
- while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
5955
- if (ch === 35) {
5956
- do
5957
- ch = state.input.charCodeAt(++state.position);
5958
- while (ch !== 0 && !isEol(ch));
5959
- break;
5960
- }
5961
- if (isEol(ch)) break;
5962
- _position = state.position;
5963
- while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
5964
- directiveArgs.push(state.input.slice(_position, state.position));
5965
- }
5966
- if (ch !== 0) readLineBreak(state);
5967
- if (_hasOwnProperty.call(directiveHandlers, directiveName)) directiveHandlers[directiveName](state, directiveName, directiveArgs);
5968
- else throwWarning(state, "unknown document directive \"" + directiveName + "\"");
5889
+ let hadWhitespace = false;
5890
+ while (isWhiteSpace(state.input.charCodeAt(state.position))) {
5891
+ hadWhitespace = true;
5892
+ state.position++;
5893
+ }
5894
+ if (hadWhitespace && state.input.charCodeAt(state.position) === 35) skipUntilLineEnd(state);
5895
+ if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
5896
+ else if (state.input.charCodeAt(state.position) !== 0) throwError(state, "a line break is expected");
5897
+ let contentIndent = detectedIndent ? indent : -1;
5898
+ let maxLeadingIndent = 0;
5899
+ const valueStart = state.position;
5900
+ let valueEnd = state.position;
5901
+ while (state.input.charCodeAt(state.position) !== 0) {
5902
+ const linePosition = state.position;
5903
+ let column = 0;
5904
+ while (state.input.charCodeAt(linePosition + column) === 32) column++;
5905
+ const first = state.input.charCodeAt(linePosition + column);
5906
+ if (first === 0) {
5907
+ if (contentIndent >= 0) {
5908
+ if (column > contentIndent) valueEnd = linePosition + column;
5909
+ } else if (column > 0) valueEnd = linePosition + column;
5910
+ break;
5969
5911
  }
5970
- skipSeparationSpace(state, true, -1);
5971
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
5972
- state.position += 3;
5973
- skipSeparationSpace(state, true, -1);
5974
- } else if (hasDirectives) throwError(state, "directives end mark is expected");
5975
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
5976
- skipSeparationSpace(state, true, -1);
5977
- 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");
5978
- state.documents.push(state.result);
5979
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
5980
- if (state.input.charCodeAt(state.position) === 46) {
5981
- state.position += 3;
5982
- skipSeparationSpace(state, true, -1);
5912
+ if (linePosition === state.lineStart && testDocumentSeparator(state, linePosition)) break;
5913
+ if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
5914
+ if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
5915
+ if (first === 9 && column < parentIndent) {
5916
+ state.position = linePosition + column;
5917
+ throwError(state, "tab characters must not be used in indentation");
5918
+ }
5919
+ if (column < maxLeadingIndent) {
5920
+ state.position = linePosition + column;
5921
+ throwError(state, "bad indentation of a mapping entry");
5983
5922
  }
5984
- return;
5985
- }
5986
- if (state.position < state.length - 1) throwError(state, "end of the stream or a document separator is expected");
5987
- }
5988
- function loadDocuments(input, options) {
5989
- input = String(input);
5990
- options = options || {};
5991
- if (input.length !== 0) {
5992
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) input += "\n";
5993
- if (input.charCodeAt(0) === 65279) input = input.slice(1);
5994
- }
5995
- const state = new State(input, options);
5996
- const nullpos = input.indexOf("\0");
5997
- if (nullpos !== -1) {
5998
- state.position = nullpos;
5999
- throwError(state, "null byte is not allowed in input");
6000
5923
  }
6001
- state.input += "\0";
6002
- while (state.input.charCodeAt(state.position) === 32) {
6003
- state.lineIndent += 1;
6004
- state.position += 1;
5924
+ if (contentIndent === -1 && first !== 0 && !isEol(first) && column < parentIndent) {
5925
+ state.lineIndent = column;
5926
+ state.position = linePosition + column;
5927
+ break;
6005
5928
  }
6006
- while (state.position < state.length - 1) readDocument(state);
6007
- return state.documents;
6008
- }
6009
- function loadAll(input, iterator, options) {
6010
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
6011
- options = iterator;
6012
- iterator = null;
5929
+ if (!detectedIndent && first !== 0 && !isEol(first) && contentIndent === -1) contentIndent = column;
5930
+ const requiredIndent = contentIndent === -1 ? parentIndent + 1 : contentIndent;
5931
+ if (first !== 0 && !isEol(first) && column < requiredIndent) {
5932
+ state.lineIndent = column;
5933
+ state.position = linePosition + column;
5934
+ break;
6013
5935
  }
6014
- const documents = loadDocuments(input, options);
6015
- if (typeof iterator !== "function") return documents;
6016
- for (let index = 0, length = documents.length; index < length; index += 1) iterator(documents[index]);
6017
- }
6018
- function load(input, options) {
6019
- const documents = loadDocuments(input, options);
6020
- if (documents.length === 0) return;
6021
- else if (documents.length === 1) return documents[0];
6022
- throw new YAMLException("expected a single document in the stream, but found more");
6023
- }
6024
- module.exports.loadAll = loadAll;
6025
- module.exports.load = load;
6026
- }));
6027
- //#endregion
6028
- //#region lib/dumper.js
6029
- var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6030
- var common = require_common();
6031
- var YAMLException = require_exception();
6032
- var DEFAULT_SCHEMA = require_default();
6033
- var _toString = Object.prototype.toString;
6034
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
6035
- var CHAR_BOM = 65279;
6036
- var CHAR_TAB = 9;
6037
- var CHAR_LINE_FEED = 10;
6038
- var CHAR_CARRIAGE_RETURN = 13;
6039
- var CHAR_SPACE = 32;
6040
- var CHAR_EXCLAMATION = 33;
6041
- var CHAR_DOUBLE_QUOTE = 34;
6042
- var CHAR_SHARP = 35;
6043
- var CHAR_PERCENT = 37;
6044
- var CHAR_AMPERSAND = 38;
6045
- var CHAR_SINGLE_QUOTE = 39;
6046
- var CHAR_ASTERISK = 42;
6047
- var CHAR_COMMA = 44;
6048
- var CHAR_MINUS = 45;
6049
- var CHAR_COLON = 58;
6050
- var CHAR_EQUALS = 61;
6051
- var CHAR_GREATER_THAN = 62;
6052
- var CHAR_QUESTION = 63;
6053
- var CHAR_COMMERCIAL_AT = 64;
6054
- var CHAR_LEFT_SQUARE_BRACKET = 91;
6055
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
6056
- var CHAR_GRAVE_ACCENT = 96;
6057
- var CHAR_LEFT_CURLY_BRACKET = 123;
6058
- var CHAR_VERTICAL_LINE = 124;
6059
- var CHAR_RIGHT_CURLY_BRACKET = 125;
6060
- var ESCAPE_SEQUENCES = {};
6061
- ESCAPE_SEQUENCES[0] = "\\0";
6062
- ESCAPE_SEQUENCES[7] = "\\a";
6063
- ESCAPE_SEQUENCES[8] = "\\b";
6064
- ESCAPE_SEQUENCES[9] = "\\t";
6065
- ESCAPE_SEQUENCES[10] = "\\n";
6066
- ESCAPE_SEQUENCES[11] = "\\v";
6067
- ESCAPE_SEQUENCES[12] = "\\f";
6068
- ESCAPE_SEQUENCES[13] = "\\r";
6069
- ESCAPE_SEQUENCES[27] = "\\e";
6070
- ESCAPE_SEQUENCES[34] = "\\\"";
6071
- ESCAPE_SEQUENCES[92] = "\\\\";
6072
- ESCAPE_SEQUENCES[133] = "\\N";
6073
- ESCAPE_SEQUENCES[160] = "\\_";
6074
- ESCAPE_SEQUENCES[8232] = "\\L";
6075
- ESCAPE_SEQUENCES[8233] = "\\P";
6076
- var DEPRECATED_BOOLEANS_SYNTAX = [
6077
- "y",
6078
- "Y",
6079
- "yes",
6080
- "Yes",
6081
- "YES",
6082
- "on",
6083
- "On",
6084
- "ON",
6085
- "n",
6086
- "N",
6087
- "no",
6088
- "No",
6089
- "NO",
6090
- "off",
6091
- "Off",
6092
- "OFF"
6093
- ];
6094
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
6095
- function compileStyleMap(schema, map) {
6096
- if (map === null) return {};
6097
- const result = {};
6098
- const keys = Object.keys(map);
6099
- for (let index = 0, length = keys.length; index < length; index += 1) {
6100
- let tag = keys[index];
6101
- let style = String(map[tag]);
6102
- if (tag.slice(0, 2) === "!!") tag = "tag:yaml.org,2002:" + tag.slice(2);
6103
- const type = schema.compiledTypeMap["fallback"][tag];
6104
- if (type && _hasOwnProperty.call(type.styleAliases, style)) style = type.styleAliases[style];
6105
- result[tag] = style;
5936
+ skipUntilLineEnd(state);
5937
+ valueEnd = state.position;
5938
+ if (isEol(state.input.charCodeAt(state.position))) {
5939
+ consumeLineBreak(state);
5940
+ valueEnd = state.position;
6106
5941
  }
6107
- return result;
6108
5942
  }
6109
- function encodeHex(character) {
6110
- let handle;
6111
- let length;
6112
- const string = character.toString(16).toUpperCase();
6113
- if (character <= 255) {
6114
- handle = "x";
6115
- length = 2;
6116
- } else if (character <= 65535) {
6117
- handle = "u";
6118
- length = 4;
6119
- } else if (character <= 4294967295) {
6120
- handle = "U";
6121
- length = 8;
6122
- } else throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
6123
- return "\\" + handle + common.repeat("0", length - string.length) + string;
6124
- }
6125
- var QUOTING_TYPE_SINGLE = 1;
6126
- var QUOTING_TYPE_DOUBLE = 2;
6127
- function State(options) {
6128
- this.schema = options["schema"] || DEFAULT_SCHEMA;
6129
- this.indent = Math.max(1, options["indent"] || 2);
6130
- this.noArrayIndent = options["noArrayIndent"] || false;
6131
- this.skipInvalid = options["skipInvalid"] || false;
6132
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
6133
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
6134
- this.sortKeys = options["sortKeys"] || false;
6135
- this.lineWidth = options["lineWidth"] || 80;
6136
- this.noRefs = options["noRefs"] || false;
6137
- this.noCompatMode = options["noCompatMode"] || false;
6138
- this.condenseFlow = options["condenseFlow"] || false;
6139
- this.quotingType = options["quotingType"] === "\"" ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
6140
- this.forceQuotes = options["forceQuotes"] || false;
6141
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
6142
- this.implicitTypes = this.schema.compiledImplicit;
6143
- this.explicitTypes = this.schema.compiledExplicit;
6144
- this.tag = null;
6145
- this.result = "";
6146
- this.duplicates = [];
6147
- this.usedDuplicates = null;
6148
- }
6149
- function indentString(string, spaces) {
6150
- const ind = common.repeat(" ", spaces);
6151
- let position = 0;
6152
- let result = "";
6153
- const length = string.length;
6154
- while (position < length) {
6155
- let line;
6156
- const next = string.indexOf("\n", position);
6157
- if (next === -1) {
6158
- line = string.slice(position);
6159
- position = length;
6160
- } else {
6161
- line = string.slice(position, next + 1);
6162
- position = next + 1;
5943
+ checkPrintable(state, valueStart, valueEnd);
5944
+ addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
5945
+ return true;
5946
+ }
5947
+ function canStartPlainScalar(state, nodeContext) {
5948
+ const ch = state.input.charCodeAt(state.position);
5949
+ const inFlow = nodeContext === CONTEXT_FLOW_IN;
5950
+ if (ch === 0 || isWsOrEol(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96 || inFlow && isFlowIndicator(ch)) return false;
5951
+ if (ch === 63 || ch === 45) {
5952
+ const following = state.input.charCodeAt(state.position + 1);
5953
+ if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) return false;
5954
+ }
5955
+ return true;
5956
+ }
5957
+ function readPlainScalar(state, nodeIndent, nodeContext, props) {
5958
+ if (!canStartPlainScalar(state, nodeContext)) return false;
5959
+ const start = state.position;
5960
+ let end = state.position;
5961
+ let ch = state.input.charCodeAt(state.position);
5962
+ const inFlow = nodeContext === CONTEXT_FLOW_IN;
5963
+ let multiline = false;
5964
+ while (ch !== 0) {
5965
+ if (state.position === state.lineStart && testDocumentSeparator(state)) break;
5966
+ if (ch === 58) {
5967
+ const following = state.input.charCodeAt(state.position + 1);
5968
+ if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
5969
+ } else if (ch === 35) {
5970
+ if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
5971
+ } else if (inFlow && isFlowIndicator(ch)) break;
5972
+ else if (isEol(ch)) {
5973
+ const savedPosition = state.position;
5974
+ const savedLine = state.line;
5975
+ const savedLineStart = state.lineStart;
5976
+ const savedLineIndent = state.lineIndent;
5977
+ skipSeparationSpace(state, false);
5978
+ if (state.lineIndent >= nodeIndent) {
5979
+ multiline = true;
5980
+ ch = state.input.charCodeAt(state.position);
5981
+ continue;
6163
5982
  }
6164
- if (line.length && line !== "\n") result += ind;
6165
- result += line;
5983
+ state.position = savedPosition;
5984
+ state.line = savedLine;
5985
+ state.lineStart = savedLineStart;
5986
+ state.lineIndent = savedLineIndent;
5987
+ break;
6166
5988
  }
6167
- return result;
6168
- }
6169
- function generateNextLine(state, level) {
6170
- return "\n" + common.repeat(" ", state.indent * level);
6171
- }
6172
- function testImplicitResolving(state, str) {
6173
- for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) if (state.implicitTypes[index].resolve(str)) return true;
6174
- return false;
6175
- }
6176
- function isWhitespace(c) {
6177
- return c === CHAR_SPACE || c === CHAR_TAB;
6178
- }
6179
- function isPrintable(c) {
6180
- return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
6181
- }
6182
- function isNsCharOrWhitespace(c) {
6183
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
6184
- }
6185
- function isPlainSafe(c, prev, inblock) {
6186
- const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
6187
- const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
6188
- 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;
6189
- }
6190
- function isPlainSafeFirst(c) {
6191
- 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;
6192
- }
6193
- function isPlainSafeLast(c) {
6194
- return !isWhitespace(c) && c !== CHAR_COLON;
5989
+ if (!isWhiteSpace(ch)) end = state.position + 1;
5990
+ ch = state.input.charCodeAt(++state.position);
6195
5991
  }
6196
- function codePointAt(string, pos) {
6197
- const first = string.charCodeAt(pos);
6198
- let second;
6199
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
6200
- second = string.charCodeAt(pos + 1);
6201
- if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
6202
- }
6203
- return first;
6204
- }
6205
- function needIndentIndicator(string) {
6206
- return /^\n* /.test(string);
6207
- }
6208
- var STYLE_PLAIN = 1;
6209
- var STYLE_SINGLE = 2;
6210
- var STYLE_LITERAL = 3;
6211
- var STYLE_FOLDED = 4;
6212
- var STYLE_DOUBLE = 5;
6213
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
6214
- let i;
6215
- let char = 0;
6216
- let prevChar = null;
6217
- let hasLineBreak = false;
6218
- let hasFoldableLine = false;
6219
- const shouldTrackWidth = lineWidth !== -1;
6220
- let previousLineBreak = -1;
6221
- let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
6222
- if (singleLineOnly || forceQuotes) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6223
- char = codePointAt(string, i);
6224
- if (!isPrintable(char)) return STYLE_DOUBLE;
6225
- plain = plain && isPlainSafe(char, prevChar, inblock);
6226
- prevChar = char;
6227
- }
6228
- else {
6229
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6230
- char = codePointAt(string, i);
6231
- if (char === CHAR_LINE_FEED) {
6232
- hasLineBreak = true;
6233
- if (shouldTrackWidth) {
6234
- hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
6235
- previousLineBreak = i;
6236
- }
6237
- } else if (!isPrintable(char)) return STYLE_DOUBLE;
6238
- plain = plain && isPlainSafe(char, prevChar, inblock);
6239
- prevChar = char;
6240
- }
6241
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
6242
- }
6243
- if (!hasLineBreak && !hasFoldableLine) {
6244
- if (plain && !forceQuotes && !testAmbiguousType(string)) return STYLE_PLAIN;
6245
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
5992
+ if (end === start) return false;
5993
+ checkPrintable(state, start, end);
5994
+ addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1, 1, -1, !multiline);
5995
+ return true;
5996
+ }
5997
+ function skipFlowSeparationSpace(state, nodeIndent) {
5998
+ const startLine = state.line;
5999
+ skipSeparationSpace(state, true);
6000
+ if (state.line > startLine && state.lineIndent < nodeIndent || state.firstTabInLine !== -1 && state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
6001
+ }
6002
+ function readFlowCollection(state, nodeIndent, props) {
6003
+ const ch = state.input.charCodeAt(state.position);
6004
+ const isMapping = ch === 123;
6005
+ const start = state.position;
6006
+ let readNext = true;
6007
+ if (ch !== 91 && ch !== 123) return false;
6008
+ const terminator = isMapping ? 125 : 93;
6009
+ if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
6010
+ else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 2);
6011
+ state.position++;
6012
+ while (state.input.charCodeAt(state.position) !== 0) {
6013
+ skipFlowSeparationSpace(state, nodeIndent);
6014
+ let ch = state.input.charCodeAt(state.position);
6015
+ if (ch === terminator) {
6016
+ state.position++;
6017
+ addPopEvent(state);
6018
+ return true;
6019
+ } else if (!readNext) throwError(state, "missed comma between flow collection entries");
6020
+ else if (ch === 44) throwError(state, "expected the node content, but found ','");
6021
+ let isPair = false;
6022
+ let isExplicitPair = false;
6023
+ if (ch === 63 && isWsOrEol(state.input.charCodeAt(state.position + 1))) {
6024
+ isPair = isExplicitPair = true;
6025
+ state.position += 1;
6026
+ skipFlowSeparationSpace(state, nodeIndent);
6246
6027
  }
6247
- if (indentPerLevel > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
6248
- if (!forceQuotes) return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
6249
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
6250
- }
6251
- function writeScalar(state, string, level, iskey, inblock) {
6252
- state.dump = function() {
6253
- if (string.length === 0) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"\"" : "''";
6254
- if (!state.noCompatMode) {
6255
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"" + string + "\"" : "'" + string + "'";
6256
- }
6257
- const indent = state.indent * Math.max(1, level);
6258
- const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
6259
- const singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
6260
- function testAmbiguity(string) {
6261
- return testImplicitResolving(state, string);
6262
- }
6263
- switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
6264
- case STYLE_PLAIN: return string;
6265
- case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'";
6266
- case STYLE_LITERAL: return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
6267
- case STYLE_FOLDED: return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
6268
- case STYLE_DOUBLE: return "\"" + escapeString(string) + "\"";
6269
- default: throw new YAMLException("impossible error: invalid scalar style");
6270
- }
6271
- }();
6272
- }
6273
- function blockHeader(string, indentPerLevel) {
6274
- const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
6275
- const clip = string[string.length - 1] === "\n";
6276
- return indentIndicator + (clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-") + "\n";
6277
- }
6278
- function dropEndingNewline(string) {
6279
- return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
6280
- }
6281
- function foldString(string, width) {
6282
- const lineRe = /(\n+)([^\n]*)/g;
6283
- let result = function() {
6284
- let nextLF = string.indexOf("\n");
6285
- nextLF = nextLF !== -1 ? nextLF : string.length;
6286
- lineRe.lastIndex = nextLF;
6287
- return foldLine(string.slice(0, nextLF), width);
6288
- }();
6289
- let prevMoreIndented = string[0] === "\n" || string[0] === " ";
6290
- let moreIndented;
6291
- let match;
6292
- while (match = lineRe.exec(string)) {
6293
- const prefix = match[1];
6294
- const line = match[2];
6295
- moreIndented = line[0] === " ";
6296
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
6297
- prevMoreIndented = moreIndented;
6028
+ const entryLine = state.line;
6029
+ const entryStart = snapshotState(state);
6030
+ const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
6031
+ skipFlowSeparationSpace(state, nodeIndent);
6032
+ ch = state.input.charCodeAt(state.position);
6033
+ if ((isMapping || isExplicitPair || state.line === entryLine) && ch === 58) {
6034
+ isPair = true;
6035
+ state.position++;
6036
+ skipFlowSeparationSpace(state, nodeIndent);
6037
+ if (!isMapping) {
6038
+ restoreState(state, entryStart);
6039
+ addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
6040
+ if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
6041
+ skipFlowSeparationSpace(state, nodeIndent);
6042
+ state.position++;
6043
+ skipFlowSeparationSpace(state, nodeIndent);
6044
+ } else if (!keyWasRead) addEmptyScalarEvent(state);
6045
+ if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
6046
+ skipFlowSeparationSpace(state, nodeIndent);
6047
+ if (!isMapping) addPopEvent(state);
6048
+ } else if (isMapping && isPair) {
6049
+ if (!keyWasRead) addEmptyScalarEvent(state);
6050
+ addEmptyScalarEvent(state);
6051
+ } else if (isMapping) addEmptyScalarEvent(state);
6052
+ else if (isPair) {
6053
+ restoreState(state, entryStart);
6054
+ addMappingEvent(state, entryStart.position, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, 2);
6055
+ parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
6056
+ addEmptyScalarEvent(state);
6057
+ addPopEvent(state);
6298
6058
  }
6299
- return result;
6059
+ ch = state.input.charCodeAt(state.position);
6060
+ if (ch === 44) {
6061
+ readNext = true;
6062
+ state.position++;
6063
+ } else readNext = false;
6300
6064
  }
6301
- function foldLine(line, width) {
6302
- if (line === "" || line[0] === " ") return line;
6303
- const breakRe = / [^ ]/g;
6304
- let match;
6305
- let start = 0;
6306
- let end;
6307
- let curr = 0;
6308
- let next = 0;
6309
- let result = "";
6310
- while (match = breakRe.exec(line)) {
6311
- next = match.index;
6312
- if (next - start > width) {
6313
- end = curr > start ? curr : next;
6314
- result += "\n" + line.slice(start, end);
6315
- start = end + 1;
6316
- }
6317
- curr = next;
6065
+ throwError(state, "unexpected end of the stream within a flow collection");
6066
+ }
6067
+ function readBlockSequence(state, nodeIndent, props) {
6068
+ if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
6069
+ addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
6070
+ while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
6071
+ if (state.firstTabInLine !== -1) {
6072
+ state.position = state.firstTabInLine;
6073
+ throwError(state, "tab characters must not be used in indentation");
6318
6074
  }
6319
- result += "\n";
6320
- if (line.length - start > width && curr > start) result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
6321
- else result += line.slice(start);
6322
- return result.slice(1);
6323
- }
6324
- function escapeString(string) {
6325
- let result = "";
6326
- let char = 0;
6327
- for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
6328
- char = codePointAt(string, i);
6329
- const escapeSeq = ESCAPE_SEQUENCES[char];
6330
- if (!escapeSeq && isPrintable(char)) {
6331
- result += string[i];
6332
- if (char >= 65536) result += string[i + 1];
6333
- } else result += escapeSeq || encodeHex(char);
6075
+ const entryLine = state.line;
6076
+ state.position++;
6077
+ const hadBreak = skipSeparationSpace(state, true) > 0;
6078
+ if (state.firstTabInLine !== -1 && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
6079
+ if (hadBreak && state.lineIndent <= nodeIndent) addEmptyScalarEvent(state);
6080
+ else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
6081
+ skipSeparationSpace(state, true);
6082
+ if (state.lineIndent < nodeIndent || state.position >= state.length) break;
6083
+ if (state.lineIndent > nodeIndent) throwError(state, "bad indentation of a sequence entry");
6084
+ if (state.line === entryLine && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
6085
+ }
6086
+ addPopEvent(state);
6087
+ return true;
6088
+ }
6089
+ function readBlockMapping(state, nodeIndent, flowIndent, props) {
6090
+ let atExplicitKey = false;
6091
+ let detected = false;
6092
+ let mappingOpened = false;
6093
+ let pendingExplicitKey = false;
6094
+ if (state.firstTabInLine !== -1) return false;
6095
+ let ch = state.input.charCodeAt(state.position);
6096
+ while (ch !== 0) {
6097
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
6098
+ state.position = state.firstTabInLine;
6099
+ throwError(state, "tab characters must not be used in indentation");
6334
6100
  }
6335
- return result;
6336
- }
6337
- function writeFlowSequence(state, level, object) {
6338
- let _result = "";
6339
- const _tag = state.tag;
6340
- for (let index = 0, length = object.length; index < length; index += 1) {
6341
- let value = object[index];
6342
- if (state.replacer) value = state.replacer.call(object, String(index), value);
6343
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
6344
- if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
6345
- _result += state.dump;
6101
+ const following = state.input.charCodeAt(state.position + 1);
6102
+ const entryLine = state.line;
6103
+ if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
6104
+ if (!mappingOpened) {
6105
+ addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
6106
+ mappingOpened = true;
6346
6107
  }
6347
- }
6348
- state.tag = _tag;
6349
- state.dump = "[" + _result + "]";
6350
- }
6351
- function writeBlockSequence(state, level, object, compact) {
6352
- let _result = "";
6353
- const _tag = state.tag;
6354
- for (let index = 0, length = object.length; index < length; index += 1) {
6355
- let value = object[index];
6356
- if (state.replacer) value = state.replacer.call(object, String(index), value);
6357
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
6358
- if (!compact || _result !== "") _result += generateNextLine(state, level);
6359
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
6360
- else _result += "- ";
6361
- _result += state.dump;
6108
+ if (ch === 63) {
6109
+ if (atExplicitKey) addEmptyScalarEvent(state);
6110
+ detected = true;
6111
+ atExplicitKey = true;
6112
+ } else if (atExplicitKey) atExplicitKey = false;
6113
+ else {
6114
+ addEmptyScalarEvent(state);
6115
+ detected = true;
6116
+ atExplicitKey = false;
6362
6117
  }
6363
- }
6364
- state.tag = _tag;
6365
- state.dump = _result || "[]";
6366
- }
6367
- function writeFlowMapping(state, level, object) {
6368
- let _result = "";
6369
- const _tag = state.tag;
6370
- const objectKeyList = Object.keys(object);
6371
- for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
6372
- let pairBuffer = "";
6373
- if (_result !== "") pairBuffer += ", ";
6374
- if (state.condenseFlow) pairBuffer += "\"";
6375
- const objectKey = objectKeyList[index];
6376
- let objectValue = object[objectKey];
6377
- if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
6378
- if (!writeNode(state, level, objectKey, false, false)) continue;
6379
- if (state.dump.length > 1024) pairBuffer += "? ";
6380
- pairBuffer += state.dump + (state.condenseFlow ? "\"" : "") + ":" + (state.condenseFlow ? "" : " ");
6381
- if (!writeNode(state, level, objectValue, false, false)) continue;
6382
- pairBuffer += state.dump;
6383
- _result += pairBuffer;
6384
- }
6385
- state.tag = _tag;
6386
- state.dump = "{" + _result + "}";
6387
- }
6388
- function writeBlockMapping(state, level, object, compact) {
6389
- let _result = "";
6390
- const _tag = state.tag;
6391
- const objectKeyList = Object.keys(object);
6392
- if (state.sortKeys === true) objectKeyList.sort();
6393
- else if (typeof state.sortKeys === "function") objectKeyList.sort(state.sortKeys);
6394
- else if (state.sortKeys) throw new YAMLException("sortKeys must be a boolean or a function");
6395
- for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
6396
- let pairBuffer = "";
6397
- if (!compact || _result !== "") pairBuffer += generateNextLine(state, level);
6398
- const objectKey = objectKeyList[index];
6399
- let objectValue = object[objectKey];
6400
- if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
6401
- if (!writeNode(state, level + 1, objectKey, true, true, true)) continue;
6402
- const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
6403
- if (explicitPair) if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += "?";
6404
- else pairBuffer += "? ";
6405
- pairBuffer += state.dump;
6406
- if (explicitPair) pairBuffer += generateNextLine(state, level);
6407
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) continue;
6408
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += ":";
6409
- else pairBuffer += ": ";
6410
- pairBuffer += state.dump;
6411
- _result += pairBuffer;
6412
- }
6413
- state.tag = _tag;
6414
- state.dump = _result || "{}";
6415
- }
6416
- function detectType(state, object, explicit) {
6417
- const typeList = explicit ? state.explicitTypes : state.implicitTypes;
6418
- for (let index = 0, length = typeList.length; index < length; index += 1) {
6419
- const type = typeList[index];
6420
- if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
6421
- if (explicit) if (type.multi && type.representName) state.tag = type.representName(object);
6422
- else state.tag = type.tag;
6423
- else state.tag = "?";
6424
- if (type.represent) {
6425
- const style = state.styleMap[type.tag] || type.defaultStyle;
6426
- let _result;
6427
- if (_toString.call(type.represent) === "[object Function]") _result = type.represent(object, style);
6428
- else if (_hasOwnProperty.call(type.represent, style)) _result = type.represent[style](object, style);
6429
- else throw new YAMLException("!<" + type.tag + "> tag resolver accepts not \"" + style + "\" style");
6430
- state.dump = _result;
6118
+ state.position += 1;
6119
+ pendingExplicitKey = true;
6120
+ } else {
6121
+ if (atExplicitKey) {
6122
+ addEmptyScalarEvent(state);
6123
+ atExplicitKey = false;
6124
+ }
6125
+ const beforeKey = snapshotState(state);
6126
+ if (!parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
6127
+ if (state.line === entryLine) {
6128
+ ch = state.input.charCodeAt(state.position);
6129
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
6130
+ if (ch === 58) {
6131
+ ch = state.input.charCodeAt(++state.position);
6132
+ if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
6133
+ if (!mappingOpened) {
6134
+ restoreState(state, beforeKey);
6135
+ addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
6136
+ mappingOpened = true;
6137
+ parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
6138
+ ch = state.input.charCodeAt(state.position);
6139
+ while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
6140
+ state.position++;
6141
+ }
6142
+ detected = true;
6143
+ atExplicitKey = false;
6144
+ pendingExplicitKey = false;
6145
+ } else if (detected) throwError(state, "expected ':' after a mapping key");
6146
+ else {
6147
+ if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
6148
+ restoreState(state, beforeKey);
6149
+ return false;
6150
+ }
6151
+ return true;
6152
+ }
6153
+ } else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
6154
+ else {
6155
+ if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
6156
+ restoreState(state, beforeKey);
6157
+ return false;
6431
6158
  }
6432
6159
  return true;
6433
6160
  }
6434
6161
  }
6162
+ if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, pendingExplicitKey)) pendingExplicitKey = false;
6163
+ if (!atExplicitKey) {
6164
+ if (pendingExplicitKey) {
6165
+ addEmptyScalarEvent(state);
6166
+ pendingExplicitKey = false;
6167
+ }
6168
+ }
6169
+ skipSeparationSpace(state, true);
6170
+ ch = state.input.charCodeAt(state.position);
6171
+ if ((state.line === entryLine || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
6172
+ else if (state.lineIndent < nodeIndent) break;
6173
+ }
6174
+ if (!detected) return false;
6175
+ if (atExplicitKey) addEmptyScalarEvent(state);
6176
+ if (mappingOpened) addPopEvent(state);
6177
+ return true;
6178
+ }
6179
+ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping = true) {
6180
+ if (state.depth >= state.maxDepth) throwError(state, `nesting exceeded maxDepth (${state.maxDepth})`);
6181
+ state.depth++;
6182
+ let indentStatus = 1;
6183
+ let atNewLine = false;
6184
+ let hasContent = false;
6185
+ let propertyStart = null;
6186
+ const props = emptyProperties();
6187
+ let allowBlockScalars = nodeContext === CONTEXT_BLOCK_OUT || nodeContext === CONTEXT_BLOCK_IN;
6188
+ let allowBlockCollections = allowBlockScalars;
6189
+ const allowBlockStyles = allowBlockScalars;
6190
+ if (allowToSeek && skipSeparationSpace(state, true)) {
6191
+ atNewLine = true;
6192
+ if (state.lineIndent > parentIndent) indentStatus = 1;
6193
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
6194
+ else indentStatus = -1;
6195
+ }
6196
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
6197
+ state.depth--;
6435
6198
  return false;
6436
6199
  }
6437
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
6438
- state.tag = null;
6439
- state.dump = object;
6440
- if (!detectType(state, object, false)) detectType(state, object, true);
6441
- const type = _toString.call(state.dump);
6442
- const inblock = block;
6443
- if (block) block = state.flowLevel < 0 || state.flowLevel > level;
6444
- const objectOrArray = type === "[object Object]" || type === "[object Array]";
6445
- let duplicateIndex;
6446
- let duplicate;
6447
- if (objectOrArray) {
6448
- duplicateIndex = state.duplicates.indexOf(object);
6449
- duplicate = duplicateIndex !== -1;
6200
+ if (indentStatus === 1) while (true) {
6201
+ const ch = state.input.charCodeAt(state.position);
6202
+ const propertyState = snapshotState(state);
6203
+ if (atNewLine && indentStatus !== 1 && (ch === 33 || ch === 38)) break;
6204
+ if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
6205
+ const fallbackState = snapshotState(state);
6206
+ const flowIndent = parentIndent + 1;
6207
+ if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === 3) {
6208
+ state.depth--;
6209
+ return true;
6210
+ }
6211
+ restoreState(state, fallbackState);
6450
6212
  }
6451
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) compact = false;
6452
- if (duplicate && state.usedDuplicates[duplicateIndex]) state.dump = "*ref_" + duplicateIndex;
6213
+ if (atNewLine && (ch === 33 && props.tagStart !== NO_RANGE$1 || ch === 38 && props.anchorStart !== NO_RANGE$1)) break;
6214
+ if (!readTagProperty(state, props, nodeContext === CONTEXT_FLOW_IN) && !readAnchorProperty(state, props)) break;
6215
+ if (propertyStart === null) propertyStart = propertyState;
6216
+ if (skipSeparationSpace(state, true)) {
6217
+ atNewLine = true;
6218
+ allowBlockCollections = allowBlockStyles;
6219
+ if (state.lineIndent > parentIndent) indentStatus = 1;
6220
+ else if (state.lineIndent === parentIndent) indentStatus = 0;
6221
+ else indentStatus = -1;
6222
+ } else allowBlockCollections = false;
6223
+ }
6224
+ if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
6225
+ if (indentStatus === 1 || nodeContext === CONTEXT_BLOCK_OUT) {
6226
+ const flowIndent = nodeContext === CONTEXT_FLOW_IN || nodeContext === CONTEXT_FLOW_OUT ? parentIndent : parentIndent + 1;
6227
+ const blockIndent = state.position - state.lineStart;
6228
+ if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent, props) || readBlockMapping(state, blockIndent, flowIndent, props)) || readFlowCollection(state, flowIndent, props)) hasContent = true;
6453
6229
  else {
6454
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) state.usedDuplicates[duplicateIndex] = true;
6455
- if (type === "[object Object]") if (block && Object.keys(state.dump).length !== 0) {
6456
- writeBlockMapping(state, level, state.dump, compact);
6457
- if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
6458
- } else {
6459
- writeFlowMapping(state, level, state.dump);
6460
- if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
6461
- }
6462
- else if (type === "[object Array]") if (block && state.dump.length !== 0) {
6463
- if (state.noArrayIndent && !isblockseq && level > 0) writeBlockSequence(state, level - 1, state.dump, compact);
6464
- else writeBlockSequence(state, level, state.dump, compact);
6465
- if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
6466
- } else {
6467
- writeFlowSequence(state, level, state.dump);
6468
- if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
6469
- }
6470
- else if (type === "[object String]") {
6471
- if (state.tag !== "?") writeScalar(state, state.dump, level, iskey, inblock);
6472
- } else if (type === "[object Undefined]") return false;
6473
- else {
6474
- if (state.skipInvalid) return false;
6475
- throw new YAMLException("unacceptable kind of an object to dump " + type);
6476
- }
6477
- if (state.tag !== null && state.tag !== "?") {
6478
- let tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
6479
- if (state.tag[0] === "!") tagStr = "!" + tagStr;
6480
- else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") tagStr = "!!" + tagStr.slice(18);
6481
- else tagStr = "!<" + tagStr + ">";
6482
- state.dump = tagStr + " " + state.dump;
6230
+ const ch = state.input.charCodeAt(state.position);
6231
+ if (propertyStart !== null && allowPropertyMapping && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62) {
6232
+ const fallbackState = snapshotState(state);
6233
+ const propertyIndent = propertyStart.position - propertyStart.lineStart;
6234
+ restoreState(state, propertyStart);
6235
+ if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === 3) hasContent = true;
6236
+ else restoreState(state, fallbackState);
6483
6237
  }
6238
+ if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
6484
6239
  }
6485
- return true;
6240
+ else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent, props);
6241
+ }
6242
+ allowBlockScalars = allowBlockScalars && !hasContent;
6243
+ if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
6244
+ addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, 1);
6245
+ hasContent = true;
6246
+ }
6247
+ state.depth--;
6248
+ return hasContent || props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1;
6249
+ }
6250
+ function readDirective(state) {
6251
+ if (state.lineIndent > 0 || state.input.charCodeAt(state.position) !== 37) return false;
6252
+ state.position++;
6253
+ const nameStart = state.position;
6254
+ while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
6255
+ const name = state.input.slice(nameStart, state.position);
6256
+ const args = [];
6257
+ if (name.length === 0) throwError(state, "directive name must not be less than one character in length");
6258
+ while (state.input.charCodeAt(state.position) !== 0 && !isEol(state.input.charCodeAt(state.position))) {
6259
+ while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position++;
6260
+ if (state.input.charCodeAt(state.position) === 35 || isEol(state.input.charCodeAt(state.position)) || state.input.charCodeAt(state.position) === 0) break;
6261
+ const start = state.position;
6262
+ while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
6263
+ args.push(state.input.slice(start, state.position));
6264
+ }
6265
+ if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
6266
+ if (name === "YAML") {
6267
+ if (state.directives.some((directive) => directive.kind === "yaml")) throwError(state, "duplication of %YAML directive");
6268
+ if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
6269
+ const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
6270
+ if (match === null) throwError(state, "ill-formed argument of the YAML directive");
6271
+ if (parseInt(match[1], 10) !== 1) throwError(state, "unacceptable YAML version of the document");
6272
+ state.directives.push({
6273
+ kind: "yaml",
6274
+ version: args[0]
6275
+ });
6276
+ } else if (name === "TAG") {
6277
+ if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
6278
+ const [handle, prefix] = args;
6279
+ if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
6280
+ if (HAS_OWN.call(state.tagHandlers, handle)) throwError(state, `there is a previously declared suffix for "${handle}" tag handle`);
6281
+ if (!PATTERN_TAG_PREFIX.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
6282
+ state.tagHandlers[handle] = prefix;
6283
+ state.directives.push({
6284
+ kind: "tag",
6285
+ handle,
6286
+ prefix
6287
+ });
6486
6288
  }
6487
- function getDuplicateReferences(object, state) {
6488
- const objects = [];
6489
- const duplicatesIndexes = [];
6490
- inspectNode(object, objects, duplicatesIndexes);
6491
- const length = duplicatesIndexes.length;
6492
- for (let index = 0; index < length; index += 1) state.duplicates.push(objects[duplicatesIndexes[index]]);
6493
- state.usedDuplicates = new Array(length);
6494
- }
6495
- function inspectNode(object, objects, duplicatesIndexes) {
6496
- if (object !== null && typeof object === "object") {
6497
- const index = objects.indexOf(object);
6498
- if (index !== -1) {
6499
- if (duplicatesIndexes.indexOf(index) === -1) duplicatesIndexes.push(index);
6500
- } else {
6501
- objects.push(object);
6502
- if (Array.isArray(object)) for (let i = 0, length = object.length; i < length; i += 1) inspectNode(object[i], objects, duplicatesIndexes);
6503
- else {
6504
- const objectKeyList = Object.keys(object);
6505
- for (let i = 0, length = objectKeyList.length; i < length; i += 1) inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
6506
- }
6507
- }
6289
+ return true;
6290
+ }
6291
+ function readDocument(state) {
6292
+ state.directives = [];
6293
+ state.tagHandlers = Object.create(null);
6294
+ let hasDirectives = false;
6295
+ skipSeparationSpace(state, true);
6296
+ while (readDirective(state)) {
6297
+ hasDirectives = true;
6298
+ skipSeparationSpace(state, true);
6299
+ }
6300
+ let explicitStart = false;
6301
+ let explicitEnd = false;
6302
+ let allowCompact = true;
6303
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 3))) {
6304
+ explicitStart = true;
6305
+ const markerLine = state.line;
6306
+ state.position += 3;
6307
+ skipSeparationSpace(state, true);
6308
+ allowCompact = state.line > markerLine;
6309
+ } else if (hasDirectives) throwError(state, "directives end mark is expected");
6310
+ const documentEventIndex = state.events.length;
6311
+ if (!explicitStart && state.position === state.lineStart && state.input.charCodeAt(state.position) === 46 && testDocumentSeparator(state)) {
6312
+ state.position += 3;
6313
+ skipSeparationSpace(state, true);
6314
+ return;
6315
+ }
6316
+ addDocumentEvent(state, explicitStart, false);
6317
+ if (!parseNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
6318
+ skipSeparationSpace(state, true);
6319
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
6320
+ explicitEnd = state.input.charCodeAt(state.position) === 46;
6321
+ if (explicitEnd) {
6322
+ const markerLine = state.line;
6323
+ state.position += 3;
6324
+ skipSeparationSpace(state, true);
6325
+ if (state.line === markerLine && state.position < state.length) throwError(state, "end of the stream or a document separator is expected");
6508
6326
  }
6509
6327
  }
6510
- function dump(input, options) {
6511
- options = options || {};
6512
- const state = new State(options);
6513
- if (!state.noRefs) getDuplicateReferences(input, state);
6514
- let value = input;
6515
- if (state.replacer) value = state.replacer.call({ "": value }, "", value);
6516
- if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
6517
- return "";
6328
+ const documentEvent = state.events[documentEventIndex];
6329
+ if (documentEvent?.type === 1) documentEvent.explicitEnd = explicitEnd;
6330
+ addPopEvent(state);
6331
+ if (!explicitEnd && state.position < state.length && !(state.position === state.lineStart && testDocumentSeparator(state))) throwError(state, "end of the stream or a document separator is expected");
6332
+ }
6333
+ function parseEvents(input, options) {
6334
+ const length = input.length;
6335
+ const state = {
6336
+ ...DEFAULT_PARSER_OPTIONS,
6337
+ ...options,
6338
+ input: `${input}\0`,
6339
+ length,
6340
+ position: 0,
6341
+ line: 0,
6342
+ lineStart: 0,
6343
+ lineIndent: 0,
6344
+ firstTabInLine: -1,
6345
+ depth: 0,
6346
+ directives: [],
6347
+ tagHandlers: Object.create(null),
6348
+ events: []
6349
+ };
6350
+ const nullpos = input.indexOf("\0");
6351
+ if (nullpos !== -1) throwErrorAt(input, nullpos, "null byte is not allowed in input", state.filename);
6352
+ if (state.input.charCodeAt(state.position) === 65279) state.position++;
6353
+ while (state.position < state.length) {
6354
+ skipSeparationSpace(state, true);
6355
+ if (state.position >= state.length) break;
6356
+ const documentStart = state.position;
6357
+ readDocument(state);
6358
+ if (state.position === documentStart)
6359
+ /* c8 ignore next */
6360
+ throwError(state, "can not read a document");
6518
6361
  }
6519
- module.exports.dump = dump;
6520
- }));
6362
+ return state.events;
6363
+ }
6521
6364
  //#endregion
6522
- //#region lib/index_vite_proxy.tmp.mjs
6523
- var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
6524
- var loader = require_loader();
6525
- var dumper = require_dumper();
6526
- function renamed(from, to) {
6527
- return function() {
6528
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
6529
- };
6530
- }
6531
- module.exports.Type = require_type();
6532
- module.exports.Schema = require_schema();
6533
- module.exports.FAILSAFE_SCHEMA = require_failsafe();
6534
- module.exports.JSON_SCHEMA = require_json();
6535
- module.exports.CORE_SCHEMA = require_core();
6536
- module.exports.DEFAULT_SCHEMA = require_default();
6537
- module.exports.load = loader.load;
6538
- module.exports.loadAll = loader.loadAll;
6539
- module.exports.dump = dumper.dump;
6540
- module.exports.YAMLException = require_exception();
6541
- module.exports.types = {
6542
- binary: require_binary(),
6543
- float: require_float(),
6544
- map: require_map(),
6545
- null: require_null(),
6546
- pairs: require_pairs(),
6547
- set: require_set(),
6548
- timestamp: require_timestamp(),
6549
- bool: require_bool(),
6550
- int: require_int(),
6551
- merge: require_merge(),
6552
- omap: require_omap(),
6553
- seq: require_seq(),
6554
- str: require_str()
6365
+ //#region src/load.ts
6366
+ var DEFAULT_LOAD_OPTIONS = {
6367
+ ...DEFAULT_PARSER_OPTIONS,
6368
+ ...DEFAULT_CONSTRUCTOR_OPTIONS
6369
+ };
6370
+ function loadDocuments(input, options = {}) {
6371
+ const opts = {
6372
+ ...DEFAULT_LOAD_OPTIONS,
6373
+ ...options
6555
6374
  };
6556
- module.exports.safeLoad = renamed("safeLoad", "load");
6557
- module.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
6558
- module.exports.safeDump = renamed("safeDump", "dump");
6559
- })))());
6560
- var { Type: Type$1, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types: types$3, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
6561
- var index_vite_proxy_tmp_default = import_js_yaml.default;
6375
+ const source = String(input);
6376
+ const PARSER_OPT_KEYS = Object.keys(DEFAULT_PARSER_OPTIONS);
6377
+ const CONSTRUCTOR_OPT_KEYS = Object.keys(DEFAULT_CONSTRUCTOR_OPTIONS);
6378
+ return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
6379
+ ...pick(opts, CONSTRUCTOR_OPT_KEYS),
6380
+ source
6381
+ });
6382
+ }
6383
+ function load(input, options) {
6384
+ const documents = loadDocuments(input, options);
6385
+ if (documents.length === 0) throw new YAMLException("expected a document, but the input is empty");
6386
+ if (documents.length === 1) return documents[0];
6387
+ throw new YAMLException("expected a single document in the stream, but found more");
6388
+ }
6389
+ //#endregion
6390
+ //#region src/dump.ts
6391
+ YAML11_SCHEMA.withTags({
6392
+ ...intYaml11Tag,
6393
+ resolve: (source, isExplicit, tagName) => {
6394
+ const result = intYaml11Tag.resolve(source, isExplicit, tagName);
6395
+ return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
6396
+ }
6397
+ }, {
6398
+ ...floatYaml11Tag,
6399
+ resolve: (source, isExplicit, tagName) => {
6400
+ const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
6401
+ return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
6402
+ }
6403
+ });
6562
6404
 
6563
6405
  /** Detect free variable `global` from Node.js. */
6564
6406
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
@@ -10470,8 +10312,23 @@ const splitPath = (path) => {
10470
10312
  }
10471
10313
  return path;
10472
10314
  };
10473
- const dereferenceOas = (schema, oas) => (schema.$ref ? get$1(oas, splitPath(schema.$ref)) : schema);
10474
- const dereferenceDoc = (schema, doc) => schema.$ref ? get$1(doc, splitPath(schema.$ref)) : schema;
10315
+ const followRefChain = (schema, doc, seen = new Set()) => {
10316
+ if (!schema.$ref)
10317
+ return { value: schema, ref: undefined };
10318
+ if (seen.has(schema.$ref))
10319
+ return { value: undefined, ref: undefined };
10320
+ const resolved = get$1(doc, splitPath(schema.$ref));
10321
+ if (resolved !== null && typeof resolved === "object" && "$ref" in resolved) {
10322
+ const next = followRefChain(resolved, doc, new Set([...seen, schema.$ref]));
10323
+ return next.value !== undefined
10324
+ ? { value: next.value, ref: next.ref ?? schema.$ref }
10325
+ : next;
10326
+ }
10327
+ return { value: resolved, ref: schema.$ref };
10328
+ };
10329
+ const dereferenceOas = (schema, oas) => (followRefChain(schema, oas).value ?? schema);
10330
+ const dereferenceDoc = (schema, doc) => followRefChain(schema, doc).value;
10331
+ const lastRefInChain = (schema, doc) => followRefChain(schema, doc).ref;
10475
10332
  const traverse = (schema, visitor) => {
10476
10333
  if (typeof schema === "boolean" || schema === undefined) {
10477
10334
  return;
@@ -10555,7 +10412,8 @@ function* iterateMessageList(messages, inlinePathBase, cache, doc) {
10555
10412
  const message = dereferenceDoc(ref, doc);
10556
10413
  if (!message)
10557
10414
  continue;
10558
- const path = "[root]." + ref.$ref.replace(/^#\//, "").replace(/\//g, ".");
10415
+ const finalRef = lastRefInChain(ref, doc) ?? ref.$ref;
10416
+ const path = "[root]." + finalRef.replace(/^#\//, "").replace(/\//g, ".");
10559
10417
  const result = { message, path };
10560
10418
  cache.set(ref.$ref, result);
10561
10419
  yield result;
@@ -11068,12 +10926,13 @@ function checkAsyncapiPreamble(asyncapi, interaction, index, interactionKind) {
11068
10926
  },
11069
10927
  };
11070
10928
  }
10929
+ const interactionKindTitleCase = `${interactionKind.charAt(0).toUpperCase()}${interactionKind.slice(1)}`;
11071
10930
  if (!interaction.asyncapiReferences) {
11072
10931
  return {
11073
10932
  ok: false,
11074
10933
  result: {
11075
10934
  code: "message.references.missing",
11076
- message: `${interactionKind.charAt(0).toUpperCase()}${interactionKind.slice(1)} interaction has no AsyncAPI references in comments.references.AsyncAPI`,
10935
+ message: `${interactionKindTitleCase} interaction has no AsyncAPI references in comments.references.AsyncAPI`,
11077
10936
  mockDetails: {
11078
10937
  ...baseMockDetails(interaction),
11079
10938
  location: `[root].interactions[${index}].comments.references.AsyncAPI`,
@@ -11085,6 +10944,22 @@ function checkAsyncapiPreamble(asyncapi, interaction, index, interactionKind) {
11085
10944
  };
11086
10945
  }
11087
10946
  const { operationId } = interaction.asyncapiReferences;
10947
+ if (!operationId) {
10948
+ return {
10949
+ ok: false,
10950
+ result: {
10951
+ code: "message.references.missing",
10952
+ message: `${interactionKindTitleCase} interaction has a malformed AsyncAPI reference in comments.references.AsyncAPI: expected an "operationId" property`,
10953
+ mockDetails: {
10954
+ ...baseMockDetails(interaction),
10955
+ location: `[root].interactions[${index}].comments.references.AsyncAPI`,
10956
+ value: interaction.asyncapiReferences,
10957
+ },
10958
+ specDetails: { location: "[root]", value: undefined },
10959
+ type: "error",
10960
+ },
10961
+ };
10962
+ }
11088
10963
  if (!asyncapi.operations?.[operationId]) {
11089
10964
  return {
11090
10965
  ok: false,
@@ -13381,7 +13256,10 @@ function requireSideChannel () {
13381
13256
  var channel = {
13382
13257
  assert: function (key) {
13383
13258
  if (!channel.has(key)) {
13384
- throw new $TypeError('Side channel does not contain ' + inspect(key));
13259
+ var keyDesc = key && Object(key) === key
13260
+ ? 'the given object key'
13261
+ : inspect(key);
13262
+ throw new $TypeError('Side channel does not contain ' + keyDesc);
13385
13263
  }
13386
13264
  },
13387
13265
  'delete': function (key) {
@@ -13401,7 +13279,7 @@ function requireSideChannel () {
13401
13279
  $channelData.set(key, value);
13402
13280
  }
13403
13281
  };
13404
- // @ts-expect-error TODO: figure out why this is erroring
13282
+
13405
13283
  return channel;
13406
13284
  };
13407
13285
  return sideChannel;
@@ -13447,6 +13325,7 @@ function requireUtils$1 () {
13447
13325
 
13448
13326
  var formats = /*@__PURE__*/ requireFormats$1();
13449
13327
  var getSideChannel = requireSideChannel();
13328
+ var defineProperty = /*@__PURE__*/ requireEsDefineProperty();
13450
13329
 
13451
13330
  var has = Object.prototype.hasOwnProperty;
13452
13331
  var isArray = Array.isArray;
@@ -13511,6 +13390,19 @@ function requireUtils$1 () {
13511
13390
  return obj;
13512
13391
  };
13513
13392
 
13393
+ var setProperty = function setProperty(obj, key, value) {
13394
+ if (key === '__proto__' && defineProperty) {
13395
+ defineProperty(obj, key, {
13396
+ configurable: true,
13397
+ enumerable: true,
13398
+ value: value,
13399
+ writable: true
13400
+ });
13401
+ } else {
13402
+ obj[key] = value;
13403
+ }
13404
+ };
13405
+
13514
13406
  var merge = function merge(target, source, options) {
13515
13407
  /* eslint no-param-reassign: 0 */
13516
13408
  if (!source) {
@@ -13520,7 +13412,10 @@ function requireUtils$1 () {
13520
13412
  if (typeof source !== 'object' && typeof source !== 'function') {
13521
13413
  if (isArray(target)) {
13522
13414
  var nextIndex = target.length;
13523
- if (options && typeof options.arrayLimit === 'number' && nextIndex > options.arrayLimit) {
13415
+ if (options && typeof options.arrayLimit === 'number' && nextIndex >= options.arrayLimit) {
13416
+ if (options.throwOnLimitExceeded) {
13417
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
13418
+ }
13524
13419
  return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
13525
13420
  }
13526
13421
  target[nextIndex] = source;
@@ -13560,6 +13455,9 @@ function requireUtils$1 () {
13560
13455
  }
13561
13456
  var combined = [target].concat(source);
13562
13457
  if (options && typeof options.arrayLimit === 'number' && combined.length > options.arrayLimit) {
13458
+ if (options.throwOnLimitExceeded) {
13459
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
13460
+ }
13563
13461
  return markOverflow(arrayToObject(combined, options), combined.length - 1);
13564
13462
  }
13565
13463
  return combined;
@@ -13583,6 +13481,12 @@ function requireUtils$1 () {
13583
13481
  target[i] = item;
13584
13482
  }
13585
13483
  });
13484
+ if (options && typeof options.arrayLimit === 'number' && target.length > options.arrayLimit) {
13485
+ if (options.throwOnLimitExceeded) {
13486
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
13487
+ }
13488
+ return markOverflow(arrayToObject(target, options), target.length - 1);
13489
+ }
13586
13490
  return target;
13587
13491
  }
13588
13492
 
@@ -13590,9 +13494,9 @@ function requireUtils$1 () {
13590
13494
  var value = source[key];
13591
13495
 
13592
13496
  if (has.call(acc, key)) {
13593
- acc[key] = merge(acc[key], value, options);
13497
+ setProperty(acc, key, merge(acc[key], value, options));
13594
13498
  } else {
13595
- acc[key] = value;
13499
+ setProperty(acc, key, value);
13596
13500
  }
13597
13501
 
13598
13502
  if (isOverflow(source) && !isOverflow(acc)) {
@@ -13611,7 +13515,7 @@ function requireUtils$1 () {
13611
13515
 
13612
13516
  var assign = function assignSingleSource(target, source) {
13613
13517
  return Object.keys(source).reduce(function (acc, key) {
13614
- acc[key] = source[key];
13518
+ setProperty(acc, key, source[key]);
13615
13519
  return acc;
13616
13520
  }, target);
13617
13521
  };
@@ -13657,6 +13561,13 @@ function requireUtils$1 () {
13657
13561
  var out = '';
13658
13562
  for (var j = 0; j < string.length; j += limit) {
13659
13563
  var segment = string.length >= limit ? string.slice(j, j + limit) : string;
13564
+ if (j + limit < string.length) {
13565
+ var last = segment.charCodeAt(segment.length - 1);
13566
+ if (last >= 0xD800 && last <= 0xDBFF) {
13567
+ segment = segment.slice(0, -1);
13568
+ j -= 1;
13569
+ }
13570
+ }
13660
13571
  var arr = [];
13661
13572
 
13662
13573
  for (var i = 0; i < segment.length; ++i) {
@@ -13710,7 +13621,7 @@ function requireUtils$1 () {
13710
13621
 
13711
13622
  var compact = function compact(value) {
13712
13623
  var queue = [{ obj: { o: value }, prop: 'o' }];
13713
- var refs = [];
13624
+ var refs = getSideChannel();
13714
13625
 
13715
13626
  for (var i = 0; i < queue.length; ++i) {
13716
13627
  var item = queue[i];
@@ -13720,9 +13631,9 @@ function requireUtils$1 () {
13720
13631
  for (var j = 0; j < keys.length; ++j) {
13721
13632
  var key = keys[j];
13722
13633
  var val = obj[key];
13723
- if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
13634
+ if (typeof val === 'object' && val !== null && !refs.has(val)) {
13724
13635
  queue[queue.length] = { obj: obj, prop: key };
13725
- refs[refs.length] = val;
13636
+ refs.set(val, true);
13726
13637
  }
13727
13638
  }
13728
13639
  }
@@ -13744,9 +13655,12 @@ function requireUtils$1 () {
13744
13655
  return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
13745
13656
  };
13746
13657
 
13747
- var combine = function combine(a, b, arrayLimit, plainObjects) {
13658
+ var combine = function combine(a, b, arrayLimit, plainObjects, throwOnLimitExceeded) {
13748
13659
  // If 'a' is already an overflow object, add to it
13749
13660
  if (isOverflow(a)) {
13661
+ if (throwOnLimitExceeded) {
13662
+ throw new RangeError('Array limit exceeded. Only ' + arrayLimit + ' element' + (arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
13663
+ }
13750
13664
  var newIndex = getMaxIndex(a) + 1;
13751
13665
  a[newIndex] = b;
13752
13666
  setMaxIndex(a, newIndex);
@@ -13755,6 +13669,9 @@ function requireUtils$1 () {
13755
13669
 
13756
13670
  var result = [].concat(a, b);
13757
13671
  if (result.length > arrayLimit) {
13672
+ if (throwOnLimitExceeded) {
13673
+ throw new RangeError('Array limit exceeded. Only ' + arrayLimit + ' element' + (arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
13674
+ }
13758
13675
  return markOverflow(arrayToObject(result, { plainObjects: plainObjects }), result.length - 1);
13759
13676
  }
13760
13677
  return result;
@@ -14202,8 +14119,19 @@ function requireParse$1 () {
14202
14119
  });
14203
14120
  };
14204
14121
 
14205
- var parseArrayValue = function (val, options, currentArrayLength) {
14122
+ var parseArrayValue = function (val, options, currentArrayLength, isFlatArrayValue) {
14206
14123
  if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
14124
+ if (isFlatArrayValue && options.throwOnLimitExceeded) {
14125
+ var commaCount = 0;
14126
+ var commaIndex = val.indexOf(',');
14127
+ while (commaIndex > -1) {
14128
+ commaCount += 1;
14129
+ if (commaCount >= options.arrayLimit) {
14130
+ throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
14131
+ }
14132
+ commaIndex = val.indexOf(',', commaIndex + 1);
14133
+ }
14134
+ }
14207
14135
  return val.split(',');
14208
14136
  }
14209
14137
 
@@ -14280,7 +14208,8 @@ function requireParse$1 () {
14280
14208
  parseArrayValue(
14281
14209
  part.slice(pos + 1),
14282
14210
  options,
14283
- isArray(obj[key]) ? obj[key].length : 0
14211
+ isArray(obj[key]) ? obj[key].length : 0,
14212
+ part.indexOf('[]=') === -1
14284
14213
  ),
14285
14214
  function (encodedVal) {
14286
14215
  return options.decoder(encodedVal, defaults.decoder, charset, 'value');
@@ -14298,10 +14227,7 @@ function requireParse$1 () {
14298
14227
  }
14299
14228
 
14300
14229
  if (options.comma && isArray(val) && val.length > options.arrayLimit) {
14301
- if (options.throwOnLimitExceeded) {
14302
- throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (options.arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
14303
- }
14304
- val = utils.combine([], val, options.arrayLimit, options.plainObjects);
14230
+ val = utils.combine([], val, options.arrayLimit, options.plainObjects, options.throwOnLimitExceeded);
14305
14231
  }
14306
14232
 
14307
14233
  if (key !== null) {
@@ -14311,7 +14237,8 @@ function requireParse$1 () {
14311
14237
  obj[key],
14312
14238
  val,
14313
14239
  options.arrayLimit,
14314
- options.plainObjects
14240
+ options.plainObjects,
14241
+ options.throwOnLimitExceeded
14315
14242
  );
14316
14243
  } else if (!existing || options.duplicates === 'last') {
14317
14244
  obj[key] = val;
@@ -14346,7 +14273,8 @@ function requireParse$1 () {
14346
14273
  [],
14347
14274
  leaf,
14348
14275
  options.arrayLimit,
14349
- options.plainObjects
14276
+ options.plainObjects,
14277
+ options.throwOnLimitExceeded
14350
14278
  );
14351
14279
  }
14352
14280
  } else {
@@ -14751,7 +14679,8 @@ function* compareReqHeader(ajv, route, interaction, index, config) {
14751
14679
  Object.entries(operation.responses).reduce((acc, [_status, response]) => {
14752
14680
  return [
14753
14681
  ...acc,
14754
- ...Object.keys(dereferenceOas(response || {}, oas)?.content || {}),
14682
+ ...Object.keys(dereferenceOas(response || {}, oas)
14683
+ ?.content || {}),
14755
14684
  ];
14756
14685
  }, []);
14757
14686
  const availableResponseContentType = operation.produces ||
@@ -23810,7 +23739,7 @@ function requireFastUri () {
23810
23739
  if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && isIP === false && nonSimpleDomain(parsed.host)) {
23811
23740
  // convert Unicode IDN -> ASCII IDN
23812
23741
  try {
23813
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
23742
+ parsed.host = new URL('http://' + parsed.host).hostname;
23814
23743
  } catch (e) {
23815
23744
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
23816
23745
  }
@@ -26970,9 +26899,7 @@ const AsyncMessage = Type.Object({
26970
26899
  metadata: Type.Optional(Type.Record(Type.String(), Type.String())),
26971
26900
  comments: Type.Optional(Type.Object({
26972
26901
  references: Type.Optional(Type.Object({
26973
- AsyncAPI: Type.Optional(Type.Object({
26974
- operationId: Type.String(),
26975
- })),
26902
+ AsyncAPI: Type.Optional(Type.Unknown()),
26976
26903
  })),
26977
26904
  })),
26978
26905
  });
@@ -26992,9 +26919,7 @@ const SyncMessage = Type.Object({
26992
26919
  response: Type.Array(SyncMessageSide),
26993
26920
  comments: Type.Optional(Type.Object({
26994
26921
  references: Type.Optional(Type.Object({
26995
- AsyncAPI: Type.Optional(Type.Object({
26996
- operationId: Type.String(),
26997
- })),
26922
+ AsyncAPI: Type.Optional(Type.Unknown()),
26998
26923
  })),
26999
26924
  })),
27000
26925
  });
@@ -27084,29 +27009,32 @@ const interactionV4 = (i) => ({
27084
27009
  headers: flattenValues(i.response?.headers),
27085
27010
  },
27086
27011
  });
27012
+ const asAsyncapiReferences = (asyncapiRef) => {
27013
+ if (!asyncapiRef)
27014
+ return undefined;
27015
+ if (typeof asyncapiRef !== "object")
27016
+ return {};
27017
+ return { ...asyncapiRef };
27018
+ };
27087
27019
  const parseAsyncInteraction = (i) => {
27088
- const asyncapiRef = i.comments?.references?.AsyncAPI;
27020
+ const asyncapiRef = asAsyncapiReferences(i.comments?.references?.AsyncAPI);
27089
27021
  return {
27090
27022
  _kind: "async",
27091
27023
  description: i.description,
27092
27024
  providerState: i.providerState,
27093
- asyncapiReferences: asyncapiRef
27094
- ? { operationId: asyncapiRef.operationId }
27095
- : undefined,
27025
+ asyncapiReferences: asyncapiRef,
27096
27026
  payload: parseAsPactV4Body(i.contents),
27097
27027
  contentType: i.contents?.contentType,
27098
27028
  metadata: i.metadata,
27099
27029
  };
27100
27030
  };
27101
27031
  const parseSyncInteraction = (i) => {
27102
- const asyncapiRef = i.comments?.references?.AsyncAPI;
27032
+ const asyncapiRef = asAsyncapiReferences(i.comments?.references?.AsyncAPI);
27103
27033
  return {
27104
27034
  _kind: "sync",
27105
27035
  description: i.description,
27106
27036
  providerState: i.providerState,
27107
- asyncapiReferences: asyncapiRef
27108
- ? { operationId: asyncapiRef.operationId }
27109
- : undefined,
27037
+ asyncapiReferences: asyncapiRef,
27110
27038
  request: {
27111
27039
  payload: parseAsPactV4Body(i.request.contents),
27112
27040
  contentType: i.request.contents?.contentType,
@@ -32083,7 +32011,7 @@ class Runner {
32083
32011
  }
32084
32012
  catch (error) {
32085
32013
  try {
32086
- return index_vite_proxy_tmp_default.load(content);
32014
+ return load(content);
32087
32015
  }
32088
32016
  catch (_err) {
32089
32017
  throw error;