@akson/cortex-analytics 0.8.1 → 0.9.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.js CHANGED
@@ -9,7 +9,7 @@ var require_package = __commonJS({
9
9
  "package.json"(exports, module) {
10
10
  module.exports = {
11
11
  name: "@akson/cortex-analytics",
12
- version: "0.8.1",
12
+ version: "0.9.0",
13
13
  description: "Unified CLI for Cortex analytics operations across all platforms",
14
14
  type: "module",
15
15
  main: "dist/index.js",
@@ -26,17 +26,19 @@ var require_package = __commonJS({
26
26
  "type-check": "tsc --noEmit"
27
27
  },
28
28
  dependencies: {
29
- "@akson/cortex-gsc": "^0.5.0",
30
- "@akson/cortex-gtm": "^3.0.0",
31
- "@akson/cortex-posthog": "^0.4.0",
29
+ "@akson/cortex-gsc": "workspace:*",
30
+ "@akson/cortex-gtm": "workspace:*",
31
+ "@akson/cortex-posthog": "workspace:*",
32
32
  chalk: "^5.5.0",
33
33
  commander: "^14.0.0",
34
- inquirer: "^11.1.0",
34
+ inquirer: "^13.1.0",
35
+ "js-yaml": "^4.1.0",
35
36
  ora: "^8.1.1",
36
37
  table: "^6.9.0"
37
38
  },
38
39
  devDependencies: {
39
40
  "@types/inquirer": "^9.0.7",
41
+ "@types/js-yaml": "^4.0.9",
40
42
  "@types/node": "^22",
41
43
  eslint: "^8",
42
44
  tsup: "^8.5.0",
@@ -111,2630 +113,7 @@ import {
111
113
  } from "@akson/cortex-utilities";
112
114
  import chalk from "chalk";
113
115
  import inquirer from "inquirer";
114
-
115
- // node_modules/js-yaml/dist/js-yaml.mjs
116
- function isNothing(subject) {
117
- return typeof subject === "undefined" || subject === null;
118
- }
119
- function isObject(subject) {
120
- return typeof subject === "object" && subject !== null;
121
- }
122
- function toArray(sequence) {
123
- if (Array.isArray(sequence)) return sequence;
124
- else if (isNothing(sequence)) return [];
125
- return [sequence];
126
- }
127
- function extend(target, source) {
128
- var index, length, key, sourceKeys;
129
- if (source) {
130
- sourceKeys = Object.keys(source);
131
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
132
- key = sourceKeys[index];
133
- target[key] = source[key];
134
- }
135
- }
136
- return target;
137
- }
138
- function repeat(string, count) {
139
- var result = "", cycle;
140
- for (cycle = 0; cycle < count; cycle += 1) {
141
- result += string;
142
- }
143
- return result;
144
- }
145
- function isNegativeZero(number) {
146
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
147
- }
148
- var isNothing_1 = isNothing;
149
- var isObject_1 = isObject;
150
- var toArray_1 = toArray;
151
- var repeat_1 = repeat;
152
- var isNegativeZero_1 = isNegativeZero;
153
- var extend_1 = extend;
154
- var common = {
155
- isNothing: isNothing_1,
156
- isObject: isObject_1,
157
- toArray: toArray_1,
158
- repeat: repeat_1,
159
- isNegativeZero: isNegativeZero_1,
160
- extend: extend_1
161
- };
162
- function formatError(exception2, compact) {
163
- var where = "", message = exception2.reason || "(unknown reason)";
164
- if (!exception2.mark) return message;
165
- if (exception2.mark.name) {
166
- where += 'in "' + exception2.mark.name + '" ';
167
- }
168
- where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
169
- if (!compact && exception2.mark.snippet) {
170
- where += "\n\n" + exception2.mark.snippet;
171
- }
172
- return message + " " + where;
173
- }
174
- function YAMLException$1(reason, mark) {
175
- Error.call(this);
176
- this.name = "YAMLException";
177
- this.reason = reason;
178
- this.mark = mark;
179
- this.message = formatError(this, false);
180
- if (Error.captureStackTrace) {
181
- Error.captureStackTrace(this, this.constructor);
182
- } else {
183
- this.stack = new Error().stack || "";
184
- }
185
- }
186
- YAMLException$1.prototype = Object.create(Error.prototype);
187
- YAMLException$1.prototype.constructor = YAMLException$1;
188
- YAMLException$1.prototype.toString = function toString(compact) {
189
- return this.name + ": " + formatError(this, compact);
190
- };
191
- var exception = YAMLException$1;
192
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
193
- var head = "";
194
- var tail = "";
195
- var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
196
- if (position - lineStart > maxHalfLength) {
197
- head = " ... ";
198
- lineStart = position - maxHalfLength + head.length;
199
- }
200
- if (lineEnd - position > maxHalfLength) {
201
- tail = " ...";
202
- lineEnd = position + maxHalfLength - tail.length;
203
- }
204
- return {
205
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
206
- pos: position - lineStart + head.length
207
- // relative position
208
- };
209
- }
210
- function padStart(string, max) {
211
- return common.repeat(" ", max - string.length) + string;
212
- }
213
- function makeSnippet(mark, options) {
214
- options = Object.create(options || null);
215
- if (!mark.buffer) return null;
216
- if (!options.maxLength) options.maxLength = 79;
217
- if (typeof options.indent !== "number") options.indent = 1;
218
- if (typeof options.linesBefore !== "number") options.linesBefore = 3;
219
- if (typeof options.linesAfter !== "number") options.linesAfter = 2;
220
- var re = /\r?\n|\r|\0/g;
221
- var lineStarts = [0];
222
- var lineEnds = [];
223
- var match;
224
- var foundLineNo = -1;
225
- while (match = re.exec(mark.buffer)) {
226
- lineEnds.push(match.index);
227
- lineStarts.push(match.index + match[0].length);
228
- if (mark.position <= match.index && foundLineNo < 0) {
229
- foundLineNo = lineStarts.length - 2;
230
- }
231
- }
232
- if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
233
- var result = "", i, line;
234
- var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
235
- var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
236
- for (i = 1; i <= options.linesBefore; i++) {
237
- if (foundLineNo - i < 0) break;
238
- line = getLine(
239
- mark.buffer,
240
- lineStarts[foundLineNo - i],
241
- lineEnds[foundLineNo - i],
242
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
243
- maxLineLength
244
- );
245
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
246
- }
247
- line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
248
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
249
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
250
- for (i = 1; i <= options.linesAfter; i++) {
251
- if (foundLineNo + i >= lineEnds.length) break;
252
- line = getLine(
253
- mark.buffer,
254
- lineStarts[foundLineNo + i],
255
- lineEnds[foundLineNo + i],
256
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
257
- maxLineLength
258
- );
259
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
260
- }
261
- return result.replace(/\n$/, "");
262
- }
263
- var snippet = makeSnippet;
264
- var TYPE_CONSTRUCTOR_OPTIONS = [
265
- "kind",
266
- "multi",
267
- "resolve",
268
- "construct",
269
- "instanceOf",
270
- "predicate",
271
- "represent",
272
- "representName",
273
- "defaultStyle",
274
- "styleAliases"
275
- ];
276
- var YAML_NODE_KINDS = [
277
- "scalar",
278
- "sequence",
279
- "mapping"
280
- ];
281
- function compileStyleAliases(map2) {
282
- var result = {};
283
- if (map2 !== null) {
284
- Object.keys(map2).forEach(function(style) {
285
- map2[style].forEach(function(alias) {
286
- result[String(alias)] = style;
287
- });
288
- });
289
- }
290
- return result;
291
- }
292
- function Type$1(tag, options) {
293
- options = options || {};
294
- Object.keys(options).forEach(function(name) {
295
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
296
- throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
297
- }
298
- });
299
- this.options = options;
300
- this.tag = tag;
301
- this.kind = options["kind"] || null;
302
- this.resolve = options["resolve"] || function() {
303
- return true;
304
- };
305
- this.construct = options["construct"] || function(data) {
306
- return data;
307
- };
308
- this.instanceOf = options["instanceOf"] || null;
309
- this.predicate = options["predicate"] || null;
310
- this.represent = options["represent"] || null;
311
- this.representName = options["representName"] || null;
312
- this.defaultStyle = options["defaultStyle"] || null;
313
- this.multi = options["multi"] || false;
314
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
315
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
316
- throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
317
- }
318
- }
319
- var type = Type$1;
320
- function compileList(schema2, name) {
321
- var result = [];
322
- schema2[name].forEach(function(currentType) {
323
- var newIndex = result.length;
324
- result.forEach(function(previousType, previousIndex) {
325
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
326
- newIndex = previousIndex;
327
- }
328
- });
329
- result[newIndex] = currentType;
330
- });
331
- return result;
332
- }
333
- function compileMap() {
334
- var result = {
335
- scalar: {},
336
- sequence: {},
337
- mapping: {},
338
- fallback: {},
339
- multi: {
340
- scalar: [],
341
- sequence: [],
342
- mapping: [],
343
- fallback: []
344
- }
345
- }, index, length;
346
- function collectType(type2) {
347
- if (type2.multi) {
348
- result.multi[type2.kind].push(type2);
349
- result.multi["fallback"].push(type2);
350
- } else {
351
- result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
352
- }
353
- }
354
- for (index = 0, length = arguments.length; index < length; index += 1) {
355
- arguments[index].forEach(collectType);
356
- }
357
- return result;
358
- }
359
- function Schema$1(definition) {
360
- return this.extend(definition);
361
- }
362
- Schema$1.prototype.extend = function extend2(definition) {
363
- var implicit = [];
364
- var explicit = [];
365
- if (definition instanceof type) {
366
- explicit.push(definition);
367
- } else if (Array.isArray(definition)) {
368
- explicit = explicit.concat(definition);
369
- } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
370
- if (definition.implicit) implicit = implicit.concat(definition.implicit);
371
- if (definition.explicit) explicit = explicit.concat(definition.explicit);
372
- } else {
373
- throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
374
- }
375
- implicit.forEach(function(type$1) {
376
- if (!(type$1 instanceof type)) {
377
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
378
- }
379
- if (type$1.loadKind && type$1.loadKind !== "scalar") {
380
- throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
381
- }
382
- if (type$1.multi) {
383
- throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
384
- }
385
- });
386
- explicit.forEach(function(type$1) {
387
- if (!(type$1 instanceof type)) {
388
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
389
- }
390
- });
391
- var result = Object.create(Schema$1.prototype);
392
- result.implicit = (this.implicit || []).concat(implicit);
393
- result.explicit = (this.explicit || []).concat(explicit);
394
- result.compiledImplicit = compileList(result, "implicit");
395
- result.compiledExplicit = compileList(result, "explicit");
396
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
397
- return result;
398
- };
399
- var schema = Schema$1;
400
- var str = new type("tag:yaml.org,2002:str", {
401
- kind: "scalar",
402
- construct: function(data) {
403
- return data !== null ? data : "";
404
- }
405
- });
406
- var seq = new type("tag:yaml.org,2002:seq", {
407
- kind: "sequence",
408
- construct: function(data) {
409
- return data !== null ? data : [];
410
- }
411
- });
412
- var map = new type("tag:yaml.org,2002:map", {
413
- kind: "mapping",
414
- construct: function(data) {
415
- return data !== null ? data : {};
416
- }
417
- });
418
- var failsafe = new schema({
419
- explicit: [
420
- str,
421
- seq,
422
- map
423
- ]
424
- });
425
- function resolveYamlNull(data) {
426
- if (data === null) return true;
427
- var max = data.length;
428
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
429
- }
430
- function constructYamlNull() {
431
- return null;
432
- }
433
- function isNull(object) {
434
- return object === null;
435
- }
436
- var _null = new type("tag:yaml.org,2002:null", {
437
- kind: "scalar",
438
- resolve: resolveYamlNull,
439
- construct: constructYamlNull,
440
- predicate: isNull,
441
- represent: {
442
- canonical: function() {
443
- return "~";
444
- },
445
- lowercase: function() {
446
- return "null";
447
- },
448
- uppercase: function() {
449
- return "NULL";
450
- },
451
- camelcase: function() {
452
- return "Null";
453
- },
454
- empty: function() {
455
- return "";
456
- }
457
- },
458
- defaultStyle: "lowercase"
459
- });
460
- function resolveYamlBoolean(data) {
461
- if (data === null) return false;
462
- var max = data.length;
463
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
464
- }
465
- function constructYamlBoolean(data) {
466
- return data === "true" || data === "True" || data === "TRUE";
467
- }
468
- function isBoolean(object) {
469
- return Object.prototype.toString.call(object) === "[object Boolean]";
470
- }
471
- var bool = new type("tag:yaml.org,2002:bool", {
472
- kind: "scalar",
473
- resolve: resolveYamlBoolean,
474
- construct: constructYamlBoolean,
475
- predicate: isBoolean,
476
- represent: {
477
- lowercase: function(object) {
478
- return object ? "true" : "false";
479
- },
480
- uppercase: function(object) {
481
- return object ? "TRUE" : "FALSE";
482
- },
483
- camelcase: function(object) {
484
- return object ? "True" : "False";
485
- }
486
- },
487
- defaultStyle: "lowercase"
488
- });
489
- function isHexCode(c) {
490
- return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
491
- }
492
- function isOctCode(c) {
493
- return 48 <= c && c <= 55;
494
- }
495
- function isDecCode(c) {
496
- return 48 <= c && c <= 57;
497
- }
498
- function resolveYamlInteger(data) {
499
- if (data === null) return false;
500
- var max = data.length, index = 0, hasDigits = false, ch;
501
- if (!max) return false;
502
- ch = data[index];
503
- if (ch === "-" || ch === "+") {
504
- ch = data[++index];
505
- }
506
- if (ch === "0") {
507
- if (index + 1 === max) return true;
508
- ch = data[++index];
509
- if (ch === "b") {
510
- index++;
511
- for (; index < max; index++) {
512
- ch = data[index];
513
- if (ch === "_") continue;
514
- if (ch !== "0" && ch !== "1") return false;
515
- hasDigits = true;
516
- }
517
- return hasDigits && ch !== "_";
518
- }
519
- if (ch === "x") {
520
- index++;
521
- for (; index < max; index++) {
522
- ch = data[index];
523
- if (ch === "_") continue;
524
- if (!isHexCode(data.charCodeAt(index))) return false;
525
- hasDigits = true;
526
- }
527
- return hasDigits && ch !== "_";
528
- }
529
- if (ch === "o") {
530
- index++;
531
- for (; index < max; index++) {
532
- ch = data[index];
533
- if (ch === "_") continue;
534
- if (!isOctCode(data.charCodeAt(index))) return false;
535
- hasDigits = true;
536
- }
537
- return hasDigits && ch !== "_";
538
- }
539
- }
540
- if (ch === "_") return false;
541
- for (; index < max; index++) {
542
- ch = data[index];
543
- if (ch === "_") continue;
544
- if (!isDecCode(data.charCodeAt(index))) {
545
- return false;
546
- }
547
- hasDigits = true;
548
- }
549
- if (!hasDigits || ch === "_") return false;
550
- return true;
551
- }
552
- function constructYamlInteger(data) {
553
- var value = data, sign = 1, ch;
554
- if (value.indexOf("_") !== -1) {
555
- value = value.replace(/_/g, "");
556
- }
557
- ch = value[0];
558
- if (ch === "-" || ch === "+") {
559
- if (ch === "-") sign = -1;
560
- value = value.slice(1);
561
- ch = value[0];
562
- }
563
- if (value === "0") return 0;
564
- if (ch === "0") {
565
- if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
566
- if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
567
- if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
568
- }
569
- return sign * parseInt(value, 10);
570
- }
571
- function isInteger(object) {
572
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
573
- }
574
- var int = new type("tag:yaml.org,2002:int", {
575
- kind: "scalar",
576
- resolve: resolveYamlInteger,
577
- construct: constructYamlInteger,
578
- predicate: isInteger,
579
- represent: {
580
- binary: function(obj) {
581
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
582
- },
583
- octal: function(obj) {
584
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
585
- },
586
- decimal: function(obj) {
587
- return obj.toString(10);
588
- },
589
- /* eslint-disable max-len */
590
- hexadecimal: function(obj) {
591
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
592
- }
593
- },
594
- defaultStyle: "decimal",
595
- styleAliases: {
596
- binary: [2, "bin"],
597
- octal: [8, "oct"],
598
- decimal: [10, "dec"],
599
- hexadecimal: [16, "hex"]
600
- }
601
- });
602
- var YAML_FLOAT_PATTERN = new RegExp(
603
- // 2.5e4, 2.5 and integers
604
- "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
605
- );
606
- function resolveYamlFloat(data) {
607
- if (data === null) return false;
608
- if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
609
- // Probably should update regexp & check speed
610
- data[data.length - 1] === "_") {
611
- return false;
612
- }
613
- return true;
614
- }
615
- function constructYamlFloat(data) {
616
- var value, sign;
617
- value = data.replace(/_/g, "").toLowerCase();
618
- sign = value[0] === "-" ? -1 : 1;
619
- if ("+-".indexOf(value[0]) >= 0) {
620
- value = value.slice(1);
621
- }
622
- if (value === ".inf") {
623
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
624
- } else if (value === ".nan") {
625
- return NaN;
626
- }
627
- return sign * parseFloat(value, 10);
628
- }
629
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
630
- function representYamlFloat(object, style) {
631
- var res;
632
- if (isNaN(object)) {
633
- switch (style) {
634
- case "lowercase":
635
- return ".nan";
636
- case "uppercase":
637
- return ".NAN";
638
- case "camelcase":
639
- return ".NaN";
640
- }
641
- } else if (Number.POSITIVE_INFINITY === object) {
642
- switch (style) {
643
- case "lowercase":
644
- return ".inf";
645
- case "uppercase":
646
- return ".INF";
647
- case "camelcase":
648
- return ".Inf";
649
- }
650
- } else if (Number.NEGATIVE_INFINITY === object) {
651
- switch (style) {
652
- case "lowercase":
653
- return "-.inf";
654
- case "uppercase":
655
- return "-.INF";
656
- case "camelcase":
657
- return "-.Inf";
658
- }
659
- } else if (common.isNegativeZero(object)) {
660
- return "-0.0";
661
- }
662
- res = object.toString(10);
663
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
664
- }
665
- function isFloat(object) {
666
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
667
- }
668
- var float = new type("tag:yaml.org,2002:float", {
669
- kind: "scalar",
670
- resolve: resolveYamlFloat,
671
- construct: constructYamlFloat,
672
- predicate: isFloat,
673
- represent: representYamlFloat,
674
- defaultStyle: "lowercase"
675
- });
676
- var json = failsafe.extend({
677
- implicit: [
678
- _null,
679
- bool,
680
- int,
681
- float
682
- ]
683
- });
684
- var core = json;
685
- var YAML_DATE_REGEXP = new RegExp(
686
- "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
687
- );
688
- var YAML_TIMESTAMP_REGEXP = new RegExp(
689
- "^([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]))?))?$"
690
- );
691
- function resolveYamlTimestamp(data) {
692
- if (data === null) return false;
693
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
694
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
695
- return false;
696
- }
697
- function constructYamlTimestamp(data) {
698
- var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
699
- match = YAML_DATE_REGEXP.exec(data);
700
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
701
- if (match === null) throw new Error("Date resolve error");
702
- year = +match[1];
703
- month = +match[2] - 1;
704
- day = +match[3];
705
- if (!match[4]) {
706
- return new Date(Date.UTC(year, month, day));
707
- }
708
- hour = +match[4];
709
- minute = +match[5];
710
- second = +match[6];
711
- if (match[7]) {
712
- fraction = match[7].slice(0, 3);
713
- while (fraction.length < 3) {
714
- fraction += "0";
715
- }
716
- fraction = +fraction;
717
- }
718
- if (match[9]) {
719
- tz_hour = +match[10];
720
- tz_minute = +(match[11] || 0);
721
- delta = (tz_hour * 60 + tz_minute) * 6e4;
722
- if (match[9] === "-") delta = -delta;
723
- }
724
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
725
- if (delta) date.setTime(date.getTime() - delta);
726
- return date;
727
- }
728
- function representYamlTimestamp(object) {
729
- return object.toISOString();
730
- }
731
- var timestamp = new type("tag:yaml.org,2002:timestamp", {
732
- kind: "scalar",
733
- resolve: resolveYamlTimestamp,
734
- construct: constructYamlTimestamp,
735
- instanceOf: Date,
736
- represent: representYamlTimestamp
737
- });
738
- function resolveYamlMerge(data) {
739
- return data === "<<" || data === null;
740
- }
741
- var merge = new type("tag:yaml.org,2002:merge", {
742
- kind: "scalar",
743
- resolve: resolveYamlMerge
744
- });
745
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
746
- function resolveYamlBinary(data) {
747
- if (data === null) return false;
748
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
749
- for (idx = 0; idx < max; idx++) {
750
- code = map2.indexOf(data.charAt(idx));
751
- if (code > 64) continue;
752
- if (code < 0) return false;
753
- bitlen += 6;
754
- }
755
- return bitlen % 8 === 0;
756
- }
757
- function constructYamlBinary(data) {
758
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
759
- for (idx = 0; idx < max; idx++) {
760
- if (idx % 4 === 0 && idx) {
761
- result.push(bits >> 16 & 255);
762
- result.push(bits >> 8 & 255);
763
- result.push(bits & 255);
764
- }
765
- bits = bits << 6 | map2.indexOf(input.charAt(idx));
766
- }
767
- tailbits = max % 4 * 6;
768
- if (tailbits === 0) {
769
- result.push(bits >> 16 & 255);
770
- result.push(bits >> 8 & 255);
771
- result.push(bits & 255);
772
- } else if (tailbits === 18) {
773
- result.push(bits >> 10 & 255);
774
- result.push(bits >> 2 & 255);
775
- } else if (tailbits === 12) {
776
- result.push(bits >> 4 & 255);
777
- }
778
- return new Uint8Array(result);
779
- }
780
- function representYamlBinary(object) {
781
- var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
782
- for (idx = 0; idx < max; idx++) {
783
- if (idx % 3 === 0 && idx) {
784
- result += map2[bits >> 18 & 63];
785
- result += map2[bits >> 12 & 63];
786
- result += map2[bits >> 6 & 63];
787
- result += map2[bits & 63];
788
- }
789
- bits = (bits << 8) + object[idx];
790
- }
791
- tail = max % 3;
792
- if (tail === 0) {
793
- result += map2[bits >> 18 & 63];
794
- result += map2[bits >> 12 & 63];
795
- result += map2[bits >> 6 & 63];
796
- result += map2[bits & 63];
797
- } else if (tail === 2) {
798
- result += map2[bits >> 10 & 63];
799
- result += map2[bits >> 4 & 63];
800
- result += map2[bits << 2 & 63];
801
- result += map2[64];
802
- } else if (tail === 1) {
803
- result += map2[bits >> 2 & 63];
804
- result += map2[bits << 4 & 63];
805
- result += map2[64];
806
- result += map2[64];
807
- }
808
- return result;
809
- }
810
- function isBinary(obj) {
811
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
812
- }
813
- var binary = new type("tag:yaml.org,2002:binary", {
814
- kind: "scalar",
815
- resolve: resolveYamlBinary,
816
- construct: constructYamlBinary,
817
- predicate: isBinary,
818
- represent: representYamlBinary
819
- });
820
- var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
821
- var _toString$2 = Object.prototype.toString;
822
- function resolveYamlOmap(data) {
823
- if (data === null) return true;
824
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
825
- for (index = 0, length = object.length; index < length; index += 1) {
826
- pair = object[index];
827
- pairHasKey = false;
828
- if (_toString$2.call(pair) !== "[object Object]") return false;
829
- for (pairKey in pair) {
830
- if (_hasOwnProperty$3.call(pair, pairKey)) {
831
- if (!pairHasKey) pairHasKey = true;
832
- else return false;
833
- }
834
- }
835
- if (!pairHasKey) return false;
836
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
837
- else return false;
838
- }
839
- return true;
840
- }
841
- function constructYamlOmap(data) {
842
- return data !== null ? data : [];
843
- }
844
- var omap = new type("tag:yaml.org,2002:omap", {
845
- kind: "sequence",
846
- resolve: resolveYamlOmap,
847
- construct: constructYamlOmap
848
- });
849
- var _toString$1 = Object.prototype.toString;
850
- function resolveYamlPairs(data) {
851
- if (data === null) return true;
852
- var index, length, pair, keys, result, object = data;
853
- result = new Array(object.length);
854
- for (index = 0, length = object.length; index < length; index += 1) {
855
- pair = object[index];
856
- if (_toString$1.call(pair) !== "[object Object]") return false;
857
- keys = Object.keys(pair);
858
- if (keys.length !== 1) return false;
859
- result[index] = [keys[0], pair[keys[0]]];
860
- }
861
- return true;
862
- }
863
- function constructYamlPairs(data) {
864
- if (data === null) return [];
865
- var index, length, pair, keys, result, object = data;
866
- result = new Array(object.length);
867
- for (index = 0, length = object.length; index < length; index += 1) {
868
- pair = object[index];
869
- keys = Object.keys(pair);
870
- result[index] = [keys[0], pair[keys[0]]];
871
- }
872
- return result;
873
- }
874
- var pairs = new type("tag:yaml.org,2002:pairs", {
875
- kind: "sequence",
876
- resolve: resolveYamlPairs,
877
- construct: constructYamlPairs
878
- });
879
- var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
880
- function resolveYamlSet(data) {
881
- if (data === null) return true;
882
- var key, object = data;
883
- for (key in object) {
884
- if (_hasOwnProperty$2.call(object, key)) {
885
- if (object[key] !== null) return false;
886
- }
887
- }
888
- return true;
889
- }
890
- function constructYamlSet(data) {
891
- return data !== null ? data : {};
892
- }
893
- var set = new type("tag:yaml.org,2002:set", {
894
- kind: "mapping",
895
- resolve: resolveYamlSet,
896
- construct: constructYamlSet
897
- });
898
- var _default = core.extend({
899
- implicit: [
900
- timestamp,
901
- merge
902
- ],
903
- explicit: [
904
- binary,
905
- omap,
906
- pairs,
907
- set
908
- ]
909
- });
910
- var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
911
- var CONTEXT_FLOW_IN = 1;
912
- var CONTEXT_FLOW_OUT = 2;
913
- var CONTEXT_BLOCK_IN = 3;
914
- var CONTEXT_BLOCK_OUT = 4;
915
- var CHOMPING_CLIP = 1;
916
- var CHOMPING_STRIP = 2;
917
- var CHOMPING_KEEP = 3;
918
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
919
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
920
- var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
921
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
922
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
923
- function _class(obj) {
924
- return Object.prototype.toString.call(obj);
925
- }
926
- function is_EOL(c) {
927
- return c === 10 || c === 13;
928
- }
929
- function is_WHITE_SPACE(c) {
930
- return c === 9 || c === 32;
931
- }
932
- function is_WS_OR_EOL(c) {
933
- return c === 9 || c === 32 || c === 10 || c === 13;
934
- }
935
- function is_FLOW_INDICATOR(c) {
936
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
937
- }
938
- function fromHexCode(c) {
939
- var lc;
940
- if (48 <= c && c <= 57) {
941
- return c - 48;
942
- }
943
- lc = c | 32;
944
- if (97 <= lc && lc <= 102) {
945
- return lc - 97 + 10;
946
- }
947
- return -1;
948
- }
949
- function escapedHexLen(c) {
950
- if (c === 120) {
951
- return 2;
952
- }
953
- if (c === 117) {
954
- return 4;
955
- }
956
- if (c === 85) {
957
- return 8;
958
- }
959
- return 0;
960
- }
961
- function fromDecimalCode(c) {
962
- if (48 <= c && c <= 57) {
963
- return c - 48;
964
- }
965
- return -1;
966
- }
967
- function simpleEscapeSequence(c) {
968
- return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
969
- }
970
- function charFromCodepoint(c) {
971
- if (c <= 65535) {
972
- return String.fromCharCode(c);
973
- }
974
- return String.fromCharCode(
975
- (c - 65536 >> 10) + 55296,
976
- (c - 65536 & 1023) + 56320
977
- );
978
- }
979
- var simpleEscapeCheck = new Array(256);
980
- var simpleEscapeMap = new Array(256);
981
- for (i = 0; i < 256; i++) {
982
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
983
- simpleEscapeMap[i] = simpleEscapeSequence(i);
984
- }
985
- var i;
986
- function State$1(input, options) {
987
- this.input = input;
988
- this.filename = options["filename"] || null;
989
- this.schema = options["schema"] || _default;
990
- this.onWarning = options["onWarning"] || null;
991
- this.legacy = options["legacy"] || false;
992
- this.json = options["json"] || false;
993
- this.listener = options["listener"] || null;
994
- this.implicitTypes = this.schema.compiledImplicit;
995
- this.typeMap = this.schema.compiledTypeMap;
996
- this.length = input.length;
997
- this.position = 0;
998
- this.line = 0;
999
- this.lineStart = 0;
1000
- this.lineIndent = 0;
1001
- this.firstTabInLine = -1;
1002
- this.documents = [];
1003
- }
1004
- function generateError(state, message) {
1005
- var mark = {
1006
- name: state.filename,
1007
- buffer: state.input.slice(0, -1),
1008
- // omit trailing \0
1009
- position: state.position,
1010
- line: state.line,
1011
- column: state.position - state.lineStart
1012
- };
1013
- mark.snippet = snippet(mark);
1014
- return new exception(message, mark);
1015
- }
1016
- function throwError(state, message) {
1017
- throw generateError(state, message);
1018
- }
1019
- function throwWarning(state, message) {
1020
- if (state.onWarning) {
1021
- state.onWarning.call(null, generateError(state, message));
1022
- }
1023
- }
1024
- var directiveHandlers = {
1025
- YAML: function handleYamlDirective(state, name, args) {
1026
- var match, major, minor;
1027
- if (state.version !== null) {
1028
- throwError(state, "duplication of %YAML directive");
1029
- }
1030
- if (args.length !== 1) {
1031
- throwError(state, "YAML directive accepts exactly one argument");
1032
- }
1033
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1034
- if (match === null) {
1035
- throwError(state, "ill-formed argument of the YAML directive");
1036
- }
1037
- major = parseInt(match[1], 10);
1038
- minor = parseInt(match[2], 10);
1039
- if (major !== 1) {
1040
- throwError(state, "unacceptable YAML version of the document");
1041
- }
1042
- state.version = args[0];
1043
- state.checkLineBreaks = minor < 2;
1044
- if (minor !== 1 && minor !== 2) {
1045
- throwWarning(state, "unsupported YAML version of the document");
1046
- }
1047
- },
1048
- TAG: function handleTagDirective(state, name, args) {
1049
- var handle, prefix;
1050
- if (args.length !== 2) {
1051
- throwError(state, "TAG directive accepts exactly two arguments");
1052
- }
1053
- handle = args[0];
1054
- prefix = args[1];
1055
- if (!PATTERN_TAG_HANDLE.test(handle)) {
1056
- throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1057
- }
1058
- if (_hasOwnProperty$1.call(state.tagMap, handle)) {
1059
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1060
- }
1061
- if (!PATTERN_TAG_URI.test(prefix)) {
1062
- throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1063
- }
1064
- try {
1065
- prefix = decodeURIComponent(prefix);
1066
- } catch (err) {
1067
- throwError(state, "tag prefix is malformed: " + prefix);
1068
- }
1069
- state.tagMap[handle] = prefix;
1070
- }
1071
- };
1072
- function captureSegment(state, start, end, checkJson) {
1073
- var _position, _length, _character, _result;
1074
- if (start < end) {
1075
- _result = state.input.slice(start, end);
1076
- if (checkJson) {
1077
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1078
- _character = _result.charCodeAt(_position);
1079
- if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1080
- throwError(state, "expected valid JSON character");
1081
- }
1082
- }
1083
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1084
- throwError(state, "the stream contains non-printable characters");
1085
- }
1086
- state.result += _result;
1087
- }
1088
- }
1089
- function mergeMappings(state, destination, source, overridableKeys) {
1090
- var sourceKeys, key, index, quantity;
1091
- if (!common.isObject(source)) {
1092
- throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1093
- }
1094
- sourceKeys = Object.keys(source);
1095
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1096
- key = sourceKeys[index];
1097
- if (!_hasOwnProperty$1.call(destination, key)) {
1098
- destination[key] = source[key];
1099
- overridableKeys[key] = true;
1100
- }
1101
- }
1102
- }
1103
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1104
- var index, quantity;
1105
- if (Array.isArray(keyNode)) {
1106
- keyNode = Array.prototype.slice.call(keyNode);
1107
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1108
- if (Array.isArray(keyNode[index])) {
1109
- throwError(state, "nested arrays are not supported inside keys");
1110
- }
1111
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1112
- keyNode[index] = "[object Object]";
1113
- }
1114
- }
1115
- }
1116
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1117
- keyNode = "[object Object]";
1118
- }
1119
- keyNode = String(keyNode);
1120
- if (_result === null) {
1121
- _result = {};
1122
- }
1123
- if (keyTag === "tag:yaml.org,2002:merge") {
1124
- if (Array.isArray(valueNode)) {
1125
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1126
- mergeMappings(state, _result, valueNode[index], overridableKeys);
1127
- }
1128
- } else {
1129
- mergeMappings(state, _result, valueNode, overridableKeys);
1130
- }
1131
- } else {
1132
- if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1133
- state.line = startLine || state.line;
1134
- state.lineStart = startLineStart || state.lineStart;
1135
- state.position = startPos || state.position;
1136
- throwError(state, "duplicated mapping key");
1137
- }
1138
- if (keyNode === "__proto__") {
1139
- Object.defineProperty(_result, keyNode, {
1140
- configurable: true,
1141
- enumerable: true,
1142
- writable: true,
1143
- value: valueNode
1144
- });
1145
- } else {
1146
- _result[keyNode] = valueNode;
1147
- }
1148
- delete overridableKeys[keyNode];
1149
- }
1150
- return _result;
1151
- }
1152
- function readLineBreak(state) {
1153
- var ch;
1154
- ch = state.input.charCodeAt(state.position);
1155
- if (ch === 10) {
1156
- state.position++;
1157
- } else if (ch === 13) {
1158
- state.position++;
1159
- if (state.input.charCodeAt(state.position) === 10) {
1160
- state.position++;
1161
- }
1162
- } else {
1163
- throwError(state, "a line break is expected");
1164
- }
1165
- state.line += 1;
1166
- state.lineStart = state.position;
1167
- state.firstTabInLine = -1;
1168
- }
1169
- function skipSeparationSpace(state, allowComments, checkIndent) {
1170
- var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1171
- while (ch !== 0) {
1172
- while (is_WHITE_SPACE(ch)) {
1173
- if (ch === 9 && state.firstTabInLine === -1) {
1174
- state.firstTabInLine = state.position;
1175
- }
1176
- ch = state.input.charCodeAt(++state.position);
1177
- }
1178
- if (allowComments && ch === 35) {
1179
- do {
1180
- ch = state.input.charCodeAt(++state.position);
1181
- } while (ch !== 10 && ch !== 13 && ch !== 0);
1182
- }
1183
- if (is_EOL(ch)) {
1184
- readLineBreak(state);
1185
- ch = state.input.charCodeAt(state.position);
1186
- lineBreaks++;
1187
- state.lineIndent = 0;
1188
- while (ch === 32) {
1189
- state.lineIndent++;
1190
- ch = state.input.charCodeAt(++state.position);
1191
- }
1192
- } else {
1193
- break;
1194
- }
1195
- }
1196
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1197
- throwWarning(state, "deficient indentation");
1198
- }
1199
- return lineBreaks;
1200
- }
1201
- function testDocumentSeparator(state) {
1202
- var _position = state.position, ch;
1203
- ch = state.input.charCodeAt(_position);
1204
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1205
- _position += 3;
1206
- ch = state.input.charCodeAt(_position);
1207
- if (ch === 0 || is_WS_OR_EOL(ch)) {
1208
- return true;
1209
- }
1210
- }
1211
- return false;
1212
- }
1213
- function writeFoldedLines(state, count) {
1214
- if (count === 1) {
1215
- state.result += " ";
1216
- } else if (count > 1) {
1217
- state.result += common.repeat("\n", count - 1);
1218
- }
1219
- }
1220
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1221
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1222
- ch = state.input.charCodeAt(state.position);
1223
- if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1224
- return false;
1225
- }
1226
- if (ch === 63 || ch === 45) {
1227
- following = state.input.charCodeAt(state.position + 1);
1228
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1229
- return false;
1230
- }
1231
- }
1232
- state.kind = "scalar";
1233
- state.result = "";
1234
- captureStart = captureEnd = state.position;
1235
- hasPendingContent = false;
1236
- while (ch !== 0) {
1237
- if (ch === 58) {
1238
- following = state.input.charCodeAt(state.position + 1);
1239
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1240
- break;
1241
- }
1242
- } else if (ch === 35) {
1243
- preceding = state.input.charCodeAt(state.position - 1);
1244
- if (is_WS_OR_EOL(preceding)) {
1245
- break;
1246
- }
1247
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1248
- break;
1249
- } else if (is_EOL(ch)) {
1250
- _line = state.line;
1251
- _lineStart = state.lineStart;
1252
- _lineIndent = state.lineIndent;
1253
- skipSeparationSpace(state, false, -1);
1254
- if (state.lineIndent >= nodeIndent) {
1255
- hasPendingContent = true;
1256
- ch = state.input.charCodeAt(state.position);
1257
- continue;
1258
- } else {
1259
- state.position = captureEnd;
1260
- state.line = _line;
1261
- state.lineStart = _lineStart;
1262
- state.lineIndent = _lineIndent;
1263
- break;
1264
- }
1265
- }
1266
- if (hasPendingContent) {
1267
- captureSegment(state, captureStart, captureEnd, false);
1268
- writeFoldedLines(state, state.line - _line);
1269
- captureStart = captureEnd = state.position;
1270
- hasPendingContent = false;
1271
- }
1272
- if (!is_WHITE_SPACE(ch)) {
1273
- captureEnd = state.position + 1;
1274
- }
1275
- ch = state.input.charCodeAt(++state.position);
1276
- }
1277
- captureSegment(state, captureStart, captureEnd, false);
1278
- if (state.result) {
1279
- return true;
1280
- }
1281
- state.kind = _kind;
1282
- state.result = _result;
1283
- return false;
1284
- }
1285
- function readSingleQuotedScalar(state, nodeIndent) {
1286
- var ch, captureStart, captureEnd;
1287
- ch = state.input.charCodeAt(state.position);
1288
- if (ch !== 39) {
1289
- return false;
1290
- }
1291
- state.kind = "scalar";
1292
- state.result = "";
1293
- state.position++;
1294
- captureStart = captureEnd = state.position;
1295
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1296
- if (ch === 39) {
1297
- captureSegment(state, captureStart, state.position, true);
1298
- ch = state.input.charCodeAt(++state.position);
1299
- if (ch === 39) {
1300
- captureStart = state.position;
1301
- state.position++;
1302
- captureEnd = state.position;
1303
- } else {
1304
- return true;
1305
- }
1306
- } else if (is_EOL(ch)) {
1307
- captureSegment(state, captureStart, captureEnd, true);
1308
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1309
- captureStart = captureEnd = state.position;
1310
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1311
- throwError(state, "unexpected end of the document within a single quoted scalar");
1312
- } else {
1313
- state.position++;
1314
- captureEnd = state.position;
1315
- }
1316
- }
1317
- throwError(state, "unexpected end of the stream within a single quoted scalar");
1318
- }
1319
- function readDoubleQuotedScalar(state, nodeIndent) {
1320
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1321
- ch = state.input.charCodeAt(state.position);
1322
- if (ch !== 34) {
1323
- return false;
1324
- }
1325
- state.kind = "scalar";
1326
- state.result = "";
1327
- state.position++;
1328
- captureStart = captureEnd = state.position;
1329
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1330
- if (ch === 34) {
1331
- captureSegment(state, captureStart, state.position, true);
1332
- state.position++;
1333
- return true;
1334
- } else if (ch === 92) {
1335
- captureSegment(state, captureStart, state.position, true);
1336
- ch = state.input.charCodeAt(++state.position);
1337
- if (is_EOL(ch)) {
1338
- skipSeparationSpace(state, false, nodeIndent);
1339
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
1340
- state.result += simpleEscapeMap[ch];
1341
- state.position++;
1342
- } else if ((tmp = escapedHexLen(ch)) > 0) {
1343
- hexLength = tmp;
1344
- hexResult = 0;
1345
- for (; hexLength > 0; hexLength--) {
1346
- ch = state.input.charCodeAt(++state.position);
1347
- if ((tmp = fromHexCode(ch)) >= 0) {
1348
- hexResult = (hexResult << 4) + tmp;
1349
- } else {
1350
- throwError(state, "expected hexadecimal character");
1351
- }
1352
- }
1353
- state.result += charFromCodepoint(hexResult);
1354
- state.position++;
1355
- } else {
1356
- throwError(state, "unknown escape sequence");
1357
- }
1358
- captureStart = captureEnd = state.position;
1359
- } else if (is_EOL(ch)) {
1360
- captureSegment(state, captureStart, captureEnd, true);
1361
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1362
- captureStart = captureEnd = state.position;
1363
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1364
- throwError(state, "unexpected end of the document within a double quoted scalar");
1365
- } else {
1366
- state.position++;
1367
- captureEnd = state.position;
1368
- }
1369
- }
1370
- throwError(state, "unexpected end of the stream within a double quoted scalar");
1371
- }
1372
- function readFlowCollection(state, nodeIndent) {
1373
- var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
1374
- ch = state.input.charCodeAt(state.position);
1375
- if (ch === 91) {
1376
- terminator = 93;
1377
- isMapping = false;
1378
- _result = [];
1379
- } else if (ch === 123) {
1380
- terminator = 125;
1381
- isMapping = true;
1382
- _result = {};
1383
- } else {
1384
- return false;
1385
- }
1386
- if (state.anchor !== null) {
1387
- state.anchorMap[state.anchor] = _result;
1388
- }
1389
- ch = state.input.charCodeAt(++state.position);
1390
- while (ch !== 0) {
1391
- skipSeparationSpace(state, true, nodeIndent);
1392
- ch = state.input.charCodeAt(state.position);
1393
- if (ch === terminator) {
1394
- state.position++;
1395
- state.tag = _tag;
1396
- state.anchor = _anchor;
1397
- state.kind = isMapping ? "mapping" : "sequence";
1398
- state.result = _result;
1399
- return true;
1400
- } else if (!readNext) {
1401
- throwError(state, "missed comma between flow collection entries");
1402
- } else if (ch === 44) {
1403
- throwError(state, "expected the node content, but found ','");
1404
- }
1405
- keyTag = keyNode = valueNode = null;
1406
- isPair = isExplicitPair = false;
1407
- if (ch === 63) {
1408
- following = state.input.charCodeAt(state.position + 1);
1409
- if (is_WS_OR_EOL(following)) {
1410
- isPair = isExplicitPair = true;
1411
- state.position++;
1412
- skipSeparationSpace(state, true, nodeIndent);
1413
- }
1414
- }
1415
- _line = state.line;
1416
- _lineStart = state.lineStart;
1417
- _pos = state.position;
1418
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1419
- keyTag = state.tag;
1420
- keyNode = state.result;
1421
- skipSeparationSpace(state, true, nodeIndent);
1422
- ch = state.input.charCodeAt(state.position);
1423
- if ((isExplicitPair || state.line === _line) && ch === 58) {
1424
- isPair = true;
1425
- ch = state.input.charCodeAt(++state.position);
1426
- skipSeparationSpace(state, true, nodeIndent);
1427
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1428
- valueNode = state.result;
1429
- }
1430
- if (isMapping) {
1431
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1432
- } else if (isPair) {
1433
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1434
- } else {
1435
- _result.push(keyNode);
1436
- }
1437
- skipSeparationSpace(state, true, nodeIndent);
1438
- ch = state.input.charCodeAt(state.position);
1439
- if (ch === 44) {
1440
- readNext = true;
1441
- ch = state.input.charCodeAt(++state.position);
1442
- } else {
1443
- readNext = false;
1444
- }
1445
- }
1446
- throwError(state, "unexpected end of the stream within a flow collection");
1447
- }
1448
- function readBlockScalar(state, nodeIndent) {
1449
- var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1450
- ch = state.input.charCodeAt(state.position);
1451
- if (ch === 124) {
1452
- folding = false;
1453
- } else if (ch === 62) {
1454
- folding = true;
1455
- } else {
1456
- return false;
1457
- }
1458
- state.kind = "scalar";
1459
- state.result = "";
1460
- while (ch !== 0) {
1461
- ch = state.input.charCodeAt(++state.position);
1462
- if (ch === 43 || ch === 45) {
1463
- if (CHOMPING_CLIP === chomping) {
1464
- chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1465
- } else {
1466
- throwError(state, "repeat of a chomping mode identifier");
1467
- }
1468
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1469
- if (tmp === 0) {
1470
- throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1471
- } else if (!detectedIndent) {
1472
- textIndent = nodeIndent + tmp - 1;
1473
- detectedIndent = true;
1474
- } else {
1475
- throwError(state, "repeat of an indentation width identifier");
1476
- }
1477
- } else {
1478
- break;
1479
- }
1480
- }
1481
- if (is_WHITE_SPACE(ch)) {
1482
- do {
1483
- ch = state.input.charCodeAt(++state.position);
1484
- } while (is_WHITE_SPACE(ch));
1485
- if (ch === 35) {
1486
- do {
1487
- ch = state.input.charCodeAt(++state.position);
1488
- } while (!is_EOL(ch) && ch !== 0);
1489
- }
1490
- }
1491
- while (ch !== 0) {
1492
- readLineBreak(state);
1493
- state.lineIndent = 0;
1494
- ch = state.input.charCodeAt(state.position);
1495
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1496
- state.lineIndent++;
1497
- ch = state.input.charCodeAt(++state.position);
1498
- }
1499
- if (!detectedIndent && state.lineIndent > textIndent) {
1500
- textIndent = state.lineIndent;
1501
- }
1502
- if (is_EOL(ch)) {
1503
- emptyLines++;
1504
- continue;
1505
- }
1506
- if (state.lineIndent < textIndent) {
1507
- if (chomping === CHOMPING_KEEP) {
1508
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1509
- } else if (chomping === CHOMPING_CLIP) {
1510
- if (didReadContent) {
1511
- state.result += "\n";
1512
- }
1513
- }
1514
- break;
1515
- }
1516
- if (folding) {
1517
- if (is_WHITE_SPACE(ch)) {
1518
- atMoreIndented = true;
1519
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1520
- } else if (atMoreIndented) {
1521
- atMoreIndented = false;
1522
- state.result += common.repeat("\n", emptyLines + 1);
1523
- } else if (emptyLines === 0) {
1524
- if (didReadContent) {
1525
- state.result += " ";
1526
- }
1527
- } else {
1528
- state.result += common.repeat("\n", emptyLines);
1529
- }
1530
- } else {
1531
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1532
- }
1533
- didReadContent = true;
1534
- detectedIndent = true;
1535
- emptyLines = 0;
1536
- captureStart = state.position;
1537
- while (!is_EOL(ch) && ch !== 0) {
1538
- ch = state.input.charCodeAt(++state.position);
1539
- }
1540
- captureSegment(state, captureStart, state.position, false);
1541
- }
1542
- return true;
1543
- }
1544
- function readBlockSequence(state, nodeIndent) {
1545
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1546
- if (state.firstTabInLine !== -1) return false;
1547
- if (state.anchor !== null) {
1548
- state.anchorMap[state.anchor] = _result;
1549
- }
1550
- ch = state.input.charCodeAt(state.position);
1551
- while (ch !== 0) {
1552
- if (state.firstTabInLine !== -1) {
1553
- state.position = state.firstTabInLine;
1554
- throwError(state, "tab characters must not be used in indentation");
1555
- }
1556
- if (ch !== 45) {
1557
- break;
1558
- }
1559
- following = state.input.charCodeAt(state.position + 1);
1560
- if (!is_WS_OR_EOL(following)) {
1561
- break;
1562
- }
1563
- detected = true;
1564
- state.position++;
1565
- if (skipSeparationSpace(state, true, -1)) {
1566
- if (state.lineIndent <= nodeIndent) {
1567
- _result.push(null);
1568
- ch = state.input.charCodeAt(state.position);
1569
- continue;
1570
- }
1571
- }
1572
- _line = state.line;
1573
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1574
- _result.push(state.result);
1575
- skipSeparationSpace(state, true, -1);
1576
- ch = state.input.charCodeAt(state.position);
1577
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1578
- throwError(state, "bad indentation of a sequence entry");
1579
- } else if (state.lineIndent < nodeIndent) {
1580
- break;
1581
- }
1582
- }
1583
- if (detected) {
1584
- state.tag = _tag;
1585
- state.anchor = _anchor;
1586
- state.kind = "sequence";
1587
- state.result = _result;
1588
- return true;
1589
- }
1590
- return false;
1591
- }
1592
- function readBlockMapping(state, nodeIndent, flowIndent) {
1593
- var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1594
- if (state.firstTabInLine !== -1) return false;
1595
- if (state.anchor !== null) {
1596
- state.anchorMap[state.anchor] = _result;
1597
- }
1598
- ch = state.input.charCodeAt(state.position);
1599
- while (ch !== 0) {
1600
- if (!atExplicitKey && state.firstTabInLine !== -1) {
1601
- state.position = state.firstTabInLine;
1602
- throwError(state, "tab characters must not be used in indentation");
1603
- }
1604
- following = state.input.charCodeAt(state.position + 1);
1605
- _line = state.line;
1606
- if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1607
- if (ch === 63) {
1608
- if (atExplicitKey) {
1609
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1610
- keyTag = keyNode = valueNode = null;
1611
- }
1612
- detected = true;
1613
- atExplicitKey = true;
1614
- allowCompact = true;
1615
- } else if (atExplicitKey) {
1616
- atExplicitKey = false;
1617
- allowCompact = true;
1618
- } else {
1619
- throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1620
- }
1621
- state.position += 1;
1622
- ch = following;
1623
- } else {
1624
- _keyLine = state.line;
1625
- _keyLineStart = state.lineStart;
1626
- _keyPos = state.position;
1627
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1628
- break;
1629
- }
1630
- if (state.line === _line) {
1631
- ch = state.input.charCodeAt(state.position);
1632
- while (is_WHITE_SPACE(ch)) {
1633
- ch = state.input.charCodeAt(++state.position);
1634
- }
1635
- if (ch === 58) {
1636
- ch = state.input.charCodeAt(++state.position);
1637
- if (!is_WS_OR_EOL(ch)) {
1638
- throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1639
- }
1640
- if (atExplicitKey) {
1641
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1642
- keyTag = keyNode = valueNode = null;
1643
- }
1644
- detected = true;
1645
- atExplicitKey = false;
1646
- allowCompact = false;
1647
- keyTag = state.tag;
1648
- keyNode = state.result;
1649
- } else if (detected) {
1650
- throwError(state, "can not read an implicit mapping pair; a colon is missed");
1651
- } else {
1652
- state.tag = _tag;
1653
- state.anchor = _anchor;
1654
- return true;
1655
- }
1656
- } else if (detected) {
1657
- throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1658
- } else {
1659
- state.tag = _tag;
1660
- state.anchor = _anchor;
1661
- return true;
1662
- }
1663
- }
1664
- if (state.line === _line || state.lineIndent > nodeIndent) {
1665
- if (atExplicitKey) {
1666
- _keyLine = state.line;
1667
- _keyLineStart = state.lineStart;
1668
- _keyPos = state.position;
1669
- }
1670
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1671
- if (atExplicitKey) {
1672
- keyNode = state.result;
1673
- } else {
1674
- valueNode = state.result;
1675
- }
1676
- }
1677
- if (!atExplicitKey) {
1678
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1679
- keyTag = keyNode = valueNode = null;
1680
- }
1681
- skipSeparationSpace(state, true, -1);
1682
- ch = state.input.charCodeAt(state.position);
1683
- }
1684
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1685
- throwError(state, "bad indentation of a mapping entry");
1686
- } else if (state.lineIndent < nodeIndent) {
1687
- break;
1688
- }
1689
- }
1690
- if (atExplicitKey) {
1691
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1692
- }
1693
- if (detected) {
1694
- state.tag = _tag;
1695
- state.anchor = _anchor;
1696
- state.kind = "mapping";
1697
- state.result = _result;
1698
- }
1699
- return detected;
1700
- }
1701
- function readTagProperty(state) {
1702
- var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1703
- ch = state.input.charCodeAt(state.position);
1704
- if (ch !== 33) return false;
1705
- if (state.tag !== null) {
1706
- throwError(state, "duplication of a tag property");
1707
- }
1708
- ch = state.input.charCodeAt(++state.position);
1709
- if (ch === 60) {
1710
- isVerbatim = true;
1711
- ch = state.input.charCodeAt(++state.position);
1712
- } else if (ch === 33) {
1713
- isNamed = true;
1714
- tagHandle = "!!";
1715
- ch = state.input.charCodeAt(++state.position);
1716
- } else {
1717
- tagHandle = "!";
1718
- }
1719
- _position = state.position;
1720
- if (isVerbatim) {
1721
- do {
1722
- ch = state.input.charCodeAt(++state.position);
1723
- } while (ch !== 0 && ch !== 62);
1724
- if (state.position < state.length) {
1725
- tagName = state.input.slice(_position, state.position);
1726
- ch = state.input.charCodeAt(++state.position);
1727
- } else {
1728
- throwError(state, "unexpected end of the stream within a verbatim tag");
1729
- }
1730
- } else {
1731
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1732
- if (ch === 33) {
1733
- if (!isNamed) {
1734
- tagHandle = state.input.slice(_position - 1, state.position + 1);
1735
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1736
- throwError(state, "named tag handle cannot contain such characters");
1737
- }
1738
- isNamed = true;
1739
- _position = state.position + 1;
1740
- } else {
1741
- throwError(state, "tag suffix cannot contain exclamation marks");
1742
- }
1743
- }
1744
- ch = state.input.charCodeAt(++state.position);
1745
- }
1746
- tagName = state.input.slice(_position, state.position);
1747
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1748
- throwError(state, "tag suffix cannot contain flow indicator characters");
1749
- }
1750
- }
1751
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1752
- throwError(state, "tag name cannot contain such characters: " + tagName);
1753
- }
1754
- try {
1755
- tagName = decodeURIComponent(tagName);
1756
- } catch (err) {
1757
- throwError(state, "tag name is malformed: " + tagName);
1758
- }
1759
- if (isVerbatim) {
1760
- state.tag = tagName;
1761
- } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
1762
- state.tag = state.tagMap[tagHandle] + tagName;
1763
- } else if (tagHandle === "!") {
1764
- state.tag = "!" + tagName;
1765
- } else if (tagHandle === "!!") {
1766
- state.tag = "tag:yaml.org,2002:" + tagName;
1767
- } else {
1768
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1769
- }
1770
- return true;
1771
- }
1772
- function readAnchorProperty(state) {
1773
- var _position, ch;
1774
- ch = state.input.charCodeAt(state.position);
1775
- if (ch !== 38) return false;
1776
- if (state.anchor !== null) {
1777
- throwError(state, "duplication of an anchor property");
1778
- }
1779
- ch = state.input.charCodeAt(++state.position);
1780
- _position = state.position;
1781
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1782
- ch = state.input.charCodeAt(++state.position);
1783
- }
1784
- if (state.position === _position) {
1785
- throwError(state, "name of an anchor node must contain at least one character");
1786
- }
1787
- state.anchor = state.input.slice(_position, state.position);
1788
- return true;
1789
- }
1790
- function readAlias(state) {
1791
- var _position, alias, ch;
1792
- ch = state.input.charCodeAt(state.position);
1793
- if (ch !== 42) return false;
1794
- ch = state.input.charCodeAt(++state.position);
1795
- _position = state.position;
1796
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1797
- ch = state.input.charCodeAt(++state.position);
1798
- }
1799
- if (state.position === _position) {
1800
- throwError(state, "name of an alias node must contain at least one character");
1801
- }
1802
- alias = state.input.slice(_position, state.position);
1803
- if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
1804
- throwError(state, 'unidentified alias "' + alias + '"');
1805
- }
1806
- state.result = state.anchorMap[alias];
1807
- skipSeparationSpace(state, true, -1);
1808
- return true;
1809
- }
1810
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1811
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
1812
- if (state.listener !== null) {
1813
- state.listener("open", state);
1814
- }
1815
- state.tag = null;
1816
- state.anchor = null;
1817
- state.kind = null;
1818
- state.result = null;
1819
- allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1820
- if (allowToSeek) {
1821
- if (skipSeparationSpace(state, true, -1)) {
1822
- atNewLine = true;
1823
- if (state.lineIndent > parentIndent) {
1824
- indentStatus = 1;
1825
- } else if (state.lineIndent === parentIndent) {
1826
- indentStatus = 0;
1827
- } else if (state.lineIndent < parentIndent) {
1828
- indentStatus = -1;
1829
- }
1830
- }
1831
- }
1832
- if (indentStatus === 1) {
1833
- while (readTagProperty(state) || readAnchorProperty(state)) {
1834
- if (skipSeparationSpace(state, true, -1)) {
1835
- atNewLine = true;
1836
- allowBlockCollections = allowBlockStyles;
1837
- if (state.lineIndent > parentIndent) {
1838
- indentStatus = 1;
1839
- } else if (state.lineIndent === parentIndent) {
1840
- indentStatus = 0;
1841
- } else if (state.lineIndent < parentIndent) {
1842
- indentStatus = -1;
1843
- }
1844
- } else {
1845
- allowBlockCollections = false;
1846
- }
1847
- }
1848
- }
1849
- if (allowBlockCollections) {
1850
- allowBlockCollections = atNewLine || allowCompact;
1851
- }
1852
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1853
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1854
- flowIndent = parentIndent;
1855
- } else {
1856
- flowIndent = parentIndent + 1;
1857
- }
1858
- blockIndent = state.position - state.lineStart;
1859
- if (indentStatus === 1) {
1860
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1861
- hasContent = true;
1862
- } else {
1863
- if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1864
- hasContent = true;
1865
- } else if (readAlias(state)) {
1866
- hasContent = true;
1867
- if (state.tag !== null || state.anchor !== null) {
1868
- throwError(state, "alias node should not have any properties");
1869
- }
1870
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1871
- hasContent = true;
1872
- if (state.tag === null) {
1873
- state.tag = "?";
1874
- }
1875
- }
1876
- if (state.anchor !== null) {
1877
- state.anchorMap[state.anchor] = state.result;
1878
- }
1879
- }
1880
- } else if (indentStatus === 0) {
1881
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1882
- }
1883
- }
1884
- if (state.tag === null) {
1885
- if (state.anchor !== null) {
1886
- state.anchorMap[state.anchor] = state.result;
1887
- }
1888
- } else if (state.tag === "?") {
1889
- if (state.result !== null && state.kind !== "scalar") {
1890
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1891
- }
1892
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1893
- type2 = state.implicitTypes[typeIndex];
1894
- if (type2.resolve(state.result)) {
1895
- state.result = type2.construct(state.result);
1896
- state.tag = type2.tag;
1897
- if (state.anchor !== null) {
1898
- state.anchorMap[state.anchor] = state.result;
1899
- }
1900
- break;
1901
- }
1902
- }
1903
- } else if (state.tag !== "!") {
1904
- if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
1905
- type2 = state.typeMap[state.kind || "fallback"][state.tag];
1906
- } else {
1907
- type2 = null;
1908
- typeList = state.typeMap.multi[state.kind || "fallback"];
1909
- for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
1910
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
1911
- type2 = typeList[typeIndex];
1912
- break;
1913
- }
1914
- }
1915
- }
1916
- if (!type2) {
1917
- throwError(state, "unknown tag !<" + state.tag + ">");
1918
- }
1919
- if (state.result !== null && type2.kind !== state.kind) {
1920
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
1921
- }
1922
- if (!type2.resolve(state.result, state.tag)) {
1923
- throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
1924
- } else {
1925
- state.result = type2.construct(state.result, state.tag);
1926
- if (state.anchor !== null) {
1927
- state.anchorMap[state.anchor] = state.result;
1928
- }
1929
- }
1930
- }
1931
- if (state.listener !== null) {
1932
- state.listener("close", state);
1933
- }
1934
- return state.tag !== null || state.anchor !== null || hasContent;
1935
- }
1936
- function readDocument(state) {
1937
- var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
1938
- state.version = null;
1939
- state.checkLineBreaks = state.legacy;
1940
- state.tagMap = /* @__PURE__ */ Object.create(null);
1941
- state.anchorMap = /* @__PURE__ */ Object.create(null);
1942
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1943
- skipSeparationSpace(state, true, -1);
1944
- ch = state.input.charCodeAt(state.position);
1945
- if (state.lineIndent > 0 || ch !== 37) {
1946
- break;
1947
- }
1948
- hasDirectives = true;
1949
- ch = state.input.charCodeAt(++state.position);
1950
- _position = state.position;
1951
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1952
- ch = state.input.charCodeAt(++state.position);
1953
- }
1954
- directiveName = state.input.slice(_position, state.position);
1955
- directiveArgs = [];
1956
- if (directiveName.length < 1) {
1957
- throwError(state, "directive name must not be less than one character in length");
1958
- }
1959
- while (ch !== 0) {
1960
- while (is_WHITE_SPACE(ch)) {
1961
- ch = state.input.charCodeAt(++state.position);
1962
- }
1963
- if (ch === 35) {
1964
- do {
1965
- ch = state.input.charCodeAt(++state.position);
1966
- } while (ch !== 0 && !is_EOL(ch));
1967
- break;
1968
- }
1969
- if (is_EOL(ch)) break;
1970
- _position = state.position;
1971
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1972
- ch = state.input.charCodeAt(++state.position);
1973
- }
1974
- directiveArgs.push(state.input.slice(_position, state.position));
1975
- }
1976
- if (ch !== 0) readLineBreak(state);
1977
- if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
1978
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
1979
- } else {
1980
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
1981
- }
1982
- }
1983
- skipSeparationSpace(state, true, -1);
1984
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
1985
- state.position += 3;
1986
- skipSeparationSpace(state, true, -1);
1987
- } else if (hasDirectives) {
1988
- throwError(state, "directives end mark is expected");
1989
- }
1990
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
1991
- skipSeparationSpace(state, true, -1);
1992
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
1993
- throwWarning(state, "non-ASCII line breaks are interpreted as content");
1994
- }
1995
- state.documents.push(state.result);
1996
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
1997
- if (state.input.charCodeAt(state.position) === 46) {
1998
- state.position += 3;
1999
- skipSeparationSpace(state, true, -1);
2000
- }
2001
- return;
2002
- }
2003
- if (state.position < state.length - 1) {
2004
- throwError(state, "end of the stream or a document separator is expected");
2005
- } else {
2006
- return;
2007
- }
2008
- }
2009
- function loadDocuments(input, options) {
2010
- input = String(input);
2011
- options = options || {};
2012
- if (input.length !== 0) {
2013
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2014
- input += "\n";
2015
- }
2016
- if (input.charCodeAt(0) === 65279) {
2017
- input = input.slice(1);
2018
- }
2019
- }
2020
- var state = new State$1(input, options);
2021
- var nullpos = input.indexOf("\0");
2022
- if (nullpos !== -1) {
2023
- state.position = nullpos;
2024
- throwError(state, "null byte is not allowed in input");
2025
- }
2026
- state.input += "\0";
2027
- while (state.input.charCodeAt(state.position) === 32) {
2028
- state.lineIndent += 1;
2029
- state.position += 1;
2030
- }
2031
- while (state.position < state.length - 1) {
2032
- readDocument(state);
2033
- }
2034
- return state.documents;
2035
- }
2036
- function loadAll$1(input, iterator, options) {
2037
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2038
- options = iterator;
2039
- iterator = null;
2040
- }
2041
- var documents = loadDocuments(input, options);
2042
- if (typeof iterator !== "function") {
2043
- return documents;
2044
- }
2045
- for (var index = 0, length = documents.length; index < length; index += 1) {
2046
- iterator(documents[index]);
2047
- }
2048
- }
2049
- function load$1(input, options) {
2050
- var documents = loadDocuments(input, options);
2051
- if (documents.length === 0) {
2052
- return void 0;
2053
- } else if (documents.length === 1) {
2054
- return documents[0];
2055
- }
2056
- throw new exception("expected a single document in the stream, but found more");
2057
- }
2058
- var loadAll_1 = loadAll$1;
2059
- var load_1 = load$1;
2060
- var loader = {
2061
- loadAll: loadAll_1,
2062
- load: load_1
2063
- };
2064
- var _toString = Object.prototype.toString;
2065
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
2066
- var CHAR_BOM = 65279;
2067
- var CHAR_TAB = 9;
2068
- var CHAR_LINE_FEED = 10;
2069
- var CHAR_CARRIAGE_RETURN = 13;
2070
- var CHAR_SPACE = 32;
2071
- var CHAR_EXCLAMATION = 33;
2072
- var CHAR_DOUBLE_QUOTE = 34;
2073
- var CHAR_SHARP = 35;
2074
- var CHAR_PERCENT = 37;
2075
- var CHAR_AMPERSAND = 38;
2076
- var CHAR_SINGLE_QUOTE = 39;
2077
- var CHAR_ASTERISK = 42;
2078
- var CHAR_COMMA = 44;
2079
- var CHAR_MINUS = 45;
2080
- var CHAR_COLON = 58;
2081
- var CHAR_EQUALS = 61;
2082
- var CHAR_GREATER_THAN = 62;
2083
- var CHAR_QUESTION = 63;
2084
- var CHAR_COMMERCIAL_AT = 64;
2085
- var CHAR_LEFT_SQUARE_BRACKET = 91;
2086
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
2087
- var CHAR_GRAVE_ACCENT = 96;
2088
- var CHAR_LEFT_CURLY_BRACKET = 123;
2089
- var CHAR_VERTICAL_LINE = 124;
2090
- var CHAR_RIGHT_CURLY_BRACKET = 125;
2091
- var ESCAPE_SEQUENCES = {};
2092
- ESCAPE_SEQUENCES[0] = "\\0";
2093
- ESCAPE_SEQUENCES[7] = "\\a";
2094
- ESCAPE_SEQUENCES[8] = "\\b";
2095
- ESCAPE_SEQUENCES[9] = "\\t";
2096
- ESCAPE_SEQUENCES[10] = "\\n";
2097
- ESCAPE_SEQUENCES[11] = "\\v";
2098
- ESCAPE_SEQUENCES[12] = "\\f";
2099
- ESCAPE_SEQUENCES[13] = "\\r";
2100
- ESCAPE_SEQUENCES[27] = "\\e";
2101
- ESCAPE_SEQUENCES[34] = '\\"';
2102
- ESCAPE_SEQUENCES[92] = "\\\\";
2103
- ESCAPE_SEQUENCES[133] = "\\N";
2104
- ESCAPE_SEQUENCES[160] = "\\_";
2105
- ESCAPE_SEQUENCES[8232] = "\\L";
2106
- ESCAPE_SEQUENCES[8233] = "\\P";
2107
- var DEPRECATED_BOOLEANS_SYNTAX = [
2108
- "y",
2109
- "Y",
2110
- "yes",
2111
- "Yes",
2112
- "YES",
2113
- "on",
2114
- "On",
2115
- "ON",
2116
- "n",
2117
- "N",
2118
- "no",
2119
- "No",
2120
- "NO",
2121
- "off",
2122
- "Off",
2123
- "OFF"
2124
- ];
2125
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2126
- function compileStyleMap(schema2, map2) {
2127
- var result, keys, index, length, tag, style, type2;
2128
- if (map2 === null) return {};
2129
- result = {};
2130
- keys = Object.keys(map2);
2131
- for (index = 0, length = keys.length; index < length; index += 1) {
2132
- tag = keys[index];
2133
- style = String(map2[tag]);
2134
- if (tag.slice(0, 2) === "!!") {
2135
- tag = "tag:yaml.org,2002:" + tag.slice(2);
2136
- }
2137
- type2 = schema2.compiledTypeMap["fallback"][tag];
2138
- if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2139
- style = type2.styleAliases[style];
2140
- }
2141
- result[tag] = style;
2142
- }
2143
- return result;
2144
- }
2145
- function encodeHex(character) {
2146
- var string, handle, length;
2147
- string = character.toString(16).toUpperCase();
2148
- if (character <= 255) {
2149
- handle = "x";
2150
- length = 2;
2151
- } else if (character <= 65535) {
2152
- handle = "u";
2153
- length = 4;
2154
- } else if (character <= 4294967295) {
2155
- handle = "U";
2156
- length = 8;
2157
- } else {
2158
- throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
2159
- }
2160
- return "\\" + handle + common.repeat("0", length - string.length) + string;
2161
- }
2162
- var QUOTING_TYPE_SINGLE = 1;
2163
- var QUOTING_TYPE_DOUBLE = 2;
2164
- function State(options) {
2165
- this.schema = options["schema"] || _default;
2166
- this.indent = Math.max(1, options["indent"] || 2);
2167
- this.noArrayIndent = options["noArrayIndent"] || false;
2168
- this.skipInvalid = options["skipInvalid"] || false;
2169
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2170
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2171
- this.sortKeys = options["sortKeys"] || false;
2172
- this.lineWidth = options["lineWidth"] || 80;
2173
- this.noRefs = options["noRefs"] || false;
2174
- this.noCompatMode = options["noCompatMode"] || false;
2175
- this.condenseFlow = options["condenseFlow"] || false;
2176
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2177
- this.forceQuotes = options["forceQuotes"] || false;
2178
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2179
- this.implicitTypes = this.schema.compiledImplicit;
2180
- this.explicitTypes = this.schema.compiledExplicit;
2181
- this.tag = null;
2182
- this.result = "";
2183
- this.duplicates = [];
2184
- this.usedDuplicates = null;
2185
- }
2186
- function indentString(string, spaces) {
2187
- var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2188
- while (position < length) {
2189
- next = string.indexOf("\n", position);
2190
- if (next === -1) {
2191
- line = string.slice(position);
2192
- position = length;
2193
- } else {
2194
- line = string.slice(position, next + 1);
2195
- position = next + 1;
2196
- }
2197
- if (line.length && line !== "\n") result += ind;
2198
- result += line;
2199
- }
2200
- return result;
2201
- }
2202
- function generateNextLine(state, level) {
2203
- return "\n" + common.repeat(" ", state.indent * level);
2204
- }
2205
- function testImplicitResolving(state, str2) {
2206
- var index, length, type2;
2207
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2208
- type2 = state.implicitTypes[index];
2209
- if (type2.resolve(str2)) {
2210
- return true;
2211
- }
2212
- }
2213
- return false;
2214
- }
2215
- function isWhitespace(c) {
2216
- return c === CHAR_SPACE || c === CHAR_TAB;
2217
- }
2218
- function isPrintable(c) {
2219
- return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2220
- }
2221
- function isNsCharOrWhitespace(c) {
2222
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2223
- }
2224
- function isPlainSafe(c, prev, inblock) {
2225
- var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2226
- var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2227
- return (
2228
- // ns-plain-safe
2229
- (inblock ? (
2230
- // c = flow-in
2231
- cIsNsCharOrWhitespace
2232
- ) : 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
2233
- );
2234
- }
2235
- function isPlainSafeFirst(c) {
2236
- 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;
2237
- }
2238
- function isPlainSafeLast(c) {
2239
- return !isWhitespace(c) && c !== CHAR_COLON;
2240
- }
2241
- function codePointAt(string, pos) {
2242
- var first = string.charCodeAt(pos), second;
2243
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2244
- second = string.charCodeAt(pos + 1);
2245
- if (second >= 56320 && second <= 57343) {
2246
- return (first - 55296) * 1024 + second - 56320 + 65536;
2247
- }
2248
- }
2249
- return first;
2250
- }
2251
- function needIndentIndicator(string) {
2252
- var leadingSpaceRe = /^\n* /;
2253
- return leadingSpaceRe.test(string);
2254
- }
2255
- var STYLE_PLAIN = 1;
2256
- var STYLE_SINGLE = 2;
2257
- var STYLE_LITERAL = 3;
2258
- var STYLE_FOLDED = 4;
2259
- var STYLE_DOUBLE = 5;
2260
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2261
- var i;
2262
- var char = 0;
2263
- var prevChar = null;
2264
- var hasLineBreak = false;
2265
- var hasFoldableLine = false;
2266
- var shouldTrackWidth = lineWidth !== -1;
2267
- var previousLineBreak = -1;
2268
- var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2269
- if (singleLineOnly || forceQuotes) {
2270
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2271
- char = codePointAt(string, i);
2272
- if (!isPrintable(char)) {
2273
- return STYLE_DOUBLE;
2274
- }
2275
- plain = plain && isPlainSafe(char, prevChar, inblock);
2276
- prevChar = char;
2277
- }
2278
- } else {
2279
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2280
- char = codePointAt(string, i);
2281
- if (char === CHAR_LINE_FEED) {
2282
- hasLineBreak = true;
2283
- if (shouldTrackWidth) {
2284
- hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2285
- i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2286
- previousLineBreak = i;
2287
- }
2288
- } else if (!isPrintable(char)) {
2289
- return STYLE_DOUBLE;
2290
- }
2291
- plain = plain && isPlainSafe(char, prevChar, inblock);
2292
- prevChar = char;
2293
- }
2294
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2295
- }
2296
- if (!hasLineBreak && !hasFoldableLine) {
2297
- if (plain && !forceQuotes && !testAmbiguousType(string)) {
2298
- return STYLE_PLAIN;
2299
- }
2300
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2301
- }
2302
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
2303
- return STYLE_DOUBLE;
2304
- }
2305
- if (!forceQuotes) {
2306
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2307
- }
2308
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2309
- }
2310
- function writeScalar(state, string, level, iskey, inblock) {
2311
- state.dump = (function() {
2312
- if (string.length === 0) {
2313
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2314
- }
2315
- if (!state.noCompatMode) {
2316
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2317
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2318
- }
2319
- }
2320
- var indent = state.indent * Math.max(1, level);
2321
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2322
- var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2323
- function testAmbiguity(string2) {
2324
- return testImplicitResolving(state, string2);
2325
- }
2326
- switch (chooseScalarStyle(
2327
- string,
2328
- singleLineOnly,
2329
- state.indent,
2330
- lineWidth,
2331
- testAmbiguity,
2332
- state.quotingType,
2333
- state.forceQuotes && !iskey,
2334
- inblock
2335
- )) {
2336
- case STYLE_PLAIN:
2337
- return string;
2338
- case STYLE_SINGLE:
2339
- return "'" + string.replace(/'/g, "''") + "'";
2340
- case STYLE_LITERAL:
2341
- return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2342
- case STYLE_FOLDED:
2343
- return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2344
- case STYLE_DOUBLE:
2345
- return '"' + escapeString(string) + '"';
2346
- default:
2347
- throw new exception("impossible error: invalid scalar style");
2348
- }
2349
- })();
2350
- }
2351
- function blockHeader(string, indentPerLevel) {
2352
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2353
- var clip = string[string.length - 1] === "\n";
2354
- var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2355
- var chomp = keep ? "+" : clip ? "" : "-";
2356
- return indentIndicator + chomp + "\n";
2357
- }
2358
- function dropEndingNewline(string) {
2359
- return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2360
- }
2361
- function foldString(string, width) {
2362
- var lineRe = /(\n+)([^\n]*)/g;
2363
- var result = (function() {
2364
- var nextLF = string.indexOf("\n");
2365
- nextLF = nextLF !== -1 ? nextLF : string.length;
2366
- lineRe.lastIndex = nextLF;
2367
- return foldLine(string.slice(0, nextLF), width);
2368
- })();
2369
- var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2370
- var moreIndented;
2371
- var match;
2372
- while (match = lineRe.exec(string)) {
2373
- var prefix = match[1], line = match[2];
2374
- moreIndented = line[0] === " ";
2375
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2376
- prevMoreIndented = moreIndented;
2377
- }
2378
- return result;
2379
- }
2380
- function foldLine(line, width) {
2381
- if (line === "" || line[0] === " ") return line;
2382
- var breakRe = / [^ ]/g;
2383
- var match;
2384
- var start = 0, end, curr = 0, next = 0;
2385
- var result = "";
2386
- while (match = breakRe.exec(line)) {
2387
- next = match.index;
2388
- if (next - start > width) {
2389
- end = curr > start ? curr : next;
2390
- result += "\n" + line.slice(start, end);
2391
- start = end + 1;
2392
- }
2393
- curr = next;
2394
- }
2395
- result += "\n";
2396
- if (line.length - start > width && curr > start) {
2397
- result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2398
- } else {
2399
- result += line.slice(start);
2400
- }
2401
- return result.slice(1);
2402
- }
2403
- function escapeString(string) {
2404
- var result = "";
2405
- var char = 0;
2406
- var escapeSeq;
2407
- for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2408
- char = codePointAt(string, i);
2409
- escapeSeq = ESCAPE_SEQUENCES[char];
2410
- if (!escapeSeq && isPrintable(char)) {
2411
- result += string[i];
2412
- if (char >= 65536) result += string[i + 1];
2413
- } else {
2414
- result += escapeSeq || encodeHex(char);
2415
- }
2416
- }
2417
- return result;
2418
- }
2419
- function writeFlowSequence(state, level, object) {
2420
- var _result = "", _tag = state.tag, index, length, value;
2421
- for (index = 0, length = object.length; index < length; index += 1) {
2422
- value = object[index];
2423
- if (state.replacer) {
2424
- value = state.replacer.call(object, String(index), value);
2425
- }
2426
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2427
- if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2428
- _result += state.dump;
2429
- }
2430
- }
2431
- state.tag = _tag;
2432
- state.dump = "[" + _result + "]";
2433
- }
2434
- function writeBlockSequence(state, level, object, compact) {
2435
- var _result = "", _tag = state.tag, index, length, value;
2436
- for (index = 0, length = object.length; index < length; index += 1) {
2437
- value = object[index];
2438
- if (state.replacer) {
2439
- value = state.replacer.call(object, String(index), value);
2440
- }
2441
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2442
- if (!compact || _result !== "") {
2443
- _result += generateNextLine(state, level);
2444
- }
2445
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2446
- _result += "-";
2447
- } else {
2448
- _result += "- ";
2449
- }
2450
- _result += state.dump;
2451
- }
2452
- }
2453
- state.tag = _tag;
2454
- state.dump = _result || "[]";
2455
- }
2456
- function writeFlowMapping(state, level, object) {
2457
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2458
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2459
- pairBuffer = "";
2460
- if (_result !== "") pairBuffer += ", ";
2461
- if (state.condenseFlow) pairBuffer += '"';
2462
- objectKey = objectKeyList[index];
2463
- objectValue = object[objectKey];
2464
- if (state.replacer) {
2465
- objectValue = state.replacer.call(object, objectKey, objectValue);
2466
- }
2467
- if (!writeNode(state, level, objectKey, false, false)) {
2468
- continue;
2469
- }
2470
- if (state.dump.length > 1024) pairBuffer += "? ";
2471
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2472
- if (!writeNode(state, level, objectValue, false, false)) {
2473
- continue;
2474
- }
2475
- pairBuffer += state.dump;
2476
- _result += pairBuffer;
2477
- }
2478
- state.tag = _tag;
2479
- state.dump = "{" + _result + "}";
2480
- }
2481
- function writeBlockMapping(state, level, object, compact) {
2482
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2483
- if (state.sortKeys === true) {
2484
- objectKeyList.sort();
2485
- } else if (typeof state.sortKeys === "function") {
2486
- objectKeyList.sort(state.sortKeys);
2487
- } else if (state.sortKeys) {
2488
- throw new exception("sortKeys must be a boolean or a function");
2489
- }
2490
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2491
- pairBuffer = "";
2492
- if (!compact || _result !== "") {
2493
- pairBuffer += generateNextLine(state, level);
2494
- }
2495
- objectKey = objectKeyList[index];
2496
- objectValue = object[objectKey];
2497
- if (state.replacer) {
2498
- objectValue = state.replacer.call(object, objectKey, objectValue);
2499
- }
2500
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2501
- continue;
2502
- }
2503
- explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2504
- if (explicitPair) {
2505
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2506
- pairBuffer += "?";
2507
- } else {
2508
- pairBuffer += "? ";
2509
- }
2510
- }
2511
- pairBuffer += state.dump;
2512
- if (explicitPair) {
2513
- pairBuffer += generateNextLine(state, level);
2514
- }
2515
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2516
- continue;
2517
- }
2518
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2519
- pairBuffer += ":";
2520
- } else {
2521
- pairBuffer += ": ";
2522
- }
2523
- pairBuffer += state.dump;
2524
- _result += pairBuffer;
2525
- }
2526
- state.tag = _tag;
2527
- state.dump = _result || "{}";
2528
- }
2529
- function detectType(state, object, explicit) {
2530
- var _result, typeList, index, length, type2, style;
2531
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
2532
- for (index = 0, length = typeList.length; index < length; index += 1) {
2533
- type2 = typeList[index];
2534
- if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
2535
- if (explicit) {
2536
- if (type2.multi && type2.representName) {
2537
- state.tag = type2.representName(object);
2538
- } else {
2539
- state.tag = type2.tag;
2540
- }
2541
- } else {
2542
- state.tag = "?";
2543
- }
2544
- if (type2.represent) {
2545
- style = state.styleMap[type2.tag] || type2.defaultStyle;
2546
- if (_toString.call(type2.represent) === "[object Function]") {
2547
- _result = type2.represent(object, style);
2548
- } else if (_hasOwnProperty.call(type2.represent, style)) {
2549
- _result = type2.represent[style](object, style);
2550
- } else {
2551
- throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
2552
- }
2553
- state.dump = _result;
2554
- }
2555
- return true;
2556
- }
2557
- }
2558
- return false;
2559
- }
2560
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
2561
- state.tag = null;
2562
- state.dump = object;
2563
- if (!detectType(state, object, false)) {
2564
- detectType(state, object, true);
2565
- }
2566
- var type2 = _toString.call(state.dump);
2567
- var inblock = block;
2568
- var tagStr;
2569
- if (block) {
2570
- block = state.flowLevel < 0 || state.flowLevel > level;
2571
- }
2572
- var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
2573
- if (objectOrArray) {
2574
- duplicateIndex = state.duplicates.indexOf(object);
2575
- duplicate = duplicateIndex !== -1;
2576
- }
2577
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2578
- compact = false;
2579
- }
2580
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
2581
- state.dump = "*ref_" + duplicateIndex;
2582
- } else {
2583
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2584
- state.usedDuplicates[duplicateIndex] = true;
2585
- }
2586
- if (type2 === "[object Object]") {
2587
- if (block && Object.keys(state.dump).length !== 0) {
2588
- writeBlockMapping(state, level, state.dump, compact);
2589
- if (duplicate) {
2590
- state.dump = "&ref_" + duplicateIndex + state.dump;
2591
- }
2592
- } else {
2593
- writeFlowMapping(state, level, state.dump);
2594
- if (duplicate) {
2595
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2596
- }
2597
- }
2598
- } else if (type2 === "[object Array]") {
2599
- if (block && state.dump.length !== 0) {
2600
- if (state.noArrayIndent && !isblockseq && level > 0) {
2601
- writeBlockSequence(state, level - 1, state.dump, compact);
2602
- } else {
2603
- writeBlockSequence(state, level, state.dump, compact);
2604
- }
2605
- if (duplicate) {
2606
- state.dump = "&ref_" + duplicateIndex + state.dump;
2607
- }
2608
- } else {
2609
- writeFlowSequence(state, level, state.dump);
2610
- if (duplicate) {
2611
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2612
- }
2613
- }
2614
- } else if (type2 === "[object String]") {
2615
- if (state.tag !== "?") {
2616
- writeScalar(state, state.dump, level, iskey, inblock);
2617
- }
2618
- } else if (type2 === "[object Undefined]") {
2619
- return false;
2620
- } else {
2621
- if (state.skipInvalid) return false;
2622
- throw new exception("unacceptable kind of an object to dump " + type2);
2623
- }
2624
- if (state.tag !== null && state.tag !== "?") {
2625
- tagStr = encodeURI(
2626
- state.tag[0] === "!" ? state.tag.slice(1) : state.tag
2627
- ).replace(/!/g, "%21");
2628
- if (state.tag[0] === "!") {
2629
- tagStr = "!" + tagStr;
2630
- } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
2631
- tagStr = "!!" + tagStr.slice(18);
2632
- } else {
2633
- tagStr = "!<" + tagStr + ">";
2634
- }
2635
- state.dump = tagStr + " " + state.dump;
2636
- }
2637
- }
2638
- return true;
2639
- }
2640
- function getDuplicateReferences(object, state) {
2641
- var objects = [], duplicatesIndexes = [], index, length;
2642
- inspectNode(object, objects, duplicatesIndexes);
2643
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2644
- state.duplicates.push(objects[duplicatesIndexes[index]]);
2645
- }
2646
- state.usedDuplicates = new Array(length);
2647
- }
2648
- function inspectNode(object, objects, duplicatesIndexes) {
2649
- var objectKeyList, index, length;
2650
- if (object !== null && typeof object === "object") {
2651
- index = objects.indexOf(object);
2652
- if (index !== -1) {
2653
- if (duplicatesIndexes.indexOf(index) === -1) {
2654
- duplicatesIndexes.push(index);
2655
- }
2656
- } else {
2657
- objects.push(object);
2658
- if (Array.isArray(object)) {
2659
- for (index = 0, length = object.length; index < length; index += 1) {
2660
- inspectNode(object[index], objects, duplicatesIndexes);
2661
- }
2662
- } else {
2663
- objectKeyList = Object.keys(object);
2664
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2665
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
2666
- }
2667
- }
2668
- }
2669
- }
2670
- }
2671
- function dump$1(input, options) {
2672
- options = options || {};
2673
- var state = new State(options);
2674
- if (!state.noRefs) getDuplicateReferences(input, state);
2675
- var value = input;
2676
- if (state.replacer) {
2677
- value = state.replacer.call({ "": value }, "", value);
2678
- }
2679
- if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
2680
- return "";
2681
- }
2682
- var dump_1 = dump$1;
2683
- var dumper = {
2684
- dump: dump_1
2685
- };
2686
- function renamed(from, to) {
2687
- return function() {
2688
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
2689
- };
2690
- }
2691
- var Type = type;
2692
- var Schema = schema;
2693
- var FAILSAFE_SCHEMA = failsafe;
2694
- var JSON_SCHEMA = json;
2695
- var CORE_SCHEMA = core;
2696
- var DEFAULT_SCHEMA = _default;
2697
- var load = loader.load;
2698
- var loadAll = loader.loadAll;
2699
- var dump = dumper.dump;
2700
- var YAMLException = exception;
2701
- var types = {
2702
- binary,
2703
- float,
2704
- map,
2705
- null: _null,
2706
- pairs,
2707
- set,
2708
- timestamp,
2709
- bool,
2710
- int,
2711
- merge,
2712
- omap,
2713
- seq,
2714
- str
2715
- };
2716
- var safeLoad = renamed("safeLoad", "load");
2717
- var safeLoadAll = renamed("safeLoadAll", "loadAll");
2718
- var safeDump = renamed("safeDump", "dump");
2719
- var jsYaml = {
2720
- Type,
2721
- Schema,
2722
- FAILSAFE_SCHEMA,
2723
- JSON_SCHEMA,
2724
- CORE_SCHEMA,
2725
- DEFAULT_SCHEMA,
2726
- load,
2727
- loadAll,
2728
- dump,
2729
- YAMLException,
2730
- types,
2731
- safeLoad,
2732
- safeLoadAll,
2733
- safeDump
2734
- };
2735
- var js_yaml_default = jsYaml;
2736
-
2737
- // src/analytics-manager.ts
116
+ import yaml from "js-yaml";
2738
117
  import ora from "ora";
2739
118
  import { table } from "table";
2740
119
  var AnalyticsManager = class {
@@ -3157,7 +536,7 @@ var AnalyticsManager = class {
3157
536
  "gtm.config.yaml not found. Please create the configuration file first."
3158
537
  );
3159
538
  }
3160
- const config = js_yaml_default.load(yamlContent);
539
+ const config = yaml.load(yamlContent);
3161
540
  spinner.text = "Querying current GTM state...";
3162
541
  const variablesResult = await this.clients.gtm.listVariables();
3163
542
  if (variablesResult.success && variablesResult.data) {
@@ -3178,7 +557,7 @@ var AnalyticsManager = class {
3178
557
  }
3179
558
  }
3180
559
  spinner.text = "Writing updated configuration...";
3181
- const updatedYaml = js_yaml_default.dump(config, {
560
+ const updatedYaml = yaml.dump(config, {
3182
561
  indent: 2,
3183
562
  lineWidth: -1,
3184
563
  quotingType: '"',
@@ -5194,8 +2573,8 @@ ${validation.errors.join("\n")}`
5194
2573
  /**
5195
2574
  * Normalize parameter map structures for GTM API (convert lowercase types to uppercase)
5196
2575
  */
5197
- normalizeParameterMap(map2) {
5198
- return map2.map((item) => ({
2576
+ normalizeParameterMap(map) {
2577
+ return map.map((item) => ({
5199
2578
  ...item,
5200
2579
  type: item.type?.toUpperCase() || "TEMPLATE",
5201
2580
  ...item.map && { map: this.normalizeParameterMap(item.map) },
@@ -5456,7 +2835,7 @@ ${validation.errors.join("\n")}`
5456
2835
  * Map tag type codes to full GTM API type names
5457
2836
  * CRITICAL: Auto-corrects googtag to gaawe for GA4 event tags
5458
2837
  */
5459
- mapTagType(type2, yamlConfig) {
2838
+ mapTagType(type, yamlConfig) {
5460
2839
  const typeMap = {
5461
2840
  googtag: "googtag",
5462
2841
  // Google Tag (basic config only - NOT for events)
@@ -5481,13 +2860,13 @@ ${validation.errors.join("\n")}`
5481
2860
  fls: "fls"
5482
2861
  // Floodlight Sales
5483
2862
  };
5484
- if (type2 === "googtag" && yamlConfig && this.isGA4EventTag(yamlConfig)) {
2863
+ if (type === "googtag" && yamlConfig && this.isGA4EventTag(yamlConfig)) {
5485
2864
  console.log(
5486
2865
  `[AUTO-CORRECT] Converting tag "${yamlConfig.name}" from type "googtag" to "gaawe" (GA4 Event Tag)`
5487
2866
  );
5488
2867
  return "gaawe";
5489
2868
  }
5490
- return typeMap[type2] || type2;
2869
+ return typeMap[type] || type;
5491
2870
  }
5492
2871
  /**
5493
2872
  * Get parameter type for tag parameters
@@ -5597,7 +2976,7 @@ ${validation.errors.join("\n")}`
5597
2976
  /**
5598
2977
  * Map trigger type codes to full GTM API type names
5599
2978
  */
5600
- mapTriggerType(type2) {
2979
+ mapTriggerType(type) {
5601
2980
  const typeMap = {
5602
2981
  pageview: "pageview",
5603
2982
  domReady: "domReady",
@@ -5611,7 +2990,7 @@ ${validation.errors.join("\n")}`
5611
2990
  scrollDepth: "scrollDepth",
5612
2991
  youtubeVideo: "youtubeVideo"
5613
2992
  };
5614
- return typeMap[type2] || type2;
2993
+ return typeMap[type] || type;
5615
2994
  }
5616
2995
  /**
5617
2996
  * Filter trigger fields for update operations
@@ -5805,7 +3184,7 @@ ${validation.errors.join("\n")}`
5805
3184
  /**
5806
3185
  * Map short variable type codes to full GTM API type names (LEGACY - for display purposes)
5807
3186
  */
5808
- mapVariableType(type2) {
3187
+ mapVariableType(type) {
5809
3188
  const typeMap = {
5810
3189
  c: "Constant",
5811
3190
  constant: "Constant",
@@ -5822,12 +3201,12 @@ ${validation.errors.join("\n")}`
5822
3201
  r: "Referrer",
5823
3202
  gas: "Google Analytics Settings"
5824
3203
  };
5825
- return typeMap[type2] || type2;
3204
+ return typeMap[type] || type;
5826
3205
  }
5827
3206
  /**
5828
3207
  * Map variable type codes to GTM API format (keep short codes, normalize long names to short codes)
5829
3208
  */
5830
- mapVariableTypeForGTMApi(type2) {
3209
+ mapVariableTypeForGTMApi(type) {
5831
3210
  const typeMap = {
5832
3211
  // Short codes remain as-is (these are what GTM API wants)
5833
3212
  c: "c",
@@ -5859,7 +3238,7 @@ ${validation.errors.join("\n")}`
5859
3238
  autoEvent: "aev",
5860
3239
  autoEventVariable: "aev"
5861
3240
  };
5862
- return typeMap[type2] || type2;
3241
+ return typeMap[type] || type;
5863
3242
  }
5864
3243
  /**
5865
3244
  * GTM API rate limiter: 0.25 QPS (1 request every 4 seconds)
@@ -6107,7 +3486,7 @@ Total resources: ${state.resources.length}`));
6107
3486
  } else if (options.format === "yaml") {
6108
3487
  const configParser = new ConfigParser();
6109
3488
  const config = configParser.stateToConfig(state);
6110
- console.log(js_yaml_default.dump(config));
3489
+ console.log(yaml.dump(config));
6111
3490
  } else {
6112
3491
  console.log(JSON.stringify(state, null, 2));
6113
3492
  }
@@ -6134,10 +3513,10 @@ Total resources: ${state.resources.length}`));
6134
3513
  )
6135
3514
  );
6136
3515
  if (config.resources) {
6137
- for (const [type2, resources] of Object.entries(config.resources)) {
3516
+ for (const [type, resources] of Object.entries(config.resources)) {
6138
3517
  if (Array.isArray(resources)) {
6139
3518
  console.log(
6140
- chalk.blue(` - ${type2}: ${resources.length} resources`)
3519
+ chalk.blue(` - ${type}: ${resources.length} resources`)
6141
3520
  );
6142
3521
  }
6143
3522
  }
@@ -6179,8 +3558,8 @@ Total resources: ${state.resources.length}`));
6179
3558
  async gtmTerraformStateShow(options) {
6180
3559
  try {
6181
3560
  const stateManager = new StateManager();
6182
- const [type2, name] = options.address.split(".");
6183
- const resource = await stateManager.getResource(type2, name);
3561
+ const [type, name] = options.address.split(".");
3562
+ const resource = await stateManager.getResource(type, name);
6184
3563
  if (!resource) {
6185
3564
  console.log(
6186
3565
  chalk.yellow(`Resource ${options.address} not found in state`)
@@ -6202,8 +3581,8 @@ Total resources: ${state.resources.length}`));
6202
3581
  const spinner = ora(`Removing ${options.address} from state...`).start();
6203
3582
  try {
6204
3583
  const stateManager = new StateManager();
6205
- const [type2, name] = options.address.split(".");
6206
- const result = await stateManager.removeResource(type2, name);
3584
+ const [type, name] = options.address.split(".");
3585
+ const result = await stateManager.removeResource(type, name);
6207
3586
  if (result.success) {
6208
3587
  spinner.succeed(`Removed ${options.address} from state`);
6209
3588
  } else {
@@ -8747,9 +6126,4 @@ try {
8747
6126
  export {
8748
6127
  program
8749
6128
  };
8750
- /*! Bundled license information:
8751
-
8752
- js-yaml/dist/js-yaml.mjs:
8753
- (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
8754
- */
8755
6129
  //# sourceMappingURL=cli.js.map